Misc IO fixes

This commit is contained in:
Mael Rouxel-Labbé 2020-10-14 21:46:13 +02:00
parent 5f1821f173
commit 4b28101397
11 changed files with 60 additions and 28 deletions

View File

@ -22,7 +22,7 @@ int main()
std::ofstream out("out.inp");
out.precision(17);
CGAL::write_INP(out, sm, "out.inp", "S4R");
CGAL::write_INP(out, "out.inp", "S4R", sm);
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,17 @@
OFF
6 7 0
1 1 0
3 1 0
2 2 0
2 3 0
0 0 0
4 0 0
3 0 1 2
3 0 2 3
3 1 3 2
3 0 4 1
3 1 4 5
3 1 5 3
3 0 3 4

View File

@ -51,7 +51,9 @@ int main (int argc, char** argv)
std::cerr << "Reading input" << std::endl;
std::vector<Point> pts;
if (!(CGAL::read_points(filename, std::back_inserter(pts))))
if (!(CGAL::read_points(filename, std::back_inserter(pts),
// the PLY reader expects a binary file by default
CGAL::parameters::use_binary_mode(false))))
{
std::cerr << "Error: cannot read " << filename << std::endl;
return EXIT_FAILURE;

View File

@ -54,7 +54,9 @@ int main (int argc, char** argv)
std::cerr << "Reading input" << std::endl;
Point_set pts;
if(!(CGAL::read_point_set(filename, pts)))
if(!(CGAL::read_point_set(filename, pts,
// the PLY reader expects a binary file by default
CGAL::parameters::use_binary_mode(false))))
{
std::cerr << "Error: cannot read " << filename << std::endl;
return EXIT_FAILURE;

View File

@ -70,7 +70,9 @@ int main (int argc, char** argv)
std::vector<Point> pts;
std::cerr << "Reading input" << std::endl;
if (!(CGAL::read_points(filename, std::back_inserter(pts))))
if (!(CGAL::read_points(filename, std::back_inserter(pts),
// the PLY reader expects a binary file by default
CGAL::parameters::use_binary_mode(false))))
{
std::cerr << "Error: cannot read " << filename << std::endl;
return EXIT_FAILURE;

View File

@ -35,7 +35,9 @@ int main (int argc, char** argv)
std::string filename_config = (argc>2) ? argv[2] : "data/b9_mesh_config.gz";
Mesh mesh;
if(!CGAL::read_polygon_mesh(filename, mesh))
if(!CGAL::read_polygon_mesh(filename, mesh,
// the PLY reader expects a binary file by default
CGAL::parameters::use_binary_mode(false)))
{
std::cerr << "Invalid input." << std::endl;
return 1;

View File

@ -90,7 +90,7 @@ bool read_points(const std::string& fname,
{
const std::string ext = IO::internal::get_file_extension(fname);
if(ext == "xyz" || "pwn")
if(ext == "xyz" || ext == "pwn")
return read_XYZ<OutputIteratorValueType>(fname, output, np);
else if(ext == "off")
return read_OFF<OutputIteratorValueType>(fname, output, np);

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/readpoints.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/compute_average_spacing.h>
#include <CGAL/Polygon_mesh_processing/compute_normal.h>

View File

@ -10,13 +10,12 @@ appends it to the polyhedral surface \f$ P\f$. Only the point coordinates
and facets from the input stream are used to build the polyhedral
surface. Neither normal vectors nor color attributes are evaluated.
\sa `CGAL::Polyhedron_3<Traits>`
\sa `CGAL::Polyhedron_incremental_builder_3<HDS>`
\sa \link PkgPolyhedronIOFunc `operator<<(std::ostream&, Polyhedron_3<PolyhedronTraits_3>&)`\endlink
This function overloads the generic function \link PkgBGLIoFuncsOFF `read_OFF(std::istream&, FaceGraph)`\endlink
(if no named parameters are used).
\note This function requires `Traits` to be a model of `Kernel` (a stronger requirement
than `PolyhedronTraits_3`).
\cgalHeading{Implementation}
This operator is implemented using the modifier mechanism for
@ -27,25 +26,29 @@ polyhedral surface.
\note Starting with \cgal 5.2, this function will no longer set the `ios::badbit`
of the input stream `in` if the file contains 0 vertices.
\sa `CGAL::Polyhedron_3<Traits>`
\sa `CGAL::Polyhedron_incremental_builder_3<HDS>`
\sa \link PkgPolyhedronIOFunc `operator<<(std::ostream&, Polyhedron_3<Traits>&)`\endlink
*/
template <class PolyhedronTraits_3>
bool read_OFF( std::istream& in, Polyhedron_3<PolyhedronTraits_3>& P);
template <class Traits>
bool read_OFF( std::istream& in, Polyhedron_3<Traits>& P);
/*!
\relates Polyhedron_3
\deprecated This function is deprecated since \cgal 5.2,
\link PkgPolyhedronIOFunc `CGAL::read_OFF(std::ostream&, Polyhedron_3<PolyhedronTraits_3>&)` \endlink should be used instead.
\link PkgPolyhedronIOFunc `CGAL::read_OFF(std::ostream&, Polyhedron_3<Traits>&)` \endlink should be used instead.
*/
template <class PolyhedronTraits_3>
bool read_off( std::ostream& out, Polyhedron_3<PolyhedronTraits_3>& P);
template <class Traits>
bool read_off( std::ostream& out, Polyhedron_3<Traits>& P);
/*!
\relates Polyhedron_3
\ingroup PkgPolyhedronIOFunc
calls \link read_OFF() `read_OFF(in, P)` \endlink.
*/
template <class PolyhedronTraits_3>
std::istream& operator>>( std::istream& in, Polyhedron_3<PolyhedronTraits_3>& P);
template <class Traits>
std::istream& operator>>( std::istream& in, Polyhedron_3<Traits>& P);
/*!
\relates Polyhedron_3
@ -69,26 +72,26 @@ This function overloads the generic function \link PkgBGLIoFuncsOFF `write_OFF(s
\sa `CGAL::Polyhedron_3<Traits>`
\sa `CGAL::Polyhedron_incremental_builder_3<HDS>`
\sa \link PkgPolyhedronIOFunc `operator>>(std::istream& in, Polyhedron_3<PolyhedronTraits_3>& P)` \endlink
\sa \link PkgPolyhedronIOFunc `operator>>(std::istream& in, Polyhedron_3<Traits>& P)` \endlink
*/
template <class PolyhedronTraits_3>
bool write_OFF( std::ostream& out, Polyhedron_3<PolyhedronTraits_3>& P);
template <class Traits>
bool write_OFF( std::ostream& out, Polyhedron_3<Traits>& P);
/*!
\relates Polyhedron_3
\deprecated This function is deprecated since \cgal 5.2,
\link PkgPolyhedronIOFunc `CGAL::write_OFF(std::ostream&, Polyhedron_3<PolyhedronTraits_3>&)` \endlink should be used instead.
\link PkgPolyhedronIOFunc `CGAL::write_OFF(std::ostream&, Polyhedron_3<Traits>&)` \endlink should be used instead.
*/
template <class PolyhedronTraits_3>
bool write_off( std::ostream& out, Polyhedron_3<PolyhedronTraits_3>& P);
template <class Traits>
bool write_off( std::ostream& out, Polyhedron_3<Traits>& P);
/*!
\relates Polyhedron_3
\ingroup PkgPolyhedronIOFunc
calls \link write_OFF() `write_OFF(out, P)` \endlink.
*/
template <class PolyhedronTraits_3>
std::ostream& operator<<( std::ostream& out, Polyhedron_3<PolyhedronTraits_3>& P);
template <class Traits>
std::ostream& operator<<( std::ostream& out, Polyhedron_3<Traits>& P);
} /* namespace CGAL */

View File

@ -76,6 +76,9 @@ public:
out() << " "
<< oformat(x) << ' ' << oformat(y) << ' ' << oformat(z) << ',' << '\n';
}
void write_vertex_normal(const double, const double, const double) { }
void write_vertex_color(const double, const double, const double) { }
void write_vertex_texture(const double, const double) { }
void write_facet_header() const
{
@ -86,6 +89,7 @@ public:
void write_facet_begin(std::size_t) { out() << " "; }
void write_facet_vertex_index( std::size_t idx) { out() << idx << ',';}
void write_face_color(const double, const double, const double) { }
void write_facet_end() { out() << "-1,\n"; }
};

View File

@ -51,7 +51,7 @@ int main(int argc, char** argv)
Seam_edge_pmap seam_edge_pm = sm.add_property_map<SM_edge_descriptor, bool>("e:on_seam", false).first;
Seam_vertex_pmap seam_vertex_pm = sm.add_property_map<SM_vertex_descriptor, bool>("v:on_seam", false).first;
const char* filename = (argc>2) ? argv[2] : "data/lion.selection.txt";
const char* selection_filename = (argc>2) ? argv[2] : "data/lion.selection.txt";
// Read the constraints on the border
std::ifstream in(filename);
@ -65,7 +65,7 @@ int main(int argc, char** argv)
}
Mesh mesh(sm, seam_edge_pm, seam_vertex_pm);
SM_halfedge_descriptor smhd = mesh.add_seams(filename);
SM_halfedge_descriptor smhd = mesh.add_seams(selection_filename);
if(smhd == SM_halfedge_descriptor() ) {
std::cerr << "Warning: No seams in input" << std::endl;
}