35 #pragma warning(disable : 4172)
38 #include <CGAL/pca_estimate_normals.h>
39 #include <CGAL/mst_orient_normals.h>
46 int main(
int argc,
char *argv[])
51 std::cout <<
"Usage: " << argv[0]
52 <<
" input_mesh_filename output_mesh_filename" << std::endl;
53 std::cout <<
"Example: " << argv[0] <<
" ../Testing/Data/tetra.xyz tetra.out.ply"
57 std::string input_file = argv[1];
58 std::string output_file = argv[2];
67 std::cout <<
"load point cloud" << std::endl;
74 auto pm =
get(boost::vertex_point, pc);
78 PointCloudT >::pmap_type;
80 std::cout <<
"create vertex-normal map" << std::endl;
87 std::cout <<
"compute normals" << std::endl;
92 const int nb_neighbors = 18;
93 CGAL::pca_estimate_normals< CGAL::Sequential_tag >(
96 CGAL::parameters::point_map(pm).normal_map(v_nm));
101 std::cout <<
"orient normals" << std::endl;
103 CGAL::mst_orient_normals(
106 CGAL::parameters::point_map(pm).normal_map(v_nm));
111 std::cout <<
"save point cloud with normals" << std::endl;
119 #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
120 #include <CGAL/pca_estimate_normals.h>
121 #include <CGAL/mst_orient_normals.h>
122 #include <CGAL/property_map.h>
123 #include <CGAL/IO/read_xyz_points.h>
124 #include <CGAL/IO/write_xyz_points.h>
133 typedef CGAL::Exact_predicates_inexact_constructions_kernel
Kernel;
134 typedef Kernel::Point_3
Point;
135 typedef Kernel::Vector_3
Vector;
137 typedef std::pair< Point, Vector > PointVectorPair;
140 #ifdef CGAL_LINKED_WITH_TBB
141 typedef CGAL::Parallel_tag Concurrency_tag;
143 typedef CGAL::Sequential_tag Concurrency_tag;
146 int main(
int argc,
char*argv[])
151 std::cout <<
"Usage: " << argv[0]
152 <<
" input_mesh_filename output_mesh_filename" << std::endl;
153 std::cout <<
"Example: " << argv[0] <<
" ../Testing/Data/tetra.xyz tetra.xyz.with_normals.ply"
157 std::string input_file = argv[1];
158 std::string output_file = argv[2];
161 std::cout <<
"load point cloud" << std::endl;
162 std::list< PointVectorPair > points;
163 std::ifstream stream(input_file);
164 if(!stream || !CGAL::read_xyz_points(
166 std::back_inserter(points),
167 CGAL::parameters::point_map(
168 CGAL::First_of_pair_property_map< PointVectorPair >())))
170 std::cerr <<
"Error: cannot read file " << input_file << std::endl;
177 std::cout <<
"compute normals" << std::endl;
178 const int nb_neighbors = 18;
179 CGAL::pca_estimate_normals< Concurrency_tag >(
182 CGAL::parameters::point_map(
183 CGAL::First_of_pair_property_map< PointVectorPair >())
184 .normal_map(CGAL::Second_of_pair_property_map< PointVectorPair >()));
189 std::cout <<
"orient normals" << std::endl;
190 std::list< PointVectorPair >::iterator unoriented_points_begin =
191 CGAL::mst_orient_normals(
194 CGAL::parameters::point_map(
195 CGAL::First_of_pair_property_map< PointVectorPair >())
197 CGAL::Second_of_pair_property_map< PointVectorPair >()));
207 std::cout <<
"save point cloud with normals" << std::endl;
208 std::ofstream out(output_file);
211 !CGAL::write_xyz_points(
214 CGAL::parameters::point_map(
215 CGAL::First_of_pair_property_map< PointVectorPair >())
217 CGAL::Second_of_pair_property_map< PointVectorPair >())))