From 4f6796731b41d0f4dddb478b3a8a9428f22554ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 13 Apr 2017 11:36:48 +0200 Subject: [PATCH] Improved readability of Skin_surface_3 Only indentation and whitespace is changed. Almost like a skin (sur)facelift ! --- .../skin_surface_pdb_reader.cpp | 13 +- ...face_retrieve_defining_weighted_points.cpp | 17 +- .../Skin_surface_3/skin_surface_simple.cpp | 3 +- .../Skin_surface_3/skin_surface_subdiv.cpp | 3 +- .../skin_surface_subdiv_with_normals.cpp | 3 +- .../Skin_surface_3/skin_surface_writer.h | 8 +- .../Skin_surface_3/union_of_balls_simple.cpp | 3 +- .../Skin_surface_3/union_of_balls_subdiv.cpp | 5 +- .../include/CGAL/Compute_anchor_3.h | 147 +-- .../Marching_tetrahedra_observer_default_3.h | 35 +- ...arching_tetrahedra_traits_skin_surface_3.h | 29 +- Skin_surface_3/include/CGAL/Skin_surface_3.h | 37 +- .../include/CGAL/Skin_surface_base_3.h | 366 ++++--- .../CGAL/Skin_surface_filtered_traits_3.h | 31 +- ...n_surface_marching_tetrahedra_observer_3.h | 58 +- .../CGAL/Skin_surface_polyhedral_items_3.h | 17 +- ...e_polyhedral_items_with_face_information.h | 13 +- .../CGAL/Skin_surface_quadratic_surface_3.h | 123 +-- .../CGAL/Skin_surface_refinement_policy_3.h | 63 +- .../include/CGAL/Skin_surface_traits_3.h | 137 +-- .../Triangulated_mixed_complex_observer_3.h | 30 +- .../Triangulation_incremental_builder_3.h | 85 +- .../include/CGAL/Union_of_balls_3.h | 38 +- .../include/CGAL/make_skin_surface_mesh_3.h | 15 +- .../include/CGAL/make_union_of_balls_3.h | 24 +- .../include/CGAL/mesh_skin_surface_3.h | 6 +- .../include/CGAL/mesh_union_of_balls_3.h | 3 +- .../CGAL/subdivide_skin_surface_mesh_3.h | 34 +- .../CGAL/subdivide_union_of_balls_mesh_3.h | 11 +- .../CGAL/triangulate_mixed_complex_3.h | 909 +++++++++--------- .../CGAL/triangulate_power_diagram_3.h | 548 +++++------ .../test/Skin_surface_3/anchor_test.cpp | 55 +- .../test/Skin_surface_3/degenerate_test.cpp | 21 +- .../Skin_surface_3/degenerate_test_exact.cpp | 20 +- .../test/Skin_surface_3/subdivision_test.cpp | 23 +- .../test/Skin_surface_3/surface_test.cpp | 61 +- .../Skin_surface_3/union_of_balls_test.cpp | 9 +- .../union_of_balls_test_exact.cpp | 8 +- 38 files changed, 1485 insertions(+), 1526 deletions(-) diff --git a/Skin_surface_3/examples/Skin_surface_3/skin_surface_pdb_reader.cpp b/Skin_surface_3/examples/Skin_surface_3/skin_surface_pdb_reader.cpp index 014541b2b1e..740fae4f663 100644 --- a/Skin_surface_3/examples/Skin_surface_3/skin_surface_pdb_reader.cpp +++ b/Skin_surface_3/examples/Skin_surface_3/skin_surface_pdb_reader.cpp @@ -22,27 +22,22 @@ typedef CGAL::Polyhedron_3 Polyhedron; #include "skin_surface_writer.h" #include "include/extract_balls_from_pdb.h" - -int main(int argc, char *argv[]) { +int main(int argc, char *argv[]) +{ const char *filename; if (argc == 2) { filename = argv[1]; } else { filename = "data/4lfq.pdb"; } - - + std::list l; double shrinkfactor = 0.5; //Container for molecular system std::vector systems; - - - + // Retrieve input balls: extract_balls_from_pdb(filename,systems,std::back_inserter(l)); - - // Construct skin surface: std::cout << "Constructing skin surface..." < #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Skin_surface_traits_3 Traits; -typedef CGAL::Skin_surface_3 Skin_surface_3; -typedef Skin_surface_3::FT FT; -typedef Skin_surface_3::Weighted_point Weighted_point; -typedef Weighted_point::Point Bare_point; +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Skin_surface_traits_3 Traits; +typedef CGAL::Skin_surface_3 Skin_surface_3; +typedef Skin_surface_3::FT FT; +typedef Skin_surface_3::Weighted_point Weighted_point; +typedef Weighted_point::Point Bare_point; typedef CGAL::Skin_surface_polyhedral_items_3 Polyhedral_items; -typedef CGAL::Polyhedron_3 Polyhedron; +typedef CGAL::Polyhedron_3 Polyhedron; -int main() { +int main() +{ std::list l; FT shrinkfactor = 0.5; diff --git a/Skin_surface_3/examples/Skin_surface_3/skin_surface_simple.cpp b/Skin_surface_3/examples/Skin_surface_3/skin_surface_simple.cpp index d62f7fcb710..0afe2039f06 100644 --- a/Skin_surface_3/examples/Skin_surface_3/skin_surface_simple.cpp +++ b/Skin_surface_3/examples/Skin_surface_3/skin_surface_simple.cpp @@ -7,7 +7,8 @@ typedef K::Point_3 Bare_point; typedef K::Weighted_point_3 Weighted_point; typedef CGAL::Polyhedron_3 Polyhedron; -int main() { +int main() +{ std::list l; double shrinkfactor = 0.5; diff --git a/Skin_surface_3/examples/Skin_surface_3/skin_surface_subdiv.cpp b/Skin_surface_3/examples/Skin_surface_3/skin_surface_subdiv.cpp index 0c43b0fb19f..bc4118e016a 100644 --- a/Skin_surface_3/examples/Skin_surface_3/skin_surface_subdiv.cpp +++ b/Skin_surface_3/examples/Skin_surface_3/skin_surface_subdiv.cpp @@ -16,7 +16,8 @@ typedef Weighted_point::Point Bare_point; typedef CGAL::Polyhedron_3 > Polyhedron; -int main() { +int main() +{ std::list l; FT shrinkfactor = 0.5; diff --git a/Skin_surface_3/examples/Skin_surface_3/skin_surface_subdiv_with_normals.cpp b/Skin_surface_3/examples/Skin_surface_3/skin_surface_subdiv_with_normals.cpp index 071ed61dbe1..8940339ceac 100644 --- a/Skin_surface_3/examples/Skin_surface_3/skin_surface_subdiv_with_normals.cpp +++ b/Skin_surface_3/examples/Skin_surface_3/skin_surface_subdiv_with_normals.cpp @@ -17,7 +17,8 @@ typedef Weighted_point::Point Bare_point; typedef CGAL::Skin_surface_polyhedral_items_3 Polyhedral_items; typedef CGAL::Polyhedron_3 Polyhedron; -int main() { +int main() +{ std::list l; FT shrinkfactor = 0.5; diff --git a/Skin_surface_3/examples/Skin_surface_3/skin_surface_writer.h b/Skin_surface_3/examples/Skin_surface_3/skin_surface_writer.h index 9a7ca8baadb..54790e43878 100644 --- a/Skin_surface_3/examples/Skin_surface_3/skin_surface_writer.h +++ b/Skin_surface_3/examples/Skin_surface_3/skin_surface_writer.h @@ -9,8 +9,8 @@ template /// Write polyhedron with normals: void write_polyhedron_with_normals(SkinSurface &skin, - Polyhedron &p, - std::ostream &out) + Polyhedron &p, + std::ostream &out) { typedef typename Polyhedron::Vertex_iterator Vertex_iterator; typedef typename Polyhedron::Facet_iterator Facet_iterator; @@ -26,8 +26,6 @@ void write_polyhedron_with_normals(SkinSurface &skin, << " " << p.size_of_halfedges() << std::endl; - - // Write vertices for (Vertex_iterator vit = p.vertices_begin(); vit != p.vertices_end(); vit ++) { @@ -38,7 +36,7 @@ void write_polyhedron_with_normals(SkinSurface &skin, // Write faces CGAL::Inverse_index index(p.vertices_begin(), - p.vertices_end()); + p.vertices_end()); for(Facet_iterator fi = p.facets_begin(); fi != p.facets_end(); ++fi) { HFC hc = fi->facet_begin(); diff --git a/Skin_surface_3/examples/Skin_surface_3/union_of_balls_simple.cpp b/Skin_surface_3/examples/Skin_surface_3/union_of_balls_simple.cpp index 1985fac70e7..dfd887c7b16 100644 --- a/Skin_surface_3/examples/Skin_surface_3/union_of_balls_simple.cpp +++ b/Skin_surface_3/examples/Skin_surface_3/union_of_balls_simple.cpp @@ -11,7 +11,8 @@ typedef Union_of_balls_3::Weighted_point Weighted_point; typedef Weighted_point::Point Bare_point; typedef CGAL::Polyhedron_3 Polyhedron; -int main() { +int main() +{ std::list l; l.push_front(Weighted_point(Bare_point(0,0,0), 1)); diff --git a/Skin_surface_3/examples/Skin_surface_3/union_of_balls_subdiv.cpp b/Skin_surface_3/examples/Skin_surface_3/union_of_balls_subdiv.cpp index c634493ee57..93117c30fbe 100644 --- a/Skin_surface_3/examples/Skin_surface_3/union_of_balls_subdiv.cpp +++ b/Skin_surface_3/examples/Skin_surface_3/union_of_balls_subdiv.cpp @@ -13,9 +13,10 @@ typedef CGAL::Union_of_balls_3 Union_of_balls_3; typedef Union_of_balls_3::Weighted_point Weighted_point; typedef Weighted_point::Point Bare_point; typedef CGAL::Polyhedron_3 > Polyhedron; + CGAL::Skin_surface_polyhedral_items_3 > Polyhedron; -int main() { +int main() +{ std::list l; l.push_front(Weighted_point(Bare_point( 1,-1,-1), 1.25)); diff --git a/Skin_surface_3/include/CGAL/Compute_anchor_3.h b/Skin_surface_3/include/CGAL/Compute_anchor_3.h index 4004a955b27..3ab73990d40 100644 --- a/Skin_surface_3/include/CGAL/Compute_anchor_3.h +++ b/Skin_surface_3/include/CGAL/Compute_anchor_3.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -36,12 +36,12 @@ public: typedef RegularTriangulation_3 Regular_triangulation; typedef typename Regular_triangulation::Geom_traits Geom_traits; typedef typename Geom_traits::Weighted_point_3 Weighted_point; - + typedef typename RegularTriangulation_3::Vertex_handle Vertex_handle; typedef typename RegularTriangulation_3::Cell_handle Cell_handle; typedef typename RegularTriangulation_3::Facet Facet; typedef typename RegularTriangulation_3::Edge Edge; - + typedef typename RegularTriangulation_3::Finite_vertices_iterator Finite_vertices_iterator; typedef typename RegularTriangulation_3::Finite_edges_iterator Finite_edges_iterator; typedef typename RegularTriangulation_3::Finite_facets_iterator Finite_facets_iterator; @@ -51,23 +51,28 @@ public: typedef typename std::list::iterator Simplex_iterator; - Compute_anchor_3(const RegularTriangulation_3 ®) : reg(reg) { - } + Compute_anchor_3(const RegularTriangulation_3 ®) : reg(reg) { } - Simplex anchor_del( const Vertex_handle v ) { + Simplex anchor_del( const Vertex_handle v ) + { equiv_anchors.clear(); return v; } + Simplex anchor_del( const Edge &e ) { return compute_anchor_del(e); } + Simplex anchor_del( const Facet &f ) { return compute_anchor_del(f); } + Simplex anchor_del( const Cell_handle ch ) { return compute_anchor_del(ch); } - Simplex anchor_del( const Simplex &s ) { + + Simplex anchor_del( const Simplex &s ) + { int dim = s.dimension(); if (dim == 0) { Vertex_handle vh = s; @@ -85,16 +90,21 @@ public: CGAL_error(); return Simplex(); } + Simplex anchor_vor( const Vertex_handle v ) { return compute_anchor_vor(v); } + Simplex anchor_vor( const Edge &e ) { return compute_anchor_vor(e); } + Simplex anchor_vor( const Facet &f ) { return compute_anchor_vor(f); } - Simplex anchor_vor( const Cell_handle ch ) { + + Simplex anchor_vor( const Cell_handle ch ) + { equiv_anchors.clear(); for (int i=0; i<4; i++) { Cell_handle ch2 = ch->neighbor(i); @@ -110,7 +120,9 @@ public: } return ch; } - Simplex anchor_vor( const Simplex &s ) { + + Simplex anchor_vor( const Simplex &s ) + { int dim = s.dimension(); if (dim == 0) { return anchor_vor(Vertex_handle(s)); @@ -127,12 +139,15 @@ public: bool is_degenerate() { return !equiv_anchors.empty(); } + Simplex_iterator equivalent_anchors_begin() { return equiv_anchors.begin(); } + Simplex_iterator equivalent_anchors_end() { return equiv_anchors.end(); } + private: /////////////////////////////// // Anchor functions @@ -140,28 +155,35 @@ private: Simplex compute_anchor_del( Edge const &e ); Simplex compute_anchor_del( Facet const &f ); Simplex compute_anchor_del( Cell_handle const ch ); - + Simplex compute_anchor_vor( Vertex_handle const v ); Simplex compute_anchor_vor( Edge const &e ); Simplex compute_anchor_vor( Facet const &f ); // Test whether the anchor of edge (wp1,wp2) and wp2 are equal - Sign test_anchor(Weighted_point &wp1, Weighted_point &wp2) { + Sign test_anchor(Weighted_point &wp1, Weighted_point &wp2) + { return enum_cast( - -reg.geom_traits().power_side_of_bounded_power_sphere_3_object()(wp1, wp2)); + -reg.geom_traits().power_side_of_bounded_power_sphere_3_object()(wp1, wp2)); } - Sign test_anchor(Weighted_point const& wp1, Weighted_point const& wp2, - Weighted_point const& wp3) { + + Sign test_anchor(Weighted_point const& wp1, Weighted_point const& wp2, + Weighted_point const& wp3) + { return enum_cast( - - reg.geom_traits().power_side_of_bounded_power_sphere_3_object()(wp1, wp2, wp3)); + - reg.geom_traits().power_side_of_bounded_power_sphere_3_object()(wp1, wp2, wp3)); } - Sign test_anchor(Weighted_point const& wp1, Weighted_point const& wp2, - Weighted_point const& wp3, Weighted_point const& wp4) { + + Sign test_anchor(Weighted_point const& wp1, Weighted_point const& wp2, + Weighted_point const& wp3, Weighted_point const& wp4) + { return enum_cast( - -reg.geom_traits().power_side_of_bounded_power_sphere_3_object()(wp1, wp2, wp3, wp4)); + -reg.geom_traits().power_side_of_bounded_power_sphere_3_object()(wp1, wp2, wp3, wp4)); } + // Test whether the anchor of e and anchor of e.first->vertex(i) are equal - Sign test_anchor(Edge e, int i) { + Sign test_anchor(Edge e, int i) + { CGAL_assertion(!reg.is_infinite(e)); CGAL_assertion(e.second == i || e.third == i); Weighted_point wp1, wp2; @@ -170,9 +192,11 @@ private: ch->vertex(e.second+e.third-i)->point(), ch->vertex(i)->point()); } + // Test whether the anchor of f and anchor of the edge f - f.first->vertex(i) // are equal - Sign test_anchor(Facet f, int i){ + Sign test_anchor(Facet f, int i) + { CGAL_assertion(!reg.is_infinite(f)); CGAL_assertion(f.second != i); CGAL_assertion(0<=f.second && f.second<4); @@ -198,12 +222,12 @@ private: CGAL_error(); } return enum_cast( - -reg.geom_traits().power_side_of_bounded_power_sphere_3_object()(wp1, wp2, wp3)); + -reg.geom_traits().power_side_of_bounded_power_sphere_3_object()(wp1, wp2, wp3)); } - // Test whether the anchor of ch and anchor of the facet (ch,i) are equal - Sign test_anchor(Cell_handle ch, int i) { + Sign test_anchor(Cell_handle ch, int i) + { CGAL_assertion(!reg.is_infinite(ch)); return enum_cast( @@ -213,7 +237,9 @@ private: ch->vertex((i+3)&3)->point(), ch->vertex(i)->point())); } - Sign test_anchor(Cell_handle ch, Cell_handle ch2) { + + Sign test_anchor(Cell_handle ch, Cell_handle ch2) + { CGAL_assertion(!reg.is_infinite(ch)); CGAL_assertion(!reg.is_infinite(ch2)); @@ -224,27 +250,28 @@ private: ch->vertex(1)->point(), ch->vertex(2)->point(), ch->vertex(3)->point(), - ch2->vertex(index)->point())); + ch2->vertex(index)->point())); } - Sign test_anchor( - Weighted_point const& wp1, Weighted_point const& wp2, - Weighted_point const& wp3, Weighted_point const& wp4, - Weighted_point const& wp5) { + + Sign test_anchor(Weighted_point const& wp1, Weighted_point const& wp2, + Weighted_point const& wp3, Weighted_point const& wp4, + Weighted_point const& wp5) + { return enum_cast( - -reg.geom_traits().power_side_of_bounded_power_sphere_3_object()(wp1, wp2, wp3, wp4, wp5)); + -reg.geom_traits().power_side_of_bounded_power_sphere_3_object()(wp1, wp2, wp3, wp4, wp5)); } const Regular_triangulation ® std::list equiv_anchors; }; - // compute_anchor_del template < class RegularTriangulation3 > typename Compute_anchor_3::Simplex Compute_anchor_3:: -compute_anchor_del(Edge const &e) { +compute_anchor_del(Edge const &e) +{ CGAL_assertion(!reg.is_infinite(e)); equiv_anchors.clear(); Sign result = test_anchor(e, e.second); @@ -259,14 +286,15 @@ compute_anchor_del(Edge const &e) { return Simplex(e.first->vertex(e.second)); } else if (result==ZERO) { equiv_anchors.push_back(Simplex(e.first->vertex(e.third))); - } + } return Simplex(e); } template < class RegularTriangulation3 > typename Compute_anchor_3::Simplex Compute_anchor_3:: -compute_anchor_del(Facet const &f) { +compute_anchor_del(Facet const &f) +{ CGAL_assertion(!reg.is_infinite(f)); equiv_anchors.clear(); @@ -282,15 +310,15 @@ compute_anchor_del(Facet const &f) { Edge(f.first, (f.second+(i==1?2:1))&3, (f.second+(i==3?2:3))&3)); } } - + if (contains_center) { return Simplex(f); } else { i--; - Edge e; e.first = f.first; - if (i==1) e.second = ((f.second+2)&3); + Edge e; e.first = f.first; + if (i==1) e.second = ((f.second+2)&3); else e.second = ((f.second+1)&3); - if (i==3) e.third = ((f.second+2)&3); + if (i==3) e.third = ((f.second+2)&3); else e.third = ((f.second+3)&3); Simplex s = anchor_del(e); @@ -314,10 +342,11 @@ compute_anchor_del(Facet const &f) { template < class RegularTriangulation3 > typename Compute_anchor_3::Simplex Compute_anchor_3:: -compute_anchor_del(Cell_handle const ch) { +compute_anchor_del(Cell_handle const ch) +{ CGAL_assertion(!reg.is_infinite(ch)); equiv_anchors.clear(); - + Simplex s; bool contains_center = true; Sign result; @@ -364,7 +393,7 @@ compute_anchor_del(Cell_handle const ch) { } if (found) { equiv_anchors.clear(); - return s; + return s; } found = true; s = tmp; @@ -375,7 +404,8 @@ compute_anchor_del(Cell_handle const ch) { template < class RegularTriangulation3 > typename Compute_anchor_3::Simplex Compute_anchor_3:: -compute_anchor_vor (Vertex_handle const v) { +compute_anchor_vor (Vertex_handle const v) +{ CGAL_assertion(!reg.is_infinite(v)); CGAL_assertion(reg.is_vertex(v)); @@ -388,13 +418,13 @@ compute_anchor_vor (Vertex_handle const v) { std::list adj_vertices; typename std::list::iterator adj_vertex; reg.incident_vertices(v, std::back_inserter(adj_vertices)); - - for (adj_vertex = adj_vertices.begin(); + + for (adj_vertex = adj_vertices.begin(); (adj_vertex != adj_vertices.end()) && contains_center; adj_vertex++) { if (!reg.is_infinite(*adj_vertex)) { side = test_anchor(v->point(),(*adj_vertex)->point()); - if (side == NEGATIVE) { + if (side == NEGATIVE) { contains_center = false; } else if (side == ZERO) { Edge e; @@ -445,7 +475,7 @@ compute_anchor_vor (Vertex_handle const v) { if (s.dimension() == 1) { Edge e = s; Vertex_handle v_other = e.first->vertex(e.second+e.third-e.first->index(v)); - for (adj_vertex = adj_vertices.begin(); + for (adj_vertex = adj_vertices.begin(); adj_vertex != adj_vertices.end(); adj_vertex++) { if ((v_other != (*adj_vertex)) && (!reg.is_infinite(*adj_vertex))) { @@ -462,7 +492,7 @@ compute_anchor_vor (Vertex_handle const v) { equiv_anchors.push_back(e2); } } - } + } } return s; } @@ -473,7 +503,8 @@ compute_anchor_vor (Vertex_handle const v) { template < class RegularTriangulation3 > typename Compute_anchor_3::Simplex -Compute_anchor_3::compute_anchor_vor (Edge const &e) { +Compute_anchor_3::compute_anchor_vor (Edge const &e) +{ CGAL_assertion(!reg.is_infinite(e)); equiv_anchors.clear(); @@ -484,14 +515,14 @@ Compute_anchor_3::compute_anchor_vor (Edge const &e) { bool contains_center = true; Sign side; Simplex s; - + Facet_circulator fcir, fstart; fstart = fcir = reg.incident_facets(e); do { if (!reg.is_infinite(*fcir)) { int i = 6 - (*fcir).second - - (*fcir).first->index(v0) - (*fcir).first->index(v1); + (*fcir).first->index(v0) - (*fcir).first->index(v1); side = test_anchor(*fcir, i); if (side == NEGATIVE) { contains_center = false; @@ -501,7 +532,7 @@ Compute_anchor_3::compute_anchor_vor (Edge const &e) { } } } while (++fcir != fstart); - + if (contains_center) { s = Simplex(e); return s; @@ -538,11 +569,11 @@ Compute_anchor_3::compute_anchor_vor (Edge const &e) { do { if (!reg.is_infinite(*fcir)) { int index2 = 6 - (*fcir).second - - (*fcir).first->index(v0) + - (*fcir).first->index(v0) - (*fcir).first->index(v1); - if (!(f.first->vertex(index) == (*fcir).first->vertex(index2))) { + if (!(f.first->vertex(index) == (*fcir).first->vertex(index2))) { side = test_anchor(v0->point(), v1->point(), - f.first->vertex(index)->point(), + f.first->vertex(index)->point(), (*fcir).first->vertex(index2)->point()); if (side == ZERO) { equiv_anchors.push_back(Facet(*fcir)); @@ -560,12 +591,13 @@ Compute_anchor_3::compute_anchor_vor (Edge const &e) { template < class RegularTriangulation3 > typename Compute_anchor_3::Simplex -Compute_anchor_3::compute_anchor_vor (Facet const &f) { +Compute_anchor_3::compute_anchor_vor (Facet const &f) +{ CGAL_assertion(!reg.is_infinite(f)); equiv_anchors.clear(); - + Sign side; - + CGAL_assertion(f.first != Cell_handle()); if (!reg.is_infinite(f.first)) { side = test_anchor(f.first, f.second); @@ -592,7 +624,6 @@ Compute_anchor_3::compute_anchor_vor (Facet const &f) { return Simplex(f); } - } //namespace CGAL #endif // CGAL_COMPUTE_ANCHOR_3_H diff --git a/Skin_surface_3/include/CGAL/Marching_tetrahedra_observer_default_3.h b/Skin_surface_3/include/CGAL/Marching_tetrahedra_observer_default_3.h index 07b5309b4d8..9c7037cf570 100644 --- a/Skin_surface_3/include/CGAL/Marching_tetrahedra_observer_default_3.h +++ b/Skin_surface_3/include/CGAL/Marching_tetrahedra_observer_default_3.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -28,34 +28,21 @@ namespace CGAL { -template -class Marching_tetrahedra_observer_default_3 { +template +class Marching_tetrahedra_observer_default_3 +{ public: typedef Polyhedron_3 Polyhedron; - + typedef Cell_iterator T_Cell_iterator; - typedef typename Polyhedron::Vertex_handle Polyhedron_vertex_handle; - typedef typename Polyhedron::Facet_handle Polyhedron_facet_handle; + typedef typename Polyhedron::Vertex_handle Polyhedron_vertex_handle; + typedef typename Polyhedron::Facet_handle Polyhedron_facet_handle; - Marching_tetrahedra_observer_default_3() { - } - - Marching_tetrahedra_observer_default_3( - const Marching_tetrahedra_observer_default_3&) { - } - - void after_vertex_insertion( - T_Cell_iterator, int, int, - Polyhedron_vertex_handle) { - } - - void after_facet_insertion( - T_Cell_iterator, - Polyhedron_facet_handle) { - } + Marching_tetrahedra_observer_default_3() { } + Marching_tetrahedra_observer_default_3(const Marching_tetrahedra_observer_default_3&) { } + void after_vertex_insertion(T_Cell_iterator, int, int, Polyhedron_vertex_handle) { } + void after_facet_insertion(T_Cell_iterator, Polyhedron_facet_handle) { } }; } //namespace CGAL diff --git a/Skin_surface_3/include/CGAL/Marching_tetrahedra_traits_skin_surface_3.h b/Skin_surface_3/include/CGAL/Marching_tetrahedra_traits_skin_surface_3.h index ad3c28a0378..27f64980edc 100644 --- a/Skin_surface_3/include/CGAL/Marching_tetrahedra_traits_skin_surface_3.h +++ b/Skin_surface_3/include/CGAL/Marching_tetrahedra_traits_skin_surface_3.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -23,19 +23,19 @@ #include - #include #include #include -namespace CGAL { +namespace CGAL { /// NGHK: Is the converter needed or do we just use the Cartesian_converter template -class Marching_tetrahedra_traits_skin_surface_3 { + class Vertex_iterator, + class Cell_iterator, + class HalfedgeDS> +class Marching_tetrahedra_traits_skin_surface_3 +{ public: typedef HalfedgeDS Halfedge_DS; @@ -44,25 +44,28 @@ public: typedef typename SkinSurface_3::Bare_point Skin_point; - Marching_tetrahedra_traits_skin_surface_3(const SkinSurface_3 &ss_3) - : ss_3(ss_3) {} + Marching_tetrahedra_traits_skin_surface_3(const SkinSurface_3 &ss_3) + : ss_3(ss_3) + { } // These two functions are required by the marching tetrahedra algorithm Sign sign(const Cell_iterator ch, int i) const { return ss_3.sign(ch->vertex(i)); } - HDS_point intersection(Cell_iterator const ch, int i, int j) const { + + HDS_point intersection(Cell_iterator const ch, int i, int j) const + { // Precondition: ch is not an infinite cell: their surface is not set Skin_point p; ss_3.intersect(ch, i, j, p); - - return + + return Cartesian_converter()(p); } const SkinSurface_3 &ss_3; }; -} //namespace CGAL +} //namespace CGAL #endif // CGAL_MARCHING_TETRAHEDRA_TRAITS_SKIN_SURFACE_3_H diff --git a/Skin_surface_3/include/CGAL/Skin_surface_3.h b/Skin_surface_3/include/CGAL/Skin_surface_3.h index 1ebd5d2c38b..8f0b8709413 100644 --- a/Skin_surface_3/include/CGAL/Skin_surface_3.h +++ b/Skin_surface_3/include/CGAL/Skin_surface_3.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -23,18 +23,20 @@ #include - #include #include #include -namespace CGAL { +namespace CGAL { + +template +class Skin_surface_3 + : public Skin_surface_base_3 +{ + typedef MixedComplexTraits_3 Gt; + typedef Skin_surface_3 Self; + typedef Skin_surface_base_3 Base; -template -class Skin_surface_3 : public Skin_surface_base_3 { - typedef MixedComplexTraits_3 Gt; - typedef Skin_surface_3 Self; - typedef Skin_surface_base_3 Base; public: typedef MixedComplexTraits_3 Geometric_traits; @@ -59,6 +61,7 @@ public: typedef typename Base::Cell_info Cell_info; typedef typename Base::TMC TMC; + private: typedef typename Base::TMC_Vertex_iterator TMC_Vertex_iterator; typedef typename Base::TMC_Cell_iterator TMC_Cell_iterator; @@ -71,14 +74,14 @@ public: using Base::geometric_traits; using Base::regular; using Base::triangulated_mixed_complex; + public: template < class WP_iterator > - Skin_surface_3(WP_iterator begin, WP_iterator end, + Skin_surface_3(WP_iterator begin, WP_iterator end, FT shrink, bool grow_balls = true, Gt gt_ = Gt(), - bool _verbose = false - ); + bool _verbose = false); template void mesh_skin_surface_3(Polyhedron_3 &p) const { @@ -91,19 +94,19 @@ public: } }; -template +template template < class WP_iterator > Skin_surface_3:: -Skin_surface_3(WP_iterator begin, WP_iterator end, +Skin_surface_3(WP_iterator begin, WP_iterator end, FT shrink, bool grow_balls, Gt gt_, - bool verbose_) - : Base(begin, end, shrink, grow_balls, gt_, verbose_) { - + bool verbose_) + : Base(begin, end, shrink, grow_balls, gt_, verbose_) +{ // Construct the Triangulated_mixed_complex: Triangulated_mixed_complex_observer_3 observer(shrink_factor()); - triangulate_mixed_complex_3(regular(), shrink_factor(), + triangulate_mixed_complex_3(regular(), shrink_factor(), triangulated_mixed_complex(), observer, verbose_); diff --git a/Skin_surface_3/include/CGAL/Skin_surface_base_3.h b/Skin_surface_3/include/CGAL/Skin_surface_base_3.h index cd9de545dcd..8753beb0a81 100644 --- a/Skin_surface_3/include/CGAL/Skin_surface_base_3.h +++ b/Skin_surface_3/include/CGAL/Skin_surface_base_3.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -23,7 +23,6 @@ #include - #include #include #include @@ -54,31 +53,33 @@ #include #include -namespace CGAL { +namespace CGAL { + +template +class Skin_surface_base_3 +{ + typedef MixedComplexTraits_3 Gt; + typedef Skin_surface_base_3 Self; -template -class Skin_surface_base_3 { - typedef MixedComplexTraits_3 Gt; - typedef Skin_surface_base_3 Self; - public: - typedef MixedComplexTraits_3 Geometric_traits; + typedef MixedComplexTraits_3 Geometric_traits; - typedef typename Gt::Weighted_point_3 Weighted_point; + typedef typename Gt::Weighted_point_3 Weighted_point; typedef typename boost::mpl::eval_if_c< internal::Has_nested_type_Bare_point::value, typename internal::Bare_point_type, boost::mpl::identity - >::type Bare_point; + >::type Bare_point; - typedef typename Gt::FT FT; + typedef typename Gt::FT FT; // For normal - typedef typename Gt::Vector_3 Vector; - - typedef Regular_triangulation_3 Regular; + typedef typename Gt::Vector_3 Vector; + + typedef Regular_triangulation_3 Regular; private: typedef Exact_predicates_inexact_constructions_kernel Filtered_kernel; + public: typedef Skin_surface_quadratic_surface_3 Quadratic_surface; @@ -99,8 +100,8 @@ private: typedef typename Regular::Finite_cells_iterator Finite_cells_iterator; public: - typedef Anchor_point Vertex_info; - typedef std::pair > Cell_info; + typedef Anchor_point Vertex_info; + typedef std::pair > Cell_info; private: // Triangulated_mixed_complex: @@ -108,6 +109,7 @@ private: typedef Triangulation_vertex_base_with_info_3 Vb; typedef Triangulation_cell_base_with_info_3 Cb; typedef Triangulation_data_structure_3 Tds; + public: typedef Triangulation_3 TMC; typedef typename TMC::Geom_traits TMC_Geom_traits; @@ -117,59 +119,53 @@ public: typedef typename TMC::Cell_handle TMC_Cell_handle; typedef typename TMC::Point TMC_Point; - // Constructor template < class WP_iterator > Skin_surface_base_3(WP_iterator begin, WP_iterator end, FT shrink, bool grow_balls = true, Gt gt_ = Gt(), bool _verbose = false); - + template void mesh_surface_3(Polyhedron_3 &p) const; template void subdivide_mesh_3(Polyhedron_3 &p) const; - - - // Access functions: + // Access functions: TMC &triangulated_mixed_complex(); const FT shrink_factor() const { return shrink; } Geometric_traits &geometric_traits() const { return gt; } - // TMC &triangulated_mixed_complex() { return _tmc; } +// TMC &triangulated_mixed_complex() { return _tmc; } Regular ®ular() { return _regular; } // Predicates and constructions Sign sign(TMC_Vertex_handle vit) const; - - Sign sign(const Bare_point &p, + + Sign sign(const Bare_point &p, const TMC_Cell_handle start = TMC_Cell_handle()) const; - - Sign sign(const Bare_point &p, + + Sign sign(const Bare_point &p, const Cell_info &info) const; // Uses inexact computations to compute the sign - Sign sign_inexact(const Bare_point &p, + Sign sign_inexact(const Bare_point &p, const Cell_info &info) const; - + void intersect(TMC_Cell_handle ch, int i, int j, Bare_point &p) const; - void intersect(Bare_point &p1, Bare_point &p2, + void intersect(Bare_point &p1, Bare_point &p2, TMC_Cell_handle &s1, TMC_Cell_handle &s2, Bare_point &p) const; - - void intersect_with_transversal_segment - (Bare_point &p, - const TMC_Cell_handle &start = TMC_Cell_handle()) const; - + void intersect_with_transversal_segment( + Bare_point &p, + const TMC_Cell_handle &start = TMC_Cell_handle()) const; + template static typename Skin_surface_base_3::Bare_point get_weighted_circumcenter(const Simplex &s, Gt2 &traits); - Vector - normal(const Bare_point &p, - TMC_Cell_handle start = TMC_Cell_handle()) const; + Vector normal(const Bare_point &p, TMC_Cell_handle start = TMC_Cell_handle()) const; template static @@ -177,38 +173,36 @@ public: get_anchor_point(const Anchor_point &anchor, Gt2 &traits); private: - void construct_bounding_box(); + void construct_bounding_box(); template< class Traits > - Skin_surface_quadratic_surface_3 - construct_surface( - const Simplex &sim, - const Traits &traits = typename Geometric_traits::Kernel()) const; + Skin_surface_quadratic_surface_3 + construct_surface(const Simplex &sim, + const Traits &traits = typename Geometric_traits::Kernel()) const; Sign compare(Cell_info &info, const Bare_point &p1, const Bare_point &p2) const; - Sign compare(Cell_info &info1, const Bare_point &p1, + Sign compare(Cell_info &info1, const Bare_point &p1, Cell_info &info2, const Bare_point &p2) const; - - TMC_Cell_handle - locate_in_tmc(const Bare_point &p, - TMC_Cell_handle start = TMC_Cell_handle()) const; + + TMC_Cell_handle locate_in_tmc(const Bare_point &p, + TMC_Cell_handle start = TMC_Cell_handle()) const; private: FT shrink; Geometric_traits gt; Regular _regular; // Triangulated mixed complex or Voronoi diagram: TMC _tmc; - + bool verbose; }; -template +template template < class WP_iterator > Skin_surface_base_3:: Skin_surface_base_3(WP_iterator begin, WP_iterator end, FT shrink_, bool grow_balls, - Gt gt_, bool verbose_) -: shrink(shrink_), gt(gt_), verbose(verbose_) + Gt gt_, bool verbose_) + : shrink(shrink_), gt(gt_), verbose(verbose_) { gt.set_shrink(shrink); CGAL_assertion(begin != end); @@ -230,40 +224,42 @@ Skin_surface_base_3(WP_iterator begin, WP_iterator end, FT shrink_, } } -template +template template void Skin_surface_base_3:: -mesh_surface_3(Polyhedron_3 &p) const { +mesh_surface_3(Polyhedron_3 &p) const +{ typedef Polyhedron_3 Polyhedron; typedef Marching_tetrahedra_traits_skin_surface_3< Self, TMC_Vertex_iterator, TMC_Cell_iterator, - typename Polyhedron::HalfedgeDS> Traits; + typename Polyhedron::HalfedgeDS> Traits; typedef Skin_surface_marching_tetrahedra_observer_3< TMC_Vertex_iterator, TMC_Cell_iterator, - Polyhedron> Observer; + Polyhedron> Observer; // Extract the coarse mesh using marching_tetrahedra Traits marching_traits(*this); Observer marching_observer; - marching_tetrahedra_3(_tmc.finite_vertices_begin(), - _tmc.finite_vertices_end(), - _tmc.finite_cells_begin(), - _tmc.finite_cells_end(), - p, + marching_tetrahedra_3(_tmc.finite_vertices_begin(), + _tmc.finite_vertices_end(), + _tmc.finite_cells_begin(), + _tmc.finite_cells_end(), + p, marching_traits, marching_observer); } -template +template template void Skin_surface_base_3:: -subdivide_mesh_3(Polyhedron_3 &p) const { +subdivide_mesh_3(Polyhedron_3 &p) const +{ typedef Skin_surface_refinement_policy_3 Policy; typedef Skin_surface_sqrt3 Subdivider; @@ -280,11 +276,11 @@ triangulated_mixed_complex() { return _tmc; } -template +template typename Skin_surface_base_3::Vector Skin_surface_base_3:: -normal(const Bare_point &p, - TMC_Cell_handle start) const { +normal(const Bare_point &p, TMC_Cell_handle start) const +{ if (start == TMC_Cell_handle()) { start = locate_in_tmc(p,start); } @@ -292,10 +288,11 @@ normal(const Bare_point &p, return start->info().second->gradient(p); } -template -Sign +template +Sign Skin_surface_base_3:: -sign(TMC_Vertex_handle vit) const { +sign(TMC_Vertex_handle vit) const +{ CGAL_assertion(!_tmc.is_infinite(vit)); TMC_Cell_handle ch = vit->cell(); if (_tmc.is_infinite(ch)) { @@ -315,11 +312,11 @@ sign(TMC_Vertex_handle vit) const { // Protection is outside the try block as VC8 has the CGAL_CFG_FPU_ROUNDING_MODE_UNWINDING_VC_BUG Protect_FPU_rounding P; try - { - Sign result = vit->cell()->info().second->sign(vit->point()); - if (is_certain(result)) - return result; - } + { + Sign result = vit->cell()->info().second->sign(vit->point()); + if (is_certain(result)) + return result; + } catch (Uncertain_conversion_exception) {} } CGAL_BRANCH_PROFILER_BRANCH(tmp); @@ -336,11 +333,11 @@ sign(TMC_Vertex_handle vit) const { return construct_surface(vit->cell()->info().first, EK()).sign(p_exact); } -template -Sign +template +Sign Skin_surface_base_3:: -sign(const Bare_point &p, - const TMC_Cell_handle start) const { +sign(const Bare_point &p, const TMC_Cell_handle start) const +{ if (start == TMC_Cell_handle()) { return sign(p, locate_in_tmc(p,start)->info()); } else { @@ -348,52 +345,52 @@ sign(const Bare_point &p, } } -template -Sign +template +Sign Skin_surface_base_3:: -sign(const Bare_point &p, const Cell_info &info) const { +sign(const Bare_point &p, const Cell_info &info) const +{ CGAL_BRANCH_PROFILER(std::string(" NGHK: failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); { Protect_FPU_rounding P; try - { - Sign result = sign_inexact(p,info); - if (is_certain(result)) - return result; - } - catch (Uncertain_conversion_exception) {} + { + Sign result = sign_inexact(p,info); + if (is_certain(result)) + return result; + } + catch (Uncertain_conversion_exception) {} } CGAL_BRANCH_PROFILER_BRANCH(tmp); Protect_FPU_rounding P(CGAL_FE_TONEAREST); - return construct_surface - (info.first, - Exact_predicates_exact_constructions_kernel()).sign(p); + return construct_surface(info.first, + Exact_predicates_exact_constructions_kernel()).sign(p); } -template -Sign +template +Sign Skin_surface_base_3:: sign_inexact(const Bare_point &p, const Cell_info &info) const { return info.second->sign(p); } -template +template void Skin_surface_base_3:: -intersect(TMC_Cell_handle ch, int i, int j, - Bare_point &p) const { +intersect(TMC_Cell_handle ch, int i, int j, Bare_point &p) const +{ Cartesian_converter converter; Bare_point p1 = gt.construct_point_3_object()(converter(ch->vertex(i)->point())); Bare_point p2 = gt.construct_point_3_object()(converter(ch->vertex(j)->point())); - return intersect(p1, p2, ch, ch, p); + return intersect(p1, p2, ch, ch, p); } -template -void +template +void Skin_surface_base_3:: -intersect(Bare_point &p1, Bare_point &p2, +intersect(Bare_point &p1, Bare_point &p2, TMC_Cell_handle &s1, TMC_Cell_handle &s2, Bare_point &p) const { @@ -423,14 +420,13 @@ intersect(Bare_point &p1, Bare_point &p2, p = midpoint(p1, p2); } -template +template void Skin_surface_base_3:: intersect_with_transversal_segment( Bare_point &p, - const TMC_Cell_handle &start) const + const TMC_Cell_handle &start) const { - typedef typename Geometric_traits::Kernel::Plane_3 Plane; typedef typename Geometric_traits::Kernel::Line_3 Line; @@ -438,7 +434,7 @@ intersect_with_transversal_segment( if (tet == TMC_Cell_handle()) { tet = locate_in_tmc(p, tet); } - + // get transversal segment: Bare_point p1, p2; @@ -503,10 +499,10 @@ intersect_with_transversal_segment( intersect(p1, p2, tet, tet, p); } -template -void +template +void Skin_surface_base_3:: -construct_bounding_box() +construct_bounding_box() { typedef typename Regular::Finite_vertices_iterator Finite_vertices_iterator; @@ -525,42 +521,42 @@ construct_bounding_box() FT dx = bbox.xmax() - bbox.xmin(); FT dy = bbox.ymax() - bbox.ymin(); FT dz = bbox.zmax() - bbox.zmin(); - - Bare_point mid(bbox.xmin() + dx/2, - bbox.ymin() + dy/2, - bbox.zmin() + dz/2); - FT dr = + + Bare_point mid(bbox.xmin() + dx/2, + bbox.ymin() + dy/2, + bbox.zmin() + dz/2); + FT dr = (dx+dy+dz+sqrt(CGAL::to_double(max_weight))+.001) / gt.get_shrink(); Weighted_point wp; wp = Weighted_point(Bare_point(mid.x()+dr, - mid.y(), - mid.z()),-1); + mid.y(), + mid.z()),-1); regular().insert(wp); wp = Weighted_point(Bare_point(mid.x()-dr, - mid.y(), - mid.z()),-1); + mid.y(), + mid.z()),-1); regular().insert(wp); wp = Weighted_point(Bare_point(mid.x(), - mid.y()+dr, - mid.z()),-1); + mid.y()+dr, + mid.z()),-1); regular().insert(wp); wp = Weighted_point(Bare_point(mid.x(), - mid.y()-dr, - mid.z()),-1); + mid.y()-dr, + mid.z()),-1); regular().insert(wp); wp = Weighted_point(Bare_point(mid.x(), - mid.y(), - mid.z()+dr),-1); + mid.y(), + mid.z()+dr),-1); regular().insert(wp); wp = Weighted_point(Bare_point(mid.x(), - mid.y(), - mid.z()-dr),-1); + mid.y(), + mid.z()-dr),-1); regular().insert(wp); } } -template +template template typename Skin_surface_base_3::Bare_point Skin_surface_base_3:: @@ -572,9 +568,9 @@ get_anchor_point(const Anchor_point &anchor, Gt2 &traits) return traits.construct_anchor_point_3_object()(p_del,p_vor); } -template +template template< class Traits > -Skin_surface_quadratic_surface_3 +Skin_surface_quadratic_surface_3 Skin_surface_base_3:: construct_surface(const Simplex &sim, const Traits &) const { @@ -615,37 +611,34 @@ construct_surface(const Simplex &sim, const Traits &) const return Quadratic_surface(); } -template +template Sign Skin_surface_base_3:: -compare(Cell_info &info, - const Bare_point &p1, - const Bare_point &p2) const { +compare(Cell_info &info, const Bare_point &p1, const Bare_point &p2) const { return compare(info, p1, info, p2); } -template +template Sign Skin_surface_base_3:: -compare(Cell_info &info1, - const Bare_point &p1, - Cell_info &info2, - const Bare_point &p2) const { +compare(Cell_info &info1, const Bare_point &p1, + Cell_info &info2, const Bare_point &p2) const +{ CGAL_BRANCH_PROFILER(std::string(" NGHK: failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); { Protect_FPU_rounding P; try - { - Sign result = CGAL_NTS sign(info1.second->value(p1) - - info2.second->value(p2)); - if (is_certain(result)) - return result; - } + { + Sign result = CGAL_NTS sign(info1.second->value(p1) - + info2.second->value(p2)); + if (is_certain(result)) + return result; + } catch (Uncertain_conversion_exception) {} } CGAL_BRANCH_PROFILER_BRANCH(tmp); Protect_FPU_rounding P(CGAL_FE_TONEAREST); - + return CGAL_NTS sign( construct_surface(info1.first, Exact_predicates_exact_constructions_kernel()).value(p1) - @@ -653,11 +646,11 @@ compare(Cell_info &info1, Exact_predicates_exact_constructions_kernel()).value(p2)); } -template +template typename Skin_surface_base_3::TMC_Cell_handle Skin_surface_base_3:: -locate_in_tmc(const Bare_point &p0, - TMC_Cell_handle start) const { +locate_in_tmc(const Bare_point &p0, TMC_Cell_handle start) const +{ Cartesian_converter converter_fk; TMC_Point p_inexact = converter_fk(p0); @@ -688,7 +681,7 @@ locate_in_tmc(const Bare_point &p0, // For the remembering stochastic walk, // we need to start trying with a random index : - boost::rand48 rng; + boost::rand48 rng; boost::uniform_smallint<> four(0, 3); boost::variate_generator > die4(rng, four); int i = die4(); @@ -707,28 +700,29 @@ locate_in_tmc(const Bare_point &p0, { Protect_FPU_rounding P; try { - o = TMC_Geom_traits().orientation_3_object()(*pts[0], *pts[1], *pts[2], *pts[3]); + o = TMC_Geom_traits().orientation_3_object()(*pts[0], *pts[1], + *pts[2], *pts[3]); } catch (Uncertain_conversion_exception) { - Protect_FPU_rounding P(CGAL_FE_TONEAREST); - typedef Exact_predicates_exact_constructions_kernel EK; - Cartesian_converter converter_ek; - - Skin_surface_traits_3 exact_traits(shrink_factor()); - - typename EK::Point_3 e_pts[4]; - - // We know that the 4 vertices of c are positively oriented. - // So, in order to test if p is seen outside from one of c's facets, - // we just replace the corresponding point by p in the orientation - // test. We do this using the array below. - for (int k=0; k<4; k++) { - if (k != i) { - e_pts[k] = get_anchor_point(c->vertex(k)->info(), exact_traits); - } else { - e_pts[k] = converter_ek(p0); - } - } - o = orientation(e_pts[0], e_pts[1], e_pts[2], e_pts[3]); + Protect_FPU_rounding P(CGAL_FE_TONEAREST); + typedef Exact_predicates_exact_constructions_kernel EK; + Cartesian_converter converter_ek; + + Skin_surface_traits_3 exact_traits(shrink_factor()); + + typename EK::Point_3 e_pts[4]; + + // We know that the 4 vertices of c are positively oriented. + // So, in order to test if p is seen outside from one of c's facets, + // we just replace the corresponding point by p in the orientation + // test. We do this using the array below. + for (int k=0; k<4; k++) { + if (k != i) { + e_pts[k] = get_anchor_point(c->vertex(k)->info(), exact_traits); + } else { + e_pts[k] = converter_ek(p0); + } + } + o = orientation(e_pts[0], e_pts[1], e_pts[2], e_pts[3]); } } @@ -744,16 +738,16 @@ locate_in_tmc(const Bare_point &p0, c = next; goto try_next_cell; } - + CGAL_assertion(c->vertex(0) != _tmc.infinite_vertex()); CGAL_assertion(c->vertex(1) != _tmc.infinite_vertex()); CGAL_assertion(c->vertex(2) != _tmc.infinite_vertex()); CGAL_assertion(c->vertex(3) != _tmc.infinite_vertex()); - + return c; } - -template + +template template typename Skin_surface_base_3::Bare_point Skin_surface_base_3:: @@ -771,40 +765,40 @@ get_weighted_circumcenter(const Simplex &s, Gt2 &traits) Gt2_Bare_point result; switch(s.dimension()) { - case 0: + case 0: { vh = s; result = traits.construct_point_3_object()(converter(vh->point())); break; } - case 1: + case 1: { e = s; result = traits.construct_weighted_circumcenter_3_object() - (converter(e.first->vertex(e.second)->point()), - converter(e.first->vertex(e.third)->point())); + (converter(e.first->vertex(e.second)->point()), + converter(e.first->vertex(e.third)->point())); break; } - case 2: + case 2: { f = s; result = traits.construct_weighted_circumcenter_3_object() - (converter(f.first->vertex((f.second+1)&3)->point()), - converter(f.first->vertex((f.second+2)&3)->point()), - converter(f.first->vertex((f.second+3)&3)->point())); + (converter(f.first->vertex((f.second+1)&3)->point()), + converter(f.first->vertex((f.second+2)&3)->point()), + converter(f.first->vertex((f.second+3)&3)->point())); break; } - case 3: + case 3: { ch = s; result = traits.construct_weighted_circumcenter_3_object() - (converter(ch->vertex(0)->point()), - converter(ch->vertex(1)->point()), - converter(ch->vertex(2)->point()), - converter(ch->vertex(3)->point())); + (converter(ch->vertex(0)->point()), + converter(ch->vertex(1)->point()), + converter(ch->vertex(2)->point()), + converter(ch->vertex(3)->point())); break; } - default: + default: { CGAL_error(); } @@ -812,6 +806,6 @@ get_weighted_circumcenter(const Simplex &s, Gt2 &traits) return result; } -} //namespace CGAL +} //namespace CGAL #endif // CGAL_SKIN_SURFACE_BASE_3_H diff --git a/Skin_surface_3/include/CGAL/Skin_surface_filtered_traits_3.h b/Skin_surface_3/include/CGAL/Skin_surface_filtered_traits_3.h index df9405f2c13..d037a57f68e 100644 --- a/Skin_surface_3/include/CGAL/Skin_surface_filtered_traits_3.h +++ b/Skin_surface_3/include/CGAL/Skin_surface_filtered_traits_3.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -25,34 +25,30 @@ #include - #include #include #include -namespace CGAL { +namespace CGAL { template class Skin_surface_filtered_traits_3 : public Skin_surface_traits_base_3 { // Exact traits is based on the exact kernel. - typedef Skin_surface_traits_3 - Exact_traits; + typedef Skin_surface_traits_3 Exact_traits; // Filtering traits is based on the filtering kernel. - typedef Skin_surface_traits_3 - Filtering_traits; + typedef Skin_surface_traits_3 Filtering_traits; typedef typename K::C2E C2E; typedef typename K::C2F C2F; typedef Skin_surface_traits_base_3 Base; public: - typedef Filtered_predicate< - typename Exact_traits::Side_of_mixed_cell_3, - typename Filtering_traits::Side_of_mixed_cell_3, - C2E, - C2F > Side_of_mixed_cell_3; + typedef Filtered_predicate Side_of_mixed_cell_3; enum { Has_filtered_predicates=true }; enum { Has_static_filters=false }; @@ -61,13 +57,12 @@ public: Skin_surface_filtered_traits_3(typename Base::FT s) : Base(s) {} // Only make the predicates filtered, not the constructions: - Side_of_mixed_cell_3 - side_of_mixed_cell_3_object() const - { - return Side_of_mixed_cell_3(Base::get_shrink()); + Side_of_mixed_cell_3 + side_of_mixed_cell_3_object() const + { + return Side_of_mixed_cell_3(Base::get_shrink()); } - }; -} //namespace CGAL +} // namespace CGAL #endif // CGAL_SKIN_SURFACE_FILTERED_TRAITS_3_H diff --git a/Skin_surface_3/include/CGAL/Skin_surface_marching_tetrahedra_observer_3.h b/Skin_surface_3/include/CGAL/Skin_surface_marching_tetrahedra_observer_3.h index 867f0acf5bc..c1eeb935536 100644 --- a/Skin_surface_3/include/CGAL/Skin_surface_marching_tetrahedra_observer_3.h +++ b/Skin_surface_3/include/CGAL/Skin_surface_marching_tetrahedra_observer_3.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -23,7 +23,6 @@ #include - #include #include #include @@ -31,57 +30,52 @@ namespace CGAL { template + class Cell_iterator, + class Polyhedron_3> class Skin_surface_marching_tetrahedra_observer_3 : public Marching_tetrahedra_observer_default_3 - + { - typedef Polyhedron_3 Polyhedron; + typedef Polyhedron_3 Polyhedron; typedef Marching_tetrahedra_observer_default_3 - Base; + Base; public: - Skin_surface_marching_tetrahedra_observer_3() : Base() { - } - + Skin_surface_marching_tetrahedra_observer_3() : Base() { } }; template + class Cell_iterator, + class P_Traits, + class SkinSurface_3> class Skin_surface_marching_tetrahedra_observer_3 - > > - : public Marching_tetrahedra_observer_default_3 - > > + > > + : public Marching_tetrahedra_observer_default_3 + > > { public: - typedef Polyhedron_3 > - Polyhedron; + typedef Polyhedron_3 > Polyhedron; typedef Marching_tetrahedra_observer_default_3 - Base; + Base; typedef Cell_iterator T_Cell_iterator; - typedef typename Polyhedron::Vertex_handle Polyhedron_vertex_handle; - typedef typename Polyhedron::Facet_handle Polyhedron_facet_handle; + typedef typename Polyhedron::Vertex_handle Polyhedron_vertex_handle; + typedef typename Polyhedron::Facet_handle Polyhedron_facet_handle; - Skin_surface_marching_tetrahedra_observer_3() : Base() { - } + Skin_surface_marching_tetrahedra_observer_3() : Base() { } Skin_surface_marching_tetrahedra_observer_3( const Skin_surface_marching_tetrahedra_observer_3& traits2) : Base(traits2) {} - void after_facet_insertion( - T_Cell_iterator ch, - Polyhedron_facet_handle fh) { - + void after_facet_insertion(T_Cell_iterator ch, Polyhedron_facet_handle fh) { fh->tmc_ch = ch; } diff --git a/Skin_surface_3/include/CGAL/Skin_surface_polyhedral_items_3.h b/Skin_surface_3/include/CGAL/Skin_surface_polyhedral_items_3.h index 05bd27eb147..0cbc4cb5740 100644 --- a/Skin_surface_3/include/CGAL/Skin_surface_polyhedral_items_3.h +++ b/Skin_surface_3/include/CGAL/Skin_surface_polyhedral_items_3.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -23,7 +23,6 @@ #include - #include #include #include @@ -31,23 +30,27 @@ namespace CGAL { template -struct Skin_Surface_polyhedral_face: public CGAL::HalfedgeDS_face_base { +struct Skin_Surface_polyhedral_face: public CGAL::HalfedgeDS_face_base +{ typedef SkinSurface3 Skin_surface; typedef typename SkinSurface3::TMC::Cell_handle TMC_Cell_handle; typedef typename SkinSurface3::Simplex Simplex; - typename SkinSurface3::Simplex containing_simplex() { + typename SkinSurface3::Simplex containing_simplex() + { CGAL_assertion(tmc_ch != NULL); return tmc_ch->info().first; } + TMC_Cell_handle tmc_ch; }; template -struct Skin_surface_polyhedral_items_3: public Polyhedron_items_3 { - +struct Skin_surface_polyhedral_items_3: public Polyhedron_items_3 +{ template - struct Face_wrapper { + struct Face_wrapper + { typedef Skin_Surface_polyhedral_face Face; }; }; diff --git a/Skin_surface_3/include/CGAL/Skin_surface_polyhedral_items_with_face_information.h b/Skin_surface_3/include/CGAL/Skin_surface_polyhedral_items_with_face_information.h index 26b43b5ba8a..244a0d9168c 100644 --- a/Skin_surface_3/include/CGAL/Skin_surface_polyhedral_items_with_face_information.h +++ b/Skin_surface_3/include/CGAL/Skin_surface_polyhedral_items_with_face_information.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -23,13 +23,13 @@ #include - #include namespace CGAL { template -struct Skin_Surface_polyhedral_face : public CGAL::HalfedgeDS_face_base { +struct Skin_Surface_polyhedral_face : public CGAL::HalfedgeDS_face_base +{ typedef typename TriangulatedMixedComplex3::Cell_handle Triang_Cell_handle; Triang_Cell_handle triang_ch; @@ -37,10 +37,11 @@ struct Skin_Surface_polyhedral_face : public CGAL::HalfedgeDS_face_base { template < class TriangulatedMixedComplex3 > class Skin_surface_polyhedral_items_with_face_information_3 - : public Polyhedron_items_3 { - + : public Polyhedron_items_3 +{ template - struct Face_wrapper { + struct Face_wrapper + { typedef Skin_Surface_polyhedral_face Face; }; }; diff --git a/Skin_surface_3/include/CGAL/Skin_surface_quadratic_surface_3.h b/Skin_surface_3/include/CGAL/Skin_surface_quadratic_surface_3.h index 0144bf37b99..65ade74a4b2 100644 --- a/Skin_surface_3/include/CGAL/Skin_surface_quadratic_surface_3.h +++ b/Skin_surface_3/include/CGAL/Skin_surface_quadratic_surface_3.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -23,46 +23,48 @@ #include - #include namespace CGAL { template < class SkinSurfaceQuadraticSurfaceTraits_3 > -class Skin_surface_quadratic_surface_3 { +class Skin_surface_quadratic_surface_3 +{ public: - typedef SkinSurfaceQuadraticSurfaceTraits_3 K; - typedef typename K::FT FT; - typedef typename K::Point_3 Point; - typedef typename K::Vector_3 Vector; - typedef typename K::Segment_3 Segment; - typedef typename K::Weighted_point_3 Weighted_point; + typedef SkinSurfaceQuadraticSurfaceTraits_3 K; + typedef typename K::FT FT; + typedef typename K::Point_3 Point; + typedef typename K::Vector_3 Vector; + typedef typename K::Segment_3 Segment; + typedef typename K::Weighted_point_3 Weighted_point; Skin_surface_quadratic_surface_3() - : dim(-1), p(0,0,0), c(0) + : dim(-1), p(0,0,0), c(0) { for (int i=0; i<6; i++) Q[i] = 0; } + Skin_surface_quadratic_surface_3(FT Qinput[], Point p, FT c, int d) : dim(10+d), p(p), c(c) { for (int i=0; i<6; i++) Q[i] = Qinput[i]; } - int dim; + Skin_surface_quadratic_surface_3(Weighted_point wp0, FT s) - : dim(0), p(wp0.point()), c(-s*(1-s)*wp0.weight()) + : dim(0), p(wp0.point()), c(-s*(1-s)*wp0.weight()) { - CGAL_PROFILER(std::string("Constructor : ") + - std::string(CGAL_PRETTY_FUNCTION)); + CGAL_PROFILER(std::string("Constructor : ") + + std::string(CGAL_PRETTY_FUNCTION)); Q[1] = Q[3] = Q[4] = 0; Q[0] = Q[2] = Q[5] = (1-s); } - Skin_surface_quadratic_surface_3(Weighted_point wp0, - Weighted_point wp1, - FT s) : dim(1) + + Skin_surface_quadratic_surface_3(Weighted_point wp0, + Weighted_point wp1, + FT s) : dim(1) { - CGAL_PROFILER(std::string("Constructor : ") + - std::string(CGAL_PRETTY_FUNCTION)); + CGAL_PROFILER(std::string("Constructor : ") + + std::string(CGAL_PRETTY_FUNCTION)); K k; p = k.construct_weighted_circumcenter_3_object()(wp0,wp1); @@ -72,50 +74,50 @@ public: FT den = t*t; Q[0] = (- t.x()*t.x()/den + (1-s)); - + Q[1] = (-2*t.y()*t.x()/den); Q[2] = (- t.y()*t.y()/den + (1-s)); - + Q[3] = (-2*t.z()*t.x()/den); Q[4] = (-2*t.z()*t.y()/den); Q[5] = (- t.z()*t.z()/den + (1-s)); - } - Skin_surface_quadratic_surface_3(Weighted_point wp0, - Weighted_point wp1, - Weighted_point wp2, - FT s) : dim(2) + + Skin_surface_quadratic_surface_3(Weighted_point wp0, + Weighted_point wp1, + Weighted_point wp2, + FT s) : dim(2) { - CGAL_PROFILER(std::string("Constructor : ") + - std::string(CGAL_PRETTY_FUNCTION)); + CGAL_PROFILER(std::string("Constructor : ") + + std::string(CGAL_PRETTY_FUNCTION)); K k; p = k.construct_weighted_circumcenter_3_object()(wp0,wp1,wp2); c = s*(1-s)*k.compute_squared_radius_smallest_orthogonal_sphere_3_object()(wp0,wp1,wp2); - + Vector t = K().construct_orthogonal_vector_3_object()(k.construct_point_3_object()(wp0), k.construct_point_3_object()(wp1), k.construct_point_3_object()(wp2)); FT den = t*t; Q[0] = -(- t.x()*t.x()/den + s); - + Q[1] = -(-2*t.y()*t.x()/den); Q[2] = -(- t.y()*t.y()/den + s); - + Q[3] = -(-2*t.z()*t.x()/den); Q[4] = -(-2*t.z()*t.y()/den); Q[5] = -(- t.z()*t.z()/den + s); } - Skin_surface_quadratic_surface_3(Weighted_point wp0, - Weighted_point wp1, - Weighted_point wp2, - Weighted_point wp3, - FT s) : dim(3) + Skin_surface_quadratic_surface_3(Weighted_point wp0, + Weighted_point wp1, + Weighted_point wp2, + Weighted_point wp3, + FT s) : dim(3) { - CGAL_PROFILER(std::string("Constructor : ") + - std::string(CGAL_PRETTY_FUNCTION)); + CGAL_PROFILER(std::string("Constructor : ") + + std::string(CGAL_PRETTY_FUNCTION)); K k; p = k.construct_weighted_circumcenter_3_object()(wp0,wp1,wp2,wp3); @@ -125,27 +127,27 @@ public: } template - FT value(Input_point const &x) const { + FT value(Input_point const &x) const + { typedef Cartesian_converter Converter; - + FT vx = Converter()(x.x()) - p.x(); FT vy = Converter()(x.y()) - p.y(); FT vz = Converter()(x.z()) - p.z(); - return - vx*(Q[0]*vx) + - vy*(Q[1]*vx+Q[2]*vy) + - vz*(Q[3]*vx+Q[4]*vy+Q[5]*vz) + - c; + return vx*(Q[0]*vx) + + vy*(Q[1]*vx+Q[2]*vy) + + vz*(Q[3]*vx+Q[4]*vy+Q[5]*vz) + + c; } template Sign sign(Input_point const &x) const { return CGAL_NTS sign(value(x)); } - template - typename Input_point::R::Vector_3 gradient(Input_point const &x) { + typename Input_point::R::Vector_3 gradient(Input_point const &x) + { // NGHK: We use the kernel trick again: DOCUMENT!!!! typedef Cartesian_converter Converter; typedef Cartesian_converter Inv_converter; @@ -157,44 +159,47 @@ public: /// Construct the intersection point with the segment (p0,p1) template - Input_point to_surface(const Input_point &p0, const Input_point &p1) { + Input_point to_surface(const Input_point &p0, const Input_point &p1) + { // NGHK: We use the kernel trick again: DOCUMENT!!!! typedef Cartesian_converter Converter; Converter conv; Input_point pp0 = p0, pp1 = p1, mid; double sq_d = to_double(squared_distance(pp0,pp1)); - + if (value(conv(pp1)) < value(conv(pp0))) { std::swap(pp0, pp1); } - + while (sq_d > 1.e-10) { mid = midpoint(pp0,pp1); if (value(conv(mid)) > 0) { - pp1 = mid; + pp1 = mid; } else { - pp0 = mid; + pp0 = mid; } sq_d /= 4; } return midpoint(pp0,pp1); } + private: //template - Vector compute_gradient(Point const &x) { - + Vector compute_gradient(Point const &x) + { FT vx = x.x() - p.x(); FT vy = x.y() - p.y(); FT vz = x.z() - p.z(); return Vector(2*Q[0]*vx + Q[1]*vy + Q[3]*vz, - Q[1]*vx + 2*Q[2]*vy + Q[4]*vz, - Q[3]*vx + Q[4]*vy + 2*Q[5]*vz); + Q[1]*vx + 2*Q[2]*vy + Q[4]*vz, + Q[3]*vx + Q[4]*vy + 2*Q[5]*vz); } - - FT Q[6]; - Point p; + + int dim; + FT Q[6]; + Point p; FT c; }; diff --git a/Skin_surface_3/include/CGAL/Skin_surface_refinement_policy_3.h b/Skin_surface_3/include/CGAL/Skin_surface_refinement_policy_3.h index c4468712a6c..c401ad4c45c 100644 --- a/Skin_surface_3/include/CGAL/Skin_surface_refinement_policy_3.h +++ b/Skin_surface_3/include/CGAL/Skin_surface_refinement_policy_3.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -23,7 +23,6 @@ #include - #include #include @@ -33,7 +32,6 @@ #include namespace CGAL { - template class Skin_surface_refinement_policy_3 { @@ -51,16 +49,15 @@ public: typedef typename P_traits::Vector_3 P_vector; typedef typename P_traits::Plane_3 P_plane; - Skin_surface_refinement_policy_3(Skin_surface const& skin) : ss_3(skin) { - } - + Skin_surface_refinement_policy_3(Skin_surface const& skin) : ss_3(skin) { } + P_point to_surface(P_vertex_handle vh) const { typename Skin_surface::Bare_point result = - Cartesian_converter()(vh->point()); ss_3.intersect_with_transversal_segment(result); - return + return Cartesian_converter ()( result ); } @@ -69,25 +66,25 @@ public: { // Convert to and from the skin surface kernel typename Skin_surface::Bare_point p = - Cartesian_converter()(vh->point()); - return Cartesian_converter()( ss_3.normal(p)); + Cartesian_converter()(vh->point()); + return Cartesian_converter()( ss_3.normal(p)); } protected: - Skin_surface const &ss_3; + const Skin_surface &ss_3; }; template -class Skin_surface_refinement_policy_3< - SkinSurfaceBase_3, - Polyhedron_3 > > +class Skin_surface_refinement_policy_3 > > { public: typedef SkinSurfaceBase_3 Skin_surface; - typedef Polyhedron_3 > Polyhedron; typedef typename Polyhedron::Traits P_traits; @@ -103,30 +100,32 @@ public: Skin_surface_refinement_policy_3(Skin_surface const& skin) : ss_3(skin) { } - P_point to_surface(P_vertex_handle vh) const { + P_point to_surface(P_vertex_handle vh) const + { typename Skin_surface::Bare_point result = - Cartesian_converter()(vh->point()); + Cartesian_converter()(vh->point()); ss_3.intersect_with_transversal_segment(result, - vh->halfedge()->facet()->tmc_ch); + vh->halfedge()->facet()->tmc_ch); - return - Cartesian_converter - ()( result ); + return + Cartesian_converter()( result ); } - P_vector normal(P_vertex_handle vh) const { + P_vector normal(P_vertex_handle vh) const + { // Convert to and from the skin surface kernel typename Skin_surface::Bare_point p = - Cartesian_converter()(vh->point()); - return - Cartesian_converter - ()( ss_3.normal(p, vh->halfedge()->facet()->tmc_ch) ); + return + Cartesian_converter< + typename Skin_surface::Geometric_traits::Kernel, + P_traits>()( ss_3.normal(p, vh->halfedge()->facet()->tmc_ch) ); } - + protected: Skin_surface const &ss_3; }; diff --git a/Skin_surface_3/include/CGAL/Skin_surface_traits_3.h b/Skin_surface_3/include/CGAL/Skin_surface_traits_3.h index b6fdef89737..32a4d580904 100644 --- a/Skin_surface_3/include/CGAL/Skin_surface_traits_3.h +++ b/Skin_surface_3/include/CGAL/Skin_surface_traits_3.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -25,7 +25,7 @@ #include -namespace CGAL { +namespace CGAL { /** Input: a list of n weighted points p_1...p_n and a query point x. There is a plane separating the mixed cell defined by p_1...p_n-1 @@ -35,47 +35,53 @@ namespace CGAL { opposite side (POSITIVE). **/ template -class Side_of_mixed_cell_3 { +class Side_of_mixed_cell_3 +{ public: typedef typename K::FT FT; typedef typename K::Bare_point Bare_point; typedef typename K::Weighted_point Weighted_point; - Side_of_mixed_cell_3(const FT &shrink) : s(shrink) {} - - typedef CGAL::Sign result_type; - + typedef CGAL::Sign result_type; + + Side_of_mixed_cell_3(const FT &shrink) : s(shrink) { } + result_type operator()(const Weighted_point &p1, - const Weighted_point &p2, - const Bare_point &x) const { + const Weighted_point &p2, + const Bare_point &x) const + { return side_of_mixed_cellC3(p1.x(),p1.y(),p1.z(),p1.weight(), - p2.x(),p2.y(),p2.z(),p2.weight(), - x.x(),x.y(),x.z(), - s); + p2.x(),p2.y(),p2.z(),p2.weight(), + x.x(),x.y(),x.z(), + s); } + result_type operator()(const Weighted_point &p1, - const Weighted_point &p2, - const Weighted_point &p3, - const Bare_point &x) const { + const Weighted_point &p2, + const Weighted_point &p3, + const Bare_point &x) const + { return side_of_mixed_cellC3(p1.x(),p1.y(),p1.z(),p1.weight(), - p2.x(),p2.y(),p2.z(),p2.weight(), - p3.x(),p3.y(),p3.z(),p3.weight(), - x.x(),x.y(),x.z(), - s); + p2.x(),p2.y(),p2.z(),p2.weight(), + p3.x(),p3.y(),p3.z(),p3.weight(), + x.x(),x.y(),x.z(), + s); } + result_type operator()(const Weighted_point &p1, - const Weighted_point &p2, - const Weighted_point &p3, - const Weighted_point &p4, - const Bare_point &x) const { + const Weighted_point &p2, + const Weighted_point &p3, + const Weighted_point &p4, + const Bare_point &x) const + { return side_of_mixed_cellC3(p1.x(),p1.y(),p1.z(),p1.weight(), - p2.x(),p2.y(),p2.z(),p2.weight(), - p3.x(),p3.y(),p3.z(),p3.weight(), - p4.x(),p4.y(),p4.z(),p4.weight(), - x.x(),x.y(),x.z(), - s); + p2.x(),p2.y(),p2.z(),p2.weight(), + p3.x(),p3.y(),p3.z(),p3.weight(), + p4.x(),p4.y(),p4.z(),p4.weight(), + x.x(),x.y(),x.z(), + s); } - + private: FT s; }; @@ -84,61 +90,61 @@ private: Computes the anchor point of a Delaunay center and a Voronoi center **/ template -class Construct_anchor_point_3 { +class Construct_anchor_point_3 +{ public: typedef typename K::FT FT; - typedef typename K::Point_3 Bare_point; + typedef typename K::Point_3 Bare_point; + + typedef Bare_point result_type; Construct_anchor_point_3(const FT &shrink) : s(shrink) {} - - typedef Bare_point result_type; - + result_type operator()(const Bare_point &p_del, - const Bare_point &p_vor) const { + const Bare_point &p_vor) const + { return Bare_point((1-s)*p_del.x() + s*p_vor.x(), - (1-s)*p_del.y() + s*p_vor.y(), - (1-s)*p_del.z() + s*p_vor.z()); + (1-s)*p_del.y() + s*p_vor.y(), + (1-s)*p_del.z() + s*p_vor.z()); } - + private: FT s; }; template -class Skin_surface_traits_base_3 +class Skin_surface_traits_base_3 : public K_ { public: - typedef K_ Kernel; - typedef Skin_surface_traits_base_3 Self; + typedef K_ Kernel; + typedef Skin_surface_traits_base_3 Self; - typedef typename Kernel::FT FT; + typedef typename Kernel::FT FT; - typedef CGAL::Side_of_mixed_cell_3 Side_of_mixed_cell_3; - typedef CGAL::Construct_anchor_point_3 Construct_anchor_point_3; - - - - Skin_surface_traits_base_3() : s(-1) { - } - Skin_surface_traits_base_3(FT s) : s(s) { - } - void set_shrink(FT s_) { - s = s_; + typedef CGAL::Side_of_mixed_cell_3 Side_of_mixed_cell_3; + typedef CGAL::Construct_anchor_point_3 Construct_anchor_point_3; + + Skin_surface_traits_base_3() : s(-1) { } + Skin_surface_traits_base_3(FT s) : s(s) { } + + void set_shrink(FT s_) { + s = s_; } + FT get_shrink() const { return s; } - - Side_of_mixed_cell_3 - side_of_mixed_cell_3_object() const { + Side_of_mixed_cell_3 side_of_mixed_cell_3_object() const + { CGAL_assertion((s>0) && (s<1)); - return Side_of_mixed_cell_3(get_shrink()); } + return Side_of_mixed_cell_3(get_shrink()); + } - Construct_anchor_point_3 - construct_anchor_point_3_object() const - { return Construct_anchor_point_3(get_shrink()); } + Construct_anchor_point_3 construct_anchor_point_3_object() const { + return Construct_anchor_point_3(get_shrink()); + } private: FT s; @@ -166,24 +172,21 @@ public: #include #include - namespace CGAL { // Just FK would be nicer, but VC 2005 messes it up with an "FK" in a base class when compiling degenerate_test.cpp template < typename Sst3FK > -class Skin_surface_traits_3 < Sst3FK,true > +class Skin_surface_traits_3 < Sst3FK, true > : public Skin_surface_filtered_traits_3 < Sst3FK > { typedef Skin_surface_filtered_traits_3 < Sst3FK > Base; + public: typedef Sst3FK Kernel; - + Skin_surface_traits_3() {} - Skin_surface_traits_3(typename Base::FT s) : Base(s) {} - + Skin_surface_traits_3(typename Base::FT s) : Base(s) { } }; - - } //namespace CGAL #endif // CGAL_SKIN_SURFACE_TRAITS_3_H diff --git a/Skin_surface_3/include/CGAL/Triangulated_mixed_complex_observer_3.h b/Skin_surface_3/include/CGAL/Triangulated_mixed_complex_observer_3.h index baf40e5d454..ea2f40142fe 100644 --- a/Skin_surface_3/include/CGAL/Triangulated_mixed_complex_observer_3.h +++ b/Skin_surface_3/include/CGAL/Triangulated_mixed_complex_observer_3.h @@ -23,7 +23,6 @@ #include - #include #include @@ -40,9 +39,9 @@ struct SS_Dereference_type { typedef T value_type; }; -template -class Triangulated_mixed_complex_observer_3 { +template +class Triangulated_mixed_complex_observer_3 +{ public: typedef SkinSurface_3 Skin_surface; typedef TriangulatedMixedComplex_3 Triangulated_mixed_complex; @@ -50,9 +49,9 @@ public: typedef typename SkinSurface_3::Regular Regular; typedef typename Regular::Geom_traits Regular_traits; typedef typename Triangulated_mixed_complex::Geom_traits - Triangulated_mixed_complex_traits; + Triangulated_mixed_complex_traits; typedef typename Triangulated_mixed_complex::Triangulation_data_structure - TMC_TDS; + TMC_TDS; typedef typename SkinSurface_3::Quadratic_surface Quadratic_surface; typedef typename Regular_traits::FT FT; @@ -77,7 +76,7 @@ public: typedef typename Quadratic_surface::Vector Surface_vector; typedef typename Surface_traits::Weighted_point_3 Surface_weighted_point; - typedef + typedef Cartesian_converter < typename Rt_Bare_point::R, typename Quadratic_surface::K > R2S_converter; Triangulated_mixed_complex_observer_3(FT shrink) : @@ -89,7 +88,8 @@ public: vh->info() = typename SkinSurface_3::Vertex_info(sDel, sVor); } - void after_cell_insertion(Rt_Simplex const &s, TMC_Cell_handle &ch) { + void after_cell_insertion(Rt_Simplex const &s, TMC_Cell_handle &ch) + { if (!(s == prev_s)) { prev_s = s; Rt_Vertex_handle vh; @@ -103,8 +103,8 @@ public: case 0: { vh = s; Surface_weighted_point wp = r2s_converter(vh->point()); - create_sphere(wp.point(), - -wp.weight(), + create_sphere(wp.point(), + -wp.weight(), r2s_converter(shrink), 1); break; } @@ -147,7 +147,7 @@ public: } case 3: { ch = s; - const Surface_weighted_point pts[4] = + const Surface_weighted_point pts[4] = { r2s_converter(ch->vertex(0)->point()), r2s_converter(ch->vertex(1)->point()), @@ -180,7 +180,8 @@ public: void create_sphere(const Surface_point &c, const Surface_RT &w, const Surface_RT &s, - const int orient) { + const int orient) + { if (s == 1) { // Dont multiply by (1-s) as this will zero the equation Q[1] = Q[3] = Q[4] = 0; @@ -188,7 +189,7 @@ public: surf = boost::shared_ptr(new Quadratic_surface(Q, c, s*w, (orient==1? 0 : 3))); } else { - // Multiply with 1-s to make the function defining the + // Multiply with 1-s to make the function defining the // skin surface implicitly continuous Q[1] = Q[3] = Q[4] = 0; Q[0] = Q[2] = Q[5] = orient*(1-s); @@ -201,7 +202,8 @@ public: const Surface_RT &w, const Surface_vector &t, const Surface_RT &s, - const int orient) { + const int orient) + { Surface_RT den = t*t; Q[0] = orient*(- t.x()*t.x()/den + (1-s)); diff --git a/Skin_surface_3/include/CGAL/Triangulation_incremental_builder_3.h b/Skin_surface_3/include/CGAL/Triangulation_incremental_builder_3.h index 03e06e9bd4b..285f1d82536 100644 --- a/Skin_surface_3/include/CGAL/Triangulation_incremental_builder_3.h +++ b/Skin_surface_3/include/CGAL/Triangulation_incremental_builder_3.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -23,7 +23,6 @@ #include - #include #include #include @@ -34,7 +33,8 @@ namespace CGAL { template < class Triangulation_3 > -class Triangulation_incremental_builder_3 { +class Triangulation_incremental_builder_3 +{ public: typedef Triangulation_3 T; typedef typename T::Vertex_handle Vertex_handle; @@ -48,37 +48,40 @@ public: ~Triangulation_incremental_builder_3() {} - void begin_triangulation(int dim) { + void begin_triangulation(int dim) + { t.clear(); t.tds().delete_cell(t.infinite_vertex()->cell()); // t.infinite = add_vertex(); - t.tds().set_dimension(dim); + t.tds().set_dimension(dim); } - void end_triangulation() { + void end_triangulation() + { construct_infinite_cells(); CGAL_assertion(t.infinite_vertex()->cell() != Cell_handle()); } Vertex_handle add_vertex(); Cell_handle add_cell(Vertex_handle vh0, Vertex_handle vh1, - Vertex_handle vh2, Vertex_handle vh3); - + Vertex_handle vh2, Vertex_handle vh3); + private: void construct_infinite_cells(); Cell_handle add_infinite_cell(Cell_handle ch, int i); - + void glue_cells(Cell_handle ch0, int ind0, Cell_handle ch1, int ind1); // Interior facets of the simplical cell: - typedef std::pair < Vertex_handle, Vertex_handle > Vpair; - typedef std::map < Vpair, Facet > MapPair; - typedef typename MapPair::iterator MapPairIt; - typedef cpp11::array < Vertex_handle, 3 > Vtriple; - typedef std::map < Vtriple, Facet > MapTriple; - typedef typename MapTriple::iterator MapTripleIt; - - Vtriple facet(Vertex_handle vh1, Vertex_handle vh2, Vertex_handle vh3) { + typedef std::pair < Vertex_handle, Vertex_handle > Vpair; + typedef std::map < Vpair, Facet > MapPair; + typedef typename MapPair::iterator MapPairIt; + typedef cpp11::array < Vertex_handle, 3 > Vtriple; + typedef std::map < Vtriple, Facet > MapTriple; + typedef typename MapTriple::iterator MapTripleIt; + + Vtriple facet(Vertex_handle vh1, Vertex_handle vh2, Vertex_handle vh3) + { if (vh1 < vh2) { if (vh2 < vh3) { return CGAL::make_array(vh1,vh2,vh3); @@ -100,15 +103,13 @@ private: } } } - + MapTriple facets; T &t; bool m_verbose; }; - - template < class TDS_> typename Triangulation_incremental_builder_3< TDS_ >::Vertex_handle Triangulation_incremental_builder_3< TDS_ >::add_vertex() { @@ -118,23 +119,22 @@ Triangulation_incremental_builder_3< TDS_ >::add_vertex() { template < class TDS_> typename Triangulation_incremental_builder_3< TDS_ >::Cell_handle Triangulation_incremental_builder_3< TDS_ >::add_cell( - Vertex_handle vh0, Vertex_handle vh1, Vertex_handle vh2, Vertex_handle vh3) + Vertex_handle vh0, Vertex_handle vh1, Vertex_handle vh2, Vertex_handle vh3) { CGAL_assertion(vh0 != NULL); CGAL_assertion(vh1 != NULL); CGAL_assertion(vh2 != NULL); CGAL_assertion(vh3 != NULL); CGAL_assertion(vh0 != vh1); CGAL_assertion(vh0 != vh2); CGAL_assertion(vh0 != vh3); CGAL_assertion(vh1 != vh2); CGAL_assertion(vh1 != vh3); CGAL_assertion(vh2 != vh3); - + Cell_handle ch = t.tds().create_cell(vh0, vh1, vh2, vh3); // Neighbors are by default set to NULL vh0->set_cell(ch); vh1->set_cell(ch); vh2->set_cell(ch); vh3->set_cell(ch); for (int i=0; i<4; i++) { - Vtriple vtriple=facet( - ch->vertex((i+1)&3), - ch->vertex((i+2)&3), - ch->vertex((i+3)&3)); + Vtriple vtriple=facet(ch->vertex((i+1)&3), + ch->vertex((i+2)&3), + ch->vertex((i+3)&3)); std::pair res = facets.insert(std::make_pair(vtriple, Facet(ch, i))); if (! res.second) { // we found an element with this key @@ -155,7 +155,7 @@ Triangulation_incremental_builder_3< TDS_ >::add_cell( template < class TDS_> typename Triangulation_incremental_builder_3< TDS_ >::Cell_handle Triangulation_incremental_builder_3< TDS_ >::add_infinite_cell( - Cell_handle ch0, int i) + Cell_handle ch0, int i) { CGAL_assertion(ch0->neighbor(i) == NULL); Vertex_handle vh[4]; @@ -200,12 +200,13 @@ Triangulation_incremental_builder_3< TDS_ >::glue_cells( // Adds infinite cells to the facets on the convex hull template < class TDS_> void -Triangulation_incremental_builder_3< TDS_ >::construct_infinite_cells() { +Triangulation_incremental_builder_3< TDS_ >::construct_infinite_cells() +{ MapTripleIt ch_facet_it; MapPair ch_edges; MapPairIt ch_edge_it; Vertex_handle vh1, vh2; - + for (ch_facet_it = facets.begin(); ch_facet_it != facets.end(); ch_facet_it ++) { @@ -216,29 +217,29 @@ Triangulation_incremental_builder_3< TDS_ >::construct_infinite_cells() { // Index of ch1 is also ind0 CGAL_assertion(ch0->neighbor(ind0) != NULL); CGAL_assertion(ch1->neighbor(ind0) != NULL); - + for (int i=1; i<4; i++) { int i1 = (i==1?2:1); int i2 = (i==3?2:3); if (ch1->vertex((ind0+i1)&3) < ch1->vertex((ind0+i2)&3)) { - vh1 = ch1->vertex((ind0+i1)&3); - vh2 = ch1->vertex((ind0+i2)&3); + vh1 = ch1->vertex((ind0+i1)&3); + vh2 = ch1->vertex((ind0+i2)&3); } else { - vh1 = ch1->vertex((ind0+i2)&3); - vh2 = ch1->vertex((ind0+i1)&3); + vh1 = ch1->vertex((ind0+i2)&3); + vh2 = ch1->vertex((ind0+i1)&3); } ch_edge_it = ch_edges.find(Vpair(vh1,vh2)); if (ch_edge_it != ch_edges.end()) { - Facet f_opp = (*ch_edge_it).second; - glue_cells(f_opp.first, f_opp.second, ch1, (ind0+i)&3); - ch_edges.erase(ch_edge_it); - CGAL_assertion(f_opp.first->neighbor(f_opp.second) != NULL); - CGAL_assertion(ch1->neighbor((ind0+i)&3) != NULL); + Facet f_opp = (*ch_edge_it).second; + glue_cells(f_opp.first, f_opp.second, ch1, (ind0+i)&3); + ch_edges.erase(ch_edge_it); + CGAL_assertion(f_opp.first->neighbor(f_opp.second) != NULL); + CGAL_assertion(ch1->neighbor((ind0+i)&3) != NULL); } else { - ch_edges[Vpair(vh1,vh2)] = Facet(ch1, (ind0+i)&3); - CGAL_assertion(ch1->neighbor((ind0+i)&3) == NULL); + ch_edges[Vpair(vh1,vh2)] = Facet(ch1, (ind0+i)&3); + CGAL_assertion(ch1->neighbor((ind0+i)&3) == NULL); } - } + } } CGAL_assertion(ch_edges.empty()); } diff --git a/Skin_surface_3/include/CGAL/Union_of_balls_3.h b/Skin_surface_3/include/CGAL/Union_of_balls_3.h index e4287ed2ef1..06a914d9426 100644 --- a/Skin_surface_3/include/CGAL/Union_of_balls_3.h +++ b/Skin_surface_3/include/CGAL/Union_of_balls_3.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -27,13 +27,16 @@ #include #include -namespace CGAL { +namespace CGAL { + +template +class Union_of_balls_3 + : public Skin_surface_base_3 +{ + typedef MixedComplexTraits_3 Gt; + typedef Union_of_balls_3 Self; + typedef Skin_surface_base_3 Base; -template -class Union_of_balls_3 : public Skin_surface_base_3 { - typedef MixedComplexTraits_3 Gt; - typedef Union_of_balls_3 Self; - typedef Skin_surface_base_3 Base; public: typedef MixedComplexTraits_3 Geometric_traits; @@ -69,12 +72,12 @@ private: using Base::geometric_traits; using Base::regular; using Base::triangulated_mixed_complex; + public: template < class WP_iterator > - Union_of_balls_3(WP_iterator begin, WP_iterator end, - Gt gt_ = Gt(), - bool _verbose = false - ); + Union_of_balls_3(WP_iterator begin, WP_iterator end, + Gt gt_ = Gt(), + bool _verbose = false); template void mesh_skin_surface_3(Polyhedron_3 &p) const { @@ -86,14 +89,14 @@ public: } }; -template +template template < class WP_iterator > Union_of_balls_3:: -Union_of_balls_3(WP_iterator begin, WP_iterator end, +Union_of_balls_3(WP_iterator begin, WP_iterator end, Gt gt_, - bool _verbose) - : Base(begin, end, 1, false, gt_, _verbose) { - + bool _verbose) + : Base(begin, end, 1, false, gt_, _verbose) +{ // Construct the Triangulated_mixed_complex: Triangulated_mixed_complex_observer_3 observer(shrink_factor()); triangulate_power_diagram_3(regular(), triangulated_mixed_complex(), observer, _verbose); @@ -102,7 +105,7 @@ Union_of_balls_3(WP_iterator begin, WP_iterator end, // { // NGHK: debug code: // CGAL_assertion(triangulated_mixed_complex().is_valid()); // std::vector ch_vertices; -// triangulated_mixed_complex().incident_vertices(triangulated_mixed_complex().infinite_vertex(), +// triangulated_mixed_complex().incident_vertices(triangulated_mixed_complex().infinite_vertex(), // std::back_inserter(ch_vertices)); // for (typename std::vector::iterator // vit = ch_vertices.begin(); vit != ch_vertices.end(); vit++) { @@ -110,7 +113,6 @@ Union_of_balls_3(WP_iterator begin, WP_iterator end, // } // } } - } //namespace CGAL diff --git a/Skin_surface_3/include/CGAL/make_skin_surface_mesh_3.h b/Skin_surface_3/include/CGAL/make_skin_surface_mesh_3.h index e140ea53d82..15ba2de7589 100644 --- a/Skin_surface_3/include/CGAL/make_skin_surface_mesh_3.h +++ b/Skin_surface_3/include/CGAL/make_skin_surface_mesh_3.h @@ -36,21 +36,20 @@ namespace CGAL { template void make_skin_surface_mesh_3(Polyhedron_3 &p, - WP_iterator begin, WP_iterator end, - double shrink_factor=.5, - int nSubdivisions=0, - bool grow_balls=true) + WP_iterator begin, WP_iterator end, + double shrink_factor=.5, + int nSubdivisions=0, + bool grow_balls=true) { if (shrink_factor == 1) { make_union_of_balls_mesh_3(p,begin,end,nSubdivisions); } - - typedef typename WP_iterator::value_type Weighted_point; + typedef typename WP_iterator::value_type Weighted_point; typedef typename Kernel_traits::Kernel K; - typedef Skin_surface_traits_3 Traits; - typedef Skin_surface_3 Skin_surface; + typedef Skin_surface_traits_3 Traits; + typedef Skin_surface_3 Skin_surface; Skin_surface skin_surface(begin, end, shrink_factor, grow_balls); diff --git a/Skin_surface_3/include/CGAL/make_union_of_balls_3.h b/Skin_surface_3/include/CGAL/make_union_of_balls_3.h index be6447b0903..bec6d6435ea 100644 --- a/Skin_surface_3/include/CGAL/make_union_of_balls_3.h +++ b/Skin_surface_3/include/CGAL/make_union_of_balls_3.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -23,7 +23,6 @@ #include - #include #include #include @@ -33,18 +32,17 @@ namespace CGAL { -template -void make_union_of_balls_mesh_3(Polyhedron_3 &p, - WP_iterator begin, WP_iterator end, - int nSubdivisions=0) +template +void make_union_of_balls_mesh_3(Polyhedron_3 &p, + WP_iterator begin, WP_iterator end, + int nSubdivisions=0) { - typedef typename WP_iterator::value_type Weighted_point; - typedef typename Kernel_traits::Kernel K; + typedef typename WP_iterator::value_type Weighted_point; + typedef typename Kernel_traits::Kernel K; + + typedef Skin_surface_traits_3 Traits; + typedef Union_of_balls_3 Union_of_balls; - typedef Skin_surface_traits_3 Traits; - typedef Union_of_balls_3 Union_of_balls; - Union_of_balls union_of_balls(begin, end); CGAL::mesh_union_of_balls_3(union_of_balls, p); @@ -52,8 +50,6 @@ void make_union_of_balls_mesh_3(Polyhedron_3 &p, CGAL::subdivide_union_of_balls_mesh_3(union_of_balls, p, nSubdivisions); } - - } //namespace CGAL #endif // CGAL_MAKE_UNION_OF_BALLS_MESH_3_H diff --git a/Skin_surface_3/include/CGAL/mesh_skin_surface_3.h b/Skin_surface_3/include/CGAL/mesh_skin_surface_3.h index 34a529e471c..ab1cdcee066 100644 --- a/Skin_surface_3/include/CGAL/mesh_skin_surface_3.h +++ b/Skin_surface_3/include/CGAL/mesh_skin_surface_3.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -23,7 +23,6 @@ #include - #include #include #include @@ -42,7 +41,7 @@ void mesh_skin_surface_3(SkinSurface_3 const &skin_surface, Polyhedron &p) // //template //void mesh_skin_surface_3 -//(SkinSurface_3 const &skin_surface, +//(SkinSurface_3 const &skin_surface, // Polyhedron_3 > &p) //{ // std::cout << "B" << std::endl; @@ -50,7 +49,6 @@ void mesh_skin_surface_3(SkinSurface_3 const &skin_surface, Polyhedron &p) //} // - } //namespace CGAL #endif // CGAL_MESH_SKIN_SURFACE_3_H diff --git a/Skin_surface_3/include/CGAL/mesh_union_of_balls_3.h b/Skin_surface_3/include/CGAL/mesh_union_of_balls_3.h index 9d56cbbe4ab..0961c75638b 100644 --- a/Skin_surface_3/include/CGAL/mesh_union_of_balls_3.h +++ b/Skin_surface_3/include/CGAL/mesh_union_of_balls_3.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -23,7 +23,6 @@ #include - #include namespace CGAL { diff --git a/Skin_surface_3/include/CGAL/subdivide_skin_surface_mesh_3.h b/Skin_surface_3/include/CGAL/subdivide_skin_surface_mesh_3.h index 8ad2004c4ea..bc1bf4374fe 100644 --- a/Skin_surface_3/include/CGAL/subdivide_skin_surface_mesh_3.h +++ b/Skin_surface_3/include/CGAL/subdivide_skin_surface_mesh_3.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -23,35 +23,34 @@ #include - #include #include namespace CGAL { -// This code is based on the Polyhedron tutorial +// This code is based on the Polyhedron tutorial template + class Polyhedron_3, + class SubdivisionPolicy_3> class Skin_surface_sqrt3 { typedef Polyhedron_3 Polyhedron; typedef SkinSurface_3 Skin_surface_3; // Projects points to the skin surface: typedef SubdivisionPolicy_3 Subdivision_policy; - + typedef typename Polyhedron::Traits Kernel; typedef typename Kernel::Point_3 Point; typedef typename Kernel::Vector_3 Vector; - + typedef typename Polyhedron::Vertex Vertex; typedef typename Polyhedron::Vertex_handle Vertex_handle; typedef typename Polyhedron::Vertex_iterator Vertex_iterator; typedef typename Polyhedron::Edge_iterator Edge_iterator; typedef typename Polyhedron::Halfedge_handle Halfedge_handle; typedef typename Polyhedron::Halfedge_iterator Halfedge_iterator; - typedef typename Polyhedron::Halfedge_around_vertex_const_circulator + typedef typename Polyhedron::Halfedge_around_vertex_const_circulator HV_circulator; typedef typename Polyhedron::Halfedge_around_facet_circulator HF_circulator; @@ -61,10 +60,10 @@ class Skin_surface_sqrt3 typedef typename Kernel::FT FT; public: - Skin_surface_sqrt3(const SkinSurface_3 &skin, - Polyhedron &P, - const SubdivisionPolicy_3 &policy) - : P(P), ss(skin), policy(policy) {} + Skin_surface_sqrt3(const SkinSurface_3 &skin, + Polyhedron &P, + const SubdivisionPolicy_3 &policy) + : P(P), ss(skin), policy(policy) { } //********************************************* // Subdivision @@ -86,13 +85,12 @@ public: } private: - + //********************************************* // Subdivide //********************************************* void do_subdivide() { - // We use that new vertices/halfedges/facets are appended at the end. Vertex_iterator last_v = P.vertices_end(); -- last_v; // the last of the old vertices @@ -107,7 +105,6 @@ private: split_halfedge(e); } while ( e++ != last_e); - Vertex_iterator v = P.vertices_begin(); do { Halfedge_handle h_cir, h_start; @@ -145,10 +142,9 @@ private: }; template -void subdivide_skin_surface_mesh_3( - const SkinSurface_3 &skin, - Polyhedron_3 &p, - int nSubdiv = 1) { +void subdivide_skin_surface_mesh_3(const SkinSurface_3 &skin, + Polyhedron_3 &p, + int nSubdiv = 1) { while (nSubdiv > 0) { skin.subdivide_mesh_3(p); nSubdiv--; diff --git a/Skin_surface_3/include/CGAL/subdivide_union_of_balls_mesh_3.h b/Skin_surface_3/include/CGAL/subdivide_union_of_balls_mesh_3.h index 2915fb9cbf0..524e29b2d9e 100644 --- a/Skin_surface_3/include/CGAL/subdivide_union_of_balls_mesh_3.h +++ b/Skin_surface_3/include/CGAL/subdivide_union_of_balls_mesh_3.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -23,17 +23,16 @@ #include - #include #include namespace CGAL { template -void subdivide_union_of_balls_mesh_3( - const UnionOfBalls_3 &skin, - Polyhedron_3 &p, - int nSubdiv = 1) { +void subdivide_union_of_balls_mesh_3(const UnionOfBalls_3 &skin, + Polyhedron_3 &p, + int nSubdiv = 1) +{ while (nSubdiv > 0) { skin.subdivide_mesh_3(p); nSubdiv--; diff --git a/Skin_surface_3/include/CGAL/triangulate_mixed_complex_3.h b/Skin_surface_3/include/CGAL/triangulate_mixed_complex_3.h index 38dcaa2a29d..83fd05ffe98 100644 --- a/Skin_surface_3/include/CGAL/triangulate_mixed_complex_3.h +++ b/Skin_surface_3/include/CGAL/triangulate_mixed_complex_3.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -23,7 +23,6 @@ #include - // #include #include @@ -41,36 +40,32 @@ namespace CGAL { - -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3 = - Triangulated_mixed_complex_observer_3 > -class Mixed_complex_triangulator_3 { +template > +class Mixed_complex_triangulator_3 +{ public: typedef typename RegularTriangulation_3::Geom_traits - Regular_traits; - typedef typename TriangulatedMixedComplex_3::Geom_traits - Triangulated_mixed_complex_traits; + Regular_traits; + typedef RegularTriangulation_3 Regular; + typedef TriangulatedMixedComplex_3 Triangulated_mixed_complex; + typedef TriangulatedMixedComplexObserver_3 Triangulated_mixed_complex_observer; - typedef RegularTriangulation_3 Regular; - typedef TriangulatedMixedComplex_3 Triangulated_mixed_complex; - typedef TriangulatedMixedComplexObserver_3 - Triangulated_mixed_complex_observer; private: typedef typename Regular::Vertex_handle Rt_Vertex_handle; typedef typename Regular::Edge Rt_Edge; typedef typename Regular::Facet Rt_Facet; typedef typename Regular::Cell_handle Rt_Cell_handle; - + typedef typename Regular::Finite_vertices_iterator Rt_Finite_vertices_iterator; typedef typename Regular::Finite_edges_iterator Rt_Finite_edges_iterator; typedef typename Regular::Finite_facets_iterator Rt_Finite_facets_iterator; typedef typename Regular::All_cells_iterator Rt_All_cells_iterator; typedef typename Regular::Finite_cells_iterator Rt_Finite_cells_iterator; - + typedef typename Regular::Cell_circulator Rt_Cell_circulator; typedef Triangulation_simplex_3 Rt_Simplex; @@ -95,8 +90,8 @@ private: Tmc_Finite_cells_iterator; typedef typename Triangulated_mixed_complex::Cell_circulator Tmc_Cell_circulator; - - typedef typename TriangulatedMixedComplex_3::Geom_traits Tmc_traits; + + typedef typename Triangulated_mixed_complex::Geom_traits Tmc_traits; typedef typename Tmc_traits::Point_3 Tmc_Point; typedef typename Tmc_traits::RT Tmc_RT; @@ -107,14 +102,14 @@ private: typedef std::pair Symb_anchor; // You might get type differences here: - // The map that maps a Rt_Simplex to an iterator of the map + // The map that maps a Rt_Simplex to an iterator of the map // (used as union_find_structure) // struct Anchor_map_iterator_tmp; // typedef std::map Anchor_map; // struct Anchor_map_iterator_tmp : Anchor_map::iterator { -// Anchor_map_iterator_tmp() +// Anchor_map_iterator_tmp() // : Anchor_map::iterator() {} -// Anchor_map_iterator_tmp(typename Anchor_map::iterator const &it) +// Anchor_map_iterator_tmp(typename Anchor_map::iterator const &it) // : Anchor_map::iterator(it) {} // }; // typedef typename Anchor_map::iterator Anchor_map_iterator; @@ -126,27 +121,26 @@ private: public: Mixed_complex_triangulator_3(Regular ®ular, - Rt_FT const &shrink, - Triangulated_mixed_complex - &triangulated_mixed_complex, - Triangulated_mixed_complex_observer &observer, - bool verbose) + Rt_FT const &shrink, + Triangulated_mixed_complex &triangulated_mixed_complex, + Triangulated_mixed_complex_observer &observer, + bool verbose) : regular(regular), shrink(shrink), _tmc(triangulated_mixed_complex), observer(observer), - triangulation_incr_builder(triangulated_mixed_complex), + triangulation_incr_builder(triangulated_mixed_complex), r2t_converter_object(), construct_anchor_point_3_obj(r2t_converter_object(shrink)), compute_anchor_obj(regular), - verbose(verbose) { - + verbose(verbose) + { build(); } private: - void build() { - + void build() + { triangulation_incr_builder.begin_triangulation(3); if (verbose) std::cout << "Construct vertices" << std::endl; @@ -155,43 +149,41 @@ private: // mixed cells corresponding to regular vertices if (verbose) std::cout << "Construct 0 cells" << std::endl; for (Rt_Finite_vertices_iterator vit = regular.finite_vertices_begin(); - vit != regular.finite_vertices_end(); vit ++) { + vit != regular.finite_vertices_end(); vit ++) { construct_0_cell(vit); } // mixed cells corresponding to regular edges if (verbose) std::cout << "Construct 1 cells" << std::endl; for (Rt_Finite_edges_iterator eit = regular.finite_edges_begin(); - eit != regular.finite_edges_end(); eit ++) { + eit != regular.finite_edges_end(); eit ++) { construct_1_cell(eit); } // mixed cells corresponding to regular facets if (verbose) std::cout << "Construct 2 cells" << std::endl; for (Rt_Finite_facets_iterator fit = regular.finite_facets_begin(); - fit != regular.finite_facets_end(); fit ++) { + fit != regular.finite_facets_end(); fit ++) { construct_2_cell(fit); } - + // mixed cells corresponding to regular cells if (verbose) std::cout << "Construct 3 cells" << std::endl; for (Rt_Finite_cells_iterator cit = regular.finite_cells_begin(); - cit != regular.finite_cells_end(); - cit++) { + cit != regular.finite_cells_end(); + cit++) { construct_3_cell(cit); } triangulation_incr_builder.end_triangulation(); - - anchors.clear(); + anchors.clear(); } - Tmc_Vertex_handle add_vertex(Symb_anchor const &anchor); + Tmc_Vertex_handle add_vertex(Symb_anchor const &anchor); Tmc_Cell_handle add_cell(Tmc_Vertex_handle vh[], int orient, Rt_Simplex s); - - Tmc_Vertex_handle get_vertex(Rt_Simplex &sDel, Rt_Simplex &sVor); + Tmc_Vertex_handle get_vertex(Rt_Simplex &sDel, Rt_Simplex &sVor); void construct_anchor_del(Rt_Simplex const &sDel); void construct_anchor_vor(Rt_Simplex const &sVor); @@ -205,12 +197,15 @@ private: typename Simplex_UF_map::iterator it = anchor_vor_map.find(sVor); CGAL_assertion(it != anchor_vor_map.end()); return *anchor_vor_uf.find(it->second); - } + } + // Anchor_map_iterator find_anchor(Anchor_map &a_map, Rt_Simplex const&s) { // return find_anchor(a_map, a_map.find(s)); // } + // Anchor_map_iterator find_anchor(Anchor_map &a_map, -// Anchor_map_iterator const&it) { +// Anchor_map_iterator const&it) +// { // CGAL_assertion(it != a_map.end()); // Anchor_map_iterator it2 = it->second; // while (it2 != it2->second) { @@ -221,34 +216,31 @@ private: // } // return it2; // } + void construct_vertices(); - + Tmc_Point get_weighted_circumcenter(Rt_Simplex const &s); Tmc_Point get_anchor(Rt_Simplex const &sDel, Rt_Simplex const &sVor); template - Point construct_anchor_point(const Point ¢er_del, + Point construct_anchor_point(const Point ¢er_del, const Point ¢er_vor) { return construct_anchor_point_3_obj(center_del,center_vor); } - + void construct_0_cell(Rt_Vertex_handle rt_vh); void construct_1_cell(const Rt_Finite_edges_iterator &eit); void construct_2_cell(const Rt_Finite_facets_iterator &fit); void construct_3_cell(Rt_Cell_handle rt_ch); - + void remove_small_edges(); - bool is_collapsible(Tmc_Vertex_handle vh, - Tmc_Vertex_handle &vh_collapse_to, - Tmc_RT sq_length); + bool is_collapsible(Tmc_Vertex_handle vh, + Tmc_Vertex_handle &vh_collapse_to, + Tmc_RT sq_length); void do_collapse(Tmc_Vertex_handle vh, Tmc_Vertex_handle vh_collapse_to); - Sign orientation(Tmc_Cell_handle ch); - - private: - Regular const ®ular; Rt_FT const &shrink; Triangulated_mixed_complex &_tmc; @@ -276,42 +268,38 @@ private: // index to vertex Unique_hash_map < Rt_Cell_handle, Index_c4 > index_03; - + Union_find_anchor anchor_del_uf, anchor_vor_uf; Simplex_UF_map anchor_del_map, anchor_vor_map; - + // Anchor_map anchor_del2, anchor_vor2; - std::map anchors; + std::map anchors; }; -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> -const int Mixed_complex_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: +template +const int Mixed_complex_triangulator_3:: edge_index[4][4] = {{-1,0,1,2},{0,-1,3,4},{1,3,-1,5},{2,4,5,-1}}; - -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template void -Mixed_complex_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: -construct_anchor_del(Rt_Simplex const &sDel) { +Mixed_complex_triangulator_3:: +construct_anchor_del(Rt_Simplex const &sDel) +{ Rt_Simplex s = compute_anchor_obj.anchor_del(sDel); - + typename Union_find_anchor::handle sDel_handle, s_handle; sDel_handle = anchor_del_uf.make_set(sDel); anchor_del_map[sDel] = sDel_handle; - - typename Simplex_UF_map::iterator s_it = anchor_del_map.find(s); + + typename Simplex_UF_map::iterator s_it = anchor_del_map.find(s); CGAL_assertion(s_it != anchor_del_map.end()); anchor_del_uf.unify_sets(sDel_handle, s_it->second); @@ -321,33 +309,32 @@ construct_anchor_del(Rt_Simplex const &sDel) { typename Compute_anchor::Simplex_iterator degenerate_it; typename Simplex_UF_map::iterator deg_map_it; for (degenerate_it = compute_anchor_obj.equivalent_anchors_begin(); - degenerate_it != compute_anchor_obj.equivalent_anchors_end(); + degenerate_it != compute_anchor_obj.equivalent_anchors_end(); degenerate_it++) { - deg_map_it = anchor_del_map.find(*degenerate_it); + deg_map_it = anchor_del_map.find(*degenerate_it); CGAL_assertion(deg_map_it != anchor_del_map.end()); - + anchor_del_uf.unify_sets(sDel_handle, deg_map_it->second); } } } -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template void -Mixed_complex_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: -construct_anchor_vor(Rt_Simplex const &sVor) { +Mixed_complex_triangulator_3:: +construct_anchor_vor(Rt_Simplex const &sVor) +{ Rt_Simplex s = compute_anchor_obj.anchor_vor(sVor); - + typename Union_find_anchor::handle sVor_handle, s_handle; sVor_handle = anchor_vor_uf.make_set(sVor); anchor_vor_map[sVor] = sVor_handle; - - typename Simplex_UF_map::iterator s_it = anchor_vor_map.find(s); + + typename Simplex_UF_map::iterator s_it = anchor_vor_map.find(s); CGAL_assertion(s_it != anchor_vor_map.end()); anchor_vor_uf.unify_sets(sVor_handle, s_it->second); @@ -357,10 +344,10 @@ construct_anchor_vor(Rt_Simplex const &sVor) { typename Compute_anchor::Simplex_iterator degenerate_it; typename Simplex_UF_map::iterator deg_map_it; for (degenerate_it = compute_anchor_obj.equivalent_anchors_begin(); - degenerate_it != compute_anchor_obj.equivalent_anchors_end(); + degenerate_it != compute_anchor_obj.equivalent_anchors_end(); degenerate_it++) { - deg_map_it = anchor_vor_map.find(*degenerate_it); - + deg_map_it = anchor_vor_map.find(*degenerate_it); + // Possibly not found for 2 Voronoi vertices with the same center, // If the first vertex is inserted and the second is already found. // see compute_anchor_obj.anchor_vor(Cell_handle) @@ -369,6 +356,7 @@ construct_anchor_vor(Rt_Simplex const &sVor) { } } } + // Rt_Simplex s = compute_anchor_obj.anchor_vor(sVor); // anchor_vor2[sVor] = Anchor_map_iterator(); // @@ -383,7 +371,7 @@ construct_anchor_vor(Rt_Simplex const &sVor) { // it = find_anchor(anchor_vor2, it); // typename Compute_anchor::Simplex_iterator degenerate_it; // for (degenerate_it = compute_anchor_obj.equivalent_anchors_begin(); -// degenerate_it != compute_anchor_obj.equivalent_anchors_end(); +// degenerate_it != compute_anchor_obj.equivalent_anchors_end(); // degenerate_it++) { // Anchor_map_iterator tmp; // it2 = anchor_vor2.find(*degenerate_it); @@ -405,27 +393,26 @@ construct_anchor_vor(Rt_Simplex const &sVor) { // } } -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template void -Mixed_complex_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: -construct_anchors() { +Mixed_complex_triangulator_3:: +construct_anchors() +{ Rt_Finite_vertices_iterator vit; Rt_Finite_edges_iterator eit; Rt_Finite_facets_iterator fit; Rt_Finite_cells_iterator cit; Rt_Simplex s; - + // Compute anchor points: for (vit=regular.finite_vertices_begin(); vit!=regular.finite_vertices_end(); vit++) { construct_anchor_del(Rt_Simplex(vit)); - } + } for (eit=regular.finite_edges_begin(); eit!=regular.finite_edges_end(); eit++) { s = Rt_Simplex(*eit); @@ -466,18 +453,16 @@ construct_anchors() { } } - // Constructs the vertices of the simplicial complex -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template void -Mixed_complex_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: -construct_vertices() { +Mixed_complex_triangulator_3:: +construct_vertices() +{ Rt_All_cells_iterator acit; Rt_Finite_cells_iterator cit; Rt_Finite_facets_iterator fit; @@ -501,9 +486,9 @@ construct_vertices() { for (int i=0; i<4; i++) { sDel = get_anchor_del(Rt_Simplex(cit->vertex(i))); if (anchors.find(Symb_anchor(sDel,sVor)) == anchors.end()) { - vh = add_vertex(Symb_anchor(sDel,sVor)); - anchors[Symb_anchor(sDel,sVor)] = vh; - CGAL_assertion(vh == get_vertex(sDel, sVor)); + vh = add_vertex(Symb_anchor(sDel,sVor)); + anchors[Symb_anchor(sDel,sVor)] = vh; + CGAL_assertion(vh == get_vertex(sDel, sVor)); } } } @@ -514,12 +499,12 @@ construct_vertices() { sVor = get_anchor_vor(Rt_Simplex(cit)); for (int i=0; i<3; i++) { for (int j=i+1; j<4; j++) { - sDel = get_anchor_del(Rt_Simplex(Rt_Edge(cit,i,j))); - if (anchors.find(Symb_anchor(sDel,sVor)) == anchors.end()) { - vh = add_vertex(Symb_anchor(sDel,sVor)); - anchors[Symb_anchor(sDel,sVor)] = vh; - CGAL_assertion(vh == get_vertex(sDel, sVor)); - } + sDel = get_anchor_del(Rt_Simplex(Rt_Edge(cit,i,j))); + if (anchors.find(Symb_anchor(sDel,sVor)) == anchors.end()) { + vh = add_vertex(Symb_anchor(sDel,sVor)); + anchors[Symb_anchor(sDel,sVor)] = vh; + CGAL_assertion(vh == get_vertex(sDel, sVor)); + } } } } @@ -535,17 +520,17 @@ construct_vertices() { if (!regular.is_infinite(c1)) { sVor = get_anchor_vor(c1); if (anchors.find(Symb_anchor(sDel,sVor)) == anchors.end()) { - vh = add_vertex(Symb_anchor(sDel,sVor)); - anchors[Symb_anchor(sDel,sVor)] = vh; - CGAL_assertion(vh == get_vertex(sDel, sVor)); + vh = add_vertex(Symb_anchor(sDel,sVor)); + anchors[Symb_anchor(sDel,sVor)] = vh; + CGAL_assertion(vh == get_vertex(sDel, sVor)); } } if (!regular.is_infinite(c2)) { sVor = get_anchor_vor(c2); if (anchors.find(Symb_anchor(sDel,sVor)) == anchors.end()) { - vh = add_vertex(Symb_anchor(sDel,sVor)); - anchors[Symb_anchor(sDel,sVor)] = vh; - CGAL_assertion(vh == get_vertex(sDel, sVor)); + vh = add_vertex(Symb_anchor(sDel,sVor)); + anchors[Symb_anchor(sDel,sVor)] = vh; + CGAL_assertion(vh == get_vertex(sDel, sVor)); } } // anchor dimDel=0, dimVor=2 @@ -553,15 +538,15 @@ construct_vertices() { for (int i=1; i<4; i++) { sDel = get_anchor_del(Rt_Simplex(c1->vertex((fit->second+i)&3))); if (anchors.find(Symb_anchor(sDel,sVor)) == anchors.end()) { - vh = add_vertex(Symb_anchor(sDel,sVor)); - anchors[Symb_anchor(sDel,sVor)] = vh; - CGAL_assertion(vh == get_vertex(sDel, sVor)); + vh = add_vertex(Symb_anchor(sDel,sVor)); + anchors[Symb_anchor(sDel,sVor)] = vh; + CGAL_assertion(vh == get_vertex(sDel, sVor)); } else { vh = get_vertex(sDel, sVor); } } } - + if (verbose) std::cout << "6 "; // anchor dimDel=0, dimVor=1 for (eit=regular.finite_edges_begin(); eit!=regular.finite_edges_end(); eit++) { @@ -575,7 +560,7 @@ construct_vertices() { anchors[Symb_anchor(sDel,sVor)] = vh; CGAL_assertion(vh == get_vertex(sDel, sVor)); } - + sDel = get_anchor_del(v2); if (anchors.find(Symb_anchor(sDel,sVor)) == anchors.end()) { vh = add_vertex(Symb_anchor(sDel,sVor)); @@ -583,7 +568,7 @@ construct_vertices() { CGAL_assertion(vh == get_vertex(sDel, sVor)); } } - + if (verbose) std::cout << "5 "; // anchor dimDel=3, dimVor=3 for (cit=regular.finite_cells_begin(); cit!=regular.finite_cells_end(); cit++) { @@ -596,7 +581,6 @@ construct_vertices() { } } - if (verbose) std::cout << "4 "; // anchor dimDel=0, dimVor=0 for (vit=regular.finite_vertices_begin(); vit!=regular.finite_vertices_end(); vit++) { @@ -608,7 +592,7 @@ construct_vertices() { CGAL_assertion(vh == get_vertex(sDel, sVor)); } } - + if (verbose) std::cout << "3 "; // anchor dimDel=1, dimVor=2 for (fit=regular.finite_facets_begin(); fit!=regular.finite_facets_end(); fit++) { @@ -622,15 +606,15 @@ construct_vertices() { e.second = (fit->second+i)&3; e.third = (fit->second+j)&3; sDel = get_anchor_del(Rt_Simplex(e)); - if (anchors.find(Symb_anchor(sDel,sVor)) == anchors.end()) { - vh = add_vertex(Symb_anchor(sDel,sVor)); - anchors[Symb_anchor(sDel,sVor)] = vh; - CGAL_assertion(vh == get_vertex(sDel, sVor)); - } + if (anchors.find(Symb_anchor(sDel,sVor)) == anchors.end()) { + vh = add_vertex(Symb_anchor(sDel,sVor)); + anchors[Symb_anchor(sDel,sVor)] = vh; + CGAL_assertion(vh == get_vertex(sDel, sVor)); + } } } } - + if (verbose) std::cout << "2 "; // anchor dimDel=2, dimVor=2 for (fit=regular.finite_facets_begin(); fit!=regular.finite_facets_end(); fit++) { @@ -645,7 +629,7 @@ construct_vertices() { CGAL_assertion(vh == get_vertex(sDel, sVor)); } } - + if (verbose) std::cout << "1" << std::endl; // anchor dimDel=1, dimVor=1 for (eit=regular.finite_edges_begin(); eit!=regular.finite_edges_end(); eit++) { @@ -665,10 +649,9 @@ construct_vertices() { // Constructs the cells of the mixed complex corresponding // to Regular vertices -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template void Mixed_complex_triangulator_3< RegularTriangulation_3, @@ -677,16 +660,16 @@ Mixed_complex_triangulator_3< construct_0_cell(Rt_Vertex_handle rt_vh) { Rt_Simplex sDel_v, sVor_v, sVor_e, sVor_f, sVor_c; Tmc_Vertex_handle vh[4]; - + Rt_Simplex simplex(rt_vh); sDel_v = get_anchor_del(Rt_Simplex(rt_vh)); sVor_v = get_anchor_vor(Rt_Simplex(rt_vh)); vh[0] = get_vertex(sDel_v,sVor_v); - + std::list adj_cells; typename std::list::iterator adj_cell; regular.incident_cells(rt_vh, std::back_inserter(adj_cells)); - + // Construct cells: for (adj_cell = adj_cells.begin(); adj_cell != adj_cells.end(); @@ -696,23 +679,23 @@ construct_0_cell(Rt_Vertex_handle rt_vh) { vh[3] = get_vertex(sDel_v,sVor_c); int index = (*adj_cell)->index(rt_vh); for (int i=1; i<4; i++) { - sVor_f = get_anchor_vor(Rt_Simplex(Rt_Facet(*adj_cell,(index+i)&3))); - vh[2] = get_vertex(sDel_v,sVor_f); - - for (int j=1; j<4; j++) { - if (j!=i) { - sVor_e = get_anchor_vor( - Rt_Simplex(Rt_Edge(*adj_cell,index,(index+j)&3))); - vh[1] = get_vertex(sDel_v,sVor_e); - if ((vh[0] != vh[1]) && (vh[1] != vh[2]) && (vh[2] != vh[3])) { - CGAL_assertion(sVor_v != sVor_e); - CGAL_assertion(sVor_e != sVor_f); - CGAL_assertion(sVor_f != sVor_c); - // Tmc_Cell_handle ch = - add_cell(vh,(index + (j==(i%3+1)? 1:0))&1,simplex); - } - } - } + sVor_f = get_anchor_vor(Rt_Simplex(Rt_Facet(*adj_cell,(index+i)&3))); + vh[2] = get_vertex(sDel_v,sVor_f); + + for (int j=1; j<4; j++) { + if (j!=i) { + sVor_e = get_anchor_vor( + Rt_Simplex(Rt_Edge(*adj_cell,index,(index+j)&3))); + vh[1] = get_vertex(sDel_v,sVor_e); + if ((vh[0] != vh[1]) && (vh[1] != vh[2]) && (vh[2] != vh[3])) { + CGAL_assertion(sVor_v != sVor_e); + CGAL_assertion(sVor_e != sVor_f); + CGAL_assertion(sVor_f != sVor_c); + // Tmc_Cell_handle ch = + add_cell(vh,(index + (j==(i%3+1)? 1:0))&1,simplex); + } + } + } } } } @@ -720,28 +703,28 @@ construct_0_cell(Rt_Vertex_handle rt_vh) { // Constructs 1-cells of the mixed complex corresponding to edges // of the regular triangulation -template < +template < class RegularTriangulation_3, class TriangulatedMixedComplex_3, class TriangulatedMixedComplexObserver_3> void -Mixed_complex_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: -construct_1_cell(const Rt_Finite_edges_iterator &e) { +Mixed_complex_triangulator_3:: +construct_1_cell(const Rt_Finite_edges_iterator &e) +{ Rt_Simplex sDel_v, sDel_e, sVor_e, sVor_f, sVor_c; Tmc_Vertex_handle vh[4]; Rt_Vertex_handle v[2]; Tmc_Cell_handle ch; - + Rt_Simplex mixed_cell_simplex(*e); sDel_e = get_anchor_del(Rt_Simplex(*e)); sVor_e = get_anchor_vor(Rt_Simplex(*e)); - + v[0] = e->first->vertex(e->second); v[1] = e->first->vertex(e->third); - + // Construct cells on the side of v[vi]: for (int vi=0; vi<2; vi++) { sDel_v = get_anchor_del(Rt_Simplex(v[vi])); @@ -749,116 +732,114 @@ construct_1_cell(const Rt_Finite_edges_iterator &e) { Rt_Cell_circulator ccir, cstart; ccir = cstart = regular.incident_cells(*e); do { - if (!regular.is_infinite(ccir)) { - int index0 = ccir->index(v[vi]); - int index1 = ccir->index(v[1-vi]); + if (!regular.is_infinite(ccir)) { + int index0 = ccir->index(v[vi]); + int index1 = ccir->index(v[1-vi]); - sVor_c = get_anchor_vor(Rt_Simplex(ccir)); + sVor_c = get_anchor_vor(Rt_Simplex(ccir)); - for (int fi=1; fi<4; fi++) { - if (((index0+fi)&3) != index1) { - sVor_f = - get_anchor_vor(Rt_Simplex(Rt_Facet(ccir,(index0+fi)&3))); - if ((sVor_c != sVor_f) && (sVor_f != sVor_e)) { - vh[0] = get_vertex(sDel_v, sVor_e); - vh[1] = get_vertex(sDel_e, sVor_e); - vh[2] = get_vertex(sDel_e, sVor_f); - vh[3] = get_vertex(sDel_e, sVor_c); - int orient; - if (((4+index1-index0)&3) == 1) { - orient = (index1 + (fi==2))&1; - } else { - orient = (index1 + (fi==1))&1; - } - // vh: dimension are (01,11,12,13) - ch = add_cell(vh,orient,mixed_cell_simplex); - - vh[1] = get_vertex(sDel_v, sVor_f); - // vh: dimension are (01,02,12,13) - ch = add_cell(vh,1-orient,mixed_cell_simplex); - - vh[2] = get_vertex(sDel_v, sVor_c); - // vh: dimension are (01,02,03,13) - ch = add_cell(vh,orient,mixed_cell_simplex); - } - } - } - } - ccir ++; + for (int fi=1; fi<4; fi++) { + if (((index0+fi)&3) != index1) { + sVor_f = + get_anchor_vor(Rt_Simplex(Rt_Facet(ccir,(index0+fi)&3))); + if ((sVor_c != sVor_f) && (sVor_f != sVor_e)) { + vh[0] = get_vertex(sDel_v, sVor_e); + vh[1] = get_vertex(sDel_e, sVor_e); + vh[2] = get_vertex(sDel_e, sVor_f); + vh[3] = get_vertex(sDel_e, sVor_c); + int orient; + if (((4+index1-index0)&3) == 1) { + orient = (index1 + (fi==2))&1; + } else { + orient = (index1 + (fi==1))&1; + } + // vh: dimension are (01,11,12,13) + ch = add_cell(vh,orient,mixed_cell_simplex); + + vh[1] = get_vertex(sDel_v, sVor_f); + // vh: dimension are (01,02,12,13) + ch = add_cell(vh,1-orient,mixed_cell_simplex); + + vh[2] = get_vertex(sDel_v, sVor_c); + // vh: dimension are (01,02,03,13) + ch = add_cell(vh,orient,mixed_cell_simplex); + } + } + } + } + ccir ++; } while (ccir != cstart); } } } - // Constructs 2-cells of the mixed complex corresponding to facets // of the regular triangulation -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template void -Mixed_complex_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: -construct_2_cell(const Rt_Finite_facets_iterator &fit) { +Mixed_complex_triangulator_3:: +construct_2_cell(const Rt_Finite_facets_iterator &fit) +{ Rt_Simplex sDel_v, sDel_e, sDel_f, sVor_f, sVor_c; Tmc_Vertex_handle vh[4]; // Implicit function over vLabels is increasing ... Rt_Cell_handle rt_ch; int index; - + rt_ch = fit->first; index = fit->second; Rt_Simplex simplex(*fit); sDel_f = get_anchor_del(Rt_Simplex(*fit)); sVor_f = get_anchor_vor(Rt_Simplex(*fit)); - + for (int i=0; i<2; i++) { // Do this twice if (!regular.is_infinite(rt_ch)) { sVor_c = get_anchor_vor(Rt_Simplex(rt_ch)); - + vh[3] = get_vertex(sDel_f, sVor_c); Tmc_Vertex_handle vh2 = get_vertex(sDel_f, sVor_f); if (vh2 != vh[3]) { - // Facet and cell do not coincide .. - for (int vi=1; vi<4; vi++) { - sDel_v = get_anchor_del(Rt_Simplex(rt_ch->vertex((index+vi)&3))); - //index_02[rt_ch].V[index][(index+vi)&3]; - vh[0] = get_vertex(sDel_v, sVor_f); - for (int ei=1; ei<4; ei++) { - if (vi != ei) { - vh[2] = vh2; - int index0 = (index+vi)&3; - int index1 = (index+ei)&3; - int fi = (6+index-vi-ei)&3;//6-index-index0-index1; - sDel_e = - get_anchor_del(Rt_Simplex(Rt_Edge(rt_ch, index0, index1))); - vh[1] = get_vertex(sDel_e, sVor_f); - //index_12[rt_ch].V[index][(6+index-vi-ei)&3]; - if ((vh[0] != vh[1]) && (vh[1] != vh[2])) { - // index0: v0 - // index1: v1 - // index0+fi&3 == facet - int orient; - - if (((4+index1-index0)&3) == 3) { - orient = (index1 + (((4+index0-fi)&3)==2))&1; - } else { - orient = (index1 + (((4+index0-fi)&3)==1))&1; - } + // Facet and cell do not coincide .. + for (int vi=1; vi<4; vi++) { + sDel_v = get_anchor_del(Rt_Simplex(rt_ch->vertex((index+vi)&3))); + //index_02[rt_ch].V[index][(index+vi)&3]; + vh[0] = get_vertex(sDel_v, sVor_f); + for (int ei=1; ei<4; ei++) { + if (vi != ei) { + vh[2] = vh2; + int index0 = (index+vi)&3; + int index1 = (index+ei)&3; + int fi = (6+index-vi-ei)&3;//6-index-index0-index1; + sDel_e = + get_anchor_del(Rt_Simplex(Rt_Edge(rt_ch, index0, index1))); + vh[1] = get_vertex(sDel_e, sVor_f); + //index_12[rt_ch].V[index][(6+index-vi-ei)&3]; + if ((vh[0] != vh[1]) && (vh[1] != vh[2])) { + // index0: v0 + // index1: v1 + // index0+fi&3 == facet + int orient; - add_cell(vh,orient,simplex); - - vh[2] = get_vertex(sDel_e, sVor_c); - add_cell(vh,1-orient,simplex); - - vh[1] = get_vertex(sDel_v, sVor_c); - add_cell(vh,orient,simplex); - } - } - } - } + if (((4+index1-index0)&3) == 3) { + orient = (index1 + (((4+index0-fi)&3)==2))&1; + } else { + orient = (index1 + (((4+index0-fi)&3)==1))&1; + } + + add_cell(vh,orient,simplex); + + vh[2] = get_vertex(sDel_e, sVor_c); + add_cell(vh,1-orient,simplex); + + vh[1] = get_vertex(sDel_v, sVor_c); + add_cell(vh,orient,simplex); + } + } + } + } } } // swap to the other cell @@ -871,19 +852,17 @@ construct_2_cell(const Rt_Finite_facets_iterator &fit) { CGAL_assertion(index == fit->second); } - // Constructs 3-cells of the mixed complex corresponding to cells // of the regular triangulation -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template void -Mixed_complex_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: -construct_3_cell(Rt_Cell_handle rt_ch) { +Mixed_complex_triangulator_3:: +construct_3_cell(Rt_Cell_handle rt_ch) +{ Rt_Simplex sDel_v, sDel_e, sDel_f, sDel_c, sVor_c; Tmc_Vertex_handle vh[4]; Tmc_Cell_handle ch; @@ -893,86 +872,82 @@ construct_3_cell(Rt_Cell_handle rt_ch) { sDel_c = get_anchor_del(Rt_Simplex(rt_ch)); sVor_c = get_anchor_vor(Rt_Simplex(rt_ch)); Rt_Simplex simplex = Rt_Simplex(rt_ch); - vh[0] = get_vertex(sDel_c, sVor_c); + vh[0] = get_vertex(sDel_c, sVor_c); for (int fi=0; fi<4; fi++) { sDel_f = get_anchor_del(Rt_Simplex(Rt_Facet(rt_ch, fi))); vh[1] = get_vertex(sDel_f, sVor_c); if (vh[0] != vh[1]) { for (int vi=1; vi<4; vi++) { - int index0 = (fi+vi)&3; - sDel_v = get_anchor_del(Rt_Simplex(rt_ch->vertex(index0))); - for (int ei=1; ei<4; ei++) { - int index1 = (fi+ei)&3; - if (vi != ei) { - sDel_e = get_anchor_del(Rt_Simplex(Rt_Edge(rt_ch, index0, index1))); - vh[2] = get_vertex(sDel_e, sVor_c); - // index_13[rt_ch].V[edge_index[index0][index1]]; - vh[3] = get_vertex(sDel_v, sVor_c); - // index_03[rt_cit].V[index0]; - if ((vh[1] != vh[2]) && (vh[2] != vh[3])) { - int orient; - - if (((4+index1-index0)&3) == 1) { - orient = (index1 + (vi==2))&1; - } else { - orient = (index1 + (vi==3))&1; - } - ch = add_cell(vh, orient, simplex); - } - } - } + int index0 = (fi+vi)&3; + sDel_v = get_anchor_del(Rt_Simplex(rt_ch->vertex(index0))); + for (int ei=1; ei<4; ei++) { + int index1 = (fi+ei)&3; + if (vi != ei) { + sDel_e = get_anchor_del(Rt_Simplex(Rt_Edge(rt_ch, index0, index1))); + vh[2] = get_vertex(sDel_e, sVor_c); + // index_13[rt_ch].V[edge_index[index0][index1]]; + vh[3] = get_vertex(sDel_v, sVor_c); + // index_03[rt_cit].V[index0]; + if ((vh[1] != vh[2]) && (vh[2] != vh[3])) { + int orient; + + if (((4+index1-index0)&3) == 1) { + orient = (index1 + (vi==2))&1; + } else { + orient = (index1 + (vi==3))&1; + } + ch = add_cell(vh, orient, simplex); + } + } + } } } } } // Adds a vertex to the simplicial complex -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template typename Mixed_complex_triangulator_3< RegularTriangulation_3, TriangulatedMixedComplex_3, TriangulatedMixedComplexObserver_3>::Tmc_Vertex_handle -Mixed_complex_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: +Mixed_complex_triangulator_3:: add_vertex (Symb_anchor const &anchor) { Tmc_Vertex_handle vh; vh = triangulation_incr_builder.add_vertex(); - observer.after_vertex_insertion(anchor.first, anchor.second, vh); - + observer.after_vertex_insertion(anchor.first, anchor.second, vh); + Protect_FPU_rounding P; vh->point() = get_anchor(anchor.first, anchor.second); -// std::cout << "@ [" -// << vh->info().first << " - " -// << vh->info().second << "] -- [" +// std::cout << "@ [" +// << vh->info().first << " - " +// << vh->info().second << "] -- [" // << vh->point() << "] -- [" // << get_weighted_circumcenter(vh->info().first) << " - " -// << get_weighted_circumcenter(vh->info().second) +// << get_weighted_circumcenter(vh->info().second) // << "]" << std::endl; return vh; } // Gets a vertex from the simplicial complex based on the anchors -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template typename Mixed_complex_triangulator_3< RegularTriangulation_3, TriangulatedMixedComplex_3, TriangulatedMixedComplexObserver_3>::Tmc_Vertex_handle -Mixed_complex_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>::get_vertex ( - Rt_Simplex &sDel, Rt_Simplex &sVor) +Mixed_complex_triangulator_3:: +get_vertex(Rt_Simplex &sDel, Rt_Simplex &sVor) { Rt_Simplex sDel2 = get_anchor_del(sDel); Rt_Simplex sVor2 = get_anchor_vor(sVor); @@ -984,29 +959,28 @@ Mixed_complex_triangulator_3< } // Adds a cell to the simplicial complex -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template typename Mixed_complex_triangulator_3< RegularTriangulation_3, TriangulatedMixedComplex_3, TriangulatedMixedComplexObserver_3>::Tmc_Cell_handle -Mixed_complex_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: -add_cell(Tmc_Vertex_handle vh[], int orient, Rt_Simplex s) { +Mixed_complex_triangulator_3:: +add_cell(Tmc_Vertex_handle vh[], int orient, Rt_Simplex s) +{ CGAL_assertion((orient==0) || (orient==1)); - CGAL_assertion(vh[0] != Tmc_Vertex_handle()); + CGAL_assertion(vh[0] != Tmc_Vertex_handle()); CGAL_assertion(vh[1] != Tmc_Vertex_handle()); - CGAL_assertion(vh[2] != Tmc_Vertex_handle()); + CGAL_assertion(vh[2] != Tmc_Vertex_handle()); CGAL_assertion(vh[3] != Tmc_Vertex_handle()); - CGAL_assertion(vh[0] != vh[1]); - CGAL_assertion(vh[0] != vh[2]); - CGAL_assertion(vh[0] != vh[3]); - CGAL_assertion(vh[1] != vh[2]); - CGAL_assertion(vh[1] != vh[3]); + CGAL_assertion(vh[0] != vh[1]); + CGAL_assertion(vh[0] != vh[2]); + CGAL_assertion(vh[0] != vh[3]); + CGAL_assertion(vh[1] != vh[2]); + CGAL_assertion(vh[1] != vh[3]); CGAL_assertion(vh[2] != vh[3]); Tmc_Cell_handle ch; @@ -1021,24 +995,23 @@ add_cell(Tmc_Vertex_handle vh[], int orient, Rt_Simplex s) { return ch; } -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template typename Mixed_complex_triangulator_3< RegularTriangulation_3, TriangulatedMixedComplex_3, TriangulatedMixedComplexObserver_3>::Tmc_Point -Mixed_complex_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: -get_weighted_circumcenter(Rt_Simplex const &s) { +Mixed_complex_triangulator_3:: +get_weighted_circumcenter(Rt_Simplex const &s) +{ Rt_Vertex_handle vh; Rt_Edge e; Rt_Facet f; Rt_Cell_handle ch; - + Tmc_Point result; switch (s.dimension()) { case 0: @@ -1048,15 +1021,15 @@ get_weighted_circumcenter(Rt_Simplex const &s) { case 1: e=s; result = weighted_circumcenter_obj( - r2t_converter_object(e.first->vertex(e.second)->point()), - r2t_converter_object(e.first->vertex(e.third)->point())); + r2t_converter_object(e.first->vertex(e.second)->point()), + r2t_converter_object(e.first->vertex(e.third)->point())); break; case 2: f=s; result = weighted_circumcenter_obj( - r2t_converter_object(f.first->vertex((f.second+1)&3)->point()), - r2t_converter_object(f.first->vertex((f.second+2)&3)->point()), - r2t_converter_object(f.first->vertex((f.second+3)&3)->point())); + r2t_converter_object(f.first->vertex((f.second+1)&3)->point()), + r2t_converter_object(f.first->vertex((f.second+2)&3)->point()), + r2t_converter_object(f.first->vertex((f.second+3)&3)->point())); break; case 3: ch=s; @@ -1072,37 +1045,33 @@ get_weighted_circumcenter(Rt_Simplex const &s) { return result; } -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template typename Mixed_complex_triangulator_3< RegularTriangulation_3, TriangulatedMixedComplex_3, TriangulatedMixedComplexObserver_3>::Tmc_Point -Mixed_complex_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: +Mixed_complex_triangulator_3:: get_anchor(Rt_Simplex const &sDel, Rt_Simplex const &sVor) { Protect_FPU_rounding P; Tmc_Point dfoc = get_weighted_circumcenter(sDel); Tmc_Point vfoc = get_weighted_circumcenter(sVor); - + return construct_anchor_point(dfoc, vfoc); } -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template void -Mixed_complex_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: +Mixed_complex_triangulator_3:: remove_small_edges() { Bbox_3 bbox; @@ -1110,9 +1079,10 @@ remove_small_edges() vit != _tmc.finite_vertices_end(); vit++) { bbox = bbox+vit->point().bbox(); } - // Tmc_RT sq_length = ((bbox.xmax()-bbox.xmin())*(bbox.xmax()-bbox.xmin()) + - // (bbox.ymax()-bbox.ymin())*(bbox.ymax()-bbox.ymin()) + - // (bbox.zmax()-bbox.zmin())*(bbox.zmax()-bbox.zmin()))/100000000; + +// Tmc_RT sq_length = ((bbox.xmax()-bbox.xmin())*(bbox.xmax()-bbox.xmin()) + +// (bbox.ymax()-bbox.ymin())*(bbox.ymax()-bbox.ymin()) + +// (bbox.zmax()-bbox.zmin())*(bbox.zmax()-bbox.zmin()))/100000000; Tmc_RT sq_length = 1e-6; // NGHK: This may intrudoce rounding errors, since the quadratic surface @@ -1128,18 +1098,16 @@ remove_small_edges() } } -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template bool -Mixed_complex_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: +Mixed_complex_triangulator_3:: is_collapsible(Tmc_Vertex_handle vh, - Tmc_Vertex_handle &vh_collapse_to, - Tmc_RT sq_length) + Tmc_Vertex_handle &vh_collapse_to, + Tmc_RT sq_length) { std::vector incident_cells; CGAL_assertion(_tmc.is_vertex(vh)); @@ -1147,65 +1115,62 @@ is_collapsible(Tmc_Vertex_handle vh, _tmc.incident_cells(vh, std::back_inserter(incident_cells)); std::set incident_vertices; - for(typename std::vector::iterator - cit = incident_cells.begin(); + for(typename std::vector::iterator + cit = incident_cells.begin(); cit != incident_cells.end(); ++cit) { // Put all incident vertices in incident_vertices. for (int j=0; j<4; ++j) if ((*cit)->vertex(j) != vh) - incident_vertices.insert((*cit)->vertex(j)); + incident_vertices.insert((*cit)->vertex(j)); } - - for (typename std::set::iterator - it = incident_vertices.begin(); + + for (typename std::set::iterator + it = incident_vertices.begin(); it != incident_vertices.end(); it++) { if ((_tmc.geom_traits().compute_squared_distance_3_object()(vh->point(), - (*it)->point()) - < sq_length) && - (vh->cell()->surf == (*it)->cell()->surf) && - (vh->sign() == (*it)->sign())) { + (*it)->point()) + < sq_length) && + (vh->cell()->surf == (*it)->cell()->surf) && + (vh->sign() == (*it)->sign())) { bool ok = true; - for (typename std::vector::iterator - cit = incident_cells.begin(); - ok && (cit != incident_cells.end()); cit++) { - if (!(*cit)->has_vertex(*it)) { - const Tmc_Point* pts[4] = { &((*cit)->vertex(0)->point()), - &((*cit)->vertex(1)->point()), - &((*cit)->vertex(2)->point()), - &((*cit)->vertex(3)->point()) }; - pts[(*cit)->index(vh)] = &(*it)->point(); - - ok = (_tmc.geom_traits().orientation_3_object() - (*pts[0],*pts[1],*pts[2],*pts[3]) == CGAL::POSITIVE); - } + for (typename std::vector::iterator + cit = incident_cells.begin(); + ok && (cit != incident_cells.end()); cit++) { + if (!(*cit)->has_vertex(*it)) { + const Tmc_Point* pts[4] = { &((*cit)->vertex(0)->point()), + &((*cit)->vertex(1)->point()), + &((*cit)->vertex(2)->point()), + &((*cit)->vertex(3)->point()) }; + pts[(*cit)->index(vh)] = &(*it)->point(); + + ok = (_tmc.geom_traits().orientation_3_object() + (*pts[0],*pts[1],*pts[2],*pts[3]) == CGAL::POSITIVE); + } } if (ok) { - vh_collapse_to = *it; - return true; - } + vh_collapse_to = *it; + return true; + } } } return false; } -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template void -Mixed_complex_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: -do_collapse(Tmc_Vertex_handle vh, - Tmc_Vertex_handle vh_collapse_to) +Mixed_complex_triangulator_3:: +do_collapse(Tmc_Vertex_handle vh, Tmc_Vertex_handle vh_collapse_to) { std::vector incident_cells; incident_cells.reserve(32); _tmc.incident_cells(vh, std::back_inserter(incident_cells)); int i,i2; for (typename std::vector::iterator - it = incident_cells.begin(); it != incident_cells.end(); it++) { + it = incident_cells.begin(); it != incident_cells.end(); it++) { i = (*it)->index(vh); if ((*it)->has_vertex(vh_collapse_to,i2)) { // This cell is collapsed, set neighbor information of the new facet @@ -1215,14 +1180,14 @@ do_collapse(Tmc_Vertex_handle vh, ch1->set_neighbor(ch1->index((*it)), ch2); ch2->set_neighbor(ch2->index((*it)), ch1); for (int i=0; i<4; i++) { - // Try to point to a cell with the same surface: - if ((*it)->vertex(i)->cell() == (*it)) { - if ((*it)->surf == ch1->surf) { - (*it)->vertex(i)->set_cell(ch1); - } else { - (*it)->vertex(i)->set_cell(ch2); - } - } + // Try to point to a cell with the same surface: + if ((*it)->vertex(i)->cell() == (*it)) { + if ((*it)->surf == ch1->surf) { + (*it)->vertex(i)->set_cell(ch1); + } else { + (*it)->vertex(i)->set_cell(ch2); + } + } } _tmc.tds().delete_cell((*it)); } else { @@ -1233,27 +1198,25 @@ do_collapse(Tmc_Vertex_handle vh, _tmc.tds().delete_vertex(vh); } -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> -Sign -Mixed_complex_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: -orientation(Tmc_Cell_handle ch) { - Orientation o; - // Protection is outside the try block as VC8 has the CGAL_CFG_FPU_ROUNDING_MODE_UNWINDING_VC_BUG - Protect_FPU_rounding P; - try { - Tmc_Point pts[4]; - for (int i=0; i<4; i++) pts[i] = ch->vertex(i)->point(); +template +Sign +Mixed_complex_triangulator_3:: +orientation(Tmc_Cell_handle ch) +{ + Orientation o; + // Protection is outside the try block as VC8 has the CGAL_CFG_FPU_ROUNDING_MODE_UNWINDING_VC_BUG + Protect_FPU_rounding P; + try { + Tmc_Point pts[4]; + for (int i=0; i<4; i++) + pts[i] = ch->vertex(i)->point(); - - // filtered kernel - o = _tmc.geom_traits().orientation_3_object()(pts[0], pts[1], - pts[2], pts[3]); + // filtered kernel + o = _tmc.geom_traits().orientation_3_object()(pts[0], pts[1], pts[2], pts[3]); } catch (Uncertain_conversion_exception) { Protect_FPU_rounding P(CGAL_FE_TONEAREST); typedef Exact_predicates_exact_constructions_kernel EK; @@ -1266,52 +1229,48 @@ orientation(Tmc_Cell_handle ch) { typename Exact_skin_surface::Bare_point e_pts[4]; for (int k=0; k<4; k++) { - e_pts[k] = + e_pts[k] = Triangulated_mixed_complex_observer::Skin_surface:: get_anchor_point(ch->vertex(k)->info(), exact_traits); // Store the more precise point ch->vertex(k)->point() = converter(e_pts[k]); } - o = exact_traits.orientation_3_object()(e_pts[0], e_pts[1], + o = exact_traits.orientation_3_object()(e_pts[0], e_pts[1], e_pts[2], e_pts[3]); } return o; } -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> -void +template +void triangulate_mixed_complex_3(RegularTriangulation_3 &rt, - typename RegularTriangulation_3::Geom_traits::FT - const & shrink_factor, - TriangulatedMixedComplex_3 &tmc, - TriangulatedMixedComplexObserver_3 &observer, - bool verbose) + const typename RegularTriangulation_3::Geom_traits::FT &shrink_factor, + TriangulatedMixedComplex_3 &tmc, + TriangulatedMixedComplexObserver_3 &observer, + bool verbose) { typedef Mixed_complex_triangulator_3< RegularTriangulation_3, TriangulatedMixedComplex_3, TriangulatedMixedComplexObserver_3> Mixed_complex_triangulator; + Mixed_complex_triangulator(rt, shrink_factor, tmc, observer, verbose); } - -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3> -void -triangulate_mixed_complex_3(RegularTriangulation_3 const ®ular, - typename RegularTriangulation_3::Geom_traits::FT - const &shrink_factor, - TriangulatedMixedComplex_3 &tmc, - bool verbose) +template +void +triangulate_mixed_complex_3(RegularTriangulation_3 const ®ular, + typename RegularTriangulation_3::Geom_traits::FT + const &shrink_factor, + TriangulatedMixedComplex_3 &tmc, + bool verbose) { Triangulated_mixed_complex_observer_3< - TriangulatedMixedComplex_3, const RegularTriangulation_3> - observer(shrink_factor); + TriangulatedMixedComplex_3, const RegularTriangulation_3> observer(shrink_factor); triangulate_mixed_complex_3(regular, shrink_factor, tmc, observer, verbose); } diff --git a/Skin_surface_3/include/CGAL/triangulate_power_diagram_3.h b/Skin_surface_3/include/CGAL/triangulate_power_diagram_3.h index 9d3ee5c17d8..6b17b14dd85 100644 --- a/Skin_surface_3/include/CGAL/triangulate_power_diagram_3.h +++ b/Skin_surface_3/include/CGAL/triangulate_power_diagram_3.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -36,36 +36,35 @@ namespace CGAL { - -template < +template < class RegularTriangulation_3, class TriangulatedMixedComplex_3, class TriangulatedMixedComplexObserver_3 = - Triangulated_mixed_complex_observer_3 > -class Power_diagram_triangulator_3 { + Triangulated_mixed_complex_observer_3 > +class Power_diagram_triangulator_3 +{ public: - typedef typename RegularTriangulation_3::Geom_traits - Regular_traits; - typedef typename TriangulatedMixedComplex_3::Geom_traits - Triangulated_mixed_complex_traits; + typedef typename RegularTriangulation_3::Geom_traits Regular_traits; + typedef typename TriangulatedMixedComplex_3::Geom_traits Triangulated_mixed_complex_traits; - typedef RegularTriangulation_3 Regular; - typedef TriangulatedMixedComplex_3 Triangulated_mixed_complex; + typedef RegularTriangulation_3 Regular; + typedef TriangulatedMixedComplex_3 Triangulated_mixed_complex; typedef TriangulatedMixedComplexObserver_3 Triangulated_mixed_complex_observer; + private: typedef typename Regular::Vertex_handle Rt_Vertex_handle; typedef typename Regular::Edge Rt_Edge; typedef typename Regular::Facet Rt_Facet; typedef typename Regular::Cell_handle Rt_Cell_handle; - + typedef typename Regular::Finite_vertices_iterator Rt_Finite_vertices_iterator; typedef typename Regular::Finite_edges_iterator Rt_Finite_edges_iterator; typedef typename Regular::Finite_facets_iterator Rt_Finite_facets_iterator; typedef typename Regular::All_cells_iterator Rt_All_cells_iterator; typedef typename Regular::Finite_cells_iterator Rt_Finite_cells_iterator; - + typedef typename Regular::Cell_circulator Rt_Cell_circulator; typedef Triangulation_simplex_3 Rt_Simplex; @@ -90,13 +89,13 @@ private: Tmc_Finite_cells_iterator; typedef typename Triangulated_mixed_complex::Cell_circulator Tmc_Cell_circulator; - + typedef typename TriangulatedMixedComplex_3::Geom_traits Tmc_traits; typedef typename Tmc_traits::Point_3 Tmc_Point; typedef typename Tmc_traits::RT Tmc_RT; typedef Triangulation_incremental_builder_3 - Triangulation_incremental_builder; + Triangulation_incremental_builder; typedef Compute_anchor_3 Compute_anchor; typedef std::pair Symb_anchor; @@ -105,48 +104,47 @@ private: // struct Anchor_map_iterator_tmp; // typedef std::map Anchor_map; // struct Anchor_map_iterator_tmp : Anchor_map::iterator { -// Anchor_map_iterator_tmp() +// Anchor_map_iterator_tmp() // : Anchor_map::iterator() {} -// Anchor_map_iterator_tmp(typename Anchor_map::iterator const &it) +// Anchor_map_iterator_tmp(typename Anchor_map::iterator const &it) // : Anchor_map::iterator(it) {} // }; // typedef typename Anchor_map::iterator Anchor_map_iterator; typedef Union_find Union_find_anchor; typedef std::map Simplex_UF_map; - + typename Union_find_anchor::handle> Simplex_UF_map; + public: - - - Power_diagram_triangulator_3( - Regular ®ular, - Triangulated_mixed_complex &triangulated_mixed_complex, - Triangulated_mixed_complex_observer &observer, - bool verbose) + Power_diagram_triangulator_3(Regular ®ular, + Triangulated_mixed_complex &triangulated_mixed_complex, + Triangulated_mixed_complex_observer &observer, + bool verbose) : regular(regular), _tmc(triangulated_mixed_complex), observer(observer), - triangulation_incr_builder(triangulated_mixed_complex), + triangulation_incr_builder(triangulated_mixed_complex), compute_anchor_obj(regular), - verbose(verbose) { - + verbose(verbose) + { build(); } private: - void build() { - + void build() + { triangulation_incr_builder.begin_triangulation(3); - if (verbose) std::cout << "Construct vertices" << std::endl; + if (verbose) + std::cout << "Construct vertices" << std::endl; construct_vertices(); - if (verbose) std::cout << "Construct cells" << std::endl; + if (verbose) + std::cout << "Construct cells" << std::endl; construct_cells(); // mixed cells corresponding to regular vertices triangulation_incr_builder.end_triangulation(); - + anchors.clear(); CGAL_assertion(_tmc.is_valid()); @@ -156,61 +154,64 @@ private: // { // NGHK: debug code: // CGAL_assertion(_tmc.is_valid()); // std::vector ch_vertices; -// _tmc.incident_vertices(_tmc.infinite_vertex(), -// std::back_inserter(ch_vertices)); +// _tmc.incident_vertices(_tmc.infinite_vertex(), +// std::back_inserter(ch_vertices)); // for (typename std::vector::iterator -// vit = ch_vertices.begin(); vit != ch_vertices.end(); vit++) { -// CGAL_assertion((*vit)->sign() == POSITIVE); +// vit = ch_vertices.begin(); vit != ch_vertices.end(); vit++) { +// CGAL_assertion((*vit)->sign() == POSITIVE); // } // } } - Tmc_Vertex_handle add_vertex(Rt_Simplex const &anchor); + Tmc_Vertex_handle add_vertex(Rt_Simplex const &anchor); + Tmc_Cell_handle add_cell(Tmc_Vertex_handle vh[], int orient, Rt_Simplex s); - + Tmc_Vertex_handle get_vertex(Rt_Simplex &sVor); - void construct_anchor_vor(Rt_Simplex const &sVor); + void construct_anchors(); - Rt_Simplex get_anchor_vor(Rt_Simplex const &sVor) { + + Rt_Simplex get_anchor_vor(Rt_Simplex const &sVor) + { typename Simplex_UF_map::iterator it = anchor_vor_map.find(sVor); CGAL_assertion(it != anchor_vor_map.end()); return *anchor_vor_uf.find(it->second); - } + } + void construct_vertices(); - + Tmc_Point get_orthocenter(Rt_Simplex const &s); + Tmc_Point get_anchor(Rt_Simplex const &sVor); + template Point construct_anchor_point(const Point ¢er_vor) { return center_vor; } - + void construct_cells(); - + void remove_small_edges(); - bool is_collapsible(Tmc_Vertex_handle vh, - Tmc_Vertex_handle &vh_collapse_to, - Tmc_RT sq_length); + + bool is_collapsible(Tmc_Vertex_handle vh, + Tmc_Vertex_handle &vh_collapse_to, + Tmc_RT sq_length); void do_collapse(Tmc_Vertex_handle vh, Tmc_Vertex_handle vh_collapse_to); - private: Regular const ®ular; Triangulated_mixed_complex &_tmc; Triangulated_mixed_complex_observer &observer; - Triangulation_incremental_builder triangulation_incr_builder; - typename Tmc_traits::Construct_weighted_circumcenter_3 orthocenter_obj; - typename Tmc_traits::Compute_squared_radius_smallest_orthogonal_sphere_3 orthoweight_obj; Compute_anchor_3 compute_anchor_obj; bool verbose; - Cartesian_converter r2t_converter_object; + Cartesian_converter r2t_converter_object; static const int edge_index[4][4]; struct Index_c4 { Tmc_Vertex_handle V[4]; }; @@ -222,42 +223,37 @@ private: // index to vertex Unique_hash_map < Rt_Cell_handle, Index_c4 > index_03; - Union_find_anchor anchor_vor_uf; Simplex_UF_map anchor_vor_map; -// Anchor_map anchor_vor2; - std::map anchors; +// Anchor_map anchor_vor2; + std::map anchors; }; -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> -const int Power_diagram_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: +template +const int Power_diagram_triangulator_3:: edge_index[4][4] = {{-1,0,1,2},{0,-1,3,4},{1,3,-1,5},{2,4,5,-1}}; - -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template void -Power_diagram_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: -construct_anchor_vor(Rt_Simplex const &sVor) { +Power_diagram_triangulator_3:: +construct_anchor_vor(Rt_Simplex const &sVor) +{ Rt_Simplex s = compute_anchor_obj.anchor_vor(sVor); - + typename Union_find_anchor::handle sVor_handle, s_handle; sVor_handle = anchor_vor_uf.make_set(sVor); anchor_vor_map[sVor] = sVor_handle; - - typename Simplex_UF_map::iterator s_it = anchor_vor_map.find(s); + + typename Simplex_UF_map::iterator s_it = anchor_vor_map.find(s); CGAL_assertion(s_it != anchor_vor_map.end()); anchor_vor_uf.unify_sets(sVor_handle, s_it->second); @@ -267,10 +263,10 @@ construct_anchor_vor(Rt_Simplex const &sVor) { typename Compute_anchor::Simplex_iterator degenerate_it; typename Simplex_UF_map::iterator deg_map_it; for (degenerate_it = compute_anchor_obj.equivalent_anchors_begin(); - degenerate_it != compute_anchor_obj.equivalent_anchors_end(); + degenerate_it != compute_anchor_obj.equivalent_anchors_end(); degenerate_it++) { - deg_map_it = anchor_vor_map.find(*degenerate_it); - + deg_map_it = anchor_vor_map.find(*degenerate_it); + // Possibly not found for 2 Voronoi vertices with the same center, // If the first vertex is inserted and the second is already found. // see compute_anchor_obj.anchor_vor(Cell_handle) @@ -281,22 +277,21 @@ construct_anchor_vor(Rt_Simplex const &sVor) { } } -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template void -Power_diagram_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: -construct_anchors() { +Power_diagram_triangulator_3:: +construct_anchors() +{ Rt_Finite_vertices_iterator vit; Rt_Finite_edges_iterator eit; Rt_Finite_facets_iterator fit; Rt_Finite_cells_iterator cit; Rt_Simplex s; - + // Compute anchor points: for (cit=regular.finite_cells_begin(); cit!=regular.finite_cells_end(); cit++) { @@ -325,18 +320,16 @@ construct_anchors() { } } - // Constructs the vertices of the simplicial complex -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template void -Power_diagram_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: -construct_vertices() { +Power_diagram_triangulator_3:: +construct_vertices() +{ Rt_All_cells_iterator acit; Rt_Finite_cells_iterator cit; Rt_Finite_facets_iterator fit; @@ -375,7 +368,7 @@ construct_vertices() { CGAL_assertion(vh == get_vertex(sVor)); } } - + if (verbose) std::cout << "2 "; // anchor dimDel=0, dimVor=1 for (eit=regular.finite_edges_begin(); eit!=regular.finite_edges_end(); eit++) { @@ -386,7 +379,7 @@ construct_vertices() { CGAL_assertion(vh == get_vertex(sVor)); } } - + if (verbose) std::cout << "1 "; // anchor dimDel=0, dimVor=0 for (vit=regular.finite_vertices_begin(); vit!=regular.finite_vertices_end(); vit++) { @@ -401,99 +394,95 @@ construct_vertices() { // Constructs the cells of the mixed complex corresponding // to Regular vertices -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template void -Power_diagram_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: -construct_cells() { +Power_diagram_triangulator_3:: +construct_cells() +{ Rt_Simplex sVor_v, sVor_e, sVor_f, sVor_c; Tmc_Vertex_handle vh[4]; - + for (Rt_Finite_vertices_iterator vit=regular.finite_vertices_begin(); vit!=regular.finite_vertices_end(); vit++) { - + Rt_Simplex simplex(vit); sVor_v = get_anchor_vor(Rt_Simplex(vit)); vh[0] = get_vertex(sVor_v); - + std::list adj_cells; typename std::list::iterator adj_cell; regular.incident_cells(vit, std::back_inserter(adj_cells)); - + // Construct cells: for (adj_cell = adj_cells.begin(); - adj_cell != adj_cells.end(); - adj_cell ++) { + adj_cell != adj_cells.end(); + adj_cell ++) { if (!regular.is_infinite(*adj_cell)) { - sVor_c = get_anchor_vor(Rt_Simplex(*adj_cell)); - vh[3] = get_vertex(sVor_c); - int index = (*adj_cell)->index(vit); - for (int i=1; i<4; i++) { - sVor_f = get_anchor_vor( - Rt_Simplex(Rt_Facet(*adj_cell,(index+i)&3))); - vh[2] = get_vertex(sVor_f); - - for (int j=1; j<4; j++) { - if (j!=i) { - sVor_e = get_anchor_vor( - Rt_Simplex(Rt_Edge(*adj_cell,index,(index+j)&3))); - vh[1] = get_vertex(sVor_e); - if ((vh[0] != vh[1]) && (vh[1] != vh[2]) && (vh[2] != vh[3])) { - CGAL_assertion(sVor_v != sVor_e); - CGAL_assertion(sVor_e != sVor_f); - CGAL_assertion(sVor_f != sVor_c); - // Tmc_Cell_handle ch = - add_cell(vh,(index + (j==(i%3+1)? 1:0))&1,simplex); - } - } - } - } + sVor_c = get_anchor_vor(Rt_Simplex(*adj_cell)); + vh[3] = get_vertex(sVor_c); + int index = (*adj_cell)->index(vit); + for (int i=1; i<4; i++) { + sVor_f = get_anchor_vor( + Rt_Simplex(Rt_Facet(*adj_cell,(index+i)&3))); + vh[2] = get_vertex(sVor_f); + + for (int j=1; j<4; j++) { + if (j!=i) { + sVor_e = get_anchor_vor( + Rt_Simplex(Rt_Edge(*adj_cell,index,(index+j)&3))); + vh[1] = get_vertex(sVor_e); + if ((vh[0] != vh[1]) && (vh[1] != vh[2]) && (vh[2] != vh[3])) { + CGAL_assertion(sVor_v != sVor_e); + CGAL_assertion(sVor_e != sVor_f); + CGAL_assertion(sVor_f != sVor_c); + // Tmc_Cell_handle ch = + add_cell(vh,(index + (j==(i%3+1)? 1:0))&1,simplex); + } + } + } + } } } } } // Adds a vertex to the simplicial complex -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template typename Power_diagram_triangulator_3< RegularTriangulation_3, TriangulatedMixedComplex_3, TriangulatedMixedComplexObserver_3>::Tmc_Vertex_handle -Power_diagram_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: -add_vertex (Rt_Simplex const &anchor) +Power_diagram_triangulator_3:: +add_vertex(Rt_Simplex const &anchor) { Tmc_Vertex_handle vh; vh = triangulation_incr_builder.add_vertex(); vh->point() = get_anchor(anchor); - observer.after_vertex_insertion(anchor, anchor, vh); + observer.after_vertex_insertion(anchor, anchor, vh); return vh; } // Gets a vertex from the simplicial complex based on the anchors -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template typename Power_diagram_triangulator_3< RegularTriangulation_3, TriangulatedMixedComplex_3, TriangulatedMixedComplexObserver_3>::Tmc_Vertex_handle -Power_diagram_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>::get_vertex (Rt_Simplex &sVor) +Power_diagram_triangulator_3:: +get_vertex (Rt_Simplex &sVor) { Rt_Simplex sVor2 = get_anchor_vor(sVor); CGAL_assertion(sVor == sVor2); @@ -503,19 +492,18 @@ Power_diagram_triangulator_3< } // Adds a cell to the simplicial complex -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template typename Power_diagram_triangulator_3< RegularTriangulation_3, TriangulatedMixedComplex_3, TriangulatedMixedComplexObserver_3>::Tmc_Cell_handle -Power_diagram_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: -add_cell(Tmc_Vertex_handle vh[], int orient, Rt_Simplex s) { +Power_diagram_triangulator_3:: +add_cell(Tmc_Vertex_handle vh[], int orient, Rt_Simplex s) +{ CGAL_assertion((orient==0) || (orient==1)); CGAL_assertion(vh[0] != Tmc_Vertex_handle()); CGAL_assertion(vh[1] != Tmc_Vertex_handle()); CGAL_assertion(vh[2] != Tmc_Vertex_handle()); CGAL_assertion(vh[3] != Tmc_Vertex_handle()); @@ -526,39 +514,36 @@ add_cell(Tmc_Vertex_handle vh[], int orient, Rt_Simplex s) { if (orient) { if (orientation(vh[0]->point(), vh[1]->point(), - vh[2]->point(), vh[3]->point()) != POSITIVE) { + vh[2]->point(), vh[3]->point()) != POSITIVE) { std::cout << orientation(vh[0]->point(), vh[1]->point(), - vh[2]->point(), vh[3]->point())<< std::endl; + vh[2]->point(), vh[3]->point())<< std::endl; } - CGAL_assertion(orientation( - vh[0]->point(), vh[1]->point(), - vh[2]->point(), vh[3]->point()) == POSITIVE); + CGAL_assertion(orientation(vh[0]->point(), vh[1]->point(), + vh[2]->point(), vh[3]->point()) == POSITIVE); ch = triangulation_incr_builder.add_cell(vh[0], vh[1], vh[2], vh[3]); } else { - CGAL_assertion(orientation( - vh[0]->point(), vh[1]->point(), - vh[3]->point(), vh[2]->point()) == POSITIVE); + CGAL_assertion(orientation(vh[0]->point(), vh[1]->point(), + vh[3]->point(), vh[2]->point()) == POSITIVE); ch = triangulation_incr_builder.add_cell(vh[0], vh[1], vh[3], vh[2]); } observer.after_cell_insertion(s, ch); return ch; } -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template typename TriangulatedMixedComplex_3::Geom_traits::Point_3 -Power_diagram_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: -get_orthocenter(Rt_Simplex const &s) { +Power_diagram_triangulator_3:: +get_orthocenter(Rt_Simplex const &s) +{ Rt_Vertex_handle vh; Rt_Edge e; Rt_Facet f; Rt_Cell_handle ch; - + Tmc_Point result; switch (s.dimension()) { case 0: @@ -568,35 +553,34 @@ get_orthocenter(Rt_Simplex const &s) { case 1: e=s; result = orthocenter_obj( - r2t_converter_object(e.first->vertex(e.second)->point()), - r2t_converter_object(e.first->vertex(e.third)->point())); + r2t_converter_object(e.first->vertex(e.second)->point()), + r2t_converter_object(e.first->vertex(e.third)->point())); break; case 2: f=s; result = orthocenter_obj( - r2t_converter_object( - f.first->vertex((f.second+1)&3)->point()), - r2t_converter_object( - f.first->vertex((f.second+2)&3)->point()), - r2t_converter_object( - f.first->vertex((f.second+3)&3)->point())); + r2t_converter_object( + f.first->vertex((f.second+1)&3)->point()), + r2t_converter_object( + f.first->vertex((f.second+2)&3)->point()), + r2t_converter_object( + f.first->vertex((f.second+3)&3)->point())); break; case 3: ch=s; result = orthocenter_obj( - r2t_converter_object(ch->vertex(0)->point()), - r2t_converter_object(ch->vertex(1)->point()), - r2t_converter_object(ch->vertex(2)->point()), - r2t_converter_object(ch->vertex(3)->point())); + r2t_converter_object(ch->vertex(0)->point()), + r2t_converter_object(ch->vertex(1)->point()), + r2t_converter_object(ch->vertex(2)->point()), + r2t_converter_object(ch->vertex(3)->point())); break; } return result; } -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template typename TriangulatedMixedComplex_3::Geom_traits::Point_3 Power_diagram_triangulator_3< RegularTriangulation_3, @@ -607,15 +591,13 @@ get_anchor(Rt_Simplex const &sVor) return get_orthocenter(sVor); } -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template void -Power_diagram_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: +Power_diagram_triangulator_3:: remove_small_edges() { Bbox_3 bbox; @@ -623,8 +605,8 @@ remove_small_edges() vit != _tmc.finite_vertices_end(); vit++) { bbox = bbox+vit->point().bbox(); } - // Tmc_RT sq_length = ((bbox.xmax()-bbox.xmin())*(bbox.xmax()-bbox.xmin()) + - // (bbox.ymax()-bbox.ymin())*(bbox.ymax()-bbox.ymin()) + + // Tmc_RT sq_length = ((bbox.xmax()-bbox.xmin())*(bbox.xmax()-bbox.xmin()) + + // (bbox.ymax()-bbox.ymin())*(bbox.ymax()-bbox.ymin()) + // (bbox.zmax()-bbox.zmin())*(bbox.zmax()-bbox.zmin()))/100000000; Tmc_RT sq_length = 1e-6; @@ -644,18 +626,16 @@ remove_small_edges() std::cout << "Collapsed: " << nCollapsed << std::endl; } -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template bool -Power_diagram_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: +Power_diagram_triangulator_3:: is_collapsible(Tmc_Vertex_handle vh, - Tmc_Vertex_handle &vh_collapse_to, - Tmc_RT sq_length) + Tmc_Vertex_handle &vh_collapse_to, + Tmc_RT sq_length) { std::vector incident_cells; CGAL_assertion(_tmc.is_vertex(vh)); @@ -663,65 +643,62 @@ is_collapsible(Tmc_Vertex_handle vh, _tmc.incident_cells(vh, std::back_inserter(incident_cells)); std::set incident_vertices; - for(typename std::vector::iterator - cit = incident_cells.begin(); + for(typename std::vector::iterator + cit = incident_cells.begin(); cit != incident_cells.end(); ++cit) { // Put all incident vertices in incident_vertices. for (int j=0; j<4; ++j) if ((*cit)->vertex(j) != vh) - incident_vertices.insert((*cit)->vertex(j)); + incident_vertices.insert((*cit)->vertex(j)); } - - for (typename std::set::iterator - it = incident_vertices.begin(); + + for (typename std::set::iterator + it = incident_vertices.begin(); it != incident_vertices.end(); it++) { if ((_tmc.geom_traits().compute_squared_distance_3_object()(vh->point(), - (*it)->point()) - < sq_length) && - (vh->cell()->surf == (*it)->cell()->surf) && - (vh->sign() == (*it)->sign())) { + (*it)->point()) + < sq_length) && + (vh->cell()->surf == (*it)->cell()->surf) && + (vh->sign() == (*it)->sign())) { bool ok = true; - for (typename std::vector::iterator - cit = incident_cells.begin(); - ok && (cit != incident_cells.end()); cit++) { - if (!(*cit)->has_vertex(*it)) { - const Tmc_Point* pts[4] = { &((*cit)->vertex(0)->point()), - &((*cit)->vertex(1)->point()), - &((*cit)->vertex(2)->point()), - &((*cit)->vertex(3)->point()) }; - pts[(*cit)->index(vh)] = &(*it)->point(); - - ok = (_tmc.geom_traits().orientation_3_object() - (*pts[0],*pts[1],*pts[2],*pts[3]) == CGAL::POSITIVE); - } + for (typename std::vector::iterator + cit = incident_cells.begin(); + ok && (cit != incident_cells.end()); cit++) { + if (!(*cit)->has_vertex(*it)) { + const Tmc_Point* pts[4] = { &((*cit)->vertex(0)->point()), + &((*cit)->vertex(1)->point()), + &((*cit)->vertex(2)->point()), + &((*cit)->vertex(3)->point()) }; + pts[(*cit)->index(vh)] = &(*it)->point(); + + ok = (_tmc.geom_traits().orientation_3_object() + (*pts[0],*pts[1],*pts[2],*pts[3]) == CGAL::POSITIVE); + } } if (ok) { - vh_collapse_to = *it; - return true; - } + vh_collapse_to = *it; + return true; + } } } return false; } -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> +template void -Power_diagram_triangulator_3< - RegularTriangulation_3, - TriangulatedMixedComplex_3, - TriangulatedMixedComplexObserver_3>:: -do_collapse(Tmc_Vertex_handle vh, - Tmc_Vertex_handle vh_collapse_to) +Power_diagram_triangulator_3:: +do_collapse(Tmc_Vertex_handle vh, Tmc_Vertex_handle vh_collapse_to) { std::vector incident_cells; incident_cells.reserve(32); _tmc.incident_cells(vh, std::back_inserter(incident_cells)); int i,i2; for (typename std::vector::iterator - it = incident_cells.begin(); it != incident_cells.end(); it++) { + it = incident_cells.begin(); it != incident_cells.end(); it++) { i = (*it)->index(vh); if ((*it)->has_vertex(vh_collapse_to,i2)) { // This cell is collapsed, set neighbor information of the new facet @@ -731,14 +708,14 @@ do_collapse(Tmc_Vertex_handle vh, ch1->set_neighbor(ch1->index((*it)), ch2); ch2->set_neighbor(ch2->index((*it)), ch1); for (int i=0; i<4; i++) { - // Try to point to a cell with the same surface: - if ((*it)->vertex(i)->cell() == (*it)) { - if ((*it)->surf == ch1->surf) { - (*it)->vertex(i)->set_cell(ch1); - } else { - (*it)->vertex(i)->set_cell(ch2); - } - } + // Try to point to a cell with the same surface: + if ((*it)->vertex(i)->cell() == (*it)) { + if ((*it)->surf == ch1->surf) { + (*it)->vertex(i)->set_cell(ch1); + } else { + (*it)->vertex(i)->set_cell(ch2); + } + } } _tmc.tds().delete_cell((*it)); } else { @@ -749,15 +726,14 @@ do_collapse(Tmc_Vertex_handle vh, _tmc.tds().delete_vertex(vh); } -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3, - class TriangulatedMixedComplexObserver_3> -void +template +void triangulate_power_diagram_3(RegularTriangulation_3 &rt, - TriangulatedMixedComplex_3 &tmc, - TriangulatedMixedComplexObserver_3 &observer, - bool verbose) + TriangulatedMixedComplex_3 &tmc, + TriangulatedMixedComplexObserver_3 &observer, + bool verbose) { typedef Power_diagram_triangulator_3< RegularTriangulation_3, @@ -766,18 +742,16 @@ triangulate_power_diagram_3(RegularTriangulation_3 &rt, Power_diagram_triangulator(rt, tmc, observer, verbose); } - -template < - class RegularTriangulation_3, - class TriangulatedMixedComplex_3> -void -triangulate_power_diagram_3(RegularTriangulation_3 const ®ular, - TriangulatedMixedComplex_3 &tmc, - bool verbose) +template +void +triangulate_power_diagram_3(RegularTriangulation_3 const ®ular, + TriangulatedMixedComplex_3 &tmc, + bool verbose) { Triangulated_mixed_complex_observer_3< - TriangulatedMixedComplex_3, const RegularTriangulation_3> - observer(1); + TriangulatedMixedComplex_3, const RegularTriangulation_3> observer(1); + triangulate_power_diagram_3(regular, tmc, observer, verbose); } diff --git a/Skin_surface_3/test/Skin_surface_3/anchor_test.cpp b/Skin_surface_3/test/Skin_surface_3/anchor_test.cpp index 73a0564e660..a42cbc8c6bd 100644 --- a/Skin_surface_3/test/Skin_surface_3/anchor_test.cpp +++ b/Skin_surface_3/test/Skin_surface_3/anchor_test.cpp @@ -23,7 +23,8 @@ typedef Regular::Facet Facet; typedef Regular::Cell_handle Cell_handle; typedef CGAL::Triangulation_simplex_3 Simplex; -void test_anchor_del() { +void test_anchor_del() +{ Regular reg; CGAL::Compute_anchor_3 compute_anchor_obj(reg); Vertex_handle vh[4]; @@ -43,14 +44,14 @@ void test_anchor_del() { assert(Simplex(vh[i]) == compute_anchor_obj.anchor_vor(vh[i])); for (int j=i+1; j<4; j++) { assert(Simplex(Edge(ch,i,j)) == - compute_anchor_obj.anchor_del(Edge(ch,i,j))); + compute_anchor_obj.anchor_del(Edge(ch,i,j))); assert(Simplex(Edge(ch,i,j)) == - compute_anchor_obj.anchor_vor(Edge(ch,i,j))); + compute_anchor_obj.anchor_vor(Edge(ch,i,j))); } assert(Simplex(Facet(ch,i)) == - compute_anchor_obj.anchor_del(Facet(ch,i))); + compute_anchor_obj.anchor_del(Facet(ch,i))); assert(Simplex(Facet(ch,i)) == - compute_anchor_obj.anchor_vor(Facet(ch,i))); + compute_anchor_obj.anchor_vor(Facet(ch,i))); assert(Simplex(ch) == compute_anchor_obj.anchor_del(ch)); assert(Simplex(ch) == compute_anchor_obj.anchor_vor(ch)); } @@ -67,14 +68,14 @@ void test_anchor_del() { assert(Simplex(vh[i]) == compute_anchor_obj.anchor_del(vh[i])); assert(Simplex(vh[i]) == compute_anchor_obj.anchor_vor(vh[i])); assert(Simplex(Facet(ch,i)) == - compute_anchor_obj.anchor_del(Facet(ch,i))); + compute_anchor_obj.anchor_del(Facet(ch,i))); assert(Simplex(Facet(ch,i)) == - compute_anchor_obj.anchor_vor(Facet(ch,i))); + compute_anchor_obj.anchor_vor(Facet(ch,i))); for (int j=i+1; j<4; j++) { assert(Simplex(Edge(ch,i,j)) == - compute_anchor_obj.anchor_del(Edge(ch,i,j))); + compute_anchor_obj.anchor_del(Edge(ch,i,j))); assert(Simplex(Edge(ch,i,j)) == - compute_anchor_obj.anchor_vor(Edge(ch,i,j))); + compute_anchor_obj.anchor_vor(Edge(ch,i,j))); } assert(Simplex(ch) == compute_anchor_obj.anchor_del(ch)); assert(Simplex(ch) == compute_anchor_obj.anchor_vor(ch)); @@ -90,17 +91,17 @@ void test_anchor_del() { // Anchor of a Delaunay edge/facet/cell on a vertex assert(Simplex(vh[0]) == - compute_anchor_obj.anchor_del(Edge(ch,index1,(index1+1)&3))); + compute_anchor_obj.anchor_del(Edge(ch,index1,(index1+1)&3))); assert(Simplex(vh[0]) == - compute_anchor_obj.anchor_del(Edge(ch,index1,(index1+2)&3))); + compute_anchor_obj.anchor_del(Edge(ch,index1,(index1+2)&3))); assert(Simplex(vh[0]) == - compute_anchor_obj.anchor_del(Edge(ch,index1,(index1+3)&3))); + compute_anchor_obj.anchor_del(Edge(ch,index1,(index1+3)&3))); assert(Simplex(vh[0]) == - compute_anchor_obj.anchor_del(Facet(ch,(index1+1)&3))); + compute_anchor_obj.anchor_del(Facet(ch,(index1+1)&3))); assert(Simplex(vh[0]) == - compute_anchor_obj.anchor_del(Facet(ch,(index1+2)&3))); + compute_anchor_obj.anchor_del(Facet(ch,(index1+2)&3))); assert(Simplex(vh[0]) == - compute_anchor_obj.anchor_del(Facet(ch,(index1+3)&3))); + compute_anchor_obj.anchor_del(Facet(ch,(index1+3)&3))); assert(Simplex(vh[0]) == compute_anchor_obj.anchor_del(ch)); reg.clear(); @@ -114,11 +115,11 @@ void test_anchor_del() { // Anchor of a Delaunay facet/cell on an edge assert(Simplex(Edge(ch,index1,index2)) == - compute_anchor_obj.anchor_del(Facet(ch,ch->index(vh[2])))); + compute_anchor_obj.anchor_del(Facet(ch,ch->index(vh[2])))); assert(Simplex(Edge(ch,index1,index2)) == - compute_anchor_obj.anchor_del(Facet(ch,ch->index(vh[3])))); + compute_anchor_obj.anchor_del(Facet(ch,ch->index(vh[3])))); assert(Simplex(Edge(ch,index1,index2)) == - compute_anchor_obj.anchor_del(ch)); + compute_anchor_obj.anchor_del(ch)); reg.clear(); vh[0] = reg.insert(Weighted_point(Point(0,0,0), 1)); @@ -129,14 +130,12 @@ void test_anchor_del() { index1 = ch->index(vh[0]); // Anchor of a Delaunay cell on an facet - assert(Simplex(Facet(ch,index1)) == - compute_anchor_obj.anchor_del(ch)); + assert(Simplex(Facet(ch,index1)) == compute_anchor_obj.anchor_del(ch)); reg.clear(); - } -int main(int, char **) { - +int main(int, char **) +{ test_anchor_del(); // Regular regular; @@ -159,11 +158,11 @@ int main(int, char **) { // yExtr[i] = y + (-1+2*i)*std::sqrt(w); // zExtr[i] = z + (-1+2*i)*std::sqrt(w); // } - + // while (in >> x >> y >> z >> w) { // //std::cerr << x << " " << y << " " << z << " " << w << std::endl; // regular.insert(Weighted_point(Point(x,y,z),w)); - + // if (w<0) w=0.01; // xExtr[0] = std::min(xExtr[0], x - std::sqrt(w)); // yExtr[0] = std::min(yExtr[0], y - std::sqrt(w)); @@ -177,14 +176,14 @@ int main(int, char **) { // double boxSize = 1 + 2.05/(shrink * (1-shrink))* // std::max((xExtr[1]-xExtr[0]), // std::max((yExtr[1]-yExtr[0]),(zExtr[1]-zExtr[0]))); - + // regular.insert(Weighted_point(Point(xExtr[0]-boxSize,0,0),-1)); // regular.insert(Weighted_point(Point(xExtr[1]+boxSize,0,0),-1)); // regular.insert(Weighted_point(Point(0,yExtr[0]-boxSize,0),-1)); // regular.insert(Weighted_point(Point(0,yExtr[1]+boxSize,0),-1)); // regular.insert(Weighted_point(Point(0,0,zExtr[0]-boxSize),-1)); // regular.insert(Weighted_point(Point(0,0,zExtr[1]+boxSize),-1)); - + // assert( regular.is_valid() ); // assert( regular.dimension() == 3 ); // } @@ -209,7 +208,7 @@ int main(int, char **) { // // subdivision engine // Sqrt3Method subdivider(simplicial, mesh); // subdivider.subdivide(2); - + // { // std::ofstream out("out/sqrt.off"); // out << mesh; diff --git a/Skin_surface_3/test/Skin_surface_3/degenerate_test.cpp b/Skin_surface_3/test/Skin_surface_3/degenerate_test.cpp index 397b8be02b2..cf8ba2ee902 100644 --- a/Skin_surface_3/test/Skin_surface_3/degenerate_test.cpp +++ b/Skin_surface_3/test/Skin_surface_3/degenerate_test.cpp @@ -20,11 +20,14 @@ typedef Weighted_point::Point Bare_point; typedef CGAL::Exact_predicates_inexact_constructions_kernel IK; typedef CGAL::Polyhedron_3 Polyhedron; -class Test_file { +class Test_file +{ public: Test_file(double shrink) : s(shrink) { } - void operator()(std::string filename) { + + void operator()(std::string filename) + { std::cout << filename << std::endl; std::list l; @@ -32,23 +35,23 @@ public: assert(in.is_open()); Weighted_point wp; while (in >> wp) l.push_front(wp); - + Skin_surface_3 skin_surface(l.begin(), l.end(), s); - + Polyhedron p; CGAL::mesh_skin_surface_3(skin_surface, p); - + assert(p.is_valid() && p.is_closed()); //std::cout << p << std::endl; } + private: double s; }; - -int main(int, char **) { - +int main(int, char **) +{ std::vector filenames; filenames.push_back("data/caffeine.cin"); filenames.push_back("data/ball.cin"); @@ -64,7 +67,7 @@ int main(int, char **) { filenames.push_back("data/test9.cin"); filenames.push_back("data/test10.cin"); filenames.push_back("data/test11.cin"); - + std::for_each(filenames.begin(), filenames.end(), Test_file(.5)); std::for_each(filenames.begin(), filenames.end(), Test_file(.85)); diff --git a/Skin_surface_3/test/Skin_surface_3/degenerate_test_exact.cpp b/Skin_surface_3/test/Skin_surface_3/degenerate_test_exact.cpp index c2a17df8b92..686c349f3e4 100644 --- a/Skin_surface_3/test/Skin_surface_3/degenerate_test_exact.cpp +++ b/Skin_surface_3/test/Skin_surface_3/degenerate_test_exact.cpp @@ -10,7 +10,7 @@ #include #include -typedef CGAL::Exact_predicates_exact_constructions_kernel K; +typedef CGAL::Exact_predicates_exact_constructions_kernel K; typedef CGAL::Skin_surface_traits_3 Traits; typedef CGAL::Skin_surface_3 Skin_surface_3; typedef Skin_surface_3::FT FT; @@ -19,10 +19,12 @@ typedef Weighted_point::Point Bare_point; typedef CGAL::Exact_predicates_inexact_constructions_kernel IK; typedef CGAL::Polyhedron_3 Polyhedron; -class Test_file { +class Test_file +{ public: Test_file(double shrink) : s(shrink) { } + void operator()(std::string filename) { std::cout << filename << std::endl; @@ -34,23 +36,23 @@ public: while (in >> x >> y >> z >> w ) { l.push_front(Weighted_point(Bare_point(x,y,z),w)); } - + Skin_surface_3 skin_surface(l.begin(), l.end(), s); - + Polyhedron p; CGAL::mesh_skin_surface_3(skin_surface, p); - + assert(p.is_valid() && p.is_closed()); //std::cout << p << std::endl; } + private: double s; }; - -int main(int, char **) { - +int main(int, char **) +{ std::vector filenames; filenames.push_back("data/test1.cin"); filenames.push_back("data/test2.cin"); @@ -63,7 +65,7 @@ int main(int, char **) { filenames.push_back("data/test9.cin"); filenames.push_back("data/test10.cin"); filenames.push_back("data/test11.cin"); - + std::for_each(filenames.begin(), filenames.end(), Test_file(.5)); std::for_each(filenames.begin(), filenames.end(), Test_file(.85)); diff --git a/Skin_surface_3/test/Skin_surface_3/subdivision_test.cpp b/Skin_surface_3/test/Skin_surface_3/subdivision_test.cpp index 9fc4fa5019e..32b3afd0d5b 100644 --- a/Skin_surface_3/test/Skin_surface_3/subdivision_test.cpp +++ b/Skin_surface_3/test/Skin_surface_3/subdivision_test.cpp @@ -22,7 +22,8 @@ typedef CGAL::Polyhedron_3 Polyhedron_skin; #include -Skin_surface_3 create_skin_surface(std::string &filename, double shrink) { +Skin_surface_3 create_skin_surface(std::string &filename, double shrink) +{ std::list l; std::ifstream in(filename.c_str()); assert(in.is_open()); @@ -34,7 +35,7 @@ Skin_surface_3 create_skin_surface(std::string &filename, double shrink) { template < class Skin_surface_3, class Polyhedron> void construct_and_subdivide_mesh(Skin_surface_3 &skin_surface, - Polyhedron &polyhedron) + Polyhedron &polyhedron) { CGAL::mesh_skin_surface_3(skin_surface, polyhedron); assert(polyhedron.is_valid() && polyhedron.is_closed()); @@ -43,29 +44,33 @@ void construct_and_subdivide_mesh(Skin_surface_3 &skin_surface, assert(polyhedron.is_valid() && polyhedron.is_closed()); } -class Test_file { +class Test_file +{ public: Test_file(double shrink) : s(shrink) { } - void operator()(std::string &filename) { + + void operator()(std::string &filename) + { std::cout << filename << std::endl; - + Skin_surface_3 skin_surface = create_skin_surface(filename, .5); - + Polyhedron p; //construct_and_subdivide_mesh(skin_surface, p); //p.clear(); - + Polyhedron_skin p_skin; construct_and_subdivide_mesh(skin_surface, p_skin); p_skin.clear(); } + private: double s; }; -int main(int, char **) { - +int main(int, char **) +{ std::vector filenames; filenames.push_back("data/caffeine.cin"); filenames.push_back("data/ball.cin"); diff --git a/Skin_surface_3/test/Skin_surface_3/surface_test.cpp b/Skin_surface_3/test/Skin_surface_3/surface_test.cpp index d300153c156..90cc0427b9b 100644 --- a/Skin_surface_3/test/Skin_surface_3/surface_test.cpp +++ b/Skin_surface_3/test/Skin_surface_3/surface_test.cpp @@ -24,7 +24,7 @@ typedef CGAL::Polyhedron_3 Polyhedron; CGAL::Cartesian_converter e2i_converter; CGAL::Cartesian_converter i2e_converter; - // Triangulated_mixed_complex: +// Triangulated_mixed_complex: typedef Skin_surface::TMC TMC; typedef TMC::Vertex_iterator TMC_Vertex_iterator; @@ -40,54 +40,57 @@ class Test_file { public: Test_file(double shrink) : s(shrink) { } - void operator()(std::string & filename) { + + void operator()(std::string & filename) + { std::cout << s << " " << filename << std::endl; - + std::ifstream in(filename.c_str()); - + std::list l; double x,y,z,w; - while (in >> x >> y >> z >> w) + while (in >> x >> y >> z >> w) l.push_front(Weighted_point(Bare_point(x,y,z),w)); - + Skin_surface skin_surface(l.begin(), l.end(), s); - + TMC &tmc = skin_surface.triangulated_mixed_complex(); -// CGAL::Triangulated_mixed_complex_observer_3 -// observer(skin_surface.shrink_factor()); -// triangulate_mixed_complex_3(skin_surface.get_regular_triangulation(), -// skin_surface.shrink_factor(), -// tmc, -// observer, -// false); + // CGAL::Triangulated_mixed_complex_observer_3 + // observer(skin_surface.shrink_factor()); + // triangulate_mixed_complex_3(skin_surface.get_regular_triangulation(), + // skin_surface.shrink_factor(), + // tmc, + // observer, + // false); for (TMC_Finite_vertices_iterator vit = tmc.finite_vertices_begin(); - vit != tmc.finite_vertices_end(); vit++) { - + vit != tmc.finite_vertices_end(); vit++) { + if (tmc.is_infinite(vit->cell())) { - std::cerr << "ERROR: is_infinite (main)" << std::endl; + std::cerr << "ERROR: is_infinite (main)" << std::endl; } Exact_K::FT val = vit->cell()->info().second->value(vit->point()); std::list cells; tmc.incident_cells(vit, std::back_inserter(cells)); - for (std::list::iterator cell = - cells.begin(); - cell != cells.end(); cell++) { - if (!tmc.is_infinite(*cell)) { - Exact_K::FT val2 = (*cell)->info().second->value(vit->point()); - // NGHK: Make exact: - //assert(val == val2); - assert(std::abs(CGAL::to_double(val-val2)) < 1e-8); - } + for (std::list::iterator cell = + cells.begin(); + cell != cells.end(); cell++) { + if (!tmc.is_infinite(*cell)) { + Exact_K::FT val2 = (*cell)->info().second->value(vit->point()); + // NGHK: Make exact: + //assert(val == val2); + assert(std::abs(CGAL::to_double(val-val2)) < 1e-8); + } } } - } + private: double s; }; -int main(int , char **) { +int main(int , char **) +{ std::vector filenames; filenames.push_back("data/test1.cin"); filenames.push_back("data/test2.cin"); @@ -101,7 +104,7 @@ int main(int , char **) { filenames.push_back("data/test10.cin"); filenames.push_back("data/test11.cin"); filenames.push_back("data/degenerate.cin"); - + std::for_each(filenames.begin(), filenames.end(), Test_file(.5)); std::for_each(filenames.begin(), filenames.end(), Test_file(.85)); diff --git a/Skin_surface_3/test/Skin_surface_3/union_of_balls_test.cpp b/Skin_surface_3/test/Skin_surface_3/union_of_balls_test.cpp index 54887875a2c..e8129bccb2c 100644 --- a/Skin_surface_3/test/Skin_surface_3/union_of_balls_test.cpp +++ b/Skin_surface_3/test/Skin_surface_3/union_of_balls_test.cpp @@ -2,7 +2,8 @@ #include #include -int main(int, char *[]) { +int main(int, char *[]) +{ double pts[][3]={{3.3874, 3.3577, 2.86547}, {4.20832, 3.04325, 3.05838}, {3.63033, 2.62921, 2.50657}, @@ -20,13 +21,15 @@ int main(int, char *[]) { std::vector l(size); for (size_t i=0; i< size; ++i) { l[i]= Weighted_point(Bare_point(pts[i][0], pts[i][1], pts[i][2]), - .9*.9); + .9*.9); std::cout << ".color " << i << std::endl; std::cout << ".sphere " << pts[i][0] << " " << pts[i][1] << " " << pts[i][2] << " " << .9 << std::endl; } + CGAL::Polyhedron_3 p; CGAL::Union_of_balls_3 > - skin_surface(l.begin(), l.end()); + skin_surface(l.begin(), l.end()); + return 0; } diff --git a/Skin_surface_3/test/Skin_surface_3/union_of_balls_test_exact.cpp b/Skin_surface_3/test/Skin_surface_3/union_of_balls_test_exact.cpp index e1b726f7e6b..27b3b648ed2 100644 --- a/Skin_surface_3/test/Skin_surface_3/union_of_balls_test_exact.cpp +++ b/Skin_surface_3/test/Skin_surface_3/union_of_balls_test_exact.cpp @@ -2,7 +2,8 @@ #include #include -int main(int, char *[]) { +int main(int, char *[]) +{ double pts[][3]={{3.3874, 3.3577, 2.86547}, {4.20832, 3.04325, 3.05838}, {3.63033, 2.62921, 2.50657}, @@ -20,13 +21,14 @@ int main(int, char *[]) { std::vector l(size); for (size_t i=0; i< size; ++i) { l[i]= Weighted_point(Bare_point(pts[i][0], pts[i][1], pts[i][2]), - .9*.9); + .9*.9); std::cout << ".color " << i << std::endl; std::cout << ".sphere " << pts[i][0] << " " << pts[i][1] << " " << pts[i][2] << " " << .9 << std::endl; } + CGAL::Polyhedron_3 p; CGAL::Union_of_balls_3 > - skin_surface(l.begin(), l.end()); + skin_surface(l.begin(), l.end()); return 0; }