diff --git a/Packages/Nef_3/TODO b/Packages/Nef_3/TODO index 316f87b6d4d..e903ab44637 100644 --- a/Packages/Nef_3/TODO +++ b/Packages/Nef_3/TODO @@ -2,8 +2,6 @@ Nef_3 Package: TODO --------------------------------------------------------------------- - Simplification of the SNC structure -- Simplify during the construction from polyhedral surfaces - (based on the simplification of SM) - Unary operations - Intersections of Line_3 with Line_3 - Find all intersections between two SNC's. 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 4ecb18155a9..e30f5d1d80d 100644 --- a/Packages/Nef_3/include/CGAL/Nef_3/SNC_constructor.h +++ b/Packages/Nef_3/include/CGAL/Nef_3/SNC_constructor.h @@ -316,8 +316,8 @@ public: return c; } SFace_handle sf_below = adjacent_sface(f_below); - TRACEN( "Shell not assigned to a volume hit "); - TRACEN( "(Inner shell #" << Shell[sf] << ")"); + TRACE( "Shell not assigned to a volume hit "); + TRACEN( "(Inner shell #" << Shell[sf_below] << ")"); c = determine_volume( sf_below, MinimalVertex, Shell); link_as_inner_shell( sf_below, c); return c; @@ -379,24 +379,35 @@ public: CGAL_assertion( !h.is_degenerate()); Point_2 (*t)(Point_3); Vector_3 hv( h.orthogonal_vector()), - hxy( 0, 0, 1), hyz( 1, 0, 0), hxz( 0, 1, 0); - if( !is_zero( hv * hxz) ) - /* the plane is not perpendicular to the XZ plane */ - t = &point_3_get_x_z_point_2< Point_2, Point_3>; - else if( !is_zero( hv * hyz) ) - /* the plane is not perpendicular to the XZ plane */ + hxy( 0, 0, 1), hyz( 1, 0, 0), hzx( 0, 1, 0); + bool mirror = false; + if( !is_zero( hv * hzx) ) { + /* the plane is not perpendicular to the ZX plane */ + t = &point_3_get_z_x_point_2< Point_2, Point_3>; + if( is_negative( hv * hzx)) mirror = true; + } + else if( !is_zero( hv * hyz) ) { + /* the plane is not perpendicular to the YZ plane */ t = &point_3_get_y_z_point_2< Point_2, Point_3>; + if( is_negative( hv * hyz)) mirror = true; + } else { CGAL_assertion( !is_zero( hv * hxy) ); /* the plane is not perpendicular to the XY plane */ t = &point_3_get_x_y_point_2< Point_2, Point_3>; + if( is_negative( hv * hxy)) mirror = true; } Direction_2 da( t( ORIGIN + Vector_3(a) ) - ORIGIN), db( t( ORIGIN + Vector_3(b)) - ORIGIN), dc( t( ORIGIN + Vector_3(c)) - ORIGIN); - TRACE( "CCW ordered " << a << ", " << b << ", " << c << ": "); - TRACE( "CCW ordered " << da << ", " << db << ", " << dc << ": "); - TRACEN( strictly_ordered_ccw( da, db, dc)); + if( mirror ) { + da = Direction_2(-da.dx(), da.dy()); + db = Direction_2(-db.dx(), db.dy()); + dc = Direction_2(-dc.dx(), dc.dy()); + } + TRACEN( "CCW ordered " << a << ", " << b << ", " << c << ": "); + TRACEN( "CCW ordered " << da << ", " << db << ", " << dc); + TRACEN( "? " << strictly_ordered_ccw( da, db, dc)); return strictly_ordered_ccw( da, db, dc); } @@ -409,18 +420,19 @@ public: Direction_3 d_r = -ray.direction(), d_e = segment(e).direction(); Plane_3 h_ref( segment(e).source(), d_e); + TRACEN("--> ref plane " << h_ref); SHalfedge_handle se = D.first_out_edge(e); Plane_3 h_se = plane(facet(twin(se))); - Vector_3 v_se = cross_product( Vector_3(d_e), - Vector_3(h_se.orthogonal_direction())); + Vector_3 v_se = cross_product( Vector_3(h_se.orthogonal_direction()), + Vector_3(d_e)); Direction_3 d_se = Direction_3(v_se); - SHalfedge_around_svertex_circulator sc(D.out_edges(e)), sce(sc); + SHalfedge_around_svertex_circulator sc(se), sce(sc); CGAL_For_all(sc, sce) { Plane_3 h_sc = plane(facet(twin(sc))); - Vector_3 v_sc = cross_product( Vector_3(d_e), - Vector_3(h_sc.orthogonal_direction())); + Vector_3 v_sc = cross_product( Vector_3(h_sc.orthogonal_direction()), + Vector_3(d_e)); Direction_3 d_sc = Direction_3(v_sc); if ( strictly_ordered_ccw_3(d_se, d_sc, d_r, h_ref)) { @@ -883,18 +895,18 @@ link_shalfedges_to_facet_cycles() const SHalfedge_around_svertex_circulator ce(D.first_out_edge(e)),cee(ce); SHalfedge_around_svertex_circulator cet(Dt.first_out_edge(et)),cete(cet); /*debug*/ - SHalfedge_around_svertex_circulator ceti, cetj; - cetj = cet; ceti = cetj++; - if(ceti != cetj) - CGAL_For_all(ceti,cete) - { - TRACEN(" et ss "< -Point_2 point_3_get_x_z_point_2(Point_3 p) { - return( Point_2(p.hx(), p.hz(), p.hw()) ); +Point_2 point_3_get_y_z_point_2(Point_3 p) { + return( Point_2(p.hy(), p.hz(), p.hw()) ); } template -Point_2 point_3_get_y_z_point_2(Point_3 p) { - return( Point_2(p.hy(), p.hz(), p.hw()) ); +Point_2 point_3_get_z_x_point_2(Point_3 p) { + return( Point_2(p.hz(), p.hx(), p.hw()) ); } template @@ -83,15 +83,15 @@ Bounded_side bounded_side_3(IteratorForward first, CGAL_assertion(!plane.is_degenerate()); TRACEN(plane); Point_2 (*t)(Point_3); - Vector_3 pv(plane.orthogonal_vector()), pxy(0,0,1), pyz(1,0,0), pxz(0,1,0); - TRACEN("pv*pxz: "<; + if( !is_zero(pv*pzx) ) + /* the plane is not perpendicular to the ZX plane */ + t = &point_3_get_z_x_point_2< Point_2, Point_3>; else if( !is_zero(pv*pyz) ) - /* the plane is not perpendicular to the XZ plane */ + /* the plane is not perpendicular to the YZ plane */ t = &point_3_get_y_z_point_2< Point_2, Point_3>; else { CGAL_assertion( !is_zero(pv*pxy) ); diff --git a/Packages/Nef_3/include/CGAL/Nef_3/polyhedron_3_to_nef_3.h b/Packages/Nef_3/include/CGAL/Nef_3/polyhedron_3_to_nef_3.h index 5913f6d3b78..86f887fa7e7 100644 --- a/Packages/Nef_3/include/CGAL/Nef_3/polyhedron_3_to_nef_3.h +++ b/Packages/Nef_3/include/CGAL/Nef_3/polyhedron_3_to_nef_3.h @@ -84,6 +84,7 @@ template void polyhedron_3_to_nef_3(Polyhedron_& P, SNC_structure& S) { typedef Polyhedron_ Polyhedron; + typedef typename SNC_constructor::SM_overlayer SM_overlayer; typedef typename SNC_structure::SM_decorator SM_decorator; typedef typename SNC_structure::Vertex_handle Vertex_handle; typedef typename SNC_structure::SVertex_handle SVertex_handle; @@ -111,7 +112,6 @@ void polyhedron_3_to_nef_3(Polyhedron_& P, SNC_structure& S) TRACEN("v "< sp_list; std::list ss_list; typename Polyhedron::Halfedge_around_vertex_const_circulator @@ -253,6 +253,9 @@ void polyhedron_3_to_nef_3(Polyhedron_& P, SNC_structure& S) SM.mark(fint) = true; SM.mark(fext) = false; SM.check_integrity_and_topological_planarity(); + + SM_overlayer O(nv); + // O.simplify(); #endif // CGAL_P2NEF3_USE_SM_OVERLAY //SMIO::dump(nv); diff --git a/Packages/Nef_3/include/CGAL/Nef_polyhedron_3.h b/Packages/Nef_3/include/CGAL/Nef_polyhedron_3.h index 150d7ab8d26..3eefaef111f 100644 --- a/Packages/Nef_3/include/CGAL/Nef_polyhedron_3.h +++ b/Packages/Nef_3/include/CGAL/Nef_polyhedron_3.h @@ -28,12 +28,11 @@ // // Nef polyhedron in the space // ============================================================================ - #ifndef CGAL_NEF_POLYHEDRON_3_H #define CGAL_NEF_POLYHEDRON_3_H #include #include -//#define SNC_VISUALIZOR +#define SNC_VISUALIZOR #include #include #include