remove default constructor

This commit is contained in:
Lingjie Zhu 2018-07-16 10:55:02 +08:00
parent 1f78b9590c
commit e27a6b2b51
12 changed files with 49 additions and 67 deletions

View File

@ -38,14 +38,14 @@ int main(int argc, char *argv[])
} }
std::cerr << "#triangles " << mesh.size_of_facets() << std::endl; std::cerr << "#triangles " << mesh.size_of_facets() << std::endl;
// algorithm instance // error metric and fitting functors
L21_approx approx(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh)));
// set metric error and fitting functors
L21_metric error_metric(mesh, L21_metric error_metric(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh))); get(boost::vertex_point, const_cast<Polyhedron &>(mesh)));
approx.set_metric(error_metric);
// algorithm instance
L21_approx approx(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh)),
error_metric);
int method = std::atoi(argv[2]); int method = std::atoi(argv[2]);
if (method < 0 || method > 2) if (method < 0 || method > 2)

View File

@ -39,14 +39,14 @@ int main(int argc, char *argv[])
} }
std::cerr << "#triangles " << mesh.size_of_facets() << std::endl; std::cerr << "#triangles " << mesh.size_of_facets() << std::endl;
// algorithm instance // error metric and fitting functors
L21_apporx approx(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh)));
// set metric error and fitting functors
L21_metric error_metric(mesh, L21_metric error_metric(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh))); get(boost::vertex_point, const_cast<Polyhedron &>(mesh)));
approx.set_metric(error_metric);
// algorithm instance
L21_apporx approx(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh)),
error_metric);
int method = std::atoi(argv[2]); int method = std::atoi(argv[2]);
if (method < 0 || method > 2) if (method < 0 || method > 2)

View File

@ -24,14 +24,14 @@ int main()
return EXIT_FAILURE; return EXIT_FAILURE;
} }
// creates VSA algorithm instance // error metric and fitting function
Mesh_approximation approx(input, L21_metric error_metric(input,
get(boost::vertex_point, const_cast<Polyhedron &>(input))); get(boost::vertex_point, const_cast<Polyhedron &>(input)));
// sets error and fitting functors // creates VSA algorithm instance
L21_metric metric(input, Mesh_approximation approx(input,
get(boost::vertex_point, const_cast<Polyhedron &>(input))); get(boost::vertex_point, const_cast<Polyhedron &>(input)),
approx.set_metric(metric); error_metric);
// seeds 100 random proxies // seeds 100 random proxies
approx.initialize_seeds(CGAL::VSA::Random, 100); approx.initialize_seeds(CGAL::VSA::Random, 100);

View File

@ -91,13 +91,13 @@ int main()
Face_area_map area_pmap(face_areas); Face_area_map area_pmap(face_areas);
Face_center_map center_pmap(face_centers); Face_center_map center_pmap(face_centers);
// error metric and fitting function
Compact_metric_point_proxy error_metric(center_pmap, area_pmap);
// creates 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)),
error_metric);
// constructs and set metric
Compact_metric_point_proxy metric(center_pmap, area_pmap);
approx.set_metric(metric);
// approximates via 200 proxies and 30 iterations // approximates via 200 proxies and 30 iterations
approx.initialize_seeds(CGAL::VSA::Hierarchical, 200); approx.initialize_seeds(CGAL::VSA::Hierarchical, 200);

View File

@ -278,31 +278,17 @@ public:
/// \name Construction /// \name Construction
/// @{ /// @{
/*! /*!
* @brief %Default empty constructor. * @brief Initializes internal data for the approximation.
*/ * @param tm `CGAL TriangleMesh` on which approximation operates
Variational_shape_approximation() :
m_ptm(NULL),
m_metric(NULL),
m_average_edge_length(0.0) {
Geom_traits traits;
vector_functor = traits.construct_vector_3_object();
point_functor = traits.construct_point_3_object();
scale_functor = traits.construct_scaled_vector_3_object();
sum_functor = traits.construct_sum_of_vectors_3_object();
scalar_product_functor = traits.compute_scalar_product_3_object();
translate_point_functor = traits.construct_translated_point_3_object();
}
/*!
* @brief Initializes and prepares for the approximation.
* @param tm `CGAL TriangleMesh` on which approximation operates.
* @param vpoint_map vertex point map of the mesh * @param vpoint_map vertex point map of the mesh
* @param error_metric an `ErrorMetricProxy` object
*/ */
Variational_shape_approximation(const TriangleMesh &tm, const VertexPointMap &vpoint_map) : Variational_shape_approximation(const TriangleMesh &tm,
const VertexPointMap &vpoint_map,
const Error_metric &error_metric) :
m_ptm(&tm), m_ptm(&tm),
m_vpoint_map(vpoint_map), m_vpoint_map(vpoint_map),
m_metric(NULL), m_metric(&error_metric),
m_average_edge_length(0.0) { m_average_edge_length(0.0) {
Geom_traits traits; Geom_traits traits;

View File

@ -128,9 +128,8 @@ bool approximate_mesh(const TriangleMesh &tm, const NamedParameters &np)
<< "\n#v " << num_vertices(tm) << std::endl; << "\n#v " << num_vertices(tm) << std::endl;
} }
L21_approx approx(tm, point_pmap);
L21_metric metric(tm, point_pmap); L21_metric metric(tm, point_pmap);
approx.set_metric(metric); L21_approx approx(tm, point_pmap, metric);
// hierarchical seeding by default // hierarchical seeding by default
CGAL::VSA::Seeding_method method = choose_param( CGAL::VSA::Seeding_method method = choose_param(

View File

@ -44,11 +44,11 @@ int main()
// create L2_approx L2 metric approximation algorithm instance // create L2_approx L2 metric approximation algorithm instance
std::cout << "setup algorithm instance" << std::endl; std::cout << "setup algorithm instance" << std::endl;
L2_approx approx(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh)));
L2_metric_plane_proxy error_metric(mesh, L2_metric_plane_proxy error_metric(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh))); get(boost::vertex_point, const_cast<Polyhedron &>(mesh)));
approx.set_metric(error_metric); L2_approx approx(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh)),
error_metric);
// random seeding and run // random seeding and run
std::cout << "random seeding and run" << std::endl; std::cout << "random seeding and run" << std::endl;

View File

@ -27,12 +27,11 @@ bool test_shape(const char *file_name, const std::size_t target_num_proxies)
std::cout << "Testing \"" << file_name << '\"' << std::endl; std::cout << "Testing \"" << file_name << '\"' << std::endl;
// algorithm instance // algorithm instance
L21_approx approx(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh)));
L21_metric error_metric(mesh, L21_metric error_metric(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh))); get(boost::vertex_point, const_cast<Polyhedron &>(mesh)));
approx.set_metric(error_metric); L21_approx approx(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh)),
error_metric);
// approximation, seeding from error, drop to the target error incrementally // approximation, seeding from error, drop to the target error incrementally
// should reach targeted number of proxies gradually // should reach targeted number of proxies gradually

View File

@ -43,12 +43,11 @@ int main()
} }
// algorithm instance // algorithm instance
L21_approx approx(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh)));
L21_metric error_metric(mesh, L21_metric error_metric(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh))); get(boost::vertex_point, const_cast<Polyhedron &>(mesh)));
approx.set_metric(error_metric); L21_approx approx(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh)),
error_metric);
approx.initialize_seeds(CGAL::VSA::Random, 100); approx.initialize_seeds(CGAL::VSA::Random, 100);
std::vector<FT> error; std::vector<FT> error;

View File

@ -27,12 +27,11 @@ bool test_manifold(const char *file_name, const FT drop = FT(1e-8))
std::cout << "Testing \"" << file_name << '\"' << std::endl; std::cout << "Testing \"" << file_name << '\"' << std::endl;
// algorithm instance // algorithm instance
L21_approx approx(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh)));
L21_metric error_metric(mesh, L21_metric error_metric(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh))); get(boost::vertex_point, const_cast<Polyhedron &>(mesh)));
approx.set_metric(error_metric); L21_approx approx(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh)),
error_metric);
// approximation, seeding from error, drop to the target error incrementally // approximation, seeding from error, drop to the target error incrementally
const std::size_t num_iterations = 20; const std::size_t num_iterations = 20;

View File

@ -92,11 +92,11 @@ int main()
// create compact metric approximation algorithm instance // create compact metric approximation algorithm instance
std::cout << "create compact vas instance" << std::endl; std::cout << "create compact vas instance" << std::endl;
Compact_approx approx(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh)));
Compact_metric_point_proxy error_metric(center_pmap, area_pmap); Compact_metric_point_proxy error_metric(center_pmap, area_pmap);
approx.set_metric(error_metric);
Compact_approx approx(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh)),
error_metric);
std::cout << "random seeding and run" << std::endl; std::cout << "random seeding and run" << std::endl;
approx.initialize_seeds(CGAL::VSA::Random, 20); approx.initialize_seeds(CGAL::VSA::Random, 20);

View File

@ -62,8 +62,8 @@ int main()
L21_metric error_metric(mesh, L21_metric error_metric(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh))); get(boost::vertex_point, const_cast<Polyhedron &>(mesh)));
L21_approx approx(mesh, L21_approx approx(mesh,
get(boost::vertex_point, const_cast<Polyhedron &>(mesh))); get(boost::vertex_point, const_cast<Polyhedron &>(mesh)),
approx.set_metric(error_metric); error_metric);
std::cout << "Random seeding by number." << std::endl; std::cout << "Random seeding by number." << std::endl;
std::srand(static_cast<unsigned int>(std::time(0))); std::srand(static_cast<unsigned int>(std::time(0)));