mirror of https://github.com/CGAL/cgal
fix color and texture reading in OFF
This commit is contained in:
parent
5679c42ce8
commit
55361fe782
|
|
@ -0,0 +1,12 @@
|
||||||
|
STCNOFF
|
||||||
|
4 4 0
|
||||||
|
|
||||||
|
0 0 0 -1 0 0 255 0 0 0 0
|
||||||
|
1 0 0 1 0 0 0 255 0 1 0
|
||||||
|
0 1 0 0 1 0 0 0 255 0.5 0.5
|
||||||
|
0 0 1 0 0 1 255 0 0 1 1
|
||||||
|
|
||||||
|
3 0 1 2 255 0 0
|
||||||
|
3 3 1 0 0 255 0
|
||||||
|
3 3 2 1 0 0 255
|
||||||
|
3 3 0 2 255 0 255
|
||||||
|
|
@ -74,7 +74,7 @@ void fill_soup(PointRange& points, PolygonRange& polygons)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Mesh>
|
template<typename Mesh>
|
||||||
void test_bgl_read_write(const char* filename)
|
void test_bgl_OFF(const char* filename)
|
||||||
{
|
{
|
||||||
Mesh sm;
|
Mesh sm;
|
||||||
std::ifstream in(filename);
|
std::ifstream in(filename);
|
||||||
|
|
@ -82,7 +82,39 @@ void test_bgl_read_write(const char* filename)
|
||||||
CGAL::write_OFF(std::cout, sm);
|
CGAL::write_OFF(std::cout, sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_bgl_soup_off(const char* filename)
|
//todo check the result.
|
||||||
|
template<typename Mesh>
|
||||||
|
void test_bgl_NCSTOFF()
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
|
typedef typename boost::property_map<Mesh, CGAL::dynamic_vertex_property_t<CGAL::Color> >::type VertexColorMap;
|
||||||
|
VertexColorMap vcm = get(CGAL::dynamic_vertex_property_t<CGAL::Color>(), fg);
|
||||||
|
|
||||||
|
typedef typename boost::property_map<Mesh, CGAL::dynamic_vertex_property_t<Kernel::Point_2> >::type VertexTextureMap;
|
||||||
|
VertexTextureMap vtm = get(CGAL::dynamic_vertex_property_t<Kernel::Point_2>(), fg);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
ok = CGAL::write_OFF(std::cout, fg, CGAL::parameters::vertex_normal_map(vnm)
|
||||||
|
.vertex_color_map(vcm)
|
||||||
|
.vertex_texture_map(vtm)
|
||||||
|
.face_color_map(fcm));
|
||||||
|
CGAL_assertion(ok);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_soup_off(const char* filename)
|
||||||
{
|
{
|
||||||
std::vector<Point> points;
|
std::vector<Point> points;
|
||||||
std::vector<std::vector<std::size_t> > polygons;
|
std::vector<std::vector<std::size_t> > polygons;
|
||||||
|
|
@ -421,17 +453,24 @@ bool test_PLY(bool binary = false)
|
||||||
//todo tests with all NPs and without NP for all tests
|
//todo tests with all NPs and without NP for all tests
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
/* const char* filename=(argc>1) ? argv[1] : "data/prim.off";
|
const char* filename=(argc>1) ? argv[1] : "data/prim.off";
|
||||||
// OFF
|
// OFF
|
||||||
test_bgl_read_write<Polyhedron>(filename);
|
test_bgl_OFF<Polyhedron>(filename);
|
||||||
test_bgl_read_write<SM>(filename);
|
test_bgl_OFF<SM>(filename);
|
||||||
test_bgl_read_write<LCC>(filename);
|
test_bgl_OFF<LCC>(filename);
|
||||||
test_bgl_soup_off(filename);
|
|
||||||
#ifdef CGAL_USE_OPENMESH
|
#ifdef CGAL_USE_OPENMESH
|
||||||
test_bgl_read_write<OMesh>(filename);
|
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
|
#endif
|
||||||
*/
|
/* test_soup_off(filename);
|
||||||
|
|
||||||
// OBJ
|
// OBJ
|
||||||
test_bgl_OBJ<Polyhedron>();
|
test_bgl_OBJ<Polyhedron>();
|
||||||
test_bgl_OBJ<SM>();
|
test_bgl_OBJ<SM>();
|
||||||
|
|
@ -441,7 +480,6 @@ int main(int argc, char** argv)
|
||||||
test_bgl_OBJ<OMesh>();
|
test_bgl_OBJ<OMesh>();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
//PLY
|
//PLY
|
||||||
if(!test_PLY<Polyhedron>())
|
if(!test_PLY<Polyhedron>())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
#include <CGAL/boost/graph/properties.h>
|
#include <CGAL/boost/graph/properties.h>
|
||||||
#include <CGAL/Linear_cell_complex_for_combinatorial_map.h>
|
#include <CGAL/Linear_cell_complex_for_combinatorial_map.h>
|
||||||
#include <CGAL/Unique_hash_map.h>
|
#include <CGAL/Unique_hash_map.h>
|
||||||
|
#include <CGAL/Dynamic_property_map.h>
|
||||||
|
|
||||||
|
|
||||||
#define CGAL_LCC_ARGS unsigned int d_, unsigned int ambient_dim, \
|
#define CGAL_LCC_ARGS unsigned int d_, unsigned int ambient_dim, \
|
||||||
|
|
@ -185,7 +186,6 @@ struct LCC_property_map<edge_external_index_t>
|
||||||
typedef type const_type;
|
typedef type const_type;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct LCC_property_map<halfedge_external_index_t>
|
struct LCC_property_map<halfedge_external_index_t>
|
||||||
{
|
{
|
||||||
|
|
@ -197,8 +197,6 @@ struct LCC_property_map<halfedge_external_index_t>
|
||||||
typedef type const_type;
|
typedef type const_type;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct LCC_property_map<vertex_external_index_t>
|
struct LCC_property_map<vertex_external_index_t>
|
||||||
{
|
{
|
||||||
|
|
@ -210,7 +208,6 @@ struct LCC_property_map<vertex_external_index_t>
|
||||||
typedef type const_type;
|
typedef type const_type;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct LCC_property_map<face_external_index_t>
|
struct LCC_property_map<face_external_index_t>
|
||||||
{
|
{
|
||||||
|
|
@ -237,7 +234,6 @@ get(boost::halfedge_external_index_t, CGAL_LCC_TYPE const&)
|
||||||
return typename boost::property_map<CGAL_LCC_TYPE, boost::halfedge_external_index_t>::
|
return typename boost::property_map<CGAL_LCC_TYPE, boost::halfedge_external_index_t>::
|
||||||
const_type(halfedges(ncmap).begin(), halfedges(ncmap).end(), num_halfedges(ncmap));
|
const_type(halfedges(ncmap).begin(), halfedges(ncmap).end(), num_halfedges(ncmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<CGAL_LCC_ARGS>
|
template<CGAL_LCC_ARGS>
|
||||||
typename boost::property_map<CGAL_LCC_TYPE, boost::vertex_external_index_t >::const_type
|
typename boost::property_map<CGAL_LCC_TYPE, boost::vertex_external_index_t >::const_type
|
||||||
get(boost::vertex_external_index_t, CGAL_LCC_TYPE const&)
|
get(boost::vertex_external_index_t, CGAL_LCC_TYPE const&)
|
||||||
|
|
@ -246,7 +242,6 @@ get(boost::vertex_external_index_t, CGAL_LCC_TYPE const&)
|
||||||
return typename boost::property_map<CGAL_LCC_TYPE, boost::vertex_external_index_t>::
|
return typename boost::property_map<CGAL_LCC_TYPE, boost::vertex_external_index_t>::
|
||||||
const_type(vertices(ncmap).begin(), vertices(ncmap).end(), num_vertices(ncmap));
|
const_type(vertices(ncmap).begin(), vertices(ncmap).end(), num_vertices(ncmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<CGAL_LCC_ARGS>
|
template<CGAL_LCC_ARGS>
|
||||||
typename boost::property_map<CGAL_LCC_TYPE, boost::edge_external_index_t >::const_type
|
typename boost::property_map<CGAL_LCC_TYPE, boost::edge_external_index_t >::const_type
|
||||||
get(boost::edge_external_index_t, CGAL_LCC_TYPE const&)
|
get(boost::edge_external_index_t, CGAL_LCC_TYPE const&)
|
||||||
|
|
@ -254,7 +249,6 @@ get(boost::edge_external_index_t, CGAL_LCC_TYPE const&)
|
||||||
return typename boost::property_map<CGAL_LCC_TYPE, boost::edge_external_index_t>::
|
return typename boost::property_map<CGAL_LCC_TYPE, boost::edge_external_index_t>::
|
||||||
const_type(const_cast<CGAL_LCC_TYPE&>(cmap));
|
const_type(const_cast<CGAL_LCC_TYPE&>(cmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<CGAL_LCC_ARGS>
|
template<CGAL_LCC_ARGS>
|
||||||
typename boost::property_map<CGAL_LCC_TYPE, boost::face_external_index_t >::const_type
|
typename boost::property_map<CGAL_LCC_TYPE, boost::face_external_index_t >::const_type
|
||||||
get(boost::face_external_index_t, CGAL_LCC_TYPE const&)
|
get(boost::face_external_index_t, CGAL_LCC_TYPE const&)
|
||||||
|
|
@ -273,7 +267,6 @@ get(boost::edge_index_t, CGAL_LCC_TYPE const& cmap)
|
||||||
return typename boost::property_map<CGAL_LCC_TYPE,boost::edge_index_t>::
|
return typename boost::property_map<CGAL_LCC_TYPE,boost::edge_index_t>::
|
||||||
const_type(const_cast<CGAL_LCC_TYPE&>(cmap));
|
const_type(const_cast<CGAL_LCC_TYPE&>(cmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<CGAL_LCC_ARGS>
|
template<CGAL_LCC_ARGS>
|
||||||
typename boost::property_map<CGAL_LCC_TYPE, boost::halfedge_index_t >::const_type
|
typename boost::property_map<CGAL_LCC_TYPE, boost::halfedge_index_t >::const_type
|
||||||
get(boost::halfedge_index_t, CGAL_LCC_TYPE const& cmap)
|
get(boost::halfedge_index_t, CGAL_LCC_TYPE const& cmap)
|
||||||
|
|
@ -281,7 +274,6 @@ get(boost::halfedge_index_t, CGAL_LCC_TYPE const& cmap)
|
||||||
return typename boost::property_map<CGAL_LCC_TYPE,boost::halfedge_index_t>::
|
return typename boost::property_map<CGAL_LCC_TYPE,boost::halfedge_index_t>::
|
||||||
const_type(const_cast<CGAL_LCC_TYPE&>(cmap));
|
const_type(const_cast<CGAL_LCC_TYPE&>(cmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<CGAL_LCC_ARGS>
|
template<CGAL_LCC_ARGS>
|
||||||
typename boost::property_map<CGAL_LCC_TYPE, boost::vertex_index_t >::const_type
|
typename boost::property_map<CGAL_LCC_TYPE, boost::vertex_index_t >::const_type
|
||||||
get(boost::vertex_index_t, CGAL_LCC_TYPE const& cmap)
|
get(boost::vertex_index_t, CGAL_LCC_TYPE const& cmap)
|
||||||
|
|
@ -289,7 +281,6 @@ get(boost::vertex_index_t, CGAL_LCC_TYPE const& cmap)
|
||||||
return typename boost::property_map<CGAL_LCC_TYPE,boost::vertex_index_t>::
|
return typename boost::property_map<CGAL_LCC_TYPE,boost::vertex_index_t>::
|
||||||
const_type(const_cast<CGAL_LCC_TYPE&>(cmap));
|
const_type(const_cast<CGAL_LCC_TYPE&>(cmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<CGAL_LCC_ARGS>
|
template<CGAL_LCC_ARGS>
|
||||||
typename boost::property_map<CGAL_LCC_TYPE, boost::face_index_t >::const_type
|
typename boost::property_map<CGAL_LCC_TYPE, boost::face_index_t >::const_type
|
||||||
get(boost::face_index_t, CGAL_LCC_TYPE const& cmap)
|
get(boost::face_index_t, CGAL_LCC_TYPE const& cmap)
|
||||||
|
|
@ -297,7 +288,6 @@ get(boost::face_index_t, CGAL_LCC_TYPE const& cmap)
|
||||||
return typename boost::property_map<CGAL_LCC_TYPE,boost::face_index_t>::
|
return typename boost::property_map<CGAL_LCC_TYPE,boost::face_index_t>::
|
||||||
const_type(const_cast<CGAL_LCC_TYPE&>(cmap));
|
const_type(const_cast<CGAL_LCC_TYPE&>(cmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*template<CGAL_LCC_ARGS>
|
/*template<CGAL_LCC_ARGS>
|
||||||
|
|
@ -326,7 +316,6 @@ get(boost::halfedge_external_index_t, CGAL_LCC_TYPE&)
|
||||||
return typename boost::property_map<CGAL_LCC_TYPE, boost::halfedge_external_index_t>::
|
return typename boost::property_map<CGAL_LCC_TYPE, boost::halfedge_external_index_t>::
|
||||||
type(halfedges(cmap).begin(), halfedges(cmap).end(), num_halfedges(cmap));
|
type(halfedges(cmap).begin(), halfedges(cmap).end(), num_halfedges(cmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<CGAL_LCC_ARGS>
|
template<CGAL_LCC_ARGS>
|
||||||
typename boost::property_map<CGAL_LCC_TYPE, boost::vertex_external_index_t >::type
|
typename boost::property_map<CGAL_LCC_TYPE, boost::vertex_external_index_t >::type
|
||||||
get(boost::vertex_external_index_t, CGAL_LCC_TYPE&)
|
get(boost::vertex_external_index_t, CGAL_LCC_TYPE&)
|
||||||
|
|
@ -334,7 +323,6 @@ get(boost::vertex_external_index_t, CGAL_LCC_TYPE&)
|
||||||
return typename boost::property_map<CGAL_LCC_TYPE, boost::vertex_external_index_t>::
|
return typename boost::property_map<CGAL_LCC_TYPE, boost::vertex_external_index_t>::
|
||||||
type(vertices(cmap).begin(), vertices(cmap).end(), num_vertices(cmap));
|
type(vertices(cmap).begin(), vertices(cmap).end(), num_vertices(cmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<CGAL_LCC_ARGS>
|
template<CGAL_LCC_ARGS>
|
||||||
typename boost::property_map<CGAL_LCC_TYPE, boost::edge_external_index_t >::type
|
typename boost::property_map<CGAL_LCC_TYPE, boost::edge_external_index_t >::type
|
||||||
get(boost::edge_external_index_t, CGAL_LCC_TYPE& cmap)
|
get(boost::edge_external_index_t, CGAL_LCC_TYPE& cmap)
|
||||||
|
|
@ -342,8 +330,6 @@ get(boost::edge_external_index_t, CGAL_LCC_TYPE& cmap)
|
||||||
return typename boost::property_map<CGAL_LCC_TYPE, boost::edge_external_index_t>::
|
return typename boost::property_map<CGAL_LCC_TYPE, boost::edge_external_index_t>::
|
||||||
type(const_cast<CGAL_LCC_TYPE&>(cmap));
|
type(const_cast<CGAL_LCC_TYPE&>(cmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<CGAL_LCC_ARGS>
|
template<CGAL_LCC_ARGS>
|
||||||
typename boost::property_map<CGAL_LCC_TYPE, boost::face_external_index_t >::type
|
typename boost::property_map<CGAL_LCC_TYPE, boost::face_external_index_t >::type
|
||||||
get(boost::face_external_index_t, CGAL_LCC_TYPE&)
|
get(boost::face_external_index_t, CGAL_LCC_TYPE&)
|
||||||
|
|
@ -402,6 +388,76 @@ struct property_map<const CGAL_LCC_TYPE, Tag>
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
// dynamic property map ambiguity resolution
|
||||||
|
#define CGAL_LCC_DYNAMIC_PMAP_SPEC(TAG, DESC) \
|
||||||
|
namespace boost { \
|
||||||
|
template<unsigned int d_, unsigned int ambient_dim, \
|
||||||
|
class Traits_, \
|
||||||
|
class Items_, \
|
||||||
|
class Alloc_, \
|
||||||
|
template<unsigned int,class,class,class,class> \
|
||||||
|
class CMap, \
|
||||||
|
class Storage_,\
|
||||||
|
class T>\
|
||||||
|
struct property_map< \
|
||||||
|
CGAL::Linear_cell_complex_for_combinatorial_map<d_, ambient_dim, Traits_, Items_, Alloc_, CMap , Storage_>,\
|
||||||
|
TAG<T> > \
|
||||||
|
{\
|
||||||
|
typedef CGAL::Linear_cell_complex_for_combinatorial_map\
|
||||||
|
<d_, ambient_dim, Traits_, Items_, Alloc_, CMap , Storage_> LCC;\
|
||||||
|
typedef typename boost::graph_traits<LCC>::DESC DESC;\
|
||||||
|
typedef CGAL::internal::Dynamic_property_map<DESC,T> type;\
|
||||||
|
typedef type const_type;\
|
||||||
|
};\
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
namespace CGAL { \
|
||||||
|
template <unsigned int d_, unsigned int ambient_dim, \
|
||||||
|
class Traits_, \
|
||||||
|
class Items_, \
|
||||||
|
class Alloc_, \
|
||||||
|
template<unsigned int,class,class,class,class> \
|
||||||
|
class CMap, \
|
||||||
|
class Storage_,\
|
||||||
|
class T> \
|
||||||
|
typename boost::property_map< \
|
||||||
|
Linear_cell_complex_for_combinatorial_map<d_, ambient_dim, Traits_, Items_, Alloc_, CMap , Storage_>, \
|
||||||
|
TAG<T> >::const_type \
|
||||||
|
get(TAG<T>, const Linear_cell_complex_for_combinatorial_map<d_, ambient_dim, Traits_, Items_, Alloc_, CMap , Storage_>&) \
|
||||||
|
{ \
|
||||||
|
typedef Linear_cell_complex_for_combinatorial_map<d_, ambient_dim, Traits_, Items_, Alloc_, CMap , Storage_> LCC;\
|
||||||
|
typedef typename boost::graph_traits<LCC>::DESC DESC; \
|
||||||
|
return internal::Dynamic_property_map<DESC,T>();\
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
template <unsigned int d_, unsigned int ambient_dim, \
|
||||||
|
class Traits_, \
|
||||||
|
class Items_, \
|
||||||
|
class Alloc_, \
|
||||||
|
template<unsigned int,class,class,class,class> \
|
||||||
|
class CMap, \
|
||||||
|
class Storage_,\
|
||||||
|
class T> \
|
||||||
|
typename boost::property_map< \
|
||||||
|
Linear_cell_complex_for_combinatorial_map<d_, ambient_dim, Traits_, Items_, Alloc_, CMap , Storage_>, \
|
||||||
|
TAG<T> >::type \
|
||||||
|
get(TAG<T>, Linear_cell_complex_for_combinatorial_map<d_, ambient_dim, Traits_, Items_, Alloc_, CMap , Storage_>&) \
|
||||||
|
{ \
|
||||||
|
typedef Linear_cell_complex_for_combinatorial_map<d_, ambient_dim, Traits_, Items_, Alloc_, CMap , Storage_> LCC;\
|
||||||
|
typedef typename boost::graph_traits<LCC>::DESC DESC; \
|
||||||
|
return internal::Dynamic_property_map<DESC,T>();\
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_LCC_DYNAMIC_PMAP_SPEC(CGAL::dynamic_vertex_property_t, vertex_descriptor)
|
||||||
|
CGAL_LCC_DYNAMIC_PMAP_SPEC(CGAL::dynamic_halfedge_property_t, halfedge_descriptor)
|
||||||
|
CGAL_LCC_DYNAMIC_PMAP_SPEC(CGAL::dynamic_edge_property_t, edge_descriptor)
|
||||||
|
CGAL_LCC_DYNAMIC_PMAP_SPEC(CGAL::dynamic_face_property_t, face_descriptor)
|
||||||
|
|
||||||
|
#undef CGAL_LCC_DYNAMIC_PMAP_SPEC
|
||||||
|
|
||||||
|
|
||||||
|
#undef CGAL_NAME_LCC_ARGS
|
||||||
#undef CGAL_LCC_ARGS
|
#undef CGAL_LCC_ARGS
|
||||||
#undef CGAL_LCC_TYPE
|
#undef CGAL_LCC_TYPE
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,8 @@ bool read_OFF(std::istream& is,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return !is.fail();
|
bool res = !is.fail();
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,14 @@
|
||||||
// ETH Zurich (Switzerland),
|
// ETH Zurich (Switzerland),
|
||||||
// INRIA Sophia-Antipolis (France),
|
// INRIA Sophia-Antipolis (France),
|
||||||
// Max-Planck-Institute Saarbruecken (Germany),
|
// Max-Planck-Institute Saarbruecken (Germany),
|
||||||
// and Tel-Aviv University (Israel). All rights reserved.
|
// 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$
|
// $URL$
|
||||||
// $Id$
|
// $Id$
|
||||||
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
|
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||||
|
|
||||||
|
|
@ -247,14 +247,79 @@ public:
|
||||||
|
|
||||||
void scan_texture(float& x, float& y, float& w)
|
void scan_texture(float& x, float& y, float& w)
|
||||||
{
|
{
|
||||||
// @ todo
|
if(has_textures())
|
||||||
CGAL_assertion(false);
|
{
|
||||||
|
if(binary())
|
||||||
|
{
|
||||||
|
float fx, fy;
|
||||||
|
I_Binary_read_big_endian_float32(m_in, fx);
|
||||||
|
I_Binary_read_big_endian_float32(m_in, fy);
|
||||||
|
if(is_homogeneous())
|
||||||
|
{
|
||||||
|
float fw;
|
||||||
|
I_Binary_read_big_endian_float32(m_in, fw);
|
||||||
|
x = fx / fw;
|
||||||
|
y = fy / fw;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
x = fx;
|
||||||
|
y = fy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(is_homogeneous())
|
||||||
|
{
|
||||||
|
float fx, fy, fw;
|
||||||
|
m_in >> iformat(fx) >> iformat(fy) >> iformat(fw);
|
||||||
|
x = fx / fw;
|
||||||
|
y = fy / fw;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_in >> iformat(x) >> iformat(y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void scan_texture(double& x, double& y, double& w)
|
void scan_texture(double& x, double& y, double& w)
|
||||||
{
|
{
|
||||||
// @ todo
|
w=1;
|
||||||
CGAL_assertion(false);
|
if(has_textures())
|
||||||
|
{
|
||||||
|
if(binary())
|
||||||
|
{
|
||||||
|
float fx, fy;
|
||||||
|
I_Binary_read_big_endian_float32(m_in, fx);
|
||||||
|
I_Binary_read_big_endian_float32(m_in, fy);
|
||||||
|
if(is_homogeneous())
|
||||||
|
{
|
||||||
|
float fw;
|
||||||
|
I_Binary_read_big_endian_float32(m_in, fw);
|
||||||
|
x = fx / fw;
|
||||||
|
y = fy / fw;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
x = fx;
|
||||||
|
y = fy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(is_homogeneous())
|
||||||
|
{
|
||||||
|
float fx, fy, fw;
|
||||||
|
m_in >> iformat(fx) >> iformat(fy) >> iformat(fw);
|
||||||
|
x = fx / fw;
|
||||||
|
y = fy / fw;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_in >> iformat(x) >> iformat(y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -635,6 +700,7 @@ public:
|
||||||
|
|
||||||
std::string col;
|
std::string col;
|
||||||
//get the line content
|
//get the line content
|
||||||
|
std::streampos position = is.tellg();
|
||||||
std::getline(is, col);
|
std::getline(is, col);
|
||||||
//split it into strings
|
//split it into strings
|
||||||
std::istringstream iss(col);
|
std::istringstream iss(col);
|
||||||
|
|
@ -663,6 +729,7 @@ public:
|
||||||
else
|
else
|
||||||
rgb[index] = static_cast<unsigned char>(atoi(color_info.c_str()));
|
rgb[index] = static_cast<unsigned char>(atoi(color_info.c_str()));
|
||||||
|
|
||||||
|
position += (color_info.length()+ index)*sizeof(char); //index indicates the number of whitespaces read.
|
||||||
++index;
|
++index;
|
||||||
if(index == 3)
|
if(index == 3)
|
||||||
break;
|
break;
|
||||||
|
|
@ -675,7 +742,7 @@ public:
|
||||||
//else create the coor with the 3 values;
|
//else create the coor with the 3 values;
|
||||||
else
|
else
|
||||||
color = CGAL::Color(rgb[0], rgb[1], rgb[2]);
|
color = CGAL::Color(rgb[0], rgb[1], rgb[2]);
|
||||||
|
is.seekg(position);
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue