WIP. Remove read_pm for streams.

This commit is contained in:
Maxime Gimeno 2020-05-06 16:52:24 +02:00
parent 7c8dcbfd47
commit bc360bcfd3
6 changed files with 45 additions and 34 deletions

View File

@ -153,16 +153,15 @@ template <typename FaceGraph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool read_GOCAD(const char* fname, FaceGraph& g, const CGAL_BGL_NP_CLASS& np, bool verbose = true)
{
std::ifstream in(fname);
std::string unused_name;
std::string unused_color;
std::pair<std::string, std::string> dummy;
return read_GOCAD(in, unused_name, unused_color, g, np, verbose);
return read_GOCAD(in, dummy, g, np, verbose);
}
template <typename FaceGraph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool read_GOCAD(const std::string& fname, FaceGraph& g, CGAL_BGL_NP_CLASS np)
bool read_GOCAD(const std::string& fname, FaceGraph& g, CGAL_BGL_NP_CLASS np, bool verbose = true)
{
return read_GOCAD(fname.c_str(), g, np);
return read_GOCAD(fname.c_str(), g, np, verbose);
}
template <typename FaceGraph>

View File

@ -163,7 +163,7 @@ template <typename FaceGraph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool read_PLY(const std::string& fname, FaceGraph& g, const CGAL_BGL_NP_CLASS& np,
bool verbose = true)
{
return IO::internal::read_PLY_BGL(fname.c_str(), g, np, verbose);
return IO::internal::read_PLY(fname.c_str(), g, np, verbose);
}

View File

@ -99,8 +99,8 @@ bool read_polygon_mesh(const std::string& fname,
return read_VTP(fname, g, np);
}
std::istream is(fname.c_str());
return read_polygon_mesh(is, g, np, false);
std::ifstream is(fname.c_str());
return read_polygon_mesh(is, g, np);
}
template <class FaceGraph>

View File

@ -73,9 +73,10 @@ void fill_soup(PointRange& points, PolygonRange& polygons)
template<typename Mesh>
void test_bgl_OFF(const char* filename)
{
Mesh sm;
Mesh sm, sm2;
std::ifstream in(filename);
CGAL::read_polygon_mesh(in,sm);
CGAL::read_polygon_mesh(filename, sm2);
CGAL::write_OFF(std::cout, sm);
}
@ -104,6 +105,12 @@ void test_bgl_OFF_with_np()
.vertex_texture_map(vtm)
.face_color_map(fcm));
CGAL_assertion(ok);
fg.clear();
ok = CGAL::read_polygon_mesh("data/full.off", fg, CGAL::parameters::vertex_normal_map(vnm)
.vertex_color_map(vcm)
.vertex_texture_map(vtm)
.face_color_map(fcm));
CGAL_assertion(ok);
ok = CGAL::write_OFF(std::cout, fg, CGAL::parameters::vertex_normal_map(vnm)
.vertex_color_map(vcm)
@ -134,6 +141,11 @@ bool test_bgl_OBJ()
CGAL::read_polygon_mesh(in, fg);
CGAL_assertion(num_vertices(fg) == 4);
CGAL_assertion(num_faces(fg) == 4);
fg.clear();
CGAL::read_polygon_mesh("data/sphere.obj", fg);
CGAL_assertion(num_vertices(fg) == 162);
CGAL_assertion(num_faces(fg) == 320);
return true;
}
@ -203,7 +215,7 @@ bool test_bgl_vtp(bool binary = false)
}
os.close();
Mesh fg2;
if(!CGAL::read_VTP("tetrahedron.vtp", fg2))
if(!CGAL::read_polygon_mesh("tetrahedron.vtp", fg2))
{
std::cerr<<"vtp reading failed."<<std::endl;
return false;
@ -239,7 +251,7 @@ bool test_bgl_vtp<Polyhedron>(bool binary)
}
os.close();
Polyhedron fg2;
if(!CGAL::read_VTP("tetrahedron.vtp", fg2))
if(!CGAL::read_polygon_mesh("tetrahedron.vtp", fg2))
{
std::cerr<<"vtp reading failed."<<std::endl;
return false;

View File

@ -34,12 +34,12 @@ namespace CGAL {
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
/// Read
template <typename PointRange, typename PolygonRange, typename NamedParameters>
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool read_GOCAD(std::istream& input,
std::pair<std::string, std::string>& name_and_color,
PointRange& points,
PolygonRange& polygons,
const NamedParameters&,
const CGAL_BGL_NP_CLASS&,
bool verbose = true)
{
CGAL_USE(verbose);
@ -105,33 +105,33 @@ bool read_GOCAD(std::istream& input,
return !input.fail();
}
template <typename PointRange, typename PolygonRange, typename NamedParameters>
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool read_GOCAD(std::istream& is,
PointRange& points,
PolygonRange& polygons,
const NamedParameters&np)
const CGAL_BGL_NP_CLASS&np)
{
std::pair<std::string, std::string> dummy;
return read_GOCAD(is, dummy, points, polygons, np);
}
template <typename PointRange, typename PolygonRange, typename NamedParameters>
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool read_GOCAD(const char* fname,
PointRange& points,
PolygonRange& polygons,
const NamedParameters& np)
const CGAL_BGL_NP_CLASS& np)
{
std::ifstream in(fname);
std::pair<std::string, std::string> dummy;
return read_GOCAD(in, dummy, points, polygons, np);
}
template <typename PointRange, typename PolygonRange, typename NamedParameters>
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool read_GOCAD(const std::string& fname,
PointRange& points,
PolygonRange& polygons,
const NamedParameters& np)
const CGAL_BGL_NP_CLASS& np)
{
return read_GOCAD(fname.c_str(), points, polygons, np);
}

View File

@ -136,7 +136,7 @@ public: // virtual interface of Base_property_array
if(pa != nullptr){
std::copy((*pa).data_.begin(), (*pa).data_.end(), data_.end()-(*pa).data_.size());
return true;
}
}
return false;
}
@ -221,7 +221,7 @@ private:
template<typename, typename>
class Property_container;
/// @endcond
/// @endcond
@ -291,7 +291,7 @@ public:
parrays_.back()->resize(size_);
}
}
// Transfer one element with all properties
// WARNING: properties must be the same in the two containers
bool transfer(const Property_container& _rhs, std::size_t from, std::size_t to)
@ -326,7 +326,7 @@ public:
typedef typename Ref_class::template Get_property_map<Key, T>::type type;
};
template <class T>
template <class T>
std::pair<typename Get_pmap_type<T>::type, bool>
get(const std::string& name, std::size_t i) const
{
@ -365,7 +365,7 @@ public:
// get a property by its name. returns invalid property if it does not exist.
template <class T>
template <class T>
std::pair<typename Get_pmap_type<T>::type, bool>
get(const std::string& name) const
{
@ -394,7 +394,7 @@ public:
// get the type of property by its name. returns typeid(void) if it does not exist.
const std::type_info&
const std::type_info&
get_type(const std::string& name) const
{
for (std::size_t i=0; i<parrays_.size(); ++i)
@ -405,7 +405,7 @@ public:
// delete a property
template <class T>
template <class T>
bool
remove(typename Get_pmap_type<T>::type& h)
{
@ -487,7 +487,7 @@ public:
this->parrays_.swap (other.parrays_);
std::swap(this->size_, other.size_);
}
private:
std::vector<Base_property_array*> parrays_;
size_t size_;
@ -497,11 +497,11 @@ private:
/// @endcond
#ifndef DOXYGEN_RUNNING
///
///
/// `Property_map` enables to attach properties to the simplices of a
///
/// `Property_map` enables to attach properties to the simplices of a
/// surface mesh.
///
///
/// @tparam Key The key type of the property map. It must be a model of `Index`.
/// @tparam Value The value type of the property.
///
@ -510,7 +510,7 @@ private:
template <class I, class T, class CRTP_derived_class>
class Property_map_base
/// @cond CGAL_DOCUMENT_INTERNALS
: public boost::put_get_helper<
: public boost::put_get_helper<
typename Property_array<T>::reference,
CRTP_derived_class>
/// @endcond
@ -528,7 +528,7 @@ public:
typedef typename Property_array<T>::const_reference const_reference;
typedef typename Property_array<T>::iterator iterator;
typedef typename Property_array<T>::const_iterator const_iterator;
#else
#else
/// A reference to the value type of the property.
typedef unspecified_type reference;
@ -549,14 +549,14 @@ public:
{
parray_ = nullptr;
}
/// @endcond
/// @endcond
public:
/// \name Accessing Properties
//@{
#ifdef DOXYGEN_RUNNING
/// Conversion to a Boolean. It is \c true when the property map
/// can be used, and \c false otherwise.
/// can be used, and \c false otherwise.
operator bool () const;
#else
operator bool_type() const {