Skip to content

Commit

Permalink
simplify example files
Browse files Browse the repository at this point in the history
  • Loading branch information
aboudev committed Jul 24, 2017
1 parent f82a6e9 commit 7d001d1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 83 deletions.
@@ -1,31 +1,18 @@
#include <iostream>
#include <fstream>

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/property_map.h>

#include <iostream>
#include <fstream>
#include <CGAL/vsa_mesh_approximation.h>
#include <CGAL/vsa_mesh_approximation_traits.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef Kernel::FT FT;
typedef Kernel::Vector_3 Vector_3;
typedef Kernel::Point_3 Point_3;
typedef Polyhedron::Facet_const_handle Facet_const_handle;
typedef Polyhedron::Halfedge_const_handle Halfedge_const_handle;
typedef Polyhedron::Facet_const_iterator Facet_const_iterator;
typedef boost::associative_property_map<std::map<Facet_const_handle, Vector_3> > FacetNormalMap;
typedef boost::associative_property_map<std::map<Facet_const_handle, FT> > FacetAreaMap;
typedef boost::property_map<Polyhedron, boost::vertex_point_t>::type VertexPointMap;

typedef CGAL::PlaneProxy<Polyhedron> PlaneProxy;
typedef CGAL::L21Metric<PlaneProxy, FacetNormalMap, FacetAreaMap> L21Metric;
typedef CGAL::L21ProxyFitting<PlaneProxy, L21Metric, FacetNormalMap, FacetAreaMap> L21ProxyFitting;
typedef CGAL::PlaneFitting<Polyhedron, FacetAreaMap, FacetNormalMap, VertexPointMap> PlaneFitting;
typedef CGAL::L21ApproximationTrait<PlaneProxy, Polyhedron, L21Metric, L21ProxyFitting, PlaneFitting, VertexPointMap, FacetNormalMap, FacetAreaMap> L21ApproximationTrait;
typedef std::map<Facet_const_handle, std::size_t> Facet_id_map;

int main(int argc, char *argv[])
{
Expand All @@ -40,29 +27,11 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
}

// construct facet normal & area map
std::map<Facet_const_handle, Vector_3> facet_normals;
std::map<Facet_const_handle, FT> facet_areas;
for(Facet_const_iterator fitr = mesh.facets_begin(); fitr != mesh.facets_end(); ++fitr) {
const Halfedge_const_handle he = fitr->halfedge();
const Point_3 p1 = he->opposite()->vertex()->point();
const Point_3 p2 = he->vertex()->point();
const Point_3 p3 = he->next()->vertex()->point();
Vector_3 normal = CGAL::unit_normal(p1, p2, p3);
facet_normals.insert(std::pair<Facet_const_handle, Vector_3>(fitr, normal));
FT area(std::sqrt(CGAL::to_double(CGAL::squared_area(p1, p2, p3))));
facet_areas.insert(std::pair<Facet_const_handle, FT>(fitr, area));
}
FacetNormalMap normal_pmap(facet_normals);
FacetAreaMap area_pmap(facet_areas);
VertexPointMap point_pmap = get(boost::vertex_point, const_cast<Polyhedron &>(mesh));

// create a property-map for segment-ids
typedef std::map<Facet_const_handle, std::size_t> Facet_id_map;
Facet_id_map internal_facet_id_map;
// create a property-map for facet proxy index map
Facet_id_map facet_proxy_map;
for (Facet_const_iterator fitr = mesh.facets_begin(); fitr != mesh.facets_end(); ++fitr)
internal_facet_id_map.insert(std::pair<Facet_const_handle, std::size_t>(fitr, 0));
boost::associative_property_map<Facet_id_map> proxy_patch_map(internal_facet_id_map);
facet_proxy_map.insert(std::pair<Facet_const_handle, std::size_t>(fitr, 0));
boost::associative_property_map<Facet_id_map> f_proxy_pmap(facet_proxy_map);

const std::size_t num_proxies = std::atoi(argv[3]);
const std::size_t num_iterations = std::atoi(argv[4]);
Expand All @@ -73,10 +42,9 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;

CGAL::vsa_approximate_and_extract(mesh,
proxy_patch_map,
f_proxy_pmap,
tris,
anchor_pos,
L21ApproximationTrait(mesh, point_pmap, normal_pmap, area_pmap),
init,
num_proxies,
num_iterations);
Expand Down
@@ -1,31 +1,14 @@
#include <iostream>
#include <fstream>

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/property_map.h>

#include <iostream>
#include <fstream>
#include <CGAL/vsa_mesh_approximation.h>
#include <CGAL/vsa_mesh_approximation_traits.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef Kernel::FT FT;
typedef Kernel::Vector_3 Vector_3;
typedef Kernel::Point_3 Point_3;
typedef Polyhedron::Facet_const_handle Facet_const_handle;
typedef Polyhedron::Halfedge_const_handle Halfedge_const_handle;
typedef Polyhedron::Facet_const_iterator Facet_const_iterator;
typedef boost::associative_property_map<std::map<Facet_const_handle, Vector_3> > FacetNormalMap;
typedef boost::associative_property_map<std::map<Facet_const_handle, FT> > FacetAreaMap;
typedef boost::property_map<Polyhedron, boost::vertex_point_t>::type VertexPointMap;

typedef CGAL::PlaneProxy<Polyhedron> PlaneProxy;
typedef CGAL::L21Metric<PlaneProxy, FacetNormalMap, FacetAreaMap> L21Metric;
typedef CGAL::L21ProxyFitting<PlaneProxy, L21Metric, FacetNormalMap, FacetAreaMap> L21ProxyFitting;
typedef CGAL::PlaneFitting<Polyhedron, FacetAreaMap, FacetNormalMap, VertexPointMap> PlaneFitting;
typedef CGAL::L21ApproximationTrait<PlaneProxy, Polyhedron, L21Metric, L21ProxyFitting, PlaneFitting, VertexPointMap, FacetNormalMap, FacetAreaMap> L21ApproximationTrait;

int main(int argc, char *argv[])
{
Expand All @@ -40,23 +23,6 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
}

// construct facet normal & area map
std::map<Facet_const_handle, Vector_3> facet_normals;
std::map<Facet_const_handle, FT> facet_areas;
for(Facet_const_iterator fitr = mesh.facets_begin(); fitr != mesh.facets_end(); ++fitr) {
const Halfedge_const_handle he = fitr->halfedge();
const Point_3 p1 = he->opposite()->vertex()->point();
const Point_3 p2 = he->vertex()->point();
const Point_3 p3 = he->next()->vertex()->point();
Vector_3 normal = CGAL::unit_normal(p1, p2, p3);
facet_normals.insert(std::pair<Facet_const_handle, Vector_3>(fitr, normal));
FT area(std::sqrt(CGAL::to_double(CGAL::squared_area(p1, p2, p3))));
facet_areas.insert(std::pair<Facet_const_handle, FT>(fitr, area));
}
FacetNormalMap normal_pmap(facet_normals);
FacetAreaMap area_pmap(facet_areas);
VertexPointMap point_pmap = get(boost::vertex_point, const_cast<Polyhedron &>(mesh));

const std::size_t num_proxies = std::atoi(argv[3]);
const std::size_t num_iterations = std::atoi(argv[4]);
std::vector<int> tris;
Expand All @@ -68,7 +34,6 @@ int main(int argc, char *argv[])
CGAL::vsa_extract(mesh,
tris,
anchor_pos,
L21ApproximationTrait(mesh, point_pmap, normal_pmap, area_pmap),
init,
num_proxies,
num_iterations);
Expand Down
@@ -1,13 +1,12 @@
#include <iostream>
#include <fstream>

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/property_map.h>

#include <iostream>
#include <fstream>
#include <CGAL/vsa_mesh_approximation.h>
#include <CGAL/vsa_mesh_approximation_traits.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
Expand Down

0 comments on commit 7d001d1

Please sign in to comment.