From d8de25a9b5d9d82dcc7d30e8166bcdfe1be5cabf Mon Sep 17 00:00:00 2001 From: Peter Hachenberger Date: Mon, 15 Dec 2003 18:59:13 +0000 Subject: [PATCH] SNC_constructor.h: overlay of edge facet intersection is now done without a sweep. --- .../include/CGAL/Nef_3/SNC_SM_decorator.h | 1 + .../include/CGAL/Nef_3/SNC_SM_point_locator.h | 2 +- .../include/CGAL/Nef_3/SNC_constructor.h | 99 ++++++++++++++++++- .../Nef_3/include/CGAL/Nef_3/SNC_decorator.h | 37 ++++--- 4 files changed, 125 insertions(+), 14 deletions(-) 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 a47cc28bd3c..5e2d6e4aa37 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 @@ -465,6 +465,7 @@ void link_as_face_cycle(SHalfedge_handle e, SFace_handle f) const SHalfedge_around_sface_circulator hfc(e), hend(hfc); CGAL_For_all(hfc,hend) set_face(hfc,f); + store_boundary_object(e,f); } 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 be335eb5939..efffc2e76c3 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 @@ -343,7 +343,7 @@ public: } } - CGAL_nef3_forall_shalfedges(e,*this) { + CGAL_nef3_forall_sedges(e,*this) { if ( visited[e] ) continue; Sphere_segment se = segment(e); Sphere_point p_res; 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 fb3d75f8604..d5131fcba7c 100644 --- a/Packages/Nef_3/include/CGAL/Nef_3/SNC_constructor.h +++ b/Packages/Nef_3/include/CGAL/Nef_3/SNC_constructor.h @@ -14,7 +14,7 @@ // $Source$ // $Revision$ $Date$ // $Name$ -// +//file:///usr/share/doc/mozilla-browser/localstart.html // Author(s) : Michael Seel // Miguel Granados // Susan Hert @@ -352,6 +352,12 @@ public: Vertex_handle clone_SM( Vertex_handle vin); + template + Vertex_handle create_edge_facet_overlay( Halfedge_handle e, + Halffacet_handle f, + const Point_3& p, + const Selection& BOP); + private: void pair_up_halfedges() const; /*{\Mop pairs all halfedge stubs to create the edges in 3-space.}*/ @@ -997,7 +1003,7 @@ create_from_edge(Halfedge_handle e, bool first = true; // SETDTHREAD(19*43*131); - SM_decorator EE(vertex(e)); + /* SHalfedge_handle eee; TRACEN("---------------------" << point(vertex(e))); CGAL_nef3_forall_shalfedges(eee,EE) @@ -1005,6 +1011,7 @@ create_from_edge(Halfedge_handle e, "|" << EE.mark(eee) << " " << EE.mark(EE.face(eee))); TRACEN(" "); + */ if(E.is_isolated(e)) { SFace_handle f = D.new_face(); @@ -1022,9 +1029,11 @@ create_from_edge(Halfedge_handle e, first = false; } + /* CGAL_nef3_forall_shalfedges(eee,D) TRACEN("|" << D.circle(eee)); TRACEN(" "); + */ ec1 = E.out_edges(e); SHalfedge_around_svertex_circulator ec2(D.out_edges(v1)); @@ -1045,11 +1054,13 @@ create_from_edge(Halfedge_handle e, SM_point_locator L(v); L.init_marks_of_halfspheres(); + /* CGAL_nef3_forall_shalfedges(eee,D) TRACEN("|" << D.circle(eee) << "|" << D.mark(eee) << " " << D.mark(D.face(eee))); TRACEN("---------------------"); + */ return v; } @@ -1132,6 +1143,90 @@ clone_SM( typename SNC_::Vertex_handle vin) { return vout; } +template +template +typename SNC_::Vertex_handle +SNC_constructor:: +create_edge_facet_overlay( typename SNC_::Halfedge_handle e, + typename SNC_::Halffacet_handle f, + const Point_3& p, + const Selection& BOP) { + + TRACEN("edge facet overlay " << p); + + Unique_hash_map mark_of_right_sface; + + SM_decorator D(sncp()->new_vertex(p, BOP(mark(e), mark(f)))); + SM_const_decorator E(source(e)); + + Sphere_point ps = calc_point(e); + ps = normalized(ps); + SVertex_handle v1 = D.new_vertex(ps); + SVertex_handle v2 = D.new_vertex(ps.antipode()); + TRACEN("new svertex 1 " << ps); + TRACEN("new svertex 2 " << ps.antipode()); + Halffacet_handle faces_p(f); + Vector_3 vec(ps); + if(plane(faces_p).oriented_side(p+vec) == ON_NEGATIVE_SIDE) + faces_p = twin(faces_p); + D.mark(v1) = BOP(E.mark(e), mark(volume(faces_p))); + D.mark(v2) = BOP(E.mark(e), mark(volume(twin(faces_p)))); + + if(E.is_isolated(e)) { + CGAL_nef3_assertion_msg(0,"not implemented yet"); + } + else { + SVertex_handle sv; + SHalfedge_handle se1; + SHalfedge_handle se2; + SFace_handle sf; + Sphere_circle c(plane(f)); + + SHalfedge_around_svertex_const_circulator ec(E.out_edges(e)), ee(ec); + CGAL_For_all(ec,ee) { + Sphere_segment seg(E.point(E.source(ec)), E.point(E.source(ec)).antipode(), E.circle(ec)); + Sphere_point sp(intersection(c, seg.sphere_circle())); + TRACEN(seg <<" has_on " << sp); + if(!seg.has_on(sp)) + sp = sp.antipode(); + sv = D.new_vertex(sp); + TRACEN("new svertex 3 " << normalized(sp)); + D.mark(sv) = BOP(E.mark(ec), mark(f)); + se1 = D.new_edge_pair(v1, sv); + se2 = D.new_edge_pair(sv, v2); + D.mark(se1) = BOP(E.mark(ec), mark(volume(faces_p))); + D.mark(se2) = BOP(E.mark(ec), mark(volume(twin(faces_p)))); + mark_of_right_sface[se1] = E.mark(E.face(ec)); + D.circle(se1) = D.circle(se2) = E.circle(ec); + D.circle(D.twin(se1)) = D.circle(D.twin(se2)) = D.circle(se1).opposite(); + } + + SHalfedge_around_svertex_circulator ec2(D.out_edges(v1)), ee2(ec2); + CGAL_For_all(ec2,ee2) { + SHalfedge_around_svertex_circulator en(ec2); + en++; + se1 = D.new_edge_pair(twin(ec2), twin(en), -1, 1); + TRACEN("new edge pair " << ssource(twin(ec2))->tmp_point() << " -> " << ssource(twin(en))->tmp_point()); + D.circle(se1) = Sphere_circle(plane(faces_p)); + D.circle(D.twin(se1)) = D.circle(se1).opposite(); + D.mark(se1) = BOP(mark_of_right_sface[ec2], mark(faces_p)); + + sf = D.new_face(); + D.mark(sf) = BOP(mark_of_right_sface[ec2], mark(volume(faces_p))); + D.link_as_face_cycle(se1,sf); + sf = D.new_face(); + D.mark(sf) = BOP(mark_of_right_sface[ec2], mark(volume(twin(faces_p)))); + D.link_as_face_cycle(D.twin(se1),sf); + } + } + TRACEN(""); + + SM_point_locator L(D.center_vertex()); + L.init_marks_of_halfspheres(); + + return D.center_vertex(); +} + template typename SNC_::Halffacet_handle SNC_constructor:: 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 7563a458ec7..6aa44f41e97 100644 --- a/Packages/Nef_3/include/CGAL/Nef_3/SNC_decorator.h +++ b/Packages/Nef_3/include/CGAL/Nef_3/SNC_decorator.h @@ -924,12 +924,14 @@ public: void operator()( Halfedge_handle e0, Object_handle o1, const Point_3& p) const { + + Halfedge_handle e; + Halffacet_handle f; + TRACEN("Intersection_call_back: intersection reported on " << p << " (normalized: " << normalized(p) << " )"); #ifdef _DEBUG SNC_decorator D0(snc0); TRACEN("edge 0 has source " << point(source(e0)) << " and direction " << D0.tmp_point(e0)); - Halfedge_handle e; - Halffacet_handle f; SNC_decorator D1(snc1); if( assign( e, o1)) { TRACEN("edge 1 has source " << point(source(e)) << " and direction " << D1.tmp_point(e)); @@ -940,15 +942,28 @@ public: else CGAL_nef3_assertion_msg( 0, "wrong handle"); #endif - SNC_decorator D(result); - Vertex_handle v0, v1; - v0 = D.qualify_with_respect( p, Object_handle(e0), snc0); - v1 = D.qualify_with_respect( p, o1, snc1); - if( inverse_order) - std::swap( v0, v1); - D.binop_local_views( v0, v1, bop, result); - result.delete_vertex(v0); - result.delete_vertex(v1); + + if( assign( e, o1)) { + SNC_decorator D(result); + Vertex_handle v0, v1; + v0 = D.qualify_with_respect( p, Object_handle(e0), snc0); + v1 = D.qualify_with_respect( p, o1, snc1); + if( inverse_order) + std::swap( v0, v1); + D.binop_local_views( v0, v1, bop, result); + result.delete_vertex(v0); + result.delete_vertex(v1); + } + else if( assign( f, o1)) { + SNC_constructor C(result); + Vertex_handle v0 = C.create_edge_facet_overlay(e0, f, p, bop); + SM_overlayer O(v0); + O.simplify(); + } + else + CGAL_nef3_assertion_msg( 0, "wrong handle"); + + } private: SNC_structure& snc0;