mirror of https://github.com/CGAL/cgal
Misc IO improvements / fixes
This commit is contained in:
parent
0be78575ce
commit
71413eb8e8
|
|
@ -25,6 +25,7 @@
|
|||
#include <CGAL/boost/graph/Named_function_parameters.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
|
|
|||
|
|
@ -32,10 +32,9 @@ namespace CGAL {
|
|||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Read
|
||||
|
||||
|
||||
template<typename PointRanges, typename PolygonRanges, typename ColorRanges,
|
||||
typename PointRange, typename PolygonRange, typename ColorRange>
|
||||
int read_from_3mf(const std::string& file_name,
|
||||
int read_from_3mf(const std::string& fname,
|
||||
PointRanges& all_points,
|
||||
PolygonRanges& all_polygons,
|
||||
ColorRanges& all_colors,
|
||||
|
|
@ -80,7 +79,7 @@ int read_from_3mf(const std::string& file_name,
|
|||
}
|
||||
|
||||
// Import Model from File
|
||||
hResult = NMR::lib3mf_reader_readfromfileutf8(pReader, file_name.c_str());
|
||||
hResult = NMR::lib3mf_reader_readfromfileutf8(pReader, fname.c_str());
|
||||
if(hResult != LIB3MF_OK)
|
||||
{
|
||||
std::cerr << "could not parse file: " << std::hex << hResult << std::endl;
|
||||
|
|
@ -368,7 +367,6 @@ int read_from_3mf(const std::string& file_name,
|
|||
return all_points.size();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \ingroup IOstreamFunctions
|
||||
*
|
||||
|
|
@ -387,20 +385,20 @@ int read_from_3mf(const std::string& file_name,
|
|||
* a model of the concepts `RandomAccessContainer` and `BackInsertionSequence`
|
||||
* whose `value type` is `CGAL::Color`.
|
||||
*
|
||||
* \param file_name the name of the 3mf file to read.
|
||||
* \param all_points a `PointRanges` that will contain the points of the meshes in `file_name`.
|
||||
* \param fname the name of the 3mf file to read.
|
||||
* \param all_points a `PointRanges` that will contain the points of the meshes in `fname`.
|
||||
* Each of these meshes will add a range of its points.
|
||||
* \param all_polygons a `PolygonRanges` that will contain the triangles of the meshes in `file_name`.
|
||||
* \param all_polygons a `PolygonRanges` that will contain the triangles of the meshes in `fname`.
|
||||
* Each of these meshes will add a range of its triangles. A `triangle` of
|
||||
* `all_polygons[i]` contains the indices of its points in `all_points[i]`.
|
||||
* \param all_colors will contain the color of each triangle for each soup.
|
||||
* \param names will contain the name of each mesh in `file_name` if any.
|
||||
* \param names will contain the name of each mesh in `fname` if any.
|
||||
* If the i'th mesh has no name, it will be called "Unknown Mesh" in names.
|
||||
*
|
||||
* \return the number of soups read.
|
||||
*/
|
||||
template<typename PointRanges, typename PolygonRanges, typename ColorRanges>
|
||||
int read_triangle_soups_from_3mf(const std::string& file_name,
|
||||
int read_triangle_soups_from_3mf(const std::string& fname,
|
||||
PointRanges& all_points,
|
||||
PolygonRanges& all_polygons,
|
||||
ColorRanges& all_colors,
|
||||
|
|
@ -411,9 +409,10 @@ int read_triangle_soups_from_3mf(const std::string& file_name,
|
|||
typedef typename ColorRanges::value_type ColorRange;
|
||||
return read_from_3mf<PointRanges,PolygonRanges,ColorRanges,
|
||||
PointRange, PolygonRange, ColorRange>
|
||||
(file_name, all_points, all_polygons, all_colors, names,
|
||||
(fname, all_points, all_polygons, all_colors, names,
|
||||
extract_soups<PointRange, PolygonRange, ColorRange>);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Write
|
||||
|
|
@ -422,7 +421,7 @@ int read_triangle_soups_from_3mf(const std::string& file_name,
|
|||
* \ingroup IOstreamFunctions
|
||||
*
|
||||
* \brief writes the triangle soups contained in `all_points` and
|
||||
* `all_polygons` into the 3mf file `file_name`.
|
||||
* `all_polygons` into the 3mf file `fname`.
|
||||
*
|
||||
* \tparam PointRanges a model of the concepts `RandomAccessContainer` and
|
||||
* `BackInsertionSequence` whose `value type` is
|
||||
|
|
@ -433,15 +432,15 @@ int read_triangle_soups_from_3mf(const std::string& file_name,
|
|||
* whose `value_type` is a model of the concept `RandomAccessContainer` whose
|
||||
* `value_type` is std::size_t.
|
||||
*
|
||||
* \param file_name the name of the 3mf file to write.
|
||||
* \param fname the name of the 3mf file to write.
|
||||
* \param all_points a `PointRanges` that contains the points of the soups to write.
|
||||
* \param all_polygons a `PolygonRanges` that contains the triangles of the soups in `file_name`.
|
||||
* \param names will contains the name of each mesh in `file_name`.
|
||||
* \param all_polygons a `PolygonRanges` that contains the triangles of the soups in `fname`.
|
||||
* \param names contains the name of each mesh to be output.
|
||||
*
|
||||
* \return `true` if the writing is successful, `false` otherwise.
|
||||
*/
|
||||
template<typename PointRanges, typename PolygonRanges>
|
||||
bool write_triangle_soups_to_3mf(const std::string& file_name,
|
||||
bool write_triangle_soups_to_3mf(const std::string& fname,
|
||||
const PointRanges& all_points,
|
||||
const PolygonRanges& all_polygons,
|
||||
const std::vector<std::string>& names)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
#include <CGAL/assertions.h>
|
||||
#include <CGAL/boost/graph/Named_function_parameters.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
#include <CGAL/IO/io.h>
|
||||
#include <CGAL/iterator.h>
|
||||
#include <CGAL/Kernel_traits.h>
|
||||
#include <CGAL/use.h>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
#ifndef CGAL_IO_GENERIC_WRITER_H
|
||||
#define CGAL_IO_GENERIC_WRITER_H
|
||||
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/boost/graph/Named_function_parameters.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
#include <CGAL/IO/Generic_writer.h>
|
||||
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <CGAL/IO/io.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
|
@ -149,19 +150,16 @@ bool read_OBJ(std::istream& is,
|
|||
}
|
||||
|
||||
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_OBJ(const char* fname,
|
||||
PointRange& points,
|
||||
PolygonRange& polygons,
|
||||
const CGAL_BGL_NP_CLASS& np,
|
||||
bool verbose = true)
|
||||
bool read_OBJ(const char* fname, PointRange& points, PolygonRange& polygons,
|
||||
const CGAL_BGL_NP_CLASS& np, bool verbose = true)
|
||||
{
|
||||
std::ifstream in(fname);
|
||||
return read_OBJ(in, points, polygons, np, verbose);
|
||||
}
|
||||
|
||||
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_OBJ(const std::string& fname, PointRange& points, PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np,
|
||||
bool verbose = true)
|
||||
bool read_OBJ(const std::string& fname, PointRange& points, PolygonRange& polygons,
|
||||
const CGAL_BGL_NP_CLASS& np, bool verbose = true)
|
||||
{
|
||||
return read_OBJ(fname.c_str(), points, polygons, np, verbose);
|
||||
}
|
||||
|
|
@ -216,6 +214,25 @@ bool write_OBJ(std::ostream& os,
|
|||
return writer(points, polygons);
|
||||
}
|
||||
|
||||
template <typename PointRange,
|
||||
typename PolygonRange,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_OBJ(const char* fname, const PointRange& points, const PolygonRange& polygons,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
std::ofstream out(fname);
|
||||
return write_OBJ(out, points, polygons, np);
|
||||
}
|
||||
|
||||
template <typename PointRange,
|
||||
typename PolygonRange,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_OBJ(const std::string& fname, const PointRange& points, const PolygonRange& polygons,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return write_OBJ(fname.c_str(), points, polygons, np);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup ObjIoFuncs
|
||||
*
|
||||
|
|
@ -223,27 +240,12 @@ bool write_OBJ(std::ostream& os,
|
|||
*
|
||||
* \see \ref IOStreamOBJ
|
||||
*/
|
||||
template <typename PointRange,
|
||||
typename PolygonRange>
|
||||
bool write_OBJ(std::ostream& os,
|
||||
const PointRange& points,
|
||||
const PolygonRange& polygons)
|
||||
template <typename PointRange, typename PolygonRange>
|
||||
bool write_OBJ(std::ostream& os, const PointRange& points, const PolygonRange& polygons)
|
||||
{
|
||||
return write_OBJ(os, points, polygons, parameters::all_default());
|
||||
}
|
||||
|
||||
template <typename PointRange,
|
||||
typename PolygonRange,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_OBJ(const char* fname,
|
||||
const PointRange& points,
|
||||
const PolygonRange& polygons,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
std::ofstream out(fname);
|
||||
return write_OBJ(out, points, polygons, np);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup ObjIoFuncs
|
||||
*
|
||||
|
|
@ -251,24 +253,10 @@ bool write_OBJ(const char* fname,
|
|||
*
|
||||
* \see \ref IOStreamOBJ
|
||||
*/
|
||||
template <typename PointRange,
|
||||
typename PolygonRange>
|
||||
bool write_OBJ(const char* fname,
|
||||
const PointRange& points,
|
||||
const PolygonRange& polygons)
|
||||
template <typename PointRange, typename PolygonRange>
|
||||
bool write_OBJ(const char* fname, const PointRange& points, const PolygonRange& polygons)
|
||||
{
|
||||
return write_OBJ(fname, points, polygons);
|
||||
}
|
||||
|
||||
template <typename PointRange,
|
||||
typename PolygonRange,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_OBJ(const std::string& fname,
|
||||
const PointRange& points,
|
||||
const PolygonRange& polygons,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return write_OBJ(fname.c_str(), points, polygons,np);
|
||||
return write_OBJ(fname, points, polygons, parameters::all_default());
|
||||
}
|
||||
|
||||
template <typename PointRange, typename PolygonRange>
|
||||
|
|
|
|||
|
|
@ -25,18 +25,18 @@ namespace CGAL {
|
|||
|
||||
class File_writer_wavefront
|
||||
{
|
||||
std::ostream* m_out;
|
||||
std::ostream* m_os;
|
||||
std::size_t m_facets;
|
||||
|
||||
public:
|
||||
std::ostream& out() const { return *m_out; }
|
||||
std::ostream& out() const { return *m_os; }
|
||||
|
||||
void write_header(std::ostream& o,
|
||||
std::size_t vertices,
|
||||
std::size_t halfedges,
|
||||
std::size_t facets)
|
||||
{
|
||||
m_out = &o;
|
||||
m_os = &o;
|
||||
m_facets = facets;
|
||||
|
||||
// Print header.
|
||||
|
|
|
|||
|
|
@ -52,13 +52,14 @@ bool read_OFF(std::istream& is,
|
|||
FaceColorOutputIterator fc_out,
|
||||
bool verbose = true)
|
||||
{
|
||||
CGAL_USE(verbose);
|
||||
typedef typename boost::range_value<PointRange>::type Point;
|
||||
typedef typename CGAL::Kernel_traits<Point>::Kernel Kernel;
|
||||
typedef typename Kernel::Point_2 Texture;
|
||||
typedef typename Kernel::Vector_3 Normal;
|
||||
typedef CGAL::Color Color;
|
||||
|
||||
CGAL_USE(verbose);
|
||||
|
||||
if(!is.good())
|
||||
return false;
|
||||
|
||||
|
|
@ -145,8 +146,7 @@ bool read_OFF(std::istream& is,
|
|||
}
|
||||
}
|
||||
|
||||
bool res = !is.fail();
|
||||
return res;
|
||||
return !is.fail();
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
|
@ -230,17 +230,6 @@ bool read_OFF(const std::string& fname, PointRange& points, PolygonRange& polygo
|
|||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Write
|
||||
|
||||
|
||||
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_OFF(std::ostream& os,
|
||||
const PointRange& points,
|
||||
const PolygonRange& polygons,
|
||||
const CGAL_BGL_NP_CLASS& )
|
||||
{
|
||||
Generic_writer<std::ostream, File_writer_OFF> writer(os);
|
||||
return writer(points, polygons);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup OffIoFuncs
|
||||
*
|
||||
|
|
@ -248,26 +237,14 @@ bool write_OFF(std::ostream& os,
|
|||
*
|
||||
* \see \ref IOStreamOFF
|
||||
*/
|
||||
template <typename PointRange, typename PolygonRange>
|
||||
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_OFF(std::ostream& os,
|
||||
const PointRange& points,
|
||||
const PolygonRange& polygons
|
||||
,typename boost::enable_if<
|
||||
typename boost::has_range_const_iterator<PolygonRange>::type
|
||||
>::type* =0)
|
||||
{
|
||||
return write_OFF(os, points, polygons, parameters::all_default());
|
||||
}
|
||||
|
||||
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_OFF(const char* fname,
|
||||
const PointRange& points,
|
||||
const PolygonRange& polygons,
|
||||
const CGAL_BGL_NP_CLASS&)
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
std::ofstream os(fname);
|
||||
Generic_writer<std::ostream, File_writer_OFF> writer(os);
|
||||
return writer(points, polygons);
|
||||
return writer(points, polygons, np);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -277,38 +254,53 @@ bool write_OFF(const char* fname,
|
|||
*
|
||||
* \see \ref IOStreamOFF
|
||||
*/
|
||||
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_OFF(const char* fname,
|
||||
const PointRange& points,
|
||||
const PolygonRange& polygons,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
std::ofstream os(fname);
|
||||
Generic_writer<std::ostream, File_writer_OFF> writer(os);
|
||||
return writer(points, polygons, np);
|
||||
}
|
||||
|
||||
template <typename PointRange, typename PolygonRange>
|
||||
bool write_OFF(std::ostream& os, const PointRange& points, const PolygonRange& polygons,
|
||||
typename boost::enable_if<
|
||||
typename boost::has_range_const_iterator<PolygonRange>::type
|
||||
>::type* =0)
|
||||
{
|
||||
return write_OFF(os, points, polygons, parameters::all_default());
|
||||
}
|
||||
|
||||
template <typename PointRange, typename PolygonRange>
|
||||
bool write_OFF(const char* fname,
|
||||
const PointRange& points,
|
||||
const PolygonRange& polygons
|
||||
,typename boost::enable_if<
|
||||
typename boost::has_range_const_iterator<PolygonRange>::type
|
||||
const PolygonRange& polygons,
|
||||
typename boost::enable_if<
|
||||
typename boost::has_range_const_iterator<PolygonRange>::type
|
||||
>::type* =0)
|
||||
{
|
||||
return write_OFF(fname, points, polygons, parameters::all_default());
|
||||
}
|
||||
|
||||
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_OFF(const std::string& fname,
|
||||
const PointRange& points,
|
||||
const PolygonRange& polygons,
|
||||
bool write_OFF(const std::string& fname, const PointRange& points, const PolygonRange& polygons,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return write_OFF(fname.c_str(), points, polygons, np);
|
||||
}
|
||||
|
||||
template <typename PointRange, typename PolygonRange>
|
||||
bool write_OFF(const std::string& fname,
|
||||
const PointRange& points,
|
||||
const PolygonRange& polygons
|
||||
,typename boost::enable_if<
|
||||
typename boost::has_range_const_iterator<PolygonRange>::type
|
||||
bool write_OFF(const std::string& fname, const PointRange& points, const PolygonRange& polygons,
|
||||
typename boost::enable_if<
|
||||
typename boost::has_range_const_iterator<PolygonRange>::type
|
||||
>::type* =0)
|
||||
{
|
||||
return write_OFF(fname, points, polygons, parameters::all_default());
|
||||
}
|
||||
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_IO_OFF_H
|
||||
|
|
|
|||
|
|
@ -271,6 +271,7 @@ public:
|
|||
std::cerr<<"error while reading vertex."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if(is_homogeneous())
|
||||
if(!(m_in >> iformat(w)))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,14 +27,14 @@ namespace CGAL {
|
|||
|
||||
class File_writer_OFF
|
||||
{
|
||||
std::ostream* m_out;
|
||||
std::ostream* m_os;
|
||||
File_header_OFF m_header;
|
||||
|
||||
public:
|
||||
File_writer_OFF(bool verbose = false) : m_header(verbose) {}
|
||||
File_writer_OFF(const File_header_OFF& h) : m_header(h) {}
|
||||
|
||||
std::ostream& out() { return *m_out; }
|
||||
std::ostream& out() { return *m_os; }
|
||||
File_header_OFF& header() { return m_header; }
|
||||
const File_header_OFF& header() const { return m_header; }
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ public:
|
|||
std::size_t facets,
|
||||
bool normals = false)
|
||||
{
|
||||
m_out = &os;
|
||||
m_os = &os;
|
||||
|
||||
m_header.set_vertices(vertices);
|
||||
m_header.set_facets(facets);
|
||||
|
|
|
|||
|
|
@ -25,19 +25,19 @@ namespace CGAL {
|
|||
|
||||
class File_writer_inventor
|
||||
{
|
||||
Inventor_ostream_base* m_out;
|
||||
Inventor_ostream_base* m_os;
|
||||
std::size_t m_facets;
|
||||
|
||||
public:
|
||||
File_writer_inventor() {}
|
||||
std::ostream& out() const { return m_out->os(); }
|
||||
std::ostream& out() const { return m_os->os(); }
|
||||
|
||||
void write_header(Inventor_ostream_base& o,
|
||||
std::size_t vertices,
|
||||
std::size_t halfedges,
|
||||
std::size_t facets)
|
||||
{
|
||||
m_out = &o;
|
||||
m_os = &o;
|
||||
m_facets = facets;
|
||||
|
||||
out() << "# " << vertices << " vertices\n";
|
||||
|
|
|
|||
|
|
@ -37,8 +37,9 @@ namespace CGAL {
|
|||
|
||||
namespace IO {
|
||||
namespace internal {
|
||||
//HEdgesRange" = range of std::pair<unsigned int, unsigned int>
|
||||
//HUVRange = range of std::pair<float, float>
|
||||
|
||||
// HEdgesRange" = range of std::pair<unsigned int, unsigned int>
|
||||
// HUVRange = range of std::pair<float, float>
|
||||
template <class PointRange, class PolygonRange, class ColorOutputIterator, class HEdgesOutputIterator, class HUVOutputIterator>
|
||||
bool read_PLY(std::istream& is,
|
||||
PointRange& points,
|
||||
|
|
@ -47,13 +48,14 @@ bool read_PLY(std::istream& is,
|
|||
ColorOutputIterator fc_out,
|
||||
ColorOutputIterator vc_out,
|
||||
HUVOutputIterator huvs_out,
|
||||
bool verbose = true,
|
||||
bool verbose = true,
|
||||
typename std::enable_if<
|
||||
CGAL::is_iterator<ColorOutputIterator>::value
|
||||
>::type* =0)
|
||||
{
|
||||
typedef typename PointRange::value_type Point_3;
|
||||
typedef CGAL::Color Color_rgb;
|
||||
|
||||
if(!is.good())
|
||||
{
|
||||
if(verbose)
|
||||
|
|
@ -69,7 +71,7 @@ bool read_PLY(std::istream& is,
|
|||
return false;
|
||||
}
|
||||
|
||||
for(std::size_t i = 0; i < reader.number_of_elements(); ++ i)
|
||||
for(std::size_t i=0; i<reader.number_of_elements(); ++i)
|
||||
{
|
||||
IO::internal::PLY_element& element = reader.element(i);
|
||||
|
||||
|
|
@ -77,20 +79,24 @@ bool read_PLY(std::istream& is,
|
|||
{
|
||||
bool has_colors = false;
|
||||
std::string rtag = "r", gtag = "g", btag = "b";
|
||||
|
||||
if((element.has_property<boost::uint8_t>("red") || element.has_property<boost::uint8_t>("r")) &&
|
||||
(element.has_property<boost::uint8_t>("green") || element.has_property<boost::uint8_t>("g")) &&
|
||||
(element.has_property<boost::uint8_t>("blue") || element.has_property<boost::uint8_t>("b")))
|
||||
{
|
||||
has_colors = true;
|
||||
|
||||
if(element.has_property<boost::uint8_t>("red"))
|
||||
{
|
||||
rtag = "red"; gtag = "green"; btag = "blue";
|
||||
rtag = "red";
|
||||
gtag = "green";
|
||||
btag = "blue";
|
||||
}
|
||||
}
|
||||
|
||||
for(std::size_t j = 0; j < element.number_of_items(); ++ j)
|
||||
for(std::size_t j=0; j<element.number_of_items(); ++j)
|
||||
{
|
||||
for(std::size_t k = 0; k < element.number_of_properties(); ++ k)
|
||||
for(std::size_t k=0; k<element.number_of_properties(); ++k)
|
||||
{
|
||||
IO::internal::PLY_read_number* property = element.property(k);
|
||||
property->get(is);
|
||||
|
|
@ -100,23 +106,24 @@ bool read_PLY(std::istream& is,
|
|||
}
|
||||
|
||||
std::tuple<Point_3, boost::uint8_t, boost::uint8_t, boost::uint8_t> new_vertex;
|
||||
|
||||
if(has_colors)
|
||||
{
|
||||
IO::internal::process_properties(element, new_vertex,
|
||||
make_ply_point_reader(CGAL::make_nth_of_tuple_property_map<0>(new_vertex)),
|
||||
std::make_pair(CGAL::make_nth_of_tuple_property_map<1>(new_vertex),
|
||||
PLY_property<boost::uint8_t>(rtag.c_str())),
|
||||
std::make_pair(CGAL::make_nth_of_tuple_property_map<2>(new_vertex),
|
||||
PLY_property<boost::uint8_t>(gtag.c_str())),
|
||||
std::make_pair(CGAL::make_nth_of_tuple_property_map<3>(new_vertex),
|
||||
PLY_property<boost::uint8_t>(btag.c_str())));
|
||||
make_ply_point_reader(CGAL::make_nth_of_tuple_property_map<0>(new_vertex)),
|
||||
std::make_pair(CGAL::make_nth_of_tuple_property_map<1>(new_vertex),
|
||||
PLY_property<boost::uint8_t>(rtag.c_str())),
|
||||
std::make_pair(CGAL::make_nth_of_tuple_property_map<2>(new_vertex),
|
||||
PLY_property<boost::uint8_t>(gtag.c_str())),
|
||||
std::make_pair(CGAL::make_nth_of_tuple_property_map<3>(new_vertex),
|
||||
PLY_property<boost::uint8_t>(btag.c_str())));
|
||||
|
||||
*vc_out++ = Color_rgb(get<1>(new_vertex), get<2>(new_vertex), get<3>(new_vertex));
|
||||
}
|
||||
else
|
||||
{
|
||||
IO::internal::process_properties(element, new_vertex,
|
||||
make_ply_point_reader(CGAL::make_nth_of_tuple_property_map<0>(new_vertex)));
|
||||
}
|
||||
|
||||
points.push_back(get<0>(new_vertex));
|
||||
}
|
||||
|
|
@ -124,13 +131,21 @@ bool read_PLY(std::istream& is,
|
|||
else if(element.name() == "face" || element.name() == "faces")
|
||||
{
|
||||
if(element.has_property<std::vector<boost::int32_t> >("vertex_indices"))
|
||||
{
|
||||
IO::internal::read_PLY_faces<boost::int32_t>(is, element, polygons, fc_out, "vertex_indices");
|
||||
}
|
||||
else if(element.has_property<std::vector<boost::uint32_t> >("vertex_indices"))
|
||||
{
|
||||
IO::internal::read_PLY_faces<boost::uint32_t>(is, element, polygons, fc_out, "vertex_indices");
|
||||
}
|
||||
else if(element.has_property<std::vector<boost::int32_t> >("vertex_index"))
|
||||
{
|
||||
IO::internal::read_PLY_faces<boost::int32_t>(is, element, polygons, fc_out, "vertex_index");
|
||||
}
|
||||
else if(element.has_property<std::vector<boost::uint32_t> >("vertex_index"))
|
||||
{
|
||||
IO::internal::read_PLY_faces<boost::uint32_t>(is, element, polygons, fc_out, "vertex_index");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(verbose)
|
||||
|
|
@ -142,18 +157,18 @@ bool read_PLY(std::istream& is,
|
|||
{
|
||||
bool has_uv = false;
|
||||
std::string stag = "source", ttag = "target", utag = "u", vtag = "v";
|
||||
if( element.has_property<unsigned int>("source") &&
|
||||
element.has_property<unsigned int>("target") &&
|
||||
element.has_property<float>("u") &&
|
||||
element.has_property<float>("v"))
|
||||
if(element.has_property<unsigned int>("source") &&
|
||||
element.has_property<unsigned int>("target") &&
|
||||
element.has_property<float>("u") &&
|
||||
element.has_property<float>("v"))
|
||||
{
|
||||
has_uv = true;
|
||||
}
|
||||
|
||||
cpp11::tuple<unsigned int, unsigned int, float, float, float> new_hedge;
|
||||
for(std::size_t j = 0; j < element.number_of_items(); ++ j)
|
||||
std::tuple<unsigned int, unsigned int, float, float, float> new_hedge;
|
||||
for(std::size_t j=0; j<element.number_of_items(); ++j)
|
||||
{
|
||||
for(std::size_t k = 0; k < element.number_of_properties(); ++ k)
|
||||
for(std::size_t k=0; k<element.number_of_properties(); ++k)
|
||||
{
|
||||
IO::internal::PLY_read_number* property = element.property(k);
|
||||
property->get(is);
|
||||
|
|
@ -165,33 +180,33 @@ bool read_PLY(std::istream& is,
|
|||
if(has_uv)
|
||||
{
|
||||
IO::internal::process_properties(element, new_hedge,
|
||||
std::make_pair(CGAL::make_nth_of_tuple_property_map<0>(new_hedge),
|
||||
PLY_property<unsigned int>(stag.c_str())),
|
||||
std::make_pair(CGAL::make_nth_of_tuple_property_map<1>(new_hedge),
|
||||
PLY_property<unsigned int>(ttag.c_str())),
|
||||
std::make_pair(CGAL::make_nth_of_tuple_property_map<2>(new_hedge),
|
||||
PLY_property<float>(utag.c_str())),
|
||||
std::make_pair(CGAL::make_nth_of_tuple_property_map<3>(new_hedge),
|
||||
PLY_property<float>(vtag.c_str())));
|
||||
std::make_pair(CGAL::make_nth_of_tuple_property_map<0>(new_hedge),
|
||||
PLY_property<unsigned int>(stag.c_str())),
|
||||
std::make_pair(CGAL::make_nth_of_tuple_property_map<1>(new_hedge),
|
||||
PLY_property<unsigned int>(ttag.c_str())),
|
||||
std::make_pair(CGAL::make_nth_of_tuple_property_map<2>(new_hedge),
|
||||
PLY_property<float>(utag.c_str())),
|
||||
std::make_pair(CGAL::make_nth_of_tuple_property_map<3>(new_hedge),
|
||||
PLY_property<float>(vtag.c_str())));
|
||||
|
||||
*hedges_out++ = std::make_pair(get<0>(new_hedge), get<1>(new_hedge));
|
||||
*huvs_out++ = std::make_pair(get<2>(new_hedge), get<3>(new_hedge));
|
||||
}
|
||||
else
|
||||
{
|
||||
IO::internal::process_properties(element, new_hedge,
|
||||
std::make_pair(CGAL::make_nth_of_tuple_property_map<0>(new_hedge),
|
||||
PLY_property<unsigned int>(stag.c_str())),
|
||||
std::make_pair(CGAL::make_nth_of_tuple_property_map<1>(new_hedge),
|
||||
PLY_property<unsigned int>(ttag.c_str()))
|
||||
);
|
||||
std::make_pair(CGAL::make_nth_of_tuple_property_map<0>(new_hedge),
|
||||
PLY_property<unsigned int>(stag.c_str())),
|
||||
std::make_pair(CGAL::make_nth_of_tuple_property_map<1>(new_hedge),
|
||||
PLY_property<unsigned int>(ttag.c_str())));
|
||||
}
|
||||
}
|
||||
}
|
||||
else // Read other elements and ignore
|
||||
{
|
||||
for(std::size_t j = 0; j < element.number_of_items(); ++ j)
|
||||
for(std::size_t j=0; j<element.number_of_items(); ++j)
|
||||
{
|
||||
for(std::size_t k = 0; k < element.number_of_properties(); ++ k)
|
||||
for(std::size_t k=0; k<element.number_of_properties(); ++k)
|
||||
{
|
||||
IO::internal::PLY_read_number* property = element.property(k);
|
||||
property->get(is);
|
||||
|
|
@ -203,8 +218,10 @@ bool read_PLY(std::istream& is,
|
|||
}
|
||||
return !is.fail();
|
||||
}
|
||||
}// End of internal
|
||||
}// End of IO
|
||||
|
||||
} // namespace internal
|
||||
} // namespace IO
|
||||
|
||||
template <class PointRange, class PolygonRange, class ColorRange, class HEdgesRange, class HUVRange>
|
||||
bool read_PLY(std::istream& is,
|
||||
PointRange& points,
|
||||
|
|
@ -213,13 +230,14 @@ bool read_PLY(std::istream& is,
|
|||
ColorRange& fcolors,
|
||||
ColorRange& vcolors,
|
||||
HUVRange& huvs,
|
||||
bool verbose =true,
|
||||
bool verbose = true,
|
||||
typename std::enable_if<
|
||||
!CGAL::is_iterator<ColorRange>::value
|
||||
>::type* =0)
|
||||
{
|
||||
return IO::internal::read_PLY(is, points, polygons, std::back_inserter(hedges), std::back_inserter(fcolors), std::back_inserter(vcolors), std::back_inserter(huvs), verbose);
|
||||
}
|
||||
|
||||
template <class PointRange, class PolygonRange, class ColorRange>
|
||||
bool read_PLY(std::istream& is,
|
||||
PointRange& points,
|
||||
|
|
@ -230,10 +248,10 @@ bool read_PLY(std::istream& is,
|
|||
{
|
||||
std::vector<std::pair<unsigned int, unsigned int> > dummy_pui;
|
||||
std::vector<std::pair<float, float> > dummy_pf;
|
||||
|
||||
return IO::internal::read_PLY(is, points, polygons, std::back_inserter(dummy_pui), std::back_inserter(fcolors), std::back_inserter(vcolors), std::back_inserter(dummy_pf), verbose);
|
||||
}
|
||||
|
||||
|
||||
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_PLY(std::istream& is,
|
||||
PointRange& points,
|
||||
|
|
@ -241,22 +259,20 @@ bool read_PLY(std::istream& is,
|
|||
const CGAL_BGL_NP_CLASS& np,
|
||||
bool verbose = true)
|
||||
{
|
||||
|
||||
using parameters::choose_parameter;
|
||||
using parameters::get_parameter;
|
||||
|
||||
std::vector<std::pair<unsigned int, unsigned int> > dummy_pui;
|
||||
std::vector<std::pair<float, float> > dummy_pf;
|
||||
|
||||
return IO::internal::read_PLY(is, points, polygons,std::back_inserter(dummy_pui),
|
||||
choose_parameter(get_parameter(np, internal_np::face_color_output_iterator),
|
||||
CGAL::Emptyset_iterator()),
|
||||
choose_parameter(get_parameter(np, internal_np::vertex_color_output_iterator),
|
||||
CGAL::Emptyset_iterator()),
|
||||
std::back_inserter(dummy_pf), verbose);
|
||||
choose_parameter(get_parameter(np, internal_np::face_color_output_iterator),
|
||||
CGAL::Emptyset_iterator()),
|
||||
choose_parameter(get_parameter(np, internal_np::vertex_color_output_iterator),
|
||||
CGAL::Emptyset_iterator()),
|
||||
std::back_inserter(dummy_pf), verbose);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \ingroup PlyIoFuncs
|
||||
*
|
||||
|
|
@ -271,17 +287,16 @@ bool read_PLY(std::istream& is,
|
|||
* \see \ref IOStreamPLY
|
||||
*/
|
||||
template <class PointRange, class PolygonRange>
|
||||
bool
|
||||
read_PLY(std::istream& is,
|
||||
PointRange& points,
|
||||
PolygonRange& polygons,
|
||||
bool verbose = true
|
||||
bool read_PLY(std::istream& is,
|
||||
PointRange& points,
|
||||
PolygonRange& polygons,
|
||||
bool verbose = true
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
,typename std::enable_if<
|
||||
boost::has_value_type<PointRange>::value
|
||||
>::type* =0
|
||||
#endif
|
||||
)
|
||||
, typename std::enable_if<
|
||||
boost::has_value_type<PointRange>::value
|
||||
>::type* =0
|
||||
#endif
|
||||
)
|
||||
{
|
||||
typedef typename PointRange::value_type Point_3;
|
||||
if(!is.good())
|
||||
|
|
@ -292,22 +307,21 @@ read_PLY(std::istream& is,
|
|||
}
|
||||
|
||||
IO::internal::PLY_reader reader(verbose);
|
||||
|
||||
if(!(reader.init(is)))
|
||||
{
|
||||
is.setstate(std::ios::failbit);
|
||||
return false;
|
||||
}
|
||||
|
||||
for(std::size_t i = 0; i < reader.number_of_elements(); ++ i)
|
||||
for(std::size_t i=0; i<reader.number_of_elements(); ++i)
|
||||
{
|
||||
IO::internal::PLY_element& element = reader.element(i);
|
||||
|
||||
if(element.name() == "vertex" || element.name() == "vertices")
|
||||
{
|
||||
for(std::size_t j = 0; j < element.number_of_items(); ++ j)
|
||||
for(std::size_t j=0; j<element.number_of_items(); ++j)
|
||||
{
|
||||
for(std::size_t k = 0; k < element.number_of_properties(); ++ k)
|
||||
for(std::size_t k=0; k<element.number_of_properties(); ++k)
|
||||
{
|
||||
IO::internal::PLY_read_number* property = element.property(k);
|
||||
property->get(is);
|
||||
|
|
@ -317,10 +331,8 @@ read_PLY(std::istream& is,
|
|||
}
|
||||
|
||||
Point_3 new_vertex;
|
||||
|
||||
IO::internal::process_properties(element, new_vertex,
|
||||
make_ply_point_reader(CGAL::Identity_property_map<Point_3>()));
|
||||
|
||||
make_ply_point_reader(CGAL::Identity_property_map<Point_3>()));
|
||||
points.push_back(new_vertex);
|
||||
}
|
||||
}
|
||||
|
|
@ -329,13 +341,21 @@ read_PLY(std::istream& is,
|
|||
std::vector<CGAL::Color> dummy;
|
||||
|
||||
if(element.has_property<std::vector<boost::int32_t> >("vertex_indices"))
|
||||
{
|
||||
IO::internal::read_PLY_faces<boost::int32_t>(is, element, polygons, dummy, "vertex_indices");
|
||||
}
|
||||
else if(element.has_property<std::vector<boost::uint32_t> >("vertex_indices"))
|
||||
{
|
||||
IO::internal::read_PLY_faces<boost::uint32_t>(is, element, polygons, dummy, "vertex_indices");
|
||||
}
|
||||
else if(element.has_property<std::vector<boost::int32_t> >("vertex_index"))
|
||||
{
|
||||
IO::internal::read_PLY_faces<boost::int32_t>(is, element, polygons, dummy, "vertex_index");
|
||||
}
|
||||
else if(element.has_property<std::vector<boost::uint32_t> >("vertex_index"))
|
||||
{
|
||||
IO::internal::read_PLY_faces<boost::uint32_t>(is, element, polygons, dummy, "vertex_index");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(verbose)
|
||||
|
|
@ -345,9 +365,9 @@ read_PLY(std::istream& is,
|
|||
}
|
||||
else // Read other elements and ignore
|
||||
{
|
||||
for(std::size_t j = 0; j < element.number_of_items(); ++ j)
|
||||
for(std::size_t j=0; j<element.number_of_items(); ++j)
|
||||
{
|
||||
for(std::size_t k = 0; k < element.number_of_properties(); ++ k)
|
||||
for(std::size_t k=0; k<element.number_of_properties(); ++k)
|
||||
{
|
||||
IO::internal::PLY_read_number* property = element.property(k);
|
||||
property->get(is);
|
||||
|
|
@ -363,11 +383,8 @@ read_PLY(std::istream& is,
|
|||
}
|
||||
|
||||
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_PLY(const char* fname,
|
||||
PointRange& points,
|
||||
PolygonRange& polygons,
|
||||
const CGAL_BGL_NP_CLASS& np,
|
||||
bool verbose = true)
|
||||
bool read_PLY(const char* fname, PointRange& points, PolygonRange& polygons,
|
||||
const CGAL_BGL_NP_CLASS& np, bool verbose = true)
|
||||
{
|
||||
std::ifstream is(fname);
|
||||
return read_PLY(is, points, polygons, np, verbose);
|
||||
|
|
@ -390,22 +407,19 @@ template <typename PointRange, typename PolygonRange>
|
|||
bool read_PLY(const char* fname,
|
||||
PointRange& points,
|
||||
PolygonRange& polygons
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
,typename std::enable_if<
|
||||
!CGAL::is_iterator<PolygonRange>::value
|
||||
>::type* =0
|
||||
#endif
|
||||
)
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename std::enable_if<
|
||||
!CGAL::is_iterator<PolygonRange>::value
|
||||
>::type* =0
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return read_PLY(fname, points, polygons, parameters::all_default());
|
||||
}
|
||||
|
||||
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_PLY(const std::string& fname,
|
||||
PointRange& points,
|
||||
PolygonRange& polygons,
|
||||
const CGAL_BGL_NP_CLASS& np,
|
||||
bool verbose = true)
|
||||
bool read_PLY(const std::string& fname, PointRange& points, PolygonRange& polygons,
|
||||
const CGAL_BGL_NP_CLASS& np, bool verbose = true)
|
||||
{
|
||||
return read_PLY(fname.c_str(), points, polygons, np, verbose);
|
||||
}
|
||||
|
|
@ -414,12 +428,12 @@ template <typename PointRange, typename PolygonRange>
|
|||
bool read_PLY(const std::string fname,
|
||||
PointRange& points,
|
||||
PolygonRange& polygons
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
,typename std::enable_if<
|
||||
!CGAL::is_iterator<PolygonRange>::value
|
||||
>::type* =0
|
||||
#endif
|
||||
)
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename std::enable_if<
|
||||
!CGAL::is_iterator<PolygonRange>::value
|
||||
>::type* =0
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return read_PLY(fname, points, polygons, parameters::all_default());
|
||||
}
|
||||
|
|
@ -433,18 +447,19 @@ bool write_PLY(std::ostream& out,
|
|||
const PointRange& points,
|
||||
const PolygonRange& polygons,
|
||||
const CGAL_BGL_NP_CLASS&
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
,typename boost::enable_if<
|
||||
typename boost::has_range_const_iterator<PointRange>::type
|
||||
>::type* =0,
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename boost::enable_if<
|
||||
typename boost::has_range_const_iterator<PointRange>::type
|
||||
>::type* =0,
|
||||
typename std::enable_if<
|
||||
boost::has_value_type<PointRange>::value
|
||||
boost::has_value_type<PointRange>::value
|
||||
>::type* =0
|
||||
#endif
|
||||
#endif
|
||||
)
|
||||
{
|
||||
typedef typename PointRange::value_type Point_3;
|
||||
typedef typename PolygonRange::value_type Polygon_3;
|
||||
|
||||
if(!out.good())
|
||||
{
|
||||
std::cerr << "Error: cannot open file" << std::endl;
|
||||
|
|
@ -457,7 +472,7 @@ bool write_PLY(std::ostream& out,
|
|||
<< "comment Generated by the CGAL library" << std::endl
|
||||
<< "element vertex " << points.size() << std::endl;
|
||||
|
||||
IO::internal::output_property_header(out, make_ply_point_writer (CGAL::Identity_property_map<Point_3>()));
|
||||
IO::internal::output_property_header(out, make_ply_point_writer(CGAL::Identity_property_map<Point_3>()));
|
||||
|
||||
out << "element face " << polygons.size() << std::endl;
|
||||
|
||||
|
|
@ -466,19 +481,18 @@ bool write_PLY(std::ostream& out,
|
|||
|
||||
out << "end_header" << std::endl;
|
||||
|
||||
for (std::size_t i = 0; i < points.size(); ++ i)
|
||||
for(std::size_t i=0; i<points.size(); ++i)
|
||||
IO::internal::output_properties(out, points.begin() + i,
|
||||
make_ply_point_writer (CGAL::Identity_property_map<Point_3>()));
|
||||
make_ply_point_writer(CGAL::Identity_property_map<Point_3>()));
|
||||
|
||||
for (std::size_t i = 0; i < polygons.size(); ++ i)
|
||||
for(std::size_t i=0; i<polygons.size(); ++i)
|
||||
IO::internal::output_properties(out, polygons.begin() + i,
|
||||
std::make_pair(CGAL::Identity_property_map<Polygon_3>(),
|
||||
PLY_property<std::vector<int> >("vertex_indices")));
|
||||
std::make_pair(CGAL::Identity_property_map<Polygon_3>(),
|
||||
PLY_property<std::vector<int> >("vertex_indices")));
|
||||
|
||||
return out.good();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \ingroup PlyIoFuncs
|
||||
*
|
||||
|
|
@ -495,14 +509,14 @@ template <class PointRange, class PolygonRange>
|
|||
bool write_PLY(std::ostream& out,
|
||||
const PointRange& points,
|
||||
const PolygonRange& polygons
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
,typename boost::enable_if<
|
||||
typename boost::has_range_const_iterator<PointRange>::type
|
||||
>::type* =0,
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename boost::enable_if<
|
||||
typename boost::has_range_const_iterator<PointRange>::type
|
||||
>::type* =0,
|
||||
typename std::enable_if<
|
||||
boost::has_value_type<PointRange>::value
|
||||
boost::has_value_type<PointRange>::value
|
||||
>::type* =0
|
||||
#endif
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return write_PLY(out, points, polygons, parameters::all_default());
|
||||
|
|
@ -518,7 +532,6 @@ bool write_PLY(const char* fname,
|
|||
return write_PLY(os, points, polygons, np);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \ingroup PlyIoFuncs
|
||||
*
|
||||
|
|
@ -532,26 +545,20 @@ bool write_PLY(const char* fname,
|
|||
* \see \ref IOStreamPLY
|
||||
*/
|
||||
template <class PointRange, class PolygonRange>
|
||||
bool write_PLY(const char* fname,
|
||||
const PointRange& points,
|
||||
const PolygonRange& polygons)
|
||||
bool write_PLY(const char* fname, const PointRange& points, const PolygonRange& polygons)
|
||||
{
|
||||
return write_PLY(fname, points, polygons, parameters::all_default());
|
||||
}
|
||||
|
||||
template <class PointRange, class PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS >
|
||||
bool write_PLY(const std::string& fname,
|
||||
const PointRange& points,
|
||||
const PolygonRange& polygons,
|
||||
bool write_PLY(const std::string& fname, const PointRange& points, const PolygonRange& polygons,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return write_PLY(fname.c_str(), points, polygons, np);
|
||||
}
|
||||
|
||||
template <class PointRange, class PolygonRange>
|
||||
bool write_PLY(const std::string& fname,
|
||||
const PointRange& points,
|
||||
const PolygonRange& polygons)
|
||||
bool write_PLY(const std::string& fname, const PointRange& points, const PolygonRange& polygons)
|
||||
{
|
||||
return write_PLY(fname, points, polygons, parameters::all_default());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,10 +79,10 @@ struct Get_FT_from_map
|
|||
|
||||
template <typename PointMap>
|
||||
std::tuple<PointMap,
|
||||
typename Kernel_traits<typename PointMap::value_type>::Kernel::Construct_point_3,
|
||||
PLY_property<typename Get_FT_from_map<PointMap>::type>,
|
||||
PLY_property<typename Get_FT_from_map<PointMap>::type>,
|
||||
PLY_property<typename Get_FT_from_map<PointMap>::type> >
|
||||
typename Kernel_traits<typename PointMap::value_type>::Kernel::Construct_point_3,
|
||||
PLY_property<typename Get_FT_from_map<PointMap>::type>,
|
||||
PLY_property<typename Get_FT_from_map<PointMap>::type>,
|
||||
PLY_property<typename Get_FT_from_map<PointMap>::type> >
|
||||
make_ply_point_reader(PointMap point_map)
|
||||
{
|
||||
return std::make_tuple(point_map, typename Kernel_traits<typename PointMap::value_type>::Kernel::Construct_point_3(),
|
||||
|
|
@ -93,10 +93,10 @@ make_ply_point_reader(PointMap point_map)
|
|||
|
||||
template <typename VectorMap>
|
||||
std::tuple<VectorMap,
|
||||
typename Kernel_traits<typename VectorMap::value_type>::Kernel::Construct_vector_3,
|
||||
PLY_property<typename Get_FT_from_map<VectorMap>::type>,
|
||||
PLY_property<typename Get_FT_from_map<VectorMap>::type>,
|
||||
PLY_property<typename Get_FT_from_map<VectorMap>::type> >
|
||||
typename Kernel_traits<typename VectorMap::value_type>::Kernel::Construct_vector_3,
|
||||
PLY_property<typename Get_FT_from_map<VectorMap>::type>,
|
||||
PLY_property<typename Get_FT_from_map<VectorMap>::type>,
|
||||
PLY_property<typename Get_FT_from_map<VectorMap>::type> >
|
||||
make_ply_normal_reader(VectorMap normal_map)
|
||||
{
|
||||
return std::make_tuple(normal_map, typename Kernel_traits<typename VectorMap::value_type>::Kernel::Construct_vector_3(),
|
||||
|
|
@ -107,9 +107,9 @@ make_ply_normal_reader(VectorMap normal_map)
|
|||
|
||||
template <typename PointMap>
|
||||
std::tuple<PointMap,
|
||||
PLY_property<typename Get_FT_from_map<PointMap>::type>,
|
||||
PLY_property<typename Get_FT_from_map<PointMap>::type>,
|
||||
PLY_property<typename Get_FT_from_map<PointMap>::type> >
|
||||
PLY_property<typename Get_FT_from_map<PointMap>::type>,
|
||||
PLY_property<typename Get_FT_from_map<PointMap>::type>,
|
||||
PLY_property<typename Get_FT_from_map<PointMap>::type> >
|
||||
make_ply_point_writer(PointMap point_map)
|
||||
{
|
||||
return std::make_tuple(point_map,
|
||||
|
|
@ -120,9 +120,9 @@ make_ply_point_writer(PointMap point_map)
|
|||
|
||||
template <typename VectorMap>
|
||||
std::tuple<VectorMap,
|
||||
PLY_property<typename Get_FT_from_map<VectorMap>::type>,
|
||||
PLY_property<typename Get_FT_from_map<VectorMap>::type>,
|
||||
PLY_property<typename Get_FT_from_map<VectorMap>::type> >
|
||||
PLY_property<typename Get_FT_from_map<VectorMap>::type>,
|
||||
PLY_property<typename Get_FT_from_map<VectorMap>::type>,
|
||||
PLY_property<typename Get_FT_from_map<VectorMap>::type> >
|
||||
make_ply_normal_writer(VectorMap normal_map)
|
||||
{
|
||||
return std::make_tuple(normal_map,
|
||||
|
|
@ -160,6 +160,7 @@ public:
|
|||
else
|
||||
stream.clear(std::ios::badbit);
|
||||
}
|
||||
|
||||
void read_ascii(std::istream& stream, signed char& c) const
|
||||
{
|
||||
short s;
|
||||
|
|
@ -168,6 +169,7 @@ public:
|
|||
else
|
||||
stream.clear(std::ios::badbit);
|
||||
}
|
||||
|
||||
void read_ascii(std::istream& stream, unsigned char& c) const
|
||||
{
|
||||
unsigned short s;
|
||||
|
|
@ -197,7 +199,6 @@ public:
|
|||
stream.clear(std::ios::badbit);
|
||||
}
|
||||
|
||||
|
||||
template <typename Type>
|
||||
Type read(std::istream& stream) const
|
||||
{
|
||||
|
|
@ -241,46 +242,39 @@ class PLY_read_typed_number : public PLY_read_number
|
|||
public:
|
||||
PLY_read_typed_number(std::string name, std::size_t format)
|
||||
: PLY_read_number(name, format)
|
||||
{
|
||||
}
|
||||
void get(std::istream& stream) const
|
||||
{
|
||||
m_buffer =(this->read<Type>(stream));
|
||||
}
|
||||
const Type& buffer() const
|
||||
{
|
||||
return m_buffer;
|
||||
}
|
||||
{ }
|
||||
|
||||
void get(std::istream& stream) const { m_buffer =(this->read<Type>(stream)); }
|
||||
|
||||
const Type& buffer() const { return m_buffer; }
|
||||
};
|
||||
|
||||
template <typename Type>
|
||||
class PLY_read_typed_list : public PLY_read_number
|
||||
class PLY_read_typed_list
|
||||
: public PLY_read_number
|
||||
{
|
||||
protected:
|
||||
mutable std::vector<Type> m_buffer;
|
||||
|
||||
public:
|
||||
PLY_read_typed_list(std::string name, std::size_t format)
|
||||
: PLY_read_number(name, format)
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
virtual void get(std::istream& stream) const = 0;
|
||||
|
||||
const std::vector<Type>& buffer() const
|
||||
{
|
||||
return m_buffer;
|
||||
}
|
||||
const std::vector<Type>& buffer() const { return m_buffer; }
|
||||
};
|
||||
|
||||
template <typename SizeType, typename IndexType>
|
||||
class PLY_read_typed_list_with_typed_size
|
||||
: public PLY_read_typed_list<IndexType>
|
||||
: public PLY_read_typed_list<IndexType>
|
||||
{
|
||||
|
||||
public:
|
||||
PLY_read_typed_list_with_typed_size(std::string name, std::size_t format)
|
||||
: PLY_read_typed_list<IndexType>(name, format)
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
void get(std::istream& stream) const
|
||||
{
|
||||
std::size_t size = static_cast<std::size_t>(this->template read<SizeType>(stream));
|
||||
|
|
@ -294,10 +288,9 @@ class PLY_element
|
|||
{
|
||||
std::string m_name;
|
||||
std::size_t m_number;
|
||||
|
||||
std::vector<PLY_read_number*> m_properties;
|
||||
public:
|
||||
|
||||
public:
|
||||
PLY_element(const std::string& name, std::size_t number)
|
||||
: m_name(name), m_number(number)
|
||||
{ }
|
||||
|
|
@ -339,6 +332,7 @@ public:
|
|||
{
|
||||
return has_property(tag, Type());
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
bool has_property(const char* tag, const std::vector<Type>&)
|
||||
{
|
||||
|
|
@ -356,6 +350,7 @@ public:
|
|||
return (dynamic_cast<PLY_read_typed_number<Type>*>(m_properties[i]) != nullptr);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool has_property(const char* tag, double)
|
||||
{
|
||||
for(std::size_t i = 0; i < number_of_properties(); ++ i)
|
||||
|
|
@ -585,7 +580,6 @@ void get_value(Reader& r, T& v, PLY_property<T>& wrapper)
|
|||
return r.assign(v, wrapper.name);
|
||||
}
|
||||
|
||||
|
||||
template <std::size_t N>
|
||||
struct Filler
|
||||
{
|
||||
|
|
@ -709,7 +703,11 @@ bool read_PLY_faces(std::istream& in,
|
|||
{
|
||||
has_colors = true;
|
||||
if(element.has_property<boost::uint8_t>("red"))
|
||||
rtag = "red"; gtag = "green"; btag = "blue";
|
||||
{
|
||||
rtag = "red";
|
||||
gtag = "green";
|
||||
btag = "blue";
|
||||
}
|
||||
}
|
||||
|
||||
for(std::size_t j = 0; j < element.number_of_items(); ++ j)
|
||||
|
|
@ -766,6 +764,7 @@ bool read_PLY_faces(std::istream& in,
|
|||
{
|
||||
return read_PLY_faces<Integer>(in, element, polygons, std::back_inserter(fcolors), vertex_indices_tag);
|
||||
}
|
||||
|
||||
} // namespace PLY
|
||||
} // namespace internal
|
||||
/// \endcond
|
||||
|
|
|
|||
|
|
@ -28,19 +28,19 @@ namespace CGAL {
|
|||
|
||||
class File_writer_VRML_2
|
||||
{
|
||||
VRML_2_ostream* m_out;
|
||||
VRML_2_ostream* m_os;
|
||||
std::size_t m_facets;
|
||||
|
||||
public:
|
||||
File_writer_VRML_2() {}
|
||||
std::ostream& out() const { return m_out->os(); }
|
||||
std::ostream& out() const { return m_os->os(); }
|
||||
|
||||
void write_header(VRML_2_ostream& o,
|
||||
std::size_t vertices,
|
||||
std::size_t halfedges,
|
||||
std::size_t facets)
|
||||
{
|
||||
m_out = &o;
|
||||
m_os = &o;
|
||||
m_facets = facets;
|
||||
|
||||
out() << " #-- Begin of Polygon Mesh\n";
|
||||
|
|
|
|||
|
|
@ -84,8 +84,8 @@ bool vtkPointSet_to_polygon_soup(vtkPointSet* poly_data,
|
|||
|
||||
return true;
|
||||
}
|
||||
}//end internal
|
||||
}//end IO
|
||||
} // namespace internal
|
||||
} // namespace IO
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -339,9 +339,8 @@ void write_soup_polys_points(std::ostream& os,
|
|||
write_vector<FT>(os, coordinates);
|
||||
}
|
||||
|
||||
}//end internal
|
||||
}//end IO
|
||||
|
||||
} // namespace internal
|
||||
} // namespace IO
|
||||
|
||||
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_VTP(std::ostream& os,
|
||||
|
|
@ -458,7 +457,7 @@ bool write_VTP(const std::string& fname,
|
|||
return write_VTP(fname, points, polygons, parameters::all_default());
|
||||
}
|
||||
|
||||
}//end CGAL
|
||||
} // namespace CGAL
|
||||
#elif DOXYGEN_RUNNING
|
||||
|
||||
/*!
|
||||
|
|
@ -472,6 +471,7 @@ template <typename PointRange, typename PolygonRange>
|
|||
bool read_VTP(const char* fname,
|
||||
PointRange& points,
|
||||
PolygonRange& polygons);
|
||||
|
||||
/*!
|
||||
* \ingroup VtpIoFuncs
|
||||
*
|
||||
|
|
@ -482,6 +482,7 @@ template <typename PointRange, typename PolygonRange>
|
|||
bool write_VTP(std::ostream& os,
|
||||
const PointRange& points,
|
||||
const PolygonRange& polygons);
|
||||
|
||||
/*!
|
||||
* \ingroup VtpIoFuncs
|
||||
*
|
||||
|
|
|
|||
|
|
@ -72,13 +72,13 @@ private:
|
|||
};
|
||||
|
||||
template <class vtkReader>
|
||||
vtkSmartPointer<vtkReader> read_vtk_file(const std::string& input_filename,
|
||||
vtkSmartPointer<vtkReader> read_vtk_file(const std::string& fname,
|
||||
vtkSmartPointer<ErrorObserverVtk> errorObserver)
|
||||
{
|
||||
vtkSmartPointer<vtkReader> reader = vtkSmartPointer<vtkReader>::New();
|
||||
reader->AddObserver(vtkCommand::ErrorEvent, errorObserver);
|
||||
reader->AddObserver(vtkCommand::WarningEvent, errorObserver);
|
||||
reader->SetFileName(input_filename.data());
|
||||
reader->SetFileName(fname.data());
|
||||
reader->Update();
|
||||
|
||||
return reader;
|
||||
|
|
|
|||
|
|
@ -544,7 +544,7 @@ std::ostream& write_multi_linestring_WKT(std::ostream& out,
|
|||
template<typename MultiPoint,
|
||||
typename MultiLineString,
|
||||
typename MultiPolygon>
|
||||
std::istream& read_WKT(std::istream& input,
|
||||
std::istream& read_WKT(std::istream& is,
|
||||
MultiPoint& points,
|
||||
MultiLineString& polylines,
|
||||
MultiPolygon& polygons)
|
||||
|
|
@ -556,8 +556,8 @@ std::istream& read_WKT(std::istream& input,
|
|||
typedef typename MultiPolygon::value_type Polygon;
|
||||
|
||||
std::string line;
|
||||
std::streampos input_pos = input.tellg();
|
||||
std::getline(input, line);
|
||||
std::streampos input_pos = is.tellg();
|
||||
std::getline(is, line);
|
||||
std::istringstream iss(line);
|
||||
std::string t;
|
||||
std::string type="";
|
||||
|
|
@ -572,51 +572,51 @@ std::istream& read_WKT(std::istream& input,
|
|||
type.push_back(c);
|
||||
}
|
||||
|
||||
input.seekg(input_pos);
|
||||
is.seekg(input_pos);
|
||||
if(type == "POINT")
|
||||
{
|
||||
Point p;
|
||||
CGAL::read_point_WKT(input, p);
|
||||
CGAL::read_point_WKT(is, p);
|
||||
points.push_back(p);
|
||||
}
|
||||
else if(type == "LINESTRING")
|
||||
{
|
||||
LineString l;
|
||||
CGAL::read_linestring_WKT(input, l);
|
||||
CGAL::read_linestring_WKT(is, l);
|
||||
polylines.push_back(l);
|
||||
}
|
||||
else if(type == "POLYGON")
|
||||
{
|
||||
Polygon p;
|
||||
CGAL::read_polygon_WKT(input, p);
|
||||
CGAL::read_polygon_WKT(is, p);
|
||||
if(!p.outer_boundary().is_empty())
|
||||
polygons.push_back(p);
|
||||
}
|
||||
else if(type == "MULTIPOINT")
|
||||
{
|
||||
MultiPoint mp;
|
||||
CGAL::read_multi_point_WKT(input, mp);
|
||||
CGAL::read_multi_point_WKT(is, mp);
|
||||
for(const Point& point : mp)
|
||||
points.push_back(point);
|
||||
}
|
||||
else if(type == "MULTILINESTRING")
|
||||
{
|
||||
MultiLineString mls;
|
||||
CGAL::read_multi_linestring_WKT(input, mls);
|
||||
CGAL::read_multi_linestring_WKT(is, mls);
|
||||
for(const LineString& ls : mls)
|
||||
polylines.push_back(ls);
|
||||
}
|
||||
else if(type == "MULTIPOLYGON")
|
||||
{
|
||||
MultiPolygon mp;
|
||||
CGAL::read_multi_polygon_WKT(input, mp);
|
||||
CGAL::read_multi_polygon_WKT(is, mp);
|
||||
for(const Polygon& poly : mp)
|
||||
polygons.push_back(poly);
|
||||
}
|
||||
}
|
||||
while(input.good() && !input.eof());
|
||||
while(is.good() && !is.eof());
|
||||
|
||||
return input;
|
||||
return !is.fail();
|
||||
}
|
||||
|
||||
} // namespace CGAL CGAL
|
||||
|
|
|
|||
Loading…
Reference in New Issue