From f09c39385a509d5d76fec38d0ae1c6b7e23b5cd5 Mon Sep 17 00:00:00 2001 From: Peter Hachenberger Date: Wed, 21 Jan 2004 14:33:58 +0000 Subject: [PATCH] marks_of_halfspheres is now only computed when needed. --- .../include/CGAL/Nef_3/SNC_SM_overlayer.h | 32 ++++++++--------- .../include/CGAL/Nef_3/SNC_SM_point_locator.h | 36 ++++++++++--------- .../include/CGAL/Nef_3/SNC_constructor.h | 30 ++++++++-------- .../Nef_3/include/CGAL/Nef_3/SNC_decorator.h | 29 +++++++-------- .../Nef_3/include/CGAL/Nef_3/SNC_structure.h | 4 +++ .../CGAL/Nef_3/polyhedron_3_to_nef_3.h | 9 +++-- 6 files changed, 74 insertions(+), 66 deletions(-) diff --git a/Packages/Nef_3/include/CGAL/Nef_3/SNC_SM_overlayer.h b/Packages/Nef_3/include/CGAL/Nef_3/SNC_SM_overlayer.h index 90e49e9508c..f79dc161c88 100644 --- a/Packages/Nef_3/include/CGAL/Nef_3/SNC_SM_overlayer.h +++ b/Packages/Nef_3/include/CGAL/Nef_3/SNC_SM_overlayer.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #undef _DEBUG @@ -279,6 +280,7 @@ public: typedef SNC_SM_decorator Base; typedef SNC_SM_decorator Decorator; typedef SNC_SM_overlayer Self; + typedef CGAL::SNC_SM_point_locator SM_point_locator; #define USING(t) typedef typename Refs_::t t USING(Vertex_handle); @@ -570,7 +572,7 @@ public: template void complete_face_support(SVertex_iterator v_start, SVertex_iterator v_end, - const Below_accessor& D, int pos) const; + Below_accessor& D, std::vector& mohs, int offset); void dump(std::ostream& os = std::cerr) const { SNC_SM_io_parser::dump(center_vertex(),os); } @@ -838,8 +840,15 @@ subdivide(Vertex_handle v0, Vertex_handle v1) TRACEN(PH(u) << " with circle " << circle(u)); } - complete_face_support(svertices_begin(), v, O, +1); - complete_face_support(v, svertices_end(), O, -1); + std::vector mohs(4); + SM_point_locator L0(PI[0].center_vertex()); + SM_point_locator L1(PI[1].center_vertex()); + + L0.init_marks_of_halfspheres(mohs, 0); + L1.init_marks_of_halfspheres(mohs, 2); + + complete_face_support(svertices_begin(), v, O, mohs, 1); + complete_face_support(v, svertices_end(), O, mohs, 0); /* DEBUG CODE: to do: have all svertices a halfedge below associated? */ TRACEN("Vertex info after swep"); @@ -1007,7 +1016,7 @@ template template void SNC_SM_overlayer:: complete_face_support(SVertex_iterator v_start, SVertex_iterator v_end, - const Below_accessor& D, int pos) const + Below_accessor& D, std::vector& mohs, int offset) { TRACEN("complete_face_support"); for (SVertex_iterator v = v_start; v != v_end; ++v) { TRACEN("VERTEX = "< 0 ? (point(v).hx() >= 0) : (point(v).hx()<=0)) ); + ( offset > 0 ? (point(v).hx() >= 0) : (point(v).hx()<=0)) ); for (int i=0; i<2; ++i) m_buffer[i] = incident_mark(previous(first_out_edge(v)),i); } TRACEN(" faces right and below "<" << mark_of_halfsphere(-1)); - TRACEN(PI[0].mark_of_halfsphere(+1) << "," << PI[1].mark_of_halfsphere(+1) << "=>" << mark_of_halfsphere(+1)); - } template diff --git a/Packages/Nef_3/include/CGAL/Nef_3/SNC_SM_point_locator.h b/Packages/Nef_3/include/CGAL/Nef_3/SNC_SM_point_locator.h index efffc2e76c3..7cd7c2a2973 100644 --- a/Packages/Nef_3/include/CGAL/Nef_3/SNC_SM_point_locator.h +++ b/Packages/Nef_3/include/CGAL/Nef_3/SNC_SM_point_locator.h @@ -20,6 +20,7 @@ #ifndef CGAL_SNC_SM_POINT_LOCATOR_H #define CGAL_SNC_SM_POINT_LOCATOR_H +#include #include #include #include @@ -457,7 +458,7 @@ public: return h; } - void init_marks_of_halfspheres(); + void init_marks_of_halfspheres(std::vector& mohs, int offset); /*{\Mop initializes the default marks of the sphere map.}*/ // C++ is really friendly: @@ -484,15 +485,16 @@ public: template -void SNC_SM_point_locator::init_marks_of_halfspheres() +void SNC_SM_point_locator::init_marks_of_halfspheres(std::vector& mohs, int offset) { TRACEN("init_marks_of_halfspheres " << center_vertex()->point()); + Sphere_point y_minus(0,-1,0); SObject_handle h = locate(y_minus); SFace_const_handle f; if ( assign(f,h) ) { TRACEN("on face " << mark(f)); - mark_of_halfsphere(-1) = mark_of_halfsphere(+1) = mark(f); - TRACEN(mark_of_halfsphere(-1) << " " << mark_of_halfsphere(+1)); + mohs[offset] = mohs[offset+1] = mark(f); + // TRACEN(mark_of_halfsphere(-1) << " " << mark_of_halfsphere(+1)); return; } @@ -503,9 +505,9 @@ void SNC_SM_point_locator::init_marks_of_halfspheres() TRACEN("on edge "< 0) || (op.x() == 0) && (op.z() < 0) ) e = twin(e); // if ( (op.z() < 0) || (op.z() == 0) && (op.x() > 0) ) e = twin(e); - mark_of_halfsphere(+1) = mark(face(e)); - mark_of_halfsphere(-1) = mark(face(twin(e))); - TRACEN(mark_of_halfsphere(-1) << " " << mark_of_halfsphere(+1)); + mohs[offset+1] = mark(face(e)); + mohs[offset] = mark(face(twin(e))); + // TRACEN(mark(face(e)) << " " << mark(face(twin(e))); return; } @@ -516,9 +518,9 @@ void SNC_SM_point_locator::init_marks_of_halfspheres() TRACEN("on loop "< 0) || ((op.x() == 0) && (op.z() < 0)) ) l = twin(l); // if ( (op.z() < 0) || (op.z() == 0) && (op.x() > 0) ) l = twin(l); - mark_of_halfsphere(+1) = mark(face(l)); - mark_of_halfsphere(-1) = mark(face(twin(l))); - TRACEN(mark_of_halfsphere(-1) << " " << mark_of_halfsphere(+1)); + mohs[offset+1] = mark(face(l)); + mohs[offset] = mark(face(twin(l))); + // TRACEN(mark_of_halfsphere(-1) << " " << mark_of_halfsphere(+1)); return; } @@ -529,21 +531,21 @@ void SNC_SM_point_locator::init_marks_of_halfspheres() if ( assign(v,h) ) { CGAL_nef3_assertion(point(v)==y_minus); if(is_isolated(v)) - mark_of_halfsphere(+1) = mark_of_halfsphere(-1) = mark(face(v)); + mohs[offset+1] = mohs[offset] = mark(face(v)); else { e = out_wedge(v,left,collinear); - if ( collinear ) mark_of_halfsphere(+1) = mark(face(twin(e))); - else mark_of_halfsphere(+1) = mark(face(e)); + if ( collinear ) mohs[offset+1] = mark(face(twin(e))); + else mohs[offset+1] = mark(face(e)); e = out_wedge(v,right,collinear); - if ( collinear ) mark_of_halfsphere(-1) = mark(face(twin(e))); - else mark_of_halfsphere(-1) = mark(face(e)); + if ( collinear ) mohs[offset] = mark(face(twin(e))); + else mohs[offset] = mark(face(e)); } - TRACEN(mark_of_halfsphere(-1) << " " << mark_of_halfsphere(+1)); + // TRACEN(mark_of_halfsphere(-1) << " " << mark_of_halfsphere(+1)); return; } /* TRACEN("1 dimensional object"); - mark_of_halfsphere(-1) = mark_of_halfsphere(+1) = 0; + mohs[offset] = mohs[offset+1] = 0; */ CGAL_nef3_assertion_msg(0,"damn wrong type"); return; diff --git a/Packages/Nef_3/include/CGAL/Nef_3/SNC_constructor.h b/Packages/Nef_3/include/CGAL/Nef_3/SNC_constructor.h index c3098a7e801..8e9df85c0fb 100644 --- a/Packages/Nef_3/include/CGAL/Nef_3/SNC_constructor.h +++ b/Packages/Nef_3/include/CGAL/Nef_3/SNC_constructor.h @@ -804,8 +804,8 @@ create_SM_on_infibox(Point_3 center, Sphere_point* SP, int size, SD.link_as_face_cycle(SD.twin(she[0]),sf[1]); SD.link_as_face_cycle(SD.twin(she[1]),sf[2]); - SM_point_locator L(v); - L.init_marks_of_halfspheres(); + // SM_point_locator L(v); + // L.init_marks_of_halfspheres(); } // ---------------------------------------------------------------------------- @@ -863,8 +863,8 @@ create_box_corner(int x, int y, int z, bool space, bool boundary) const { // SD.mark_of_halfsphere(-1) = (x<0 && y>0 && z>0); // SD.mark_of_halfsphere(+1) = (x>0 && y>0 && z<0); /* TODO: to check if the commented code above could be wrong */ - SM_point_locator L(v); - L.init_marks_of_halfspheres(); + // SM_point_locator L(v); + // L.init_marks_of_halfspheres(); return v; } @@ -927,8 +927,8 @@ create_extended_box_corner(int x,int y,int z,bool space,bool boundary) const { // SD.mark_of_halfsphere(-1) = (x<0 && y>0 && z>0); // SD.mark_of_halfsphere(+1) = (x>0 && y>0 && z<0); /* TODO: to check if the commented code above could be wrong */ - SM_point_locator L(v); - L.init_marks_of_halfspheres(); + // SM_point_locator L(v); + // L.init_marks_of_halfspheres(); return v; } @@ -961,6 +961,7 @@ create_from_facet(Halffacet_handle f, const Point_3& p) const D.mark(f2) = mark(volume(twin(f))); D.mark(l) = mark(f); #ifdef CGAL_NEF3_BUGGY_CODE + /* Sphere_point q(0,-1,0); CGAL::Oriented_side os = c.oriented_side(q); switch ( os ) { @@ -976,10 +977,11 @@ create_from_facet(Halffacet_handle f, const Point_3& p) const if ( c.a()>=0 && c.c()<=0 ) // normal(c) dx<=0&&dz>=0 D.mark_of_halfsphere(-1) = true; } + */ /* TODO: to find why the code chuck above is wrong */ #endif // CGAL_NEF3_BUGGY_CODE - SM_point_locator L(v); - L.init_marks_of_halfspheres(); + // SM_point_locator L(v); + // L.init_marks_of_halfspheres(); return v; } @@ -1053,8 +1055,8 @@ create_from_edge(Halfedge_handle e, } TRACEN(" "); - SM_point_locator L(v); - L.init_marks_of_halfspheres(); + // SM_point_locator L(v); + // L.init_marks_of_halfspheres(); /* CGAL_nef3_forall_shalfedges(eee,D) @@ -1139,8 +1141,8 @@ clone_SM( typename SNC_::Vertex_handle vin) { } } - D.mark_of_halfsphere(-1) = E.mark_of_halfsphere(-1); - D.mark_of_halfsphere(+1) = E.mark_of_halfsphere(+1); + // D.mark_of_halfsphere(-1) = E.mark_of_halfsphere(-1); + // D.mark_of_halfsphere(+1) = E.mark_of_halfsphere(+1); return vout; } @@ -1243,8 +1245,8 @@ create_edge_facet_overlay( typename SNC_::Halfedge_handle e, } } - SM_point_locator L(D.center_vertex()); - L.init_marks_of_halfspheres(); + // SM_point_locator L(D.center_vertex()); + // L.init_marks_of_halfspheres(); return D.center_vertex(); } 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 4845e628c6b..76937ced660 100644 --- a/Packages/Nef_3/include/CGAL/Nef_3/SNC_decorator.h +++ b/Packages/Nef_3/include/CGAL/Nef_3/SNC_decorator.h @@ -140,7 +140,6 @@ public: USING(Line_3); USING(Plane_3); USING(Vector_3); - USING(Direction_3); USING(Sphere_kernel); USING(Sphere_point); @@ -750,7 +749,7 @@ public: Halffacet_handle res = facet(sh); - Direction_3 ed(segment(e).direction()); + Vector_3 ed(segment(e).direction()); Vector_3 ev(segment(e).direction()), rv(ray.direction()); SHalfedge_around_svertex_circulator sh(SD.first_out_edge(e)), send(sh); Vector_3 vec0(cross_product(ev,plane(res).orthogonal_vector())); @@ -864,8 +863,8 @@ public: SFace_handle f = SD.new_face(); SD.mark(f) = mark(c); TRACEN("volume "<<&*c<<" marked as "< KernelTraits; typedef typename KernelTraits::Kernel Kernel; typedef typename Kernel::Vector_3 Vector; - typedef typename Kernel::Direction_3 Direction; typedef typename Facet::Halfedge_around_facet_const_circulator Halfedge_circulator; typedef typename Facet::Halfedge Halfedge; @@ -67,8 +66,8 @@ struct Facet_plane_3 { Vector plane_orthogonal_vector; normal_vector_newell_3( point_cir, point_cir, plane_orthogonal_vector); TRACEN( *point_cir); - TRACEN(Plane( *point_cir, Direction( plane_orthogonal_vector))); - return( Plane( *point_cir, Direction( plane_orthogonal_vector))); + TRACEN(Plane( *point_cir, Vector( plane_orthogonal_vector))); + return( Plane( *point_cir, Vector( plane_orthogonal_vector))); } }; @@ -200,8 +199,8 @@ void polyhedron_3_to_nef_3(Polyhedron_& P, SNC_structure& S) SM.mark(fext) = false; SM.check_integrity_and_topological_planarity(); - SM_point_locator L(nv); - L.init_marks_of_halfspheres(); + // SM_point_locator L(nv); + // L.init_marks_of_halfspheres(); } }