本文整理汇总了C++中cdt::Finite_faces_iterator::is_valid方法的典型用法代码示例。如果您正苦于以下问题:C++ Finite_faces_iterator::is_valid方法的具体用法?C++ Finite_faces_iterator::is_valid怎么用?C++ Finite_faces_iterator::is_valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cdt::Finite_faces_iterator
的用法示例。
在下文中一共展示了Finite_faces_iterator::is_valid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
//construct two non-intersecting nested polygons
Polygon_2 polygon1;
polygon1.push_back(Point_2(0.0, 0.0));
polygon1.push_back(Point_2(2.0, 0.0));
polygon1.push_back(Point_2(1.7, 1.0));
polygon1.push_back(Point_2(2.0, 2.0));
polygon1.push_back(Point_2(0.0, 2.0));
Polygon_2 polygon2;
polygon2.push_back(Point_2(0.5, 0.5));
polygon2.push_back(Point_2(1.5, 0.5));
polygon2.push_back(Point_2(1.5, 1.5));
polygon2.push_back(Point_2(0.5, 1.5));
//Insert the polyons into a constrained triangulation
CDT cdt;
insert_polygon(cdt, polygon1);
insert_polygon(cdt, polygon2);
//Extract point and provide the an index
std::vector< triangulation_point > points ;
for ( CDT::Vertex_iterator it = cdt.vertices_begin(); it != cdt.vertices_end(); ++it ){
it->info() = points.size() ;
points.push_back( it->point() );
}
//Mark facets that are inside the domain bounded by the polygon
mark_domains(cdt);
//
int count = 0;
for (CDT::Finite_faces_iterator fit = cdt.finite_faces_begin(); fit != cdt.finite_faces_end(); ++fit) {
if (fit->info().in_domain()){
++count;
}
}
/*
* export
*/
std::ofstream ofs("polygon_triangulation2.obj");
if ( ! ofs.good() ){
std::cout << "can't open file" << std::endl;
return 1 ;
}
//-- print vertices
ofs << "# " << points.size() << " vertices"<< std::endl ;
for ( size_t i = 0; i < points.size(); i++ ){
ofs << "v " << points[i] << " 0.0" << std::endl;
}
//-- print faces
ofs << "# " << cdt.number_of_faces() << " faces"<< std::endl ;
// warning : Delaunay_triangulation_2::All_faces_iterator iterator over infinite faces
for ( CDT::Finite_faces_iterator it = cdt.finite_faces_begin(); it != cdt.finite_faces_end(); ++it )
{
//ignore holes
if ( ! it->info().in_domain() ){
continue ;
}
size_t ia = it->vertex(0)->info();
size_t ib = it->vertex(1)->info();
size_t ic = it->vertex(2)->info();
assert( it->is_valid() );
//assert ( ia < cdt.number_of_vertices() || ib < tri.number_of_vertices() || ic < tri.number_of_vertices() ) ;
ofs << "f " << ( ia + 1 ) << " " << ( ib + 1 ) << " " << ( ic + 1 ) << std::endl;
}
return 0;
}