Replace IO functions in examples and fix Surface_mesh read_OFF()

This commit is contained in:
Maxime Gimeno 2020-06-15 15:59:52 +02:00
parent ed03dc0cb8
commit 25c8313859
49 changed files with 316 additions and 311 deletions

View File

@ -6,7 +6,7 @@
#include <CGAL/boost/graph/graph_traits_TriMesh_ArrayKernelT.h>
#include <CGAL/boost/graph/iterator.h>
#include <CGAL/boost/graph/Euler_operations.h>
#include <CGAL/boost/graph/IO/OFF.h>
#include <CGAL/boost/graph/IO/polygon_mesh_io.h>
#include <CGAL/mesh_segmentation.h>
#include <CGAL/property_map.h>
@ -26,14 +26,15 @@ int main(int argc, char** argv )
Mesh mesh;
std::vector<vertex_descriptor> V;
std::ifstream in((argc>1)?argv[1]:"in.off");
CGAL::read_OFF(in, mesh);
const char* filename = (argc>1)?argv[1]:"in.off";
const char* outname= (argc>2)?argv[2]:"out.off";
CGAL::read_polygon_mesh(filename, mesh);
for(vertex_descriptor vd : vertices(mesh)){
for(halfedge_descriptor hd : CGAL::halfedges_around_target(vd,mesh)){
if(! CGAL::is_border(edge(hd,mesh),mesh)){
CGAL::Euler::flip_edge(hd,mesh);
CGAL::write_OFF((argc>2)?argv[2]:"out.off", mesh);
CGAL::write_polygon_mesh(outname, mesh);
return 0;
}
}

View File

@ -3,7 +3,7 @@
#include <CGAL/boost/graph/Face_filtered_graph.h>
#include <CGAL/boost/graph/partition.h>
#include <CGAL/boost/graph/IO/OFF.h>
#include <CGAL/boost/graph/IO/polygon_mesh_io.h>
#include <fstream>
#include <iostream>
@ -13,16 +13,11 @@ typedef CGAL::Surface_mesh<K::Point_3> SM;
int main(int argc, char** argv)
{
std::ifstream in((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;
if(!in) {
std::cerr << "Error: could not read input file" << std::endl;
return EXIT_FAILURE;
}
SM sm;
CGAL::read_OFF(in, sm);
CGAL::read_polygon_mesh(filename, sm);
// The vertex <--> partition_id property map
typedef SM::Property_map<SM::Vertex_index, std::size_t> Vertex_id_map;

View File

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

View File

@ -1,7 +1,7 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Point_set_3.h>
#include <CGAL/Point_set_3/IO.h>
#include <CGAL/Point_set_3/point_set_io.h>
#include <CGAL/grid_simplify_point_set.h>
#include <fstream>
@ -36,10 +36,8 @@ int main (int, char**)
point_set.add_normal_map();
test (point_set.has_normal_map(), "point set should have normals.");
std::ifstream f ("data/oni.pwn");
CGAL::read_XYZ(f, point_set);
f.close ();
const char* fname ("data/oni.pwn");
CGAL::read_point_set(fname, point_set);
Point_set::iterator
first_to_remove = CGAL::grid_simplify_point_set (point_set,

View File

@ -1,6 +1,6 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/compute_average_spacing.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <vector>
#include <fstream>
@ -26,10 +26,8 @@ int main(int argc, char*argv[])
// we use a property map that accesses the 1st element of the tuple.
std::vector<IndexedPointWithColorTuple> points;
std::ifstream stream(fname);
if (!stream ||
!CGAL::read_XYZ(
stream, std::back_inserter(points),
if (!CGAL::read_points(
fname, std::back_inserter(points),
CGAL::parameters::point_map(CGAL::Nth_of_tuple_property_map<1,IndexedPointWithColorTuple>())))
{
std::cerr << "Error: cannot read file " << fname << std::endl;

View File

@ -1,6 +1,6 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/IO/write_xyz_points.h>
#include <CGAL/bilateral_smooth_point_set.h>
#include <CGAL/tags.h>
@ -26,10 +26,8 @@ int main(int argc, char*argv[])
// Reads a .xyz point set file in points[] * with normals *.
std::vector<PointVectorPair> points;
std::ifstream stream(input_filename);
if (!stream ||
!CGAL::read_XYZ(stream,
std::back_inserter(points),
if (!CGAL::read_points(input_filename,
std::back_inserter(points),
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())))
{

View File

@ -1,6 +1,6 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/edge_aware_upsample_point_set.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/IO/write_xyz_points.h>
#include <vector>
@ -25,10 +25,7 @@ int main(int argc, char* argv[])
// Reads a .xyz point set file in points[], *with normals*.
std::vector<PointVectorPair> points;
std::ifstream stream(input_filename);
if (!stream ||
!CGAL::read_XYZ(stream,
if (!CGAL::read_points(input_filename,
std::back_inserter(points),
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())))

View File

@ -1,7 +1,7 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/vcm_estimate_edges.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_off_points.h>
#include <CGAL/IO/read_points.h>
#include <utility> // defines std::pair
#include <vector>
@ -22,9 +22,7 @@ typedef std::array<double,6> Covariance;
int main (int , char**) {
// Reads a .xyz point set file in points[].
std::list<PointVectorPair> points;
std::ifstream stream("data/fandisk.off");
if (!stream ||
!CGAL::read_OFF(stream,
if (!CGAL::read_points("data/fandisk.off",
std::back_inserter(points),
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())))
{

View File

@ -1,6 +1,6 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/grid_simplify_point_set.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <vector>
#include <fstream>
@ -14,9 +14,7 @@ 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";
std::ifstream stream(fname);
if (!stream ||
!CGAL::read_XYZ(stream, std::back_inserter(points)))
if (!CGAL::read_points(fname, std::back_inserter(points)))
{
std::cerr << "Error: cannot read file " << fname << std::endl;
return EXIT_FAILURE;

View File

@ -1,6 +1,6 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/hierarchy_simplify_point_set.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/IO/write_xyz_points.h>
#include <CGAL/Timer.h>
#include <CGAL/Memory_sizer.h>
@ -17,9 +17,7 @@ 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";
std::ifstream stream(fname);
if (!stream ||
!CGAL::read_XYZ(stream, std::back_inserter(points)))
if (!CGAL::read_points(fname, std::back_inserter(points)))
{
std::cerr << "Error: cannot read file " << fname << std::endl;
return EXIT_FAILURE;

View File

@ -20,8 +20,7 @@
#include <CGAL/vcm_estimate_normals.h>
#include <CGAL/mst_orient_normals.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_off_points.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/IO/write_xyz_points.h>
#include <utility> // defines std::pair
@ -252,9 +251,7 @@ int main(int argc, char * argv[])
std::string extension = input_filename.substr(input_filename.find_last_of('.'));
if (extension == ".off" || extension == ".OFF")
{
std::ifstream stream(input_filename.c_str());
success = stream &&
CGAL::read_OFF(stream,
success = CGAL::read_points(input_filename.c_str(),
std::back_inserter(points),
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()));
}
@ -262,9 +259,7 @@ int main(int argc, char * argv[])
else if (extension == ".xyz" || extension == ".XYZ" ||
extension == ".pwn" || extension == ".PWN")
{
std::ifstream stream(input_filename.c_str());
success = stream &&
CGAL::read_XYZ(stream,
success = CGAL::read_points(input_filename.c_str(),
std::back_inserter(points),
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()));
}

View File

@ -3,7 +3,7 @@
#include <CGAL/pca_estimate_normals.h>
#include <CGAL/mst_orient_normals.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <utility> // defines std::pair
#include <list>
@ -25,9 +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[].
std::list<PointVectorPair> points;
std::ifstream stream(fname);
if (!stream ||
!CGAL::read_XYZ(stream,
if (!CGAL::read_points(fname,
std::back_inserter(points),
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())))
{

View File

@ -1,6 +1,6 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/random_simplify_point_set.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/IO/write_xyz_points.h>
#include <vector>
@ -16,9 +16,7 @@ int main(int argc, char*argv[])
const char* fname = (argc>1)?argv[1]:"data/oni.xyz";
// Reads a .xyz point set file in points[].
std::vector<Point> points;
std::ifstream stream(fname);
if (!stream ||
!CGAL::read_XYZ(stream, std::back_inserter(points)))
if (!CGAL::read_points(fname, std::back_inserter(points)))
{
std::cerr << "Error: cannot read file " << fname << std::endl;
return EXIT_FAILURE;

View File

@ -1,6 +1,6 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/IO/write_xyz_points.h>
#include <utility> // defines std::pair
@ -20,16 +20,14 @@ int main(int argc, char*argv[])
{
const char* fname = (argc>1)?argv[1]:"data/oni.xyz";
// Reads a .xyz point set file in points[].
// Note: read_XYZ() requires an output iterator
// Note: read_points() requires an output iterator
// over points and as well as property maps to access each
// point position and normal.
std::vector<Pwn> points;
std::ifstream in(fname);
if (!in ||
!CGAL::read_XYZ(
in,std::back_inserter(points),
CGAL::parameters::point_map (CGAL::First_of_pair_property_map<Pwn>()).
normal_map (CGAL::Second_of_pair_property_map<Pwn>())))
if (!CGAL::read_points(fname,
std::back_inserter(points),
CGAL::parameters::point_map (CGAL::First_of_pair_property_map<Pwn>()).
normal_map (CGAL::Second_of_pair_property_map<Pwn>())))
{
std::cerr << "Error: cannot read file " << fname << std::endl;
return EXIT_FAILURE;

View File

@ -1,5 +1,5 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/IO/read_ply_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/IO/write_ply_points.h>
#include <CGAL/property_map.h>
@ -25,27 +25,21 @@ int main(int argc, const char** argv)
const char* fname2 = (argc>2)?argv[2]:"data/hippo2.ply";
std::vector<Pwn> pwns1, pwns2;
std::ifstream input(fname1);
if (!input ||
!CGAL::read_PLY(input, std::back_inserter(pwns1),
CGAL::parameters::point_map (CGAL::First_of_pair_property_map<Pwn>()).
normal_map (Normal_map())))
if (!CGAL::read_points(fname1, std::back_inserter(pwns1),
CGAL::parameters::point_map (CGAL::First_of_pair_property_map<Pwn>()).
normal_map (Normal_map())))
{
std::cerr << "Error: cannot read file " << fname1 << std::endl;
return EXIT_FAILURE;
}
input.close();
input.open(fname2);
if (!input ||
!CGAL::read_PLY(input, std::back_inserter(pwns2),
if (!CGAL::read_points(fname2, std::back_inserter(pwns2),
CGAL::parameters::point_map (Point_map()).
normal_map (Normal_map())))
{
std::cerr << "Error: cannot read file " << fname2 << std::endl;
return EXIT_FAILURE;
}
input.close();
// EITHER call the registration method Super4PCS from OpenGR to get the transformation to apply to pwns2
// std::pair<K::Aff_transformation_3, double> res =

View File

@ -1,5 +1,5 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/IO/read_ply_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/IO/write_ply_points.h>
#include <CGAL/property_map.h>
#include <CGAL/Aff_transformation_3.h>
@ -28,27 +28,21 @@ int main(int argc, const char** argv)
const char* fname2 = (argc>2)?argv[2]:"data/hippo2.ply";
std::vector<Pwn> pwns1, pwns2;
std::ifstream input(fname1);
if (!input ||
!CGAL::read_PLY(input, std::back_inserter(pwns1),
CGAL::parameters::point_map (CGAL::First_of_pair_property_map<Pwn>()).
normal_map (Normal_map())))
if (!CGAL::read_points(fname1, std::back_inserter(pwns1),
CGAL::parameters::point_map (CGAL::First_of_pair_property_map<Pwn>()).
normal_map (Normal_map())))
{
std::cerr << "Error: cannot read file " << fname1 << std::endl;
return EXIT_FAILURE;
}
input.close();
input.open(fname2);
if (!input ||
!CGAL::read_PLY(input, std::back_inserter(pwns2),
CGAL::parameters::point_map (Point_map()).
normal_map (Normal_map())))
if (!CGAL::read_points(fname2, std::back_inserter(pwns2),
CGAL::parameters::point_map (Point_map()).
normal_map (Normal_map())))
{
std::cerr << "Error: cannot read file " << fname2 << std::endl;
return EXIT_FAILURE;
}
input.close();
std::cerr << "Computing registration transformation using OpenGR Super4PCS.." << std::endl;
// First, compute registration transformation using OpenGR Super4PCS

View File

@ -1,5 +1,5 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/IO/read_ply_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/IO/write_ply_points.h>
#include <CGAL/property_map.h>
#include <CGAL/Aff_transformation_3.h>
@ -28,27 +28,21 @@ int main(int argc, const char** argv)
const char* fname2 = (argc>2)?argv[2]:"data/hippo2.ply";
std::vector<Pwn> pwns1, pwns2;
std::ifstream input(fname1);
if (!input ||
!CGAL::read_PLY(input, std::back_inserter(pwns1),
CGAL::parameters::point_map (CGAL::First_of_pair_property_map<Pwn>()).
normal_map (Normal_map())))
if (!CGAL::read_points(fname1, std::back_inserter(pwns1),
CGAL::parameters::point_map (CGAL::First_of_pair_property_map<Pwn>()).
normal_map (Normal_map())))
{
std::cerr << "Error: cannot read file " << fname1 << std::endl;
return EXIT_FAILURE;
}
input.close();
input.open(fname2);
if (!input ||
!CGAL::read_PLY(input, std::back_inserter(pwns2),
CGAL::parameters::point_map (Point_map()).
normal_map (Normal_map())))
if (!CGAL::read_points(fname2, std::back_inserter(pwns2),
CGAL::parameters::point_map (Point_map()).
normal_map (Normal_map())))
{
std::cerr << "Error: cannot read file " << fname2 << std::endl;
return EXIT_FAILURE;
}
input.close();
//
// Prepare ICP config

View File

@ -2,7 +2,7 @@
#include <CGAL/property_map.h>
#include <CGAL/compute_average_spacing.h>
#include <CGAL/remove_outliers.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <vector>
#include <fstream>
@ -18,10 +18,8 @@ int main(int argc, char*argv[])
// Reads a .xyz point set file in points[].
// The Identity_property_map property map can be omitted here as it is the default value.
std::vector<Point> points;
std::ifstream stream(fname);
if (!stream ||
!CGAL::read_XYZ(stream, std::back_inserter(points),
CGAL::parameters::point_map(CGAL::Identity_property_map<Point>())))
if (!CGAL::read_points(fname, std::back_inserter(points),
CGAL::parameters::point_map(CGAL::Identity_property_map<Point>())))
{
std::cerr << "Error: cannot read file " << fname << std::endl;
return EXIT_FAILURE;

View File

@ -1,5 +1,5 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/estimate_scale.h>
#include <CGAL/jet_smooth_point_set.h>
@ -27,11 +27,9 @@ int main (int argc, char** argv)
CGAL::Timer task_timer;
std::vector<Point_3> points;
std::ifstream stream(fname);
// read input
if (!(stream
&& CGAL::read_XYZ(stream, std::back_inserter(points))))
if (!CGAL::read_points(fname, std::back_inserter(points)))
{
std::cerr << "Error: can't read input file" << std::endl;
return EXIT_FAILURE;

View File

@ -1,5 +1,5 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/IO/write_xyz_points.h>
#include <CGAL/property_map.h>
@ -30,10 +30,8 @@ int main (int argc, char** argv)
Pwn_vector points;
// Loading point set from a file.
std::ifstream stream(argc>1 ? argv[1] : "data/cube.pwn");
if (!stream ||
!CGAL::read_XYZ(stream,
if (!CGAL::read_points((argc>1 ? argv[1] : "data/cube.pwn"),
std::back_inserter(points),
CGAL::parameters::point_map(Point_map()).
normal_map(Normal_map())))

View File

@ -1,6 +1,6 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/wlop_simplify_and_regularize_point_set.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/IO/write_xyz_points.h>
#include <vector>
@ -21,9 +21,8 @@ int main(int argc, char** argv)
// Reads a .xyz point set file in points[]
std::vector<Point> points;
std::ifstream stream(input_filename);
if (!stream || !CGAL::read_XYZ(stream, std::back_inserter(points)))
if (!CGAL::read_points(input_filename, std::back_inserter(points)))
{
std::cerr << "Error: cannot read file " << input_filename << std::endl;

View File

@ -20,7 +20,7 @@
#include <CGAL/Poisson_implicit_surface_3.h>
#include <CGAL/IO/facets_in_complex_2_to_triangle_mesh.h>
#include <CGAL/Poisson_reconstruction_function.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/compute_average_spacing.h>
#include <CGAL/Polygon_mesh_processing/compute_normal.h>
@ -185,12 +185,11 @@ int main(int argc, char * argv[])
extension == ".pwn" || extension == ".PWN")
{
// Reads the point set file in points[].
// Note: read_XYZ() requires an iterator over points
// Note: read_points() requires an iterator over points
// + property maps to access each point's position and normal.
std::ifstream stream(input_filename.c_str());
if (!stream ||
!CGAL::read_XYZ(
stream,
!CGAL::read_points(
input_filename.c_str(),
std::back_inserter(points),
CGAL::parameters::point_map
(CGAL::make_first_of_pair_property_map(Point_with_normal())).

View File

@ -6,7 +6,7 @@
#include <CGAL/IO/facets_in_complex_2_to_triangle_mesh.h>
#include <CGAL/Poisson_reconstruction_function.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/compute_average_spacing.h>
#include <CGAL/Polygon_mesh_processing/distance.h>
@ -40,13 +40,12 @@ int main(void)
FT sm_distance = 0.375; // Surface Approximation error w.r.t. point set average spacing.
// Reads the point set file in points[].
// Note: read_XYZ() requires an iterator over points
// Note: read_points() requires an iterator over points
// + property maps to access each point's position and normal.
PointList points;
std::ifstream stream("data/kitten.xyz");
if (!stream ||
!CGAL::read_XYZ(
stream,
!CGAL::read_points(
"data/kitten.xyz",
std::back_inserter(points),
CGAL::parameters::point_map (Point_map()).
normal_map (Normal_map())))

View File

@ -1,7 +1,7 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/poisson_surface_reconstruction.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <vector>
#include <fstream>
@ -16,10 +16,10 @@ typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
int main(void)
{
std::vector<Pwn> points;
std::ifstream stream("data/kitten.xyz");
if (!stream ||
!CGAL::read_XYZ(
stream,
!CGAL::read_points(
"data/kitten.xyz",
std::back_inserter(points),
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<Pwn>()).
normal_map(CGAL::Second_of_pair_property_map<Pwn>())))

View File

@ -19,7 +19,7 @@
#include <CGAL/Poisson_reconstruction_function.h>
#include <CGAL/Point_with_normal_3.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/readpoints.h>
#include <CGAL/compute_average_spacing.h>
#include <CGAL/Polygon_mesh_processing/compute_normal.h>
@ -135,13 +135,11 @@ int main(int argc, char * argv[])
extension == ".pwn" || extension == ".PWN")
{
// Reads the point set file in points[].
// Note: read_XYZ() requires an iterator over points
// Note: read_points() requires an iterator over points
// + property maps to access each point's position and normal.
// The position property map can be omitted here as we use iterators over Point_3 elements.
std::ifstream stream(input_filename.c_str());
if (!stream ||
!CGAL::read_XYZ(
stream,
if (!CGAL::read_points(
input_filename.c_str(),
std::back_inserter(points),
CGAL::parameters::normal_map
(CGAL::make_normal_of_point_with_normal_map(PointList::value_type()))

View File

@ -7,7 +7,7 @@
#include <CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h>
#include <CGAL/Polygon_mesh_processing/orientation.h>
#include <CGAL/IO/OFF.h>
#include <CGAL/IO/polygon_soup_io.h>
#include <vector>
#include <fstream>
@ -19,12 +19,11 @@ typedef CGAL::Polyhedron_3<K, CGAL::Polyhedron_items_with_id_3> Polyhedron;
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/tet-shuffled.off";
std::ifstream input(filename);
std::vector<K::Point_3> points;
std::vector<std::vector<std::size_t> > polygons;
if(!input || !CGAL::read_OFF(input, points, polygons) || points.empty())
if(!CGAL::read_polygon_soup(filename, points, polygons) || points.empty())
{
std::cerr << "Cannot open file " << std::endl;
return EXIT_FAILURE;

View File

@ -1,5 +1,5 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/property_map.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Shape_detection/Region_growing/Region_growing.h>
@ -96,12 +96,12 @@ int main()
std::cerr << "Failed open file \'" << input_file << "\'" << std::endl;
return EXIT_FAILURE;
}
input_stream.close();
std::cout << "Loading point cloud: " << input_file << "...";
CGAL::Timer t;
t.start();
if (!input_stream ||
!CGAL::read_XYZ(input_stream,
if (!CGAL::read_points(input_file.c_str(),
std::back_inserter(points),
CGAL::parameters::point_map(Point_map()).normal_map(Normal_map()))) {

View File

@ -1,5 +1,5 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/property_map.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Shape_detection/Efficient_RANSAC.h>
@ -63,12 +63,12 @@ int main()
std::cerr << "failed open file \'" <<input_file << "\'" << std::endl;
return EXIT_FAILURE;
}
input_stream.close();
std::cout << "Loading point cloud: " << input_file << "...";
CGAL::Timer t;
t.start();
if (!input_stream ||
!CGAL::read_XYZ(input_stream,
if (!CGAL::read_points(input_file.c_str(),
std::back_inserter(points),
CGAL::parameters::point_map(Point_map()).normal_map(Normal_map())))
{

View File

@ -57,7 +57,7 @@ Polyhedron_demo_gocad_plugin::load(QFileInfo fileinfo, bool& ok, bool add_to_sce
ok = false;
return QList<Scene_item*>();
}
in.close();
CGAL::Timer t;
t.start();

View File

@ -1,13 +1,13 @@
#include "SMesh_type.h"
#include "Scene_surface_mesh_item.h"
#include "Scene_polygon_soup_item.h"
#include "Kernel_type.h"
#include "Scene.h"
#include "SMesh_type.h"
#include <CGAL/Three/Polyhedron_demo_io_plugin_interface.h>
#include <CGAL/Three/Three.h>
#include <CGAL/IO/STL.h>
#include <CGAL/IO/polygon_soup_io.h>
#include <CGAL/boost/graph/io.h>
#include <CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h>
@ -65,6 +65,7 @@ load(QFileInfo fileinfo, bool& ok, bool add_to_scene){
ok = false;
return QList<Scene_item*>();
}
in.close();
if(fileinfo.size() == 0)
{
CGAL::Three::Three::warning( tr("The file you are trying to load is empty."));
@ -75,9 +76,9 @@ load(QFileInfo fileinfo, bool& ok, bool add_to_scene){
CGAL::Three::Three::scene()->addItem(item);
return QList<Scene_item*>()<<item;
}
std::vector<std::array<double, 3> > points;
std::vector<std::array<int, 3> > triangles;
if (!CGAL::read_STL(in, points, triangles))
std::vector<EPICK::Point_3> points;
std::vector<std::vector<int> > triangles;
if (!CGAL::read_polygon_soup(fileinfo.filePath().toUtf8().toStdString(), points, triangles))
{
std::cerr << "Error: invalid STL file" << std::endl;
ok = false;
@ -90,11 +91,10 @@ load(QFileInfo fileinfo, bool& ok, bool add_to_scene){
SMesh* SM = new SMesh();
if (CGAL::Polygon_mesh_processing::is_polygon_soup_a_polygon_mesh(triangles))
{
auto pmap = boost::make_function_property_map<std::array<double, 3>, Point_3>(
[](const std::array<double, 3>& a) { return Point_3(a[0], a[1], a[2]); });
CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(points, triangles, *SM,
CGAL::parameters::point_map(pmap),
CGAL::parameters::all_default());
//auto pmap = boost::make_function_property_map<std::array<double, 3>, Point_3>(
// [](const std::array<double, 3>& a) { return Point_3(a[0], a[1], a[2]); });
CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(points, triangles, *SM);
}
if(!SM->is_valid() || SM->is_empty()){

View File

@ -355,7 +355,7 @@ public:
if(is_polygon_mesh)
{
FaceGraph* poly = new FaceGraph();
if (CGAL::IO::internal::vtkPointSet_to_polygon_mesh(data, *poly))
if (CGAL::IO::internal::vtkPointSet_to_polygon_mesh(data, *poly, CGAL::parameters::all_default()))
{
Scene_facegraph_item* poly_item = new Scene_facegraph_item(poly);
if(group)

View File

@ -661,7 +661,7 @@ Scene_polygon_soup_item::new_triangle(const std::size_t i,
d->soup->polygons.push_back(new_polygon);
}
template <class Point, class Polygon>
template <class Point, typename Polygon>
void Scene_polygon_soup_item::load(const std::vector<Point>& points, const std::vector<Polygon>& polygons)
{
if(!d->soup)
@ -700,8 +700,8 @@ void Scene_polygon_soup_item::load(const std::vector<Point>& points, const std::
}
// Force the instanciation of the template function for the types used in the STL_io_plugin. This is needed
// because the d-pointer forbid the definition in the .h for this function.
template SCENE_POLYGON_SOUP_ITEM_EXPORT void Scene_polygon_soup_item::load<std::array<double, 3>, std::array<int, 3> >
(const std::vector<std::array<double, 3> >& points, const std::vector<std::array<int, 3> >& polygons);
template SCENE_POLYGON_SOUP_ITEM_EXPORT void Scene_polygon_soup_item::load<EPICK::Point_3, std::vector<int> >
(const std::vector<EPICK::Point_3>& points, const std::vector<std::vector<int> >& polygons);
template SCENE_POLYGON_SOUP_ITEM_EXPORT void Scene_polygon_soup_item::load<CGAL::Epick::Point_3, std::vector<std::size_t> >
(const std::vector<CGAL::Epick::Point_3>& points, const std::vector<std::vector<std::size_t> >& polygons);
template SCENE_POLYGON_SOUP_ITEM_EXPORT void Scene_polygon_soup_item::load<CGAL::Epick::Point_3, std::vector<std::size_t> >

View File

@ -113,7 +113,7 @@ public:
Scene_polygon_soup_item* clone() const Q_DECL_OVERRIDE;
template <class Point, class Polygon>
template <class Point, typename Polygon>
void load(const std::vector<Point>& points, const std::vector<Polygon>& polygons);
template <class Point, class Polygon>

View File

@ -9,6 +9,7 @@
#include <CGAL/Monge_via_jet_fitting.h>
#include <fstream>
#include <cassert>
#include <CGAL/boost/graph/IO/polygon_mesh_io.h>
#if defined(CGAL_USE_BOOST_PROGRAM_OPTIONS) && ! defined(DONT_USE_BOOST_PROGRAM_OPTIONS)
#include <boost/program_options.hpp>
@ -286,7 +287,7 @@ int main()
//load the model from <mesh.off>
PolyhedralSurf P;
CGAL::read_OFF(if_name.c_str(), P);
CGAL::read_polygon_mesh(if_name.c_str(), P);
fprintf(stderr, "loadMesh %d Ves %d Facets\n",
(int)num_vertices(P), (int)num_faces(P));
if(verbose)

View File

@ -7,7 +7,7 @@
#include <iostream>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/Point_with_normal_3.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
@ -29,11 +29,9 @@ typedef CGAL::Shape_detection::Plane<Traits> Plane;
int main(int argc, char** argv) {
Pwn_vector points;
std::ifstream stream(argc > 1 ? argv[1] : "data/cube.pwn");
if (!stream ||
!CGAL::read_XYZ(
stream,
if (!CGAL::read_points(
(argc > 1 ? argv[1] : "data/cube.pwn"),
std::back_inserter(points),
CGAL::parameters::point_map(Point_map()).
normal_map(Normal_map()))) {

View File

@ -7,7 +7,7 @@
#include <iostream>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/Point_with_normal_3.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
@ -34,14 +34,12 @@ int main (int argc, char** argv) {
Pwn_vector points;
// Load point set from a file.
std::ifstream stream(filename);
if (!stream ||
!CGAL::read_XYZ(
stream,
std::back_inserter(points),
CGAL::parameters::point_map(Point_map()).
normal_map(Normal_map()))) {
if (!CGAL::read_points(
filename,
std::back_inserter(points),
CGAL::parameters::point_map(Point_map()).
normal_map(Normal_map()))) {
std::cerr << "Error: cannot read file cube.pwn!" << std::endl;
return EXIT_FAILURE;

View File

@ -8,7 +8,7 @@
#include <CGAL/Timer.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/Point_with_normal_3.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
@ -61,14 +61,12 @@ int main (int argc, char** argv) {
const char* filename = (argc > 1) ? argv[1] : "data/cube.pwn";
Pwn_vector points;
std::ifstream stream(filename);
if (!stream ||
!CGAL::read_XYZ(
stream,
std::back_inserter(points),
CGAL::parameters::point_map(Point_map()).
normal_map(Normal_map()))) {
if (!CGAL::read_points(
filename,
std::back_inserter(points),
CGAL::parameters::point_map(Point_map()).
normal_map(Normal_map()))) {
std::cerr << "Error: cannot read file cube.pwn!" << std::endl;
return EXIT_FAILURE;

View File

@ -2,7 +2,7 @@
#include <iostream>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/Point_with_normal_3.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
@ -27,11 +27,10 @@ int main(int argc, char** argv) {
Pwn_vector points;
// Load point set from a file.
std::ifstream stream((argc > 1) ? argv[1] : "data/cube.pwn");
if (!stream ||
!CGAL::read_XYZ(
stream,
!CGAL::read_points(
((argc > 1) ? argv[1] : "data/cube.pwn"),
std::back_inserter(points),
CGAL::parameters::point_map(Point_map()).
normal_map(Normal_map()))) {

View File

@ -2,7 +2,7 @@
#include <iostream>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/Point_with_normal_3.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
@ -31,11 +31,9 @@ int main(int argc, char** argv) {
Pwn_vector points;
// Load point set from a file.
std::ifstream stream((argc > 1) ? argv[1] : "data/cube.pwn");
if (!stream ||
!CGAL::read_XYZ(
stream,
if (!CGAL::read_points(
((argc > 1) ? argv[1] : "data/cube.pwn"),
std::back_inserter(points),
CGAL::parameters::point_map(Point_map()).
normal_map(Normal_map()))) {

View File

@ -4,7 +4,7 @@
#include <CGAL/Timer.h>
#include <CGAL/number_utils.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Shape_detection/Efficient_RANSAC.h>
@ -28,11 +28,9 @@ int main(int argc, char** argv) {
Pwn_vector points;
// Load point set from a file.
std::ifstream stream((argc > 1) ? argv[1] : "data/cube.pwn");
if (!stream ||
!CGAL::read_XYZ(
stream,
if (!CGAL::read_points(
((argc > 1) ? argv[1] : "data/cube.pwn"),
std::back_inserter(points),
CGAL::parameters::point_map(Point_map()).
normal_map(Normal_map()))) {

View File

@ -9,7 +9,7 @@
#include <iostream>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Shape_detection_3.h>
@ -40,13 +40,11 @@ int run(const char* filename) {
// Load a point set from a file.
// read_XYZ takes an OutputIterator for storing the points
// and a property map to store the normal vector with each point.
std::ifstream stream(filename);
if (!stream ||
!CGAL::read_XYZ(stream,
std::back_inserter(points),
CGAL::parameters::point_map(Point_map()).
normal_map(Normal_map()))) {
if (!CGAL::read_points(filename,
std::back_inserter(points),
CGAL::parameters::point_map(Point_map()).
normal_map(Normal_map()))) {
std::cout << "Error: cannot read the file cube.pwn" << std::endl;
return EXIT_FAILURE;

View File

@ -475,7 +475,7 @@ bool write_triangle_soups_to_3mf(const std::string& fname,
}
// convenience
template<typename PointRanges, typename PolygonRanges>
template<typename PointRange, typename PolygonRange>
bool write_triangle_soup_to_3mf(const std::string& fname,
const PointRange& points,
const PolygonRange& polygons,
@ -488,7 +488,7 @@ bool write_triangle_soup_to_3mf(const std::string& fname,
return write_triangle_soups_to_3mf(fname, all_points, all_polygons, names);
}
template<typename PointRanges, typename PolygonRanges>
template<typename PointRange, typename PolygonRange>
bool write_3MF(const std::string& fname,
const PointRange& points,
const PolygonRange& polygons)

View File

@ -80,8 +80,8 @@ operator<<(VRML_1_ostream& os,
<< oformat(CGAL::to_double(t[1].z())) << " ,\n"
<< Indent << " "
<< oformat(CGAL::to_double(t[2].x())) << " "
<< oformat(CGAL::to_double(t[2].y()) << " "
<< oformat(CGAL::to_double(t[2].z()) << " ,\n"
<< oformat(CGAL::to_double(t[2].y())) << " "
<< oformat(CGAL::to_double(t[2].z())) << " ,\n"
<< Indent << " "
<< oformat(CGAL::to_double(t[3].x())) << " "
<< oformat(CGAL::to_double(t[3].y())) << " "

View File

@ -114,6 +114,165 @@ public:
DefaultMap_const
> ::type const_type;
};
template <typename Point, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool read_OFF_with_or_without_fcolors(std::istream& is,
Surface_mesh<Point>& sm,
const CGAL::File_scanner_OFF& scanner,
const CGAL_BGL_NP_CLASS& np)
{
typedef Surface_mesh<Point> Mesh;
typedef typename Mesh::Face_index Face_index;
typedef CGAL::Color Color;
typedef typename
CGAL::internal::IO::GetFaceColorMap<Mesh, CGAL_BGL_NP_CLASS>::type FCM;
using parameters::choose_parameter;
using parameters::is_default_parameter;
using parameters::get_parameter;
bool created;
typename Mesh::template Property_map<Face_index, Color> fcm;
bool is_fcm_requested =
!(is_default_parameter(get_parameter(np, internal_np::face_color_map)));
if(!is_fcm_requested && scanner.has_colors())
{
std::tie(fcm, created) =
sm.template add_property_map<Face_index, Color>("f:color", Color(0,0,0));
CGAL_assertion(created);
is_fcm_requested = true;
}
if(is_fcm_requested)
{
FCM fcolors = choose_parameter(get_parameter(np, internal_np::face_color_map),
fcm);
return CGAL::IO::internal::read_OFF_BGL(is, sm, np.face_color_map(fcolors));
}
else
return CGAL::IO::internal::read_OFF_BGL(is, sm, np);
}
template <typename Point, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool read_OFF_with_or_without_vtextures(std::istream& is,
Surface_mesh<Point>& sm,
const CGAL::File_scanner_OFF& scanner,
const CGAL_BGL_NP_CLASS& np)
{
typedef Surface_mesh<Point> Mesh;
typedef typename Mesh::Vertex_index Vertex_index;
typedef typename GetK<Surface_mesh<Point>, CGAL_BGL_NP_CLASS>::Kernel K;
typedef typename K::Point_2 Texture;
typedef typename
CGAL::internal::IO::GetVertexTextureMap<Mesh, K, CGAL_BGL_NP_CLASS>::type VTM;
typename Mesh::template Property_map<Vertex_index, Texture> vtextures;
using parameters::choose_parameter;
using parameters::is_default_parameter;
using parameters::get_parameter;
bool created;
typename Mesh::template Property_map<Vertex_index, Texture> vtm;
bool is_vtm_requested =
!(is_default_parameter(get_parameter(np, internal_np::vertex_texture_map)));
if(!is_vtm_requested && scanner.has_textures())
{
std::tie(vtm, created) =
sm.template add_property_map<Vertex_index, Texture>("v:texcoord");
CGAL_assertion(created);
is_vtm_requested = true;
}
if(is_vtm_requested)
{
VTM vtextures = choose_parameter(get_parameter(np, internal_np::vertex_texture_map),
vtm);
return read_OFF_with_or_without_fcolors(is, sm, scanner, np.vertex_texture_map(vtextures));
}
else
return read_OFF_with_or_without_fcolors(is, sm, scanner, np);
}
template <typename Point, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool read_OFF_with_or_without_vcolors(std::istream& is,
Surface_mesh<Point>& sm,
const CGAL::File_scanner_OFF& scanner,
const CGAL_BGL_NP_CLASS& np)
{
typedef Surface_mesh<Point> Mesh;
typedef typename Mesh::Vertex_index Vertex_index;
typedef CGAL::Color Color;
typename Mesh::template Property_map<Vertex_index, Color> vcolors;
typedef typename
CGAL::internal::IO::GetVertexColorMap<Mesh, CGAL_BGL_NP_CLASS>::type VCM;
using parameters::choose_parameter;
using parameters::is_default_parameter;
using parameters::get_parameter;
bool created;
bool is_vcm_requested =
!(is_default_parameter(get_parameter(np, internal_np::vertex_color_map)));
typename Mesh::template Property_map<Vertex_index, Color> vcm;
if(!is_vcm_requested && scanner.has_colors())
{
std::tie(vcm, created) =
sm.template add_property_map<Vertex_index, Color>("v:color", Color(0,0,0));
CGAL_assertion(created);
is_vcm_requested = true;
}
if(is_vcm_requested)
{
VCM vcolors = choose_parameter(get_parameter(np, internal_np::vertex_color_map),
vcm);
return read_OFF_with_or_without_vtextures(is, sm, scanner, np.vertex_color_map(vcolors));
}
else
return read_OFF_with_or_without_vtextures(is, sm, scanner, np);
}
template <typename Point, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool read_OFF_with_or_without_vnormals(std::istream& is,
Surface_mesh<Point>& sm,
const CGAL::File_scanner_OFF& scanner,
const CGAL_BGL_NP_CLASS& np)
{
typedef Surface_mesh<Point> Mesh;
typedef typename Mesh::Vertex_index Vertex_index;
typedef typename GetK<Surface_mesh<Point>, CGAL_BGL_NP_CLASS>::Kernel K;
typedef typename K::Vector_3 Normal;
using parameters::choose_parameter;
using parameters::is_default_parameter;
using parameters::get_parameter;
typedef typename
CGAL::internal::IO::GetVertexNormalMap<Mesh, K, CGAL_BGL_NP_CLASS>::type VNM;
bool is_vnm_requested =
!(is_default_parameter(get_parameter(np, internal_np::vertex_normal_map)));
bool created;
typename Mesh::template Property_map<Vertex_index, Normal> vnm;
if(!is_vnm_requested && scanner.has_normals())
{
std::tie(vnm, created) =
sm.template add_property_map<Vertex_index, Normal>("v:normal");
CGAL_assertion(created);
is_vnm_requested = true;
}
if(is_vnm_requested){
VNM vnormals = choose_parameter(get_parameter(np, internal_np::vertex_normal_map),
vnm);
return read_OFF_with_or_without_vcolors(is, sm, scanner, np.vertex_normal_map(vnormals));
}
else
return read_OFF_with_or_without_vcolors(is, sm, scanner, np);
}
}//end IO
}// end internal
////////////////////////////////////////////////////////////////////////////////////////////////////
@ -155,72 +314,13 @@ bool read_OFF(std::istream& is,
typedef typename CGAL::GetVertexPointMap<Mesh, CGAL_BGL_NP_CLASS>::type VPM;
typedef typename
CGAL::internal::IO::GetVertexNormalMap<Mesh, K, CGAL_BGL_NP_CLASS>::type VNM;
typedef typename
CGAL::internal::IO::GetVertexColorMap<Mesh, CGAL_BGL_NP_CLASS>::type VCM;
typedef typename
CGAL::internal::IO::GetVertexTextureMap<Mesh, K, CGAL_BGL_NP_CLASS>::type VTM;
typedef typename
CGAL::internal::IO::GetFaceColorMap<Mesh, CGAL_BGL_NP_CLASS>::type FCM;
const bool is_vnm_requested =
!(is_default_parameter(get_parameter(np, internal_np::vertex_normal_map)));
const bool is_vcm_requested =
!(is_default_parameter(get_parameter(np, internal_np::vertex_color_map)));
const bool is_vtm_requested =
!(is_default_parameter(get_parameter(np, internal_np::vertex_texture_map)));
const bool is_fcm_requested =
!(is_default_parameter(get_parameter(np, internal_np::face_color_map)));
bool created;
typename Mesh::template Property_map<Vertex_index, Normal> vnm;
typename Mesh::template Property_map<Vertex_index, Color> vcm;
typename Mesh::template Property_map<Vertex_index, Texture> vtm;
typename Mesh::template Property_map<Face_index, Color> fcm;
if(!is_vnm_requested)
{
std::tie(vnm, created) =
sm.template add_property_map<Vertex_index, Normal>("v:normal");
CGAL_assertion(created);
}
if(!is_vcm_requested)
{
std::tie(vcm, created) =
sm.template add_property_map<Vertex_index, Color>("v:color", Color(0,0,0));
CGAL_assertion(created);
}
if(!is_vtm_requested)
{
std::tie(vtm, created) =
sm.template add_property_map<Vertex_index, Texture>("v:texcoord");
CGAL_assertion(created);
}
if(!is_fcm_requested)
{
std::tie(fcm, created) =
sm.template add_property_map<Face_index, Color>("f:color", Color(0,0,0));
CGAL_assertion(created);
}
VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
get_property_map(CGAL::vertex_point, sm));
VNM vnormals = choose_parameter(get_parameter(np, internal_np::vertex_normal_map),
vnm);
VCM vcolors = choose_parameter(get_parameter(np, internal_np::vertex_color_map),
vcm);
VTM vtextures = choose_parameter(get_parameter(np, internal_np::vertex_texture_map),
vtm);
FCM fcolors = choose_parameter(get_parameter(np, internal_np::face_color_map),
fcm);
bool res = IO::internal::read_OFF_BGL(is, sm, CGAL::parameters::vertex_point_map(vpm)
.vertex_normal_map(vnormals)
.vertex_color_map(vcolors)
.vertex_texture_map(vtextures)
.face_color_map(fcolors),
verbose);
std::streampos pos = is.tellg();
CGAL::File_scanner_OFF scanner(is, false);
is.seekg(pos);
bool res = internal::IO::read_OFF_with_or_without_vnormals(is, sm, scanner, np);
if(!res)
sm.clear();
return res;

View File

@ -2,7 +2,7 @@
#include <CGAL/Linear_cell_complex_for_combinatorial_map.h>
#include <CGAL/boost/graph/graph_traits_Linear_cell_complex_for_combinatorial_map.h>
#include <CGAL/boost/graph/IO/OFF.h>
#include <CGAL/boost/graph/IO/polygon_mesh_io.h>
#include <CGAL/mesh_segmentation.h>
#include <CGAL/property_map.h>
#include <CGAL/Unique_hash_map.h>
@ -20,7 +20,7 @@ int main()
{
// create and read LCC
LCC mesh;
CGAL::read_OFF("data/cactus.off", mesh);
CGAL::read_polygon_mesh("data/cactus.off", mesh);
// create a property-map for SDF values
typedef CGAL::Unique_hash_map<Facet_const_handle, double> Facet_double_map;

View File

@ -8,7 +8,7 @@
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_length_cost.h>
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Midpoint_placement.h>
#include <CGAL/boost/graph/IO/OFF.h>
#include <CGAL/boost/graph/IO/polygon_mesh_io.h>
#include <iostream>
#include <fstream>
@ -24,7 +24,7 @@ int main(int argc, char** argv)
LCC lcc;
const char* filename = (argc > 1) ? argv[1] : "data/cube-meshed.off";
std::ifstream is(filename);
if(!CGAL::read_OFF(filename, lcc))
if(!CGAL::read_polygon_mesh(filename, lcc))
{
std::cerr << "Failed to read input mesh: " << filename << std::endl;
return EXIT_FAILURE;

View File

@ -2,7 +2,7 @@
#include <CGAL/Linear_cell_complex_for_combinatorial_map.h>
#include <CGAL/boost/graph/graph_traits_Linear_cell_complex_for_combinatorial_map.h>
#include <CGAL/boost/graph/IO/OFF.h>
#include <CGAL/boost/graph/IO/polygon_mesh_io.h>
#include <CGAL/Mean_curvature_flow_skeletonization.h>
#include <fstream>
@ -24,7 +24,7 @@ typedef Skeleton::edge_descriptor Skeleton_edge;
int main()
{
LCC lcc;
CGAL::read_OFF("data/elephant.off", lcc);
CGAL::read_polygon_mesh("data/elephant.off", lcc);
Skeleton skeleton;
Skeletonization mcs(lcc);

View File

@ -3,7 +3,7 @@
#include <CGAL/boost/graph/graph_traits_Linear_cell_complex_for_combinatorial_map.h>
#include <CGAL/boost/graph/properties_Linear_cell_complex_for_combinatorial_map.h>
#include <CGAL/boost/graph/split_graph_into_polylines.h>
#include <CGAL/boost/graph/IO/OFF.h>
#include <CGAL/boost/graph/IO/polygon_mesh_io.h>
#include <CGAL/extract_mean_curvature_flow_skeleton.h>
#include <fstream>
@ -53,7 +53,7 @@ struct Display_polylines{
int main()
{
LCC lcc;
CGAL::read_OFF("data/elephant.off", lcc);
CGAL::read_polygon_mesh("data/elephant.off", lcc);
Skeleton skeleton;

View File

@ -5,9 +5,8 @@
#include <fstream>
#include <CGAL/IO/OFF.h>
#include <CGAL/IO/read_off_points.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/IO/write_off_points.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/write_xyz_points.h>
#include <CGAL/Iterator_range.h>
@ -102,20 +101,6 @@ void Scene::loadPointsOFF(const char* filename)
/* 1. use CGAL::File_scanner_OFF to read in data --tested */
readOFFPointsandFacets( filename, pts );
/* 2. use CGAL::read_OFF to read in data -- tested */
/* Note: read in points only, i.e. normals and faces are ignored */
/* Note: this function can NOT omit comments (starting with '#') */
// ifstream fin;
// fin.open( filename );
// check whether the file is opened properly
// if( !fin ) {
// showError( QObject::tr("Error: cannot open file %1 for reading.").arg(filename) );
// return;
// }
// if ( !CGAL::read_OFF( fin, // inout ifstream
// back_inserter(pts) ) ) { // output iterator over points
// showError( QObject::tr("Error: cannot read file %1.").arg(filename) );
// }
/* Insert the points to build a Delaunay triangulation */
/* Note: this function returns the number of inserted points;
@ -139,19 +124,11 @@ void Scene::loadPointsOFF(const char* filename)
void Scene::loadPointsXYZ(const char* filename)
{
ifstream fin;
fin.open( filename );
// Check whether the file is opened properly
if( !fin ) {
showError( QObject::tr("Error: cannot open file %1 for reading.").arg(filename) );
return;
}
/* Use CGAL::read_XYZ to read in data -- tested */
/* Note: this function reads in points only (normals are ignored) */
/* Note: this function can NOT omit comments (starting with '#') */
list<Point_3> pts;
if( !CGAL::read_XYZ( fin, // input ifstream
if( !CGAL::read_points( filename, // input ifstream
back_inserter(pts) ) ) { // output iterator over points
showError( QObject::tr("Error: cannot read file %1.").arg(filename) );
}