mirror of https://github.com/CGAL/cgal
fix test accordingly
This commit is contained in:
parent
aa2edb17f8
commit
564d1fefd4
|
|
@ -6,21 +6,22 @@
|
|||
#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::FT FT;
|
||||
typedef Kernel::Point_3 Point_3;
|
||||
|
||||
typedef CGAL::Polyhedron_3<Kernel> Polyhedron_3;
|
||||
typedef Polyhedron_3::Facet_handle Facet_handle;
|
||||
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
|
||||
typedef Polyhedron::Facet_handle Facet_handle;
|
||||
typedef boost::associative_property_map<std::map<Facet_handle, std::size_t> > FacetProxyMap;
|
||||
typedef boost::property_map<Polyhedron, boost::vertex_point_t>::type VertexPointMap;
|
||||
|
||||
typedef CGAL::PlaneProxy<Polyhedron_3> PlaneProxy;
|
||||
typedef CGAL::L2Metric<Polyhedron_3> L2Metric;
|
||||
typedef CGAL::L2ProxyFitting<Polyhedron_3> L2ProxyFitting;
|
||||
typedef CGAL::VSA_approximation<Polyhedron_3, PlaneProxy, L2Metric, L2ProxyFitting> VSA;
|
||||
typedef CGAL::PlaneProxy<Polyhedron> PlaneProxy;
|
||||
typedef CGAL::L2Metric<Polyhedron> L2Metric;
|
||||
typedef CGAL::L2ProxyFitting<Polyhedron> L2ProxyFitting;
|
||||
typedef CGAL::VSA_approximation<Polyhedron, VertexPointMap,
|
||||
CGAL::Default, L2Metric, L2ProxyFitting> VSA;
|
||||
|
||||
/**
|
||||
* This file tests the VSA class API and the L2 metric.
|
||||
|
|
@ -28,7 +29,7 @@ typedef CGAL::VSA_approximation<Polyhedron_3, PlaneProxy, L2Metric, L2ProxyFitti
|
|||
*/
|
||||
int main()
|
||||
{
|
||||
Polyhedron_3 mesh;
|
||||
Polyhedron mesh;
|
||||
std::ifstream input("./data/sphere_iso.off");
|
||||
if (!input || !(input >> mesh) || mesh.empty()) {
|
||||
std::cerr << "Invalid off file." << std::endl;
|
||||
|
|
@ -37,20 +38,18 @@ int main()
|
|||
|
||||
// facet area map
|
||||
std::map<Facet_handle, std::size_t> facet_index;
|
||||
for (Polyhedron_3::Facet_iterator fitr = mesh.facets_begin();
|
||||
for (Polyhedron::Facet_iterator fitr = mesh.facets_begin();
|
||||
fitr != mesh.facets_end(); ++fitr)
|
||||
facet_index.insert(std::pair<Facet_handle, std::size_t>(fitr, 0));
|
||||
FacetProxyMap proxy_pmap(facet_index);
|
||||
|
||||
L2Metric metric(mesh);
|
||||
L2ProxyFitting proxy_fitting(mesh);
|
||||
|
||||
// create VSA L2 metric approximation algorithm instance
|
||||
std::cout << "setup algorithm instance" << std::endl;
|
||||
VSA l2_approx;
|
||||
l2_approx.set_mesh(mesh);
|
||||
l2_approx.set_error_metric(metric);
|
||||
l2_approx.set_proxy_fitting(proxy_fitting);
|
||||
VSA l2_approx(mesh,
|
||||
get(boost::vertex_point, const_cast<Polyhedron &>(mesh)));
|
||||
L2Metric metric(mesh);
|
||||
L2ProxyFitting proxy_fitting(mesh);
|
||||
l2_approx.set_metric(metric, proxy_fitting);
|
||||
|
||||
// random init and run
|
||||
std::cout << "random init and run" << std::endl;
|
||||
|
|
@ -94,7 +93,7 @@ int main()
|
|||
|
||||
// extract the approximation polyhedron
|
||||
std::cout << "meshing" << std::endl;
|
||||
Polyhedron_3 out_mesh;
|
||||
Polyhedron out_mesh;
|
||||
if (l2_approx.meshing(out_mesh, FT(0.5), true))
|
||||
std::cout << "manifold." << std::endl;
|
||||
else
|
||||
|
|
@ -110,7 +109,7 @@ int main()
|
|||
std::vector<Point_3> anchor_pos;
|
||||
l2_approx.get_anchor_points(std::back_inserter(anchor_pos));
|
||||
|
||||
std::vector<Polyhedron_3::Vertex_handle> anchor_vtx;
|
||||
std::vector<Polyhedron::Vertex_handle> anchor_vtx;
|
||||
l2_approx.get_anchor_vertices(std::back_inserter(anchor_vtx));
|
||||
|
||||
std::vector<int> tris;
|
||||
|
|
|
|||
|
|
@ -6,34 +6,34 @@
|
|||
#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::FT FT;
|
||||
typedef Kernel::Point_3 Point_3;
|
||||
typedef CGAL::Polyhedron_3<Kernel> Polyhedron_3;
|
||||
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
|
||||
typedef boost::property_map<Polyhedron, boost::vertex_point_t>::type VertexPointMap;
|
||||
|
||||
typedef CGAL::PlaneProxy<Polyhedron_3> PlaneProxy;
|
||||
typedef CGAL::L21Metric<Polyhedron_3> L21Metric;
|
||||
typedef CGAL::L21ProxyFitting<Polyhedron_3> L21ProxyFitting;
|
||||
typedef CGAL::VSA_approximation<Polyhedron_3, PlaneProxy, L21Metric, L21ProxyFitting> VSAL21;
|
||||
typedef CGAL::L21Metric<Polyhedron> L21Metric;
|
||||
typedef CGAL::L21ProxyFitting<Polyhedron> L21ProxyFitting;
|
||||
typedef CGAL::VSA_approximation<Polyhedron, VertexPointMap> VSAL21;
|
||||
|
||||
bool test_shape(const char *file_name, const std::size_t target_num_proxies)
|
||||
{
|
||||
Polyhedron_3 mesh;
|
||||
Polyhedron mesh;
|
||||
std::ifstream input(file_name);
|
||||
if (!input || !(input >> mesh) || mesh.empty()) {
|
||||
std::cerr << "Invalid off file." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// algorithm instance
|
||||
VSAL21 vsa_l21(mesh,
|
||||
get(boost::vertex_point, const_cast<Polyhedron &>(mesh)));
|
||||
|
||||
L21Metric l21_metric(mesh);
|
||||
L21ProxyFitting l21_fitting(mesh);
|
||||
|
||||
// algorithm instance
|
||||
VSAL21 vsa_l21(l21_metric, l21_fitting);
|
||||
vsa_l21.set_mesh(mesh);
|
||||
vsa_l21.set_metric(l21_metric, l21_fitting);
|
||||
|
||||
// approximation, init from error, drop to the target error incrementally
|
||||
// should reach targeted number of proxies gradually
|
||||
|
|
@ -51,7 +51,7 @@ bool test_shape(const char *file_name, const std::size_t target_num_proxies)
|
|||
}
|
||||
|
||||
// meshing, should be manifold
|
||||
Polyhedron_3 mesh_out;
|
||||
Polyhedron mesh_out;
|
||||
if (!vsa_l21.meshing(mesh_out)) {
|
||||
std::cout << "incremental reaching meshing non-manifold" << std::endl;
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -6,17 +6,17 @@
|
|||
#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::FT FT;
|
||||
typedef CGAL::Polyhedron_3<Kernel> Polyhedron_3;
|
||||
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
|
||||
typedef boost::property_map<Polyhedron, boost::vertex_point_t>::type VertexPointMap;
|
||||
|
||||
typedef CGAL::PlaneProxy<Polyhedron_3> PlaneProxy;
|
||||
typedef CGAL::L21Metric<Polyhedron_3> L21Metric;
|
||||
typedef CGAL::L21ProxyFitting<Polyhedron_3> L21ProxyFitting;
|
||||
typedef CGAL::VSA_approximation<Polyhedron_3, PlaneProxy, L21Metric, L21ProxyFitting> VSAL21;
|
||||
typedef CGAL::PlaneProxy<Polyhedron> PlaneProxy;
|
||||
typedef CGAL::L21Metric<Polyhedron> L21Metric;
|
||||
typedef CGAL::L21ProxyFitting<Polyhedron> L21ProxyFitting;
|
||||
typedef CGAL::VSA_approximation<Polyhedron, VertexPointMap> VSAL21;
|
||||
|
||||
bool check_strict_ordering(const std::vector<FT> &error)
|
||||
{
|
||||
|
|
@ -37,19 +37,20 @@ bool check_strict_ordering(const std::vector<FT> &error)
|
|||
*/
|
||||
int main()
|
||||
{
|
||||
Polyhedron_3 mesh;
|
||||
Polyhedron mesh;
|
||||
std::ifstream input("./data/sphere_iso.off");
|
||||
if (!input || !(input >> mesh) || mesh.empty()) {
|
||||
std::cerr << "Invalid off file." << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// algorithm instance
|
||||
VSAL21 vsa_l21(mesh,
|
||||
get(boost::vertex_point, const_cast<Polyhedron &>(mesh)));
|
||||
|
||||
L21Metric l21_metric(mesh);
|
||||
L21ProxyFitting l21_fitting(mesh);
|
||||
|
||||
// algorithm instance
|
||||
VSAL21 vsa_l21(l21_metric, l21_fitting);
|
||||
vsa_l21.set_mesh(mesh);
|
||||
vsa_l21.set_metric(l21_metric, l21_fitting);
|
||||
|
||||
vsa_l21.init_proxies(100, VSAL21::RandomInit);
|
||||
std::vector<FT> error;
|
||||
|
|
|
|||
|
|
@ -14,12 +14,13 @@ typedef Kernel::FT FT;
|
|||
typedef Kernel::Vector_3 Vector_3;
|
||||
typedef Kernel::Point_3 Point_3;
|
||||
|
||||
typedef CGAL::Polyhedron_3<Kernel> Polyhedron_3;
|
||||
typedef Polyhedron_3::Facet_handle Facet_handle;
|
||||
typedef Polyhedron_3::Halfedge_handle Halfedge_handle;
|
||||
typedef Polyhedron_3::Facet_iterator Facet_iterator;
|
||||
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::associative_property_map<std::map<Facet_handle, FT> > FacetAreaMap;
|
||||
typedef boost::associative_property_map<std::map<Facet_handle, Point_3> > FacetCenterMap;
|
||||
typedef boost::property_map<Polyhedron, boost::vertex_point_t>::type VertexPointMap;
|
||||
|
||||
struct PointProxy {
|
||||
Facet_handle seed;
|
||||
|
|
@ -67,14 +68,15 @@ struct PointProxyFitting {
|
|||
const FacetCenterMap center_pmap;
|
||||
const FacetAreaMap area_pmap;
|
||||
};
|
||||
typedef CGAL::VSA_approximation<Polyhedron_3, PointProxy, CompactMetric, PointProxyFitting> CompactVSA;
|
||||
typedef CGAL::VSA_approximation<Polyhedron, VertexPointMap,
|
||||
PointProxy, CompactMetric, PointProxyFitting> CompactVSA;
|
||||
|
||||
/**
|
||||
* This file tests the user defined metric.
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
Polyhedron_3 mesh;
|
||||
Polyhedron mesh;
|
||||
std::ifstream input("./data/cube_meshed_open.off");
|
||||
if (!input || !(input >> mesh) || mesh.empty()) {
|
||||
std::cerr << "Invalid off file." << std::endl;
|
||||
|
|
@ -96,15 +98,14 @@ int main()
|
|||
FacetAreaMap area_pmap(facet_areas);
|
||||
FacetCenterMap center_pmap(facet_centers);
|
||||
|
||||
CompactMetric metric(center_pmap);
|
||||
PointProxyFitting proxy_fitting(center_pmap, area_pmap);
|
||||
|
||||
// create compact metric approximation algorithm instance
|
||||
std::cout << "create compact vas instance" << std::endl;
|
||||
CompactVSA compact_approx;
|
||||
compact_approx.set_mesh(mesh);
|
||||
compact_approx.set_error_metric(metric);
|
||||
compact_approx.set_proxy_fitting(proxy_fitting);
|
||||
CompactVSA compact_approx(mesh,
|
||||
get(boost::vertex_point, const_cast<Polyhedron &>(mesh)));
|
||||
|
||||
CompactMetric metric(center_pmap);
|
||||
PointProxyFitting proxy_fitting(center_pmap, area_pmap);
|
||||
compact_approx.set_metric(metric, proxy_fitting);
|
||||
|
||||
std::cout << "random init and run" << std::endl;
|
||||
compact_approx.init_proxies(20, CompactVSA::RandomInit);
|
||||
|
|
@ -115,7 +116,7 @@ int main()
|
|||
|
||||
// extract the approximation polyhedron
|
||||
std::cout << "meshing" << std::endl;
|
||||
Polyhedron_3 out_mesh;
|
||||
Polyhedron out_mesh;
|
||||
if (compact_approx.meshing(out_mesh))
|
||||
std::cout << "manifold." << std::endl;
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in New Issue