MEPP2 Project
test_smoothing_aif.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.
14 
16 
20 
21 //#define USE_GENERIC_READER_WRITER // when activated you need to link to vtk
22 //libs if VTK is used
23 #ifndef USE_GENERIC_READER_WRITER
26 #else
27 //---------------- specific code above --------------------
28 
29 //---------------- generic code below ---------------------
30 
33 #endif
34 
39 
40 //---------------- generic code above ---------------------
41 
42 //---------------- other code below -----------------------
43 
45 
46 #include <fstream>
47 
48 void
49 test_calculate_scaling_aif(const std::string &input_file_path)
50 {
51  using BarycenterMap =
53  /**********************************************************************************************************/
54 #ifdef USE_GENERIC_READER_WRITER
55  MeshT m;
56  FEVV::PMapsContainer pmaps_bag;
57  FEVV::Filters::read_mesh(input_file_path, m, pmaps_bag);
58 #else
59  PtrMeshT pm;
61  if(!(pm = in.read(input_file_path)))
62  {
63  std::cout << "reading failed";
64  return;
65  }
66  MeshT m(*pm); // copy contructor use
67 #endif
68  /**********************************************************************************************************/
69  try
70  {
71  /**********************************************************************************************************/
72  auto pos_pm = get(boost::vertex_point, m);
73  /**********************************************************************************************************/
74  BarycenterMap barycenters_pm =
77  m, pos_pm, barycenters_pm, 0.2f);
78  FEVV::Filters::reposition_vertices(m, pos_pm, barycenters_pm);
79 
81  m, pos_pm, barycenters_pm, 0.2f);
82  FEVV::Filters::reposition_vertices(m, pos_pm, barycenters_pm);
83 
85  m, pos_pm, barycenters_pm, 0.2f);
86  FEVV::Filters::reposition_vertices(m, pos_pm, barycenters_pm);
87  }
88  catch(const std::exception &e)
89  {
90  std::cout << "processing failed: " << e.what();
91  return;
92  }
93 #ifdef USE_GENERIC_READER_WRITER
94  /**********************************************************************************************************/
96  "smoothed_aif_" + FEVV::FileUtils::get_file_name(input_file_path) +
97  FEVV::FileUtils::get_file_extension(input_file_path),
98  m,
99  pmaps_bag);
100 #else
101  /**********************************************************************************************************/
103  try
104  {
105  out.write(m,
106  "smoothed_aif_" +
107  FEVV::FileUtils::get_file_name(input_file_path) +
108  FEVV::FileUtils::get_file_extension(input_file_path));
109  }
110  catch(...)
111  {
112  std::cout << "writing failed";
113  return;
114  }
115 #endif
116  std::cout << "Done." << std::endl;
117 }
118 
119 //------------------------------------------------------------------------------
120 
121 int
122 main(int narg, char **argv)
123 {
124  if(narg < 2)
125  {
126  std::cout << "Usage: " << argv[0]
127  << " filename; filename being an off file." << std::endl;
128  exit(EXIT_FAILURE);
129  }
130 
132  return 0;
133 }
FEVV::DataStructures::AIF::AIFMeshWriter
This class represents an AIFMesh object writer. An AIFMeshWriter writes a mesh file (....
Definition: AIFMeshWriter.hpp:37
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
calculate_vertices_one_ring_geometric_laplacian.hpp
generic_reader.hpp
FEVV::DataStructures::AIF::AIFMeshReader::read
ptr_output read(const std::string &filePath)
Definition: AIFMeshReader.inl:50
properties_aif.h
FEVV::Vertex_pmap_traits::create
static pmap_type create(const MeshT &)
Definition: properties.h:321
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
FEVV::Assoc_property_map
Definition: properties.h:236
main
int main(int narg, char **argv)
Definition: test_smoothing_aif.cpp:122
FEVV::AIF_mesh_kernel_generator
AIF specialization. Refer to for concrete usage .
Definition: Geometry_traits_aif.h:31
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::DataStructures::AIF::AIFMeshWriter::write
void write(const ptr_input inputMesh, const std::string &filePath)
Definition: AIFMeshWriter.inl:28
AIFMesh.hpp
PtrMeshT
FEVV::DataStructures::AIF::AIFMesh::ptr_mesh PtrMeshT
Definition: test_smoothing_aif.cpp:19
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::DataStructures::AIF::AIFMesh::ptr_mesh
boost::shared_ptr< Self > ptr_mesh
Definition: AIFMesh.hpp:51
Graph_traits_aif.h
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
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
Geometry_traits_aif.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
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
FEVV::DataStructures::AIF::AIFMeshReader
This class represents an AIFMesh object reader. An AIFMeshReader reads a mesh file (....
Definition: AIFMeshReader.hpp:37
test_calculate_scaling_aif
void test_calculate_scaling_aif(const std::string &input_file_path)
Definition: test_smoothing_aif.cpp:49
AIFMeshReader.hpp
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
AIFMesh
FEVV::DataStructures::AIF::AIFMesh AIFMesh
Definition: Graph_properties_aif.h:19
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
AIFMeshWriter.hpp