mirror of https://github.com/CGAL/cgal
fix read_PLY and add a test to bgl for the ply writing
This commit is contained in:
parent
3df3b62d02
commit
0f56294ebc
|
|
@ -43,8 +43,9 @@ namespace CGAL {
|
||||||
template <class FaceGraph, class NamedParameters>
|
template <class FaceGraph, class NamedParameters>
|
||||||
bool write_PLY(std::ostream& out,
|
bool write_PLY(std::ostream& out,
|
||||||
const FaceGraph& mesh,
|
const FaceGraph& mesh,
|
||||||
const NamedParameters& np,
|
const std::string& comments,
|
||||||
const std::string& comments = std::string())
|
const NamedParameters& np
|
||||||
|
)
|
||||||
{
|
{
|
||||||
typedef typename boost::graph_traits<FaceGraph>::vertex_descriptor vertex_descriptor;
|
typedef typename boost::graph_traits<FaceGraph>::vertex_descriptor vertex_descriptor;
|
||||||
typedef typename boost::graph_traits<FaceGraph>::halfedge_descriptor halfedge_descriptor;
|
typedef typename boost::graph_traits<FaceGraph>::halfedge_descriptor halfedge_descriptor;
|
||||||
|
|
@ -109,12 +110,27 @@ bool write_PLY(std::ostream& out,
|
||||||
return out.good();
|
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>
|
template <class FaceGraph>
|
||||||
bool write_PLY(std::ostream& out,
|
bool write_PLY(std::ostream& out,
|
||||||
const FaceGraph& mesh)
|
const FaceGraph& mesh)
|
||||||
{
|
{
|
||||||
return write_PLY(out, mesh, parameters::all_default(), "");
|
return write_PLY(out, mesh, "", parameters::all_default());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace CGAL
|
} // namespace CGAL
|
||||||
|
|
|
||||||
|
|
@ -206,12 +206,24 @@ bool test_PLY()
|
||||||
CGAL::make_tetrahedron(Point(0, 0, 0), Point(1, 1, 0),
|
CGAL::make_tetrahedron(Point(0, 0, 0), Point(1, 1, 0),
|
||||||
Point(2, 0, 1), Point(3, 0, 0), fg);
|
Point(2, 0, 1), Point(3, 0, 0), fg);
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
CGAL::write_PLY(out, fg);
|
CGAL::write_PLY(out, fg, "hello");
|
||||||
if(out.fail())
|
if(out.fail())
|
||||||
{
|
{
|
||||||
std::cerr<<"Tetrahedron writing failed."<<std::endl;
|
std::cerr<<"Tetrahedron writing failed."<<std::endl;
|
||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -245,7 +245,7 @@ read_PLY(std::istream& is,
|
||||||
IO::internal::process_properties(element, 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(get<0>(new_vertex));
|
points.push_back(new_vertex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(element.name() == "face" || element.name() == "faces")
|
else if(element.name() == "face" || element.name() == "faces")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue