mirror of https://github.com/CGAL/cgal
cleanup examples
This commit is contained in:
parent
b940dea08f
commit
07cb9e4c52
|
|
@ -16,7 +16,7 @@ typedef Mesh_approximation::Error_metric L21_metric;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// read input surface triangle mesh
|
// reads input surface triangle mesh
|
||||||
Polyhedron input;
|
Polyhedron input;
|
||||||
std::ifstream file("data/mask.off");
|
std::ifstream file("data/mask.off");
|
||||||
if (!file || !(file >> input) || input.empty()) {
|
if (!file || !(file >> input) || input.empty()) {
|
||||||
|
|
@ -24,34 +24,36 @@ int main()
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create VSA algorithm instance
|
// creates VSA algorithm instance
|
||||||
Mesh_approximation approx(input,
|
Mesh_approximation approx(input,
|
||||||
get(boost::vertex_point, const_cast<Polyhedron &>(input)));
|
get(boost::vertex_point, const_cast<Polyhedron &>(input)));
|
||||||
|
|
||||||
// set error and fitting functors
|
// sets error and fitting functors
|
||||||
L21_metric metric(input,
|
L21_metric metric(input,
|
||||||
get(boost::vertex_point, const_cast<Polyhedron &>(input)));
|
get(boost::vertex_point, const_cast<Polyhedron &>(input)));
|
||||||
approx.set_metric(metric);
|
approx.set_metric(metric);
|
||||||
|
|
||||||
// seeding 100 random proxies
|
// seeds 100 random proxies
|
||||||
approx.seeding(CGAL::Random, 100);
|
approx.seeding(CGAL::Random, 100);
|
||||||
|
|
||||||
// run 30 iterations
|
// runs 30 iterations
|
||||||
approx.run(30);
|
approx.run(30);
|
||||||
|
|
||||||
// add 3 proxies to the one with the maximum fitting error
|
// adds 3 proxies to the one with the maximum fitting error,
|
||||||
// run 5 iterations between each addition
|
// running 5 iterations between each addition
|
||||||
approx.add_to_furthest_proxies(3, 5);
|
approx.add_to_furthest_proxies(3, 5);
|
||||||
|
|
||||||
// run 10 iterations
|
// runs 10 iterations
|
||||||
approx.run(10);
|
approx.run(10);
|
||||||
|
|
||||||
// teleport 2 proxies to tunnel out of local minima
|
// teleports 2 proxies to tunnel out of local minima,
|
||||||
// run 5 iterations between each teleport
|
// running 5 iterations between each teleport
|
||||||
approx.teleport_proxies(2, 5);
|
approx.teleport_proxies(2, 5);
|
||||||
|
|
||||||
|
// runs 10 iterations
|
||||||
approx.run(10);
|
approx.run(10);
|
||||||
|
|
||||||
// meshing with default parameters
|
// generates output mesh with default parameters
|
||||||
approx.extract_mesh();
|
approx.extract_mesh();
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ typedef CGAL::VSA_approximation<
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// create polyhedral surface and read input mesh
|
// creates polyhedral surface and reads input mesh
|
||||||
Polyhedron input;
|
Polyhedron input;
|
||||||
std::ifstream file("data/bear.off");
|
std::ifstream file("data/bear.off");
|
||||||
if (!file || !(file >> input) || input.empty()) {
|
if (!file || !(file >> input) || input.empty()) {
|
||||||
|
|
@ -70,7 +70,7 @@ int main()
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// construct precomputed facet normal and area map
|
// constructs precomputed facet normal and area map
|
||||||
std::map<Facet_handle, FT> facet_areas;
|
std::map<Facet_handle, FT> facet_areas;
|
||||||
std::map<Facet_handle, Point> facet_centers;
|
std::map<Facet_handle, Point> facet_centers;
|
||||||
for(Facet_iterator fitr = input.facets_begin(); fitr != input.facets_end(); ++fitr) {
|
for(Facet_iterator fitr = input.facets_begin(); fitr != input.facets_end(); ++fitr) {
|
||||||
|
|
@ -86,15 +86,15 @@ int main()
|
||||||
Facet_area_map area_pmap(facet_areas);
|
Facet_area_map area_pmap(facet_areas);
|
||||||
Facet_center_map center_pmap(facet_centers);
|
Facet_center_map center_pmap(facet_centers);
|
||||||
|
|
||||||
// create compact metric approximation algorithm instance
|
// creates compact metric approximation algorithm instance
|
||||||
Approximation approx(input,
|
Approximation approx(input,
|
||||||
get(boost::vertex_point, const_cast<Polyhedron &>(input)));
|
get(boost::vertex_point, const_cast<Polyhedron &>(input)));
|
||||||
|
|
||||||
// construct and set metric
|
// constructs and set metric
|
||||||
Compact_metric metric(center_pmap, area_pmap);
|
Compact_metric metric(center_pmap, area_pmap);
|
||||||
approx.set_metric(metric);
|
approx.set_metric(metric);
|
||||||
|
|
||||||
// approximation via 200 proxies and 30 iterations
|
// approximates via 200 proxies and 30 iterations
|
||||||
approx.seeding(CGAL::Hierarchical, 200);
|
approx.seeding(CGAL::Hierarchical, 200);
|
||||||
approx.run(30);
|
approx.run(30);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ typedef boost::associative_property_map<Facet_index_map> Facet_proxy_pmap;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// create polyhedral surface and read input surface triangle mesh
|
// creates polyhedral surface and reads input mesh
|
||||||
Polyhedron input;
|
Polyhedron input;
|
||||||
std::ifstream file("data/mask.off");
|
std::ifstream file("data/mask.off");
|
||||||
if (!file || !(file >> input) || input.empty()) {
|
if (!file || !(file >> input) || input.empty()) {
|
||||||
|
|
@ -36,7 +36,7 @@ int main()
|
||||||
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
|
facet_proxy_map(fpxmap)); // output facet proxy-id map
|
||||||
|
|
||||||
// TODO: retrieve segments of the segmentation
|
// TODO: iterates over segments and outputs to console
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue