diff --git a/Packages/Nef_3/TODO b/Packages/Nef_3/TODO index a3f671a997d..42f4a94ad9e 100644 --- a/Packages/Nef_3/TODO +++ b/Packages/Nef_3/TODO @@ -1,8 +1,11 @@ Nef_3 Package: TODO --------------------------------------------------------------------- +- Solve null pointer info on sphere vertices problem when the overlayer + is called. - Qualify x with respect to P(1-i). - Binary operations +- Replace new and delete instructions by the corresponding Allocator methods. - Change &D.mark() to D.set_mark(...) and D.get_mark(...) - Extended kernel with infimaximal box - Define endpoint of segments used for ray shoting to be in the diff --git a/Packages/Nef_3/include/CGAL/Nef_3/SNC_SM_checker.h b/Packages/Nef_3/include/CGAL/Nef_3/SNC_SM_checker.h index eb31e9961c0..b307683cdc3 100644 --- a/Packages/Nef_3/include/CGAL/Nef_3/SNC_SM_checker.h +++ b/Packages/Nef_3/include/CGAL/Nef_3/SNC_SM_checker.h @@ -115,7 +115,7 @@ check_order_preserving_embedding(SVertex_const_handle v) const !strictly_ordered_ccw_at(p,direction(e),direction(en), direction(ef)) ) { error_status << "ccw order violate!" << endl << '\0'; - CGAL_assertion_msg(0,error_status.str()); + CGAL_nef3_assertion_msg(0,error_status.str()); } e = en; } @@ -137,7 +137,7 @@ void SNC_SM_checker:: check_is_triangulation() const { check_integrity_and_topological_planarity(false); - CGAL_assertion(number_of_connected_components() == 1); + CGAL_nef3_assertion(number_of_connected_components() == 1); check_order_preserving_embedding(); std::ostrstream error_status; @@ -151,7 +151,7 @@ check_is_triangulation() const error_status << PH(hit); ++edges_in_face_cycle; } - CGAL_assertion_msg(edges_in_face_cycle==3,error_status.str()); + CGAL_nef3_assertion_msg(edges_in_face_cycle==3,error_status.str()); } error_status.freeze(0); } diff --git a/Packages/Nef_3/include/CGAL/Nef_3/SNC_SM_decorator.h b/Packages/Nef_3/include/CGAL/Nef_3/SNC_SM_decorator.h index a55ae76f509..60d65764ccb 100644 --- a/Packages/Nef_3/include/CGAL/Nef_3/SNC_SM_decorator.h +++ b/Packages/Nef_3/include/CGAL/Nef_3/SNC_SM_decorator.h @@ -142,6 +142,7 @@ the sphere map of |v|.}*/ Vertex_handle center_vertex() const { return psm_; } +/* This code chunk should be in SNC_SM_const_decorator */ SVertex_const_handle source(SHalfedge_const_handle e) const { return e->source_; } SVertex_const_handle target(SHalfedge_const_handle e) const diff --git a/Packages/Nef_3/include/CGAL/Nef_3/SNC_SM_io_parser.h b/Packages/Nef_3/include/CGAL/Nef_3/SNC_SM_io_parser.h index be8e534873c..495d09bda66 100644 --- a/Packages/Nef_3/include/CGAL/Nef_3/SNC_SM_io_parser.h +++ b/Packages/Nef_3/include/CGAL/Nef_3/SNC_SM_io_parser.h @@ -226,13 +226,13 @@ bool SNC_SM_io_parser::read_edge(SHalfedge_handle e) !(in >> m) || !check_sep("}") || !(in >> k) || !check_sep("}") ) return false; - CGAL_assertion_msg + CGAL_nef3_assertion_msg (eo >= 0 && eo < en && epr >= 0 && epr < en && ene >= 0 && ene < en && v >= 0 && v < vn && f >= 0 && f < fn , "wrong index in read_edge"); // precond: features exist! - CGAL_assertion(EI[twin(e)]); + CGAL_nef3_assertion(EI[twin(e)]); set_prev(e,Edge_of[epr]); set_next(e,Edge_of[ene]); set_source(e,Vertex_of[v]); @@ -262,7 +262,7 @@ bool SNC_SM_io_parser::read_loop(SHalfloop_handle l) !(in >> m) || !check_sep("}") || !(in >> k) || !check_sep("}") ) return false; - CGAL_assertion_msg( + CGAL_nef3_assertion_msg( (lo >= 0 && lo < 2 && f >= 0 && f < fn),"wrong index in read_edge"); set_face(l,Face_of[f]); @@ -294,17 +294,17 @@ bool SNC_SM_io_parser::read_face(SFace_handle f) int n, ei, vi, li; Mark m; if ( !(in >> n) || !check_sep("{") ) return false; while (in >> ei) { - CGAL_assertion_msg(ei >= 0 && ei < en, "wrong index in face cycle list."); + CGAL_nef3_assertion_msg(ei >= 0 && ei < en, "wrong index in face cycle list."); store_boundary_object(Edge_of[ei],f); } in.clear(); if (!check_sep(",")) { return false; } while (in >> vi) { - CGAL_assertion_msg(vi >= 0 && vi < vn, "wrong index in iso vertex list."); + CGAL_nef3_assertion_msg(vi >= 0 && vi < vn, "wrong index in iso vertex list."); store_boundary_object(Vertex_of[vi],f); } in.clear(); if (!check_sep(",")) { return false; } while (in >> li) { - CGAL_assertion_msg(li >= 0 && li < 2, "wrong index in iso vertex list."); + CGAL_nef3_assertion_msg(li >= 0 && li < 2, "wrong index in iso vertex list."); store_boundary_object(Loop_of[li],f); } in.clear(); if (!check_sep(",") || !(in >> m) || !check_sep("}") ) @@ -346,15 +346,15 @@ template void SNC_SM_io_parser::read() { if ( !check_sep("Sphere Map") ) - CGAL_assertion_msg(0,"SNC_SM_io_parser::read: no embedded_PM header."); + CGAL_nef3_assertion_msg(0,"SNC_SM_io_parser::read: no embedded_PM header."); if ( !(check_sep("svertices") && (in >> vn)) ) - CGAL_assertion_msg(0,"SNC_SM_io_parser::read: wrong vertex line."); + CGAL_nef3_assertion_msg(0,"SNC_SM_io_parser::read: wrong vertex line."); if ( !(check_sep("shalfedges") && (in >> en) && (en%2==0)) ) - CGAL_assertion_msg(0,"SNC_SM_io_parser::read: wrong edge line."); + CGAL_nef3_assertion_msg(0,"SNC_SM_io_parser::read: wrong edge line."); if ( !(check_sep("shalfloops") && (in >> ln)) ) - CGAL_assertion_msg(0,"SNC_SM_io_parser::read: wrong loop line."); + CGAL_nef3_assertion_msg(0,"SNC_SM_io_parser::read: wrong loop line."); if ( !(check_sep("sfaces") && (in >> fn)) ) - CGAL_assertion_msg(0,"SNC_SM_io_parser::read: wrong face line."); + CGAL_nef3_assertion_msg(0,"SNC_SM_io_parser::read: wrong face line."); Vertex_of.reserve(vn); Edge_of.reserve(en); @@ -369,18 +369,18 @@ void SNC_SM_io_parser::read() for(i=0; inew_volume(); diff --git a/Packages/Nef_3/include/CGAL/Nef_3/SNC_decorator.h b/Packages/Nef_3/include/CGAL/Nef_3/SNC_decorator.h index 057350fd4eb..2904442e485 100644 --- a/Packages/Nef_3/include/CGAL/Nef_3/SNC_decorator.h +++ b/Packages/Nef_3/include/CGAL/Nef_3/SNC_decorator.h @@ -204,16 +204,16 @@ public: SFace_handle adjacent_sface(Halffacet_handle f) const { Halffacet_cycle_iterator fc(f->facet_cycles_begin()); - CGAL_assertion( fc != f->facet_cycles_end()); + CGAL_nef3_assertion( fc != f->facet_cycles_end()); SHalfedge_handle se; if ( assign(se, fc) ) { - CGAL_assertion( facet(se) == f); - CGAL_assertion( sface(se) != SFace_handle()); - CGAL_assertion( volume(sface(twin(se))) == volume(f)); + CGAL_nef3_assertion( facet(se) == f); + CGAL_nef3_assertion( sface(se) != SFace_handle()); + CGAL_nef3_assertion( volume(sface(twin(se))) == volume(f)); return sface(twin(se)); } else - CGAL_assertion_msg( 0, "Facet outer cycle entry point" + CGAL_nef3_assertion_msg( 0, "Facet outer cycle entry point" "is not an SHalfedge? "); return SFace_handle(); // never reached } @@ -276,7 +276,7 @@ public: template void undo_boundary_object(H h, Halffacet_handle f) const - { CGAL_assertion(sncp()->is_boundary_object(h)); + { CGAL_nef3_assertion(sncp()->is_boundary_object(h)); Halffacet_cycle_iterator it = sncp()->boundary_item(h); sncp()->undef_boundary_item(h); f->boundary_entry_objects_.erase(it); @@ -302,7 +302,7 @@ public: template void undo_boundary_object(H h, Volume_handle c) const - { CGAL_assertion(sncp()->is_boundary_object(h)); + { CGAL_nef3_assertion(sncp()->is_boundary_object(h)); Shell_entry_iterator it = sncp()->boundary_item(h); sncp()->undef_boundary_item(h); c->shell_entry_objects_.erase(it); @@ -327,7 +327,7 @@ public: }; void link_as_outer_shell( SFace_handle f, Volume_handle c ) const { - CGAL_assertion(c->shell_entry_objects_.size() == 0); + CGAL_nef3_assertion(c->shell_entry_objects_.size() == 0); Shell_volume_setter Setter(*this, c); visit_shell_objects( f, Setter ); TRACEN("Volume "<<&*c<<", outer shell "<<&*f); @@ -335,7 +335,7 @@ public: } void link_as_inner_shell( SFace_handle f, Volume_handle c ) const { - // CGAL_assertion(c->shell_entry_objects_.size() > 0); + // CGAL_nef3_assertion(c->shell_entry_objects_.size() > 0); Shell_volume_setter Setter(*this, c); visit_shell_objects( f, Setter ); TRACEN("Volume "<<&*c<<", inner shell "<<&*f); @@ -356,7 +356,7 @@ public: void clear_outer_box_marks() { SFace_handle sf; - CGAL_assertion( assign( sf, shells_begin(volumes_begin()))); + CGAL_nef3_assertion( assign( sf, shells_begin(volumes_begin()))); assign( sf, shells_begin(volumes_begin())); Shell_mark_setter Setter( *this, false); visit_shell_objects( sf, Setter ); @@ -376,7 +376,7 @@ public: l->incident_facet_ = f; SD.twin(l)->incident_facet_ = twin(f); } else { - CGAL_assertion( facet_plane.opposite() == SD.circle(l)); + CGAL_nef3_assertion( facet_plane.opposite() == SD.circle(l)); l->incident_facet_ = twin(f); SD.twin(l)->incident_facet_ = f; } @@ -409,13 +409,13 @@ public: \precondition |ray| target is on |v| and the intersection between |ray| and the 2-skeleton incident to v is empty. }*/ { Halffacet_handle f_visible; - CGAL_assertion( ray.target() == point(v)); + CGAL_nef3_assertion( ray.target() == point(v)); Sphere_point sp(ray.source() - point(v)); TRACEN( "Locating " << sp <<" in " << point(v)); SM_point_locator L(v); SObject_handle o = L.locate(sp); SFace_const_handle sf; - CGAL_assertion( assign( sf, o)); + CGAL_nef3_assertion( assign( sf, o)); assign( sf, o); SFace_cycle_const_iterator fc = sf->sface_cycles_begin(), fce = sf->sface_cycles_end(); @@ -435,7 +435,7 @@ public: f_visible = facet(twin(sl)); } else - CGAL_assertion_msg(0, "Damn, wrong handle."); + CGAL_nef3_assertion_msg(0, "Damn, wrong handle."); } return f_visible; } @@ -447,7 +447,7 @@ public: facets in the adjacency list of |e| that could be 'seen' from the piercing point of the |ray| on the local (virtual) view of |e| \precondition |ray| target belongs to |e|. }*/ { - CGAL_assertion( segment(e).has_on( ray.target())); + CGAL_nef3_assertion( segment(e).has_on( ray.target())); SM_decorator SD; if( SD.is_isolated(e)) return Halffacet_handle(); @@ -491,19 +491,23 @@ public: } template - void binop_local_views( Vertex_handle v0, Vertex_handle v1, - const Selection& BOP) + Vertex_handle binop_local_views( Vertex_handle v0, Vertex_handle v1, + const Selection& BOP) /*{\op }*/ { typedef SNC_SM_io_parser SNC_SM_io_parser; SNC_SM_io_parser IO0( std::cerr, v0); SNC_SM_io_parser IO1( std::cerr, v1); + TRACEN(v0->debug()); + TRACEN(v1->debug()); IO0.print(); IO1.print(); - SM_overlayer O(v0); + Vertex_handle v01 = sncp()->new_vertex(); + SM_overlayer O(v01); O.subdivide( v0, v1); O.select( BOP); O.simplify(); + return v01; } #ifdef DEADCODE @@ -526,6 +530,7 @@ public: Vertex_handle create_local_view_on( const Point_3& p, Halfedge_handle e) { SNC_constructor C(*sncp()); + TRACEN("<-> edge local view on "< facet local view on "< volume local view on "< vertex local view on "< void binary_operation( SNC_structure& snc1i, const Selection& BOP) /*{\op }*/ { + typedef Unique_hash_map Hash_map; + Hash_map Stay(false); SNC_ray_shoter rs(*sncp()); - Vertex_handle v0, v1; + Vertex_iterator v0, v1; CGAL_nef3_forall_vertices( v0, *sncp()) { + if( Stay[v0]) continue; v1 = qualify_with_respect( point(v0), snc1i); - binop_local_views( v0, v1, BOP); /* result on v0 */ - if( v1->sncp() == sncp()) - sncp()->delete_vertex(v1); /* delete v1 only if that sphere map is - a local copy */ + TRACEN("bionop of vertices "<<&*v0<<" "<<&*v1); + Stay[binop_local_views( v0, v1, BOP)] = true; } CGAL_nef3_forall_vertices( v1, snc1i) { + if( Stay[v1]) continue; v0 = qualify_with_respect( point(v1), *sncp()); - binop_local_views( v0, v1, BOP); /* result on v0 */ + TRACEN("bionop of vertices "<<&*v0<<" "<<&*v1); + Stay[binop_local_views( v0, v1, BOP)] = true; } - Halfedge_handle e0, e1; - Halffacet_handle f0, f1; + Halfedge_iterator e0, e1; + Halffacet_iterator f0, f1; CGAL_nef3_forall_edges( e0, *sncp()) { CGAL_nef3_forall_facets( f1, snc1i) { Point_3 ip; if( rs.does_intersect_internally( segment(e0), f1, ip )) { v0 = qualify_with_respect( ip, *sncp()); v1 = qualify_with_respect( ip, snc1i); - binop_local_views( v0, v1, BOP); /* result on vi */ - sncp()->delete_vertex(v1); + Stay[binop_local_views( v0, v1, BOP)] = true; } } } @@ -669,8 +680,7 @@ public: if( rs.does_intersect_internally( segment(e1), f0, ip )) { v1 = qualify_with_respect( ip, snc1i); v0 = qualify_with_respect( ip, *sncp()); - binop_local_views( v0, v1, BOP); // result on vi - sncp()->delete_vertex(v1); + Stay[binop_local_views( v0, v1, BOP)] = true; } } } @@ -681,15 +691,24 @@ public: Vertex_handle v0, v1; v0 = qualify_with_respect( ip, *sncp()); v1 = qualify_with_respect( ip, snc1i); - binop_local_views( v0, v1, BOP); // result on v0 - sncp()->delete_vertex(v1); + Stay[binop_local_views( v0, v1, BOP)] = true; } } } + CGAL_nef3_forall_vertices( v0, *sncp()) + if( !Stay[v0]) sncp()->delete_vertex(v0); // remove vertices whose local view is not that of a vertex // TO VERIFY: clean adjacency information before next step? // synthesis of spatial structure + + // this code corresponds to build_external_extructure on + // Nef_polyhedron_3.h + SNC_constructor C(*sncp()); + C.pair_up_halfedges(); + C.link_shalfedges_to_facet_cycles(); + C.categorize_facet_cycles_and_create_facets(); + C.create_volumes(); } template @@ -784,7 +803,7 @@ visit_shell_objects(SFace_handle f, Visitor& V) const if ( Done[sface(l)] ) continue; SFaceCandidates.push_back(sface(l)); Done[sface(l)] = true; - } else CGAL_assertion_msg(0,"Damn wrong handle."); + } else CGAL_nef3_assertion_msg(0,"Damn wrong handle."); } } if ( !SFaceCandidates.empty() ) { @@ -820,7 +839,7 @@ visit_shell_objects(SFace_handle f, Visitor& V) const Halffacet_handle f = facet(twin(l)); if ( Done[f] ) continue; FacetCandidates.push_back(f); Done[f] = true; - } else CGAL_assertion_msg(0,"Damn wrong handle."); + } else CGAL_nef3_assertion_msg(0,"Damn wrong handle."); } } } diff --git a/Packages/Nef_3/include/CGAL/Nef_3/SNC_io_parser.h b/Packages/Nef_3/include/CGAL/Nef_3/SNC_io_parser.h index a1f10acbddc..8fd3dd9a518 100644 --- a/Packages/Nef_3/include/CGAL/Nef_3/SNC_io_parser.h +++ b/Packages/Nef_3/include/CGAL/Nef_3/SNC_io_parser.h @@ -165,7 +165,7 @@ public: template SNC_io_parser::SNC_io_parser(std::istream& is, SNC_structure& W) : Base(W), in(is), out(std::cout) -{ CGAL_assertion(W.empty()); +{ CGAL_nef3_assertion(W.empty()); verbose = false; } template @@ -263,21 +263,21 @@ template void SNC_io_parser::read() { if ( !check_sep("Selective Nef Complex") ) - CGAL_assertion_msg(0,"SNC_io_parser::read: no embedded_PM header."); + CGAL_nef3_assertion_msg(0,"SNC_io_parser::read: no embedded_PM header."); if ( !(check_sep("vertices") && (in >> vn)) ) - CGAL_assertion_msg(0,"SNC_io_parser::read: wrong vertex line."); + CGAL_nef3_assertion_msg(0,"SNC_io_parser::read: wrong vertex line."); if ( !(check_sep("halfedges") && (in >> en) && (en%2==0)) ) - CGAL_assertion_msg(0,"SNC_io_parser::read: wrong edge line."); + CGAL_nef3_assertion_msg(0,"SNC_io_parser::read: wrong edge line."); if ( !(check_sep("facets") && (in >> fn) && (fn%2==0)) ) - CGAL_assertion_msg(0,"SNC_io_parser::read: wrong facet line."); + CGAL_nef3_assertion_msg(0,"SNC_io_parser::read: wrong facet line."); if ( !(check_sep("volumes") && (in >> cn)) ) - CGAL_assertion_msg(0,"SNC_io_parser::read: wrong volume line."); + CGAL_nef3_assertion_msg(0,"SNC_io_parser::read: wrong volume line."); if ( !(check_sep("shalfedges") && (in >> sen)) ) - CGAL_assertion_msg(0,"SNC_io_parser::read: wrong sedge line."); + CGAL_nef3_assertion_msg(0,"SNC_io_parser::read: wrong sedge line."); if ( !(check_sep("shalfloops") && (in >> sln)) ) - CGAL_assertion_msg(0,"SNC_io_parser::read: wrong sloop line."); + CGAL_nef3_assertion_msg(0,"SNC_io_parser::read: wrong sloop line."); if ( !(check_sep("sfaces") && (in >> sfn)) ) - CGAL_assertion_msg(0,"SNC_io_parser::read: wrong sface line."); + CGAL_nef3_assertion_msg(0,"SNC_io_parser::read: wrong sface line."); Vertex_of.reserve(vn); Edge_of.reserve(en); @@ -297,31 +297,31 @@ void SNC_io_parser::read() for(i=0; i> p) || !check_sep("}") ) return false; - CGAL_assertion_msg( + CGAL_nef3_assertion_msg( Vertex_of[n] == v && svs >= 0 && svs < en && sve >= 0 && sve < en && ses >= 0 && ses < sen && see >= 0 && see < sen && @@ -397,7 +397,7 @@ read_edge(Halfedge_handle e) const return false; if (iso) efm=sfn; else efm=sen; - CGAL_assertion_msg ( + CGAL_nef3_assertion_msg ( Edge_of[n] == e && et >= 0 && et < en && vs >= 0 && vs < vn && ef >= 0 && et < efm , "wrong index in read_edge"); @@ -430,13 +430,13 @@ read_facet(Halffacet_handle f) const int n, ei, li; Mark m; if ( !(in >> n) || !check_sep("{") ) return false; while (in >> ei) { - CGAL_assertion_msg(ei >= 0 && ei < sen, + CGAL_nef3_assertion_msg(ei >= 0 && ei < sen, "wrong index in facet cycle list."); store_boundary_object(SEdge_of[ei],f); } in.clear(); if (!check_sep(",")) { return false; } while (in >> li) { - CGAL_assertion_msg(li >= 0 && li < sln, + CGAL_nef3_assertion_msg(li >= 0 && li < sln, "wrong index in facet cycle list."); store_boundary_object(SLoop_of[li],f); } in.clear(); @@ -463,7 +463,7 @@ read_volume(Volume_handle c) const int n, fi; Mark m; if ( !(in >> n) || !check_sep("{") ) return false; while (in >> fi) { - CGAL_assertion_msg(fi >= 0 && fi < sfn, + CGAL_nef3_assertion_msg(fi >= 0 && fi < sfn, "wrong index in shell list."); store_boundary_object(SFace_of[fi],c); } in.clear(); @@ -503,7 +503,7 @@ read_sedge(SHalfedge_handle e) const !(in >> en) || !check_sep(",") || !(in >> ft) || !check_sep("}") ) return false; - CGAL_assertion_msg + CGAL_nef3_assertion_msg (et >= 0 && et < sen && sp >= 0 && sp < sen && sn >= 0 && sn < sen && vs >= 0 && vs < en && sf >= 0 && sf < sfn && ep >= 0 && ep < sen && @@ -511,7 +511,7 @@ read_sedge(SHalfedge_handle e) const "wrong index in read_sedge"); // precond: features exist! - CGAL_assertion(SEdge_of[n]==e); + CGAL_nef3_assertion(SEdge_of[n]==e); e->sprev_ = SEdge_of[sp]; e->snext_ = SEdge_of[sn]; e->source_ = Edge_of[vs]; @@ -543,12 +543,12 @@ read_sloop(SHalfloop_handle l) const !(in >> sf) || !check_sep(",") || !(in >> ft) || !check_sep("}") ) return false; - CGAL_assertion_msg + CGAL_nef3_assertion_msg (lt >= 0 && lt < sen && sf >= 0 && sf < sfn && ft >= 0 && ft < fn , "wrong index in read_sedge"); - CGAL_assertion(SLoop_of[n]==l); + CGAL_nef3_assertion(SLoop_of[n]==l); l->twin_ = SLoop_of[lt]; l->incident_sface_ = SFace_of[sf]; l->incident_facet_ = Halffacet_of[ft]; @@ -582,22 +582,22 @@ read_sface(SFace_handle f) const if ( !(in >> n) || !check_sep("{") || !(in >> vc) || !check_sep(",") ) return false; - CGAL_assertion(vc >= 0 && vc < vn); + CGAL_nef3_assertion(vc >= 0 && vc < vn); f->center_vertex_ = Vertex_of[vc]; SM_decorator D(Vertex_of[vc]); while (in >> ei) { - CGAL_assertion_msg(ei >= 0 && ei < sen, + CGAL_nef3_assertion_msg(ei >= 0 && ei < sen, "wrong index in sface cycle list."); D.store_boundary_object(SEdge_of[ei],f); } in.clear(); while (in >> vi) { - CGAL_assertion_msg(vi >= 0 && vi < en, + CGAL_nef3_assertion_msg(vi >= 0 && vi < en, "wrong index in sface cycle list."); D.store_boundary_object(Edge_of[vi],f); } in.clear(); if (!check_sep(",")) { return false; } while (in >> li) { - CGAL_assertion_msg(li >= 0 && li < sln, + CGAL_nef3_assertion_msg(li >= 0 && li < sln, "wrong index in sface cycle list."); D.store_boundary_object(SLoop_of[li],f); } in.clear(); diff --git a/Packages/Nef_3/include/CGAL/Nef_3/SNC_items.h b/Packages/Nef_3/include/CGAL/Nef_3/SNC_items.h index d36a0f87431..b505bfe470d 100644 --- a/Packages/Nef_3/include/CGAL/Nef_3/SNC_items.h +++ b/Packages/Nef_3/include/CGAL/Nef_3/SNC_items.h @@ -287,6 +287,22 @@ public: Mark& mark() { return mark_; } GenPtr& info() { return info_; } + public: + std::string debug() const + { std::stringstream os; + set_pretty_mode(os); + os<<"{ addr, point, mark, snc, svb, sve, seb, see, sfb, sfe, sl," + <<" mneg, mpos, info }"<debug()<<"," - <source_->debug()<<" "<debug()<<", " + <source_->debug()<<" "< facet plane " << h); TRACEN("-> a point on " << h.point()); TRACEN("-> seg segment " << seg); - CGAL_assertion( !h.is_degenerate()); + CGAL_nef3_assertion( !h.is_degenerate()); if( seg.is_degenerate()) /* no possible internal intersection */ return false; @@ -369,15 +369,15 @@ public: Oriented_side os1 = h.oriented_side(seg.source()); Oriented_side os2 = h.oriented_side(seg.target()); TRACEN( "-> endpoint plane side " << os1 << " " << os2); - CGAL_assertion( h.has_on(p)); - CGAL_assertion( seg.has_on(p)); + CGAL_nef3_assertion( h.has_on(p)); + CGAL_nef3_assertion( seg.has_on(p)); if (os1 == os2) return false; #endif //REDUNDANT_CODE Object o = intersection( h, seg); Segment_3 s; if ( assign( s, o) ) { - CGAL_assertion( s == seg ); + CGAL_nef3_assertion( s == seg ); TRACEN( "-> seg belongs to facet's plane." << p ); return false; } @@ -398,7 +398,7 @@ public: typedef Container_from_circulator Container; Plane_3 h(plane(f)); - CGAL_assertion(h.has_on(p)); + CGAL_nef3_assertion(h.has_on(p)); Halffacet_cycle_iterator fc = f->facet_cycles_begin(); SHalfedge_handle se; Bounded_side outer_bound_pos; @@ -406,11 +406,11 @@ public: SHalfedge_around_facet_circulator hfc(se); Circulator c(hfc); Container ct(c); - CGAL_assertion( !is_empty_range(ct.begin(), ct.end())); + CGAL_nef3_assertion( !is_empty_range(ct.begin(), ct.end())); outer_bound_pos = bounded_side_3(ct.begin(), ct.end(), p, h); } else - CGAL_assertion_msg(0, "is facet first cycle a SHalfloop?"); + CGAL_nef3_assertion_msg(0, "is facet first cycle a SHalfloop?"); if( outer_bound_pos != CGAL::ON_BOUNDED_SIDE ) return outer_bound_pos; /* The point p is not in the relative interior of the outer face cycle @@ -433,12 +433,12 @@ public: SHalfedge_around_facet_circulator hfc(se); Circulator c(hfc); Container ct(c); - CGAL_assertion( !is_empty_range(ct.begin(), ct.end())); + CGAL_nef3_assertion( !is_empty_range(ct.begin(), ct.end())); inner_bound_pos = bounded_side_3( ct.begin(), ct.end(), p, h.opposite()); } else - CGAL_assertion_msg(0, "Damn wrong handle."); + CGAL_nef3_assertion_msg(0, "Damn wrong handle."); if( inner_bound_pos != CGAL::ON_UNBOUNDED_SIDE ) return opposite(inner_bound_pos); /* At this point the point p belongs to relative interior of the facet's diff --git a/Packages/Nef_3/include/CGAL/Nef_3/SNC_structure.h b/Packages/Nef_3/include/CGAL/Nef_3/SNC_structure.h index d81ddce91d5..7cc19bc5d7d 100644 --- a/Packages/Nef_3/include/CGAL/Nef_3/SNC_structure.h +++ b/Packages/Nef_3/include/CGAL/Nef_3/SNC_structure.h @@ -70,7 +70,7 @@ struct move_shalfedge_around_facet { template void merge_sets( Object o1, Object o2, Hash_map& hash, Union_find& uf) { - CGAL_assertion( hash[o1] != 0 && hash[o2] != 0); + CGAL_nef3_assertion( hash[o1] != 0 && hash[o2] != 0); if( !uf.same_set( hash[o1], hash[o2])) uf.unify_sets( hash[o1], hash[o2]); } @@ -849,7 +849,7 @@ public: /* determines if a vertex v is part of a volume, cheking if its local graph is trivial (only one sface with no boundary). */ { SM_decorator SD(v); - CGAL_assertion( !is_empty_range( SD.sfaces_begin(), SD.sfaces_end())); + CGAL_nef3_assertion( !is_empty_range( SD.sfaces_begin(), SD.sfaces_end())); if( is_empty_range( SD.svertices_begin(), SD.svertices_end()) && is_empty_range( SD.shalfedges_begin(), SD.shalfedges_end()) && !SD.has_loop()) @@ -862,12 +862,16 @@ public: facet, checking if its local graph consists just of a sloop and two incident sfaces. */ { SM_decorator SD(v); - CGAL_assertion(!is_empty_range(SD.svertices_begin(),SD.svertices_end()) || + CGAL_nef3_assertion(!is_empty_range(SD.svertices_begin(),SD.svertices_end()) || is_empty_range(SD.shalfedges_begin(),SD.shalfedges_end())); return( SD.has_loop() && is_empty_range( SD.svertices_begin(), SD.svertices_end())); } + bool is_vertex(Vertex_handle v) { + return !is_part_of_facet(v) && !is_part_edge(v); + } + bool is_part_of_edge(Vertex_handle v) { /* determines if a vertex v is part of a edge, checking at its local graph for two antipodal vertices possible connected by a bundle of @@ -937,12 +941,12 @@ public: while( f != D.halffacets_end() && f->is_twin()) f++; while( f != D.halffacets_end()) { - CGAL_assertion( !f->is_twin()); + CGAL_nef3_assertion( !f->is_twin()); Halffacet_iterator f_next(f); do f_next++; while( f_next != D.halffacets_end() && f_next->is_twin()); - CGAL_assertion( f != D.twin(f)); + CGAL_nef3_assertion( f != D.twin(f)); Volume_handle c1 = D.volume(f), c2 = D.volume(D.twin(f)); TRACEN(" mark("<index(c1)<<")="<index(f) <<")="<is_twin()) e++; while( e != (*this).halfedges_end()) { - CGAL_assertion( !e->is_twin()); + CGAL_nef3_assertion( !e->is_twin()); Halfedge_iterator e_next(e); do e_next++; @@ -1013,7 +1017,7 @@ public: Vertex_iterator v_next(v); v_next++; - CGAL_assertion( SD.sfaces_begin() != SFace_handle()); + CGAL_nef3_assertion( SD.sfaces_begin() != SFace_handle()); if( is_part_of_volume(v)) { TRACEN("mark("<index(v)<<")="<index(D.volume(SD.sfaces_begin()))<<")="<< @@ -1024,7 +1028,7 @@ public: } } else if( is_part_of_facet(v)) { - CGAL_assertion( D.facet(SD.shalfloop()) != Halffacet_handle()); + CGAL_nef3_assertion( D.facet(SD.shalfloop()) != Halffacet_handle()); if( D.mark(v) == D.mark(D.facet(SD.shalfloop()))) { TRACEN("removing "<index(v)<< " on facet "<index(D.facet(SD.shalfloop()))); @@ -1034,7 +1038,7 @@ public: else if( is_part_of_edge(v)) { SVertex_iterator sv(SD.svertices_begin()); Halfedge_handle e1(sv++), e2(sv++); - CGAL_assertion( sv == SD.svertices_end()); + CGAL_nef3_assertion( sv == SD.svertices_end()); if( D.mark(e1) == D.mark(v) && D.mark(v) == D.mark(e2)) { TRACEN("merging "<index(e1)<<" & "<index(e2)<< " in "<index(v)); @@ -1055,9 +1059,9 @@ public: void remove_edge_and_merge_facet_cycles( Halfedge_handle e) { SNC_decorator D(*this); - CGAL_assertion( D.has_outdeg_two(e)); + CGAL_nef3_assertion( D.has_outdeg_two(e)); Halfedge_handle et = D.twin(e); - CGAL_assertion( D.has_outdeg_two(et)); + CGAL_nef3_assertion( D.has_outdeg_two(et)); SM_decorator SD1(D.vertex(e)); SM_decorator SD2(D.vertex(et)); SHalfedge_handle e1 = SD1.first_out_edge(e); @@ -1070,18 +1074,18 @@ public: SVertex_handle v) { SNC_decorator D(*this); SM_decorator SD(D.vertex(v)); - CGAL_assertion( SD.target(s1) == v); + CGAL_nef3_assertion( SD.target(s1) == v); SHalfedge_handle s2(SD.next(s1)); - CGAL_assertion( SD.source(s2) == v); + CGAL_nef3_assertion( SD.source(s2) == v); if( s1 == s2) { TRACEN(IO->index(s1)<<'('<index(D.twin(s2))<<") to sloop"); SD.convert_edge_to_loop(s1); - CGAL_assertion(SD.shalfloop() != SHalfloop_handle()); + CGAL_nef3_assertion(SD.shalfloop() != SHalfloop_handle()); D.add_sloop_to_facet( SD.shalfloop(), D.facet(s1)); TRACEN(IO->index(s2)<<" removed"); } else { - CGAL_assertion( D.has_outdeg_two(v)); + CGAL_nef3_assertion( D.has_outdeg_two(v)); D.link_as_prev_next_pair( s1, D.next(s2)); TRACEN(IO->index(s1)<<" "<index(D.next(s2))<<" linked."); D.link_as_prev_next_pair( D.twin(D.next(s2)), D.twin(s1)); @@ -1094,9 +1098,9 @@ public: void merge_halfedge_pairs( SVertex_handle p, SVertex_handle q) { SNC_decorator D(*this); - CGAL_assertion( D.vertex(p) == D.vertex(q)); + CGAL_nef3_assertion( D.vertex(p) == D.vertex(q)); Vertex_handle v(D.vertex(p)); - CGAL_assertion( is_part_of_edge(v)); + CGAL_nef3_assertion( is_part_of_edge(v)); SM_decorator SD(v); SHalfedge_around_svertex_circulator s(SD.first_out_edge(p)), se(s); CGAL_For_all( s, se) { @@ -1152,7 +1156,7 @@ public: continue; SM_decorator SD(D.vertex(e)); SFace_handle sf = *(uf.find(hash[D.sface(e)])); - CGAL_assertion( sf != SFace_handle()); + CGAL_nef3_assertion( sf != SFace_handle()); SHalfedge_around_sface_circulator c(e), cend(c); CGAL_For_all( c, cend) { SD.set_face(c, sf); @@ -1165,7 +1169,7 @@ public: SM_decorator SD(D.vertex(sv)); if( SD.is_isolated(sv)) { SFace_handle sf = *(uf.find(hash[D.sface(sv)])); - CGAL_assertion( sf != SFace_handle()); + CGAL_nef3_assertion( sf != SFace_handle()); SD.set_face( sv, sf); SD.store_boundary_object( sv, sf); } @@ -1200,7 +1204,7 @@ public: D.store_boundary_object( u_min, f); else { SHalfedge_handle f_sedge; - CGAL_assertion( assign( f_sedge, f->boundary_entry_objects_.front())); + CGAL_nef3_assertion( assign( f_sedge, f->boundary_entry_objects_.front())); assign( f_sedge, f->boundary_entry_objects_.front()); Point_3 p(D.point(D.vertex(f_sedge))); if( lexicographically_xyz_smaller( D.point(D.vertex(u_min)), p)) @@ -1330,8 +1334,8 @@ pointer_update(const SNC_structure& D) /* It is possible that the is_twin() property differs for equivalent facets on both SNC structures. So, we need to store the correct selection mark in the correct (non-twin) facet of a halffacet pair. */ - CGAL_assertion_code( if( fc->is_twin() == f->is_twin()) - CGAL_assertion( fc->mark_ == f->mark_)); + CGAL_nef3_assertion_code( if( fc->is_twin() == f->is_twin()) + CGAL_nef3_assertion( fc->mark_ == f->mark_)); if( !f->is_twin() && fc->is_twin()) f->mark_ = f->twin_->mark_; } // Volume update diff --git a/Packages/Nef_3/include/CGAL/Nef_3/SNC_visualizor_OGL.h b/Packages/Nef_3/include/CGAL/Nef_3/SNC_visualizor_OGL.h index 1cfc15fc1d1..9ea282a7f54 100644 --- a/Packages/Nef_3/include/CGAL/Nef_3/SNC_visualizor_OGL.h +++ b/Packages/Nef_3/include/CGAL/Nef_3/SNC_visualizor_OGL.h @@ -115,7 +115,7 @@ namespace OGL { operator double_ptr() const { return const_cast(*this).coords_; } double operator[](unsigned i) - { CGAL_assertion(i<3); return coords_[i]; } + { CGAL_nef3_assertion(i<3); return coords_[i]; } }; // Double_triple static std::ostream& operator << (std::ostream& os, @@ -183,22 +183,22 @@ namespace OGL { { return fc_ends_.size(); } Coord_iterator facet_cycle_begin(unsigned i) - { CGAL_assertion(i std::istream& operator>>(std::istream&, Nef_polyhedron_3&); template -class Nef_polyhedron_3_rep : public Rep +class Nef_polyhedron_3_rep : public Ref_counted { typedef Nef_polyhedron_3_rep Self; friend class Nef_polyhedron_3; @@ -221,7 +221,7 @@ protected: typedef typename SNC_structure::Sphere_circle Sphere_circle; Vertex_handle create_cube_corner(int x, int y, int z, bool space=false) { - CGAL_assertion(CGAL_NTS abs(x) == + CGAL_nef3_assertion(CGAL_NTS abs(x) == CGAL_NTS abs(y) == CGAL_NTS abs(z) == 1); Vertex_handle v = snc().new_vertex();