From 2eeb88ac96cb49755b487cb01a1bfc3fc8f0f1fb Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Fri, 15 Jul 2022 13:18:56 +0200 Subject: [PATCH] moved my main program to a new example file in PMP --- .../Polygon_mesh_processing/CMakeLists.txt | 12 +- .../interpolated_corrected_curvatures.cpp | 75 +++++++++++ .../Triangulation_2/triangulation_prog1.cpp | 120 +++--------------- 3 files changed, 106 insertions(+), 101 deletions(-) create mode 100644 Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures.cpp diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt index baa4d41677a..d6f4e273516 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt @@ -5,11 +5,13 @@ cmake_minimum_required(VERSION 3.1...3.23) project(Polygon_mesh_processing_Examples) # CGAL and its components -find_package(CGAL REQUIRED) +find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) # Boost and its components find_package(Boost REQUIRED) + + if(NOT Boost_FOUND) message( @@ -100,6 +102,14 @@ create_single_source_cgal_program("orientation_pipeline_example.cpp") #create_single_source_cgal_program( "snapping_example.cpp") create_single_source_cgal_program("match_faces.cpp") create_single_source_cgal_program("cc_compatible_orientations.cpp") +create_single_source_cgal_program("interpolated_corrected_curvatures.cpp") + +if(CGAL_Qt5_FOUND) + + #link it with the required CGAL libraries + target_link_libraries(interpolated_corrected_curvatures PUBLIC CGAL::CGAL_Basic_viewer) + +endif() if(OpenMesh_FOUND) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures.cpp new file mode 100644 index 00000000000..f45bec68a03 --- /dev/null +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures.cpp @@ -0,0 +1,75 @@ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace PMP = CGAL::Polygon_mesh_processing; + +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; +typedef CGAL::Polyhedron_3 Polyhedron; +typedef CGAL::Surface_mesh Mesh; +typedef boost::graph_traits::face_descriptor face_descriptor; +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; + + +int main(int argc, char* argv[]) +{ + const std::string filename = (argc>1) ? argv[1] : CGAL::data_file_path("small_bunny.obj"); + + Mesh g1; + if(!CGAL::IO::read_polygon_mesh(filename, g1)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } + std::unordered_map vnm_vec; + boost::associative_property_map< std::unordered_map> vnm(vnm_vec); + + PMP::compute_vertex_normals(g1, vnm); + + + std::vector mu0_map, mu1_map, mu2_map; + + mu0_map = PMP::interpolated_corrected_measure_i(g1, PMP::MU0_AREA_MEASURE, CGAL::parameters::vertex_normal_map(vnm)); + mu1_map = PMP::interpolated_corrected_measure_i(g1, PMP::MU1_MEAN_CURVATURE_MEASURE, CGAL::parameters::vertex_normal_map(vnm)); + mu2_map = PMP::interpolated_corrected_measure_i(g1, PMP::MU2_GAUSSIAN_CURVATURE_MEASURE, CGAL::parameters::vertex_normal_map(vnm)); + + int n = g1.faces().size(); + + for (int i = 0; i < n; i++) + { + std::cout << mu0_map[i] << "\n"; + } + + std::cout << "\n"; + + for (int i = 0; i < n; i++) + { + std::cout << mu1_map[i] << "\n"; + } + + std::cout << "\n"; + + for (int i = 0; i < n; i++) + { + std::cout << mu2_map[i] << "\n"; + } + + + CGAL::draw(g1); + + return EXIT_SUCCESS; +} diff --git a/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp b/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp index 2e625d722cc..86b2c23cb48 100644 --- a/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp +++ b/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp @@ -1,106 +1,26 @@ +#include + #include -#include -#include -#include -#include +#include -#include +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -#include -#include -#include -#include -#include -#include +typedef CGAL::Triangulation_2 Triangulation; +typedef Triangulation::Vertex_circulator Vertex_circulator; +typedef Triangulation::Point Point; -namespace PMP = CGAL::Polygon_mesh_processing; +int main() { + std::ifstream in("data/triangulation_prog1.cin"); + std::istream_iterator begin(in); + std::istream_iterator end; -typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; -typedef CGAL::Polyhedron_3 Polyhedron; -typedef CGAL::Surface_mesh Mesh; -typedef boost::graph_traits::face_descriptor face_descriptor; -typedef boost::graph_traits::vertex_descriptor vertex_descriptor; - - - -int main(int argc, char* argv[]) -{ - Mesh g1; - if (!PMP::IO::read_polygon_mesh("small_bunny.obj", g1) || !CGAL::is_triangle_mesh(g1)) - { - std::cerr << "Invalid input." << std::endl; - return 1; - } - - //int n1 = g1.size_of_facets(); - - std::unordered_map vnm_vec; - boost::associative_property_map< std::unordered_map> vnm(vnm_vec); - - PMP::compute_vertex_normals(g1, vnm); - - - - std::vector mu0_map, mu1_map, mu2_map; - - mu0_map = PMP::interpolated_corrected_measure_i(g1, PMP::MU0_AREA_MEASURE, vnm); - mu1_map = PMP::interpolated_corrected_measure_i(g1, PMP::MU1_MEAN_CURVATURE_MEASURE, vnm); - mu2_map = PMP::interpolated_corrected_measure_i(g1, PMP::MU2_GAUSSIAN_CURVATURE_MEASURE, vnm); - - int n = g1.faces().size(); - - for (int i = 0; i < n; i++) - { - std::cout << mu0_map[i] << "\n"; - } - - std::cout << "\n"; - - for (int i = 0; i < n; i++) - { - std::cout << mu1_map[i] << "\n"; - } - - std::cout << "\n"; - - for (int i = 0; i < n; i++) - { - std::cout << mu2_map[i] << "\n"; - } - - - - - /*srand(time(NULL)); - - CGAL::GetGeomTraits GT; - - std::vector X(N); - std::vector U(N); - - for (int i = 0; i < N; i++) { - X[i] = { rand() , rand() , rand() }; - U[i] = { rand() , rand() , rand() }; - U[i] = U[i] / sqrt(U[i] * U[i]); - } - - - std::cout << PMP::interpolated_mu_i_face(X, U, PMP::MU0_AREA_MEASURE) << std::endl; - std::cout << PMP::interpolated_mu_i_face(X, U, PMP::MU1_MEAN_CURVATURE_MEASURE) << std::endl; - std::cout << PMP::interpolated_mu_i_face(X, U, PMP::MU2_GAUSSIAN_CURVATURE_MEASURE) << std::endl;*/ - - /*srand(time(NULL)); - Epic::Vector_3 x, y; - Epic::FT d = 0; - - Epic::Vector_3 z; - std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now(); - for (int i = 0; i < N; i++) - { - x * y; - } - std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); - std::cout << std::chrono::duration_cast(end - begin).count() << std::endl;*/ - -} + Triangulation t; + t.insert(begin, end); + Vertex_circulator vc = t.incident_vertices(t.infinite_vertex()), + done(vc); + if (vc != nullptr) { + do { std::cout << vc->point() << std::endl; + }while(++vc != done); + } + return 0; \ No newline at end of file