本文整理汇总了C++中Tr::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ Tr::insert方法的具体用法?C++ Tr::insert怎么用?C++ Tr::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tr
的用法示例。
在下文中一共展示了Tr::insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FT
void
_test_surface_neighbors_3_sphere( const Tr & )
{
Tr T;
int n=200, m=20;
double r = 3;
typedef typename Tr::Geom_traits Gt;
typedef typename Gt::Point_3 Point;
std::vector<Point> points;
points.reserve(n+m);
// Create n+m-4 points on a sphere of radius 2
CGAL::Random_points_on_sphere_3<Point> g(r);
CGAL::cpp11::copy_n( g, n+m, std::back_inserter(points));
for(int i=0; i<n ; i++)
T.insert(points[i]);
//test with different calls:
int k=0;
for(int i=n;i<n+m;i++)
{
test_coords_and_neighbors(T, points[i],
typename Gt::Vector_3(points[i]-CGAL::ORIGIN),
typename Gt::FT(0.5),++k % 8);
}
}
示例2: main
int main()
{
Tr::Point p1(0,0,0);
Tr::Point p2(1,0,0);
Tr::Point p3(0,1,0);
Tr::Point p4(0,0,1);
Tr tr;
tr.insert(p1);
tr.insert(p2);
tr.insert(p3);
tr.insert(p4);
Tr::Cell_handle ch = tr.finite_cells_begin();
int k = 0;
Tr::Facet f = std::make_pair(ch,k);
Tr::Cell::Subdomain_index sub_index = 1;
Tr::Cell::Surface_patch_index surf_index = 2;
Tr::Cell::Surface_patch_index surf_index_bis = 21;
Tr::Vertex::Index index (surf_index);
Tr::Vertex::Index index_bis(surf_index_bis);
// Init cell
tr.dual(ch);
ch->set_subdomain_index(sub_index);
// Init facet
Tr::Bare_point facet_circum =
tr.geom_traits().construct_weighted_circumcenter_3_object()(
tr.point(ch, k+1), tr.point(ch, k+2), tr.point(ch, k+3));
ch->set_surface_patch_index(k,surf_index);
ch->set_facet_surface_center(k,facet_circum);
ch->set_facet_surface_center_index(k,index);
// Init vertices
ch->vertex(0)->set_dimension(2);
ch->vertex(1)->set_dimension(2);
ch->vertex(2)->set_dimension(2);
ch->vertex(3)->set_dimension(2);
ch->vertex(0)->set_index(index);
ch->vertex(1)->set_index(index);
ch->vertex(2)->set_index(index_bis);
ch->vertex(3)->set_index(index_bis);
// -----------------------------------
// Test edge criteria
// -----------------------------------
Tr::Bare_point bp1 = tr.geom_traits().construct_point_3_object()(p1);
Mc ec1(edge_size = 1);
assert( ec1.edge_criteria_object().sizing_field(bp1,1,index) == 1 );
Mc ec2(edge_sizing_field = Esf(2));
assert( ec2.edge_criteria_object().sizing_field(bp1,1,index) == 2 );
Mc ec3(edge_sizing_field = 3.);
assert( ec3.edge_criteria_object().sizing_field(bp1,1,index) == 3 );
Mc ec4(edge_size = 4.1,
edge_sizing_field = Esf(4.2));
assert( ec4.edge_criteria_object().sizing_field(bp1,1,index) == 4.1 );
Mc ec5(sizing_field = 5.);
assert( ec5.edge_criteria_object().sizing_field(bp1,1,index) == 5 );
Mc ec6(sizing_field = 6.1,
edge_sizing_field = 6.2);
assert( ec6.edge_criteria_object().sizing_field(bp1,1,index) == 6.2 );
Mc ec7(sizing_field = 7.1,
edge_size = 7.2);
assert( ec7.edge_criteria_object().sizing_field(bp1,1,index) == 7.2 );
// -----------------------------------
// Test facet criteria
// -----------------------------------
typedef Tr::Geom_traits::FT FT;
Tr::Geom_traits::Compute_squared_radius_3 squared_radius = tr.geom_traits().compute_squared_radius_3_object();
Tr::Geom_traits::Construct_point_3 cp = tr.geom_traits().construct_point_3_object();
FT radius_facet = CGAL::sqrt(squared_radius(cp(tr.point(ch, k+1)),
cp(tr.point(ch, k+2)),
cp(tr.point(ch, k+3))));
FT facet_size_ok = radius_facet*FT(10);
FT facet_size_nok = radius_facet/FT(10);
Mc fc1(facet_size = facet_size_ok);
assert( ! fc1.facet_criteria_object()(tr, f) );
Mc fc2(facet_sizing_field = facet_size_ok);
assert( ! fc2.facet_criteria_object()(tr, f) );
Mc fc3(facet_sizing_field = Fsf(facet_size_ok));
assert( ! fc3.facet_criteria_object()(tr, f) );
Mc fc4(facet_sizing_field = facet_size_nok,
//.........这里部分代码省略.........
示例3: g
void
_test_surface_neighbors_3_cube(const Tr &, const Transformation&
transform, const int n = 75,
typename Tr::Geom_traits::FT tolerance = typename Tr::Geom_traits::FT(1e-29),
bool grid=true)
{
Tr T;
int m=10;
double r = 3;
typedef typename Tr::Geom_traits Gt;
typedef typename Gt::FT Coord_type;
typedef typename Gt::Point_3 Point;
typedef typename Gt::Point_2 Point_2;
typedef typename Gt::Vector_3 Vector;
//data points: generate random points in a square of length r
std::vector<Point_2> points_2_data;
points_2_data.reserve(n);
if(grid)
{
CGAL::points_on_square_grid_2(r, n, std::back_inserter(points_2_data),
CGAL::Creator_uniform_2<Coord_type,Point_2>());
}
else
{
CGAL::Random_points_in_square_2<Point_2> g(r);
CGAL::cpp11::copy_n(g, n, std::back_inserter(points_2_data));
}
for(int i=0; i < n; i++)
{
T.insert(transform(Point(points_2_data[i].x(),points_2_data[i].y(), -r)));
T.insert(transform(Point(points_2_data[i].x(),points_2_data[i].y(), r)));
T.insert(transform(Point(-r, points_2_data[i].x(),points_2_data[i].y())));
T.insert(transform(Point(r, points_2_data[i].x(), points_2_data[i].y())));
T.insert(transform(Point(points_2_data[i].x(), -r, points_2_data[i].y())));
T.insert(transform(Point(points_2_data[i].x(), r, points_2_data[i].y())));
}
//test_points: generate random points in a square of length r
std::vector<Point_2> points_2_test;
points_2_test.reserve(m);
CGAL::Random_points_in_square_2<Point_2> g2(r-1.0);
CGAL::cpp11::copy_n(g2, m, std::back_inserter(points_2_test));
int k=0;
for(int i=0;i<m;i++)
{
//test point on z=r plane:
test_coords_and_neighbors(T,transform(Point(points_2_test[i].x(),
points_2_test[i].y(), r)),
transform(Vector(0,0,1)),tolerance, ++k % 8);
//test point on x=-r plane:
test_coords_and_neighbors(T,transform(Point(-r, points_2_test[i].x(),
points_2_test[i].y())),
transform(Vector(-1,0,0)),tolerance, ++k % 8 );
//test point on x=r plane:
test_coords_and_neighbors(T,transform(Point(r, points_2_test[i].x(),
points_2_test[i].y())),
transform(Vector(1,0,0)),tolerance,++k % 8 );
//test point on y=-r plane:
test_coords_and_neighbors(T,transform(Point(points_2_test[i].x(),
-r,points_2_test[i].y())),
transform(Vector(0,-1,0)),tolerance,++k % 8 );
//test point on y=r plane:
test_coords_and_neighbors(T,transform(Point(points_2_test[i].x(),
r,points_2_test[i].y())),
transform(Vector(0,1,0)),tolerance,++k % 8);
}
//test a sample point:
//with Delaunay triangulation filering:
test_coords_and_neighbors(T,transform(Point(points_2_data[n/2].x(),
points_2_data[n/2].y(), r)),
transform(Vector(0,0,1)),Coord_type(0),0);
//considering all points:
test_coords_and_neighbors(T,transform(Point(points_2_data[n/2].x(),
points_2_data[n/2].y(), r)),
transform(Vector(0,0,1)),Coord_type(0),4);
}