-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
Polygon_mesh_processing/examples/Polygon_mesh_processing/sample_example.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> | ||
#include <CGAL/Surface_mesh.h> | ||
#include <CGAL/Polygon_mesh_processing/distance.h> | ||
|
||
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h> | ||
#include <CGAL/Point_set_3.h> | ||
#include <iostream> | ||
#include <string> | ||
#include <vector> | ||
|
||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; | ||
typedef K::Point_3 Point; | ||
|
||
typedef CGAL::Point_set_3<Point> Point_set; | ||
|
||
typedef CGAL::Surface_mesh<Point> Mesh; | ||
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor; | ||
typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor; | ||
|
||
namespace PMP = CGAL::Polygon_mesh_processing; | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
const std::string filename = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/eight.off"); | ||
|
||
Mesh mesh; | ||
if(!PMP::IO::read_polygon_mesh(filename, mesh)) | ||
{ | ||
std::cerr << "Invalid input." << std::endl; | ||
return 1; | ||
} | ||
|
||
const double points_per_face = (argc > 2) ? atof(argv[2]) : 10; | ||
|
||
std::vector<Point> points; | ||
|
||
PMP::sample_triangle_mesh(mesh, std::back_inserter(points), CGAL::parameters::number_of_points_per_face(points_per_face)); | ||
|
||
std::cout.precision(17); | ||
for(const Point& p : points){ | ||
std::cout << p << std::endl; | ||
} | ||
|
||
Point_set point_set; | ||
PMP::sample_triangle_mesh(mesh, | ||
point_set.point_back_inserter(), | ||
CGAL::parameters::point_map(point_set.point_push_map())); | ||
|
||
std::cout << point_set.number_of_points() << std::endl; | ||
return 0; | ||
} |