mirror of https://github.com/CGAL/cgal
Misc minor code improvements
This commit is contained in:
parent
fcf0fa4273
commit
3ea5fc5a10
|
|
@ -5,7 +5,7 @@
|
|||
// Max-Planck-Institute Saarbruecken (Germany),
|
||||
// and Tel-Aviv University (Israel). All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org);
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
|
|
|
|||
|
|
@ -222,8 +222,9 @@ bool write_OFF_BGL(std::ostream& os,
|
|||
\cgalParamBegin{face_color_map} the property map with the colors associated to the faces of `g`.\cgalParamEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\sa Overloads of this function for specific models of the concept `FaceGraph`.
|
||||
\returns `true` if writing was successful.
|
||||
|
||||
\sa Overloads of this function for specific models of the concept `FaceGraph`.
|
||||
\see \ref IOStreamOFF
|
||||
*/
|
||||
template <typename FaceGraph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
|
|
@ -263,8 +264,8 @@ bool write_OFF(std::ostream& os, const FaceGraph& g, const CGAL_BGL_NP_CLASS& np
|
|||
\see \ref IOStreamOFF
|
||||
*/
|
||||
template <typename FaceGraph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_OFF(const char* fname, const FaceGraph& g, const CGAL_BGL_NP_CLASS& np
|
||||
,typename boost::disable_if<
|
||||
bool write_OFF(const char* fname, const FaceGraph& g, const CGAL_BGL_NP_CLASS& np,
|
||||
typename boost::disable_if<
|
||||
typename boost::has_range_const_iterator<FaceGraph>::type
|
||||
>::type* =0)
|
||||
{
|
||||
|
|
@ -273,8 +274,8 @@ bool write_OFF(const char* fname, const FaceGraph& g, const CGAL_BGL_NP_CLASS& n
|
|||
}
|
||||
|
||||
template <typename FaceGraph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_OFF(const std::string& fname, const FaceGraph& g, const CGAL_BGL_NP_CLASS& np
|
||||
,typename boost::disable_if<
|
||||
bool write_OFF(const std::string& fname, const FaceGraph& g, const CGAL_BGL_NP_CLASS& np,
|
||||
typename boost::disable_if<
|
||||
typename boost::has_range_const_iterator<FaceGraph>::type
|
||||
>::type* =0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@
|
|||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Read
|
||||
|
|
@ -44,7 +44,7 @@ class PLY_builder
|
|||
|
||||
public:
|
||||
PLY_builder(std::istream& is_, bool verbose) : Base(is_, verbose) { }
|
||||
//! TODO: use vertex_point_map
|
||||
|
||||
template <typename NamedParameters>
|
||||
bool read(std::istream& input,
|
||||
Point_container& points,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Write
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIOFct
|
||||
|
||||
|
|
|
|||
|
|
@ -95,55 +95,43 @@ bool read_polygon_mesh(const std::string& fname,
|
|||
FaceGraph& g,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
|
||||
if (fname.find(".obj") != std::string::npos) {
|
||||
if(fname.find(".obj") != std::string::npos)
|
||||
return read_OBJ(fname, g, np);
|
||||
}
|
||||
|
||||
if (fname.find(".off") != std::string::npos) {
|
||||
if(fname.find(".off") != std::string::npos)
|
||||
return read_OFF(fname, g, np);
|
||||
}
|
||||
|
||||
if (fname.find(".ply") != std::string::npos) {
|
||||
if(fname.find(".ply") != std::string::npos)
|
||||
return read_PLY(fname, g, np);
|
||||
}
|
||||
|
||||
if (fname.find(".stl") != std::string::npos) {
|
||||
if(fname.find(".stl") != std::string::npos)
|
||||
return read_STL(fname, g, np);
|
||||
}
|
||||
|
||||
#ifdef CGAL_USE_VTK
|
||||
if (fname.find(".vtp") != std::string::npos) {
|
||||
if(fname.find(".vtp") != std::string::npos)
|
||||
return read_VTP(fname, g, np);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (fname.find(".ts") != std::string::npos) {
|
||||
if(fname.find(".ts") != std::string::npos)
|
||||
return read_GOCAD(fname, g, np);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class FaceGraph>
|
||||
bool read_polygon_mesh(const std::string& fname,
|
||||
FaceGraph& g)
|
||||
bool read_polygon_mesh(const std::string& fname, FaceGraph& g)
|
||||
{
|
||||
return read_polygon_mesh(fname, g, parameters::all_default());
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class FaceGraph, typename NamedParameters>
|
||||
bool read_polygon_mesh(const char* fname,
|
||||
FaceGraph& g,
|
||||
const NamedParameters& np)
|
||||
bool read_polygon_mesh(const char* fname, FaceGraph& g, const NamedParameters& np)
|
||||
{
|
||||
return read_polygon_mesh(std::string(fname), g, np);
|
||||
}
|
||||
|
||||
template <class FaceGraph>
|
||||
bool read_polygon_mesh(const char* fname,
|
||||
FaceGraph& g)
|
||||
bool read_polygon_mesh(const char* fname, FaceGraph& g)
|
||||
{
|
||||
return read_polygon_mesh(fname, g, parameters::all_default());
|
||||
}
|
||||
|
|
@ -154,83 +142,76 @@ bool read_polygon_mesh(const char* fname,
|
|||
|
||||
/*!
|
||||
* \ingroup PkgBGLIOFct
|
||||
*
|
||||
* \brief writes a polygon mesh in a file.
|
||||
* \tparam FaceGraph a model of `FaceGraph`
|
||||
*
|
||||
* \tparam FaceGraph a model of `FaceListGraph` and `HalfedgeListGraph`
|
||||
* \tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters"
|
||||
*
|
||||
* \param fname the name of the file. Its extension must be one of the following :
|
||||
* `.off` (\ref IOStreamOFF "OFF file format") , `.obj` (\ref IOStreamOBJ "OBJ file format"),
|
||||
* `.stl` (\ref IOStreamSTL "STL file format"), `.ply` (\ref IOStreamPLY "PLY file format"),
|
||||
* `.vtp`(\ref IOStreamVTK "VTP file format") or `.ts`(\ref IOStreamGocad "GOCAD file format").
|
||||
* \param g the mesh
|
||||
* \param g the mesh to be output
|
||||
* \param np optional \ref pmp_namedparameters "Named Parameters" described below
|
||||
*
|
||||
* \cgalNamedParamsBegin
|
||||
* \cgalParamBegin{vertex_point_map} the property map with the points associated to the vertices of `g`.
|
||||
* If this parameter is omitted, an internal property map for
|
||||
* `CGAL::vertex_point_t` should be available in `FaceGraph`\cgalParamEnd
|
||||
* `CGAL::vertex_point_t` should be available in `FaceGraph`
|
||||
* \cgalParamEnd
|
||||
* \cgalNamedParamsEnd
|
||||
* Other named parameters may be used according to the file extension.
|
||||
* See `PkgBGLIOFct` for an exhaustive list.
|
||||
* \return `true` if the writing worked, `false` otherwise.
|
||||
*
|
||||
* \see \ref IOStreamOFF
|
||||
* Other named parameters may be used according to the file extension, see \ref PkgBGLIOFct for an exhaustive list.
|
||||
*
|
||||
* \return `true` if writing was successful, `false` otherwise.
|
||||
*/
|
||||
template <class FaceGraph, typename NamedParameters>
|
||||
bool write_polygon_mesh(const std::string& fname,
|
||||
FaceGraph& g,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
if (fname.find(".ts") != std::string::npos) {
|
||||
return write_GOCAD(fname, g, np);
|
||||
}
|
||||
|
||||
if (fname.find(".obj") != std::string::npos) {
|
||||
if(fname.find(".obj") != std::string::npos) // @fixme what about my_super_file.obj.off
|
||||
return write_OBJ(fname, g, np);
|
||||
}
|
||||
|
||||
if (fname.find(".off") != std::string::npos) {
|
||||
if(fname.find(".off") != std::string::npos) // @fixme case sensitivity
|
||||
return write_OFF(fname, g, np);
|
||||
}
|
||||
|
||||
if (fname.find(".ply") != std::string::npos) {
|
||||
if(fname.find(".ply") != std::string::npos)
|
||||
return write_PLY(fname, g, np);
|
||||
}
|
||||
|
||||
if (fname.find(".stl") != std::string::npos) {
|
||||
if(fname.find(".stl") != std::string::npos)
|
||||
return write_STL(fname, g, np);
|
||||
}
|
||||
|
||||
if(fname.find(".ts") != std::string::npos)
|
||||
return write_GOCAD(fname, g, np);
|
||||
|
||||
#ifdef CGAL_USE_VTK
|
||||
if (fname.find(".vtp") != std::string::npos) {
|
||||
if(fname.find(".vtp") != std::string::npos)
|
||||
return write_VTP(fname, g, np);
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class FaceGraph>
|
||||
bool write_polygon_mesh(const std::string& fname,
|
||||
FaceGraph& g)
|
||||
bool write_polygon_mesh(const std::string& fname, FaceGraph& g)
|
||||
{
|
||||
return write_polygon_mesh(fname, g, parameters::all_default());
|
||||
}
|
||||
|
||||
template <class FaceGraph, typename NamedParameters>
|
||||
bool write_polygon_mesh(const char* fname,
|
||||
FaceGraph& g,
|
||||
const NamedParameters& np)
|
||||
bool write_polygon_mesh(const char* fname, FaceGraph& g, const NamedParameters& np)
|
||||
{
|
||||
return write_polygon_mesh(std::string(fname), g, np);
|
||||
}
|
||||
|
||||
template <class FaceGraph>
|
||||
bool write_polygon_mesh(const char* fname,
|
||||
FaceGraph& g)
|
||||
bool write_polygon_mesh(const char* fname, FaceGraph& g)
|
||||
{
|
||||
return write_polygon_mesh(fname, g, parameters::all_default());
|
||||
}
|
||||
|
||||
}//end CGAL
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_BOOST_GRAPH_POLYGON_MESH_IO_H
|
||||
|
|
|
|||
|
|
@ -33,8 +33,7 @@ typedef CGAL::Polyhedron_3<Kernel, CGAL::Polyhedron_items_with_id_3> Polyhedron;
|
|||
typedef CGAL::Surface_mesh<Point> SM;
|
||||
|
||||
typedef CGAL::Linear_cell_complex_traits<3, Kernel> MyTraits;
|
||||
typedef CGAL::Linear_cell_complex_for_bgl_combinatorial_map_helper
|
||||
<2, 3, MyTraits>::type LCC;
|
||||
typedef CGAL::Linear_cell_complex_for_bgl_combinatorial_map_helper<2, 3, MyTraits>::type LCC;
|
||||
|
||||
#if defined(CGAL_USE_OPENMESH)
|
||||
|
||||
|
|
@ -70,7 +69,6 @@ void fill_soup(PointRange& points, PolygonRange& polygons)
|
|||
polygons[3] = poly;
|
||||
}
|
||||
|
||||
|
||||
void test_polygon_soup_io()
|
||||
{
|
||||
std::vector<Point> points;
|
||||
|
|
@ -79,9 +77,7 @@ void test_polygon_soup_io()
|
|||
std::string filenames[5] = {"soup.obj", "soup.off", "soup.stl", "soup.ts", "soup.ply"};
|
||||
|
||||
for(const std::string& name : filenames)
|
||||
{
|
||||
CGAL_assertion(CGAL::write_polygon_soup(name, points, polygons));
|
||||
}
|
||||
|
||||
for(const std::string& name : filenames)
|
||||
{
|
||||
|
|
@ -134,6 +130,7 @@ void test_bgl_OFF_with_np()
|
|||
{
|
||||
Mesh fg;
|
||||
std::ifstream in("data/full.off");
|
||||
|
||||
typedef typename boost::property_map<Mesh, CGAL::dynamic_vertex_property_t<Kernel::Vector_3> >::type VertexNormalMap;
|
||||
VertexNormalMap vnm = get(CGAL::dynamic_vertex_property_t<Kernel::Vector_3>(), fg);
|
||||
|
||||
|
|
@ -146,12 +143,12 @@ void test_bgl_OFF_with_np()
|
|||
typedef typename boost::property_map<Mesh, CGAL::dynamic_face_property_t<CGAL::Color> >::type FaceColorMap;
|
||||
FaceColorMap fcm = get(CGAL::dynamic_face_property_t<CGAL::Color>(), fg);
|
||||
|
||||
|
||||
bool ok = CGAL::read_OFF(in, fg, CGAL::parameters::vertex_normal_map(vnm)
|
||||
.vertex_color_map(vcm)
|
||||
.vertex_texture_map(vtm)
|
||||
.face_color_map(fcm));
|
||||
CGAL_assertion(ok);
|
||||
|
||||
fg.clear();
|
||||
vnm = get(CGAL::dynamic_vertex_property_t<Kernel::Vector_3>(), fg);
|
||||
ok = CGAL::read_polygon_mesh("data/full.off", fg, CGAL::parameters::vertex_normal_map(vnm)
|
||||
|
|
@ -172,6 +169,7 @@ void test_soup_off(const char* filename)
|
|||
std::vector<Point> points;
|
||||
std::vector<std::vector<std::size_t> > polygons;
|
||||
std::ifstream in(filename);
|
||||
|
||||
CGAL::read_OFF(in,points, polygons);
|
||||
CGAL::write_OFF(std::cout, points, polygons);
|
||||
}
|
||||
|
|
@ -182,19 +180,22 @@ bool test_bgl_OBJ()
|
|||
Mesh fg;
|
||||
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_OBJ(out, fg);
|
||||
|
||||
std::istringstream in(out.str());
|
||||
|
||||
fg.clear();
|
||||
CGAL::read_OBJ(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;
|
||||
}
|
||||
|
||||
|
|
@ -204,21 +205,22 @@ bool test_bgl_OBJ_with_np()
|
|||
Mesh fg, fg2;
|
||||
CGAL::make_tetrahedron(Point(0, 0, 0), Point(1, 1, 0),
|
||||
Point(2, 0, 1), Point(3, 0, 0), fg);
|
||||
|
||||
typedef typename boost::property_map<Mesh, CGAL::dynamic_vertex_property_t<Kernel::Vector_3> >::type VertexNormalMap;
|
||||
VertexNormalMap vnm = get(CGAL::dynamic_vertex_property_t<Kernel::Vector_3>(), fg);
|
||||
VertexNormalMap vnm2 = get(CGAL::dynamic_vertex_property_t<Kernel::Vector_3>(), fg2);
|
||||
|
||||
|
||||
for(const auto& v : vertices(fg))
|
||||
put(vnm, v, Kernel::Vector_3(0.0,1.0,0.0));
|
||||
|
||||
std::ostringstream out;
|
||||
CGAL::write_OBJ(out, fg, CGAL::parameters::vertex_normal_map(vnm));
|
||||
|
||||
std::istringstream in(out.str());
|
||||
|
||||
CGAL::read_OBJ(in, fg2, CGAL::parameters::vertex_normal_map(vnm2));
|
||||
|
||||
CGAL_assertion(num_vertices(fg2) == 4);
|
||||
CGAL_assertion(num_faces(fg2) == 4);
|
||||
|
||||
typename boost::graph_traits<Mesh>::vertex_iterator vit, vit2;
|
||||
for(vit = vertices(fg).begin(), vit2 = vertices(fg2).begin();
|
||||
vit != vertices(fg).end(), vit2 != vertices(fg2).end();
|
||||
|
|
@ -234,18 +236,20 @@ void test_bgl_soup_obj()
|
|||
{
|
||||
std::vector<Point> points;
|
||||
std::vector<std::vector<std::size_t> > polygons;
|
||||
std::ostringstream out;
|
||||
fill_soup(points, polygons);
|
||||
|
||||
std::ostringstream out;
|
||||
CGAL::write_OBJ(out, points, polygons);
|
||||
|
||||
points.clear();
|
||||
polygons.clear();
|
||||
|
||||
std::istringstream in(out.str());
|
||||
CGAL::read_OBJ(in,points, polygons);
|
||||
CGAL_assertion(points.size() == 4);
|
||||
CGAL_assertion(polygons.size() == 4);
|
||||
|
||||
}
|
||||
|
||||
#ifdef CGAL_USE_VTK
|
||||
template<typename Mesh>
|
||||
bool test_bgl_vtp(bool binary = false)
|
||||
|
|
@ -261,6 +265,7 @@ bool test_bgl_vtp(bool binary = false)
|
|||
std::cerr << "vtp writing failed." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
os.close();
|
||||
Mesh fg2;
|
||||
if(!CGAL::read_polygon_mesh("tetrahedron.vtp", fg2))
|
||||
|
|
@ -268,8 +273,8 @@ bool test_bgl_vtp(bool binary = false)
|
|||
std::cerr << "vtp reading failed." << std::endl;
|
||||
return false;
|
||||
}
|
||||
if(num_vertices(fg) != num_vertices(fg2)
|
||||
|| num_faces(fg) != num_faces(fg2))
|
||||
|
||||
if(num_vertices(fg) != num_vertices(fg2) || num_faces(fg) != num_faces(fg2))
|
||||
{
|
||||
std::cerr << "Coherence problem. Wrong number of vertices or faces." << std::endl;
|
||||
return false;
|
||||
|
|
@ -290,6 +295,7 @@ bool test_bgl_vtp<Polyhedron>(bool binary)
|
|||
std::size_t id = 0;
|
||||
for(auto v : vertices(fg))
|
||||
put(vid,v, id++);
|
||||
|
||||
std::ofstream os("tetrahedron.vtp");
|
||||
CGAL::write_VTP(os, fg, CGAL::parameters::vertex_index_map(vid).use_binary_mode(binary));
|
||||
if(!os)
|
||||
|
|
@ -298,18 +304,20 @@ bool test_bgl_vtp<Polyhedron>(bool binary)
|
|||
return false;
|
||||
}
|
||||
os.close();
|
||||
|
||||
Polyhedron fg2;
|
||||
if(!CGAL::read_polygon_mesh("tetrahedron.vtp", fg2))
|
||||
{
|
||||
std::cerr << "vtp reading failed." << std::endl;
|
||||
return false;
|
||||
}
|
||||
if(num_vertices(fg) != num_vertices(fg2)
|
||||
|| num_faces(fg) != num_faces(fg2))
|
||||
|
||||
if(num_vertices(fg) != num_vertices(fg2) || num_faces(fg) != num_faces(fg2))
|
||||
{
|
||||
std::cerr << "Coherence problem. Wrong number of vertices or faces." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -329,12 +337,10 @@ bool test_soup_vtp(bool binary = false)
|
|||
}
|
||||
os.close();
|
||||
|
||||
|
||||
std::vector<Point> soup_points;
|
||||
std::vector<std::vector<std::size_t> > soup_polygons;
|
||||
CGAL::read_VTP("tetrahedron_soup.vtp", soup_points, soup_polygons);
|
||||
if(4 != soup_points.size()
|
||||
|| 4 != soup_polygons.size())
|
||||
if(4 != soup_points.size() || 4 != soup_polygons.size())
|
||||
{
|
||||
std::cerr << "Coherence problem. Wrong number of vertices or faces." << std::endl;
|
||||
return false;
|
||||
|
|
@ -351,6 +357,7 @@ bool test_bgl_gocad()
|
|||
FaceGraph fg;
|
||||
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_GOCAD(out, "tetrahedron", fg);
|
||||
if(out.fail())
|
||||
|
|
@ -358,25 +365,31 @@ bool test_bgl_gocad()
|
|||
std::cerr << "Tetrahedron writing failed." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
FaceGraph fg2;
|
||||
std::istringstream in(out.str());
|
||||
std::pair<std::string, std::string> cnn;
|
||||
CGAL::read_GOCAD(in, cnn, fg2);
|
||||
if(cnn.first != "tetrahedron"){
|
||||
if(cnn.first != "tetrahedron")
|
||||
{
|
||||
std::cerr << "reading error: tetrahedron != " <<cnn.first<< std::endl;
|
||||
return 1;
|
||||
}
|
||||
if( !cnn.second.empty()){
|
||||
std::cerr<<"reading error: there should be no color."<<std::endl;
|
||||
return 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(in.fail()){
|
||||
if(!cnn.second.empty())
|
||||
{
|
||||
std::cerr << "reading error: there should be no color." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(in.fail())
|
||||
{
|
||||
std::cerr << "Tetrahedron reading failed." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(num_vertices(fg2) != 4){
|
||||
if(num_vertices(fg2) != 4)
|
||||
{
|
||||
std::cerr << "Wrong number of vertices: 4 != " << num_vertices(fg2) << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -392,7 +405,6 @@ bool test_bgl_gocad()
|
|||
template<class FaceGraph>
|
||||
bool test_bgl_gocad_with_np()
|
||||
{
|
||||
|
||||
typedef typename boost::property_map<FaceGraph,CGAL::vertex_point_t>::type VertexPointMap;
|
||||
FaceGraph fg;
|
||||
CGAL::make_tetrahedron(Point(0, 0, 0), Point(1, 1, 0),
|
||||
|
|
@ -411,21 +423,26 @@ bool test_bgl_gocad_with_np()
|
|||
std::istringstream in(out.str());
|
||||
std::pair<std::string, std::string> cnn;
|
||||
CGAL::read_GOCAD(in, cnn, fg2, CGAL::parameters::vertex_point_map(vpm2));
|
||||
if(cnn.first != "tetrahedron"){
|
||||
if(cnn.first != "tetrahedron")
|
||||
{
|
||||
std::cerr << "reading error: tetrahedron != " <<cnn.first<< std::endl;
|
||||
return 1;
|
||||
}
|
||||
if( !cnn.second.empty()){
|
||||
std::cerr<<"reading error: there should be no color."<<std::endl;
|
||||
return 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(in.fail()){
|
||||
if(!cnn.second.empty())
|
||||
{
|
||||
std::cerr << "reading error: there should be no color." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(in.fail())
|
||||
{
|
||||
std::cerr << "Tetrahedron reading failed." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(num_vertices(fg2) != 4){
|
||||
if(num_vertices(fg2) != 4)
|
||||
{
|
||||
std::cerr << "Wrong number of vertices: 4 != " << num_vertices(fg2) << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -546,12 +563,14 @@ bool test_bgl_PLY(bool binary = false)
|
|||
CGAL::set_mode(in, CGAL::IO::BINARY);
|
||||
|
||||
fg.clear();
|
||||
if(!CGAL::read_PLY(in, fg)){
|
||||
if(!CGAL::read_PLY(in, fg))
|
||||
{
|
||||
std::cerr << "Tetrahedron reading failed." << std::endl;
|
||||
return false;
|
||||
}
|
||||
CGAL_assertion(num_vertices(fg) == 4);
|
||||
CGAL_assertion(num_faces(fg) == 4);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -561,6 +580,7 @@ bool test_bgl_PLY_with_np(bool binary)
|
|||
FaceGraph fg;
|
||||
CGAL::make_tetrahedron(Point(0, 0, 0), Point(1, 1, 0),
|
||||
Point(2, 0, 1), Point(3, 0, 0), fg);
|
||||
|
||||
typedef typename boost::property_map<FaceGraph, CGAL::dynamic_vertex_property_t<CGAL::Color> >::type VertexColorMap;
|
||||
typedef typename boost::property_map<FaceGraph, CGAL::dynamic_face_property_t<CGAL::Color> >::type FaceColorMap;
|
||||
FaceColorMap fcm = get(CGAL::dynamic_face_property_t<CGAL::Color>(), fg);
|
||||
|
|
@ -582,15 +602,14 @@ bool test_bgl_PLY_with_np(bool binary)
|
|||
if(binary)
|
||||
CGAL::set_mode(out, CGAL::IO::BINARY);
|
||||
|
||||
CGAL::write_PLY(out, fg, "hello", CGAL::parameters::vertex_color_map(vcm)
|
||||
.face_color_map(fcm));
|
||||
CGAL::write_PLY(out, fg, "hello", CGAL::parameters::vertex_color_map(vcm).face_color_map(fcm));
|
||||
if(out.fail())
|
||||
{
|
||||
std::cerr << "Tetrahedron writing failed." << std::endl;
|
||||
return false;
|
||||
}
|
||||
std::istringstream in(out.str());
|
||||
|
||||
std::istringstream in(out.str());
|
||||
if(binary)
|
||||
CGAL::set_mode(in, CGAL::IO::BINARY);
|
||||
|
||||
|
|
@ -604,6 +623,7 @@ bool test_bgl_PLY_with_np(bool binary)
|
|||
}
|
||||
CGAL_assertion(num_vertices(fg) == 4);
|
||||
CGAL_assertion(num_faces(fg) == 4);
|
||||
|
||||
vit = vertices(fg).begin();
|
||||
CGAL_assertion(get(vcm2, *vit++) == CGAL::Color(255,0,0));
|
||||
CGAL_assertion(get(vcm2, *vit++) == CGAL::Color(0,255,0));
|
||||
|
|
@ -616,7 +636,6 @@ bool test_bgl_PLY_with_np(bool binary)
|
|||
CGAL_assertion(get(fcm2,*fit++)==CGAL::Color(0,0,155));
|
||||
CGAL_assertion(get(fcm2,*fit++)==CGAL::Color(155,0,155));
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -626,14 +645,16 @@ int main(int argc, char** argv)
|
|||
test_polygon_mesh_io<Polyhedron>();
|
||||
test_polygon_mesh_io<SM>();
|
||||
test_polygon_mesh_io<LCC>();
|
||||
const char* filename=(argc>1) ? argv[1] : "data/prim.off";
|
||||
|
||||
// OFF
|
||||
const char* filename = (argc>1) ? argv[1] : "data/prim.off";
|
||||
test_bgl_OFF<Polyhedron>(filename);
|
||||
test_bgl_OFF<SM>(filename);
|
||||
test_bgl_OFF<LCC>(filename);
|
||||
#ifdef CGAL_USE_OPENMESH
|
||||
test_bgl_OFF<OMesh>(filename);
|
||||
#endif
|
||||
|
||||
// polyhedron's overload doesn't care for any np that is not vpm
|
||||
test_bgl_OFF_with_np<Polyhedron>();
|
||||
test_bgl_OFF_with_np<SM>();
|
||||
|
|
@ -659,70 +680,68 @@ int main(int argc, char** argv)
|
|||
test_bgl_OBJ_with_np<OMesh>();
|
||||
#endif
|
||||
|
||||
|
||||
// PLY
|
||||
if(!test_bgl_PLY<Polyhedron>())
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if(!test_bgl_PLY<Polyhedron>(true))
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if(!test_bgl_PLY<SM>())
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if(!test_bgl_PLY<SM>(true))
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if(!test_bgl_PLY_with_np<Polyhedron>(false))
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if(!test_bgl_PLY_with_np<Polyhedron>(true))
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if(!test_bgl_PLY_with_np<SM>(false))
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if(!test_bgl_PLY_with_np<SM>(true))
|
||||
return 1;
|
||||
|
||||
return EXIT_FAILURE;
|
||||
|
||||
// GOCAD
|
||||
if(!test_bgl_gocad<Polyhedron>())
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if(!test_bgl_gocad<SM>())
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if(!test_bgl_gocad<LCC>())
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if(!test_bgl_gocad_with_np<Polyhedron>())
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if(!test_bgl_gocad_with_np<SM>())
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if(!test_bgl_gocad_with_np<LCC>())
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if(!test_soup_gocad())
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
|
||||
// STL
|
||||
if(!test_bgl_stl<Polyhedron>())
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if(!test_bgl_stl<SM>())
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if(!test_bgl_stl<LCC>())
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
|
||||
// VTP
|
||||
#ifdef CGAL_USE_VTK
|
||||
if(!test_bgl_vtp<Polyhedron>(false))
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if(!test_bgl_vtp<SM>(false))
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if(!test_bgl_vtp<LCC>(false))
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if(!test_soup_vtp(false))
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if(!test_bgl_vtp<Polyhedron>(true))
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if(!test_bgl_vtp<SM>(true))
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if(!test_bgl_vtp<LCC>(true))
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if(!test_soup_vtp(true))
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
#endif
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
|||
Loading…
Reference in New Issue