本文整理汇总了C++中Tr::finite_cells_begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Tr::finite_cells_begin方法的具体用法?C++ Tr::finite_cells_begin怎么用?C++ Tr::finite_cells_begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tr
的用法示例。
在下文中一共展示了Tr::finite_cells_begin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int , char** argv)
{
Tr tr;
C2T3 c2t3(tr);
std::ifstream ifs(argv[1]);
if( !ifs )
{
std::cerr << "Usage:\n"
<< " " << argv[0] << " FILE\n"
<< "\n"
<< " FILE must be " << format_cgal_description
<< "\n";
return EXIT_FAILURE;
}
std::cout << " Reading " << argv[1] << std::endl;
if( CGAL::Mesh_3::input_mesh(ifs, c2t3,
true,
&std::cerr) )
// if( CGAL::input_pslg_from_medit(ifs,
// c2t3,
// true, // debug
// &std::cout) ) // debug to cout
{
display_faces_counts(tr, " ", &std::cout);
std::cout << "\n Statistics:\n";
std::cout << "(vertices)\n";
display_vertices_by_surface_indices_statistics(tr, " ", &std::cout);
std::cout << "(facets)\n";
display_facets_by_surface_indices_statistics(c2t3, " ", &std::cout);
Compute_min_angle<Tr> min_angle(tr);
double min = 180;
for(Tr::Finite_cells_iterator cit = tr.finite_cells_begin();
cit != tr.finite_cells_end();
++cit)
if(cit->is_in_domain())
{
const double angle = min_angle(cit);
if( angle < min ) min = angle;
}
std::cout << "\nmin angle: " << min << "\n";
return EXIT_SUCCESS;
}
else
return EXIT_FAILURE;
}
示例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: main
int main()
{
CGAL::Timer t;
t.start();
// Define functions
Function f1(&torus_function);
Function f2(&sphere_function<5>);
Function f3(&tanglecube_function);
Function f4(&heart_function);
Function f5(&klein_function);
Function f6(&false_knot_function);
Function f7(&knot1_function);
Function f8(&octic_function);
Function_vector v;
v.push_back(&f1);
//v.push_back(&f2);
//v.push_back(&f3);
//v.push_back(&f4);
//v.push_back(&f5);
//v.push_back(&f6);
//v.push_back(&f7);
//v.push_back(&f8);
// Domain (Warning: Sphere_3 constructor uses square radius !)
Mesh_domain domain(v, K::Sphere_3(CGAL::ORIGIN, 5.*5.), 1e-6);
// Set mesh criteria
Facet_criteria facet_criteria(30, 0.2, 0.02); // angle, size, approximation
Cell_criteria cell_criteria(2., 0.4); // radius-edge ratio, size
Mesh_criteria criteria(facet_criteria, cell_criteria);
// Mesh generation
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria, no_exude(), no_perturb());
// Perturbation (maximum cpu time: 10s, targeted dihedral angle: default)
CGAL::perturb_mesh_3(c3t3, domain, time_limit = 10);
// Exudation
CGAL::exude_mesh_3(c3t3,12);
CGAL::Random rand;
t.stop();
std::cout << "Time elapsed for building the mesh: " << t.time() << std::endl;
t.reset();
t.start();
int nr = 1500;
std::vector<Point> points;
points.reserve(nr);
CGAL::Random_points_in_mesh_3<Point, C3t3, FastPolicy> g(c3t3);
t.stop();
std::cout << "Time elapsed for init Random_points_in_mesh_3: " <<
t.time() << std::endl;
t.reset();
t.start();
CGAL::cpp11::copy_n( g, nr, std::back_inserter(points));
t.stop();
std::cout << "Time elapsed for generating the points: " << t.time() << std::endl;
t.reset();
Tr tr = c3t3.triangulation();
Tetrahedron3 tet;
Tr::Finite_cells_iterator it = tr.finite_cells_begin();
for (; it != tr.finite_cells_end(); it++) {
if (c3t3.is_in_complex(it)) {
tet = tr.tetrahedron(it);
break;
}
}
t.start();
std::vector<Point> points_tet;
points_tet.reserve(nr);
CGAL::Random_points_in_tetrahedron_3<Point> g1(tet);
CGAL::cpp11::copy_n(g1, nr, std::back_inserter(points_tet));
t.stop();
std::cout << "Time elapsed for " << nr << " points in one tetrahedron: " <<
t.time() << std::endl;
t.reset();
std::cout << "The generated points are: " << std::endl;
for (int i = 0; i < nr; i++) {
std::cout << points[i].x() << " " << points[i].y() << " " <<
points[i].z() << std::endl;
}
points_tet.clear();
points.clear();
v.clear();
return 0;
}