mirror of https://github.com/CGAL/cgal
fix examples
This commit is contained in:
parent
4cf7bf4e4b
commit
f031ae3800
|
|
@ -10,14 +10,14 @@
|
||||||
|
|
||||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||||
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
|
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
|
||||||
typedef Polyhedron::Facet_const_handle Facet_const_handle;
|
typedef Polyhedron::Facet_handle Facet_handle;
|
||||||
typedef Polyhedron::Facet_const_iterator Facet_const_iterator;
|
typedef Polyhedron::Facet_iterator Facet_iterator;
|
||||||
typedef std::map<Facet_const_handle, std::size_t> Facet_id_map;
|
typedef std::map<Facet_handle, std::size_t> Facet_id_map;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (argc < 5)
|
if (argc < 5)
|
||||||
return 0;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
// create and read Polyhedron
|
// create and read Polyhedron
|
||||||
Polyhedron mesh;
|
Polyhedron mesh;
|
||||||
|
|
@ -29,9 +29,9 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
// create a property-map for facet proxy index map
|
// create a property-map for facet proxy index map
|
||||||
Facet_id_map facet_proxy_map;
|
Facet_id_map facet_proxy_map;
|
||||||
for (Facet_const_iterator fitr = mesh.facets_begin(); fitr != mesh.facets_end(); ++fitr)
|
for (Facet_iterator fitr = mesh.facets_begin(); fitr != mesh.facets_end(); ++fitr)
|
||||||
facet_proxy_map.insert(std::pair<Facet_const_handle, std::size_t>(fitr, 0));
|
facet_proxy_map.insert(std::pair<Facet_handle, std::size_t>(fitr, 0));
|
||||||
boost::associative_property_map<Facet_id_map> f_proxy_pmap(facet_proxy_map);
|
boost::associative_property_map<Facet_id_map> proxy_pmap(facet_proxy_map);
|
||||||
|
|
||||||
const std::size_t num_proxies = std::atoi(argv[3]);
|
const std::size_t num_proxies = std::atoi(argv[3]);
|
||||||
const std::size_t num_iterations = std::atoi(argv[4]);
|
const std::size_t num_iterations = std::atoi(argv[4]);
|
||||||
|
|
@ -42,7 +42,7 @@ int main(int argc, char *argv[])
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
CGAL::vsa_approximate_and_extract(mesh,
|
CGAL::vsa_approximate_and_extract(mesh,
|
||||||
f_proxy_pmap,
|
proxy_pmap,
|
||||||
tris,
|
tris,
|
||||||
anchor_pos,
|
anchor_pos,
|
||||||
init,
|
init,
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (argc < 5)
|
if (argc < 5)
|
||||||
return 0;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
// create and read Polyhedron
|
// create and read Polyhedron
|
||||||
Polyhedron mesh;
|
Polyhedron mesh;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ typedef CGAL::PCAPlaneFitting<Polyhedron_3> PCAPlaneFitting;
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (argc < 5)
|
if (argc < 5)
|
||||||
return 0;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
// read Polyhedron
|
// read Polyhedron
|
||||||
Polyhedron_3 mesh;
|
Polyhedron_3 mesh;
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,12 @@ typedef Kernel::FT FT;
|
||||||
typedef Kernel::Vector_3 Vector_3;
|
typedef Kernel::Vector_3 Vector_3;
|
||||||
typedef Kernel::Point_3 Point_3;
|
typedef Kernel::Point_3 Point_3;
|
||||||
typedef Polyhedron::Facet_handle Facet_handle;
|
typedef Polyhedron::Facet_handle Facet_handle;
|
||||||
typedef Polyhedron::Facet_const_handle Facet_const_handle;
|
typedef Polyhedron::Halfedge_handle Halfedge_handle;
|
||||||
typedef Polyhedron::Halfedge_const_handle Halfedge_const_handle;
|
typedef Polyhedron::Facet_iterator Facet_iterator;
|
||||||
typedef Polyhedron::Facet_const_iterator Facet_const_iterator;
|
typedef boost::associative_property_map<std::map<Facet_handle, Vector_3> > FacetNormalMap;
|
||||||
typedef boost::associative_property_map<std::map<Facet_const_handle, Vector_3> > FacetNormalMap;
|
typedef boost::associative_property_map<std::map<Facet_handle, FT> > FacetAreaMap;
|
||||||
typedef boost::associative_property_map<std::map<Facet_const_handle, FT> > FacetAreaMap;
|
typedef boost::associative_property_map<std::map<Facet_handle, Point_3> > FacetCenterMap;
|
||||||
typedef boost::associative_property_map<std::map<Facet_const_handle, Point_3> > FacetCenterMap;
|
typedef std::map<Facet_handle, std::size_t> Facet_id_map;
|
||||||
|
|
||||||
struct PointProxy {
|
struct PointProxy {
|
||||||
Facet_handle seed;
|
Facet_handle seed;
|
||||||
|
|
@ -32,7 +32,7 @@ struct CompactMetric {
|
||||||
CompactMetric(const FacetCenterMap &_center_pmap)
|
CompactMetric(const FacetCenterMap &_center_pmap)
|
||||||
: center_pmap(_center_pmap) {}
|
: center_pmap(_center_pmap) {}
|
||||||
|
|
||||||
FT operator()(const Facet_const_handle &f, const PointProxy &px) const {
|
FT operator()(const Facet_handle &f, const PointProxy &px) const {
|
||||||
return FT(std::sqrt(CGAL::to_double(
|
return FT(std::sqrt(CGAL::to_double(
|
||||||
CGAL::squared_distance(center_pmap[f], px.center))));
|
CGAL::squared_distance(center_pmap[f], px.center))));
|
||||||
}
|
}
|
||||||
|
|
@ -43,15 +43,11 @@ struct CompactMetric {
|
||||||
struct PointProxyFitting {
|
struct PointProxyFitting {
|
||||||
typedef PointProxy Proxy;
|
typedef PointProxy Proxy;
|
||||||
|
|
||||||
PointProxyFitting(const FacetCenterMap &_center_pmap,
|
PointProxyFitting(const FacetCenterMap &_center_pmap, const FacetAreaMap &_area_pmap)
|
||||||
const FacetAreaMap &_area_pmap)
|
: center_pmap(_center_pmap), area_pmap(_area_pmap) {}
|
||||||
: center_pmap(_center_pmap),
|
|
||||||
area_pmap(_area_pmap) {}
|
|
||||||
|
|
||||||
template<typename FacetIterator>
|
template<typename FacetIterator>
|
||||||
PointProxy operator()(const FacetIterator beg, const FacetIterator end) const {
|
PointProxy operator()(const FacetIterator beg, const FacetIterator end) const {
|
||||||
CGAL_assertion(beg != end);
|
|
||||||
|
|
||||||
// fitting center
|
// fitting center
|
||||||
Vector_3 center = CGAL::NULL_VECTOR;
|
Vector_3 center = CGAL::NULL_VECTOR;
|
||||||
FT area(0);
|
FT area(0);
|
||||||
|
|
@ -75,7 +71,7 @@ struct PointProxyFitting {
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (argc < 5)
|
if (argc < 5)
|
||||||
return 0;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
// create and read Polyhedron
|
// create and read Polyhedron
|
||||||
Polyhedron mesh;
|
Polyhedron mesh;
|
||||||
|
|
@ -86,26 +82,25 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
// construct facet normal & area map
|
// construct facet normal & area map
|
||||||
std::map<Facet_const_handle, FT> facet_areas;
|
std::map<Facet_handle, FT> facet_areas;
|
||||||
std::map<Facet_const_handle, Point_3> facet_centers;
|
std::map<Facet_handle, Point_3> facet_centers;
|
||||||
for(Facet_const_iterator fitr = mesh.facets_begin(); fitr != mesh.facets_end(); ++fitr) {
|
for(Facet_iterator fitr = mesh.facets_begin(); fitr != mesh.facets_end(); ++fitr) {
|
||||||
const Halfedge_const_handle he = fitr->halfedge();
|
const Halfedge_handle he = fitr->halfedge();
|
||||||
const Point_3 p1 = he->opposite()->vertex()->point();
|
const Point_3 &p0 = he->opposite()->vertex()->point();
|
||||||
const Point_3 p2 = he->vertex()->point();
|
const Point_3 &p1 = he->vertex()->point();
|
||||||
const Point_3 p3 = he->next()->vertex()->point();
|
const Point_3 &p2 = he->next()->vertex()->point();
|
||||||
FT area(std::sqrt(CGAL::to_double(CGAL::squared_area(p1, p2, p3))));
|
FT area(std::sqrt(CGAL::to_double(CGAL::squared_area(p0, p1, p2))));
|
||||||
facet_areas.insert(std::pair<Facet_const_handle, FT>(fitr, area));
|
facet_areas.insert(std::pair<Facet_handle, FT>(fitr, area));
|
||||||
facet_centers.insert(std::pair<Facet_const_handle, Point_3>(fitr, CGAL::centroid(p1, p2, p3)));
|
facet_centers.insert(std::pair<Facet_handle, Point_3>(fitr, CGAL::centroid(p0, p1, p2)));
|
||||||
}
|
}
|
||||||
FacetAreaMap area_pmap(facet_areas);
|
FacetAreaMap area_pmap(facet_areas);
|
||||||
FacetCenterMap center_pmap(facet_centers);
|
FacetCenterMap center_pmap(facet_centers);
|
||||||
|
|
||||||
// create a property-map for segment-ids
|
// create a property-map for segment-ids
|
||||||
typedef std::map<Facet_const_handle, std::size_t> Facet_id_map;
|
Facet_id_map facet_proxy_map;
|
||||||
Facet_id_map internal_facet_id_map;
|
for (Facet_iterator fitr = mesh.facets_begin(); fitr != mesh.facets_end(); ++fitr)
|
||||||
for (Facet_const_iterator fitr = mesh.facets_begin(); fitr != mesh.facets_end(); ++fitr)
|
facet_proxy_map.insert(std::pair<Facet_handle, std::size_t>(fitr, 0));
|
||||||
internal_facet_id_map.insert(std::pair<Facet_const_handle, std::size_t>(fitr, 0));
|
boost::associative_property_map<Facet_id_map> proxy_pmap(facet_proxy_map);
|
||||||
boost::associative_property_map<Facet_id_map> proxy_patch_map(internal_facet_id_map);
|
|
||||||
|
|
||||||
const std::size_t num_proxies = std::atoi(argv[3]);
|
const std::size_t num_proxies = std::atoi(argv[3]);
|
||||||
const std::size_t num_iterations = std::atoi(argv[4]);
|
const std::size_t num_iterations = std::atoi(argv[4]);
|
||||||
|
|
@ -114,7 +109,7 @@ int main(int argc, char *argv[])
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
CGAL::vsa_approximate(mesh,
|
CGAL::vsa_approximate(mesh,
|
||||||
proxy_patch_map,
|
proxy_pmap,
|
||||||
CompactMetric(center_pmap),
|
CompactMetric(center_pmap),
|
||||||
PointProxyFitting(center_pmap, area_pmap),
|
PointProxyFitting(center_pmap, area_pmap),
|
||||||
init,
|
init,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue