mirror of https://github.com/CGAL/cgal
remove Polyhedron output mesh
vsa_mesh_approximation + vsa_mesh_segmentation -> mesh_approximation
This commit is contained in:
parent
745f87e172
commit
f276cac096
|
|
@ -76,10 +76,9 @@ int main(int argc, char *argv[])
|
|||
t0.stop();
|
||||
std::cerr << "iterations time " << t0.time() << " sec." << std::endl;
|
||||
|
||||
Polyhedron mesh_out;
|
||||
t0.reset();
|
||||
t0.start();
|
||||
approx.extract_mesh(mesh_out);
|
||||
approx.extract_mesh();
|
||||
t0.stop();
|
||||
std::cerr << "meshing time " << t0.time() << " sec." << std::endl;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/vsa_mesh_approximation.h>
|
||||
#include <CGAL/mesh_approximation.h>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
typedef CGAL::Plane_proxy<Kernel> Plane_proxy;
|
||||
|
|
@ -36,14 +36,14 @@ int main()
|
|||
std::vector<Plane_proxy> proxies;
|
||||
|
||||
// free function interface with named parameters
|
||||
CGAL::vsa_mesh_approximation(input,
|
||||
std::back_inserter(points),
|
||||
std::back_inserter(triangles),
|
||||
CGAL::mesh_approximation(input,
|
||||
CGAL::Surface_mesh_approximation::parameters::min_error_drop(0.05). // seeding with minimum error drop
|
||||
nb_of_iterations(40). // set number of clustering iterations after seeding
|
||||
mesh_chord_error(0.3). // set chord approximation error threshold when meshing
|
||||
facet_proxy_map(fpxmap). // get facet partition map
|
||||
proxies(std::back_inserter(proxies))); // get proxies
|
||||
proxies(std::back_inserter(proxies)). // get proxies
|
||||
anchor_points(std::back_inserter(points)). // anchor points
|
||||
indexed_triangles(std::back_inserter(triangles))); // indexed triangles
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/vsa_mesh_approximation.h>
|
||||
#include <CGAL/mesh_approximation.h>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
|
||||
|
|
@ -18,25 +18,22 @@ int main()
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// output polyhedral surface and indexed face set
|
||||
Polyhedron output;
|
||||
// output indexed triangles
|
||||
std::vector<Kernel::Point_3> points;
|
||||
std::vector<std::vector<std::size_t> > triangles; // triplets of indices
|
||||
|
||||
// free function interface with named parameters
|
||||
bool valid_polyhedron = CGAL::vsa_mesh_approximation(input,
|
||||
std::back_inserter(points),
|
||||
std::back_inserter(triangles),
|
||||
bool is_manifold = CGAL::mesh_approximation(input,
|
||||
CGAL::Surface_mesh_approximation::parameters::seeding_method(CGAL::Hierarchical). // hierarchical seeding
|
||||
max_nb_proxies(200). // seeding with maximum number of proxies
|
||||
nb_of_iterations(30). // number of clustering iterations after seeding
|
||||
// output to polyhedron
|
||||
output_mesh(&output)); // valid when the indexed face set represents a 2-manifold, oriented surface
|
||||
anchor_points(std::back_inserter(points)). // anchor points
|
||||
indexed_triangles(std::back_inserter(triangles))); // indexed triangles
|
||||
|
||||
std::cout << "#anchor points: " << points.size() << std::endl;
|
||||
std::cout << "#triangles: " << triangles.size() << std::endl;
|
||||
|
||||
if (valid_polyhedron)
|
||||
if (is_manifold)
|
||||
std::cout << "oriented, 2-manifold output." << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -52,9 +52,8 @@ int main()
|
|||
approx.teleport_proxies(2, 5);
|
||||
approx.run(10);
|
||||
|
||||
// mesh and output final polyhedral surface
|
||||
Polyhedron output;
|
||||
approx.extract_mesh(output);
|
||||
// meshing with default parameters
|
||||
approx.extract_mesh();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/vsa_mesh_segmentation.h>
|
||||
#include <CGAL/mesh_approximation.h>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
|
||||
|
|
@ -29,12 +29,12 @@ int main()
|
|||
Facet_proxy_pmap fpxmap(fidx_map);
|
||||
|
||||
// free function interface with named parameters
|
||||
CGAL::vsa_mesh_segmentation(input,
|
||||
fpxmap, // output segmentation
|
||||
CGAL::mesh_approximation(input,
|
||||
CGAL::Surface_mesh_approximation::parameters::seeding_method(CGAL::Hierarchical). // hierarchical seeding
|
||||
max_nb_proxies(200). // first stop criterion
|
||||
min_error_drop(0.05). // second stop criterion
|
||||
nb_of_iterations(30)); // number of iterations after seeding
|
||||
nb_of_iterations(30). // number of iterations after seeding
|
||||
facet_proxy_map(fpxmap)); // output facet proxy-id map
|
||||
|
||||
// TODO: retrieve segments of the segmentation
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/vsa_mesh_approximation.h>
|
||||
#include <CGAL/mesh_approximation.h>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
|
||||
|
|
@ -18,12 +18,12 @@ int main()
|
|||
// The output will be an indexed triangle mesh
|
||||
std::vector<Kernel::Point_3> points;
|
||||
std::vector<std::vector<std::size_t> > triangles;
|
||||
|
||||
|
||||
// free function interface with named parameters
|
||||
CGAL::vsa_mesh_approximation(input,
|
||||
std::back_inserter(points),
|
||||
std::back_inserter(triangles),
|
||||
CGAL::Surface_mesh_approximation::parameters::max_nb_proxies(200));
|
||||
CGAL::mesh_approximation(input,
|
||||
CGAL::Surface_mesh_approximation::parameters::max_nb_proxies(200).
|
||||
anchor_points(std::back_inserter(points)). // anchor points
|
||||
indexed_triangles(std::back_inserter(triangles))); // indexed triangles
|
||||
|
||||
std::cout << "#vertices: " << points.size() << std::endl;
|
||||
std::cout << "#triangles: " << triangles.size() << std::endl;
|
||||
|
|
|
|||
|
|
@ -851,11 +851,9 @@ public:
|
|||
}
|
||||
|
||||
/*!
|
||||
* @brief Extract the approximated surface mesh.
|
||||
* @brief Extract the approximated indexed triangle surface.
|
||||
* @note If the extracted surface mesh contains non-manifold facets,
|
||||
* they are not built into the output polyhedron.
|
||||
* @tparam PolyhedronSurface should be `CGAL::Polyhedron_3`
|
||||
* @param[out] tm_out output triangle mesh
|
||||
* @param chord_error boundary approximation recursively split criterion
|
||||
* @param is_relative_to_chord set `true` if the chord_error is relative to the the chord length (relative sense),
|
||||
* otherwise it's relative to the average edge length (absolute sense).
|
||||
|
|
@ -864,9 +862,7 @@ public:
|
|||
* @param pca_plane set `true` if use PCA plane fitting, otherwise use the default area averaged plane parameters
|
||||
* @return `true` if the extracted surface mesh is manifold, `false` otherwise.
|
||||
*/
|
||||
template <typename PolyhedronSurface>
|
||||
bool extract_mesh(PolyhedronSurface &tm_out,
|
||||
const FT chord_error = FT(5.0),
|
||||
bool extract_mesh(const FT chord_error = FT(5.0),
|
||||
const bool is_relative_to_chord = false,
|
||||
const bool with_dihedral_angle = false,
|
||||
const bool optimize_anchor_location = true,
|
||||
|
|
@ -896,7 +892,9 @@ public:
|
|||
if (optimize_anchor_location)
|
||||
this->optimize_anchor_location();
|
||||
|
||||
return build_polyhedron_surface(tm_out);
|
||||
// check manifold
|
||||
CGAL::Polyhedron_3<Geom_traits> tm_test;
|
||||
return build_polyhedron_surface(tm_test);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -81,14 +81,6 @@ void get_proxy_map(const Approximation &approx, FacetProxyMap fproxymap) {
|
|||
template <typename Approximation>
|
||||
void get_proxy_map(const Approximation &, internal_np::vsa_no_output_t) {}
|
||||
|
||||
template <typename Approximation, typename OutputIterator>
|
||||
void get_anchor_vertices(const Approximation &approx, OutputIterator out_itr) {
|
||||
approx.anchor_vertices(out_itr);
|
||||
}
|
||||
|
||||
template <typename Approximation>
|
||||
void get_anchor_vertices(const Approximation &, internal_np::vsa_no_output_t) {}
|
||||
|
||||
template <typename Approximation, typename OutputIterator>
|
||||
void get_proxies(const Approximation &approx, OutputIterator out_itr) {
|
||||
approx.proxies(out_itr);
|
||||
|
|
@ -97,6 +89,21 @@ void get_proxies(const Approximation &approx, OutputIterator out_itr) {
|
|||
template <typename Approximation>
|
||||
void get_proxies(const Approximation &, internal_np::vsa_no_output_t) {}
|
||||
|
||||
template <typename Approximation, typename OutputIterator>
|
||||
void get_anchor_points(const Approximation &approx, OutputIterator out_itr) {
|
||||
approx.anchor_points(out_itr);
|
||||
}
|
||||
|
||||
template <typename Approximation>
|
||||
void get_anchor_points(const Approximation &, internal_np::vsa_no_output_t) {}
|
||||
|
||||
template <typename Approximation, typename OutputIterator>
|
||||
void get_indexed_triangles(const Approximation &approx, OutputIterator out_itr) {
|
||||
approx.indexed_triangles(out_itr);
|
||||
}
|
||||
|
||||
template <typename Approximation>
|
||||
void get_indexed_triangles(const Approximation &, internal_np::vsa_no_output_t) {}
|
||||
} //end of namespace CGAL
|
||||
|
||||
#endif //CGAL_NAMED_PARAMETERS_HELPERS_H
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@ CGAL_add_named_parameter(mesh_chord_error_t, mesh_chord_error, mesh_chord_error)
|
|||
// output parameters
|
||||
CGAL_add_named_parameter(facet_proxy_map_t, facet_proxy_map, facet_proxy_map)
|
||||
CGAL_add_named_parameter(proxies_t, proxies, proxies)
|
||||
CGAL_add_named_parameter(anchor_vertices_t, anchor_vertices, anchor_vertices)
|
||||
CGAL_add_named_parameter(output_mesh_t, output_mesh, output_mesh)
|
||||
CGAL_add_named_parameter(anchor_points_t, anchor_points, anchor_points)
|
||||
CGAL_add_named_parameter(indexed_triangles_t, indexed_triangles, indexed_triangles)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
#include <CGAL/internal/Surface_mesh_approximation/named_function_params.h>
|
||||
#include <CGAL/internal/Surface_mesh_approximation/named_params_helper.h>
|
||||
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/property_map.h>
|
||||
|
||||
#include <boost/graph/graph_traits.hpp>
|
||||
|
|
@ -26,16 +25,12 @@ namespace CGAL {
|
|||
* @tparam TriangleMesh model of `FaceListGraph`.
|
||||
* If `TriangleMesh` has an internal property map for `CGAL::face_index_t`,
|
||||
* and no `face_index_map` is given as a named parameter, then the internal one should be initialized.
|
||||
* @tparam AnchorPointOutputIterator a class model of `OutputIterator` with `GeomTraits::Point_3` value type
|
||||
* @tparam IndexedTriangleOutputIterator a class model of `OutputIterator` with `std::vector<std::size_t>` value type
|
||||
* @tparam NamedParameters a sequence of \ref namedparameters
|
||||
*
|
||||
* @param tm a triangle surface mesh to be approximated
|
||||
* @param[out] apts_out_itr output iterator over anchor points
|
||||
* @param[out] tris_out_itr output iterator over indexed triangles (triplets of integers referring to anchor points)
|
||||
* @param np optional sequence of \ref namedparameters among the ones listed below
|
||||
* @return `true` if the indexed triangles represent a valid 2-manifold, oriented surface mesh, and `false` otherwise.
|
||||
*
|
||||
*
|
||||
* \cgalNamedParamsBegin
|
||||
* \cgalParamBegin{geom_traits} a geometric traits class instance, model of `Kernel`.
|
||||
* Exact constructions kernels are not supported by this function.
|
||||
|
|
@ -55,25 +50,21 @@ namespace CGAL {
|
|||
* \cgalParamEnd
|
||||
* \cgalParamBegin{mesh_chord_error} maximum chord approximation error used for meshing.
|
||||
* \cgalParamEnd
|
||||
* \cgalParamBegin{face_proxy_map} property map containing the assigned proxy index of each face of input mesh `tm`.
|
||||
* \cgalParamBegin{face_proxy_map} a ReadWritePropertyMap with
|
||||
* `boost::graph_traits<TriangleMesh>::%face_descriptor` as key and `std::size_t` as value type.
|
||||
* A proxy is a set of connected facets which are placed under the same proxy patch (see \cgalFigureRef{iterations}).
|
||||
* The proxy-id is contiguous in range [0, number_of_proxies - 1].
|
||||
* \cgalParamEnd
|
||||
* \cgalParamBegin{proxies} output iterator over proxies.
|
||||
* \cgalParamEnd
|
||||
* \cgalParamBegin{anchor_vertices} output iterator over anchor vertices, defined on the input mesh `tm`.
|
||||
* \cgalParamBegin{anchor_points} output iterator over anchor points.
|
||||
* \cgalParamEnd
|
||||
* \cgalParamBegin{output_mesh} polyhedral surface mesh derived from the indexed facet set. The polyhedron is not empty only
|
||||
* when the indexed face set represents a 2-manifold, oriented surface triangle mesh.
|
||||
* \cgalParamBegin{indexed_triangles} output iterator over indexed triangles.
|
||||
* \cgalParamEnd
|
||||
* \cgalNamedParamsEnd
|
||||
*/
|
||||
template <typename TriangleMesh,
|
||||
typename AnchorPointOutputIterator,
|
||||
typename IndexedTriangleOutputIterator,
|
||||
typename NamedParameters>
|
||||
bool vsa_mesh_approximation(const TriangleMesh &tm,
|
||||
AnchorPointOutputIterator apts_out_itr,
|
||||
IndexedTriangleOutputIterator tris_out_itr,
|
||||
const NamedParameters &np)
|
||||
template <typename TriangleMesh, typename NamedParameters>
|
||||
bool mesh_approximation(const TriangleMesh &tm, const NamedParameters &np)
|
||||
{
|
||||
using boost::get_param;
|
||||
using boost::choose_param;
|
||||
|
|
@ -119,6 +110,7 @@ bool vsa_mesh_approximation(const TriangleMesh &tm,
|
|||
<< ", #relx = " << nb_of_relaxations << std::endl;
|
||||
#endif
|
||||
|
||||
// get proxy map
|
||||
typedef typename boost::lookup_named_param_def<
|
||||
internal_np::facet_proxy_map_t,
|
||||
NamedParameters,
|
||||
|
|
@ -127,26 +119,7 @@ bool vsa_mesh_approximation(const TriangleMesh &tm,
|
|||
get_param(np, internal_np::facet_proxy_map), internal_np::vsa_no_output);
|
||||
get_proxy_map(approx, fproxymap);
|
||||
|
||||
typedef CGAL::Polyhedron_3<Geom_traits> PolyhedronSurface;
|
||||
PolyhedronSurface tmp_poly;
|
||||
PolyhedronSurface * const tm_out = choose_param(get_param(np, internal_np::output_mesh), &tmp_poly);
|
||||
const FT chord_error = choose_param(get_param(np, internal_np::mesh_chord_error), FT(5.0));
|
||||
const bool is_manifold = approx.extract_mesh(*tm_out, chord_error);
|
||||
|
||||
// get anchor points
|
||||
approx.anchor_points(apts_out_itr);
|
||||
|
||||
// get indexed triangles
|
||||
approx.indexed_triangles(tris_out_itr);
|
||||
|
||||
typedef typename boost::lookup_named_param_def<
|
||||
internal_np::anchor_vertices_t,
|
||||
NamedParameters,
|
||||
internal_np::vsa_no_output_t>::type AnchorVertexOutItr;
|
||||
AnchorVertexOutItr avtx_out_itr = choose_param(
|
||||
get_param(np, internal_np::anchor_vertices) , internal_np::vsa_no_output);
|
||||
get_anchor_vertices(approx, avtx_out_itr);
|
||||
|
||||
// get proxies
|
||||
typedef typename boost::lookup_named_param_def <
|
||||
internal_np::proxies_t,
|
||||
NamedParameters,
|
||||
|
|
@ -155,6 +128,28 @@ bool vsa_mesh_approximation(const TriangleMesh &tm,
|
|||
get_param(np, internal_np::proxies), internal_np::vsa_no_output);
|
||||
get_proxies(approx, pxies_out_itr);
|
||||
|
||||
// meshing
|
||||
const FT chord_error = choose_param(get_param(np, internal_np::mesh_chord_error), FT(5.0));
|
||||
const bool is_manifold = approx.extract_mesh(chord_error);
|
||||
|
||||
// get anchor points
|
||||
typedef typename boost::lookup_named_param_def<
|
||||
internal_np::anchor_points_t,
|
||||
NamedParameters,
|
||||
internal_np::vsa_no_output_t>::type Anchor_point_output_iterator;
|
||||
Anchor_point_output_iterator apts_out_itr = choose_param(
|
||||
get_param(np, internal_np::anchor_points) , internal_np::vsa_no_output);
|
||||
get_anchor_points(approx, apts_out_itr);
|
||||
|
||||
// get indexed triangles
|
||||
typedef typename boost::lookup_named_param_def<
|
||||
internal_np::indexed_triangles_t,
|
||||
NamedParameters,
|
||||
internal_np::vsa_no_output_t>::type Indexed_triangles_output_iterator;
|
||||
Indexed_triangles_output_iterator tris_out_itr = choose_param(
|
||||
get_param(np, internal_np::indexed_triangles) , internal_np::vsa_no_output);
|
||||
get_indexed_triangles(approx, tris_out_itr);
|
||||
|
||||
return is_manifold;
|
||||
}
|
||||
|
||||
|
|
@ -1,124 +0,0 @@
|
|||
#ifndef CGAL_SURFACE_MESH_APPROXIMATION_VSA_MESH_SEGMENTATION_H
|
||||
#define CGAL_SURFACE_MESH_APPROXIMATION_VSA_MESH_SEGMENTATION_H
|
||||
|
||||
#include <CGAL/license/Surface_mesh_approximation.h>
|
||||
|
||||
|
||||
#include <CGAL/vsa_metrics.h>
|
||||
#include <CGAL/VSA_approximation.h>
|
||||
#include <CGAL/internal/Surface_mesh_approximation/named_function_params.h>
|
||||
#include <CGAL/internal/Surface_mesh_approximation/named_params_helper.h>
|
||||
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/property_map.h>
|
||||
|
||||
#include <boost/graph/graph_traits.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
* \ingroup PkgTSMA
|
||||
* @brief Function segments the input mesh into planar parts.
|
||||
* This function segments the input triangle surface mesh by the Variational Shape Approximation algorithm.
|
||||
* It fills a property map which associates a segment-id (in [0, number_of_segments -1])
|
||||
* or a proxy-id (in [0, number_of_proxies - 1]) to each facet.
|
||||
* A segment is a set of connected facets which are placed under the same proxy patch (see \cgalFigureRef{iterations}).
|
||||
*
|
||||
* @tparam TriangleMesh model of `FaceListGraph`.
|
||||
* If `TriangleMesh` has an internal property map for `CGAL::face_index_t`,
|
||||
* and no `face_index_map` is given
|
||||
* as a named parameter, then the internal one should be initialized
|
||||
* @tparam SegmentPropertyMap a ReadWritePropertyMap with
|
||||
* `boost::graph_traits<TriangleMesh>::%face_descriptor` as key and `std::size_t` as value type
|
||||
* @tparam NamedParameters a sequence of \ref namedparameters
|
||||
*
|
||||
* @param tm a triangle surface mesh to be segmented
|
||||
* @param[out] segment_ids the segment or proxy id of each facet
|
||||
* @param np optional sequence of \ref namedparameters among the ones listed below
|
||||
*
|
||||
* \cgalNamedParamsBegin
|
||||
* \cgalParamBegin{geom_traits} a geometric traits class instance, model of `Kernel`.
|
||||
* Exact constructions kernels are not supported by this function.
|
||||
* \cgalParamEnd
|
||||
* \cgalParamBegin{vertex_point_map} property map with the points associated
|
||||
* to the vertices of `tm`. Instance of a class model of `ReadWritePropertyMap`.
|
||||
* \cgalParamEnd
|
||||
* \cgalParamBegin{seeding_method} selection of seeding method.
|
||||
* \cgalParamEnd
|
||||
* \cgalParamBegin{max_nb_proxies} maximum number of proxies to approximate the geometry.
|
||||
* \cgalParamEnd
|
||||
* \cgalParamBegin{min_error_drop} minimum error drop of the approximation.
|
||||
* \cgalParamEnd
|
||||
* \cgalParamBegin{nb_of_iterations} number of partitioning and fitting iterations after seeding.
|
||||
* \cgalParamEnd
|
||||
* \cgalParamBegin{nb_of_relaxations} number of relaxations interleaved within seeding.
|
||||
* \cgalParamEnd
|
||||
* \cgalParamBegin{proxies} output iterator over proxies
|
||||
* \cgalParamEnd
|
||||
* \cgalNamedParamsEnd
|
||||
*/
|
||||
template <typename TriangleMesh,
|
||||
typename SegmentPropertyMap,
|
||||
typename NamedParameters>
|
||||
void vsa_mesh_segmentation(const TriangleMesh &tm,
|
||||
const SegmentPropertyMap segment_ids, const NamedParameters &np)
|
||||
{
|
||||
using boost::get_param;
|
||||
using boost::choose_param;
|
||||
|
||||
typedef typename GetGeomTraits<TriangleMesh, NamedParameters>::type Geom_traits;
|
||||
typedef typename Geom_traits::FT FT;
|
||||
|
||||
typedef typename GetVertexPointMap<TriangleMesh, NamedParameters>::type Vertex_point_map;
|
||||
Vertex_point_map point_pmap = choose_param(get_param(np, internal_np::vertex_point),
|
||||
get_property_map(vertex_point, const_cast<TriangleMesh &>(tm)));
|
||||
|
||||
typedef CGAL::VSA_approximation<TriangleMesh, Vertex_point_map> L21_approx;
|
||||
typedef typename L21_approx::Error_metric L21_metric;
|
||||
typedef typename L21_approx::Proxy_fitting L21_proxy_fitting;
|
||||
|
||||
L21_approx approx(tm, point_pmap);
|
||||
L21_metric l21_metric(tm);
|
||||
L21_proxy_fitting l21_fitting(tm);
|
||||
approx.set_metric(l21_metric, l21_fitting);
|
||||
|
||||
// default hierarchical seeding
|
||||
CGAL::Approximation_seeding_tag method = choose_param(
|
||||
get_param(np, internal_np::seeding_method), CGAL::Hierarchical);
|
||||
boost::optional<std::size_t> max_nb_proxies = choose_param(
|
||||
get_param(np, internal_np::max_nb_proxies), boost::optional<std::size_t>());
|
||||
boost::optional<FT> min_error_drop = choose_param(
|
||||
get_param(np, internal_np::min_error_drop), boost::optional<FT>());
|
||||
std::size_t nb_of_relaxations = choose_param(get_param(np, internal_np::nb_of_relaxations), 5);
|
||||
approx.seeding(method, max_nb_proxies, min_error_drop, nb_of_relaxations);
|
||||
|
||||
// reasonable default number of iterations
|
||||
std::size_t nb_of_iterations_default = max_nb_proxies ? num_faces(tm) / *max_nb_proxies : 30;
|
||||
nb_of_iterations_default = (std::min)((std::max)(
|
||||
nb_of_iterations_default, static_cast<std::size_t>(20)), static_cast<std::size_t>(60));
|
||||
const std::size_t nb_of_iterations = choose_param(
|
||||
get_param(np, internal_np::nb_of_iterations), nb_of_iterations_default);
|
||||
|
||||
approx.run(nb_of_iterations);
|
||||
|
||||
#ifdef CGAL_SURFACE_MESH_APPROXIMATION_DEBUG
|
||||
std::cout << "#px = " << approx.get_proxies_sizes()
|
||||
<< ", #itr = " << nb_of_iterations
|
||||
<< ", #relx = " << nb_of_relaxations << std::endl;
|
||||
#endif
|
||||
|
||||
approx.proxy_map(segment_ids);
|
||||
|
||||
typedef typename boost::lookup_named_param_def <
|
||||
internal_np::proxies_t,
|
||||
NamedParameters,
|
||||
internal_np::vsa_no_output_t>::type ProxiesOutItr;
|
||||
ProxiesOutItr pxies_out_itr = choose_param(
|
||||
get_param(np, internal_np::proxies), internal_np::vsa_no_output);
|
||||
get_proxies(approx, pxies_out_itr);
|
||||
}
|
||||
|
||||
} // end namespace CGAL
|
||||
|
||||
#endif // CGAL_SURFACE_MESH_APPROXIMATION_VSA_MESH_SEGMENTATION_H
|
||||
|
|
@ -89,8 +89,7 @@ int main()
|
|||
|
||||
// extract the approximation polyhedron
|
||||
std::cout << "meshing" << std::endl;
|
||||
Polyhedron out_mesh;
|
||||
if (approx.extract_mesh(out_mesh, FT(1.0)))
|
||||
if (approx.extract_mesh(FT(1.0)))
|
||||
std::cout << "manifold." << std::endl;
|
||||
else
|
||||
std::cout << "non-manifold" << std::endl;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
|
||||
#include <CGAL/vsa_mesh_approximation.h>
|
||||
#include <CGAL/mesh_approximation.h>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic;
|
||||
typedef CGAL::Simple_cartesian<double> Sckernel;
|
||||
|
|
@ -29,14 +29,13 @@ int test() {
|
|||
std::vector<typename K::Point_3> points;
|
||||
std::vector<std::vector<std::size_t> > triangles;
|
||||
|
||||
CGAL::vsa_mesh_approximation(tm,
|
||||
std::back_inserter(points),
|
||||
std::back_inserter(triangles),
|
||||
CGAL::mesh_approximation(tm,
|
||||
CGAL::Surface_mesh_approximation::parameters::max_nb_proxies(6).
|
||||
nb_of_iterations(30).
|
||||
nb_of_relaxations(5).
|
||||
mesh_chord_error(0.5).
|
||||
output_mesh(&out_mesh));
|
||||
anchor_points(std::back_inserter(points)).
|
||||
indexed_triangles(std::back_inserter(triangles)));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@
|
|||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
|
||||
#include <CGAL/IO/Polyhedron_iostream.h>
|
||||
#include <CGAL/vsa_mesh_approximation.h>
|
||||
#include <CGAL/mesh_approximation.h>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
|
||||
|
||||
/**
|
||||
* This file tests the free function CGAL::vsa_mesh_approximation.
|
||||
* This file tests the free function CGAL::mesh_approximation.
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
|
|
@ -23,16 +23,13 @@ int main()
|
|||
}
|
||||
|
||||
Polyhedron out_mesh;
|
||||
std::vector<std::vector<std::size_t> > triangles;
|
||||
std::vector<Kernel::Point_3> points;
|
||||
std::list<Polyhedron::Vertex_handle> anchors;
|
||||
std::vector<CGAL::Plane_proxy<Kernel> > proxies;
|
||||
std::map<Polyhedron::Facet_handle, std::size_t> fidxmap;
|
||||
boost::associative_property_map<std::map<Polyhedron::Facet_handle, std::size_t> > fpxmap(fidxmap);
|
||||
std::vector<CGAL::Plane_proxy<Kernel> > proxies;
|
||||
std::vector<Kernel::Point_3> points;
|
||||
std::vector<std::vector<std::size_t> > triangles;
|
||||
|
||||
CGAL::vsa_mesh_approximation(mesh,
|
||||
std::back_inserter(points),
|
||||
std::back_inserter(triangles),
|
||||
CGAL::mesh_approximation(mesh,
|
||||
CGAL::Surface_mesh_approximation::parameters::seeding_method(CGAL::Incremental).
|
||||
max_nb_proxies(6).
|
||||
nb_of_iterations(30).
|
||||
|
|
@ -40,14 +37,13 @@ int main()
|
|||
mesh_chord_error(0.5).
|
||||
facet_proxy_map(fpxmap).
|
||||
proxies(std::back_inserter(proxies)).
|
||||
anchor_vertices(std::back_inserter(anchors)).
|
||||
output_mesh(&out_mesh));
|
||||
anchor_points(std::back_inserter(points)).
|
||||
indexed_triangles(std::back_inserter(triangles)));
|
||||
|
||||
std::cout << "#triangles " << triangles.size() << std::endl;
|
||||
std::cout << "#vertices " << points.size() << std::endl;
|
||||
std::cout << "#anchor_vertices " << anchors.size() << std::endl;
|
||||
std::cout << "#proxies " << proxies.size() << std::endl;
|
||||
std::cout << "#fpxmap " << fidxmap.size() << std::endl;
|
||||
std::cout << "#proxies " << proxies.size() << std::endl;
|
||||
std::cout << "#vertices " << points.size() << std::endl;
|
||||
std::cout << "#triangles " << triangles.size() << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/vsa_mesh_segmentation.h>
|
||||
#include <CGAL/mesh_approximation.h>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
typedef CGAL::Plane_proxy<Kernel> Plane_proxy;
|
||||
|
|
@ -13,7 +13,7 @@ typedef boost::unordered_map<face_descriptor, std::size_t> Facet_index_map;
|
|||
typedef boost::associative_property_map<Facet_index_map> Facet_proxy_pmap;
|
||||
|
||||
/**
|
||||
* This file tests the free function CGAL::vsa_mesh_segmentation.
|
||||
* This file tests the free function CGAL::mesh_approximation.
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
|
|
@ -32,13 +32,13 @@ int main()
|
|||
std::vector<Plane_proxy> proxies;
|
||||
|
||||
// free function interface with named parameters
|
||||
CGAL::vsa_mesh_segmentation(input,
|
||||
fpxmap, // output indexed face set
|
||||
CGAL::mesh_approximation(input,
|
||||
CGAL::Surface_mesh_approximation::parameters::seeding_method(CGAL::Hierarchical). // hierarchical seeding
|
||||
max_nb_proxies(200). // both maximum number of proxies stop criterion,
|
||||
min_error_drop(0.05). // and minimum error drop stop criterion are specified
|
||||
nb_of_iterations(30). // number of clustering iterations after seeding
|
||||
nb_of_relaxations(5). // number of relaxations in seeding
|
||||
facet_proxy_map(fpxmap). // output indexed face set
|
||||
proxies(std::back_inserter(proxies))); // number of iterations after seeding
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -43,8 +43,7 @@ bool test_manifold(const char *file_name, const FT drop = FT(1e-8))
|
|||
std::cout << "#proxies " << approx.proxies_size() << std::endl;
|
||||
|
||||
// meshing
|
||||
Polyhedron mesh_out;
|
||||
if (approx.extract_mesh(mesh_out)) {
|
||||
if (approx.extract_mesh()) {
|
||||
std::cout << "Succeeded." << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,10 +104,9 @@ int main()
|
|||
if (approx.proxies_size() != 20)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
// extract the approximation polyhedron
|
||||
// extract the approximation
|
||||
std::cout << "meshing" << std::endl;
|
||||
Polyhedron out_mesh;
|
||||
if (approx.extract_mesh(out_mesh))
|
||||
if (approx.extract_mesh())
|
||||
std::cout << "manifold." << std::endl;
|
||||
else
|
||||
std::cout << "non-manifold" << std::endl;
|
||||
|
|
|
|||
Loading…
Reference in New Issue