mirror of https://github.com/CGAL/cgal
WIP tests NP
This commit is contained in:
parent
55361fe782
commit
841f7a2016
|
|
@ -84,7 +84,7 @@ void test_bgl_OFF(const char* filename)
|
|||
|
||||
//todo check the result.
|
||||
template<typename Mesh>
|
||||
void test_bgl_NCSTOFF()
|
||||
void test_bgl_OFF_with_np()
|
||||
{
|
||||
Mesh fg;
|
||||
std::ifstream in("data/full.off");
|
||||
|
|
@ -140,6 +140,40 @@ bool test_bgl_OBJ()
|
|||
return true;
|
||||
}
|
||||
|
||||
template<typename Mesh>
|
||||
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();
|
||||
++vit, ++vit2)
|
||||
{
|
||||
CGAL_assertion(get(vnm, *vit) == get(vnm2, *vit2));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void test_bgl_soup_obj()
|
||||
{
|
||||
std::vector<Point> points;
|
||||
|
|
@ -386,7 +420,39 @@ bool test_STL()
|
|||
|
||||
|
||||
template<class FaceGraph>
|
||||
bool test_PLY(bool binary = false)
|
||||
bool test_bgl_PLY(bool binary = false)
|
||||
{
|
||||
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;
|
||||
|
||||
if(binary)
|
||||
CGAL::set_mode(out, CGAL::IO::BINARY);
|
||||
|
||||
CGAL::write_PLY(out, fg, "hello");
|
||||
if(out.fail())
|
||||
{
|
||||
std::cerr<<"Tetrahedron writing failed."<<std::endl;
|
||||
return false;
|
||||
}
|
||||
std::istringstream in(out.str());
|
||||
|
||||
if(binary)
|
||||
CGAL::set_mode(in, CGAL::IO::BINARY);
|
||||
|
||||
fg.clear();
|
||||
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;
|
||||
}
|
||||
|
||||
template<typename FaceGraph>
|
||||
bool test_bgl_PLY_with_np(bool binary)
|
||||
{
|
||||
FaceGraph fg;
|
||||
CGAL::make_tetrahedron(Point(0, 0, 0), Point(1, 1, 0),
|
||||
|
|
@ -450,26 +516,28 @@ bool test_PLY(bool binary = false)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
//todo tests with all NPs and without NP for all tests
|
||||
//todo Polyhedron read_OFF NPs
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
/*
|
||||
const char* filename=(argc>1) ? argv[1] : "data/prim.off";
|
||||
/*
|
||||
// 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_NCSTOFF<Polyhedron>();
|
||||
test_bgl_NCSTOFF<SM>();
|
||||
test_bgl_NCSTOFF<LCC>();
|
||||
#ifdef CGAL_USE_OPENMESH
|
||||
test_bgl_NCSTOFF<OMesh>();
|
||||
#endif
|
||||
/* test_soup_off(filename);
|
||||
//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>();
|
||||
test_bgl_OFF_with_np<LCC>();
|
||||
#ifdef CGAL_USE_OPENMESH
|
||||
test_bgl_OFF_with_np<OMesh>();
|
||||
#endif
|
||||
test_soup_off(filename);
|
||||
|
||||
// OBJ
|
||||
test_bgl_OBJ<Polyhedron>();
|
||||
|
|
@ -480,15 +548,34 @@ int main(int argc, char** argv)
|
|||
test_bgl_OBJ<OMesh>();
|
||||
#endif
|
||||
|
||||
test_bgl_OBJ_with_np<Polyhedron>();
|
||||
test_bgl_OBJ_with_np<SM>();
|
||||
test_bgl_OBJ_with_np<LCC>();
|
||||
#ifdef CGAL_USE_OPENMESH
|
||||
test_bgl_OBJ_with_np<OMesh>();
|
||||
#endif
|
||||
|
||||
|
||||
//PLY
|
||||
if(!test_PLY<Polyhedron>())
|
||||
if(!test_bgl_PLY<Polyhedron>())
|
||||
return 1;
|
||||
if(!test_PLY<Polyhedron>(true))
|
||||
if(!test_bgl_PLY<Polyhedron>(true))
|
||||
return 1;
|
||||
if(!test_PLY<SM>())
|
||||
if(!test_bgl_PLY<SM>())
|
||||
return 1;
|
||||
if(!test_PLY<SM>(true))
|
||||
if(!test_bgl_PLY<SM>(true))
|
||||
return 1;
|
||||
|
||||
if(!test_bgl_PLY_with_np<Polyhedron>(false))
|
||||
return 1;
|
||||
if(!test_bgl_PLY_with_np<Polyhedron>(true))
|
||||
return 1;
|
||||
if(!test_bgl_PLY_with_np<SM>(false))
|
||||
return 1;
|
||||
if(!test_bgl_PLY_with_np<SM>(true))
|
||||
return 1;
|
||||
|
||||
*/
|
||||
// GOCAD
|
||||
if(!test_gocad<Polyhedron>())
|
||||
return 1;
|
||||
|
|
@ -498,8 +585,7 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
if(!test_soup_gocad())
|
||||
return 1;
|
||||
|
||||
|
||||
/*
|
||||
// STL
|
||||
if(!test_STL<Polyhedron>())
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -90,10 +90,7 @@ void Polyhedron_scan_OFF<HDS>:: operator()(HDS& target)
|
|||
Color c;
|
||||
file_scan_color(scanner, c);
|
||||
}
|
||||
else
|
||||
{
|
||||
scanner.skip_to_next_vertex(i);
|
||||
}
|
||||
}
|
||||
|
||||
if(!m_in || B.error())
|
||||
|
|
|
|||
|
|
@ -86,7 +86,9 @@ bool read_OBJ(std::istream& is,
|
|||
}
|
||||
else if(line[0] == 'v' && line[1] == 'n' && line[2] == ' ')
|
||||
{
|
||||
std::istringstream iss(line.substr(1));
|
||||
std::istringstream iss(line);
|
||||
std::string dummy;
|
||||
iss >> dummy;
|
||||
double nx, ny, nz; // @fixme double?
|
||||
if(iss >> nx >> ny >> nz)
|
||||
*vn_out++ = Normal(nx, ny, nz); // @fixme check that every vertex has a normal?
|
||||
|
|
|
|||
|
|
@ -150,23 +150,6 @@ bool read_OFF(std::istream& is,
|
|||
} // namespace internal
|
||||
} // namespace IO
|
||||
|
||||
/*!
|
||||
* \ingroup IOstreamFunctions
|
||||
*
|
||||
* reads the content of `is` into `points` and `polygons`, in the OFF format.
|
||||
*
|
||||
* \cgalNamedParamsBegin
|
||||
\cgalParamBegin{vertex_normal_map} the property map with the normals associated to the vertices of `g`.\cgalParamEnd
|
||||
|
||||
\cgalParamBegin{vertex_color_map} the property map with the colors associated to the vertices of `g`.\cgalParamEnd
|
||||
|
||||
\cgalParamBegin{vertex_texture_map} the property map with the textures associated to the vertices of `g`.\cgalParamEnd
|
||||
|
||||
\cgalParamBegin{face_color_map} the property map with the colors associated to the faces of `g`.\cgalParamEnd
|
||||
\cgalNamedParamsEnd
|
||||
*
|
||||
* \see \ref IOStreamOFF
|
||||
*/
|
||||
template <typename PointRange, typename PolygonRange, typename NamedParameters>
|
||||
bool read_OFF(std::istream& is,
|
||||
PointRange& points,
|
||||
|
|
@ -187,23 +170,6 @@ bool read_OFF(std::istream& is,
|
|||
CGAL::Emptyset_iterator()));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup IOstreamFunctions
|
||||
*
|
||||
* reads the content of the file `fname` into `points` and `polygons`, in the OFF format.
|
||||
*
|
||||
* * \cgalNamedParamsBegin
|
||||
\cgalParamBegin{vertex_normal_map} the property map with the normals associated to the vertices of `g`.\cgalParamEnd
|
||||
|
||||
\cgalParamBegin{vertex_color_map} the property map with the colors associated to the vertices of `g`.\cgalParamEnd
|
||||
|
||||
\cgalParamBegin{vertex_texture_map} the property map with the textures associated to the vertices of `g`.\cgalParamEnd
|
||||
|
||||
\cgalParamBegin{face_color_map} the property map with the colors associated to the faces of `g`.\cgalParamEnd
|
||||
\cgalNamedParamsEnd
|
||||
*
|
||||
* \see \ref IOStreamOFF
|
||||
*/
|
||||
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_OFF(const char* fname,
|
||||
PointRange& points,
|
||||
|
|
@ -220,12 +186,28 @@ bool read_OFF(const std::string& fname, PointRange& points, PolygonRange& polygo
|
|||
return read_OFF(fname.c_str(), points, polygons, np);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup IOstreamFunctions
|
||||
*
|
||||
* reads the content of `is` into `points` and `polygons`, in the OFF format.
|
||||
*
|
||||
*
|
||||
* \see \ref IOStreamOFF
|
||||
*/
|
||||
template <typename PointRange, typename PolygonRange>
|
||||
bool read_OFF(std::istream& is, PointRange& points, PolygonRange& polygons)
|
||||
{
|
||||
return read_OFF(is, points, polygons, parameters::all_default());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup IOstreamFunctions
|
||||
*
|
||||
* reads the content of the file `fname` into `points` and `polygons`, in the OFF format.
|
||||
*
|
||||
*
|
||||
* \see \ref IOStreamOFF
|
||||
*/
|
||||
template <typename PointRange, typename PolygonRange>
|
||||
bool read_OFF(const char* fname, PointRange& points, PolygonRange& polygons)
|
||||
{
|
||||
|
|
@ -242,13 +224,7 @@ bool read_OFF(const std::string& fname, PointRange& points, PolygonRange& polygo
|
|||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Write
|
||||
|
||||
/*!
|
||||
* \ingroup IOstreamFunctions
|
||||
*
|
||||
* writes the content of `points` and `polygons` in `out`, in the OFF format.
|
||||
*
|
||||
* \see \ref IOStreamOFF
|
||||
*/
|
||||
|
||||
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_OFF(std::ostream& os,
|
||||
const PointRange& points,
|
||||
|
|
@ -259,6 +235,13 @@ bool write_OFF(std::ostream& os,
|
|||
return writer(points, polygons);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup IOstreamFunctions
|
||||
*
|
||||
* writes the content of `points` and `polygons` in `out`, in the OFF format.
|
||||
*
|
||||
* \see \ref IOStreamOFF
|
||||
*/
|
||||
template <typename PointRange, typename PolygonRange>
|
||||
bool write_OFF(std::ostream& os,
|
||||
const PointRange& points,
|
||||
|
|
@ -267,13 +250,6 @@ bool write_OFF(std::ostream& os,
|
|||
return write_OFF(os, points, polygons, parameters::all_default());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup IOstreamFunctions
|
||||
*
|
||||
* writes the content of `points` and `polygons` in the file `fname`, in the OFF format.
|
||||
*
|
||||
* \see \ref IOStreamOFF
|
||||
*/
|
||||
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_OFF(const char* fname,
|
||||
const PointRange& points,
|
||||
|
|
@ -285,6 +261,13 @@ bool write_OFF(const char* fname,
|
|||
return writer(points, polygons, np);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup IOstreamFunctions
|
||||
*
|
||||
* writes the content of `points` and `polygons` in the file `fname`, in the OFF format.
|
||||
*
|
||||
* \see \ref IOStreamOFF
|
||||
*/
|
||||
template <typename PointRange, typename PolygonRange>
|
||||
bool write_OFF(const char* fname,
|
||||
const PointRange& points,
|
||||
|
|
|
|||
Loading…
Reference in New Issue