Actually use the new IO functions + some example improvements

This commit is contained in:
Mael Rouxel-Labbé 2020-06-23 18:24:39 +02:00
parent 239b01a546
commit 9cca59ba36
157 changed files with 1272 additions and 1219 deletions

View File

@ -1,7 +1,5 @@
#include <iostream>
#include <fstream>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/Polyhedron_3.h>
@ -9,6 +7,9 @@
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/Timer.h>
#include <iostream>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::FT FT;
typedef K::Point_3 Point_3;
@ -26,8 +27,12 @@ void triangle_mesh(const char* fname)
typedef CGAL::AABB_tree<Traits> Tree;
TriangleMesh tmesh;
std::ifstream in(fname);
in >> tmesh;
if(!CGAL::read_polygon_mesh(fname, tmesh) || CGAL::is_triangle_mesh(tmesh))
{
std::cerr << "Invalid input." << std::endl;
return;
}
Timer t;
t.start();
Tree tree(faces(tmesh).first, faces(tmesh).second, tmesh);
@ -36,7 +41,6 @@ void triangle_mesh(const char* fname)
std::cout << "Closest point to ORIGIN:" << tree.closest_point(CGAL::ORIGIN) << std::endl;
}
Bbox_3 bbox(boost::graph_traits<Surface_mesh>::face_descriptor fd,
const Surface_mesh& p)
{
@ -47,7 +51,6 @@ Bbox_3 bbox(boost::graph_traits<Surface_mesh>::face_descriptor fd,
return res;
}
void surface_mesh_cache_bbox(const char* fname)
{
typedef boost::graph_traits<Surface_mesh>::face_descriptor face_descriptor;
@ -64,9 +67,9 @@ void surface_mesh_cache_bbox(const char* fname)
t.start();
Bbox_pmap bb = tmesh.add_property_map<face_descriptor,Bbox_3>("f:bbox",Bbox_3()).first;
for(face_descriptor fd : faces(tmesh)){
for(face_descriptor fd : faces(tmesh))
put(bb, fd, bbox(fd,tmesh));
}
Traits traits(bb);
Tree tree(traits);
tree.insert(faces(tmesh).first, faces(tmesh).second, tmesh);
@ -77,7 +80,6 @@ void surface_mesh_cache_bbox(const char* fname)
std::cout << "Closest point to ORIGIN:" << tree.closest_point(CGAL::ORIGIN) << std::endl;
}
int main(int argc, char* argv[])
{
std::cout << "Polyhedron_3" << std::endl;

View File

@ -1,14 +1,15 @@
#include <iostream>
#include <fstream>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/Polygon_mesh_processing/compute_normal.h>
#include <CGAL/Polygon_mesh_processing/orientation.h>
#include <iostream>
#include <fstream>
typedef CGAL::Simple_cartesian<double> K;
typedef K::FT FT;
typedef K::Point_3 Point;
@ -24,8 +25,8 @@ typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef boost::optional<Tree::Intersection_and_primitive_id<Ray>::Type> Ray_intersection;
struct Skip {
struct Skip
{
face_descriptor fd;
Skip(const face_descriptor fd)
@ -44,14 +45,20 @@ struct Skip {
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/tetrahedron.off";
std::ifstream input(filename);
Mesh mesh;
input >> mesh;
if(!CGAL::read_polygon_mesh(filename, mesh))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
Tree tree(faces(mesh).first, faces(mesh).second, mesh);
double d = CGAL::Polygon_mesh_processing::is_outward_oriented(mesh)?-1:1;
for(face_descriptor fd : faces(mesh)){
for(face_descriptor fd : faces(mesh))
{
halfedge_descriptor hd = halfedge(fd,mesh);
Point p = CGAL::centroid(mesh.point(source(hd,mesh)),
mesh.point(target(hd,mesh)),
@ -61,13 +68,16 @@ int main(int argc, char* argv[])
Ray ray(p,d * v);
Skip skip(fd);
Ray_intersection intersection = tree.first_intersection(ray, skip);
if(intersection){
if(intersection)
{
if(boost::get<Point>(&(intersection->first))){
const Point* p = boost::get<Point>(&(intersection->first) );
std::cout << *p << std::endl;
}
}
}
std::cerr << "done" << std::endl;
return 0;
}

View File

@ -113,8 +113,7 @@ int main (int argc, char* argv[])
const char* fname = (argc>1) ? argv[1] : "data/cube.pwn";
// Loading point set from a file.
if (!CGAL::read_points(fname,
std::back_inserter(points),
if (!CGAL::read_points(fname, std::back_inserter(points),
CGAL::parameters::point_map(Point_map()).
normal_map(Normal_map())))
{

View File

@ -14,9 +14,14 @@ typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/prim.off";
Mesh sm;
std::ifstream in((argc>1)?argv[1]:"data/prim.off");
in >> sm;
if(!CGAL::read_polygon_mesh(filename, sm))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
Mesh::Property_map<vertex_descriptor,int> ccmap;
ccmap = sm.add_property_map<vertex_descriptor,int>("v:CC").first;

View File

@ -14,10 +14,15 @@ typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
int main(int argc, char* argv[])
{
const char* filename = (argc>1) ? argv[1] : "data/prim.off";
Mesh P;
//std::cin >> P;
std::ifstream in((argc>1)?argv[1]:"data/prim.off");
in >> P;
if(!CGAL::read_polygon_mesh(filename, P))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
Mesh::Property_map<vertex_descriptor,vertex_descriptor> predecessor;
predecessor = P.add_property_map<vertex_descriptor,vertex_descriptor>("v:predecessor").first;

View File

@ -4,14 +4,15 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/boost/graph/Seam_mesh.h>
#include <CGAL/boost/graph/io.h>
#include <CGAL/Polygon_mesh_processing/connected_components.h>
#include <iostream>
#include <fstream>
#include <vector>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point;
typedef CGAL::Surface_mesh<Point> Mesh;
@ -30,12 +31,16 @@ typedef boost::graph_traits<Seam_mesh>::halfedge_descriptor halfedge_descr
typedef boost::graph_traits<Seam_mesh>::edge_descriptor edge_descriptor;
typedef boost::graph_traits<Seam_mesh>::face_descriptor face_descriptor;
int main(int argc, char* argv[])
{
const char* filename = (argc>1) ? argv[1] : "data/cube.off";
Mesh sm;
std::ifstream in((argc>1) ? argv[1] : "data/cube.off");
in >> sm;
if(!CGAL::read_polygon_mesh(filename, sm))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
Seam_edge_pmap seam_edge_pm =
sm.add_property_map<SM_edge_descriptor, bool>("e:on_seam", false).first;

View File

@ -37,12 +37,13 @@ typedef boost::graph_traits<Mesh>::edge_descriptor edge_descriptor;
int main(int argc, char* argv[])
{
Mesh primal;
const char* filename = (argc > 1) ? argv[1] : "data/prim.off";
std::ifstream in(filename);
if(!(in >> primal)) {
std::cerr << "Error reading polyhedron from file " << filename << std::endl;
return EXIT_FAILURE;
Mesh primal;
if(!CGAL::read_polygon_mesh(filename, primal))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
Dual dual(primal);

View File

@ -13,11 +13,15 @@ typedef CGAL::Surface_mesh<K::Point_3> SM;
int main(int argc, char** argv)
{
const char* filename = (argc>1)?argv[1]:"data/blobby.off";
const char* filename = (argc>1) ? argv[1] : "data/blobby.off";
int number_of_parts = (argc>2) ? atoi(argv[2]) : 8;
SM sm;
CGAL::read_polygon_mesh(filename, sm);
if(!CGAL::read_polygon_mesh(filename, sm))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
// The vertex <--> partition_id property map
typedef SM::Property_map<SM::Vertex_index, std::size_t> Vertex_id_map;

View File

@ -47,12 +47,11 @@ typedef Classification::Feature::Vertical_dispersion<Kernel, Point_range, Pmap>
int main (int argc, char** argv)
{
std::string filename (argc > 1 ? argv[1] : "data/b9.ply");
std::ifstream in (filename.c_str());
std::vector<Point> pts;
const char* filename = (argc > 1) ? argv[1] : "data/b9.ply";
std::cerr << "Reading input" << std::endl;
if (!in || !(CGAL::read_points(in, std::back_inserter(pts))))
std::vector<Point> pts;
if (!(CGAL::read_points(filename, std::back_inserter(pts))))
{
std::cerr << "Error: cannot read " << filename << std::endl;
return EXIT_FAILURE;

View File

@ -49,19 +49,16 @@ typedef Classification::Cluster<Point_set, Pmap> Clu
int main (int argc, char** argv)
{
std::string filename = "data/b9.ply";
std::string filename_config = "data/b9_clusters_config.gz";
if (argc > 1)
filename = argv[1];
if (argc > 2)
filename_config = argv[2];
std::ifstream in (filename.c_str(), std::ios::binary);
Point_set pts;
std::string filename = (argc>1) ? argv[1] : "data/b9.ply";
std::string filename_config = (argc>2) ? argv[2] : "data/b9_clusters_config.gz";
std::cerr << "Reading input" << std::endl;
in >> pts;
Point_set pts;
if(!(CGAL::read_point_set(filename, pts)))
{
std::cerr << "Error: cannot read " << filename << std::endl;
return EXIT_FAILURE;
}
std::cerr << "Estimating normals" << std::endl;
CGAL::Real_timer t;

View File

@ -67,11 +67,10 @@ public:
int main (int argc, char** argv)
{
std::string filename (argc > 1 ? argv[1] : "data/b9.ply");
std::ifstream in (filename.c_str());
std::vector<Point> pts;
std::cerr << "Reading input" << std::endl;
if (!in || !(CGAL::read_points(in, std::back_inserter(pts))))
if (!(CGAL::read_points(filename, std::back_inserter(pts))))
{
std::cerr << "Error: cannot read " << filename << std::endl;
return EXIT_FAILURE;

View File

@ -3,17 +3,17 @@
// converts 64 to 32 bits integers
#endif
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Classification.h>
#include <CGAL/Real_timer.h>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <string>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Classification.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Real_timer.h>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point;
typedef CGAL::Surface_mesh<Point> Mesh;
@ -31,19 +31,15 @@ typedef Classification::Mesh_feature_generator<Kernel, Mesh, Face_point_map>
int main (int argc, char** argv)
{
std::string filename = "data/b9_mesh.off";
std::string filename_config = "data/b9_mesh_config.gz";
std::string filename = (argc>1) ? argv[1] : "data/b9_mesh.off";
std::string filename_config = (argc>2) ? argv[2] : "data/b9_mesh_config.gz";
if (argc > 1)
filename = argv[1];
if (argc > 2)
filename_config = argv[2];
std::ifstream in (filename.c_str());
Mesh mesh;
std::cerr << "Reading input" << std::endl;
in >> mesh;
if(!CGAL::read_polygon_mesh(filename, mesh))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
std::cerr << "Generating features" << std::endl;
CGAL::Real_timer t;

View File

@ -36,15 +36,11 @@ typedef Classification::Point_set_feature_generator<Kernel, Point_set, Pmap>
int main (int argc, char** argv)
{
std::string filename = "data/b9_training.ply";
if (argc > 1)
filename = argv[1];
std::ifstream in (filename.c_str(), std::ios::binary);
Point_set pts;
std::string filename = (argc > 1) ? argv[1] : "data/b9_training.ply";
std::cerr << "Reading input" << std::endl;
std::ifstream in (filename.c_str(), std::ios::binary);
Point_set pts;
in >> pts;
Imap label_map;

View File

@ -36,15 +36,11 @@ typedef Classification::Point_set_feature_generator<Kernel, Point_set, Pmap>
int main (int argc, char** argv)
{
std::string filename = "data/b9_training.ply";
if (argc > 1)
filename = argv[1];
std::ifstream in (filename.c_str(), std::ios::binary);
Point_set pts;
std::string filename = (argc > 1) ? argv[1] : "data/b9_training.ply";
std::cerr << "Reading input" << std::endl;
std::ifstream in (filename.c_str(), std::ios::binary);
Point_set pts;
in >> pts;
Imap label_map;

View File

@ -218,7 +218,7 @@ int main (int argc, char** argv)
CGAL::copy_face_graph (dsm, dsm_mesh);
std::ofstream dsm_ofile ("dsm.ply", std::ios_base::binary);
CGAL::set_binary_mode (dsm_ofile);
CGAL::write_ply (dsm_ofile, dsm_mesh);
CGAL::write_PLY (dsm_ofile, dsm_mesh);
dsm_ofile.close();
//! [Save DSM]
@ -323,7 +323,7 @@ int main (int argc, char** argv)
std::ofstream tin_colored_ofile ("colored_tin.ply", std::ios_base::binary);
CGAL::set_binary_mode (tin_colored_ofile);
CGAL::write_ply (tin_colored_ofile, tin_colored_mesh);
CGAL::write_PLY (tin_colored_ofile, tin_colored_mesh);
tin_colored_ofile.close();
//! [Save TIN with info]
@ -416,7 +416,7 @@ int main (int argc, char** argv)
// Save original DTM
std::ofstream dtm_ofile ("dtm.ply", std::ios_base::binary);
CGAL::set_binary_mode (dtm_ofile);
CGAL::write_ply (dtm_ofile, dtm_mesh);
CGAL::write_PLY (dtm_ofile, dtm_mesh);
dtm_ofile.close();
std::cerr << face_selection.size() << " face(s) are selected for removal" << std::endl;
@ -440,7 +440,7 @@ int main (int argc, char** argv)
// Save filtered DTM
std::ofstream dtm_holes_ofile ("dtm_with_holes.ply", std::ios_base::binary);
CGAL::set_binary_mode (dtm_holes_ofile);
CGAL::write_ply (dtm_holes_ofile, dtm_mesh);
CGAL::write_PLY (dtm_holes_ofile, dtm_mesh);
dtm_holes_ofile.close();
// Get all holes
@ -478,7 +478,7 @@ int main (int argc, char** argv)
// Save DTM with holes filled
std::ofstream dtm_filled_ofile ("dtm_filled.ply", std::ios_base::binary);
CGAL::set_binary_mode (dtm_filled_ofile);
CGAL::write_ply (dtm_filled_ofile, dtm_mesh);
CGAL::write_PLY (dtm_filled_ofile, dtm_mesh);
dtm_filled_ofile.close();
//! [Hole filling]
@ -491,7 +491,7 @@ int main (int argc, char** argv)
std::ofstream dtm_remeshed_ofile ("dtm_remeshed.ply", std::ios_base::binary);
CGAL::set_binary_mode (dtm_remeshed_ofile);
CGAL::write_ply (dtm_remeshed_ofile, dtm_mesh);
CGAL::write_PLY (dtm_remeshed_ofile, dtm_mesh);
dtm_remeshed_ofile.close();
//! [Remeshing]

View File

@ -20,7 +20,7 @@ int main()
// generate 250 points randomly in a sphere of radius 100.0
// and insert them into the triangulation
std::copy_n(gen, 250, std::back_inserter(points) );
std::copy_n(gen, 250, std::back_inserter(points));
Delaunay T;
T.insert(points.begin(), points.end());

View File

@ -22,7 +22,7 @@ int main()
// generate 250 points randomly in a sphere of radius 100.0
// and insert them into the triangulation
std::copy_n(gen, 250, std::back_inserter(points) );
std::copy_n(gen, 250, std::back_inserter(points));
Delaunay T;
T.insert(points.begin(), points.end());

View File

@ -16,7 +16,6 @@ typedef K::Point_3 Point_3;
typedef CGAL::Delaunay_triangulation_3<K> Delaunay;
typedef Delaunay::Vertex_handle Vertex_handle;
typedef OpenMesh::TriMesh_ArrayKernelT</* MyTraits*/> Surface_mesh;
int main()
@ -26,7 +25,7 @@ int main()
// generate 250 points randomly in a sphere of radius 100.0
// and insert them into the triangulation
std::copy_n(gen, 250, std::back_inserter(points) );
std::copy_n(gen, 250, std::back_inserter(points));
Delaunay T;
T.insert(points.begin(), points.end());

View File

@ -21,7 +21,7 @@ int main()
// generate 250 points randomly in a sphere of radius 100.0
// and insert them into the triangulation
std::copy_n(gen, 250, std::back_inserter(points) );
std::copy_n(gen, 250, std::back_inserter(points));
Delaunay T;
T.insert(points.begin(), points.end());

View File

@ -8,23 +8,20 @@
#include <vector>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_3 Point_3;
int main(int argc, char* argv[])
{
std::ifstream in( (argc>1)? argv[1] : "data/star.off");
const char* filename = (argc>1) ? argv[1] : "data/star.off";
if(!in)
std::vector<Point_3> points;
if(!CGAL::read_points(filename, std::back_inserter(points)))
{
std::cerr<< "Cannot open input file." <<std::endl;
return 1;
}
std::vector<Point_3> points;
CGAL::read_points(in, std::back_inserter(points));
//This will contain the extreme vertices
std::vector<std::size_t> extreme_point_indices;
@ -33,6 +30,7 @@ int main(int argc, char* argv[])
boost::counting_iterator<std::size_t>(points.size())),
std::back_inserter(extreme_point_indices),
CGAL::make_extreme_points_traits_adapter(CGAL::make_property_map(points)));
//print the number of extreme vertices
std::cout << "Indices of points on the convex hull are:\n";
std::copy(extreme_point_indices.begin(), extreme_point_indices.end(), std::ostream_iterator<std::size_t>(std::cout, " "));

View File

@ -1,21 +1,24 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Extreme_points_traits_adapter_3.h>
#include <CGAL/convex_hull_3.h>
#include <vector>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_3 Point_3;
typedef CGAL::Surface_mesh<Point_3> Mesh;
int main(int argc, char* argv[])
{
std::ifstream in( (argc>1)? argv[1] : "data/star.off");
const char* filename = (argc>1) ? argv[1] : "data/star.off";
Mesh sm;
if(! in || !(in >> sm) || !sm.is_valid()){
std::cerr<<"Not a valid off file."<<std::endl;
if(!CGAL::read_polygon_mesh(filename, sm))
{
std::cerr<< "Cannot open input file." <<std::endl;
return 1;
}
//This will contain the extreme vertices
@ -24,6 +27,7 @@ int main(int argc, char* argv[])
//call the function with the traits adapter for vertices
CGAL::extreme_points_3(vertices(sm), std::back_inserter(extreme_vertices),
CGAL::make_extreme_points_traits_adapter(sm.points()));
//print the number of extreme vertices
std::cout << "There are " << extreme_vertices.size() << " extreme vertices in this mesh." << std::endl;

View File

@ -13,17 +13,16 @@ typedef CGAL::Surface_mesh<Point_3> Surface_mesh;
int main(int argc, char* argv[])
{
std::ifstream in( (argc>1)? argv[1] : "data/star.off");
const char* filename = (argc>1) ? argv[1] : "data/star.off";
Surface_mesh poly;
if(!(in >> poly))
if(!CGAL::read_polygon_mesh(filename, poly))
{
std::cerr<<"Could not find input file."<<std::endl;
std::cerr<< "Cannot open input file." <<std::endl;
return 1;
}
Surface_mesh chull;
// compute convex hull
Surface_mesh chull;
CGAL::convex_hull_3(poly, chull);
std::cout << "The convex hull contains " << chull.number_of_vertices() << " vertices" << std::endl;

View File

@ -1,12 +1,14 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/convex_hull_3.h>
#include <vector>
#include <fstream>
#include <CGAL/convex_hull_3.h>
#include <CGAL/boost/graph/io.h>
#include <CGAL/boost/graph/graph_traits_TriMesh_ArrayKernelT.h>
#include <OpenMesh/Core/IO/MeshIO.hh>
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
#include <CGAL/boost/graph/graph_traits_TriMesh_ArrayKernelT.h>
#include <vector>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_3
@ -15,12 +17,11 @@ typedef OpenMesh::TriMesh_ArrayKernelT</* MyTraits*/> Mesh;
int main(int argc, char* argv[])
{
std::ifstream in( (argc>1)? argv[1] : "data/cube.xyz");
std::ifstream in((argc>1) ? argv[1] : "data/cube.xyz");
std::vector<Point_3> points;
Point_3 p, n;
while(in >> p >> n){
while(in >> p >> n)
points.push_back(p);
}
// define polyhedron to hold convex hull
Mesh poly;
@ -28,12 +29,10 @@ int main(int argc, char* argv[])
// compute convex hull of non-collinear points
CGAL::convex_hull_3(points.begin(), points.end(), poly);
Mesh sm;
CGAL::convex_hull_3(points.begin(), points.end(), sm);
CGAL::write_off((argc>2)?argv[2]:"out.off", sm);
CGAL::write_polygon_mesh((argc>2)?argv[2]:"out.off", sm);
return 0;
}

View File

@ -1,5 +1,6 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/convex_hull_3.h>
#include <CGAL/Convex_hull_traits_3.h>
#include <CGAL/Extreme_points_traits_adapter_3.h>
@ -7,18 +8,17 @@
#include <CGAL/Cartesian.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <vector>
#include <cassert>
#include <algorithm>
#include <fstream>
#include <iostream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Polyhedron_3<K> Polyhedron_3;
typedef K::Point_3 Point_3;
void test_function_overload()
{
std::vector<Point_3> points;

View File

@ -5,7 +5,6 @@
#include <iostream>
#include <fstream>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point_3;
typedef CGAL::Surface_mesh<Point_3> Triangle_mesh;
@ -15,12 +14,14 @@ typedef Triangle_mesh::Property_map<vertex_descriptor,double> Vertex_distance_ma
int main(int argc, char* argv[])
{
Triangle_mesh tm;
const char* filename = (argc > 1) ? argv[1] : "./data/elephant.off";
std::ifstream input(filename);
if (!input || !(input >> tm) || tm.is_empty()) {
std::cerr << "Not a valid off file." << std::endl;
return 1;
Triangle_mesh tm;
if(!CGAL::read_polygon_mesh(filename, tm) ||
CGAL::is_empty(tm) || !CGAL::is_triangle_mesh(tm))
{
std::cerr << "Invalid input file." << std::endl;
return EXIT_FAILURE;
}
//property map for the distance values to the source set
@ -31,7 +32,8 @@ int main(int argc, char* argv[])
CGAL::Heat_method_3::estimate_geodesic_distances(tm, vertex_distance, source) ;
std::cout << "Source vertex " << source << " at: " << tm.point(source) << std::endl;
for(vertex_descriptor vd : vertices(tm)){
for(vertex_descriptor vd : vertices(tm))
{
std::cout << vd << " ("<< tm.point(vd) << ")"
<< " is at distance " << get(vertex_distance, vd) << std::endl;
}

View File

@ -2,11 +2,11 @@
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Heat_method_3/Surface_mesh_geodesic_distances_3.h>
#include <boost/unordered_map.hpp>
#include <fstream>
#include <iostream>
#include <boost/unordered_map.hpp>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point_3;
typedef CGAL::Polyhedron_3<Kernel> Triangle_mesh;

View File

@ -1,10 +1,11 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Heat_method_3/Surface_mesh_geodesic_distances_3.h>
#include <fstream>
#include <iostream>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point_3;
typedef CGAL::Surface_mesh<Point_3> Triangle_mesh;
@ -13,16 +14,16 @@ typedef boost::graph_traits<Triangle_mesh>::vertex_descriptor vertex_descriptor;
typedef Triangle_mesh::Property_map<vertex_descriptor,double> Vertex_distance_map;
typedef CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3<Triangle_mesh> Heat_method;
int main(int argc, char* argv[])
{
Triangle_mesh tm;
const char* filename = (argc > 1) ? argv[1] : "./data/sphere.off";
std::ifstream input(filename);
if (!input || !(input >> tm) || tm.is_empty()) {
std::cerr << "Not a valid off file." << std::endl;
return 1;
Triangle_mesh tm;
if(!CGAL::read_polygon_mesh(filename, tm) ||
CGAL::is_empty(tm) || !CGAL::is_triangle_mesh(tm))
{
std::cerr << "Invalid input file." << std::endl;
return EXIT_FAILURE;
}
//property map for the distance values to the source set

View File

@ -19,11 +19,11 @@ typedef CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3<Triangle_mesh, CG
int main(int argc, char* argv[])
{
Triangle_mesh tm;
const char* filename = (argc > 1) ? argv[1] : "./data/elephant.off";
std::ifstream input(filename);
if (!input || !(input >> tm) || tm.is_empty()) {
std::cerr << "Not a valid off file." << std::endl;
return 1;
if(!CGAL::read_polygon_mesh(filename, tm) ||
CGAL::is_empty(tm) || !CGAL::is_triangle_mesh(tm))
{
std::cerr << "Invalid input file." << std::endl;
return EXIT_FAILURE;
}
//property map for the distance values to the source set

View File

@ -4,6 +4,7 @@
#include <CGAL/optimal_bounding_box.h>
#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>
#include <CGAL/Polygon_mesh_processing/measure.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/Real_timer.h>
@ -19,9 +20,10 @@ typedef CGAL::Surface_mesh<Point> Surface_mesh;
int main(int argc, char** argv)
{
std::ifstream input((argc > 1) ? argv[1] : "data/pig.off");
const char* filename = (argc > 1) ? argv[1] : "data/pig.off";
Surface_mesh sm;
if(!input || !(input >> sm) || sm.is_empty())
if(!PMP::read_polygon_mesh(filename, sm) || sm.is_empty())
{
std::cerr << "Invalid input file." << std::endl;
return EXIT_FAILURE;

View File

@ -2,6 +2,7 @@
#include <CGAL/Surface_mesh.h>
#include <CGAL/optimal_bounding_box.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <array>
#include <fstream>
@ -20,9 +21,10 @@ namespace CP = CGAL::parameters;
int main(int argc, char** argv)
{
std::ifstream input((argc > 1) ? argv[1] : "data/pig.off");
const char* filename = (argc > 1) ? argv[1] : "data/pig.off";
Surface_mesh sm;
if (!input || !(input >> sm) || sm.is_empty())
if(!CGAL::Polygon_mesh_processing::read_polygon_mesh(filename, sm) || sm.is_empty())
{
std::cerr << "Invalid input file." << std::endl;
return EXIT_FAILURE;

View File

@ -5,6 +5,7 @@
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/optimal_bounding_box.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <boost/property_map/function_property_map.hpp>
@ -32,9 +33,10 @@ private:
int main(int argc, char** argv)
{
std::ifstream input((argc > 1) ? argv[1] : "data/pig.off");
const char* filename = (argc > 1) ? argv[1] : "data/pig.off";
Surface_mesh sm;
if (!input || !(input >> sm) || sm.is_empty())
if(!CGAL::Polygon_mesh_processing::read_polygon_mesh(filename, sm) || sm.is_empty())
{
std::cerr << "Invalid input file." << std::endl;
return EXIT_FAILURE;

View File

@ -14,8 +14,8 @@ typedef CGAL::Point_set_3<Point> Point_set;
int main (int argc, char** argv)
{
const char* filename = argc > 1 ? argv[1] : "data/oni.xyz";
Point_set point_set;
Point_set point_set;
if(!CGAL::read_point_set(filename, point_set))
{
std::cerr << "Can't read input file " << filename << std::endl;

View File

@ -48,7 +48,7 @@ int main (int argc, char** argv)
std::ofstream out ("out.ply",
std::ios_base::binary); // Mandatory on Windows
CGAL::set_binary_mode (out); // Select binary mode (ASCII is default)
out << point_set; // same as `CGAL::write_ply_point_set (out, point_set)`
out << point_set; // same as `CGAL::write_PLY(out, point_set)`
}
else // ASCII output
{

View File

@ -16,10 +16,9 @@ int main (int argc, char** argv)
{
const char* fname = argc > 1 ? argv[1] : "data/oni.xyz";
// Reading input
Point_set point_set;
// Reading input in XYZ format
if(!CGAL::read_point_set(fname, point_set))
if(!CGAL::read_XYZ(fname, point_set))
{
std::cerr << "Can't read input file " << std::endl;
return EXIT_FAILURE;

View File

@ -152,7 +152,7 @@ template <typename Point, typename Vector>
std::ostream& operator<<(std::ostream& os,
const CGAL::Point_set_3<Point, Vector>& ps)
{
write_ply_point_set(os, ps);
write_PLY(os, ps);
return os;
}

View File

@ -22,7 +22,7 @@ int main(int argc, char*argv[])
{
const char* fname = (argc>1)?argv[1]:"data/sphere_20k.xyz";
// Reads a .xyz point set file in points.
// Reads a file in points.
// As the point is the second element of the tuple (that is with index 1)
// we use a property map that accesses the 1st element of the tuple.

View File

@ -25,7 +25,7 @@ int main(int argc, char*argv[])
const char* input_filename = (argc>1) ? argv[1] : "data/fin90_with_PCA_normals.xyz";
const char* output_filename = (argc>2) ? argv[2] : "data/fin90_with_PCA_normals_bilateral_smoothed.xyz";
// Reads a .xyz point set file in points[] * with normals *.
// Reads a point set file in points[] * with normals *.
std::vector<PointVectorPair> points;
if(!CGAL::read_points(input_filename, std::back_inserter(points),
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())

View File

@ -20,7 +20,7 @@ typedef std::array<double,6> Covariance;
int main (int , char**)
{
// Reads a .xyz point set file in points[].
// Reads a polygon mesh file in points[].
std::list<PointVectorPair> points;
if(!CGAL::read_points("data/fandisk.off",
std::back_inserter(points),

View File

@ -12,9 +12,10 @@ typedef Kernel::Point_3 Point;
int main(int argc, char*argv[])
{
// Reads a .xyz point set file in points[].
std::vector<Point> points;
const char* fname = (argc>1) ? argv[1] : "data/oni.xyz";
// Reads a point set file in points[].
std::vector<Point> points;
if(!CGAL::read_points(fname, std::back_inserter(points)))
{
std::cerr << "Error: cannot read file " << fname << std::endl;

View File

@ -13,10 +13,11 @@ typedef Kernel::Vector_3 Vector;
int main(int argc, char*argv[])
{
const char* fname = (argc>1) ? argv[1] : "data/fin90_with_PCA_normals.xyz";
// Reads a .xyz point set file in points[].
std::vector<Point> points;
std::vector<Vector> normals;
const char* fname = (argc>1) ? argv[1] : "data/fin90_with_PCA_normals.xyz";
std::ifstream stream(fname);
Point p;
Vector v;

View File

@ -15,9 +15,10 @@ typedef Kernel::Point_3 Point;
int main(int argc, char*argv[])
{
const char* fname = (argc>1) ? argv[1] : "data/oni.xyz";
// Reads a point set file in points[].
std::vector<Point> points;
const char* fname = (argc>1)?argv[1]:"data/oni.xyz";
if(!CGAL::read_points(fname, std::back_inserter(points)))
{
std::cerr << "Error: cannot read file " << fname << std::endl;

View File

@ -240,11 +240,10 @@ int main(int argc, char * argv[])
// Loads point set
//***************************************
// Reads a .off or .xyz point set file in points[].
// Reads a point set file in points[].
PointList points;
std::cerr << "Open " << input_filename << " for reading..." << std::endl;
// If OFF file format
if(!CGAL::read_points(input_filename.c_str(), std::back_inserter(points),
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())))
{

View File

@ -25,7 +25,7 @@ int main(int argc, char*argv[])
{
const char* fname = (argc>1) ? argv[1] : "data/sphere_1k.xyz";
// Reads a .xyz point set file in points[].
// Reads a point set file in points[].
std::list<PointVectorPair> points;
if(!CGAL::read_points(fname,
std::back_inserter(points),

View File

@ -17,11 +17,10 @@ typedef std::pair<Point, Color> PointWithColor;
int main(int argc, char*argv[])
{
const char* fname = (argc>1) ? argv[1] : "data/pig_points.las";
// Reads a .las point set file with normal vectors and colors
std::vector<PointWithColor> points; // store points
std::ifstream in(fname, std::ios_base::binary);
std::vector<PointWithColor> points; // store points
if(!CGAL::read_LAS_with_properties(in, std::back_inserter (points),
CGAL::make_las_point_reader(CGAL::First_of_pair_property_map<PointWithColor>()),
std::make_tuple(CGAL::Second_of_pair_property_map<PointWithColor>(),

View File

@ -1,4 +1,5 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/write_xyz_points.h>
@ -18,7 +19,8 @@ typedef std::pair<Point, Vector> Pwn;
int main(int argc, char*argv[])
{
const char* fname = (argc>1)?argv[1]:"data/oni.xyz";
const char* fname = (argc>1) ? argv[1] : "data/oni.xyz";
// Reads a .xyz point set file in points[].
// Note: read_points() requires an output iterator
// over points and as well as property maps to access each

View File

@ -1,6 +1,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/IO/write_ply_points.h>
#include <CGAL/IO/write_points.h>
#include <CGAL/property_map.h>
#include <CGAL/OpenGR/compute_registration_transformation.h>

View File

@ -1,6 +1,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/IO/write_ply_points.h>
#include <CGAL/IO/write_points.h>
#include <CGAL/property_map.h>
#include <CGAL/Aff_transformation_3.h>
#include <CGAL/aff_transformation_tags.h>

View File

@ -25,9 +25,8 @@ int main (int argc, char** argv)
CGAL::Timer task_timer;
std::vector<Point_3> points;
// read input
std::vector<Point_3> points;
if(!CGAL::read_points(fname, std::back_inserter(points)))
{
std::cerr << "Error: can't read input file" << std::endl;

View File

@ -25,13 +25,14 @@ typedef CGAL::Shape_detection::Plane<Traits> Plane;
int main (int argc, char** argv)
{
const char* filename = (argc>1) ? argv[1] : "data/cube.pwn";
// Points with normals.
Pwn_vector points;
// Loading point set from a file.
if (!CGAL::read_points((argc>1 ? argv[1] : "data/cube.pwn"),
std::back_inserter(points),
if(!CGAL::read_points(filename, std::back_inserter(points),
CGAL::parameters::point_map(Point_map())
.normal_map(Normal_map())))
{

View File

@ -1,13 +1,13 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/config.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/property_map.h>
#include <vector>
#include <cassert>
#include <string>
#include <fstream>
#include <string>
#include <vector>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point_3;
@ -25,8 +25,7 @@ bool read(std::string s)
bool read(std::string s,
std::vector<PointVectorPair>& pv_pairs)
{
return CGAL::read_points(s,
back_inserter(pv_pairs),
return CGAL::read_points(s, back_inserter(pv_pairs),
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())
.normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()));
}
@ -34,19 +33,17 @@ bool read(std::string s,
bool read_off(std::string s,
std::vector<PointVectorPair>& pv_pairs)
{
return CGAL::read_OFF(s,
back_inserter(pv_pairs),
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()));
return CGAL::read_OFF(s, back_inserter(pv_pairs),
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())
.normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()));
}
bool read_ply(std::string s,
std::vector<PointVectorPair>& pv_pairs)
{
return CGAL::read_PLY(s,
back_inserter(pv_pairs),
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()));
return CGAL::read_PLY(s, back_inserter(pv_pairs),
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())
.normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()));
}
int main()

View File

@ -141,7 +141,7 @@ int main(int argc, char*argv[])
std::ofstream f ("out.ply", std::ios_base::binary);
CGAL::set_binary_mode (f);
CGAL::write_ply (f, output_mesh);
CGAL::write_PLY(f, output_mesh);
f.close ();
//! [Output poisson]

View File

@ -2,11 +2,10 @@
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/compute_normal.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <iostream>
#include <fstream>
namespace PMP = CGAL::Polygon_mesh_processing;
#include <iostream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
@ -17,14 +16,16 @@ typedef CGAL::Surface_mesh<Point> Surface_mesh;
typedef boost::graph_traits<Surface_mesh>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Surface_mesh>::face_descriptor face_descriptor;
namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/eight.off";
std::ifstream input(filename);
Surface_mesh mesh;
if (!input || !(input >> mesh) || mesh.is_empty()) {
std::cerr << "Not a valid off file." << std::endl;
if(!PMP::read_polygon_mesh(filename, mesh))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}

View File

@ -18,8 +18,6 @@ typedef OpenMesh::PolyMesh_ArrayKernelT< > Mesh;
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor;
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/eight.off";
@ -33,26 +31,23 @@ int main(int argc, char* argv[])
mesh.add_property(vnormals.handle());
Vector v(0, 0, 0);
for(vertex_descriptor vd : vertices(mesh)){
for(vertex_descriptor vd : vertices(mesh))
put(vnormals, vd, v);
}
for(face_descriptor fd : faces(mesh)){
for(face_descriptor fd : faces(mesh))
put(fnormals, fd, v);
}
CGAL::Polygon_mesh_processing::compute_normals
(mesh,
vnormals,
fnormals,
CGAL::Polygon_mesh_processing::parameters::vertex_point_map(get(CGAL::vertex_point, mesh)).
geom_traits(K()));
CGAL::Polygon_mesh_processing::compute_normals(mesh, vnormals, fnormals,
CGAL::parameters::vertex_point_map(get(CGAL::vertex_point, mesh))
.geom_traits(K()));
std::cout << "Face normals :" << std::endl;
for(face_descriptor fd : faces(mesh)){
for(face_descriptor fd : faces(mesh))
std::cout << fnormals[fd] << std::endl;
}
std::cout << "Normals at vertices :" << std::endl;
for(vertex_descriptor vd : vertices(mesh)){
for(vertex_descriptor vd : vertices(mesh))
std::cout << vnormals[vd] << std::endl;
}
return 0;
}

View File

@ -1,14 +1,16 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Polygon_mesh_processing/compute_normal.h>
#include <boost/property_map/property_map.hpp>
#include <map>
#include <CGAL/Polygon_mesh_processing/compute_normal.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
// #include <CGAL/Unique_hash_map.h>
// #include <boost/unordered_map.hpp>
#include <boost/property_map/property_map.hpp>
#include <iostream>
#include <fstream>
#include <map>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_3 Point;
@ -18,14 +20,16 @@ typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef boost::graph_traits<Polyhedron>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Polyhedron>::face_descriptor face_descriptor;
namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/eight.off";
std::ifstream input(filename);
Polyhedron mesh;
if (!input || !(input >> mesh) || mesh.is_empty()) {
std::cerr << "Not a valid off file." << std::endl;
if(!PMP::read_polygon_mesh(filename, mesh))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
@ -36,17 +40,16 @@ int main(int argc, char* argv[])
// CGAL::Unique_hash_map<face_descriptor,Vector> fnormals;
// boost::unordered_map<vertex_descriptor,Vector> vnormals;
CGAL::Polygon_mesh_processing::compute_normals(mesh,
boost::make_assoc_property_map(vnormals),
PMP::compute_normals(mesh, boost::make_assoc_property_map(vnormals),
boost::make_assoc_property_map(fnormals));
std::cout << "Face normals :" << std::endl;
for(face_descriptor fd: faces(mesh)){
for(face_descriptor fd: faces(mesh))
std::cout << fnormals[fd] << std::endl;
}
std::cout << "Vertex normals :" << std::endl;
for(vertex_descriptor vd: vertices(mesh)){
for(vertex_descriptor vd: vertices(mesh))
std::cout << vnormals[vd] << std::endl;
}
return 0;
}

View File

@ -2,8 +2,11 @@
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/connected_components.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <boost/function_output_iterator.hpp>
#include <boost/property_map/property_map.hpp>
#include <iostream>
#include <fstream>
#include <map>
@ -69,11 +72,11 @@ struct Put_true
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/blobby_3cc.off";
std::ifstream input(filename);
Mesh mesh;
if (!input || !(input >> mesh) || mesh.is_empty()) {
std::cerr << "Not a valid off file." << std::endl;
if(!PMP::read_polygon_mesh(filename, mesh))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}

View File

@ -8,9 +8,9 @@
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point;
typedef CGAL::Linear_cell_complex_traits<3, Kernel> MyTraits;
typedef CGAL::Linear_cell_complex_for_bgl_combinatorial_map_helper
<2, 3, MyTraits>::type LCC;
typedef CGAL::Linear_cell_complex_for_bgl_combinatorial_map_helper<2, 3, MyTraits>::type LCC;
namespace PMP = CGAL::Polygon_mesh_processing;
@ -18,11 +18,13 @@ int main(int argc, char* argv[])
{
const char* filename1 = (argc > 1) ? argv[1] : "data/blobby.off";
const char* filename2 = (argc > 2) ? argv[2] : "data/eight.off";
std::ifstream input(filename1);
LCC mesh1, mesh2;
CGAL::Polygon_mesh_processing::IO::read_polygon_mesh(filename1, mesh1);
CGAL::Polygon_mesh_processing::IO::read_polygon_mesh(filename2, mesh2);
if(!PMP::read_polygon_mesh(filename1, mesh1) || !PMP::read_polygon_mesh(filename2, mesh2))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
std::cout << "Number of vertices before corefinement "
<< num_vertices(mesh1) << " and "

View File

@ -2,8 +2,10 @@
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <fstream>
#include <iostream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
@ -14,19 +16,11 @@ int main(int argc, char* argv[])
{
const char* filename1 = (argc > 1) ? argv[1] : "data/blobby.off";
const char* filename2 = (argc > 2) ? argv[2] : "data/eight.off";
std::ifstream input(filename1);
Mesh mesh1, mesh2;
if (!input || !(input >> mesh1))
if(!PMP::read_polygon_mesh(filename1, mesh1) || !PMP::read_polygon_mesh(filename2, mesh2))
{
std::cerr << "First mesh is not a valid off file." << std::endl;
return 1;
}
input.close();
input.open(filename2);
if (!input || !(input >> mesh2))
{
std::cerr << "Second mesh is not a valid off file." << std::endl;
std::cerr << "Invalid input." << std::endl;
return 1;
}

View File

@ -3,13 +3,17 @@
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <fstream>
#include <iostream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Exact_predicates_exact_constructions_kernel EK;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
typedef Mesh::Property_map<vertex_descriptor,EK::Point_3> Exact_point_map;
typedef Mesh::Property_map<vertex_descriptor,bool> Exact_point_computed;
@ -66,19 +70,11 @@ int main(int argc, char* argv[])
{
const char* filename1 = (argc > 1) ? argv[1] : "data/blobby.off";
const char* filename2 = (argc > 2) ? argv[2] : "data/eight.off";
std::ifstream input(filename1);
Mesh mesh1, mesh2;
if (!input || !(input >> mesh1))
if(!PMP::read_polygon_mesh(filename1, mesh1) || !PMP::read_polygon_mesh(filename2, mesh2))
{
std::cerr << "First mesh is not a valid off file." << std::endl;
return 1;
}
input.close();
input.open(filename2);
if (!input || !(input >> mesh2))
{
std::cerr << "Second mesh is not a valid off file." << std::endl;
std::cerr << "Invalid input." << std::endl;
return 1;
}
@ -111,9 +107,11 @@ int main(int argc, char* argv[])
output << mesh2;
return 0;
}
std::cout << "Union could not be computed\n";
return 1;
}
std::cout << "Intersection could not be computed\n";
return 1;
}

View File

@ -1,22 +1,27 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/Polygon_mesh_processing/remesh.h>
#include <CGAL/boost/graph/selection.h>
#include <fstream>
#include <iostream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
typedef boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
typedef boost::graph_traits<Mesh>::edge_descriptor edge_descriptor;
typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor;
typedef boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
namespace PMP = CGAL::Polygon_mesh_processing;
namespace params = PMP::parameters;
struct Vector_pmap_wrapper{
struct Vector_pmap_wrapper
{
std::vector<bool>& vect;
Vector_pmap_wrapper(std::vector<bool>& v) : vect(v) {}
friend bool get(const Vector_pmap_wrapper& m, face_descriptor f)
@ -33,19 +38,11 @@ int main(int argc, char* argv[])
{
const char* filename1 = (argc > 1) ? argv[1] : "data/blobby.off";
const char* filename2 = (argc > 2) ? argv[2] : "data/eight.off";
std::ifstream input(filename1);
Mesh mesh1, mesh2;
if (!input || !(input >> mesh1))
if(!PMP::read_polygon_mesh(filename1, mesh1) || !PMP::read_polygon_mesh(filename2, mesh2))
{
std::cerr << "First mesh is not a valid off file." << std::endl;
return 1;
}
input.close();
input.open(filename2);
if (!input || !(input >> mesh2))
{
std::cerr << "Second mesh is not a valid off file." << std::endl;
std::cerr << "Invalid input." << std::endl;
return 1;
}
@ -105,11 +102,8 @@ int main(int argc, char* argv[])
<< " faces were selected for the remeshing step\n";
// remesh the region around the intersection polylines
PMP::isotropic_remeshing(
selected_faces,
0.02,
mesh1,
params::edge_is_constrained_map(is_constrained_map) );
PMP::isotropic_remeshing(selected_faces, 0.02, mesh1,
params::edge_is_constrained_map(is_constrained_map));
std::ofstream output("difference_remeshed.off");
output.precision(17);

View File

@ -2,6 +2,7 @@
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <fstream>
@ -14,26 +15,18 @@ int main(int argc, char* argv[])
{
const char* filename1 = (argc > 1) ? argv[1] : "data/blobby.off";
const char* filename2 = (argc > 2) ? argv[2] : "data/eight.off";
std::ifstream input(filename1);
Mesh mesh1, mesh2;
if (!input || !(input >> mesh1))
if(!PMP::read_polygon_mesh(filename1, mesh1) || !PMP::read_polygon_mesh(filename2, mesh2))
{
std::cerr << "First mesh is not a valid off file." << std::endl;
return 1;
}
input.close();
input.open(filename2);
if (!input || !(input >> mesh2))
{
std::cerr << "Second mesh is not a valid off file." << std::endl;
std::cerr << "Invalid input." << std::endl;
return 1;
}
Mesh out;
bool valid_union = PMP::corefine_and_compute_union(mesh1,mesh2, out);
if (valid_union)
if(valid_union)
{
std::cout << "Union was successfully computed\n";
std::ofstream output("union.off");
@ -41,6 +34,8 @@ int main(int argc, char* argv[])
output << out;
return 0;
}
std::cout << "Union could not be computed\n";
return 1;
}

View File

@ -2,8 +2,10 @@
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <fstream>
#include <iostream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
@ -15,19 +17,11 @@ int main(int argc, char* argv[])
{
const char* filename1 = (argc > 1) ? argv[1] : "data/blobby.off";
const char* filename2 = (argc > 2) ? argv[2] : "data/eight.off";
std::ifstream input(filename1);
Mesh mesh1, mesh2;
if (!input || !(input >> mesh1))
if(!PMP::read_polygon_mesh(filename1, mesh1) || !PMP::read_polygon_mesh(filename2, mesh2))
{
std::cerr << "First mesh is not a valid off file." << std::endl;
return 1;
}
input.close();
input.open(filename2);
if (!input || !(input >> mesh2))
{
std::cerr << "Second mesh is not a valid off file." << std::endl;
std::cerr << "Invalid input." << std::endl;
return 1;
}

View File

@ -1,9 +1,13 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <boost/container/flat_map.hpp>
#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <boost/container/flat_map.hpp>
#include <fstream>
#include <iostream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
@ -46,19 +50,11 @@ int main(int argc, char* argv[])
{
const char* filename1 = (argc > 1) ? argv[1] : "data/blobby.off";
const char* filename2 = (argc > 2) ? argv[2] : "data/eight.off";
std::ifstream input(filename1);
Mesh mesh1, mesh2;
if (!input || !(input >> mesh1))
if(!PMP::read_polygon_mesh(filename1, mesh1) || !PMP::read_polygon_mesh(filename2, mesh2))
{
std::cerr << "First mesh is not a valid off file." << std::endl;
return 1;
}
input.close();
input.open(filename2);
if (!input || !(input >> mesh2))
{
std::cerr << "Second mesh is not a valid off file." << std::endl;
std::cerr << "Invalid input." << std::endl;
return 1;
}

View File

@ -3,9 +3,10 @@
#include <CGAL/Polyhedron_items_with_id_3.h>
#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <fstream>
#include <iostream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Polyhedron_3<K, CGAL::Polyhedron_items_with_id_3> Mesh;
@ -16,19 +17,11 @@ int main(int argc, char* argv[])
{
const char* filename1 = (argc > 1) ? argv[1] : "data/blobby.off";
const char* filename2 = (argc > 2) ? argv[2] : "data/eight.off";
std::ifstream input(filename1);
Mesh mesh1, mesh2;
if (!input || !(input >> mesh1))
if(!PMP::read_polygon_mesh(filename1, mesh1) || !PMP::read_polygon_mesh(filename2, mesh2))
{
std::cerr << "First mesh is not a valid off file." << std::endl;
return 1;
}
input.close();
input.open(filename2);
if (!input || !(input >> mesh2))
{
std::cerr << "Second mesh is not a valid off file." << std::endl;
std::cerr << "Invalid input." << std::endl;
return 1;
}

View File

@ -1,8 +1,11 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/detect_features.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <fstream>
#include <iostream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
@ -13,12 +16,11 @@ namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/P.off";
std::ifstream input(filename);
Mesh mesh;
if (!input || !(input >> mesh))
if(!PMP::read_polygon_mesh(filename, mesh))
{
std::cerr << "Not a valid input file." << std::endl;
std::cerr << "Invalid input." << std::endl;
return 1;
}
@ -41,7 +43,6 @@ int main(int argc, char* argv[])
++nb_sharp_edges;
}
std::cout<<"This mesh contains "<<nb_sharp_edges<<" sharp edges"<<std::endl;
std::cout<<" and "<<number_of_patches<<" surface patches."<<std::endl;

View File

@ -2,9 +2,11 @@
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/connected_components.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/boost/graph/Face_filtered_graph.h>
#include <boost/property_map/property_map.hpp>
#include <iostream>
#include <fstream>
#include <map>
@ -17,46 +19,42 @@ typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor;
typedef boost::graph_traits<Mesh>::faces_size_type faces_size_type;
typedef Mesh::Property_map<face_descriptor, faces_size_type> FCCmap;
typedef CGAL::Face_filtered_graph<Mesh> Filtered_graph;
typedef CGAL::Face_filtered_graph<Mesh> Filtered_graph;
namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
std::ifstream input((argc > 1) ? argv[1] : "data/blobby_3cc.off");
const char* filename = (argc > 1) ? argv[1] : "data/blobby_3cc.off";
Mesh mesh;
if (!input || !(input >> mesh) || mesh.is_empty()) {
std::cerr << "Not a valid off file." << std::endl;
if(!PMP::read_polygon_mesh(filename, mesh))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
FCCmap fccmap = mesh.add_property_map<face_descriptor, faces_size_type>("f:CC").first;
faces_size_type num = PMP::connected_components(mesh,fccmap);
std::cerr << "- The graph has " << num << " connected components (face connectivity)" << std::endl;
Filtered_graph ffg(mesh, 0, fccmap);
std::cout << "The faces in component 0 are:" << std::endl;
for(boost::graph_traits<Filtered_graph>::face_descriptor f : faces(ffg)){
Filtered_graph ffg(mesh, 0, fccmap);
for(boost::graph_traits<Filtered_graph>::face_descriptor f : faces(ffg))
std::cout << f << std::endl;
}
if(num>1){
if(num > 1)
{
std::vector<faces_size_type> components;
components.push_back(0);
components.push_back(1);
ffg.set_selected_faces(components, fccmap);
std::cout << "The faces in components 0 and 1 are:" << std::endl;
for(Filtered_graph::face_descriptor f : faces(ffg)){
ffg.set_selected_faces(components, fccmap);
for(Filtered_graph::face_descriptor f : faces(ffg))
std::cout << f << std::endl;
}
}
return 0;
}

View File

@ -1,5 +1,6 @@
#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/remesh.h>
@ -11,7 +12,7 @@ typedef CGAL::Surface_mesh<K::Point_3> Mesh;
namespace PMP = CGAL::Polygon_mesh_processing;
int main()
int main(int, char**)
{
Mesh tm1, tm2;
CGAL::make_tetrahedron(Point(.0,.0,.0),
@ -19,11 +20,13 @@ int main()
Point(1,1,1),
Point(1,.0,2),
tm1);
tm2=tm1;
tm2 = tm1;
CGAL::Polygon_mesh_processing::isotropic_remeshing(tm2.faces(),.05, tm2);
std::cout << "Approximated Hausdorff distance: "
<< CGAL::Polygon_mesh_processing::approximate_Hausdorff_distance
<TAG>(tm1, tm2, PMP::parameters::number_of_points_per_area_unit(4000))
<< std::endl;
return 0;
}

View File

@ -1,5 +1,7 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/Polygon_mesh_processing/triangulate_hole.h>
#include <iostream>
@ -7,20 +9,23 @@
#include <vector>
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef Polyhedron::Vertex_handle Vertex_handle;
typedef Polyhedron::Halfedge_handle Halfedge_handle;
typedef Polyhedron::Facet_handle Facet_handle;
typedef Polyhedron::Vertex_handle Vertex_handle;
namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/mech-holes-shark.off";
std::ifstream input(filename);
Polyhedron poly;
if ( !input || !(input >> poly) || poly.empty() ) {
std::cerr << "Not a valid off file." << std::endl;
if(!PMP::read_polygon_mesh(filename, poly))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
@ -32,14 +37,12 @@ int main(int argc, char* argv[])
{
std::vector<Facet_handle> patch_facets;
std::vector<Vertex_handle> patch_vertices;
bool success = std::get<0>(
CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole(
poly,
bool success = std::get<0>(PMP::triangulate_refine_and_fair_hole(poly,
h,
std::back_inserter(patch_facets),
std::back_inserter(patch_vertices),
CGAL::Polygon_mesh_processing::parameters::vertex_point_map(get(CGAL::vertex_point, poly)).
geom_traits(Kernel())) );
PMP::parameters::vertex_point_map(get(CGAL::vertex_point, poly))
.geom_traits(Kernel())));
std::cout << " Number of facets in constructed patch: " << patch_facets.size() << std::endl;
std::cout << " Number of vertices in constructed patch: " << patch_vertices.size() << std::endl;
@ -54,5 +57,6 @@ int main(int argc, char* argv[])
std::ofstream out("filled.off");
out.precision(17);
out << poly << std::endl;
return 0;
}

View File

@ -12,43 +12,44 @@
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point;
typedef CGAL::Linear_cell_complex_traits<3, Kernel> MyTraits;
typedef CGAL::Linear_cell_complex_for_bgl_combinatorial_map_helper
<2, 3, MyTraits>::type LCC;
typedef CGAL::Linear_cell_complex_for_bgl_combinatorial_map_helper<2, 3, MyTraits>::type LCC;
typedef boost::graph_traits<LCC>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<LCC>::halfedge_descriptor halfedge_descriptor;
typedef boost::graph_traits<LCC>::face_descriptor face_descriptor;
typedef boost::graph_traits<LCC>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<LCC>::halfedge_iterator halfedge_iterator;
namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/mech-holes-shark.off";
LCC mesh;
CGAL::Polygon_mesh_processing::IO::read_polygon_mesh(filename, mesh);
if(!PMP::read_polygon_mesh(filename, mesh))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
// Incrementally fill the holes
unsigned int nb_holes = 0;
for ( halfedge_iterator it=halfedges(mesh).begin();
it!=halfedges(mesh).end(); ++it)
for ( halfedge_descriptor h : halfedges(mesh))
{
halfedge_descriptor h=*it;
if(is_border(h,mesh))
{
std::vector<face_descriptor> patch_facets;
std::vector<vertex_descriptor> patch_vertices;
bool success = std::get<0>(
CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole(
mesh,
bool success = std::get<0>(PMP::triangulate_refine_and_fair_hole(mesh,
h,
std::back_inserter(patch_facets),
std::back_inserter(patch_vertices),
CGAL::Polygon_mesh_processing::parameters::vertex_point_map(get(CGAL::vertex_point, mesh)).
geom_traits(Kernel())) );
PMP::parameters::vertex_point_map(get(CGAL::vertex_point, mesh))
.geom_traits(Kernel())));
std::cout << "* Number of facets in constructed patch: " << patch_facets.size() << std::endl;
std::cout << " Number of vertices in constructed patch: " << patch_vertices.size() << std::endl;
std::cout << " Is fairing successful: " << success << std::endl;
nb_holes++;
++nb_holes;
}
}

View File

@ -1,12 +1,12 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_mesh_processing/triangulate_hole.h>
#include <CGAL/boost/graph/graph_traits_PolyMesh_ArrayKernelT.h>
#include <CGAL/boost/graph/helpers.h>
#include <OpenMesh/Core/IO/MeshIO.hh>
#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
#include <CGAL/boost/graph/graph_traits_PolyMesh_ArrayKernelT.h>
#include <CGAL/Polygon_mesh_processing/triangulate_hole.h>
#include <CGAL/boost/graph/helpers.h>
#include <iostream>
#include <fstream>
#include <vector>
@ -19,11 +19,12 @@ typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor;
namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/mech-holes-shark.off";
Mesh mesh;
OpenMesh::IO::read_mesh(mesh, filename);
@ -35,14 +36,11 @@ int main(int argc, char* argv[])
{
std::vector<face_descriptor> patch_facets;
std::vector<vertex_descriptor> patch_vertices;
bool success = std::get<0>(
CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole(
mesh,
h,
bool success = std::get<0>(PMP::triangulate_refine_and_fair_hole(mesh, h,
std::back_inserter(patch_facets),
std::back_inserter(patch_vertices),
CGAL::Polygon_mesh_processing::parameters::vertex_point_map(get(CGAL::vertex_point, mesh)).
geom_traits(Kernel())) );
CGAL::parameters::vertex_point_map(get(CGAL::vertex_point, mesh))
.geom_traits(Kernel())));
CGAL_assertion(CGAL::is_valid_polygon_mesh(mesh));
@ -58,5 +56,6 @@ int main(int argc, char* argv[])
std::cout << nb_holes << " holes have been filled" << std::endl;
OpenMesh::IO::write_mesh(mesh, "filled_OM.off");
return 0;
}

View File

@ -3,6 +3,7 @@
#include <CGAL/Polygon_mesh_processing/triangulate_hole.h>
#include <CGAL/Polygon_mesh_processing/border.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <boost/lexical_cast.hpp>
@ -15,9 +16,11 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point;
typedef CGAL::Surface_mesh<Point> Mesh;
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor;
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
namespace PMP = CGAL::Polygon_mesh_processing;
bool is_small_hole(halfedge_descriptor h, Mesh & mesh,
double max_hole_diam, int max_num_hole_edges)
@ -48,22 +51,22 @@ int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/mech-holes-shark.off";
Mesh mesh;
if(!PMP::read_polygon_mesh(filename, mesh))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
// Both of these must be positive in order to be considered
double max_hole_diam = (argc > 2) ? boost::lexical_cast<double>(argv[2]): -1.0;
int max_num_hole_edges = (argc > 3) ? boost::lexical_cast<int>(argv[3]) : -1;
std::ifstream input(filename);
Mesh mesh;
if ( !input || !(input >> mesh) ) {
std::cerr << "Not a valid off file." << std::endl;
return 1;
}
unsigned int nb_holes = 0;
std::vector<halfedge_descriptor> border_cycles;
// collect one halfedge per boundary cycle
CGAL::Polygon_mesh_processing::extract_boundary_cycles(mesh, std::back_inserter(border_cycles));
PMP::extract_boundary_cycles(mesh, std::back_inserter(border_cycles));
for(halfedge_descriptor h : border_cycles)
{
@ -73,12 +76,10 @@ int main(int argc, char* argv[])
std::vector<face_descriptor> patch_facets;
std::vector<vertex_descriptor> patch_vertices;
bool success = std::get<0>(
CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole(
mesh,
bool success = std::get<0>(PMP::triangulate_refine_and_fair_hole(mesh,
h,
std::back_inserter(patch_facets),
std::back_inserter(patch_vertices)) );
std::back_inserter(patch_vertices)));
std::cout << "* Number of facets in constructed patch: " << patch_facets.size() << std::endl;
std::cout << " Number of vertices in constructed patch: " << patch_vertices.size() << std::endl;
@ -94,5 +95,6 @@ int main(int argc, char* argv[])
std::cout << "Mesh written to: " << outfile << std::endl;
out.precision(17);
out << mesh << std::endl;
return 0;
}

View File

@ -3,8 +3,10 @@
#include <CGAL/Polygon_mesh_processing/remesh.h>
#include <CGAL/Polygon_mesh_processing/border.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <boost/function_output_iterator.hpp>
#include <fstream>
#include <vector>
@ -32,11 +34,11 @@ struct halfedge2edge
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/pig.off";
std::ifstream input(filename);
Mesh mesh;
if (!input || !(input >> mesh) || !CGAL::is_triangle_mesh(mesh)) {
std::cerr << "Not a valid input file." << std::endl;
if(!PMP::read_polygon_mesh(filename, mesh) || !CGAL::is_triangle_mesh(mesh))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
@ -46,9 +48,7 @@ int main(int argc, char* argv[])
std::cout << "Split border...";
std::vector<edge_descriptor> border;
PMP::border_halfedges(faces(mesh),
mesh,
boost::make_function_output_iterator(halfedge2edge(mesh, border)));
PMP::border_halfedges(faces(mesh), mesh, boost::make_function_output_iterator(halfedge2edge(mesh, border)));
PMP::split_long_edges(border, target_edge_length, mesh);
std::cout << "done." << std::endl;
@ -56,13 +56,9 @@ int main(int argc, char* argv[])
std::cout << "Start remeshing of " << filename
<< " (" << num_faces(mesh) << " faces)..." << std::endl;
PMP::isotropic_remeshing(
faces(mesh),
target_edge_length,
mesh,
PMP::isotropic_remeshing(faces(mesh), target_edge_length, mesh,
PMP::parameters::number_of_iterations(nb_iter)
.protect_constraints(true)//i.e. protect border, here
);
.protect_constraints(true)); //i.e. protect border, here
std::cout << "Remeshing done." << std::endl;

View File

@ -3,14 +3,16 @@
#include <CGAL/Polygon_mesh_processing/remesh.h>
#include <CGAL/Polygon_mesh_processing/border.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <boost/function_output_iterator.hpp>
#include <fstream>
#include <vector>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
typedef boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
typedef boost::graph_traits<Mesh>::edge_descriptor edge_descriptor;
typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor;
@ -33,11 +35,11 @@ struct halfedge2edge
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/pig.off";
std::ifstream input(filename);
Mesh mesh;
if (!input || !(input >> mesh) || !CGAL::is_triangle_mesh(mesh)) {
std::cerr << "Not a valid input file." << std::endl;
if(!PMP::read_polygon_mesh(filename, mesh) || !CGAL::is_triangle_mesh(mesh))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}

View File

@ -1,14 +1,14 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/locate.h>
#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/boost/graph/helpers.h>
#include <CGAL/Dynamic_property_map.h>
#include <CGAL/Polygon_mesh_processing/locate.h>
#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::FT FT;

View File

@ -1,10 +1,10 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/repair.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/boost/graph/iterator.h>
#include <CGAL/Polygon_mesh_processing/repair.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/IO/OFF.h>
#include <fstream>
#include <iostream>
@ -24,9 +24,8 @@ void merge_vertices(vertex_descriptor v_keep, vertex_descriptor v_rm, Mesh& mesh
{
std::cout << "merging vertices " << v_keep << " and " << v_rm << std::endl;
for(halfedge_descriptor h : CGAL::halfedges_around_target(v_rm, mesh)){
for(halfedge_descriptor h : CGAL::halfedges_around_target(v_rm, mesh))
set_target(h, v_keep, mesh); // to ensure that no halfedge points at the deleted vertex
}
remove_vertex(v_rm, mesh);
}
@ -34,13 +33,12 @@ void merge_vertices(vertex_descriptor v_keep, vertex_descriptor v_rm, Mesh& mesh
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/blobby.off";
std::ifstream input(filename);
Mesh mesh;
if(!input || !(input >> mesh) || num_vertices(mesh) == 0)
if(!PMP::read_polygon_mesh(filename, mesh) || CGAL::is_empty(mesh))
{
std::cerr << filename << " is not a valid off file." << std::endl;
return EXIT_FAILURE;
std::cerr << "Invalid input." << std::endl;
return 1;
}
// Artificially create non-manifoldness for the sake of the example by merging some vertices

View File

@ -1,32 +1,35 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_slicer.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/AABB_halfedge_graph_segment_primitive.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/Polygon_mesh_slicer.h>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
typedef std::vector<K::Point_3> Polyline_type;
typedef std::list< Polyline_type > Polylines;
typedef std::list<Polyline_type> Polylines;
typedef CGAL::AABB_halfedge_graph_segment_primitive<Mesh> HGSP;
typedef CGAL::AABB_traits<K, HGSP> AABB_traits;
typedef CGAL::AABB_tree<AABB_traits> AABB_tree;
namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/eight.off";
std::ifstream input(filename);
Mesh mesh;
if (!input || !(input >> mesh) || mesh.is_empty()
|| !CGAL::is_triangle_mesh(mesh)) {
std::cerr << "Not a valid input file." << std::endl;
if(!PMP::read_polygon_mesh(filename, mesh) || CGAL::is_empty(mesh) || !CGAL::is_triangle_mesh(mesh))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}

View File

@ -1,8 +1,9 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/smooth_mesh.h>
#include <CGAL/Polygon_mesh_processing/detect_features.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <iostream>
#include <fstream>
@ -17,13 +18,12 @@ namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char** argv)
{
const char* filename = argc > 1 ? argv[1] : "data/anchor_dense.off";
std::ifstream input(filename);
Mesh mesh;
if (!input || !(input >> mesh) || mesh.is_empty())
if(!PMP::read_polygon_mesh(filename, mesh))
{
std::cerr << "Not a valid .off file." << std::endl;
return EXIT_FAILURE;
std::cerr << "Invalid input." << std::endl;
return 1;
}
// Constrain edges with a dihedral angle over 60°

View File

@ -1,114 +1,68 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/orientation.h>
#include <CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h>
#include <CGAL/Polygon_mesh_processing/orient_polygon_soup_extension.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/algorithm.h>
#include <CGAL/Timer.h>
#include <CGAL/IO/polygon_soup_io.h>
#include <fstream>
#include <algorithm>
#include <cstdlib>
#include <fstream>
#include <iostream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_3 Point_3;
typedef CGAL::Surface_mesh<Point_3> Mesh;
namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char** argv)
{
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_3 Point_3;
typedef CGAL::Surface_mesh<Point_3> Mesh;
const char* input_filename = (argc < 2) ? "data/blobby-shuffled.off" : argv[1];
const char* reference_filename = (argc < 2) ? "data/blobby.off" : argv[2];
std::vector<Point_3> points;
std::vector< std::vector<std::size_t> > polygons;
Mesh ref1;
const char* input_filename = argc<2 ? "data/blobby-shuffled.off" : argv[1];
std::ifstream input(input_filename);
if ( !input){
std::vector<std::vector<std::size_t> > polygons;
if(!CGAL::read_polygon_soup(input_filename, points, polygons) ||
points.size() == 0 || polygons.size() == 0)
{
std::cerr << "Error: can not read input file.\n";
return 1;
}
typedef K::Point_3 Point_3;
CGAL::File_scanner_OFF scanner(input);
points.resize(scanner.size_of_vertices());
polygons.resize(scanner.size_of_facets());
//read points
for (std::size_t i = 0; i < scanner.size_of_vertices(); ++i)
{
double x, y, z, w;
scanner.scan_vertex( x, y, z, w);
points[i] = Point_3(x, y, z, w);
scanner.skip_to_next_vertex( i);
}
//read triangles
for (std::size_t i = 0; i < scanner.size_of_facets(); ++i)
{
std::size_t no;
scanner.scan_facet( no, i);
polygons[i].resize(no);
for(std::size_t j = 0; j < no; ++j) {
std::size_t id;
scanner.scan_facet_vertex_index(id, i);
if(id < scanner.size_of_vertices())
Mesh ref1;
if(!PMP::read_polygon_mesh(reference_filename, ref1))
{
polygons[i][j] = id;
}
else
{
std::cerr << "Error: input file not valid.\n";
return 1;
}
}
}
input.close();
if(points.size() == 0 || polygons.size()==0)
{
std::cerr << "Error: input file not valid.\n";
std::cerr << "Invalid input." << std::endl;
return 1;
}
const char* reference_filename = argc<2 ? "data/blobby.off" : argv[2];
input.open(reference_filename);
std::cout << "Is the soup a polygon mesh ? : " << PMP::is_polygon_soup_a_polygon_mesh(polygons) << std::endl;
if ( !input || !(input >> ref1)){
std::cerr << "Error: can not read reference file.\n";
return 1;
}
input.close();
PMP::orient_triangle_soup_with_reference_triangle_mesh<CGAL::Sequential_tag>(ref1, points, polygons);
std::cout << "Is the soup a polygon mesh ? : "
<< CGAL::Polygon_mesh_processing::is_polygon_soup_a_polygon_mesh(polygons)
<< std::endl;
std::cout << "And now ? : " << PMP::is_polygon_soup_a_polygon_mesh(polygons) << std::endl;
CGAL::Polygon_mesh_processing::orient_triangle_soup_with_reference_triangle_mesh<CGAL::Sequential_tag>(ref1, points, polygons);
PMP::duplicate_non_manifold_edges_in_polygon_soup(points, polygons);
std::cout << "And now ? : "
<< CGAL::Polygon_mesh_processing::is_polygon_soup_a_polygon_mesh(polygons)
<< std::endl;
CGAL::Polygon_mesh_processing::duplicate_non_manifold_edges_in_polygon_soup(points, polygons);
std::cout << "And now ? : "
<< CGAL::Polygon_mesh_processing::is_polygon_soup_a_polygon_mesh(polygons)
<< std::endl;
std::cout << "And now ? : " << PMP::is_polygon_soup_a_polygon_mesh(polygons) << std::endl;
Mesh poly;
CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(
points, polygons, poly);
PMP::polygon_soup_to_polygon_mesh(points, polygons, poly);
typedef boost::property_map<Mesh, CGAL::dynamic_face_property_t<std::size_t> >::type Fccmap;
Fccmap fccmap = get(CGAL::dynamic_face_property_t<std::size_t>(), poly);
std::cout<<CGAL::Polygon_mesh_processing::
connected_components(poly, fccmap)<<" CCs before merge."<<std::endl;
CGAL::Polygon_mesh_processing::
merge_reversible_connected_components(poly);
std::cout << PMP::connected_components(poly, fccmap) << " CCs before merge." << std::endl;
PMP::merge_reversible_connected_components(poly);
std::cout<<PMP::connected_components(poly, fccmap) << " remaining CCs." << std::endl;
std::cout<<CGAL::Polygon_mesh_processing::
connected_components(poly, fccmap)<<" remaining CCs."<<std::endl;
return 0;
}

View File

@ -1,7 +1,8 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/point_generators_3.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/point_generators_3.h>
#include <CGAL/Side_of_triangle_mesh.h>
#include <vector>
@ -12,6 +13,8 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_3 Point;
typedef CGAL::Polyhedron_3<K> Polyhedron;
namespace PMP = CGAL::Polygon_mesh_processing;
double max_coordinate(const Polyhedron& poly)
{
double max_coord = -std::numeric_limits<double>::infinity();
@ -28,13 +31,11 @@ double max_coordinate(const Polyhedron& poly)
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/eight.off";
std::ifstream input(filename);
Polyhedron poly;
if (!input || !(input >> poly) || poly.empty()
|| !CGAL::is_triangle_mesh(poly))
if(!PMP::read_polygon_mesh(filename, poly) || CGAL::is_empty(poly) || !CGAL::is_triangle_mesh(poly))
{
std::cerr << "Not a valid input file." << std::endl;
std::cerr << "Invalid input." << std::endl;
return 1;
}

View File

@ -1,14 +1,12 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/boost/graph/graph_traits_PolyMesh_ArrayKernelT.h>
#include <CGAL/point_generators_3.h>
#include <CGAL/Side_of_triangle_mesh.h>
#include <OpenMesh/Core/IO/MeshIO.hh>
#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
#include <CGAL/boost/graph/graph_traits_PolyMesh_ArrayKernelT.h>
#include <CGAL/point_generators_3.h>
#include <CGAL/Side_of_triangle_mesh.h>
#include <vector>
#include <fstream>
#include <limits>
@ -42,7 +40,7 @@ int main(int argc, char* argv[])
Mesh mesh;
OpenMesh::IO::read_mesh(mesh, filename);
if (!CGAL::is_triangle_mesh(mesh))
if (CGAL::is_empty(mesh) || !CGAL::is_triangle_mesh(mesh))
{
std::cerr << "Input geometry is not triangulated." << std::endl;
return EXIT_FAILURE;

View File

@ -2,6 +2,7 @@
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/random_perturbation.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <iostream>
#include <fstream>
@ -13,24 +14,22 @@ typedef CGAL::Surface_mesh<Point> Surface_mesh;
typedef boost::graph_traits<Surface_mesh>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Surface_mesh>::face_descriptor face_descriptor;
namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/eight.off";
std::ifstream input(filename);
Surface_mesh mesh;
if (!input || !(input >> mesh) || mesh.is_empty()) {
std::cerr << "Not a valid off file." << std::endl;
if(!PMP::read_polygon_mesh(filename, mesh))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
const double max_size = (argc > 2) ? atof(argv[2]) : 0.02;
namespace PMP = CGAL::Polygon_mesh_processing;
PMP::random_perturbation(
mesh,
max_size,
PMP::parameters::vertex_point_map(mesh.points()).geom_traits(K()));
PMP::random_perturbation(mesh, max_size, CGAL::parameters::vertex_point_map(mesh.points()).geom_traits(K()));
std::ofstream out("data/eight_perturbed.off");
out.precision(17);

View File

@ -4,16 +4,18 @@
#include <CGAL/Polygon_mesh_processing/refine.h>
#include <CGAL/Polygon_mesh_processing/fair.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <fstream>
#include <map>
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef Polyhedron::Vertex_handle Vertex_handle;
namespace PMP = CGAL::Polygon_mesh_processing;
// extract vertices which are at most k (inclusive)
// far from vertex v in the graph of edges
void extract_k_ring(Vertex_handle v,
@ -33,9 +35,8 @@ void extract_k_ring(Vertex_handle v,
Polyhedron::Halfedge_around_vertex_circulator e(v->vertex_begin()), e_end(e);
do {
Vertex_handle new_v = e->opposite()->vertex();
if (D.insert(std::make_pair(new_v, dist_v + 1)).second) {
if (D.insert(std::make_pair(new_v, dist_v + 1)).second)
qv.push_back(new_v);
}
} while (++e != e_end);
}
}
@ -43,23 +44,21 @@ void extract_k_ring(Vertex_handle v,
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/blobby.off";
std::ifstream input(filename);
Polyhedron poly;
if ( !input || !(input >> poly) || poly.empty()
|| !CGAL::is_triangle_mesh(poly)) {
std::cerr << "Not a valid input file." << std::endl;
if(!PMP::read_polygon_mesh(filename, poly) || !CGAL::is_triangle_mesh(poly))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
std::vector<Polyhedron::Facet_handle> new_facets;
std::vector<Vertex_handle> new_vertices;
CGAL::Polygon_mesh_processing::refine(poly,
faces(poly),
PMP::refine(poly, faces(poly),
std::back_inserter(new_facets),
std::back_inserter(new_vertices),
CGAL::Polygon_mesh_processing::parameters::density_control_factor(2.));
CGAL::parameters::density_control_factor(2.));
std::ofstream refined_off("refined.off");
refined_off.precision(17);
@ -72,7 +71,7 @@ int main(int argc, char* argv[])
std::vector<Vertex_handle> region;
extract_k_ring(v, 12/*e.g.*/, region);
bool success = CGAL::Polygon_mesh_processing::fair(poly, region);
bool success = PMP::fair(poly, region);
std::cout << "Fairing : " << (success ? "succeeded" : "failed") << std::endl;
std::ofstream faired_off("faired.off");

View File

@ -2,6 +2,8 @@
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/self_intersections.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/Real_timer.h>
#include <CGAL/tags.h>
@ -17,13 +19,12 @@ namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/pig.off";
std::ifstream input(filename);
Mesh mesh;
if (!input || !(input >> mesh) || !CGAL::is_triangle_mesh(mesh))
if(!PMP::read_polygon_mesh(filename, mesh) || !CGAL::is_triangle_mesh(mesh))
{
std::cerr << "Not a valid input file." << std::endl;
return EXIT_FAILURE;
std::cerr << "Invalid input." << std::endl;
return 1;
}
std::cout << "Using parallel mode? " << std::is_same<CGAL::Parallel_if_available_tag, CGAL::Parallel_tag>::value << std::endl;

View File

@ -1,7 +1,8 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/smooth_shape.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <iostream>
#include <fstream>
@ -14,13 +15,12 @@ namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/pig.off";
std::ifstream input(filename);
Mesh mesh;
if (!input || !(input >> mesh) || mesh.is_empty())
if(!PMP::read_polygon_mesh(filename, mesh))
{
std::cerr << "Not a valid .off file." << std::endl;
return EXIT_FAILURE;
std::cerr << "Invalid input." << std::endl;
return 1;
}
const unsigned int nb_iterations = (argc > 2) ? std::atoi(argv[2]) : 10;

View File

@ -3,6 +3,7 @@
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Polygon_mesh_processing/stitch_borders.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <iostream>
#include <fstream>
@ -10,14 +11,16 @@
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Polyhedron_3<K> Polyhedron;
namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/full_border_quads.off";
std::ifstream input(filename);
Polyhedron mesh;
if (!input || !(input >> mesh) || mesh.is_empty()) {
std::cerr << "Not a valid off file." << std::endl;
if(!PMP::read_polygon_mesh(filename, mesh))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
@ -26,7 +29,7 @@ int main(int argc, char* argv[])
std::cout << "\t Number of halfedges :\t" << mesh.size_of_halfedges() << std::endl;
std::cout << "\t Number of facets :\t" << mesh.size_of_facets() << std::endl;
CGAL::Polygon_mesh_processing::stitch_borders(mesh);
PMP::stitch_borders(mesh);
std::cout << "Stitching done : " << std::endl;
std::cout << "\t Number of vertices :\t" << mesh.size_of_vertices() << std::endl;

View File

@ -1,17 +1,16 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_mesh_processing/stitch_borders.h>
#include <OpenMesh/Core/IO/MeshIO.hh>
#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
#include <CGAL/boost/graph/graph_traits_PolyMesh_ArrayKernelT.h>
#include <CGAL/Polygon_mesh_processing/stitch_borders.h>
#include <iostream>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef OpenMesh::PolyMesh_ArrayKernelT< > Mesh;
int main(int argc, char* argv[])
{
@ -25,8 +24,7 @@ int main(int argc, char* argv[])
std::cout << "\t Number of halfedges :\t" << num_halfedges(mesh) << std::endl;
std::cout << "\t Number of facets :\t" << num_faces(mesh) << std::endl;
CGAL::Polygon_mesh_processing::stitch_borders(mesh,
CGAL::Polygon_mesh_processing::parameters::vertex_point_map(get(CGAL::vertex_point, mesh)));
CGAL::Polygon_mesh_processing::stitch_borders(mesh, CGAL::parameters::vertex_point_map(get(CGAL::vertex_point, mesh)));
mesh.garbage_collection();
std::cout << "Stitching done : " << std::endl;

View File

@ -1,10 +1,10 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/iterator.h>
#include <CGAL/Polygon_mesh_processing/intersection.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
namespace PMP=CGAL::Polygon_mesh_processing;
#include <CGAL/iterator.h>
#include <iostream>
#include <fstream>
@ -13,28 +13,21 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point;
typedef CGAL::Surface_mesh<Point> Mesh;
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor;
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
const char* filename1 = (argc > 1) ? argv[1] : "data/blobby.off";
std::ifstream input(filename1);
Mesh mesh1;
if ( !input || !(input >> mesh1) ) {
std::cerr << filename1 << " is not a valid off file." << std::endl;
return 1;
}
input.close();
const char* filename2 = (argc > 2) ? argv[2] : "data/eight.off";
input.open(filename2);
Mesh mesh2;
if ( !input || !(input >> mesh2) ) {
std::cerr << filename2 << " is not a valid off file." << std::endl;
Mesh mesh1, mesh2;
if(!PMP::read_polygon_mesh(filename1, mesh1) || !PMP::read_polygon_mesh(filename2, mesh2))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}

View File

@ -2,33 +2,36 @@
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/boost/graph/helpers.h>
#include <fstream>
#include <iostream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point;
typedef CGAL::Surface_mesh<Point> Surface_mesh;
namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/P.off";
const char* outfilename = (argc > 2) ? argv[2] : "P_tri.off";
std::ifstream input(filename);
Surface_mesh mesh;
if (!input || !(input >> mesh) || mesh.is_empty())
if(!PMP::read_polygon_mesh(filename, mesh))
{
std::cerr << "Not a valid off file." << std::endl;
std::cerr << "Invalid input." << std::endl;
return 1;
}
CGAL::Polygon_mesh_processing::triangulate_faces(mesh);
PMP::triangulate_faces(mesh);
// Confirm that all faces are triangles.
for(boost::graph_traits<Surface_mesh>::face_descriptor fit : faces(mesh))
if (next(next(halfedge(fit, mesh), mesh), mesh)
!= prev(halfedge(fit, mesh), mesh))
for(boost::graph_traits<Surface_mesh>::face_descriptor f : faces(mesh))
if(!CGAL::is_triangle(halfedge(f, mesh), mesh))
std::cerr << "Error: non-triangular face left in mesh." << std::endl;
std::ofstream cube_off(outfilename);

View File

@ -17,13 +17,12 @@ int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/cube_quad.off";
const char* outfilename = (argc > 2) ? argv[2] : "cube_tri.off";
std::ifstream input(filename);
Mesh mesh;
OpenMesh::IO::read_mesh(mesh, filename);
CGAL::Polygon_mesh_processing::triangulate_faces(mesh,
CGAL::Polygon_mesh_processing::parameters::vertex_point_map(get(CGAL::vertex_point, mesh)).
CGAL::parameters::vertex_point_map(get(CGAL::vertex_point, mesh)).
geom_traits(Kernel()));
mesh.garbage_collection();

View File

@ -1,4 +1,5 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_mesh_processing/triangulate_hole.h>
#include <CGAL/utility.h>
@ -41,8 +42,7 @@ int main()
polyline_collinear.push_back(Point(4.,0.,0.));
std::vector<Triangle_int> patch_will_be_empty;
CGAL::Polygon_mesh_processing::triangulate_hole_polyline(
polyline_collinear,
CGAL::Polygon_mesh_processing::triangulate_hole_polyline(polyline_collinear,
back_inserter(patch_will_be_empty));
CGAL_assertion(patch_will_be_empty.empty());

View File

@ -1,10 +1,13 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/orientation.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/boost/graph/Face_filtered_graph.h>
#include <iostream>
#include <fstream>
#include <iostream>
#include <sstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
@ -16,33 +19,35 @@ namespace params = CGAL::parameters;
int main(int argc, char** argv)
{
const char* filename = (argc > 1) ? argv[1] : "data/blobby.off";
std::ifstream input(filename);
assert(input);
Surface_mesh sm;
input >> sm;
Surface_mesh mesh;
if(!PMP::read_polygon_mesh(filename, mesh))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
// property map to assign a volume id for each face
Surface_mesh::Property_map<Surface_mesh::Face_index, std::size_t> vol_id_map =
sm.add_property_map<Surface_mesh::Face_index, std::size_t>().first;
mesh.add_property_map<Surface_mesh::Face_index, std::size_t>().first;
std::vector<PMP::Volume_error_code> err_codes;
// fill the volume id map
std::size_t nb_vol =
PMP::volume_connected_components(sm,
vol_id_map,
std::vector<PMP::Volume_error_code> err_codes;
std::size_t nb_vol = PMP::volume_connected_components(mesh, vol_id_map,
params::error_codes(std::ref(err_codes)));
std::cout << "Found " << nb_vol << " volumes\n";
// write each volume in an OFF file
typedef CGAL::Face_filtered_graph<Surface_mesh> Filtered_graph;
Filtered_graph vol_mesh(sm, 0, vol_id_map);
Filtered_graph vol_mesh(mesh, 0, vol_id_map);
for(std::size_t id = 0; id < nb_vol; ++id)
{
if (err_codes[id] != PMP::VALID_VOLUME)
if(err_codes[id] != PMP::VALID_VOLUME)
std::cerr << "There is an issue with volume #" << id << "\n";
if(id > 0)
vol_mesh.set_selected_faces(id, vol_id_map);
Surface_mesh out;
CGAL::copy_face_graph(vol_mesh, out);
std::ostringstream oss;

View File

@ -50,9 +50,7 @@ int main()
CGAL::Timer t;
t.start();
if (!input_stream ||
!CGAL::read_PLY_with_properties(
input_stream,
if (!CGAL::read_PLY_with_properties(input_stream,
std::back_inserter(points),
CGAL::make_ply_point_reader(Point_map()),
CGAL::make_ply_normal_reader(Normal_map()),
@ -93,8 +91,7 @@ int main()
}
else {
const std::string& output_file = "data/building_result-0.05.off";
std::ofstream output_stream(output_file.c_str());
if (output_stream && CGAL::write_off(output_stream, model))
if (CGAL::write_OFF(output_file, model))
std::cout << " Done. Saved to " << output_file << ". Time: " << t.time() << " sec." << std::endl;
else {
std::cerr << " Failed saving file." << std::endl;
@ -111,8 +108,7 @@ int main()
}
else {
const std::string& output_file = "data/building_result-0.5.off";
std::ofstream output_stream(output_file.c_str());
if (output_stream && CGAL::write_off(output_stream, model))
if (CGAL::write_OFF(output_file, model))
std::cout << " Done. Saved to " << output_file << ". Time: " << t.time() << " sec." << std::endl;
else {
std::cerr << " Failed saving file." << std::endl;
@ -129,8 +125,7 @@ int main()
}
else {
const std::string& output_file = "data/building_result-0.7.off";
std::ofstream output_stream(output_file.c_str());
if (output_stream && CGAL::write_off(output_stream, model))
if (CGAL::write_OFF(output_file, model))
std::cout << " Done. Saved to " << output_file << ". Time: " << t.time() << " sec." << std::endl;
else {
std::cerr << " Failed saving file." << std::endl;

View File

@ -50,9 +50,7 @@ int main()
CGAL::Timer t;
t.start();
if (!input_stream ||
!CGAL::read_PLY_with_properties(
input_stream,
if (!CGAL::read_PLY_with_properties(input_stream,
std::back_inserter(points),
CGAL::make_ply_point_reader(Point_map()),
CGAL::make_ply_normal_reader(Normal_map()),
@ -92,8 +90,7 @@ int main()
// Saves the mesh model
const std::string& output_file("data/ball_result.off");
std::ofstream output_stream(output_file.c_str());
if (output_stream && CGAL::write_off(output_stream, model))
if (CGAL::write_OFF(output_file, model))
std::cout << " Done. Saved to " << output_file << ". Time: " << t.time() << " sec." << std::endl;
else {
std::cerr << " Failed saving file." << std::endl;

View File

@ -101,8 +101,7 @@ int main()
CGAL::Timer t;
t.start();
if (!CGAL::read_points(input_file.c_str(),
std::back_inserter(points),
if (!CGAL::read_points(input_file.c_str(), std::back_inserter(points),
CGAL::parameters::point_map(Point_map()).normal_map(Normal_map()))) {
std::cerr << "Error: cannot read file " << input_file << std::endl;
@ -176,8 +175,7 @@ int main()
std::cout << "Saving...";
t.reset();
const std::string& output_file("data/cube_result.off");
std::ofstream output_stream(output_file.c_str());
if (output_stream && CGAL::write_off(output_stream, model))
if (CGAL::write_OFF(output_file, model))
std::cout << " Done. Saved to " << output_file << ". Time: " << t.time() << " sec." << std::endl;
else {
std::cerr << " Failed saving file." << std::endl;

View File

@ -68,8 +68,7 @@ int main()
CGAL::Timer t;
t.start();
if (!CGAL::read_points(input_file.c_str(),
std::back_inserter(points),
if (!CGAL::read_points(input_file.c_str(), std::back_inserter(points),
CGAL::parameters::point_map(Point_map()).normal_map(Normal_map())))
{
std::cerr << "Error: cannot read file " << input_file << std::endl;
@ -127,8 +126,7 @@ int main()
}
const std::string& output_file("data/cube_result.off");
std::ofstream output_stream(output_file.c_str());
if (output_stream && CGAL::write_off(output_stream, model))
if (CGAL::write_OFF(output_file, model))
std::cout << " Done. Saved to " << output_file << ". Time: " << t.time() << " sec." << std::endl;
else {
std::cerr << " Failed saving file." << std::endl;
@ -142,7 +140,7 @@ int main()
algo.output_candidate_faces(candidate_faces);
const std::string& candidate_faces_file("data/cube_candidate_faces.off");
std::ofstream candidate_stream(candidate_faces_file.c_str());
if (candidate_stream && CGAL::write_off(candidate_stream, candidate_faces))
if (CGAL::write_OFF(candidate_stream, candidate_faces))
std::cout << "Candidate faces saved to " << candidate_faces_file << "." << std::endl;
return EXIT_SUCCESS;

View File

@ -1,16 +1,22 @@
#ifndef POINT_SET_ITEM_H
#define POINT_SET_ITEM_H
#include <CGAL/Three/Scene_item_rendering_helper.h>
#include <CGAL/Three/Scene_item_with_properties.h>
#include <CGAL/Three/Scene_zoomable_item_interface.h>
#include "Scene_points_with_normal_item_config.h"
#include <CGAL/Surface_mesh/Surface_mesh_fwd.h>
#include <CGAL/config.h>
#include <CGAL/Surface_mesh/Surface_mesh.h>
#include "Kernel_type.h"
#include "Point_set_3.h"
#include <iostream>
#include <CGAL/config.h>
struct Scene_points_with_normal_item_priv;
// point set
typedef Point_set_3<Kernel> Point_set;
typedef CGAL::Surface_mesh<Kernel::Point_3> SMesh;

View File

@ -104,7 +104,7 @@ struct Intersect_facets {
}
};
void write_off() {
void write_OFF() {
cout << "OFF\n" << (triangles.size() * 3) << ' ' << triangles.size()
<< " 0\n";
for ( std::vector<Triangle>::iterator i = triangles.begin();
@ -154,7 +154,7 @@ int main(int argc, char* argv[]) {
cerr << "Intersection ... " << endl;
intersection( P);
cerr << "Intersection : " << user_time.time() << " seconds." << endl;
write_off();
write_OFF();
return 0;
}

View File

@ -12,14 +12,13 @@ typedef CGAL::Search_traits_2<K> Traits;
typedef CGAL::Fuzzy_sphere<Traits> Fuzzy_circle;
typedef CGAL::Kd_tree<Traits> Tree;
int main() {
int main()
{
const int N = 30;
Tree tree;
Random_points_iterator rpg;
for(int i = 0; i < N; i++){
for(int i = 0; i < N; i++)
tree.insert(*rpg++);
}
// fuzziness = 0

View File

@ -17,8 +17,8 @@ struct X_not_positive {
// An iterator that only enumerates dD points with positive x-coordinate
typedef CGAL::Filter_iterator<NN_iterator, X_not_positive> NN_positive_x_iterator;
int main() {
int main()
{
Tree tree;
tree.insert(Point_d(0,0));
tree.insert(Point_d(1,1));

View File

@ -16,8 +16,8 @@ typedef CGAL::Kd_tree<Traits> Tree;
typedef CGAL::Fuzzy_sphere<Traits> Fuzzy_sphere;
typedef CGAL::Fuzzy_iso_box<Traits> Fuzzy_iso_box;
int main() {
int main()
{
const int N = 1000;
// generator for random data points in the square ( (-1000,-1000), (1000,1000) )
Random_points_iterator rpit(4, 1000.0);

View File

@ -13,15 +13,16 @@ typedef CGAL::Manhattan_distance_iso_box_point<TreeTraits> Distance;
typedef CGAL::K_neighbor_search<TreeTraits, Distance> Neighbor_search;
typedef Neighbor_search::Tree Tree;
int main() {
int main()
{
const int N = 1000;
const unsigned int K = 10;
Tree tree;
Random_points_iterator rpit(4,1000.0);
for(int i = 0; i < N; i++){
for(int i = 0; i < N; i++)
tree.insert(*rpit++);
}
Point_d pp(0.1,0.1,0.1,0.1);
Point_d qq(0.2,0.2,0.2,0.2);
Iso_box_d query(pp,qq);

Some files were not shown because too many files have changed in this diff Show More