MEPP2 Project
test_curvature_filter_openmesh.cpp
Go to the documentation of this file.
1 // Copyright (c) 2012-2019 University of Lyon and CNRS (France).
2 // All rights reserved.
3 //
4 // This file is part of MEPP2; you can redistribute it and/or modify
5 // it under the terms of the GNU Lesser General Public License as
6 // published by the Free Software Foundation; either version 3 of
7 // the License, or (at your option) any later version.
8 //
9 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11 #include "FEVV/Wrappings/Geometry_traits_openmesh.h" // Always in first position for MVS 4996 warnings
12 
13 #include <fstream>
14 #include <string>
15 
16 
17 #define CGAL_USE_OM_POINTS
18 #include <CGAL/boost/graph/graph_traits_PolyMesh_ArrayKernelT.h>
19 #include <CGAL/boost/graph/properties_PolyMesh_ArrayKernelT.h>
21 
22 
23 #include "FEVV/Filters/Generic/Manifold/Curvature/curvature.hpp" // for calculate_curvature()
25 
26 #include <OpenMesh/Core/IO/MeshIO.hh> // for OpenMesh::IO::read_mesh())
27 
28 #include "FEVV/Wrappings/properties_openmesh.h" // for datastructure default property map
29 
30 struct MyTraitsDouble : public OpenMesh::DefaultTraits
31 {
32  typedef OpenMesh::Vec3d Point; // use double-values points
33  typedef OpenMesh::Vec3d Normal;
34 };
35 
36 typedef OpenMesh::PolyMesh_ArrayKernelT< MyTraitsDouble >
37  OMMesh; // use MyTraitsDouble to remove a warning
38 
39 //------------------------------------------------------------------------------
40 
41 // code from Visualization/PluginFilters/curvature/CurvaturePlugin.h
42 void
44 {
45  typedef OMMesh HalfedgeGraph;
46 
47  std::cout << "Asking to Curvature mesh ! " << std::endl;
48 
49  auto pm = get(boost::vertex_point, *mesh);
50 
51  // ---
52 
53  //using Vector = typename FEVV::Geometry_traits< HalfedgeGraph >::Vector;
54 
55  // Face normal map
56  // this one is a standard property map
57  auto f_nm = make_property_map(FEVV::face_normal, *mesh);
58 
60 
61  // ---
62 
63  // Vertex curvature map
64  // this one is a NON-standard property map!
65  auto v_cm =
66  FEVV::make_vertex_property_map< HalfedgeGraph,
68  *mesh);
69 
72  double min_nrm_min_curvature, max_nrm_min_curvature, min_nrm_max_curvature,
73  max_nrm_max_curvature;
74 
75  bool value_is_geod = false;
76  double value_radius = 0.001;
77  FEVV::Filters::calculate_curvature( // B) call the filter corresponding to
78  // your operation
79  *mesh,
80  v_cm,
81  pm,
82  f_nm,
83  value_is_geod,
84  value_radius,
85  min_nrm_min_curvature,
86  max_nrm_min_curvature,
87  min_nrm_max_curvature,
88  max_nrm_max_curvature);
89 
90  // ---
91 
92  std::cout << "Curvature mesh, isGeod: " << value_is_geod
93  << " - radius: " << value_radius << "." << std::endl;
94 }
95 
96 //------------------------------------------------------------------------------
97 
98 int
99 main(int narg, char **argv)
100 {
101  if(narg < 2)
102  {
103  std::cout << "Usage: " << argv[0] << " mesh_filename" << std::endl;
104  exit(EXIT_FAILURE);
105  }
106  std::string filename(argv[1]);
107 
108 
109  OMMesh m;
110  if(!OpenMesh::IO::read_mesh(m, filename))
111  {
112  std::cout << "Failed to read file." << std::endl;
113  return -1;
114  }
115 
116 
117  curvature(&m);
118 
119 
120  std::cout << "Done." << std::endl;
121 
122  return 0;
123 }
main
int main(int narg, char **argv)
Definition: test_curvature_filter_openmesh.cpp:99
Geometry_traits_openmesh.h
FEVV::Filters::v_Curv
Definition: curvature.hpp:41
calculate_face_normals.hpp
curvature.hpp
curvature
void curvature(OMMesh *mesh)
Definition: test_curvature_filter_openmesh.cpp:43
FEVV::Filters::calculate_curvature
void calculate_curvature(const HalfedgeGraph &g, VertexCurvatureMap &v_cm, const PointMap &pm, const FaceNormalMap &f_nm, bool is_geod, double radius, double &min_nrm_min_curvature, double &max_nrm_min_curvature, double &min_nrm_max_curvature, double &max_nrm_max_curvature, const GeometryTraits &gt)
Calculate the curvature for a mesh.
Definition: curvature.hpp:312
MyTraitsDouble::Point
OpenMesh::Vec3d Point
Definition: test_curvature_filter_openmesh.cpp:32
FEVV::Filters::read_mesh
void read_mesh(const std::string &filename, FEVV::CGALPointSet &g, PMapsContainer &pmaps, bool=false)
Load mesh from file.
Definition: cgal_point_set_reader.hpp:110
FEVV::make_vertex_property_map
Vertex_pmap_traits< MeshT, ValueT >::pmap_type make_vertex_property_map(const MeshT &m)
Definition: properties.h:736
FEVV::Filters::calculate_face_normals
void calculate_face_normals(const HalfedgeGraph &g, const PointMap &pm, FaceNormalMap fnm, const GeometryTraits &gt)
Calculate "some" normal of all the faces of the considered mesh and populate the argument provided Fa...
Definition: calculate_face_normals.hpp:40
OMMesh
OpenMesh::PolyMesh_ArrayKernelT< MyTraitsDouble > OMMesh
Definition: test_curvature_filter_openmesh.cpp:37
properties_openmesh.h
boost::get
boost::property_map< FEVV::DataStructures::AIF::AIFMesh, boost::vertex_index_t >::const_type get(const boost::vertex_index_t &, const FEVV::DataStructures::AIF::AIFMesh &)
Returns the vertex index property map of the mesh.
Definition: Graph_properties_aif.h:108
MyTraitsDouble::Normal
OpenMesh::Vec3d Normal
Definition: test_curvature_filter_openmesh.cpp:33
MyTraitsDouble
Definition: test_curvature_filter_openmesh.cpp:31
FEVV::make_property_map
PMap_traits< PropertyT, MeshT >::pmap_type make_property_map(PropertyT, const MeshT &m)
Definition: properties.h:630
FEVV::face_normal
@ face_normal
Definition: properties.h:77