diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_metric_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_metric_example.cpp index be7149c7eb8..08ef7ea46bb 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_metric_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_metric_example.cpp @@ -100,7 +100,6 @@ struct ApproxTrait { typedef PointProxy Proxy; typedef CompactMetric ErrorMetric; typedef PointProxyFitting ProxyFitting; - typedef CGAL::PlaneFitting PlaneFitting; ApproxTrait(const Polyhedron &_mesh, const VertexPointMap &_point_pmap, @@ -117,10 +116,6 @@ struct ApproxTrait { return ProxyFitting(center_pmap, area_pmap, normal_pmap); } - PlaneFitting construct_plane_fitting_functor() const { - return PlaneFitting(mesh); - } - const Polyhedron &mesh; const VertexPointMap point_pmap; const FacetCenterMap center_pmap; diff --git a/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/VSA.h b/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/VSA.h index d7985ad0842..3cf89814134 100644 --- a/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/VSA.h +++ b/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/VSA.h @@ -400,14 +400,12 @@ private: * @tparam FacetSegmentMap `WritablePropertyMap` with `boost::graph_traits::face_handle` as key and `std::size_t` as value type */ template + typename FacetSegmentMap, + typename PlaneFitting = typename CGAL::PlaneFitting, + typename GeomTraits = typename TriangleMesh::Traits> class VSA_mesh_extraction { - typedef typename ApproximationTraits::GeomTraits GeomTraits; - typedef typename ApproximationTraits::PlaneFitting PlaneFitting; - typedef typename GeomTraits::FT FT; typedef typename GeomTraits::Point_3 Point_3; typedef typename GeomTraits::Vector_3 Vector_3; @@ -447,20 +445,19 @@ public: /** * Extracts the surface mesh from an approximation partition @a _seg_pmap of mesh @a _mesh. * @param _mesh the approximated triangle mesh. - * @param _appx_trait approximation traits object. + * @param _plane_fitting plane fitting function object. * @param _point_pmap vertex point map of the input mesh. * @param _seg_pmap approximation partition. */ VSA_mesh_extraction(const TriangleMesh &_mesh, - const ApproximationTraits &_appx_trait, + const PlaneFitting &_plane_fitting, const VertexPointMap &_point_pmap, const FacetSegmentMap &_seg_pmap) : mesh(_mesh), point_pmap(_point_pmap), seg_pmap(_seg_pmap), vanchor_map(vertex_int_map), - num_proxies(0), - plane_fitting(_appx_trait.construct_plane_fitting_functor()) { + num_proxies(0) { GeomTraits traits; vector_functor = traits.construct_vector_3_object(); scale_functor = traits.construct_scaled_vector_3_object(); @@ -482,7 +479,7 @@ public: BOOST_FOREACH(face_descriptor f, faces(mesh)) px_facets[seg_pmap[f]].push_back(f); BOOST_FOREACH(const std::list &px_patch, px_facets) { - px_planes.push_back(plane_fitting(px_patch.begin(), px_patch.end())); + px_planes.push_back(_plane_fitting(px_patch.begin(), px_patch.end())); Vector_3 norm = CGAL::NULL_VECTOR; FT area(0); @@ -1068,9 +1065,6 @@ private: // All borders cycles. std::vector borders; - - // The proxy plane fitting functor. - PlaneFitting plane_fitting; }; // end class VSA_mesh_extraction } // end namespace internal diff --git a/Surface_mesh_approximation/include/CGAL/vsa_mesh_approximation.h b/Surface_mesh_approximation/include/CGAL/vsa_mesh_approximation.h index d4ccbfdcae4..9679419db12 100644 --- a/Surface_mesh_approximation/include/CGAL/vsa_mesh_approximation.h +++ b/Surface_mesh_approximation/include/CGAL/vsa_mesh_approximation.h @@ -26,6 +26,7 @@ namespace CGAL * @tparam AnchorPositionContainer a container of extracted anchor position * @tparam AnchorVertexContainer a container of extracted anchor vertex * @tparam BoundaryContainer a container of proxy patch boundary + * @tparam PlaneFitting a plane fitting functor * @tparam ApproximationTrait an approximation trait * @param init select seed initialization @@ -47,6 +48,7 @@ template void vsa_mesh_approximation( const int init, @@ -59,6 +61,7 @@ void vsa_mesh_approximation( AnchorPositionContainer &pos, AnchorVertexContainer &vtx, BoundaryContainer &bdrs, + const PlaneFitting &_plane_fitting, const ApproximationTrait &app_trait) { // CGAL_precondition(is_pure_triangle(tm)); @@ -71,11 +74,12 @@ void vsa_mesh_approximation( typedef CGAL::internal::VSA_mesh_extraction< TriangleMesh, - ApproximationTrait, VertexPointMap, - FacetProxyMap> VSA_mesh_extraction; + FacetProxyMap, + PlaneFitting, + ApproximationTrait::GeomTraits> VSA_mesh_extraction; - VSA_mesh_extraction extractor(tm, app_trait, v_point_pmap, f_proxy_pmap); + VSA_mesh_extraction extractor(tm, _plane_fitting, v_point_pmap, f_proxy_pmap); extractor.extract_mesh(tris); BOOST_FOREACH(const typename VSA_mesh_extraction::Anchor &a, extractor.collect_anchors()) { @@ -147,6 +151,7 @@ void vsa_approximate( * @tparam TriangleMesh model of `FaceGraph`. * @tparam AnchorIndexContainer a container of approximated indexed triangle soup * @tparam AnchorPositionContainer a container of extracted anchor position + * @tparam PlaneFitting a plane fitting functor * @tparam ApproximationTrait an approximation trait * @param tm a triangle mesh @@ -160,11 +165,13 @@ void vsa_approximate( template void vsa_extract( const TriangleMesh &tm, AnchorIndexContainer &tris, AnchorPositionContainer &pos, + const PlaneFitting &_plane_fitting, const ApproximationTrait &app_trait, const int init, const std::size_t number_of_segments, @@ -188,12 +195,13 @@ void vsa_extract( typedef typename boost::property_map::type VertexPointMap; typedef CGAL::internal::VSA_mesh_extraction< TriangleMesh, - ApproximationTrait, VertexPointMap, - FacetProxyMap> VSA_mesh_extraction; + FacetProxyMap, + PlaneFitting, + ApproximationTrait::GeomTraits> VSA_mesh_extraction; VSA_mesh_extraction extractor(tm, - app_trait, + _plane_fitting, get(boost::vertex_point, const_cast(tm)), f_proxy_pmap); @@ -214,6 +222,7 @@ void vsa_extract( std::size_t as value type * @tparam AnchorIndexContainer a container of approximated indexed triangle soup * @tparam AnchorPositionContainer a container of extracted anchor position + * @tparam PlaneFitting a plane fitting functor * @tparam ApproximationTrait an approximation trait * @param tm a triangle mesh @@ -229,12 +238,14 @@ template void vsa_approximate_and_extract( const TriangleMesh &tm, FacetProxyMap f_proxy_pmap, AnchorIndexContainer &tris, AnchorPositionContainer &pos, + const PlaneFitting &_plane_fitting, const ApproximationTrait &app_trait, const int init, const std::size_t number_of_segments, @@ -251,12 +262,13 @@ void vsa_approximate_and_extract( typedef typename boost::property_map::type VertexPointMap; typedef CGAL::internal::VSA_mesh_extraction< TriangleMesh, - ApproximationTrait, VertexPointMap, - FacetProxyMap> VSA_mesh_extraction; + FacetProxyMap, + PlaneFitting, + ApproximationTrait::GeomTraits> VSA_mesh_extraction; VSA_mesh_extraction extractor(tm, - app_trait, + _plane_fitting, get(boost::vertex_point, const_cast(tm)), f_proxy_pmap); @@ -306,8 +318,7 @@ void vsa_approximate( typedef CGAL::PlaneProxy PlaneProxy; typedef CGAL::L21Metric L21Metric; typedef CGAL::L21ProxyFitting L21ProxyFitting; - typedef CGAL::PlaneFitting PlaneFitting; - typedef CGAL::L21ApproximationTrait L21ApproximationTrait; + typedef CGAL::L21ApproximationTrait L21ApproximationTrait; VertexPointMap point_pmap = get(boost::vertex_point, const_cast(tm)); // construct facet normal & area map @@ -378,7 +389,7 @@ void vsa_extract( typedef CGAL::L21Metric L21Metric; typedef CGAL::L21ProxyFitting L21ProxyFitting; typedef CGAL::PlaneFitting PlaneFitting; - typedef CGAL::L21ApproximationTrait L21ApproximationTrait; + typedef CGAL::L21ApproximationTrait L21ApproximationTrait; VertexPointMap point_pmap = get(boost::vertex_point, const_cast(tm)); // construct facet normal & area map @@ -406,6 +417,7 @@ void vsa_extract( vsa_extract(tm, tris, pos, + PlaneFitting(tm), L21ApproximationTrait(tm, point_pmap, normal_pmap, area_pmap), init, number_of_segments, @@ -462,7 +474,7 @@ void vsa_approximate_and_extract( typedef CGAL::L21Metric L21Metric; typedef CGAL::L21ProxyFitting L21ProxyFitting; typedef CGAL::PlaneFitting PlaneFitting; - typedef CGAL::L21ApproximationTrait L21ApproximationTrait; + typedef CGAL::L21ApproximationTrait L21ApproximationTrait; VertexPointMap point_pmap = get(boost::vertex_point, const_cast(tm)); // construct facet normal & area map @@ -486,6 +498,7 @@ void vsa_approximate_and_extract( f_proxy_pmap, tris, pos, + PlaneFitting(tm), app_trait, init, number_of_segments, diff --git a/Surface_mesh_approximation/include/CGAL/vsa_mesh_approximation_traits.h b/Surface_mesh_approximation/include/CGAL/vsa_mesh_approximation_traits.h index a4b6a8f46f5..f041325cd4a 100644 --- a/Surface_mesh_approximation/include/CGAL/vsa_mesh_approximation_traits.h +++ b/Surface_mesh_approximation/include/CGAL/vsa_mesh_approximation_traits.h @@ -153,11 +153,11 @@ template::halfedge_descriptor halfedge_descriptor; template - Plane_3 operator()(const FacetIterator &beg, const FacetIterator &end) { + Plane_3 operator()(const FacetIterator &beg, const FacetIterator &end) const { CGAL_assertion(beg != end); // area average normal and centroid Vector_3 norm = CGAL::NULL_VECTOR; - Vector_3 centroid = CGAL::NULL_VECTOR; + Vector_3 cent = CGAL::NULL_VECTOR; FT sum_area(0); for (FacetIterator fitr = beg; fitr != end; ++fitr) { const halfedge_descriptor he = halfedge(*fitr, mesh); @@ -170,14 +170,14 @@ template @@ -202,7 +201,6 @@ template - Plane_3 operator()(const FacetIterator beg, const FacetIterator end) { + Plane_3 operator()(const FacetIterator beg, const FacetIterator end) const { CGAL_assertion(beg != end); std::list tris; @@ -401,7 +394,6 @@ template struct L2ApproximationTrait @@ -411,7 +403,6 @@ public: typedef PlaneProxy Proxy; typedef L2ErrorMetric ErrorMetric; typedef L2ProxyFitting ProxyFitting; - typedef PCAPlaneFitting PlaneFitting; L2ApproximationTrait( const TriangleMesh &_mesh, @@ -433,11 +424,6 @@ public: return ProxyFitting(mesh, point_pmap, area_pmap); } - // construct plane fitting functor - PlaneFitting construct_plane_fitting_functor() const { - return PlaneFitting(mesh, point_pmap); - } - private: const TriangleMesh &mesh; const VertexPointMap point_pmap;