Skip to content

Commit

Permalink
fix examples accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
aboudev committed Aug 25, 2017
1 parent a30a107 commit 62b1aa9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
Expand Up @@ -6,17 +6,16 @@
#include <CGAL/IO/Polyhedron_iostream.h>

#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
#include <CGAL/VSA_metrics.h>
#include <CGAL/VSA_approximation.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point_3;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef boost::property_map<Polyhedron, boost::vertex_point_t>::type VertexPointMap;

typedef CGAL::PlaneProxy<Polyhedron> PlaneProxy;
typedef CGAL::L2Metric<Polyhedron> L2Metric;
typedef CGAL::L2ProxyFitting<Polyhedron> L2ProxyFitting;
typedef CGAL::VSA_approximation<Polyhedron, PlaneProxy, L2Metric, L2ProxyFitting> VSA;
typedef CGAL::L21Metric<Polyhedron> L21Metric;
typedef CGAL::L21ProxyFitting<Polyhedron> L21ProxyFitting;
typedef CGAL::VSA_approximation<Polyhedron, VertexPointMap> VSAL21;

int main()
{
Expand All @@ -28,35 +27,34 @@ int main()
return EXIT_FAILURE;
}

L2Metric metric(input);
L2ProxyFitting proxy_fitting(input);

// create VSA L2 metric approximation algorithm instance
VSA l2_approx;
l2_approx.set_mesh(input);
l2_approx.set_error_metric(metric);
l2_approx.set_proxy_fitting(proxy_fitting);
// create VSA L21 metric approximation algorithm instance
VSAL21 l21_approx(input,
get(boost::vertex_point, const_cast<Polyhedron &>(input)));
// set error and fitting functors
L21Metric metric(input);
L21ProxyFitting proxy_fitting(input);
l21_approx.set_metric(metric, proxy_fitting);

// initialize proxies randomly on the mesh
l2_approx.init_proxies(100, VSA::RandomInit);
l21_approx.init_proxies(100, VSAL21::RandomInit);

// run the iteration to minimize the error
for (std::size_t i = 0; i < 30; ++i)
l2_approx.run_one_step();
l21_approx.run_one_step();

// add proxies to the one with the maximum fitting error
l2_approx.add_proxies(VSA::IncrementalInit, 3);
l21_approx.add_proxies(VSAL21::IncrementalInit, 3);
for (std::size_t i = 0; i < 10; ++i)
l2_approx.run_one_step();
l21_approx.run_one_step();

// merge and teleport the proxies from local minimal
l2_approx.teleport_proxies(2);
l21_approx.teleport_proxies(2);
for (std::size_t i = 0; i < 10; ++i)
l2_approx.run_one_step();
l21_approx.run_one_step();

// extract the approximation polyhedron
Polyhedron output;
l2_approx.meshing(output);
l21_approx.meshing(output);

return EXIT_SUCCESS;
}
Expand Up @@ -18,6 +18,8 @@ typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef Polyhedron::Facet_handle Facet_handle;
typedef Polyhedron::Halfedge_handle Halfedge_handle;
typedef Polyhedron::Facet_iterator Facet_iterator;

typedef boost::property_map<Polyhedron, boost::vertex_point_t>::type VertexPointMap;
typedef boost::associative_property_map<std::map<Facet_handle, FT> > FacetAreaMap;
typedef boost::associative_property_map<std::map<Facet_handle, Point> > FacetCenterMap;

Expand Down Expand Up @@ -75,7 +77,8 @@ struct PointProxyFitting {
const FacetCenterMap center_pmap;
const FacetAreaMap area_pmap;
};
typedef CGAL::VSA_approximation<Polyhedron, PointProxy, CompactMetric, PointProxyFitting> CompactVSA;
typedef CGAL::VSA_approximation<Polyhedron, VertexPointMap,
PointProxy, CompactMetric, PointProxyFitting> CompactVSA;

int main()
{
Expand Down Expand Up @@ -103,15 +106,14 @@ int main()
FacetAreaMap area_pmap(facet_areas);
FacetCenterMap center_pmap(facet_centers);

// create compact metric approximation algorithm instance
CompactVSA compact_approx(input,
get(boost::vertex_point, const_cast<Polyhedron &>(input)));

// construct metric and fitting functors
CompactMetric metric(center_pmap);
PointProxyFitting proxy_fitting(center_pmap, area_pmap);

// create compact metric approximation algorithm instance
CompactVSA compact_approx;
compact_approx.set_mesh(input);
compact_approx.set_error_metric(metric);
compact_approx.set_proxy_fitting(proxy_fitting);
compact_approx.set_metric(metric, proxy_fitting);

// using 200 proxies to approximate the shape
compact_approx.init_proxies(200, CompactVSA::HierarchicalInit);
Expand Down

0 comments on commit 62b1aa9

Please sign in to comment.