From bb67aa6d0a1aa69fcea100220ba0a1a8efa63e22 Mon Sep 17 00:00:00 2001 From: iyaz Date: Wed, 29 May 2013 15:08:12 +0300 Subject: [PATCH] Renaming and cleaning --- .../internal/{Fair.h => Fair_Polyhedron_3.h} | 6 +- .../CGAL/internal/Fill_hole_connector.h | 111 ++++++++++++++++++ .../{Refine.h => Refine_Polyhedron_3.h} | 6 +- .../{Smooth.h => Smooth_Polyhedron_3.h} | 8 +- ...late.h => Triangulate_hole_Polyhedron_3.h} | 11 +- .../Triangulate_hole_polyline.h} | 15 +-- .../Polyhedron_demo_hole_filling_plugin.cpp | 1 - ...lyhedron_demo_smoothing_fairing_plugin.cpp | 3 +- 8 files changed, 135 insertions(+), 26 deletions(-) rename Hole_filling/include/CGAL/internal/{Fair.h => Fair_Polyhedron_3.h} (98%) create mode 100644 Hole_filling/include/CGAL/internal/Fill_hole_connector.h rename Hole_filling/include/CGAL/internal/{Refine.h => Refine_Polyhedron_3.h} (97%) rename Hole_filling/include/CGAL/internal/{Smooth.h => Smooth_Polyhedron_3.h} (85%) rename Hole_filling/include/CGAL/internal/{Triangulate.h => Triangulate_hole_Polyhedron_3.h} (96%) rename Hole_filling/include/CGAL/{Fill_hole.h => internal/Triangulate_hole_polyline.h} (93%) diff --git a/Hole_filling/include/CGAL/internal/Fair.h b/Hole_filling/include/CGAL/internal/Fair_Polyhedron_3.h similarity index 98% rename from Hole_filling/include/CGAL/internal/Fair.h rename to Hole_filling/include/CGAL/internal/Fair_Polyhedron_3.h index c7f1d545794..31f5e881cdc 100644 --- a/Hole_filling/include/CGAL/internal/Fair.h +++ b/Hole_filling/include/CGAL/internal/Fair_Polyhedron_3.h @@ -1,5 +1,5 @@ -#ifndef CGAL_HOLE_FILLING_FAIR_H -#define CGAL_HOLE_FILLING_FAIR_H +#ifndef CGAL_HOLE_FILLING_FAIR_POLYHEDRON_3_H +#define CGAL_HOLE_FILLING_FAIR_POLYHEDRON_3_H #include #include @@ -246,4 +246,4 @@ void fair(Polyhedron& poly, //} }//namespace CGAL -#endif //CGAL_HOLE_FILLING_FAIR_H \ No newline at end of file +#endif //CGAL_HOLE_FILLING_FAIR_POLYHEDRON_3_H \ No newline at end of file diff --git a/Hole_filling/include/CGAL/internal/Fill_hole_connector.h b/Hole_filling/include/CGAL/internal/Fill_hole_connector.h new file mode 100644 index 00000000000..7d4526e1486 --- /dev/null +++ b/Hole_filling/include/CGAL/internal/Fill_hole_connector.h @@ -0,0 +1,111 @@ +#ifndef CGAL_HOLE_FILLING_FILL_HOLE_CONNECTOR +#define CGAL_HOLE_FILLING_FILL_HOLE_CONNECTOR +#include +#include +#include +#include + +#include + +#include +#include +#include + +namespace CGAL { +namespace internal { + + struct Nop_functor { + template + void operator()(const T& t) const {} + }; + + // Connector class to triangulate - refine - fair holes on Polyhedron_3 + template + class Fill_hole_Polyhedron_3 { + + typedef typename Polyhedron::Traits::Point_3 Point_3; + typedef typename Polyhedron::Vertex_handle Vertex_handle; + typedef typename Polyhedron::Halfedge_handle Halfedge_handle; + typedef typename Polyhedron::Facet_handle Facet_handle; + typedef typename Polyhedron::Halfedge_around_facet_circulator Halfedge_around_facet_circulator; + typedef typename Polyhedron::Halfedge_around_vertex_circulator Halfedge_around_vertex_circulator; + + private: + void average_length(Polyhedron& poly, Vertex_handle vh, std::map& scale_attribute) + { + const Point_3& vp = vh->point(); + Halfedge_around_vertex_circulator circ(vh->vertex_begin()), done(circ); + int deg = 0; + double sum = 0; + do { + const Point_3& vq = circ->opposite()->vertex()->point(); + sum += std::sqrt(CGAL::squared_distance(vp, vq)); + ++deg; + ++circ; + } while(circ != done); + scale_attribute[vh] = sum/deg; + } + + void get_boundary_vertices(Polyhedron& poly, Halfedge_handle it, std::set& boundary_vertices) { + Halfedge_around_facet_circulator circ(it), done(circ); + do{ + boundary_vertices.insert(circ->vertex()); + } while (++circ != done); + } + + public: + template + void triangulate_and_refine_hole(Polyhedron& poly, Halfedge_handle it, double alpha, OutputIterator output) + { + if(! it->is_border()){ return; } + + // compute scale_attribute before triangulation + std::map scale_attribute; + Halfedge_around_facet_circulator circ(it), done(circ); + do{ + average_length(poly, circ->vertex(), scale_attribute); + } while (++circ != done); + // Triangulate + std::set facets; + triangulate_hole(poly, it, std::inserter(facets, facets.begin())); + // Refine + internal::Refine_Polyhedron_3 refine_functor(alpha); + refine_functor(poly, scale_attribute, facets); + + std::copy(facets.begin(), facets.end(), output); + } + + template + void triangulate_refine_and_fair + (Polyhedron& poly, Halfedge_handle it, double alpha, WeightCalculator weight_calculator) + { + if(! it->is_border()){ return; } + + // save boundary vertices before triangulation + std::set boundary_vertices; + get_boundary_vertices(poly, it, boundary_vertices); + + //Triangulate and refine + std::vector facets; + triangulate_and_refine_hole(poly, it, alpha, std::back_inserter(facets)); + + // get interior vertices + std::set interior_vertices; + for(std::vector::iterator it = facets.begin(); it != facets.end(); ++it) { + Halfedge_around_facet_circulator circ = (*it)->facet_begin(); + do { + if(boundary_vertices.find(circ->vertex()) == boundary_vertices.end()) { + interior_vertices.insert(circ->vertex()); + } + } while(++circ != (*it)->facet_begin()); + } + + CGAL_TRACE_STREAM << "before fair |boundary vertices| = " << boundary_vertices.size() << std::endl; + CGAL_TRACE_STREAM << "before fair |interior vertices| = " << interior_vertices.size() << std::endl; + // Fair + fair(poly, interior_vertices, weight_calculator); + } + }; +}//namespace internal +}//namespace CGAL +#endif // CGAL_HOLE_FILLING_FILL_HOLE_CONNECTOR \ No newline at end of file diff --git a/Hole_filling/include/CGAL/internal/Refine.h b/Hole_filling/include/CGAL/internal/Refine_Polyhedron_3.h similarity index 97% rename from Hole_filling/include/CGAL/internal/Refine.h rename to Hole_filling/include/CGAL/internal/Refine_Polyhedron_3.h index 46a5dd14d2c..1bc0ea69d5f 100644 --- a/Hole_filling/include/CGAL/internal/Refine.h +++ b/Hole_filling/include/CGAL/internal/Refine_Polyhedron_3.h @@ -1,5 +1,5 @@ -#ifndef CGAL_HOLE_FILLING_REFINE_H -#define CGAL_HOLE_FILLING_REFINE_H +#ifndef CGAL_HOLE_FILLING_REFINE_POLYHEDRON_3_H +#define CGAL_HOLE_FILLING_REFINE_POLYHEDRON_3_H #include #include #include @@ -148,4 +148,4 @@ public: }//namespace internal }//namespace CGAL -#endif //CGAL_HOLE_FILLING_REFINE_H \ No newline at end of file +#endif //CGAL_HOLE_FILLING_REFINE_POLYHEDRON_3_H \ No newline at end of file diff --git a/Hole_filling/include/CGAL/internal/Smooth.h b/Hole_filling/include/CGAL/internal/Smooth_Polyhedron_3.h similarity index 85% rename from Hole_filling/include/CGAL/internal/Smooth.h rename to Hole_filling/include/CGAL/internal/Smooth_Polyhedron_3.h index 9e27c8c5bb7..0e1ac194cbb 100644 --- a/Hole_filling/include/CGAL/internal/Smooth.h +++ b/Hole_filling/include/CGAL/internal/Smooth_Polyhedron_3.h @@ -1,5 +1,5 @@ -#ifndef CGAL_HOLE_FILLING_SMOOTH_H -#define CGAL_HOLE_FILLING_SMOOTH_H +#ifndef CGAL_HOLE_FILLING_SMOOTH_POLYHEDRON_3_H +#define CGAL_HOLE_FILLING_SMOOTH_POLYHEDRON_3_H // going to be moved some place more relevant #include #include @@ -9,7 +9,7 @@ namespace CGAL { -// simple laplacian smoothing +// simple Laplacian smoothing template void smooth( Polyhedron& polyhedron, InputIterator vertex_begin, @@ -17,8 +17,6 @@ void smooth( Polyhedron& polyhedron, WeightCalculator weight_calculator = WeightCalculator() ) { - typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef typename boost::graph_traits::edge_descriptor edge_descriptor; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::in_edge_iterator in_edge_iterator; typedef typename Polyhedron::Traits::Point_3 Point; diff --git a/Hole_filling/include/CGAL/internal/Triangulate.h b/Hole_filling/include/CGAL/internal/Triangulate_hole_Polyhedron_3.h similarity index 96% rename from Hole_filling/include/CGAL/internal/Triangulate.h rename to Hole_filling/include/CGAL/internal/Triangulate_hole_Polyhedron_3.h index 9e891e8449a..abb35889159 100644 --- a/Hole_filling/include/CGAL/internal/Triangulate.h +++ b/Hole_filling/include/CGAL/internal/Triangulate_hole_Polyhedron_3.h @@ -1,17 +1,19 @@ -#ifndef CGAL_HOLE_FILLING_TRIANGULATE_H -#define CGAL_HOLE_FILLING_TRIANGULATE_H +#ifndef CGAL_HOLE_FILLING_TRIANGULATE_HOLE_POLYHEDRON_3_H +#define CGAL_HOLE_FILLING_TRIANGULATE_HOLE_POLYHEDRON_3_H #include #include #include #include + #include +#include namespace CGAL { namespace internal { template -class Triangulate_Hole_Polyhedron_3{ +class Triangulate_hole_Polyhedron_3{ // typedefs typedef typename Polyhedron::Traits::Point_3 Point_3; typedef typename Polyhedron::Halfedge_handle Halfedge_handle; @@ -196,9 +198,8 @@ public: void operator()(Polyhedron& poly, Halfedge_handle it) { triangulate(poly, it, dummy_inserter()); } - }; }//namespace internal }//namespace CGAL -#endif //CGAL_HOLE_FILLING_TRIANGULATE_H \ No newline at end of file +#endif //CGAL_HOLE_FILLING_TRIANGULATE_HOLE_POLYHEDRON_3_H \ No newline at end of file diff --git a/Hole_filling/include/CGAL/Fill_hole.h b/Hole_filling/include/CGAL/internal/Triangulate_hole_polyline.h similarity index 93% rename from Hole_filling/include/CGAL/Fill_hole.h rename to Hole_filling/include/CGAL/internal/Triangulate_hole_polyline.h index 64d2f672138..caa298b45ca 100644 --- a/Hole_filling/include/CGAL/Fill_hole.h +++ b/Hole_filling/include/CGAL/internal/Triangulate_hole_polyline.h @@ -1,6 +1,5 @@ - -#ifndef CGAL_FILL_HOLE_H -#define CGAL_FILL_HOLE_H +#ifndef CGAL_HOLE_FILLING_TRIANGULATE_HOLE_POLYLINE_H +#define CGAL_HOLE_FILLING_TRIANGULATE_HOLE_POLYLINE_H #include #include @@ -8,9 +7,10 @@ #include namespace CGAL { +namespace internal { template -class Fill_hole { +class Triangulate_hole_polyline { public: typedef typename K::Point_3 Point_3; typedef std::vector Polyline_3; @@ -156,6 +156,7 @@ public: } }; +} // namespace internal /*! Creates triangles to fill the hole defined by points in the range `(pbegin,pend)`. @@ -170,7 +171,7 @@ fill_hole(InputIterator pbegin, InputIterator pend, OutputIterator out) { typedef typename CGAL::Kernel_traits< typename std::iterator_traits::value_type>::Kernel Kernel; - typedef Fill_hole Fill; + typedef CGAL::internal::Triangulate_hole_polyline Fill; typename Fill::Polyline_3 P(pbegin, pend); typename Fill::Polyline_3 Q(qbegin, qend); if(P.front() != P.back()){ @@ -193,7 +194,7 @@ fill_hole(InputIterator pbegin, InputIterator pend, OutputIterator out) { typedef typename CGAL::Kernel_traits< typename std::iterator_traits::value_type>::Kernel Kernel; - typedef Fill_hole Fill; + typedef CGAL::internal::Triangulate_hole_polyline Fill; typename Fill::Polyline_3 P(pbegin, pend); typename Fill::Polyline_3 Q; if(P.front() != P.back()){ @@ -205,4 +206,4 @@ fill_hole(InputIterator pbegin, InputIterator pend, } // namespace CGAL -#endif // CGAL_FILL_HOLE_H +#endif // CGAL_HOLE_FILLING_TRIANGULATE_HOLE_POLYLINE_H diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp index 87c719f80dc..bd5f4990ecb 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp @@ -9,7 +9,6 @@ #include "ui_Hole_filling_widget.h" #include "Polyhedron_type.h" -//#include #include #include diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_smoothing_fairing_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_smoothing_fairing_plugin.cpp index 4bbc1a231e2..b1552160076 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_smoothing_fairing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_smoothing_fairing_plugin.cpp @@ -6,9 +6,8 @@ #include "ui_Smoothing_fairing_widget.h" #include "Polyhedron_type.h" -//#include #include -#include +#include #include #include