From 3c5ca4d88d6255485e52a8f85ebfb2caf2eb6fdc Mon Sep 17 00:00:00 2001 From: konstantinos katrioplas Date: Wed, 5 Jul 2017 12:20:24 +0300 Subject: [PATCH] setup for curvature flow class --- .../curvature_flow_example.cpp | 40 +++++++++ .../Isotropic_remeshing/curvature_flow_impl.h | 60 +++++++++++++ .../CGAL/Polygon_mesh_processing/smoothing.h | 22 +++++ .../test_curvature_flow.cpp | 89 +++++++++++++++++++ 4 files changed, 211 insertions(+) create mode 100644 Polygon_mesh_processing/examples/Polygon_mesh_processing/curvature_flow_example.cpp create mode 100644 Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/curvature_flow_impl.h create mode 100644 Polygon_mesh_processing/test/Polygon_mesh_processing/test_curvature_flow.cpp diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/curvature_flow_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/curvature_flow_example.cpp new file mode 100644 index 00000000000..5caf2c80a17 --- /dev/null +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/curvature_flow_example.cpp @@ -0,0 +1,40 @@ +#include +#include + +#include +#include + +#include + + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Surface_mesh Mesh; + + + +int main(int argc, char* argv[]){ + + + const char* filename = "data/curved_polygon.off"; + std::ifstream input(filename); + + Mesh mesh; + if (!input || !(input >> mesh) || mesh.is_empty()) { + std::cerr << "Not a valid .off file." << std::endl; + return 1; + } + + + + CGAL::Polygon_mesh_processing::curvature_flow(mesh); + + + + std::ofstream output("data/curved_polygon_smoothed.off"); + output << mesh; + output.close(); + + + + return 0; +} diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/curvature_flow_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/curvature_flow_impl.h new file mode 100644 index 00000000000..7298ccff075 --- /dev/null +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/curvature_flow_impl.h @@ -0,0 +1,60 @@ +#ifndef CURVATURE_FLOW_IMPL_H +#define CURVATURE_FLOW_IMPL_H + + + +namespace CGAL { + +namespace Polygon_mesh_processing { + +namespace internal { + + + + +template +class Curvature_flow +{ + + + + + +public: + + + Curvature_flow(PolygonMesh& pmesh, VertexPointMap& vpmap) : mesh_(pmesh), vpmap_(vpmap) + {} + + + + + // k = div n + + + // cot a = v1 * v2 / v1 x v2 + + + + +private: + PolygonMesh& mesh_; + VertexPointMap& vpmap_; + +}; + + + + + + + +} // internal +} // Polygon_mesh_processing +} // CGAL + + + + + +#endif // CURVATURE_FLOW_IMPL_H diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/smoothing.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/smoothing.h index ec9c72a2815..5b977a76fc8 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/smoothing.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/smoothing.h @@ -5,6 +5,7 @@ #include +#include #include #include @@ -128,6 +129,27 @@ void compatible_remeshing(PolygonMesh& pmesh, const FaceRange& faces, const Edg +template +void curvature_flow(PolygonMesh& pmesh, NamedParameters& np) +{ + using boost::choose_param; + using boost::get_param; + + //vpmap + typedef typename GetVertexPointMap::const_type VertexPointMap; + VertexPointMap vpmap = choose_param(get_param(np, internal_np::vertex_point), + get_const_property_map(CGAL::vertex_point, pmesh)); + + internal::Curvature_flow curvature_remesher(pmesh, vpmap); + +} + +void curvature_flow(PolygonMesh& pmesh) +{ + curvature_flow(pmesh, parameters::all_default()); +} + + } // namespace Polygon_mesh_processing diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_curvature_flow.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_curvature_flow.cpp new file mode 100644 index 00000000000..45bd2268dc3 --- /dev/null +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_curvature_flow.cpp @@ -0,0 +1,89 @@ +#include +#include +#include +#include + +#include +#include + +#include + + +#define CGAL_PMP_REMESHING_VERBOSE +#define CGAL_TEST_COMP_REMESHING_OUTPUT + + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Surface_mesh Mesh; + + + +int main(int argc, char* argv[]){ + + + + std::string filename; + std::ifstream input; + Mesh mesh; +#ifdef CGAL_TEST_COMP_REMESHING_OUTPUT + std::ofstream output; +#endif + + + + std::vector filenames = { + "data/curved_polygon", + /*"data/polygon", + "data/polygon3D", + "data/blobby_3cc", + "data/cube_quad", + "data/elephant", + "data/degenerate_polygon", + "data/sneaky_degenerate_polygon", + "data/joint_refined", + "data/mannequin-devil", + "data/mech-holes-shark", + "data/non_manifold_vertex", + "data/overlapping_triangles", + "data/tetra1", + "data/tetra2", + "data/tetra3", + "data/tetra4", + "data/two_tris_collinear", + "data/U"*/ + }; + + + for(auto i=0; i!= filenames.size(); ++i) + { + filename = filenames[i]+".off"; + input.open(filename); + + +#ifdef CGAL_PMP_REMESHING_VERBOSE +std::cout<<"case: "<< filename << std::endl; +#endif + + if (!input || !(input >> mesh) || mesh.is_empty()) { + std::cerr << "Not a valid .off file." << std::endl; + return 1; + } + input.close(); + + + CGAL::Polygon_mesh_processing::curvature_flow(mesh); + + + +#ifdef CGAL_TEST_COMP_REMESHING_OUTPUT + output.open(filenames[i]+"_smoothed"+".off"); + output << mesh; + output.close(); +#endif + + } + + + + return 0; +}