From ca4e71a1aa7d848adb90d6a8e208bc52e6849d2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 8 Nov 2016 11:10:42 +0100 Subject: [PATCH] remove trailing whitespaces --- .../CGAL/intersection_of_Polyhedra_3.h | 404 +++++++++--------- ...ection_of_Polyhedra_3_refinement_visitor.h | 234 +++++----- 2 files changed, 319 insertions(+), 319 deletions(-) diff --git a/Operations_on_polyhedra/include/CGAL/intersection_of_Polyhedra_3.h b/Operations_on_polyhedra/include/CGAL/intersection_of_Polyhedra_3.h index 3503d611aaf..35a86b6952b 100644 --- a/Operations_on_polyhedra/include/CGAL/intersection_of_Polyhedra_3.h +++ b/Operations_on_polyhedra/include/CGAL/intersection_of_Polyhedra_3.h @@ -76,11 +76,11 @@ namespace CGAL{ // for each edge incident to the vertex, we do // the same operations as in 2) // -//In case the segment intersect the triangle at one of the segment endpoint, +//In case the segment intersect the triangle at one of the segment endpoint, //we repeat the same procedure for each segment incident to this //endpoint. // -//Note that given a pair (segment,triangle)=(S,T), if S belongs +//Note that given a pair (segment,triangle)=(S,T), if S belongs //to the plane of T, we have nothing to do in the following cases: // -- no triangle T' contains S such that T and T' are coplanar // -- at least one triangle contains S @@ -129,7 +129,7 @@ struct Empty_node_visitor{ }; namespace internal_IOP{ - + template struct Compare_handles{ typedef typename Polyhedron_types::Halfedge_handle Halfedge_handle; @@ -138,8 +138,8 @@ struct Compare_handles{ typedef typename Polyhedron_types::Facet Facet; typedef typename Polyhedron_types::Facet_handle Facet_handle; typedef std::pair Vertex_handle_pair; - - static inline Vertex_handle_pair + + static inline Vertex_handle_pair make_sorted_pair_of_vertices(Halfedge_handle h) { const Vertex* v1=&(* h->vertex() ); const Vertex* v2=&(* h->opposite()->vertex() ); @@ -147,17 +147,17 @@ struct Compare_handles{ return Vertex_handle_pair(v1,v2); return Vertex_handle_pair(v2,v1); } - + bool operator()(Halfedge_handle h1,Halfedge_handle h2) const { Vertex_handle_pair p1=make_sorted_pair_of_vertices(h1); Vertex_handle_pair p2=make_sorted_pair_of_vertices(h2); - return p1 < p2; + return p1 < p2; } - + bool operator()(Facet_handle f1,Facet_handle f2) const { return &(*f1) < &(*f2); } - + bool operator()(const std::pair& p1, const std::pair& p2) const{ Halfedge* h1= (std::min) ( &(*(p1.first)), &(*(p1.first->opposite())) ); Halfedge* h2= (std::min) ( &(*(p2.first)), &(*(p2.first->opposite())) ); @@ -169,10 +169,10 @@ struct Compare_handles{ template struct Compare_handle_pairs{ typedef typename Polyhedron_types::Facet Facet; - typedef typename Polyhedron_types::Facet_handle Facet_handle; + typedef typename Polyhedron_types::Facet_handle Facet_handle; typedef std::pair Facet_pair; typedef std::pair Facet_pair_and_int; - + bool operator()(const Facet_pair& p1, const Facet_pair& p2) const{ Facet* f1=&(*p1.first); Facet* f2=&(*p2.first); @@ -202,7 +202,7 @@ struct Order_along_a_halfedge{ const Nodes_vector& nodes; Halfedge_handle hedge; PolyhedronPointPMap ppmap; - + Order_along_a_halfedge(Halfedge_handle hedge_,const Nodes_vector& nodes_, PolyhedronPointPMap ppmap):nodes(nodes_),hedge(hedge_), ppmap(ppmap){} bool operator()(int i,int j) const { //returns true, iff q lies strictly between p and r. @@ -217,7 +217,7 @@ struct Order_along_a_halfedge{ catch(CGAL::Uncertain_conversion_exception&){ return CGAL::collinear_are_strictly_ordered_along_line(nodes.to_exact(get(ppmap, hedge->vertex())), nodes.exact_node(j), - nodes.exact_node(i)); + nodes.exact_node(i)); } } }; @@ -234,33 +234,33 @@ class Split_halfedge : public CGAL::Modifier_base { unlock_halfedge(Halfedge_handle h){ return static_cast(&(*h)); } - + public: - + Split_halfedge(Halfedge_handle h) : hedge(h){} // new_hedge hedge // -----------> -----------> // v // <----------- <----------- - // new_opposite opposite - // + // new_opposite opposite + // void operator()( HDS& hds) { - + Vertex_handle v=hds.vertices_push_back(Vertex()); Halfedge_handle opposite=hedge->opposite(); - + Halfedge_handle new_hedge=hds.edges_push_back(*hedge); Halfedge_handle new_opposite=new_hedge->opposite(); - + //update next relations unlock_halfedge(new_hedge)->set_next(hedge); unlock_halfedge(new_hedge->prev())->set_next(new_hedge); unlock_halfedge(hedge)->set_prev(new_hedge); unlock_halfedge(opposite)->set_next(new_opposite); - unlock_halfedge(new_opposite)->set_prev(opposite); + unlock_halfedge(new_opposite)->set_prev(opposite); unlock_halfedge(new_opposite->next())->set_prev(new_opposite); unlock_halfedge(opposite)->set_vertex(v); @@ -281,18 +281,18 @@ public: // Warning this will split only existing edges, newly created edge intersected // by the intersection polyline won't be split template, class Kernel=typename Kernel_traits< typename boost::property_traits::value_type>::Kernel > class Node_visitor_for_polyline_split{ -//typedefs +//typedefs typedef typename Polyhedron::Halfedge_handle Halfedge_handle; typedef typename Polyhedron::Halfedge Halfedge; typedef typename Polyhedron::Vertex_handle Vertex_handle; //Info stores information about a particular intersection on an - //edge or a vertex of a polyhedron. The two first elements in - //the template describe the intersected simplex of the considered - //polyhedron; the two last elements describe the element of the + //edge or a vertex of a polyhedron. The two first elements in + //the template describe the intersected simplex of the considered + //polyhedron; the two last elements describe the element of the //second polyhedron (can be either a vertex, an edge of a facet) //involved in the intersection typedef CGAL::cpp11::tupleopposite(); coplanar_v=true; } - + if (coplanar_v) handle_on_vertex(node_id,principal_edge,type,additional_edge); else{ if ( is_on_polyline(principal_edge) ){ typename Node_to_infos_map::iterator it_res= - node_infos.insert(std::make_pair(node_id,Infos())).first; + node_infos.insert(std::make_pair(node_id,Infos())).first; it_res->second.push_back( Info(internal_IOP::EDGE,principal_edge,type,additional_edge) ); } } } - + void handle_on_vertex(int node_id,Halfedge_handle edge,internal_IOP::Intersection_type type,Halfedge_handle additional_edge){ Halfedge_handle current=edge; do{ if (is_on_polyline(current)){ typename Node_to_infos_map::iterator it_res= - node_infos.insert(std::make_pair(node_id,Infos())).first; - it_res->second.push_back( Info(internal_IOP::VERTEX,current,type,additional_edge) ); + node_infos.insert(std::make_pair(node_id,Infos())).first; + it_res->second.push_back( Info(internal_IOP::VERTEX,current,type,additional_edge) ); break; } current=current->next()->opposite(); } - while(current!=edge); + while(current!=edge); } - + Halfedge* make_unique_key(Halfedge_handle h){ if (&(*h) < &(*h->opposite())) return &(*h); else return &(*h->opposite()); } - + // new_hedge hedge // -----------> -----------> // v // <----------- <----------- - // new_opposite opposite - // + // new_opposite opposite + // void split_edge_and_retriangulate(Halfedge_handle hedge,const typename Kernel::Point_3& point,Polyhedron& P){ internal_IOP::Split_halfedge delegated(hedge); P.delegate( delegated ); @@ -388,10 +388,10 @@ class Node_visitor_for_polyline_split{ internal_IOP::Order_along_a_halfedge(hedge,nodes,ppmap) ); } - + public: static const bool do_need_vertex_graph = false; - typedef internal_IOP::Predicates_on_constructions Node_storage_type; + typedef internal_IOP::Predicates_on_constructions Node_storage_type; typedef Tag_false Is_polyhedron_const; Node_visitor_for_polyline_split(){} @@ -416,7 +416,7 @@ public: handle_principal_edge(node_id,type,principal_edge,additional_edge,is_vertex_coplanar,is_vertex_opposite_coplanar); if ( is_on_polyline(additional_edge) ){ typename Node_to_infos_map::iterator it_res= - node_infos.insert(std::make_pair(node_id,Infos())).first; + node_infos.insert(std::make_pair(node_id,Infos())).first; it_res->second.push_back( Info(type,additional_edge, ( is_vertex_coplanar||is_vertex_opposite_coplanar ) ? internal_IOP::VERTEX:internal_IOP::EDGE, is_vertex_opposite_coplanar?principal_edge->opposite():principal_edge) ); @@ -432,7 +432,7 @@ public: break; } } - + template void annotate_graph(Iterator begin,Iterator end){ for(Iterator it=begin;it!=end;++it){ @@ -441,38 +441,38 @@ public: it->make_terminal(); } } - + void update_terminal_nodes(std::vector& terminal_bools){ for (typename Node_to_infos_map::iterator it=node_infos.begin();it!=node_infos.end();++it){ terminal_bools[it->first]=true; } } - + void new_input_polyhedron(const Polyhedron&){} void start_new_polyline(int,int){} void add_node_to_polyline(int){} void set_number_of_intersection_points_from_coplanar_facets(int){} - + void add_filtered_intersection(Halfedge_handle eh,Halfedge_handle fh,Polyhedron& Pe,Polyhedron& Pf){ hedge_to_polyhedron.insert(std::make_pair(make_unique_key(eh),&Pe)); hedge_to_polyhedron.insert(std::make_pair(make_unique_key(fh),&Pf)); hedge_to_polyhedron.insert(std::make_pair(make_unique_key(fh->next()),&Pf)); hedge_to_polyhedron.insert(std::make_pair(make_unique_key(fh->next()->next()),&Pf)); } - + //split_halfedges template void finalize(const Nodes_vector& nodes){ typedef std::map, std::vector,internal_IOP::Compare_handles > Halfedges_to_split; - + Halfedges_to_split halfedges_to_split; - + for (typename Node_to_infos_map::iterator it=node_infos.begin();it!=node_infos.end();++it){ int node_id=it->first; const Infos& infos=it->second; std::map > hedges_to_split; - + //collect information about halfedge to split typename Infos::const_iterator it_info=infos.begin(); for (;it_info!=infos.end();++it_info) @@ -501,14 +501,14 @@ public: } } } - - + + //do the split for(typename Halfedges_to_split::iterator it=halfedges_to_split.begin();it!=halfedges_to_split.end();++it){ Halfedge_handle hedge=it->first.first; Polyhedron* P=it->first.second; std::vector& node_ids=it->second; - + sort_vertices_along_hedge(node_ids,hedge,nodes); for (std::vector::iterator it_id=node_ids.begin();it_id!=node_ids.end();++it_id){ split_edge_and_retriangulate(hedge,nodes[*it_id],*P); @@ -520,7 +520,7 @@ public: namespace internal_IOP{ - + template typename Exact_kernel::Point_3 compute_triangle_segment_intersection_point( @@ -534,11 +534,11 @@ namespace internal_IOP{ to_exact( get(ppmap, vf2) ), to_exact( get(ppmap, vf3) ) ); - + typename Exact_kernel::Segment_3 s (to_exact( get(ppmap, vh1) ), to_exact( get(ppmap, vh2) ) ); - + typename Exact_kernel::Intersect_3 exact_intersect=ek.intersect_3_object(); CGAL::Object inter=exact_intersect(t,s); CGAL_assertion(CGAL::do_intersect(t,s)); @@ -546,31 +546,31 @@ namespace internal_IOP{ CGAL_assertion(e_pt!=NULL); return *e_pt; } - + template typename Exact_kernel::Point_3 compute_triangle_segment_intersection_point( typename Polyhedron::Halfedge_const_handle edge, typename Polyhedron::Facet_const_handle facet, const Exact_kernel& ek, - PolyhedronPointPMap pmap) + PolyhedronPointPMap pmap) { return compute_triangle_segment_intersection_point( edge->vertex(),edge->opposite()->vertex(), facet->halfedge()->vertex(),facet->halfedge()->next()->vertex(),facet->halfedge()->opposite()->vertex(), ek, pmap); - - } - - + + } + + //A class containing a vector of the intersection points. //The third template parameter indicates whether an //exact representation is required template ::value> class Triangle_segment_intersection_points; - - + + //Store only the double version of the intersection points. template class Triangle_segment_intersection_points @@ -580,7 +580,7 @@ namespace internal_IOP{ typedef typename Polyhedron::Halfedge_const_handle Halfedge_handle; typedef typename Polyhedron::Facet_const_handle Facet_handle; typedef CGAL::Exact_predicates_exact_constructions_kernel Exact_kernel; - typedef CGAL::Cartesian_converter Exact_to_double; + typedef CGAL::Cartesian_converter Exact_to_double; //members Nodes_vector nodes; Exact_kernel ek; @@ -592,19 +592,19 @@ namespace internal_IOP{ ppmap(ppmap){} typedef CGAL::Interval_nt::Protector Protector; - + const typename Kernel::Point_3& operator[](int i) const { return nodes[i]; } - + const typename Kernel::Point_3& exact_node(int i) const {return nodes[i];} const typename Kernel::Point_3& interval_node(int i) const {return nodes[i];} const typename Kernel::Point_3& to_exact(const typename Kernel::Point_3& p) const {return p;} const typename Kernel::Point_3& to_interval(const typename Kernel::Point_3& p) const {return p;} - + size_t size() const {return nodes.size();} - + void add_new_node(const typename Exact_kernel::Point_3& p) { nodes.push_back( exact_to_double(p) ); @@ -622,7 +622,7 @@ namespace internal_IOP{ void add_new_node(const typename Kernel::Point_3& p) { nodes.push_back(p); - } + } }; // end specialization // Triangle_segment_intersection_points @@ -636,7 +636,7 @@ namespace internal_IOP{ class Triangle_segment_intersection_points { //typedefs - public: + public: typedef CGAL::Simple_cartesian > Ikernel; typedef CGAL::Exact_predicates_exact_constructions_kernel Exact_kernel; private: @@ -644,48 +644,48 @@ namespace internal_IOP{ typedef CGAL::Cartesian_converter Double_to_interval; typedef CGAL::Cartesian_converter Exact_to_interval; typedef CGAL::Cartesian_converter Double_to_exact; - + typedef typename Polyhedron::Vertex_const_handle Vertex_handle; typedef typename Polyhedron::Halfedge_const_handle Halfedge_handle; - typedef typename Polyhedron::Facet_const_handle Facet_handle; - + typedef typename Polyhedron::Facet_const_handle Facet_handle; + typedef std::vector Interval_nodes; typedef std::vector Exact_nodes; - - + + //members Interval_nodes inodes; Exact_nodes enodes; - + Interval_to_double interval_to_double; Exact_to_interval exact_to_interval; Double_to_interval double_to_interval; Double_to_exact double_to_exact; Exact_kernel ek; PolyhedronPointPMap ppmap; - + public: Triangle_segment_intersection_points(PolyhedronPointPMap ppmap): ppmap(ppmap){} - typedef CGAL::Interval_nt::Protector Protector; - + typedef CGAL::Interval_nt::Protector Protector; + typename Kernel::Point_3 operator[](int i) const { return interval_to_double(inodes[i]); } - + const typename Ikernel::Point_3& interval_node(int i) const { return inodes[i]; } - + typename Ikernel::Point_3 to_interval(const typename Kernel::Point_3& p) const { return double_to_interval(p); } - + const Exact_kernel::Point_3 exact_node(int i) const { return enodes[i]; @@ -694,9 +694,9 @@ namespace internal_IOP{ typename Exact_kernel::Point_3 to_exact(const typename Kernel::Point_3& p) const { return double_to_exact(p); - } - - + } + + size_t size() const {return enodes.size();} void add_new_node(const Exact_kernel::Point_3& p){ @@ -720,7 +720,7 @@ namespace internal_IOP{ } }; // end specialization // Triangle_segment_intersection_points - + //Third specialization: The kernel already has exact constructions. template class Triangle_segment_intersection_points @@ -745,16 +745,16 @@ namespace internal_IOP{ operator[](int i) const { return nodes[i]; } - + size_t size() const {return nodes.size();} const typename Kernel::Point_3& exact_node(int i) const {return nodes[i];} const typename Kernel::Point_3& interval_node(int i) const {return nodes[i];} - + //add a new node in the final graph. //it is the intersection of the triangle with the segment void add_new_node(Halfedge_handle edge,Facet_handle facet) { - nodes.push_back ( + nodes.push_back ( compute_triangle_segment_intersection_point(edge,facet,k,ppmap) ); } @@ -763,13 +763,13 @@ namespace internal_IOP{ { nodes.push_back(p); } - + const typename Kernel::Point_3& to_interval(const typename Kernel::Point_3& p) const { return p; } const typename Kernel::Point_3& to_exact(const typename Kernel::Point_3& p) const { return p; } }; // end specialization // Triangle_segment_intersection_points - + } #ifdef CGAL_COREFINEMENT_DO_REPORT_SELF_INTERSECTIONS @@ -801,12 +801,12 @@ class Intersection_of_Polyhedra_3{ typedef typename Default::Get::type Use_const_polyhedron; typedef typename Default::Get::value_type >::Kernel >::type Kernel; -//typedefs +//typedefs typedef typename Kernel::Triangle_3 Triangle; typedef typename Kernel::Segment_3 Segment; typedef internal_IOP:: Polyhedron_types Polyhedron_types; - + typedef typename Polyhedron_types::Polyhedron_ref Polyhedron_ref; typedef typename Polyhedron_types::Halfedge_handle Halfedge_handle; typedef typename Polyhedron_types::Halfedge_iterator Halfedge_iterator; @@ -819,13 +819,13 @@ class Intersection_of_Polyhedra_3{ double, 3, Halfedge_handle> Box; typedef std::pair Facet_pair; typedef std::pair Facet_pair_and_int; - + typedef internal_IOP:: Compare_handles Compare_handles; typedef internal_IOP:: Compare_handle_pairs Compare_handle_pairs; - + typedef std::map,Compare_handle_pairs> Facets_to_nodes_map;//Indeed the boundary of the intersection of two coplanar triangles may contain several segments. @@ -848,7 +848,7 @@ class Intersection_of_Polyhedra_3{ //member data PolyhedronPointPMap ppmap; //helper functions - static inline Facet_pair + static inline Facet_pair make_sorted_pair_of_facets(Facet_handle fh1,Facet_handle fh2) { const Facet* f1=&(*fh1); const Facet* f2=&(*fh2); @@ -871,7 +871,7 @@ class Intersection_of_Polyhedra_3{ if ( &(*h)<&(*h->opposite()) ) return h; return h->opposite(); } - + //member variables Edge_to_intersected_facets edge_to_sfacet; //Associate a segment to a filtered set of facets that may be intersected Facets_to_nodes_map f_to_node; //Associate a pair of triangle to their intersection points @@ -885,13 +885,13 @@ class Intersection_of_Polyhedra_3{ // is on the intersection polyline, I choose to direcly filter the output by removing duplicated edges Coplanar_duplicated_intersection_set coplanar_duplicated_intersection;//Set containing edges that are duplicated because of edges (partially) included in a triangle #endif - + //functions that should come from a traits class bool has_at_least_two_incident_faces(Halfedge_handle edge) { return !edge->is_border_edge(); } - + template void get_incident_facets(Halfedge_handle edge,Output_iterator out){ if (!edge->is_border()) *out++=edge->facet(); @@ -909,7 +909,7 @@ class Intersection_of_Polyhedra_3{ } //internal functions - + class Map_edge_facet_bbox_intersection { Edge_to_intersected_facets& edge_to_sfacet; Polyhedron_ref polyhedron_triangle; @@ -966,7 +966,7 @@ class Intersection_of_Polyhedra_3{ Halfedge_handle eh = eb->handle(); //handle for the edge if(eh->is_border()) eh = eh->opposite(); CGAL_assertion(!eh->is_border()); - + //check if the segment intersects the plane of the facet or if it is included in the plane const typename Kernel::Point_3 & a = get(ppmap, fh->vertex()); const typename Kernel::Point_3 & b = get(ppmap, fh->next()->vertex()); @@ -986,11 +986,11 @@ class Intersection_of_Polyhedra_3{ coplanar_facets.insert(make_sorted_pair_of_facets(eh->opposite()->facet(),fh->facet())); } visitor.add_filtered_intersection(eh,fh,polyhedron_edge,polyhedron_triangle); - //in case only the edge is coplanar, the intersection points will be detected using an incident facet + //in case only the edge is coplanar, the intersection points will be detected using an incident facet //(see remark at the beginning of the file) - return; + return; } - + typename Edge_to_intersected_facets::iterator res= edge_to_sfacet.insert(std::make_pair(eh,Facet_set())).first; res->second.insert(fh->facet()); @@ -1068,7 +1068,7 @@ class Intersection_of_Polyhedra_3{ } } }; - + // This function tests the intersection of the faces of P with the edges of Q void filter_intersections( Polyhedron_ref P, Polyhedron_ref Q) { std::vector facet_boxes, edge_boxes; @@ -1085,7 +1085,7 @@ class Intersection_of_Polyhedra_3{ for ( typename std::vector::iterator j = facet_boxes.begin(); j != facet_boxes.end(); ++j){ facet_box_ptr.push_back( &*j); } - + for ( Halfedge_iterator i = Q.halfedges_begin(); i != Q.halfedges_end(); ++i){ if(&*i < &*(i->opposite())){ edge_boxes.push_back( @@ -1094,7 +1094,7 @@ class Intersection_of_Polyhedra_3{ i)); } } - + std::vector edge_box_ptr; edge_box_ptr.reserve( Q.size_of_halfedges()/2); for ( typename std::vector::iterator j = edge_boxes.begin(); j != edge_boxes.end(); ++j){ @@ -1149,7 +1149,7 @@ class Intersection_of_Polyhedra_3{ it!=incident_facets.end();++it) { CGAL_assertion(cgal_do_intersect_debug(facet,*it)); - + Facet_pair facet_pair = make_sorted_pair_of_facets(facet,*it); if ( !coplanar_facets.empty() && coplanar_facets.find(facet_pair)!=coplanar_facets.end() ) continue; typename Facets_to_nodes_map::iterator it_list= @@ -1176,7 +1176,7 @@ class Intersection_of_Polyhedra_3{ //associate the intersection point to all facets incident to edge using the intersected edge //at least one pair of facets is already handle above - + typename Edge_to_intersected_facets::iterator it_fset=edge_to_sfacet.find(edge_intersected); if (it_fset==edge_to_sfacet.end()) return; Facet_set& fset_bis=it_fset->second; @@ -1196,7 +1196,7 @@ class Intersection_of_Polyhedra_3{ { std::vector incident_halfedges; get_incident_edges_to_vertex(vertex_intersected,std::back_inserter(incident_halfedges)); - for (typename std::vector::iterator + for (typename std::vector::iterator it=incident_halfedges.begin();it!=incident_halfedges.end();++it) { cip_handle_case_edge(node_id,fset,edge,*it); @@ -1230,7 +1230,7 @@ class Intersection_of_Polyhedra_3{ nodes.add_new_node(pt); } - + #ifdef USE_DETECTION_MULTIPLE_DEFINED_EDGES void check_coplanar_edge(Halfedge_handle hedge,Facet_handle facet) { @@ -1246,9 +1246,9 @@ class Intersection_of_Polyhedra_3{ //choose the smaller of the two faces (only one need to de deleted) Facet_handle smaller=make_sorted_pair_of_facets(hedge->face(),hedge->opposite()->face()).first; coplanar_duplicated_intersection.insert(make_sorted_pair_of_facets(smaller,facet)); - } + } } - + bool are_incident_facets_coplanar(Halfedge_handle hedge){ const typename Kernel::Point_3& p0=get(ppmap, hedge->vertex()); const typename Kernel::Point_3& p1=get(ppmap, hedge->next()->vertex()); @@ -1263,14 +1263,14 @@ class Intersection_of_Polyhedra_3{ case internal_IOP::FACET: check_coplanar_edge(hedge,additional_edge->face()); break; - + case internal_IOP::EDGE: if ( !additional_edge->is_border() ){ check_coplanar_edge(hedge,additional_edge->face()); } if (!additional_edge->opposite()->is_border()) check_coplanar_edge(hedge,additional_edge->opposite()->face()); - break; + break; case internal_IOP::VERTEX: { //consider all incident faces @@ -1283,20 +1283,20 @@ class Intersection_of_Polyhedra_3{ while(current!=additional_edge); } break; - + default: CGAL_assertion(type==internal_IOP::COPLNR); break; - } + } } - + void check_coplanar_edge_old(Halfedge_handle hedge,Halfedge_handle additional_edge,internal_IOP::Intersection_type type) { switch(type){ case internal_IOP::FACET: check_coplanar_edge(hedge,additional_edge->face()); break; - + case internal_IOP::EDGE: { if ( !additional_edge->is_border() ){ @@ -1317,7 +1317,7 @@ class Intersection_of_Polyhedra_3{ coplanar_duplicated_intersection.insert(make_sorted_pair_of_facets(hedge->face(),facet)); coplanar_duplicated_intersection.insert(make_sorted_pair_of_facets(hedge->opposite()->face(),facet)); coplanar_duplicated_intersection.insert(make_sorted_pair_of_facets(hedge->opposite()->face(),additional_edge->opposite()->face())); - } + } } else { @@ -1333,17 +1333,17 @@ class Intersection_of_Polyhedra_3{ check_coplanar_edge(hedge,additional_edge->opposite()->face()); } } - break; - case internal_IOP::VERTEX: - break; - + case internal_IOP::VERTEX: + + break; + default: CGAL_assertion(type==internal_IOP::COPLNR); break; - } + } } - + template void check_coplanar_edges(Hedge_iterator begin,Hedge_iterator end,Halfedge_handle additional_edge,internal_IOP::Intersection_type type) { @@ -1351,7 +1351,7 @@ class Intersection_of_Polyhedra_3{ check_coplanar_edge(*it,additional_edge,type); } #endif // USE_DETECTION_MULTIPLE_DEFINED_EDGES - + void print_type_debug(internal_IOP::Intersection_type type,bool cpl,bool opp_cpl) { switch(type){ @@ -1361,20 +1361,20 @@ class Intersection_of_Polyhedra_3{ case internal_IOP::EMPTY: std::cout << "EMPTY " << cpl << " " << opp_cpl << std::endl; break; - + case internal_IOP::FACET: std::cout << "FACET " << cpl << " " << opp_cpl << std::endl; break; - + case internal_IOP::EDGE: std::cout << "EDGE " << cpl << " " << opp_cpl << std::endl; - break; + break; case internal_IOP::VERTEX: std::cout << "VERTEX " << cpl << " " << opp_cpl << std::endl; break; } } - + void handle_coplanar_case_VERTEX_FACET(Halfedge_handle vertex,Halfedge_handle facet,int node_id){ visitor->new_node_added(node_id,internal_IOP::FACET,vertex,facet,true,false); @@ -1387,7 +1387,7 @@ class Intersection_of_Polyhedra_3{ if (it_ets!=edge_to_sfacet.end()) it_ets->second.erase(facet->facet()); } } - + void handle_coplanar_case_VERTEX_EDGE(Halfedge_handle vertex,Halfedge_handle edge,int node_id){ visitor->new_node_added(node_id,internal_IOP::VERTEX,edge,vertex,false,false); std::vector all_edges; @@ -1404,15 +1404,15 @@ class Intersection_of_Polyhedra_3{ visitor->new_node_added(node_id,internal_IOP::VERTEX,vertex2,vertex1,true,false); std::vector all_edges; get_incident_edges_to_vertex(vertex1,std::back_inserter(all_edges)); - typename std::vector::iterator it_edge=all_edges.begin(); + typename std::vector::iterator it_edge=all_edges.begin(); for (;it_edge!=all_edges.end();++it_edge){ typename Edge_to_intersected_facets::iterator it_ets=edge_to_sfacet.find(*it_edge); Facet_set* fset = (it_ets!=edge_to_sfacet.end())?&(it_ets->second):NULL; cip_handle_case_vertex(node_id,fset,*it_edge,vertex2); } } - - + + template int get_or_create_node(Cpl_inter_pt& ipt,int& current_node,Coplanar_node_map& coplanar_node_map){ void *v1, *v2; @@ -1434,7 +1434,7 @@ class Intersection_of_Polyhedra_3{ std::pair res=coplanar_node_map.insert(std::make_pair(key,current_node+1)); if (res.second){ //insert a new node - + if (ipt.type_1==internal_IOP::VERTEX) add_new_node(get(ppmap, ipt.info_1->vertex())); else{ @@ -1447,18 +1447,18 @@ class Intersection_of_Polyhedra_3{ } return res.first->second; } - + void compute_intersection_of_coplanar_facets(int& current_node){ typedef std::map,int> Coplanar_node_map; Coplanar_node_map coplanar_node_map; - + for (typename Coplanar_facets_set::iterator it=coplanar_facets.begin();it!=coplanar_facets.end();++it){ Facet_handle f1=it->first; Facet_handle f2=it->second; typedef internal_IOP::Intersection_point_with_info Cpl_inter_pt; std::list inter_pts; internal_IOP::intersection_coplanar_facets(f1->halfedge(),f2->halfedge(),ppmap,inter_pts); -// std::cout << "found " << inter_pts.size() << " inter pts: "; +// std::cout << "found " << inter_pts.size() << " inter pts: "; std::size_t nb_pts=inter_pts.size(); std::vector cpln_nodes; cpln_nodes.reserve(nb_pts); for (typename std::list::iterator iti=inter_pts.begin();iti!=inter_pts.end();++iti){ @@ -1488,21 +1488,21 @@ class Intersection_of_Polyhedra_3{ visitor->new_node_added(node_id,internal_IOP::EDGE,iti->info_1,iti->info_2,false,false); typename Edge_to_intersected_facets::iterator it_ets=edge_to_sfacet.find(iti->info_1); Facet_set* fset = (it_ets!=edge_to_sfacet.end())?&(it_ets->second):NULL; - cip_handle_case_edge(node_id,fset,iti->info_1,iti->info_2); + cip_handle_case_edge(node_id,fset,iti->info_1,iti->info_2); } break; default: CGAL_error_msg("Should not get there!"); } - } + } break; - + case internal_IOP::FACET: { CGAL_assertion(iti->type_2==internal_IOP::VERTEX); handle_coplanar_case_VERTEX_FACET(iti->info_2,iti->info_1,node_id); } break; - + default: CGAL_error_msg("Should not get there!"); } } @@ -1510,7 +1510,7 @@ class Intersection_of_Polyhedra_3{ case 0: break; case 1: { - typename Facets_to_nodes_map::iterator it_list= + typename Facets_to_nodes_map::iterator it_list= f_to_node.insert( std::make_pair( Facet_pair_and_int(*it,1),std::set()) ).first; it_list->second.insert(cpln_nodes[0]); } @@ -1530,7 +1530,7 @@ class Intersection_of_Polyhedra_3{ // std::cout << std::endl; } } - + void compute_intersection_points(int& current_node){ for(typename Edge_to_intersected_facets::iterator it=edge_to_sfacet.begin();it!=edge_to_sfacet.end();++it){ Halfedge_handle edge=it->first; @@ -1540,7 +1540,7 @@ class Intersection_of_Polyhedra_3{ Intersection_result res=internal_IOP::do_intersect(edge,facet,ppmap); internal_IOP::Intersection_type type=CGAL::cpp11::get<0>(res); - + //handle degenerate case: one extremity of edge below to facet std::vector all_edges; if ( CGAL::cpp11::get<2>(res) ) @@ -1551,14 +1551,14 @@ class Intersection_of_Polyhedra_3{ else all_edges.push_back(edge); } - + CGAL_precondition(*all_edges.begin()==edge || *all_edges.begin()==edge->opposite()); // print_type_debug(type,CGAL::cpp11::get<2>(res),CGAL::cpp11::get<3>(res)); - + #ifdef USE_DETECTION_MULTIPLE_DEFINED_EDGES check_coplanar_edges(boost::next(all_edges.begin()),all_edges.end(),CGAL::cpp11::get<1>(res),type); #endif - + typename std::vector::iterator it_edge=all_edges.begin(); switch(type){ case internal_IOP::COPLNR: @@ -1627,7 +1627,7 @@ class Intersection_of_Polyhedra_3{ for (;it_edge!=all_edges.end();++it_edge){ if ( it_edge!=all_edges.begin() ){ typename Edge_to_intersected_facets::iterator it_ets=edge_to_sfacet.find(*it_edge); - Facet_set* fset_bis = (it_ets!=edge_to_sfacet.end())?&(it_ets->second):NULL; + Facet_set* fset_bis = (it_ets!=edge_to_sfacet.end())?&(it_ets->second):NULL; cip_handle_case_vertex(node_id,fset_bis,*it_edge,vertex_intersected); } else @@ -1641,11 +1641,11 @@ class Intersection_of_Polyhedra_3{ } // end loop on all entries (edges) in 'edge_to_sfacet' CGAL_assertion(nodes.size()==unsigned(current_node+1)); } - + #ifdef USE_DETECTION_MULTIPLE_DEFINED_EDGES void remove_duplicated_intersecting_edges() { - for (typename Coplanar_duplicated_intersection_set::iterator + for (typename Coplanar_duplicated_intersection_set::iterator it=coplanar_duplicated_intersection.begin(); it!=coplanar_duplicated_intersection.end(); ++it) @@ -1665,7 +1665,7 @@ class Intersection_of_Polyhedra_3{ { std::set< std::pair > already_seen; std::list to_erase; - for (typename Facets_to_nodes_map::iterator + for (typename Facets_to_nodes_map::iterator it=f_to_node.begin(); it!=f_to_node.end(); ++it @@ -1678,11 +1678,11 @@ class Intersection_of_Polyhedra_3{ *(it->second.begin()), *boost::next(it->second.begin()) ) ).second; - + if (!is_new) to_erase.push_back(it); } - + for ( typename std::list::iterator it=to_erase.begin();it!=to_erase.end();++it ) @@ -1694,15 +1694,15 @@ class Intersection_of_Polyhedra_3{ struct Graph_node{ std::set neighbors; unsigned degree; - + Graph_node():degree(0){} - + void insert(std::size_t i){ ++degree; CGAL_assertion(neighbors.find(i)==neighbors.end()); neighbors.insert(i); } - + void erase(std::size_t i){ CGAL_assertion(neighbors.find(i)!=neighbors.end()); neighbors.erase(i); @@ -1825,18 +1825,18 @@ class Intersection_of_Polyhedra_3{ *out++=polyline; } } - + int get_other_int(const std::set& s,int i) const { if (*s.begin()!=i) return *s.begin(); return *boost::next(s.begin()); } - + template bool is_grabbed(const Dispatch_out_it&) const{ return CGAL::Is_in_tuple::value; } - - + + template struct Is_dispatch_based_ouput_iterator{ typedef boost::false_type type; @@ -1847,26 +1847,26 @@ class Intersection_of_Polyhedra_3{ typedef typename boost::is_base_of< Dispatch_output_iterator, Dispatch_based_output_it >::type type; }; - + template inline void construct_polylines_with_info(Nodes_vector& nodes,Output_iterator out){ return construct_polylines_with_info(nodes,out,typename Is_dispatch_based_ouput_iterator::type()); } - + template void construct_polylines_with_info(Nodes_vector& nodes,Output_iterator out,boost::false_type){ construct_polylines_with_info(nodes, dispatch_or_drop_output >(out),boost::true_type()); } - + template class Dispatch_based_output_it,class V,class O> void construct_polylines_with_info(Nodes_vector& nodes, Dispatch_based_output_it out,boost::true_type) { typedef typename Facets_to_nodes_map::value_type Edge; typedef std::list Polyline_info; - - + + std::size_t nb_nodes=nodes.size(); std::vector node_mult(nb_nodes,0); std::vector terminal_bools(nb_nodes,false); @@ -1895,10 +1895,10 @@ class Intersection_of_Polyhedra_3{ *out++=std::vector(); } } - + //visitor call visitor->update_terminal_nodes(terminal_bools); - + //We start from a node N and recursively walk one edge to find other // node. If this is a cycle we stop when we are back at the node N; //otherwise we stop at a terminal node and restart a walk from N @@ -1911,27 +1911,27 @@ class Intersection_of_Polyhedra_3{ ++current_node; continue; } - + Edge* edge=*connections[current_node].begin(); connections[current_node].erase(connections[current_node].begin()); - + Polyline_info polyline_info; std::list polyline_embedding; - + if ( is_grabbed >(out)) polyline_info.push_back(edge->first.first); polyline_embedding.push_back(nodes[current_node]); - + unsigned i=current_node; unsigned start_node=current_node; bool reverse=false; while (true){ i=get_other_int(edge->second,i); connections[i].erase(edge); - + if (reverse) polyline_embedding.push_front(nodes[i]); else polyline_embedding.push_back(nodes[i]); - + if (i==start_node) break; if (terminal_bools[i]){ if (reverse || terminal_bools[current_node]) break; @@ -1939,17 +1939,17 @@ class Intersection_of_Polyhedra_3{ i=current_node; if ( connections[i].empty() ) break; } - + edge=*connections[i].begin(); connections[i].erase(connections[i].begin()); - + if ( is_grabbed >(out)){ if (reverse) polyline_info.push_front(edge->first.first); else polyline_info.push_back(edge->first.first); } - + } - + *out++=std::vector(polyline_embedding.begin(),polyline_embedding.end()); if ( is_grabbed >(out)){ CGAL_assertion(polyline_embedding.size()==polyline_info.size()+1); @@ -1957,9 +1957,9 @@ class Intersection_of_Polyhedra_3{ } } } - + //debug functions - + bool cgal_do_intersect_debug(Halfedge_handle eh,Facet_handle fh){ Triangle t( get(ppmap, fh->halfedge()->vertex()), get(ppmap, fh->halfedge()->next()->vertex()), @@ -1982,7 +1982,7 @@ class Intersection_of_Polyhedra_3{ return CGAL::do_intersect( t1, t2); } - + void print_f_to_node_debug(){ std::cout << "print_f_to_node_debug " << &f_to_node << std::endl; for (typename Facets_to_nodes_map::iterator it=f_to_node.begin();it!=f_to_node.end();++it){ @@ -1991,15 +1991,15 @@ class Intersection_of_Polyhedra_3{ std::cout << "}" <& graph){ for (typename std::map::const_iterator it=graph.begin();it!=graph.end();++it){ std::cout << it->first << " -> {"; std::copy(it->second.neighbors.begin(),it->second.neighbors.end(),std::ostream_iterator(std::cout,",")); - std::cout << "}" < OutputIterator main_run(OutputIterator out,bool build_polylines=true){ // std::cout << edge_to_sfacet.size() << std::endl; int current_node=-1; - + //print_edge_to_sfacet_debug(); #ifndef DO_NOT_HANDLE_COPLANAR_FACETS //first handle coplanar triangles @@ -2028,17 +2028,17 @@ class Intersection_of_Polyhedra_3{ //build connectivity info compute_intersection_points(current_node); // 'current_node' is passed by // non-const reference - + if (!build_polylines){ visitor->finalize(nodes); return out; } - //remove duplicated intersecting edges: + //remove duplicated intersecting edges: // In case two facets are incident along such an edge coplanar in a facet of another polyhedron (and one extremity inside the facet), the intersection // will be reported twice. We kept track (check_coplanar_edge(s)) of this so that, we can remove one intersecting edge out of the two //print_f_to_node_debug(); remove_duplicated_intersecting_edges(); - + //std::cout << "f_to_node "<< f_to_node.size() << std::endl; //print_f_to_node_debug(); //collect connectivity infos and create polylines @@ -2046,12 +2046,12 @@ class Intersection_of_Polyhedra_3{ construct_polylines(nodes,out); //using the graph approach (at some point we know all connections between intersection points) else construct_polylines_with_info(nodes,out); //direct construction by propagation - - visitor->finalize(nodes); - + + visitor->finalize(nodes); + return out; } - + public: Intersection_of_Polyhedra_3(PolyhedronPointPMap ppmap=PolyhedronPointPMap()) :ppmap(ppmap),nodes(ppmap), @@ -2069,17 +2069,17 @@ public: CGAL_precondition( it1->is_pure_triangle() ); Polyhedron_ref P=*it1; visitor->new_input_polyhedron(P); - for(InputIterator it2=boost::next(it1);it2!=end;++it2){ + for(InputIterator it2=boost::next(it1);it2!=end;++it2){ CGAL_precondition( it2->is_pure_triangle() ); Polyhedron_ref Q=*it2; filter_intersections(P, Q); filter_intersections(Q, P); } } - + return main_run(out); } - + //pairwise intersection between all elements in the range //(pointers version) template @@ -2089,17 +2089,17 @@ public: CGAL_precondition( (*it1)->is_pure_triangle() ); Polyhedron_ref P=**it1; visitor->new_input_polyhedron(P); - for(InputIterator it2=boost::next(it1);it2!=end;++it2){ + for(InputIterator it2=boost::next(it1);it2!=end;++it2){ CGAL_precondition( (*it2)->is_pure_triangle() ); Polyhedron_ref Q=**it2; filter_intersections(P, Q); filter_intersections(Q, P); } } - + return main_run(out); } - + //intersection between P and each element in the range template OutputIterator @@ -2115,7 +2115,7 @@ public: } return main_run(out); } - + //intersection between P and each element in the range //(pointers version) template @@ -2132,7 +2132,7 @@ public: } return main_run(out); } - + //intersection between P and Q template OutputIterator diff --git a/Operations_on_polyhedra/include/CGAL/intersection_of_Polyhedra_3_refinement_visitor.h b/Operations_on_polyhedra/include/CGAL/intersection_of_Polyhedra_3_refinement_visitor.h index 8c364402541..d46d8879770 100644 --- a/Operations_on_polyhedra/include/CGAL/intersection_of_Polyhedra_3_refinement_visitor.h +++ b/Operations_on_polyhedra/include/CGAL/intersection_of_Polyhedra_3_refinement_visitor.h @@ -53,7 +53,7 @@ // and points on edge should be handled by hand (simply start using the point opposite to the edge) // --sorted_around_edge_filtered: can be done using the original supporting planes // --in intersection_of_Polyhedra_3: upon call to Triangle_segment_intersection_point::add_new_node, interval and exact nodes are -// inserted into a vector. Since we do not know the final size of vector this lead to reallocation of data. +// inserted into a vector. Since we do not know the final size of vector this lead to reallocation of data. // --in Triangle_segment_intersection_point, try using EPEC instead of Interval_nt+SC // --use a sorted pair of indices in edge_to_hedge+simplify the code TAG_SLXX1 // --in sew_2_marked_darts arrange how darts are passed to avoid comparing to a Point_3 @@ -70,7 +70,7 @@ // already exists bool report_isolated_point or a template parameter (polyline with a unique point) namespace CGAL { - + namespace internal_IOP { @@ -83,7 +83,7 @@ namespace CGAL typedef typename HDS::Halfedge Halfedge; typedef typename HDS::Face Face; typedef typename boost::property_traits::value_type Point; - + //data members Face_handle current_face; std::map nodes_; @@ -99,14 +99,14 @@ namespace CGAL unlock_halfedge(Halfedge_handle h){ return static_cast(&(*h)); } - + typename HDS::Face::Base* unlock_face(Face_handle f){ return static_cast(&(*f)); - } - + } + public: - + template Triangulate_a_face( Face_handle face, const Nodes_vector& nodes, @@ -125,7 +125,7 @@ namespace CGAL nodes_.insert(std::make_pair(*it,nodes[*it])); } //grab edges that are not on the convex hull (these have already been created) - for (typename Triangulation::Finite_edges_iterator + for (typename Triangulation::Finite_edges_iterator it=triangulation.finite_edges_begin(); it!=triangulation.finite_edges_end(); ++it) @@ -143,7 +143,7 @@ namespace CGAL CGAL_assertion( triangulation.is_infinite(it->first->vertex(it->second)) || triangulation.is_infinite( triangulation.mirror_vertex(it->first,it->second)) ); } //grab triangles. - for (typename Triangulation::Finite_faces_iterator + for (typename Triangulation::Finite_faces_iterator it=triangulation.finite_faces_begin(); it!=triangulation.finite_faces_end(); ++it) @@ -157,14 +157,14 @@ namespace CGAL } - + void operator()( HDS& hds) { // std::cerr << "node_to_polyhedron_vertex_"<< std::endl; // for (typename std::map::iterator it=node_to_polyhedron_vertex_.begin();it!=node_to_polyhedron_vertex_.end();++it) // std::cerr << it->first << " " << &(*(it->second)) << std::endl; - + //insert the intersection point interior to the face inside the polyhedron and - //save their Polyhedron::vertex_handle + //save their Polyhedron::vertex_handle for (typename std::map::iterator it=nodes_.begin();it!=nodes_.end();++it) { Vertex_handle v=hds.vertices_push_back(Vertex()); @@ -174,20 +174,20 @@ namespace CGAL node_to_polyhedron_vertex_.insert( std::make_pair(it->first,v) ); // std::cerr << "vertices " << it->first << " " << &(*v) << std::endl; } - + //insert the new halfedge and set their incident vertex - for (typename std::vector >::iterator + for (typename std::vector >::iterator it=edges_to_create_.begin();it!=edges_to_create_.end();++it) { Halfedge_handle he=hds.edges_push_back(Halfedge(),Halfedge()); - + //associate edge to halfedge going from i to j with j as incident vertex CGAL_assertion(node_to_polyhedron_vertex_.find(it->second)!= node_to_polyhedron_vertex_.end()); Vertex_handle v=node_to_polyhedron_vertex_.find(it->second)->second; unlock_halfedge(he)->set_vertex( v ); v->set_halfedge(he); // std::cerr << " --in edge " << &(*v) << std::endl; - edge_to_hedge_.insert( std::make_pair(*it,he) ); + edge_to_hedge_.insert( std::make_pair(*it,he) ); v=node_to_polyhedron_vertex_.find(it->first)->second; // std::cerr << " --in edge " << &(*v) << std::endl; unlock_halfedge( he->opposite() )->set_vertex( v ); @@ -195,43 +195,43 @@ namespace CGAL edge_to_hedge_.insert( std::make_pair(std::make_pair(it->second,it->first),he->opposite()) ); // std::cerr << "edges " << it->first << " " << it->second << std::endl; } - + std::vector >::iterator it=faces_to_create_.begin(); Face_handle face_triangulated = current_face; //create the new faces and update adjacencies while (true) { int i=cpp11::get<0>(*it),j=cpp11::get<1>(*it),k=cpp11::get<2>(*it); -// std::cerr << "faces " << i << " " << j << " " << k<< std::endl; +// std::cerr << "faces " << i << " " << j << " " << k<< std::endl; Halfedge_handle current = edge_to_hedge_.find(std::make_pair(i,j))->second; Halfedge_handle next = edge_to_hedge_.find(std::make_pair(j,k))->second; Halfedge_handle previous = edge_to_hedge_.find(std::make_pair(k,i))->second; - + CGAL_assertion (edge_to_hedge_.find(std::make_pair(i,j))!=edge_to_hedge_.end()); CGAL_assertion (edge_to_hedge_.find(std::make_pair(j,k))!=edge_to_hedge_.end()); CGAL_assertion (edge_to_hedge_.find(std::make_pair(k,i))!=edge_to_hedge_.end()); - + CGAL_assertion(current->vertex()==node_to_polyhedron_vertex_.find(j)->second); CGAL_assertion(next->vertex()==node_to_polyhedron_vertex_.find(k)->second); CGAL_assertion(previous->vertex()==node_to_polyhedron_vertex_.find(i)->second); - + unlock_halfedge(current)->set_next(next); unlock_halfedge(next)->set_next(previous); unlock_halfedge(previous)->set_next(current); - + unlock_halfedge(current)->set_prev(previous); unlock_halfedge(next)->set_prev(current); unlock_halfedge(previous)->set_prev(next); - + //update face halfedge unlock_face(current_face)->set_halfedge(current); - + //update face of halfedges unlock_halfedge(current) ->set_face(current_face); unlock_halfedge(next) ->set_face(current_face); - unlock_halfedge(previous) ->set_face(current_face); - + unlock_halfedge(previous) ->set_face(current_face); + if ( ++it!=faces_to_create_.end() ) current_face=hds.faces_push_back( facet_construct(*face_triangulated) ); else @@ -304,14 +304,14 @@ template< class Polyhedron, class PolyhedronPointPMap_=Default > class Node_visitor_refine_polyhedra{ -//Default typedefs +//Default typedefs typedef typename Default::Get::type OutputBuilder; typedef typename Default::Get >::type EdgeMarkPropertyMap; typedef typename Default::Get >::type NestedFacetConstruct; typedef typename Default::Get >::type NewNodeVertexVisitor; typedef typename Default::Get >::type PolyhedronPointPMap; typedef typename Default::Get::value_type >::Kernel >::type Kernel; -//typedefs +//typedefs typedef typename Polyhedron::Halfedge_handle Halfedge_handle; typedef typename Polyhedron::Halfedge_const_handle Halfedge_const_handle; typedef typename Polyhedron::Face_handle Face_handle; @@ -319,9 +319,9 @@ class Node_visitor_refine_polyhedra{ typedef typename Polyhedron::Vertex_handle Vertex_handle; typedef internal_IOP::Compare_handles Cmp_handle; //This ensures uniqueness of edges when comparing halfedges typedef internal_IOP::Compare_unik_address Cmp_unik_ad; //This ensures uniqueness of edges when comparing halfedges - + //constrained triangulation used for triangulation interior of faces - #ifdef DO_NO_USE_EXACT_CDT + #ifdef DO_NO_USE_EXACT_CDT typedef CGAL::Triangulation_vertex_base_with_info_2 Vbi; typedef CGAL::Constrained_triangulation_face_base_2 Fb; typedef CGAL::Triangulation_data_structure_2 TDS_2; @@ -332,21 +332,21 @@ class Node_visitor_refine_polyhedra{ typedef CGAL::Triangulation_vertex_base_with_info_2 Vbi; typedef CGAL::Constrained_triangulation_face_base_2 Fb; typedef CGAL::Triangulation_data_structure_2 TDS_2; - typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; //DO WE NEED DELAUNAY???? + typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; //DO WE NEED DELAUNAY???? #endif - + typedef std::map Hedge_to_polyhedron_map; typedef std::vector Node_ids; typedef std::set Node_id_set; //avoid having duplicated node on edge of coplanar triangles - typedef std::map< Face_handle,Node_ids,Cmp_handle > In_face_map; + typedef std::map< Face_handle,Node_ids,Cmp_handle > In_face_map; typedef std::map< Halfedge_handle,Node_id_set,Cmp_unik_ad > In_halfedge_map; //to keep the correspondance between node_id and vertex_handle in each polyhedron typedef std::map Node_to_polyhedron_vertex_map; typedef std::map Poly_to_map_node; //to maintain an polyhedron halfedge on each polyline + pair //with first = "is the key (pair) was reversed?" and second is the number of edges +1 in the polyline - typedef std::map< std::pair, std::pair< std::map,std::pair > > An_edge_per_polyline_map; + typedef std::map< std::pair, std::pair< std::map,std::pair > > An_edge_per_polyline_map; //to handle coplanar halfedge of polyhedra that are full in the intersection typedef std::map< int,Halfedge_handle > Node_to_target_of_hedge_map; typedef std::map< Polyhedron*,Node_to_target_of_hedge_map> Poly_to_vertices_on_intersection_map; @@ -363,14 +363,14 @@ class Node_visitor_refine_polyhedra{ Poly_to_map_node polyhedron_to_map_node_to_polyhedron_vertex; std::set non_manifold_nodes; //contain nodes that are original vertices of input polyhedron and that neighborhood is not a topological disk std::map nodes_that_are_original_vertices;//to keep the correspondance between original polyhedron vertices that are also nodes - + OutputBuilder output_builder; - + // new_hedge hedge // -----------> -----------> // v // <----------- <----------- - // new_opposite opposite + // new_opposite opposite // template Vertex_handle split_edge( Halfedge_handle hedge, @@ -408,7 +408,7 @@ class Node_visitor_refine_polyhedra{ internal_IOP::Order_along_a_halfedge(hedge,nodes, ppmap) ); } - + //insert intersection as constrained edges in a CDT triangulation template void insert_constrained_edges_coplanar_case(int node_id, @@ -449,7 +449,7 @@ class Node_visitor_refine_polyhedra{ for (std::set::iterator it_n=it_neighbors->second.begin();it_n!=it_neighbors->second.end();++it_n){ typename std::map::iterator it_vh=id_to_CDT_vh.find(*it_n); // this condition ensures to consider only graph edges that are in the same triangle (not in a neighbor one when involving node on a triangle edge) - if ( !points_on_triangle || it_vh!=id_to_CDT_vh.end() ){ + if ( !points_on_triangle || it_vh!=id_to_CDT_vh.end() ){ CGAL_assertion(it_vh!=id_to_CDT_vh.end()); triangulation.insert_constraint(vh,id_to_CDT_vh.find(*it_n)->second); constrained_edges.push_back(std::make_pair(*it_node_id,*it_n)); @@ -462,13 +462,13 @@ class Node_visitor_refine_polyhedra{ std::cout << "X0: Found an isolated point" << std::endl; } #endif - + insert_constrained_edges_coplanar_case(*it_node_id,triangulation,id_to_CDT_vh); } } - - std::pair make_sorted_pair(int i,int j) const {return i make_sorted_pair(int i,int j) const {return i indices,typename Polyhedron::Halfedge_handle hedge) { std::pair sorted_pair=make_sorted_pair(indices.first,indices.second); @@ -492,7 +492,7 @@ class Node_visitor_refine_polyhedra{ triangle_boundary_indices[0]=-1; triangle_boundary_indices[1]=-2; triangle_boundary_indices[2]=-3; - + for (int k=0;k<3;++k){ typename std::map::iterator it=nodes_that_are_original_vertices.find(triangle_boundary[k]); if (it!=nodes_that_are_original_vertices.end()) @@ -522,7 +522,7 @@ public: typedef internal_IOP::Predicates_on_constructions Node_storage_type; typedef Tag_false Is_polyhedron_const; static const bool do_need_vertex_graph = true; //because we need to know which edges are constrained - + void set_number_of_intersection_points_from_coplanar_facets(int n){ number_coplanar_vertices=n; } @@ -543,12 +543,12 @@ public: curr=curr->next()->opposite(); } while(curr!=hedge); - } - + } + void check_node_on_non_manifold_edge(int node_id,Halfedge_handle hedge){ if ( hedge->is_border_edge() ) non_manifold_nodes.insert(node_id); } - + void new_node_added(int node_id, internal_IOP::Intersection_type type, Halfedge_handle principal_edge, @@ -587,10 +587,10 @@ public: default: return; } - + CGAL_assertion(!is_vertex_coplanar || !is_vertex_opposite_coplanar); //coplanar edge are not forwarded - - + + if ( is_vertex_coplanar ) { //grab original vertex that is on commom intersection @@ -617,7 +617,7 @@ public: } } } - + template void annotate_graph(Iterator begin,Iterator end) { @@ -630,12 +630,12 @@ public: graph_of_constraints.insert(std::make_pair(node_id,neighbors)); } } - + void update_terminal_nodes(std::vector&) { CGAL_assertion(!"Must not call this function"); } - + void add_filtered_intersection(Halfedge_handle eh,Halfedge_handle fh,Polyhedron& Pe,Polyhedron& Pf){ //use the representant halfedge of the facet as key //--set polyhedron for the two facets incident to the edge @@ -646,7 +646,7 @@ public: //--set polyhedron for the facet intersected by the edge hedge_to_polyhedron.insert(std::make_pair(fh->facet()->halfedge(),&Pf)); } - + struct Polyhedron_face_boundary{ std::vector node_ids_array[3]; // the node_ids on each halfedges @@ -665,12 +665,12 @@ public: halfedges[0]=first; halfedges[1]=first->next(); halfedges[2]=first->next()->next(); - + vertices[0]=halfedges[0]->opposite()->vertex(); vertices[1]=halfedges[1]->opposite()->vertex(); vertices[2]=halfedges[2]->opposite()->vertex(); } - + //used when object was created with hedge but opposite was used to split the original face void update_original_halfedge(Halfedge_handle original,Halfedge_handle new_hedge) { @@ -682,7 +682,7 @@ public: hedges_ids.insert(std::make_pair(new_hedge,index)); halfedges[index]=new_hedge; } - + template void copy_node_ids(Halfedge_handle hedge,Iterator begin,Iterator end) { @@ -691,8 +691,8 @@ public: std::copy(begin,end,std::back_inserter(node_ids_array[it_id->second])); } }; - - + + void start_new_polyline(int i, int j) { if ( i==j ) //case of a single point @@ -702,20 +702,20 @@ public: return; } std::pair res= - an_edge_per_polyline.insert( + an_edge_per_polyline.insert( std::make_pair( make_sorted_pair(i,j), std::make_pair( std::map(),std::make_pair(false,0)) ) ); CGAL_assertion(res.second); last_polyline=res.first; - if ( i !=last_polyline->first.first ) + if ( i !=last_polyline->first.first ) last_polyline->second.second.first=true; } - + void add_node_to_polyline(int){ ++(last_polyline->second.second.second); } - + void new_input_polyhedron(Polyhedron& P) { typedef std::pair Res; @@ -724,12 +724,12 @@ public: polyhedron_to_map_node_to_polyhedron_vertex.insert(std::make_pair( &P,Node_to_polyhedron_vertex_map() )); CGAL_assertion(res.second == true); } - + //1) split_halfedges and retriangulate faces with no intersection point interior to the facet //2) retriangulate using a constrained Delaunay triangulation each triangle in each Polyhedron that contains at least // one intersection point inside the facet //3) mark polyhedron edges that are on the intersection - //4) create one output polyhedron per connected component of polyhedron, connected by an edge which is not an intersection edge + //4) create one output polyhedron per connected component of polyhedron, connected by an edge which is not an intersection edge //5) import each piece into a common combinatorial map //6) glue all the pieces together template @@ -739,18 +739,18 @@ public: // I need to know in the case the third vertex is a node its index (for exact construction) typedef std::map,Cmp_unik_ad > Border_halfedges_map; Border_halfedges_map border_halfedges; - + //store for each triangle facet which boundary is intersected by the other surface, //original vertices (and halfedges in the refined mesh pointing on these vertices) typedef std::map Faces_boundary; - Faces_boundary faces_boundary; - + Faces_boundary faces_boundary; + //0) For each polyhedron, collect original vertices that belongs to the intersection. // From the graph of constaints, extract intersection edges that are incident to such vertices. In case // there exists another original vertex adjacent to the first one found, this halfedge must be // marked on the boundary (and possibly update an_edge_per_polyline). // This is done first to avoid halfedges stored to be modified in the steps following. - for (typename Poly_to_vertices_on_intersection_map::iterator + for (typename Poly_to_vertices_on_intersection_map::iterator it=poly_to_vertices_on_inter.begin(); it!=poly_to_vertices_on_inter.end(); ++it) @@ -758,7 +758,7 @@ public: Polyhedron* poly=it->first; std::set > already_done; Node_to_target_of_hedge_map& nodes_to_hedge=it->second; - for(typename Node_to_target_of_hedge_map::iterator + for(typename Node_to_target_of_hedge_map::iterator it_node_2_hedge=nodes_to_hedge.begin(); it_node_2_hedge!=nodes_to_hedge.end(); ++it_node_2_hedge) @@ -786,7 +786,7 @@ public: put(m_edge_mark_pmap,std::make_pair(hedge,poly),true); put(m_edge_mark_pmap,std::make_pair(hedge->opposite(),poly),true); } - update_edge_per_polyline(poly,edge_pair,hedge); + update_edge_per_polyline(poly,edge_pair,hedge); //save the fact that we already handle this edge already_done.insert(std::make_pair(node_id_of_first,*it_id)); } @@ -800,7 +800,7 @@ public: #endif } } - + //1) First split halfedges cut by the intersection polyline(s) for (typename In_halfedge_map::iterator it=in_hedge.begin();it!=in_hedge.end();++it) { @@ -811,7 +811,7 @@ public: typename Hedge_to_polyhedron_map::iterator it_poly=hedge_to_polyhedron.find( hedge->facet()->halfedge() ); CGAL_assertion(it_poly!=hedge_to_polyhedron.end()); Polyhedron* P=it_poly->second; //the polyhedron in which vertices should be added - + sort_vertices_along_hedge(node_ids,hedge,nodes); //save original face and nodes for face of hedge (1) @@ -821,24 +821,24 @@ public: it_face=faces_boundary.insert(std::make_pair(hedge->face(),Polyhedron_face_boundary(hedge))).first; it_face->second.copy_node_ids(hedge,node_ids.begin(),node_ids.end()); } - + //save original face and nodes for face of hedge->opposite (2) typename Faces_boundary::iterator opposite_original_info=faces_boundary.end(); if ( !hedge->opposite()->is_border() ){ opposite_original_info=faces_boundary.find(hedge->opposite()->face()); - if (opposite_original_info==faces_boundary.end()) + if (opposite_original_info==faces_boundary.end()) opposite_original_info=faces_boundary.insert(std::make_pair(hedge->opposite()->face(),Polyhedron_face_boundary(hedge->opposite()))).first; - opposite_original_info->second.copy_node_ids(hedge->opposite(),node_ids.rbegin(),node_ids.rend()); - } - + opposite_original_info->second.copy_node_ids(hedge->opposite(),node_ids.rbegin(),node_ids.rend()); + } + typename Poly_to_map_node::iterator it_map=polyhedron_to_map_node_to_polyhedron_vertex.find(P); CGAL_assertion(it_map!=polyhedron_to_map_node_to_polyhedron_vertex.end()); //a map to identify the vertex in the polyhedron corresponding to an intersection point - Node_to_polyhedron_vertex_map& node_to_polyhedron_vertex=it_map->second; - + Node_to_polyhedron_vertex_map& node_to_polyhedron_vertex=it_map->second; + CGAL_assertion_code(Vertex_handle original_vertex=hedge->opposite()->vertex();) - - //We need an edge incident to the source vertex of hedge. This is the first opposite edge created. + + //We need an edge incident to the source vertex of hedge. This is the first opposite edge created. bool first=true; Halfedge_handle hedge_incident_to_src; //do split the edges for (std::vector::const_iterator it_id=node_ids.begin();it_id!=node_ids.end();++it_id){ @@ -849,7 +849,7 @@ public: hedge_incident_to_src=hedge->opposite()->next(); } } - + CGAL_assertion(hedge_incident_to_src->vertex()==original_vertex); CGAL_assertion(hedge_incident_to_src->face()==hedge->opposite()->face()); @@ -858,12 +858,12 @@ public: CGAL_assertion(opposite_original_info!=faces_boundary.end()); opposite_original_info->second.update_original_halfedge(hedge->opposite(),hedge_incident_to_src); } - + //insert the two incident faces in in_face map so that they will be triangulated. if (!hedge->is_border()) in_face.insert(std::make_pair(hedge->face(),Node_ids())); if (!hedge->opposite()->is_border()) in_face.insert(std::make_pair(hedge->opposite()->face(),Node_ids())); } - + //2)triangulation of the triangle faces containing intersection point in their interior // and also those with intersection points only on the boundary. for (typename In_face_map::iterator it=in_face.begin();it!=in_face.end();++it) @@ -872,7 +872,7 @@ public: Node_ids& node_ids = it->second; //the index of the intersection point that are interior to the face typename Faces_boundary::iterator it_fb=faces_boundary.find(f); - + typename Hedge_to_polyhedron_map::iterator it_polyhedron = hedge_to_polyhedron.find (f->halfedge()); //we can do this because the halfedge is still the same (at least its address)+no Face::set_halfedge called CGAL_assertion(it_polyhedron != hedge_to_polyhedron.end()); Polyhedron* P=it_polyhedron->second; @@ -880,12 +880,12 @@ public: CGAL_assertion(it_map!=polyhedron_to_map_node_to_polyhedron_vertex.end()); //a map to identify the vertex in the polyhedron corresponding to an intersection point Node_to_polyhedron_vertex_map& node_to_polyhedron_vertex=it_map->second; - + std::map id_to_CDT_vh; - + //associate an edge of the triangulation to a halfedge in a given polyhedron std::map,Halfedge_handle> edge_to_hedge; - + Vertex_handle triangle_boundary[3]; int triangle_boundary_indices[3]; //the node_id of the triangle original vertex or a fake id if (it_fb!=faces_boundary.end()){ //the boundary of the triangle face was refined @@ -899,13 +899,13 @@ public: triangle_boundary[1]=f->halfedge()->next()->vertex(); //-2 triangle_boundary[2]=f->halfedge()->next()->next()->vertex(); //-3 CGAL_assertion(f->halfedge()->next()->next()->next()==f->halfedge());//check this is a triangle - set_triangle_boundary_indices(triangle_boundary,triangle_boundary_indices); + set_triangle_boundary_indices(triangle_boundary,triangle_boundary_indices); edge_to_hedge.insert (std::make_pair( std::make_pair( triangle_boundary_indices[2],triangle_boundary_indices[0] ) , f->halfedge() ) ); edge_to_hedge.insert (std::make_pair( std::make_pair( triangle_boundary_indices[0],triangle_boundary_indices[1] ) , f->halfedge()->next() ) ); edge_to_hedge.insert (std::make_pair( std::make_pair( triangle_boundary_indices[1],triangle_boundary_indices[2] ) , f->halfedge()->next()->next() ) ); } - + #ifdef DO_NO_USE_EXACT_CDT typename Kernel::Plane_3 plane( get(ppmap,triangle_boundary[0]),get(ppmap,triangle_boundary[1]),get(ppmap,triangle_boundary[2])); #else @@ -923,8 +923,8 @@ public: vh->info()=*it_node_id; id_to_CDT_vh.insert(std::make_pair(*it_node_id,vh)); } - - + + typename CDT::Vertex_handle triangle_vertices[3]; #ifdef DO_NO_USE_EXACT_CDT triangle_vertices[0]=triangulation.insert(plane.to_2d(get(ppmap,triangle_boundary[0]))); @@ -934,9 +934,9 @@ public: //we can do this because these are input points. triangle_vertices[0]=triangulation.insert(plane.to_2d(convert(get(ppmap,triangle_boundary[0])))); triangle_vertices[1]=triangulation.insert(plane.to_2d(convert(get(ppmap,triangle_boundary[1])))); - triangle_vertices[2]=triangulation.insert(plane.to_2d(convert(get(ppmap,triangle_boundary[2])))); + triangle_vertices[2]=triangulation.insert(plane.to_2d(convert(get(ppmap,triangle_boundary[2])))); #endif - + triangle_vertices[0]->info()=triangle_boundary_indices[0]; triangle_vertices[1]->info()=triangle_boundary_indices[1]; triangle_vertices[2]->info()=triangle_boundary_indices[2]; @@ -944,13 +944,13 @@ public: node_to_polyhedron_vertex[-1]=triangle_boundary[0]; node_to_polyhedron_vertex[-2]=triangle_boundary[1]; node_to_polyhedron_vertex[-3]=triangle_boundary[2]; - + //if one of the triangle original vertex is also a node for (int ik=0;ik<3;++ik){ if ( triangle_boundary_indices[ik]>=0 ) id_to_CDT_vh.insert(std::make_pair(triangle_boundary_indices[ik],triangle_vertices[ik])); } - //insert points on edges + //insert points on edges #ifdef DO_NO_USE_EXACT_CDT //and constrains these edges #endif @@ -973,7 +973,7 @@ public: #ifdef DO_NO_USE_EXACT_CDT typename CDT::Vertex_handle vh=triangulation.insert(plane.to_2d(nodes[*it_id])); #else - typename CDT::Vertex_handle vh=triangulation.insert(plane.to_2d(nodes.exact_node(*it_id))); + typename CDT::Vertex_handle vh=triangulation.insert(plane.to_2d(nodes.exact_node(*it_id))); #endif vh->info()=*it_id; id_to_CDT_vh.insert(std::make_pair(*it_id,vh)); @@ -998,28 +998,28 @@ public: #endif } } - + std::list > constrained_edges; - + //insert constraints that are interior to the triangle (in the case no edges are collinear in the meshes) insert_constrained_edges(node_ids,triangulation,id_to_CDT_vh,constrained_edges); - + //insert constraints between points that are on the boundary (not a contrained on the triangle boundary) if (it_fb!=faces_boundary.end()) //is there at least one intersection point on the boundary of the face? { for (int i=0;i<3;++i){ - Node_ids& bounding_ids=it_fb->second.node_ids_array[i]; + Node_ids& bounding_ids=it_fb->second.node_ids_array[i]; insert_constrained_edges(bounding_ids,triangulation,id_to_CDT_vh,constrained_edges,true); } } - + //insert coplanar edges for endpoints of triangles for (int i=0;i<3;++i){ int nindex=triangle_vertices[i]->info(); if ( nindex >=0 ) insert_constrained_edges_coplanar_case(nindex,triangulation,id_to_CDT_vh); } - + //XSL_TAG_CPL_VERT //collect edges incident to a point that is the intersection of two coplanar faces. //This ensure that triangulations are compatible. @@ -1028,7 +1028,7 @@ public: for (typename CDT::Finite_vertices_iterator vit=triangulation.finite_vertices_begin(), vit_end=triangulation.finite_vertices_end();vit_end!=vit;++vit) { - //skip original vertices (that are not nodes) and non-coplanar facet issued vertices + //skip original vertices (that are not nodes) and non-coplanar facet issued vertices //(this is working because intersection points between coplanar facets are the first inserted) if ( vit->info() < 0 || vit->info() >= number_coplanar_vertices) continue; std::map< int,std::set >::iterator res=coplanar_constraints.insert(std::make_pair(vit->info(),std::set())).first; @@ -1039,20 +1039,20 @@ public: if (triangulation.is_infinite(*curr) ) continue; typename CDT::Edge mirror_edge=triangulation.mirror_edge(*curr); if ( triangulation.is_infinite( curr->first->vertex(curr->second) ) || - triangulation.is_infinite( mirror_edge.first->vertex(mirror_edge.second) ) ) + triangulation.is_infinite( mirror_edge.first->vertex(mirror_edge.second) ) ) continue; //skip edges that are on the boundary of the triangle (these are already constrained) //insert edges in the set of constraints - int nindex = + int nindex = curr->first->vertex( (curr->second+1)%3 )==static_cast(vit)? (curr->second+2)%3:(curr->second+1)%3; typename CDT::Vertex_handle vn=curr->first->vertex(nindex); if ( vit->info() > vn->info() ) continue; //take only one out of the two edges + skip negative vn->info() - CGAL_assertion(vn->info()>=0); + CGAL_assertion(vn->info()>=0); res->second.insert( vn->info() ); }while(start!=++curr); } - -// this is a working alternative that should be slower + +// this is a working alternative that should be slower // for (typename CDT::Finite_edges_iterator eit=triangulation.finite_edges_begin(), // eit_end=triangulation.finite_edges_end();eit_end!=eit;++eit) // { @@ -1067,17 +1067,17 @@ public: // coplanar_constraints.insert(std::make_pair(v1->info(),std::set())).first->second.insert(v2->info()); // } } - - + + //create a modifier to insert nodes and copy the triangulation of the face //inside the polyhedron internal_IOP::Triangulate_a_face modifier( f, nodes, node_ids, node_to_polyhedron_vertex, edge_to_hedge, triangulation, facet_construct, node_vertex_visitor, ppmap); - + CGAL_assertion(P->is_valid()); P->delegate(modifier); CGAL_assertion(P->is_valid()); - + //3) mark halfedges that are common to two polyhedral surfaces //recover halfedges inserted that are on the intersection for (std::list >::iterator it_cst=constrained_edges.begin();it_cst!=constrained_edges.end();++it_cst) @@ -1107,7 +1107,7 @@ public: put(m_edge_mark_pmap,std::make_pair(it_poly_hedge->second,P),true); put(m_edge_mark_pmap,std::make_pair(it_poly_hedge->second->opposite(),P),true); //setting the opposite is only needed for border edges (done in adjacent triangle otherwise) } - update_edge_per_polyline(P,it_poly_hedge->first,it_poly_hedge->second); + update_edge_per_polyline(P,it_poly_hedge->first,it_poly_hedge->second); } } } @@ -1149,7 +1149,7 @@ public: }; }//namespace CGAL - + #endif //CGAL_INTERSECTION_OF_POLYHEDRA_3_REFINEMENT_VISITOR_H