void insert_constraint(CT& ct,PointIterator first, PointIterator last, bool close=false) { typedef typename CT::Vertex_handle VertexHandle; typedef typename CT::Geom_traits::Point_2 Point; if(first == last){ return; } const Point& p0 = *first; Point p = p0; VertexHandle v0 = ct.insert(p0), v(v0), w(v0); ++first; for(; first!=last; ++first){ const Point& q = *first; if(p != q){ w = ct.insert(q); ct.insert_constraint(v,w); v = w; p = q; } } if(close && (p != p0)){ ct.insert(w,v0); } }
bool registerComponentTable(CT& component_table) { if (component_tables_.find(CT::GetStaticName()) != component_tables_.end()) { return false; } component_tables_.emplace(CT::GetStaticName(), component_table); component_table.setContext(this); return true; };
void run() { typedef typename Space::execution_space ExecSpace; TestViewMappingSubview< ExecSpace > self; ASSERT_EQ( Aa.extent(0), AN ); ASSERT_EQ( Ab.extent(0), AN - 2 ); ASSERT_EQ( Ac.extent(0), AN - 2 ); ASSERT_EQ( Ba.extent(0), BN0 ); ASSERT_EQ( Ba.extent(1), BN1 ); ASSERT_EQ( Ba.extent(2), BN2 ); ASSERT_EQ( Bb.extent(0), BN0 - 2 ); ASSERT_EQ( Bb.extent(1), BN1 - 2 ); ASSERT_EQ( Bb.extent(2), BN2 - 2 ); ASSERT_EQ( Ca.extent(0), CN0 ); ASSERT_EQ( Ca.extent(1), CN1 ); ASSERT_EQ( Ca.extent(2), CN2 ); ASSERT_EQ( Ca.extent(3), 13 ); ASSERT_EQ( Ca.extent(4), 14 ); ASSERT_EQ( Cb.extent(0), CN0 - 2 ); ASSERT_EQ( Cb.extent(1), CN1 - 2 ); ASSERT_EQ( Cb.extent(2), CN2 - 2 ); ASSERT_EQ( Da.extent(0), DN0 ); ASSERT_EQ( Da.extent(1), DN1 ); ASSERT_EQ( Da.extent(2), DN2 ); ASSERT_EQ( Da.extent(3), DN3 ); ASSERT_EQ( Da.extent(4), DN4 ); ASSERT_EQ( Db.extent(0), DN1 - 2 ); ASSERT_EQ( Db.extent(1), DN2 - 2 ); ASSERT_EQ( Db.extent(2), DN3 - 2 ); ASSERT_EQ( Da.stride_1(), Db.stride_0() ); ASSERT_EQ( Da.stride_2(), Db.stride_1() ); ASSERT_EQ( Da.stride_3(), Db.stride_2() ); long error_count = -1; Kokkos::parallel_reduce( Kokkos::RangePolicy< ExecSpace >( 0, 1 ), *this, error_count ); ASSERT_EQ( error_count, 0 ); }
static void markDomains(CT& ct) { typedef typename CT::Face_handle FaceHandle; typedef typename CT::Edge Edge; QList<Edge> border; markDomain(ct, ct.infinite_face(), 0, border); while(!border.isEmpty()) { Edge e=border.takeFirst(); FaceHandle c=e.first; FaceHandle n=c->neighbor(e.second); if(!n->info().isNested()) { markDomain(ct, n, c->info().nestingLevel+1, border); } } }
static void markDomain(CT& ct,FaceHandle start,int index,QList<Edge>& border) { QList<FaceHandle> queue; queue.append(start); while(!queue.isEmpty()) { FaceHandle fh=queue.takeFirst(); fh->info().nestingLevel=index; for(auto i=0; i<3; ++i) { FaceHandle n=fh->neighbor(i); if(!n->info().isNested()) { Edge e(fh,i); if(ct.is_constrained(e)) border.append(e); else queue.append(n); } } } }
int main() { CT ct; Polygon_2 P; while(std::cin >> P){ ct.insert_constraint(P); } PS::simplify(ct, Cost(), Stop(0.5)); for(Constraint_iterator cit = ct.constraints_begin(); cit != ct.constraints_end(); ++cit) { std::cout << "simplified polyline" << std::endl; for(Points_in_constraint_iterator vit = ct.points_in_constraint_begin(*cit); vit != ct.points_in_constraint_end(*cit); ++vit) std::cout << *vit << std::endl; } return 0; }
bool isPresent(const VT & value, CT & container) { return (std::find(container.begin(), container.end(), value) != container.end()); }
bool CGALBuilder::triangulate() { typedef CGAL::Triangulation_vertex_base_with_info_2<VertexInfo,CGAL::Kernel3> VertexBase; typedef CGAL::Triangulation_face_base_with_info_2<FaceInfo,CGAL::Kernel3> Info; typedef CGAL::Constrained_triangulation_face_base_2<CGAL::Kernel3,Info> FaceBase; typedef CGAL::Triangulation_data_structure_2<VertexBase,FaceBase> TDS; typedef CGAL::Exact_predicates_tag Tag; typedef CGAL::Constrained_triangulation_2<CGAL::Kernel3,TDS,Tag> CT; typedef CT::Vertex_handle VertexHandle; typedef CT::Face_iterator FaceIterator; QList<CGAL::Point3> points3=primitive.getPoints(); int total=points3.size(); if(total<3) return false; else if(total==3) return true; CT ct; TDS::size_type count=0; for(CGALPolygon* pg: primitive.getCGALPolygons()) { QList<int> indexes=pg->getIndexes(); if(indexes.size()<3) continue; CGALProjection* pro=pg->getProjection(); QList<CGAL::Point2> points2; for(auto i: indexes) { CGAL::Point2 p2=pro->project(points3.at(i)); VertexHandle h=ct.insert(p2); h->info().index = i; points2.append(p2); ++count; } #if CGAL_VERSION_NR < CGAL_VERSION_NUMBER(4,6,0) insert_constraint(ct,points2.begin(),points2.end(),true); #else ct.insert_constraint(points2.begin(),points2.end(),true); #endif } if(count<3||ct.number_of_vertices()<count) return false; if(ct.number_of_faces()>3) markDomains(ct); primitive.clearPolygons(); for(FaceIterator f=ct.finite_faces_begin(); f!=ct.finite_faces_end(); ++f) { if(f->info().inDomain()) { auto* pg=primitive.createCGALPolygon(); for(auto i=0; i<3; ++i) { VertexInfo info=f->vertex(i)->info(); if(info.isValid()) pg->append(info.index); } pg->calculatePlane(); } } return true; }