fix read_PLY and add a test to bgl for the ply writing

This commit is contained in:
Maxime Gimeno 2020-03-18 17:29:02 +01:00
parent 3df3b62d02
commit 0f56294ebc
3 changed files with 33 additions and 5 deletions

View File

@ -43,8 +43,9 @@ namespace CGAL {
template <class FaceGraph, class NamedParameters>
bool write_PLY(std::ostream& out,
const FaceGraph& mesh,
const NamedParameters& np,
const std::string& comments = std::string())
const std::string& comments,
const NamedParameters& np
)
{
typedef typename boost::graph_traits<FaceGraph>::vertex_descriptor vertex_descriptor;
typedef typename boost::graph_traits<FaceGraph>::halfedge_descriptor halfedge_descriptor;
@ -109,12 +110,27 @@ bool write_PLY(std::ostream& out,
return out.good();
}
template <class FaceGraph>
bool write_PLY(std::ostream& out,
const FaceGraph& mesh,
const std::string comments)
{
return write_PLY(out, mesh, comments, parameters::all_default());
}
template <class FaceGraph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool write_PLY(std::ostream& out,
const FaceGraph& mesh,
const CGAL_BGL_NP_CLASS& np)
{
return write_PLY(out, mesh, "", np);
}
template <class FaceGraph>
bool write_PLY(std::ostream& out,
const FaceGraph& mesh)
{
return write_PLY(out, mesh, parameters::all_default(), "");
return write_PLY(out, mesh, "", parameters::all_default());
}
} // namespace CGAL

View File

@ -206,12 +206,24 @@ bool test_PLY()
CGAL::make_tetrahedron(Point(0, 0, 0), Point(1, 1, 0),
Point(2, 0, 1), Point(3, 0, 0), fg);
std::ostringstream out;
CGAL::write_PLY(out, fg);
CGAL::write_PLY(out, fg, "hello");
if(out.fail())
{
std::cerr<<"Tetrahedron writing failed."<<std::endl;
return false;
}
std::istringstream in(out.str());
std::vector<Point> points;
std::vector<std::vector<std::size_t> > polygons;
if(!CGAL::read_PLY(in, points, polygons)){
std::cerr<<"Tetrahedron reading failed."<<std::endl;
return false;
}
CGAL_assertion(points.size() == 4);
CGAL_assertion(polygons.size() == 4);
return true;
}

View File

@ -245,7 +245,7 @@ read_PLY(std::istream& is,
IO::internal::process_properties(element, new_vertex,
make_ply_point_reader(CGAL::Identity_property_map<Point_3>()));
points.push_back(get<0>(new_vertex));
points.push_back(new_vertex);
}
}
else if(element.name() == "face" || element.name() == "faces")