Merge pull request #5352 from lrineau/CGAL-fix_CGAL_IO-GF

Fixes after the PR "CGAL I/O
This commit is contained in:
Laurent Rineau 2021-02-18 15:23:43 +01:00
commit a72fdb7b3c
37 changed files with 561 additions and 64 deletions

View File

@ -18,7 +18,7 @@
#include <CGAL/boost/graph/IO/Generic_facegraph_builder.h> #include <CGAL/boost/graph/IO/Generic_facegraph_builder.h>
#include <CGAL/boost/graph/iterator.h> #include <CGAL/boost/graph/iterator.h>
#include <CGAL/boost/graph/Named_function_parameters.h> #include <CGAL/boost/graph/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <boost/container/flat_map.hpp> #include <boost/container/flat_map.hpp>
#include <fstream> #include <fstream>
@ -271,7 +271,7 @@ bool read_GOCAD(const std::string& fname, Graph& g,
/// \cgalParamNBegin{stream_precision} /// \cgalParamNBegin{stream_precision}
/// \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} /// \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
/// \cgalParamType{int} /// \cgalParamType{int}
/// \cgalParamDefault{`6`} /// \cgalParamDefault{`the precision of the stream `os``}
/// \cgalParamNEnd /// \cgalParamNEnd
/// \cgalNamedParamsEnd /// \cgalNamedParamsEnd
/// ///
@ -303,8 +303,7 @@ bool write_GOCAD(std::ostream& os,
if(!os.good()) if(!os.good())
return false; return false;
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6); set_stream_precision_from_NP(os, np);
os.precision(precision);
os << "GOCAD TSurf 1\n" os << "GOCAD TSurf 1\n"
"HEADER {\n" "HEADER {\n"
@ -380,7 +379,7 @@ bool write_GOCAD(std::ostream& os, const char* name, const Graph& g,
/// \cgalParamNBegin{stream_precision} /// \cgalParamNBegin{stream_precision}
/// \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} /// \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
/// \cgalParamType{int} /// \cgalParamType{int}
/// \cgalParamDefault{`6`} /// \cgalParamDefault{`the precision of the stream `os``}
/// \cgalParamNEnd /// \cgalParamNEnd
/// \cgalNamedParamsEnd /// \cgalNamedParamsEnd
/// ///
@ -454,6 +453,7 @@ bool write_GOCAD(const std::string& fname,
{ {
std::ofstream os(fname); std::ofstream os(fname);
CGAL::set_mode(os, CGAL::IO::ASCII); CGAL::set_mode(os, CGAL::IO::ASCII);
return write_GOCAD(os, fname.c_str(), g, np); return write_GOCAD(os, fname.c_str(), g, np);
} }

View File

@ -117,8 +117,7 @@ public:
if(!m_os.good()) if(!m_os.good())
return false; return false;
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6); set_stream_precision_from_NP(m_os, np);
m_os.precision(precision);
VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
get_const_property_map(CGAL::vertex_point, g)); get_const_property_map(CGAL::vertex_point, g));

View File

@ -231,7 +231,7 @@ bool read_OBJ(const std::string& fname, Graph& g,
\cgalParamNBegin{stream_precision} \cgalParamNBegin{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int} \cgalParamType{int}
\cgalParamDefault{`6`} \cgalParamDefault{`the precision of the stream `os``}
\cgalParamNEnd \cgalParamNEnd
\cgalNamedParamsEnd \cgalNamedParamsEnd
@ -285,6 +285,11 @@ bool write_OBJ(std::ostream& os, const Graph& g,
\cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t` \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t`
must be available in `Graph`.} must be available in `Graph`.}
\cgalParamNEnd \cgalParamNEnd
\cgalParamNBegin{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int}
\cgalParamDefault{`6`}
\cgalParamNEnd
\cgalNamedParamsEnd \cgalNamedParamsEnd
\returns `true` if writing was successful, `false` otherwise. \returns `true` if writing was successful, `false` otherwise.

View File

@ -284,9 +284,9 @@ bool read_OFF(const std::string& fname, Graph& g,
\deprecated This function is deprecated since \cgal 5.2, `CGAL::read_OFF()` should be used instead. \deprecated This function is deprecated since \cgal 5.2, `CGAL::read_OFF()` should be used instead.
*/ */
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS> template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
CGAL_DEPRECATED bool read_off(std::ostream& os, Graph& g, const CGAL_BGL_NP_CLASS& np) CGAL_DEPRECATED bool read_off(std::istream& is, Graph& g, const CGAL_BGL_NP_CLASS& np)
{ {
return read_OFF(os, g, np); return read_OFF(is, g, np);
} }
/*! /*!
@ -300,6 +300,18 @@ CGAL_DEPRECATED bool read_off(const char* fname, Graph& g, const CGAL_BGL_NP_CLA
return read_OFF(fname, g, np); return read_OFF(fname, g, np);
} }
template <typename Graph>
CGAL_DEPRECATED bool read_off(std::istream& is, Graph& g)
{
return read_off(is, g, parameters::all_default());
}
template <typename Graph>
CGAL_DEPRECATED bool read_off(const char* fname, Graph& g)
{
return read_off(fname, g, parameters::all_default());
}
#endif // CGAL_NO_DEPRECATED_CODE #endif // CGAL_NO_DEPRECATED_CODE
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
@ -374,7 +386,7 @@ bool write_OFF_BGL(std::ostream& os,
\cgalParamNBegin{stream_precision} \cgalParamNBegin{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int} \cgalParamType{int}
\cgalParamDefault{`6`} \cgalParamDefault{`the precision of the stream `os``}
\cgalParamNEnd \cgalParamNEnd
\cgalNamedParamsEnd \cgalNamedParamsEnd
@ -483,6 +495,7 @@ bool write_OFF(const std::string& fname,
std::cerr<<"Could not create file."; std::cerr<<"Could not create file.";
return false; return false;
} }
return write_OFF(os, g, np); return write_OFF(os, g, np);
} }
@ -510,6 +523,11 @@ CGAL_DEPRECATED bool write_off(std::ostream& os, const Graph& g, const CGAL_BGL_
return write_OFF(os, g, np); return write_OFF(os, g, np);
} }
template <typename Graph>
CGAL_DEPRECATED bool write_off(std::ostream& os, const Graph& g)
{
return write_off(os, g, CGAL::parameters::all_default());
}
/*! /*!
\ingroup PkgBGLIOFctDeprecated \ingroup PkgBGLIOFctDeprecated
@ -521,6 +539,11 @@ CGAL_DEPRECATED bool write_off(const char* fname, const Graph& g, const CGAL_BGL
return write_OFF(fname, g, np); return write_OFF(fname, g, np);
} }
template <typename Graph>
CGAL_DEPRECATED bool write_off(const char* fname, const Graph& g)
{
return write_off(fname, g, parameters::all_default());
}
#endif // CGAL_NO_DEPRECATED_CODE #endif // CGAL_NO_DEPRECATED_CODE
} // namespace CGAL } // namespace CGAL

View File

@ -311,7 +311,7 @@ bool read_PLY(const std::string& fname, Graph& g,
\cgalParamNBegin{stream_precision} \cgalParamNBegin{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int} \cgalParamType{int}
\cgalParamDefault{`6`} \cgalParamDefault{`the precision of the stream `os``}
\cgalParamExtra{This parameter is only meaningful while using ASCII encoding.} \cgalParamExtra{This parameter is only meaningful while using ASCII encoding.}
\cgalParamNEnd \cgalParamNEnd
\cgalNamedParamsEnd \cgalNamedParamsEnd
@ -361,8 +361,7 @@ bool write_PLY(std::ostream& os,
if(!os.good()) if(!os.good())
return false; return false;
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6); set_stream_precision_from_NP(os, np);
os.precision(precision);
// Write header // Write header
os << "ply" << std::endl os << "ply" << std::endl
@ -550,6 +549,7 @@ bool write_PLY(const std::string& fname,
{ {
std::ofstream os(fname); std::ofstream os(fname);
CGAL::set_mode(os, CGAL::IO::ASCII); CGAL::set_mode(os, CGAL::IO::ASCII);
return write_PLY(os, g, comments, np); return write_PLY(os, g, comments, np);
} }
} }

View File

@ -231,7 +231,7 @@ bool read_STL(const std::string& fname, Graph& g) { return read_STL(fname, g, pa
\cgalParamNBegin{stream_precision} \cgalParamNBegin{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int} \cgalParamType{int}
\cgalParamDefault{`6`} \cgalParamDefault{`the precision of the stream `os``}
\cgalParamExtra{This parameter is only meaningful while using ASCII encoding.} \cgalParamExtra{This parameter is only meaningful while using ASCII encoding.}
\cgalParamNEnd \cgalParamNEnd
\cgalNamedParamsEnd \cgalNamedParamsEnd
@ -262,8 +262,7 @@ bool write_STL(std::ostream& os,
if(!os.good()) if(!os.good())
return false; return false;
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6); set_stream_precision_from_NP(os, np);
os.precision(precision);
if(get_mode(os) == IO::BINARY) if(get_mode(os) == IO::BINARY)
{ {
@ -372,6 +371,7 @@ bool write_STL(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS
{ {
std::ofstream os(fname); std::ofstream os(fname);
CGAL::set_mode(os, CGAL::IO::ASCII); CGAL::set_mode(os, CGAL::IO::ASCII);
return write_STL(os, g, np); return write_STL(os, g, np);
} }
} }

View File

@ -420,7 +420,7 @@ void write_polys_points(std::ostream& os,
* \cgalParamNBegin{stream_precision} * \cgalParamNBegin{stream_precision}
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} * \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
* \cgalParamType{int} * \cgalParamType{int}
* \cgalParamDefault{`6`} * \cgalParamDefault{`the precision of the stream `os``}
* \cgalParamNEnd * \cgalParamNEnd
* \cgalNamedParamsEnd * \cgalNamedParamsEnd
* *
@ -439,8 +439,7 @@ bool write_VTP(std::ostream& os,
if(!os.good()) if(!os.good())
return false; return false;
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6); set_stream_precision_from_NP(os, np);
os.precision(precision);
os << "<?xml version=\"1.0\"?>\n" os << "<?xml version=\"1.0\"?>\n"
<< "<VTKFile type=\"PolyData\" version=\"0.1\""; << "<VTKFile type=\"PolyData\" version=\"0.1\"";
@ -539,6 +538,7 @@ bool write_VTP(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS
} }
else else
os.open(fname); os.open(fname);
return write_VTP(os, g, np); return write_VTP(os, g, np);
} }
@ -564,6 +564,12 @@ CGAL_DEPRECATED bool write_vtp(std::ostream& os, const Graph& g, const CGAL_BGL_
return write_VTP(os, g, np); return write_VTP(os, g, np);
} }
template <typename Graph>
CGAL_DEPRECATED bool write_vtp(std::ostream& os, const Graph& g)
{
return write_vtp(os, g, parameters::all_default());
}
#endif // CGAL_NO_DEPRECATED_CODE #endif // CGAL_NO_DEPRECATED_CODE
} // namespace CGAL } // namespace CGAL

View File

@ -59,7 +59,7 @@ namespace CGAL {
\cgalParamNBegin{stream_precision} \cgalParamNBegin{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int} \cgalParamType{int}
\cgalParamDefault{`6`} \cgalParamDefault{`the precision of the stream `os``}
\cgalParamNEnd \cgalParamNEnd
\cgalNamedParamsEnd \cgalNamedParamsEnd
@ -70,7 +70,8 @@ bool write_WRL(std::ostream& os,
const Graph& g, const Graph& g,
const CGAL_BGL_NP_CLASS& np) const CGAL_BGL_NP_CLASS& np)
{ {
IO::internal::Generic_facegraph_printer<std::ostream, Graph, CGAL::File_writer_VRML_2> printer(os); CGAL::VRML_2_ostream vos(os);
IO::internal::Generic_facegraph_printer<CGAL::VRML_2_ostream, Graph, CGAL::File_writer_VRML_2> printer(vos);
return printer(g, np); return printer(g, np);
} }
@ -108,8 +109,8 @@ bool write_WRL(std::ostream& os,
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS> template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool write_WRL(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np) bool write_WRL(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np)
{ {
std::ifstream is(fname); std::ofstream os(fname);
return write_WRL(is, g, np); return write_WRL(os, g, np);
} }
template <typename Graph> template <typename Graph>
@ -130,6 +131,12 @@ CGAL_DEPRECATED bool write_wrl(std::ostream& os, const Graph& g, const CGAL_BGL_
return write_WRL(os, g, np); return write_WRL(os, g, np);
} }
template <typename Graph>
CGAL_DEPRECATED bool write_wrl(std::ostream& os, const Graph& g)
{
return write_wrl(os, g, parameters::all_default());
}
#endif // CGAL_NO_DEPRECATED_CODE #endif // CGAL_NO_DEPRECATED_CODE
} // namespace CGAL } // namespace CGAL

View File

@ -560,6 +560,21 @@ CGAL_DEF_GET_INITIALIZED_INDEX_MAP(face, typename boost::graph_traits<Graph>::fa
Alpha_expansion_boost_adjacency_list_tag Alpha_expansion_boost_adjacency_list_tag
>::type type; >::type type;
}; };
template<typename NP>
void set_stream_precision_from_NP(std::ostream& os, const NP& np)
{
using parameters::get_parameter;
using parameters::choose_parameter;
using parameters::is_default_parameter;
if(!is_default_parameter(get_parameter(np, internal_np::stream_precision)))
{
const int precision = choose_parameter<int>(get_parameter(np,
internal_np::stream_precision));
os.precision(precision);
}
}
} //namespace CGAL } //namespace CGAL

View File

@ -98,6 +98,8 @@ create_single_source_cgal_program(
create_single_source_cgal_program( "graph_traits_inheritance.cpp" ) create_single_source_cgal_program( "graph_traits_inheritance.cpp" )
create_single_source_cgal_program("test_deprecated_io.cpp")
if(OpenMesh_FOUND) if(OpenMesh_FOUND)
target_link_libraries(test_clear PRIVATE ${OPENMESH_LIBRARIES}) target_link_libraries(test_clear PRIVATE ${OPENMESH_LIBRARIES})
target_compile_definitions(test_clear PRIVATE -DCGAL_USE_OPENMESH) target_compile_definitions(test_clear PRIVATE -DCGAL_USE_OPENMESH)
@ -129,6 +131,8 @@ if (VTK_FOUND)
if(VTK_LIBRARIES) if(VTK_LIBRARIES)
target_link_libraries(test_bgl_read_write PRIVATE ${VTK_LIBRARIES}) target_link_libraries(test_bgl_read_write PRIVATE ${VTK_LIBRARIES})
target_compile_definitions(test_bgl_read_write PRIVATE -DCGAL_USE_VTK) target_compile_definitions(test_bgl_read_write PRIVATE -DCGAL_USE_VTK)
target_link_libraries(test_deprecated_io PRIVATE ${VTK_LIBRARIES})
target_compile_definitions(test_deprecated_io PRIVATE -DCGAL_USE_VTK)
else() else()
message(STATUS "Tests that use VTK will not be compiled.") message(STATUS "Tests that use VTK will not be compiled.")
endif() endif()

View File

@ -0,0 +1,58 @@
#include <CGAL/internal/disable_deprecation_warnings_and_errors.h>
#include <fstream>
#include <iostream>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/boost/graph/generators.h>
#include <CGAL/boost/graph/IO/OFF.h>
#include <CGAL/boost/graph/IO/VTK.h>
#include <CGAL/boost/graph/IO/WRL.h>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point_3;
typedef CGAL::Surface_mesh<Point_3> SM;
int main()
{
// OFF
SM sm_in, sm_out;
Point_3 p0(0,0,0), p1(1,0,0), p2(0,1,0);
CGAL::make_triangle(p0, p1, p2, sm_out);
bool ok = CGAL::write_off("tmp.off", sm_out);
assert(ok);
ok = CGAL::read_off("tmp.off", sm_in);
assert(ok);
assert(num_vertices(sm_in) == 3 && num_faces(sm_in) == 1);
sm_in.clear();
std::ofstream os("tmp.off");
ok = CGAL::write_off(os, sm_out);
assert(ok);
os.close();
std::ifstream is("tmp.off");
ok = CGAL::read_off(is, sm_in);
assert(ok);
assert(num_vertices(sm_in) == 3 && num_faces(sm_in) == 1);
is.close();
sm_in.clear();
#ifdef CGAL_USE_VTK
//vtk
os.open("tmp.vtp");
ok = CGAL::write_vtp(os, sm_out);
assert(ok);
os.close();
ok = CGAL::read_VTP("tmp.vtp", sm_in);
assert(ok);
assert(num_vertices(sm_in) == 3 && num_faces(sm_in) == 1);
sm_in.clear();
#endif
//wrl
os.open("tmp.wrl");
ok = CGAL::write_wrl(os, sm_out);
assert(ok);
os.close();
return EXIT_SUCCESS;
}

View File

@ -67,7 +67,7 @@ LC_CTYPE=en_US.UTF-8
18 * * * * $HOME/bin/dump_crontab 18 * * * * $HOME/bin/dump_crontab
# Docker check every hour # Docker check every hour
#0 * * * * docker inspect --format='{{json .State.Health.Status}}' cgal-mediawiki-docker_wiki_1 | grep -q '"healthy"' || docker logs cgal-mediawiki-docker_wiki_1 0 * * * * docker inspect --format='{{json .State.Health.Status}}' cgal-mediawiki-docker_wiki_1 | grep -q '"healthy"' || docker logs cgal-mediawiki-docker_wiki_1
# cgal->cgal2 with git-multimail # cgal->cgal2 with git-multimail
*/5 * * * * cd $HOME/Git/cgal-dev-pusher.git && $HOME/bin/git-fetch-and-push-to-multimail cgal-dev cgal-dev-receiver */5 * * * * cd $HOME/Git/cgal-dev-pusher.git && $HOME/bin/git-fetch-and-push-to-multimail cgal-dev cgal-dev-receiver

View File

@ -134,7 +134,7 @@ CGAL_DEPRECATED bool read_off_point_set(std::istream& is, ///< input stream.
\cgalParamNBegin{stream_precision} \cgalParamNBegin{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int} \cgalParamType{int}
\cgalParamDefault{`6`} \cgalParamDefault{`the precision of the stream `os``}
\cgalParamNEnd \cgalParamNEnd
\cgalNamedParamsEnd \cgalNamedParamsEnd

View File

@ -456,7 +456,7 @@ CGAL_DEPRECATED bool read_ply_point_set(std::istream& is, ///< input stream.
\cgalParamNBegin{stream_precision} \cgalParamNBegin{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int} \cgalParamType{int}
\cgalParamDefault{`6`} \cgalParamDefault{`the precision of the stream `os``}
\cgalParamExtra{This parameter is only meaningful while using ASCII encoding.} \cgalParamExtra{This parameter is only meaningful while using ASCII encoding.}
\cgalParamNEnd \cgalParamNEnd
\cgalNamedParamsEnd \cgalNamedParamsEnd
@ -493,8 +493,7 @@ bool write_PLY(std::ostream& os,
return false; return false;
} }
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6); set_stream_precision_from_NP(os, np);
os.precision(precision);
os << "ply" << std::endl os << "ply" << std::endl
<< ((get_mode(os) == IO::BINARY) ? "format binary_little_endian 1.0" : "format ascii 1.0") << std::endl << ((get_mode(os) == IO::BINARY) ? "format binary_little_endian 1.0" : "format ascii 1.0") << std::endl

View File

@ -132,7 +132,7 @@ CGAL_DEPRECATED bool read_xyz_point_set(std::istream& is, CGAL::Point_set_3<Poin
\cgalParamNBegin{stream_precision} \cgalParamNBegin{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int} \cgalParamType{int}
\cgalParamDefault{`6`} \cgalParamDefault{`the precision of the stream `os``}
\cgalParamNEnd \cgalParamNEnd
\cgalNamedParamsEnd \cgalNamedParamsEnd

View File

@ -28,3 +28,18 @@ endif()
create_single_source_cgal_program("point_set_test.cpp") create_single_source_cgal_program("point_set_test.cpp")
create_single_source_cgal_program("point_set_test_join.cpp") create_single_source_cgal_program("point_set_test_join.cpp")
create_single_source_cgal_program("test_deprecated_io_ps.cpp")
#Use LAS
#disable if MSVC 2017
if(NOT MSVC_VERSION OR (MSVC_VERSION GREATER_EQUAL 1919 AND MSVC_VERSION LESS 1910))
find_package(LASLIB)
include(CGAL_LASLIB_support)
if (TARGET CGAL::LASLIB_support)
target_link_libraries(test_deprecated_io_ps PUBLIC CGAL::LASLIB_support)
else()
message(STATUS "NOTICE : the LAS reader test requires LASlib and will not be compiled.")
endif()
else()
message(STATUS "NOTICE : the LAS reader does not work with Visual Studio 2017.")
endif()

View File

@ -0,0 +1,82 @@
#include <CGAL/internal/disable_deprecation_warnings_and_errors.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Point_set_3.h>
#include <CGAL/Point_set_3/IO/LAS.h>
#include <CGAL/Point_set_3/IO/OFF.h>
#include <CGAL/Point_set_3/IO/PLY.h>
#include <iostream>
#include <fstream>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point_3;
typedef Kernel::Vector_3 Vector_3;
int main()
{
CGAL::Point_set_3<Point_3, Vector_3> ps, ps2;
std::ifstream is("data/oni.pwn");
std::ofstream os;
if(!CGAL::read_xyz_point_set(is, ps))
{
std::cerr<<"Error while reading input."<<std::endl;
return EXIT_FAILURE;
}
is.close();
bool ok = false;
#ifdef CGAL_LINKED_WITH_LASLIB
//LAS
os.open("tmp.las", std::ios::binary);
ok = CGAL::write_las_point_set(os, ps);
os.close();
assert (ok);
is.open("tmp.las", std::ios::binary);
ok = CGAL::read_las_point_set(is, ps2);
is.close();
assert(ok);
ps2.clear();
#endif
//OFF
os.open("tmp.off", std::ios::binary);
ok = CGAL::write_off_point_set(os, ps);
os.close();
assert (ok);
is.open("tmp.off", std::ios::binary);
ok = CGAL::read_off_point_set(is, ps2);
is.close();
assert(ok);
ps2.clear();
//PLY
os.open("tmp.ply", std::ios::binary);
ok = CGAL::write_ply_point_set(os, ps);
os.close();
assert (ok);
is.open("tmp.ply", std::ios::binary);
ok = CGAL::read_ply_point_set(is, ps2);
is.close();
assert(ok);
ps2.clear();
//XYZ
os.open("tmp.xyz", std::ios::binary);
ok = CGAL::write_xyz_point_set(os, ps);
os.close();
assert (ok);
is.open("tmp.xyz", std::ios::binary);
ok = CGAL::read_xyz_point_set(is, ps2);
is.close();
assert(ok);
ps2.clear();
return EXIT_SUCCESS;
}

View File

@ -66,8 +66,7 @@ bool write_OFF_PSP(std::ostream& os,
return false; return false;
} }
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6); set_stream_precision_from_NP(os, np);
os.precision(precision);
// Write header // Write header
os << "NOFF" << std::endl; os << "NOFF" << std::endl;
@ -125,7 +124,7 @@ bool write_OFF_PSP(std::ostream& os,
\cgalParamNBegin{stream_precision} \cgalParamNBegin{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int} \cgalParamType{int}
\cgalParamDefault{`6`} \cgalParamDefault{`the precision of the stream `os``}
\cgalParamNEnd \cgalParamNEnd
\cgalNamedParamsEnd \cgalNamedParamsEnd
@ -208,6 +207,7 @@ bool write_OFF(const std::string& filename,
) )
{ {
std::ofstream os(filename); std::ofstream os(filename);
set_stream_precision_from_NP(os, np);
return write_OFF(os, points, np); return write_OFF(os, points, np);
} }

View File

@ -175,7 +175,7 @@ template <typename PointRange,
\cgalParamNBegin{stream_precision} \cgalParamNBegin{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int} \cgalParamType{int}
\cgalParamDefault{`6`} \cgalParamDefault{`the precision of the stream `os``}
\cgalParamExtra{This parameter is only meaningful while using ASCII encoding.} \cgalParamExtra{This parameter is only meaningful while using ASCII encoding.}
\cgalParamNEnd \cgalParamNEnd
\cgalNamedParamsEnd \cgalNamedParamsEnd
@ -212,8 +212,7 @@ bool write_PLY(std::ostream& os,
return false; return false;
} }
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6); set_stream_precision_from_NP(os, np);
os.precision(precision);
if (has_normals) if (has_normals)
return write_PLY_with_properties(os, points, return write_PLY_with_properties(os, points,

View File

@ -67,8 +67,7 @@ bool write_XYZ_PSP(std::ostream& os,
return false; return false;
} }
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6); set_stream_precision_from_NP(os, np);
os.precision(precision);
// Write positions + normals // Write positions + normals
for(typename PointRange::const_iterator it = points.begin(); it != points.end(); it++) for(typename PointRange::const_iterator it = points.begin(); it != points.end(); it++)
@ -122,7 +121,7 @@ bool write_XYZ_PSP(std::ostream& os,
\cgalParamNBegin{stream_precision} \cgalParamNBegin{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int} \cgalParamType{int}
\cgalParamDefault{`6`} \cgalParamDefault{`the precision of the stream `os``}
\cgalParamNEnd \cgalParamNEnd
\cgalNamedParamsEnd \cgalNamedParamsEnd

View File

@ -28,6 +28,7 @@ include(CGAL_TBB_support)
# Executables that do *not* require Eigen # Executables that do *not* require Eigen
create_single_source_cgal_program( "read_test.cpp" ) create_single_source_cgal_program( "read_test.cpp" )
create_single_source_cgal_program( "test_read_write_point_set.cpp" ) create_single_source_cgal_program( "test_read_write_point_set.cpp" )
create_single_source_cgal_program( "test_deprecated_io_point_set.cpp" )
create_single_source_cgal_program( "read_test_with_different_pmaps.cpp" ) create_single_source_cgal_program( "read_test_with_different_pmaps.cpp" )
create_single_source_cgal_program( "analysis_test.cpp" ) create_single_source_cgal_program( "analysis_test.cpp" )
create_single_source_cgal_program( "remove_outliers_test.cpp" ) create_single_source_cgal_program( "remove_outliers_test.cpp" )
@ -43,6 +44,7 @@ if(NOT MSVC_VERSION OR (MSVC_VERSION GREATER_EQUAL 1919 AND MSVC_VERSION LESS 1
include(CGAL_LASLIB_support) include(CGAL_LASLIB_support)
if (TARGET CGAL::LASLIB_support) if (TARGET CGAL::LASLIB_support)
target_link_libraries(test_read_write_point_set PUBLIC ${CGAL_libs} CGAL::LASLIB_support) target_link_libraries(test_read_write_point_set PUBLIC ${CGAL_libs} CGAL::LASLIB_support)
target_link_libraries(test_deprecated_io_point_set PUBLIC ${CGAL_libs} CGAL::LASLIB_support)
else() else()
message(STATUS "NOTICE : the LAS reader test requires LASlib and will not be compiled.") message(STATUS "NOTICE : the LAS reader test requires LASlib and will not be compiled.")
endif() endif()

View File

@ -0,0 +1,192 @@
#include <CGAL/internal/disable_deprecation_warnings_and_errors.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Point_set_3.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/IO/write_points.h>
// Just to try and create ambiguities
#include <CGAL/boost/graph/io.h>
#include <CGAL/IO/io.h>
#include <CGAL/property_map.h>
#include <vector>
#include <cassert>
#include <string>
#include <fstream>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point_3;
typedef Kernel::Vector_3 Vector_3;
typedef std::array<unsigned short, 4> Color;
typedef std::pair<Point_3, Color> PointWithColor;
typedef CGAL::Nth_of_tuple_property_map<1, PointWithColor> Color_map;
struct GetRedMap{
typedef PointWithColor key_type;
typedef unsigned short value_type;
typedef const value_type& reference;
typedef boost::lvalue_property_map_tag category;
};
unsigned short get(const GetRedMap&, const PointWithColor& p)
{
return p.second[0];
}
struct GetGreenMap{
typedef PointWithColor key_type;
typedef unsigned short value_type;
typedef const value_type& reference;
typedef boost::lvalue_property_map_tag category;
};
unsigned short get(const GetGreenMap&, const PointWithColor& p)
{
return p.second[1];
}
struct GetBlueMap{
typedef PointWithColor key_type;
typedef unsigned short value_type;
typedef const value_type& reference;
typedef boost::lvalue_property_map_tag category;
};
unsigned short get(const GetBlueMap&, const PointWithColor& p)
{
return p.second[2];
}
struct GetAlphaMap{
typedef PointWithColor key_type;
typedef unsigned short value_type;
typedef const value_type& reference;
typedef boost::lvalue_property_map_tag category;
};
unsigned short get(const GetAlphaMap&, const PointWithColor& p)
{
return p.second[3];
}
int main()
{
std::vector<PointWithColor> points(3);
points[0] = std::make_pair(Point_3(1,0,0), Color{255,0,0,255});
points[1] = std::make_pair(Point_3(0,1,0), Color{0,255,0,255});
points[2] = std::make_pair(Point_3(0,0,1), Color{0,0,255,255});
std::ofstream os;
std::ifstream is;
bool ok;
std::vector<Point_3> ps;
ps.push_back(Point_3(1,0,0));
ps.push_back(Point_3(0,1,0));
ps.push_back(Point_3(0,0,1));
//LAS
#ifdef CGAL_LINKED_WITH_LASLIB
os.open("tmp.las", std::ios::binary);
ok = CGAL::write_las_points_with_properties(os, points,
CGAL::make_las_point_writer(CGAL::First_of_pair_property_map<PointWithColor>()),
std::make_pair(GetRedMap(),CGAL::LAS_property::R()),
std::make_pair(GetGreenMap(), CGAL::LAS_property::G()),
std::make_pair(GetBlueMap(), CGAL::LAS_property::B()),
std::make_pair(GetAlphaMap(), CGAL::LAS_property::I())
);
os.close();
assert(ok);
points.clear();
is.open("tmp.las", std::ios::binary);
ok = CGAL::read_las_points_with_properties(is, 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>(),
CGAL::Construct_array(),
CGAL::LAS_property::R(),
CGAL::LAS_property::G(),
CGAL::LAS_property::B(),
CGAL::LAS_property::I()));
is.close();
assert(ok);
assert(points.size() == 3);
assert(points[1].second[1] == 255);
os.open("tmp.las", std::ios_base::binary);
CGAL::write_las_points(os, ps, CGAL::parameters::all_default());
os.close();
assert(ok);
ps.clear();
is.open("tmp.las", std::ios::binary);
ok = CGAL::read_las_points(is, std::back_inserter (ps),CGAL::parameters::all_default());
is.close();
assert(ok);
assert(ps.size() == 3);
#endif
//PLY
os.open("tmp.ply");
ok = CGAL::write_ply_points_with_properties(os, points,
CGAL::make_ply_point_writer (CGAL::First_of_pair_property_map<PointWithColor>()),
std::make_pair(GetRedMap(),CGAL::PLY_property<unsigned short>("red")),
std::make_pair(GetGreenMap(), CGAL::PLY_property<unsigned short>("green")),
std::make_pair(GetBlueMap(), CGAL::PLY_property<unsigned short>("blue")),
std::make_pair(GetAlphaMap(), CGAL::PLY_property<unsigned short>("alpha"))
);
os.close();
assert(ok);
is.open("tmp.ply");
points.clear();
ok = CGAL::read_ply_points_with_properties(is, std::back_inserter (points),
CGAL::make_ply_point_reader(CGAL::First_of_pair_property_map<PointWithColor>()),
std::make_tuple(CGAL::Second_of_pair_property_map<PointWithColor>(),
CGAL::Construct_array(),
CGAL::PLY_property<unsigned short>("red"),
CGAL::PLY_property<unsigned short>("green"),
CGAL::PLY_property<unsigned short>("blue"),
CGAL::PLY_property<unsigned short>("alpha")));
is.close();
assert(ok);
assert(points.size() == 3);
assert(points[1].second[1] == 255);
os.open("tmp.ply");
ok = CGAL::write_ply_points(os, ps, CGAL::parameters::all_default());
os.close();
assert(ok);
is.open("tmp.ply");
ps.clear();
ok = CGAL::read_ply_points(is, std::back_inserter (ps),
CGAL::parameters::all_default());
is.close();
assert(ok);
assert(ps.size() == 3);
//OFF
os.open("tmp.off");
ok = CGAL::write_off_points(os, ps, CGAL::parameters::all_default());
os.close();
assert(ok);
is.open("tmp.off");
ps.clear();
ok = CGAL::read_off_points(is, std::back_inserter (ps),
CGAL::parameters::all_default());
is.close();
assert(ok);
assert(ps.size() == 3);
//XYZ
os.open("tmp.xyz");
ok = CGAL::write_xyz_points(os, ps, CGAL::parameters::all_default());
os.close();
assert(ok);
is.open("tmp.xyz");
ps.clear();
ok = CGAL::read_xyz_points(is, std::back_inserter (ps),
CGAL::parameters::all_default());
is.close();
assert(ok);
assert(ps.size() == 3);
}

View File

@ -299,8 +299,7 @@ bool write_GOCAD(std::ostream& os,
set_ascii_mode(os); // GOCAD is ASCII only set_ascii_mode(os); // GOCAD is ASCII only
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6); set_stream_precision_from_NP(os, np);
os.precision(precision);
os << "GOCAD TSurf 1\n" os << "GOCAD TSurf 1\n"
"HEADER {\n" "HEADER {\n"
@ -357,7 +356,7 @@ bool write_GOCAD(std::ostream& os,
* \cgalParamNBegin{stream_precision} * \cgalParamNBegin{stream_precision}
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} * \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
* \cgalParamType{int} * \cgalParamType{int}
* \cgalParamDefault{`6`} * \cgalParamDefault{`the precision of the stream `os``}
* \cgalParamNEnd * \cgalParamNEnd
* \cgalNamedParamsEnd * \cgalNamedParamsEnd
* *

View File

@ -49,8 +49,7 @@ public:
if(!m_os.good()) if(!m_os.good())
return false; return false;
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6); set_stream_precision_from_NP(m_os, np);
m_os.precision(precision);
m_writer.write_header(m_os, points.size(), 0, polygons.size()); m_writer.write_header(m_os, points.size(), 0, polygons.size());
for(std::size_t i=0, end=points.size(); i<end; ++i) for(std::size_t i=0, end=points.size(); i<end; ++i)

View File

@ -23,6 +23,7 @@
#include <boost/range/value_type.hpp> #include <boost/range/value_type.hpp>
#include <boost/utility/enable_if.hpp> #include <boost/utility/enable_if.hpp>
#include <CGAL/boost/graph/Named_function_parameters.h>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
@ -158,9 +159,9 @@ bool read_OBJ(std::istream& is,
} }
if(norm_found && verbose) if(norm_found && verbose)
std::cout<<"WARNING: normals were found in this file, but were discarded."<<std::endl; std::cout<<"NOTE: normals were found in this file, but were discarded."<<std::endl;
if(tex_found && verbose) if(tex_found && verbose)
std::cout<<"WARNING: textures were found in this file, but were discarded."<<std::endl; std::cout<<"NOTE: textures were found in this file, but were discarded."<<std::endl;
if(points.empty() || polygons.empty()) if(points.empty() || polygons.empty())
{ {
@ -318,7 +319,7 @@ bool read_OBJ(const std::string& fname, PointRange& points, PolygonRange& polygo
* \cgalParamNBegin{stream_precision} * \cgalParamNBegin{stream_precision}
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} * \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
* \cgalParamType{int} * \cgalParamType{int}
* \cgalParamDefault{`6`} * \cgalParamDefault{`the precision of the stream `os``}
* \cgalParamNEnd * \cgalParamNEnd
* \cgalNamedParamsEnd * \cgalNamedParamsEnd
* *
@ -393,6 +394,7 @@ bool write_OBJ(const std::string& fname,
{ {
std::ofstream os(fname); std::ofstream os(fname);
CGAL::set_mode(os, CGAL::IO::ASCII); CGAL::set_mode(os, CGAL::IO::ASCII);
return write_OBJ(os, points, polygons, np); return write_OBJ(os, points, polygons, np);
} }

View File

@ -298,7 +298,7 @@ bool read_OFF(const std::string& fname, PointRange& points, PolygonRange& polygo
* \cgalParamNBegin{stream_precision} * \cgalParamNBegin{stream_precision}
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} * \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
* \cgalParamType{int} * \cgalParamType{int}
* \cgalParamDefault{`6`} * \cgalParamDefault{`the precision of the stream `os``}
* \cgalParamNEnd * \cgalParamNEnd
* \cgalNamedParamsEnd * \cgalNamedParamsEnd
* *

View File

@ -21,6 +21,7 @@
#include <CGAL/basic.h> #include <CGAL/basic.h>
#include <iostream> #include <iostream>
#include <CGAL/boost/graph/named_params_helper.h>
// OpenInventor and VRML 1.0 are quite similar formats, so // OpenInventor and VRML 1.0 are quite similar formats, so
// output operators could be shared if they use the following // output operators could be shared if they use the following
@ -89,6 +90,12 @@ private:
} }
}; };
template<typename NP>
void set_stream_precision_from_NP(Inventor_ostream_base& os, const NP& np)
{
return set_stream_precision_from_NP(os.os(), np);
}
} // namespace CGAL } // namespace CGAL
#endif // CGAL_IO_INVENTOR_OSTREAM_H #endif // CGAL_IO_INVENTOR_OSTREAM_H

View File

@ -17,6 +17,7 @@
#include <CGAL/IO/helpers.h> #include <CGAL/IO/helpers.h>
#include <CGAL/boost/graph/Named_function_parameters.h> #include <CGAL/boost/graph/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <CGAL/property_map.h> #include <CGAL/property_map.h>
#include <CGAL/iterator.h> #include <CGAL/iterator.h>
@ -444,7 +445,7 @@ bool read_PLY(const std::string& fname, PointRange& points, PolygonRange& polygo
* \cgalParamNBegin{stream_precision} * \cgalParamNBegin{stream_precision}
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} * \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
* \cgalParamType{int} * \cgalParamType{int}
* \cgalParamDefault{`6`} * \cgalParamDefault{`the precision of the stream `os``}
* \cgalParamExtra{This parameter is only meaningful while using ASCII encoding.} * \cgalParamExtra{This parameter is only meaningful while using ASCII encoding.}
* \cgalParamNEnd * \cgalParamNEnd
* \cgalNamedParamsEnd * \cgalNamedParamsEnd
@ -467,8 +468,7 @@ bool write_PLY(std::ostream& out,
if(!out.good()) if(!out.good())
return false; return false;
const int precision = parameters::choose_parameter(parameters::get_parameter(np, internal_np::stream_precision), 6); set_stream_precision_from_NP(out, np);
out.precision(precision);
// Write header // Write header
out << "ply" << std::endl out << "ply" << std::endl

View File

@ -284,7 +284,7 @@ bool read_STL(const std::string& fname, PointRange& points, TriangleRange& facet
* \cgalParamNBegin{stream_precision} * \cgalParamNBegin{stream_precision}
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} * \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
* \cgalParamType{int} * \cgalParamType{int}
* \cgalParamDefault{`6`} * \cgalParamDefault{`the precision of the stream `os``}
* \cgalParamExtra{This parameter is only meaningful while using ASCII encoding.} * \cgalParamExtra{This parameter is only meaningful while using ASCII encoding.}
* \cgalParamNEnd * \cgalParamNEnd
* \cgalNamedParamsEnd * \cgalNamedParamsEnd
@ -317,8 +317,7 @@ bool write_STL(std::ostream& os,
if(!os.good()) if(!os.good())
return false; return false;
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6); set_stream_precision_from_NP(os, np);
os.precision(precision);
if(get_mode(os) == IO::BINARY) if(get_mode(os) == IO::BINARY)
{ {

View File

@ -21,6 +21,7 @@
#include <CGAL/basic.h> #include <CGAL/basic.h>
#include <iostream> #include <iostream>
#include <CGAL/boost/graph/named_params_helper.h>
namespace CGAL { namespace CGAL {
@ -104,6 +105,11 @@ inline VRML_2_ostream& operator<<(VRML_2_ostream& os,
return os; return os;
} }
template<typename NP>
void set_stream_precision_from_NP(VRML_2_ostream& os, const NP& np)
{
return set_stream_precision_from_NP(os.os(), np);
}
} // namespace CGAL } // namespace CGAL
#endif // CGAL_IO_VRML_2_OSTREAM_H #endif // CGAL_IO_VRML_2_OSTREAM_H
@ -315,4 +321,5 @@ operator<<(VRML_2_ostream& os,
} //namespace CGAL } //namespace CGAL
#endif // CGAL_IO_VRML_VRML_2_SEGMENT_3 #endif // CGAL_IO_VRML_VRML_2_SEGMENT_3
#endif // CGAL_SPHERE_3_H #endif // CGAL_SPHERE_3_H

View File

@ -19,6 +19,7 @@
#include <CGAL/IO/VTK/VTK_writer.h> #include <CGAL/IO/VTK/VTK_writer.h>
#include <CGAL/boost/graph/Named_function_parameters.h> #include <CGAL/boost/graph/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#ifdef CGAL_USE_VTK #ifdef CGAL_USE_VTK
#include <vtkSmartPointer.h> #include <vtkSmartPointer.h>
@ -373,7 +374,7 @@ void write_soup_polys_points(std::ostream& os,
* \cgalParamNBegin{stream_precision} * \cgalParamNBegin{stream_precision}
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} * \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
* \cgalParamType{int} * \cgalParamType{int}
* \cgalParamDefault{`6`} * \cgalParamDefault{`the precision of the stream `os``}
* \cgalParamNEnd * \cgalParamNEnd
* \cgalNamedParamsEnd * \cgalNamedParamsEnd
* *
@ -393,8 +394,7 @@ bool write_VTP(std::ostream& os,
if(!os.good()) if(!os.good())
return false; return false;
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6); set_stream_precision_from_NP(os, np);
os.precision(precision);
os << "<?xml version=\"1.0\"?>\n" os << "<?xml version=\"1.0\"?>\n"
<< "<VTKFile type=\"PolyData\" version=\"0.1\""; << "<VTKFile type=\"PolyData\" version=\"0.1\"";

View File

@ -18,12 +18,9 @@
#include <CGAL/IO/3MF.h> #include <CGAL/IO/3MF.h>
#include <CGAL/IO/OBJ.h> #include <CGAL/IO/OBJ.h>
#include <CGAL/IO/OFF.h> #include <CGAL/IO/OFF.h>
// #include <CGAL/IO/OI.h>
#include <CGAL/IO/PLY.h> #include <CGAL/IO/PLY.h>
#include <CGAL/IO/STL.h> #include <CGAL/IO/STL.h>
// #include <CGAL/IO/VRML.h>
#include <CGAL/IO/VTK.h> #include <CGAL/IO/VTK.h>
// #include <CGAL/IO/WKT.h>
#include <CGAL/IO/GOCAD.h> #include <CGAL/IO/GOCAD.h>
#include <algorithm> #include <algorithm>

View File

@ -556,7 +556,7 @@ bool write_OFF_with_or_without_vnormals(std::ostream& os,
/// \cgalParamNBegin{stream_precision} /// \cgalParamNBegin{stream_precision}
/// \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} /// \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
/// \cgalParamType{int} /// \cgalParamType{int}
/// \cgalParamDefault{`6`} /// \cgalParamDefault{`the precision of the stream `os``}
/// \cgalParamNEnd /// \cgalParamNEnd
/// \cgalNamedParamsEnd /// \cgalNamedParamsEnd
/// ///

View File

@ -899,7 +899,7 @@ CGAL_DEPRECATED bool read_ply(std::istream& is, Surface_mesh<P>& sm, std::string
/// \cgalParamNBegin{stream_precision} /// \cgalParamNBegin{stream_precision}
/// \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream} /// \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
/// \cgalParamType{int} /// \cgalParamType{int}
/// \cgalParamDefault{`6`} /// \cgalParamDefault{`the precision of the stream `os``}
/// \cgalParamExtra{This parameter is only meaningful while using ASCII encoding.} /// \cgalParamExtra{This parameter is only meaningful while using ASCII encoding.}
/// \cgalParamNEnd /// \cgalParamNEnd
/// \cgalNamedParamsEnd /// \cgalNamedParamsEnd
@ -921,8 +921,7 @@ bool write_PLY(std::ostream& os,
if(!os.good()) if(!os.good())
return false; return false;
const int precision = parameters::choose_parameter(parameters::get_parameter(np, internal_np::stream_precision), 6); set_stream_precision_from_NP(os, np);
os.precision(precision);
os << "ply" << std::endl os << "ply" << std::endl
<< ((get_mode(os) == IO::BINARY) ? "format binary_little_endian 1.0" : "format ascii 1.0") << std::endl << ((get_mode(os) == IO::BINARY) ? "format binary_little_endian 1.0" : "format ascii 1.0") << std::endl

View File

@ -14,3 +14,16 @@ file(
foreach(cppfile ${cppfiles}) foreach(cppfile ${cppfiles})
create_single_source_cgal_program("${cppfile}") create_single_source_cgal_program("${cppfile}")
endforeach() endforeach()
find_path(3MF_INCLUDE_DIR
NAMES Model/COM/NMR_DLLInterfaces.h
DOC "Path to lib3MF headers"
)
find_library(3MF_LIBRARIES NAMES 3MF DOC "Path to the lib3MF library")
if(3MF_LIBRARIES AND 3MF_INCLUDE_DIR AND EXISTS "${3MF_INCLUDE_DIR}/Model/COM/NMR_DLLInterfaces.h")
include_directories(${3MF_INCLUDE_DIR})
target_link_libraries(test_deprecated_io_sm PRIVATE ${3MF_LIBRARIES})
target_compile_definitions(test_deprecated_io_sm PRIVATE -DCGAL_LINKED_WITH_3MF)
else()
message(STATUS "NOTICE : read_3mf requires the lib3MF library, and will not be tested.")
endif()

Binary file not shown.

View File

@ -0,0 +1,70 @@
#include <CGAL/internal/disable_deprecation_warnings_and_errors.h>
#include <fstream>
#include <iostream>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/boost/graph/generators.h>
#include <CGAL/Surface_mesh/IO/3MF.h>
#include <CGAL/Surface_mesh/IO/OFF.h>
#include <CGAL/Surface_mesh/IO/PLY.h>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point_3;
typedef CGAL::Surface_mesh<Point_3> SM;
int main()
{
// OFF
SM sm_in, sm_out;
Point_3 p0(0,0,0), p1(1,0,0), p2(0,1,0);
CGAL::make_triangle(p0, p1, p2, sm_out);
bool ok = CGAL::write_off(sm_out, "tmp.off");
assert(ok);
ok = CGAL::read_off(sm_in, "tmp.off");
assert(ok);
assert(num_vertices(sm_in) == 3 && num_faces(sm_in) == 1);
sm_in.clear();
std::ofstream os("tmp.off");
ok = CGAL::write_off(os, sm_out);
assert(ok);
os.close();
std::ifstream is("tmp.off");
ok = CGAL::read_off(is, sm_in);
assert(ok);
assert(num_vertices(sm_in) == 3 && num_faces(sm_in) == 1);
is.close();
sm_in.clear();
//PLY
os.open("tmp.ply");
std::string comments;
ok = CGAL::write_ply(os, sm_out, comments);
assert(ok);
os.close();
is.open("tmp.ply");
ok = CGAL::read_ply(is, sm_in, comments);
assert(ok);
assert(num_vertices(sm_in) == 3 && num_faces(sm_in) == 1);
is.close();
sm_in.clear();
#ifdef CGAL_LINKED_WITH_3MF
// 3mf
std::vector<SM> output_3mf;
ok = CGAL::read_3mf("test.3mf", output_3mf);
assert(ok);
assert(output_3mf.size() == 2);
sm_in.clear();
#endif
//others
ok = CGAL::write_mesh(sm_out, "tmp.off");
assert(ok);
ok = CGAL::read_mesh(sm_in, "tmp.ply");
assert(ok);
assert(num_vertices(sm_in) == 3 && num_faces(sm_in) == 1);
sm_in.clear();
return EXIT_SUCCESS;
}