MEPP2 Project
test_smoothing_surfacemesh.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 General Public License as published
6 // by the Free Software Foundation; either version 3 of the License,
7 // 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 <CGAL/Cartesian.h>
12 #include <CGAL/Surface_mesh.h>
13 #include <CGAL/boost/graph/graph_traits_Surface_mesh.h> // CGAL Graph traits wrapper
14 
15 #include "FEVV/Wrappings/Geometry_traits_cgal_surface_mesh.h" // FEVV geometry wrapper
16 
17 //#define USE_GENERIC_READER_WRITER // when activated you need to link to vtk
18 //libs if VTK is used
19 #ifdef USE_GENERIC_READER_WRITER
21 #include "FEVV/Wrappings/properties_cgal.h"
24 #endif
25 
27 
32 
33 #include <fstream>
34 #include <string>
35 
36 using namespace FEVV;
37 using namespace FEVV::Filters;
38 
39 void
40 test_smoothing_surface_mesh(std::string filename)
41 {
42  typedef CGAL::Cartesian< double > Kernel;
43  typedef CGAL::Surface_mesh< Kernel::Point_3 > Mesh;
44 
45  typedef FEVV::Geometry_traits< Mesh > Geometry;
46  typedef Geometry::Point Point;
47  typedef boost::vector_property_map<
48  Point,
49  typename boost::property_map< Mesh, boost::vertex_index_t >::const_type >
50  BarycenterMap;
51  /**********************************************************************************************************/
52  Mesh m;
53 #ifdef USE_GENERIC_READER_WRITER
55  FEVV::Filters::read_mesh(filename, m, pmaps);
56 #else
57  std::ifstream in(filename);
58  if(!in)
59  {
60  std::cout << "Unable to read file " << filename << std::endl;
61  exit(EXIT_FAILURE);
62  }
63  in >> m;
64 #endif
65  /**********************************************************************************************************/
66  auto pos_pm = get(boost::vertex_point, m);
67  /**********************************************************************************************************/
68  BarycenterMap barycenters_pm(get(boost::vertex_index, m));
70  m, pos_pm, barycenters_pm, 0.2f);
71  FEVV::Filters::reposition_vertices(m, pos_pm, barycenters_pm);
72 
74  m, pos_pm, barycenters_pm, 0.2f);
75  FEVV::Filters::reposition_vertices(m, pos_pm, barycenters_pm);
76 
78  m, pos_pm, barycenters_pm, 0.2f);
79  FEVV::Filters::reposition_vertices(m, pos_pm, barycenters_pm);
80  /**********************************************************************************************************/
81 #ifdef USE_GENERIC_READER_WRITER
82  FEVV::Filters::write_mesh("smoothed_surf_" +
85  m,
86  pmaps);
87 #else
88  std::ofstream smoothed_off("smoothed_surf_" +
91  smoothed_off << m;
92  smoothed_off.close();
93 #endif
94  std::cout << "Done." << std::endl;
95 }
96 
97 int
98 main(int narg, char **argv)
99 {
100  if(narg < 2)
101  {
102  std::cout << "Usage: " << argv[0]
103  << " filename; filename being an off file." << std::endl;
104  exit(EXIT_FAILURE);
105  }
106 
108  return 0;
109 }
FEVV::Filters::calculate_vertices_one_ring_geometric_laplacian
void calculate_vertices_one_ring_geometric_laplacian(const FaceGraph &g, const PointMap &pm, CentroidMap geom_laplacians_pm, const typename GeometryTraits::Scalar smoothing_factor, const GeometryTraits &gt)
Compute geometric laplacians for all vertices and store them in geom_laplacians_pm.
Definition: calculate_vertices_one_ring_geometric_laplacian.hpp:49
FEVV::Filters
Definition: clean_topology.hpp:21
calculate_vertices_one_ring_geometric_laplacian.hpp
generic_reader.hpp
Graph_traits_extension_cgal_surface_mesh.h
FEVV::Geometry_traits
Refer to Geometry_traits_documentation_dummy for further documentation on provided types and algorith...
Definition: Geometry_traits.h:162
Point
AIFMesh::Point Point
Definition: Graph_properties_aif.h:21
Geometry_traits_cgal_surface_mesh.h
FEVV::PMapsContainer
std::map< std::string, boost::any > PMapsContainer
Definition: properties.h:99
FEVV::FileUtils::get_file_name
std::string get_file_name(const std::string &file_name)
Definition: FileUtilities.hpp:128
Kernel
CGAL::Cartesian< double > Kernel
Definition: test_complying_concepts_linear_cell_complex.cpp:22
FEVV::get
FEVV::PCLPointCloudPointMap::value_type get(const FEVV::PCLPointCloudPointMap &pm, FEVV::PCLPointCloudPointMap::key_type key)
Specialization of get(point_map, key) for PCLPointCloud.
Definition: Graph_properties_pcl_point_cloud.h:117
FEVV::Filters::reposition_vertices
void reposition_vertices(const PropertyGraph &g, PointMap pm, const NewPointMap &smoothed_pm, const GeometryTraits &)
Apply new vertex positions to vertex position property map.
Definition: reposition_vertices.hpp:44
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
calculate_vertices_one_ring_angles_based_centroid.hpp
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::FileUtils::get_file_extension
std::string get_file_extension(const std::string &file_name)
Definition: FileUtilities.hpp:36
calculate_vertices_one_ring_barycenter.hpp
reposition_vertices.hpp
Mesh
FEVV::DataStructures::AIF::AIFMesh Mesh
Definition: test_complying_concepts_aif.cpp:18
FEVV::Filters::write_mesh
void write_mesh(const std::string &filename, FEVV::CGALPointSet &g, PMapsContainer &pmaps)
Write mesh to file.
Definition: cgal_point_set_writer.hpp:42
generic_writer.hpp
FEVV::DataStructures::AIF::AIFMesh
This class represents an AIF structure. AIF structure can deal with both manifold and non-manifold su...
Definition: AIFMesh.hpp:47
test_smoothing_surface_mesh
void test_smoothing_surface_mesh(std::string filename)
Definition: test_smoothing_surfacemesh.cpp:40
FEVV::Filters::calculate_vertices_one_ring_angles_based_centroid
void calculate_vertices_one_ring_angles_based_centroid(const FaceGraph &g, const PointMap &pm, CentroidMap angles_based_centroids_pm, const typename GeometryTraits::Scalar smoothing_factor, const GeometryTraits &gt)
Compute angle-based centroids for all vertices and store them in bangles_based_centroids_pm.
Definition: calculate_vertices_one_ring_angles_based_centroid.hpp:49
FEVV::Filters::calculate_vertices_one_ring_barycenter
void calculate_vertices_one_ring_barycenter(const FaceGraph &g, const PointMap &pm, CentroidMap barycenters_pm, const typename GeometryTraits::Scalar smoothing_factor, const GeometryTraits &gt)
Compute barycenters for all vertices and store them in barycenters_pm.
Definition: calculate_vertices_one_ring_barycenter.hpp:47
FileUtilities.hpp
main
int main(int narg, char **argv)
Definition: test_smoothing_surfacemesh.cpp:98