Merge branch 'master' into remove_compile_order_check

This commit is contained in:
Jan Möbius
2020-06-24 09:28:35 +02:00
491 changed files with 39363 additions and 17798 deletions

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
@@ -82,6 +77,7 @@
#include <OpenMesh/Core/IO/writer/STLWriter.hh>
#include <OpenMesh/Core/IO/writer/OMWriter.hh>
#include <OpenMesh/Core/IO/writer/PLYWriter.hh>
#include <OpenMesh/Core/IO/writer/VTKWriter.hh>
//=== NAMESPACES ==============================================================
@@ -104,6 +100,7 @@ static BaseWriter* OFFWriterInstance = &OFFWriter();
static BaseWriter* STLWriterInstance = &STLWriter();
static BaseWriter* OMWriterInstance = &OMWriter();
static BaseWriter* PLYWriterInstance = &PLYWriter();
static BaseWriter* VTKWriterInstance = &VTKWriter();
//=============================================================================

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
@@ -263,7 +258,7 @@ find_writer(const std::string& _format)
if ((*it)->can_u_write(filename))
return *it;
return NULL;
return nullptr;
}

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
//
@@ -152,7 +147,7 @@ public:
bool write(const std::string& _filename,
BaseExporter& _be,
Options _opt=Options::Default,
std::streamsize _precision = 6);
std::streamsize _precision = 6);
/** Write a mesh to open std::ostream _os. The source data structure is specified
by the given BaseExporter. The \c save method consecutively queries all
@@ -164,7 +159,7 @@ public:
const std::string& _ext,
BaseExporter& _be,
Options _opt=Options::Default,
std::streamsize _precision = 6);
std::streamsize _precision = 6);
/// Returns true if the format is supported by one of the reader modules.

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
#ifndef OM_MESHIO_HH

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
#ifndef OPENMESH_IO_OFFFORMAT_HH

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
@@ -113,6 +108,19 @@ namespace OMFormat {
return hdr;
}
//-----------------------------------------------------------------------------
std::string as_string(uint8 version)
{
std::stringstream ss;
ss << major_version(version);
ss << ".";
ss << minor_version(version);
return ss.str();
}
//-----------------------------------------------------------------------------
const char *as_string(Chunk::Entity e)
@@ -127,7 +135,7 @@ namespace OMFormat {
default:
std::clog << "as_string(Chunk::Entity): Invalid value!";
}
return NULL;
return nullptr;
}
@@ -145,7 +153,7 @@ namespace OMFormat {
case Chunk::Type_Custom: return "Custom";
case Chunk::Type_Topology: return "Topology";
}
return NULL;
return nullptr;
}
@@ -164,7 +172,7 @@ namespace OMFormat {
case Chunk::Dim_7D: return "7D";
case Chunk::Dim_8D: return "8D";
}
return NULL;
return nullptr;
}
@@ -179,7 +187,7 @@ namespace OMFormat {
case Chunk::Integer_32 : return "32";
case Chunk::Integer_64 : return "64";
}
return NULL;
return nullptr;
}
const char *as_string(Chunk::Float_Size d)
@@ -190,7 +198,7 @@ namespace OMFormat {
case Chunk::Float_64 : return "64";
case Chunk::Float_128: return "128";
}
return NULL;
return nullptr;
}
@@ -238,6 +246,9 @@ namespace OMFormat {
}
//-----------------------------------------------------------------------------
} // namespace OMFormat
// --------------------------------------------------------------------------

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
#ifndef OPENMESH_IO_OMFORMAT_HH
@@ -257,7 +252,7 @@ namespace OMFormat {
PropertyName( ) { }
PropertyName( const std::string& _name ) { *this = _name; }
explicit PropertyName( const std::string& _name ) { *this = _name; }
bool is_valid() const { return is_valid( size() ); }
@@ -294,7 +289,7 @@ namespace OMFormat {
inline size_t chunk_header_size( void ) { return sizeof(uint16); }
/// Return the size of a scale in bytes.
/// Return the size of a scaler in bytes.
inline size_t scalar_size( const Chunk::Header& _hdr )
{
return _hdr.float_ ? (0x01 << _hdr.bits_) : (0x04 << _hdr.bits_);
@@ -355,6 +350,16 @@ namespace OMFormat {
#endif
}
template <typename T> bool is_double(const T&)
{
return false;
}
template <> inline bool is_double(const double&)
{
return true;
}
template <typename T> bool is_integer(const T)
{
#if defined(OM_MISSING_HEADER_LIMITS)
@@ -469,6 +474,8 @@ namespace OMFormat {
// ---------------------------------------- convenience functions
std::string as_string(uint8 version);
const char *as_string(Chunk::Type t);
const char *as_string(Chunk::Entity e);
const char *as_string(Chunk::Dim d);
@@ -744,7 +751,7 @@ namespace OMFormat {
//=============================================================================
#if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_IO_OMFORMAT_CC)
# define OPENMESH_IO_OMFORMAT_TEMPLATES
# include "OMFormatT.cc"
# include "OMFormatT_impl.hh"
#endif
//=============================================================================
#endif

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
#ifndef OPENMESH_IO_OPTIONS_HH
@@ -115,7 +110,8 @@ public:
FaceTexCoord = 0x0400, ///< Has (r) / store (w) face texture coordinates
ColorAlpha = 0x0800, ///< Has (r) / store (w) alpha values for colors
ColorFloat = 0x1000, ///< Has (r) / store (w) float values for colors (currently only implemented for PLY and OFF files)
Custom = 0x2000 ///< Has (r) custom properties (currently only implemented in PLY Reader ASCII version)
Custom = 0x2000, ///< Has (r) custom properties (currently only implemented in PLY Reader ASCII version)
Status = 0x4000 ///< Has (r) / store (w) status properties
};
public:
@@ -206,10 +202,14 @@ public:
bool vertex_has_normal() const { return check(VertexNormal); }
bool vertex_has_color() const { return check(VertexColor); }
bool vertex_has_texcoord() const { return check(VertexTexCoord); }
bool vertex_has_status() const { return check(Status); }
bool edge_has_color() const { return check(EdgeColor); }
bool edge_has_status() const { return check(Status); }
bool halfedge_has_status() const { return check(Status); }
bool face_has_normal() const { return check(FaceNormal); }
bool face_has_color() const { return check(FaceColor); }
bool face_has_texcoord() const { return check(FaceTexCoord); }
bool face_has_status() const { return check(Status); }
bool color_has_alpha() const { return check(ColorAlpha); }
bool color_is_float() const { return check(ColorFloat); }

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
@@ -95,21 +90,27 @@ public:
// get vertex data
virtual Vec3f point(VertexHandle _vh) const = 0;
virtual Vec3d pointd(VertexHandle _vh) const = 0;
virtual bool is_point_double() const = 0;
virtual Vec3f normal(VertexHandle _vh) const = 0;
virtual Vec3d normald(VertexHandle _vh) const = 0;
virtual bool is_normal_double() const = 0;
virtual Vec3uc color(VertexHandle _vh) const = 0;
virtual Vec4uc colorA(VertexHandle _vh) const = 0;
virtual Vec3ui colori(VertexHandle _vh) const = 0;
virtual Vec4ui colorAi(VertexHandle _vh) const = 0;
virtual Vec3ui colori(VertexHandle _vh) const = 0;
virtual Vec4ui colorAi(VertexHandle _vh) const = 0;
virtual Vec3f colorf(VertexHandle _vh) const = 0;
virtual Vec4f colorAf(VertexHandle _vh) const = 0;
virtual Vec2f texcoord(VertexHandle _vh) const = 0;
virtual Vec2f texcoord(HalfedgeHandle _heh) const = 0;
virtual OpenMesh::Attributes::StatusInfo status(VertexHandle _vh) const = 0;
// get face data
virtual unsigned int
get_vhandles(FaceHandle _fh,
std::vector<VertexHandle>& _vhandles) const=0;
///
/// \brief getHeh returns the HalfEdgeHandle that belongs to the face
/// specified by _fh and has a toVertexHandle that corresponds to _vh.
@@ -121,12 +122,14 @@ public:
virtual unsigned int
get_face_texcoords(std::vector<Vec2f>& _hehandles) const = 0;
virtual Vec3f normal(FaceHandle _fh) const = 0;
virtual Vec3d normald(FaceHandle _fh) const = 0;
virtual Vec3uc color (FaceHandle _fh) const = 0;
virtual Vec4uc colorA(FaceHandle _fh) const = 0;
virtual Vec3ui colori(FaceHandle _fh) const = 0;
virtual Vec4ui colorAi(FaceHandle _fh) const = 0;
virtual Vec3f colorf(FaceHandle _fh) const = 0;
virtual Vec4f colorAf(FaceHandle _fh) const = 0;
virtual OpenMesh::Attributes::StatusInfo status(FaceHandle _fh) const = 0;
// get edge data
virtual Vec3uc color(EdgeHandle _eh) const = 0;
@@ -135,9 +138,18 @@ public:
virtual Vec4ui colorAi(EdgeHandle _eh) const = 0;
virtual Vec3f colorf(EdgeHandle _eh) const = 0;
virtual Vec4f colorAf(EdgeHandle _eh) const = 0;
virtual OpenMesh::Attributes::StatusInfo status(EdgeHandle _eh) const = 0;
// get halfedge data
virtual int get_halfedge_id(VertexHandle _vh) = 0;
virtual int get_halfedge_id(FaceHandle _vh) = 0;
virtual int get_next_halfedge_id(HalfedgeHandle _heh) = 0;
virtual int get_to_vertex_id(HalfedgeHandle _heh) = 0;
virtual int get_face_id(HalfedgeHandle _heh) = 0;
virtual OpenMesh::Attributes::StatusInfo status(HalfedgeHandle _heh) const = 0;
// get reference to base kernel
virtual const BaseKernel* kernel() { return 0; }
virtual const BaseKernel* kernel() { return nullptr; }
// query number of faces, vertices, normals, texcoords
@@ -150,10 +162,14 @@ public:
virtual bool is_triangle_mesh() const { return false; }
virtual bool has_vertex_normals() const { return false; }
virtual bool has_vertex_colors() const { return false; }
virtual bool has_vertex_status() const { return false; }
virtual bool has_vertex_texcoords() const { return false; }
virtual bool has_edge_colors() const { return false; }
virtual bool has_edge_status() const { return false; }
virtual bool has_halfedge_status() const { return false; }
virtual bool has_face_normals() const { return false; }
virtual bool has_face_colors() const { return false; }
virtual bool has_face_status() const { return false; }
};

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
@@ -70,6 +65,7 @@
#include <OpenMesh/Core/Utils/vector_cast.hh>
#include <OpenMesh/Core/Utils/color_cast.hh>
#include <OpenMesh/Core/IO/exporter/BaseExporter.hh>
#include <OpenMesh/Core/IO/OMFormat.hh>
//=== NAMESPACES ==============================================================
@@ -89,66 +85,88 @@ class ExporterT : public BaseExporter
public:
// Constructor
ExporterT(const Mesh& _mesh) : mesh_(_mesh) {}
explicit ExporterT(const Mesh& _mesh) : mesh_(_mesh) {}
// get vertex data
Vec3f point(VertexHandle _vh) const
Vec3f point(VertexHandle _vh) const override
{
return vector_cast<Vec3f>(mesh_.point(_vh));
}
Vec3f normal(VertexHandle _vh) const
Vec3d pointd(VertexHandle _vh) const override
{
return (mesh_.has_vertex_normals()
? vector_cast<Vec3f>(mesh_.normal(_vh))
: Vec3f(0.0f, 0.0f, 0.0f));
return vector_cast<Vec3d>(mesh_.point(_vh));
}
Vec3uc color(VertexHandle _vh) const
bool is_point_double() const override
{
return OMFormat::is_double(typename Mesh::Point()[0]);
}
bool is_normal_double() const override
{
return OMFormat::is_double(typename Mesh::Normal()[0]);
}
Vec3f normal(VertexHandle _vh) const override
{
return (mesh_.has_vertex_normals()
? vector_cast<Vec3f>(mesh_.normal(_vh))
: Vec3f(0.0f, 0.0f, 0.0f));
}
Vec3d normald(VertexHandle _vh) const override
{
return (mesh_.has_vertex_normals()
? vector_cast<Vec3d>(mesh_.normal(_vh))
: Vec3d(0.0f, 0.0f, 0.0f));
}
Vec3uc color(VertexHandle _vh) const override
{
return (mesh_.has_vertex_colors()
? color_cast<Vec3uc>(mesh_.color(_vh))
: Vec3uc(0, 0, 0));
}
Vec4uc colorA(VertexHandle _vh) const
Vec4uc colorA(VertexHandle _vh) const override
{
return (mesh_.has_vertex_colors()
? color_cast<Vec4uc>(mesh_.color(_vh))
: Vec4uc(0, 0, 0, 0));
}
Vec3ui colori(VertexHandle _vh) const
Vec3ui colori(VertexHandle _vh) const override
{
return (mesh_.has_vertex_colors()
? color_cast<Vec3ui>(mesh_.color(_vh))
: Vec3ui(0, 0, 0));
}
Vec4ui colorAi(VertexHandle _vh) const
Vec4ui colorAi(VertexHandle _vh) const override
{
return (mesh_.has_vertex_colors()
? color_cast<Vec4ui>(mesh_.color(_vh))
: Vec4ui(0, 0, 0, 0));
}
Vec3f colorf(VertexHandle _vh) const
Vec3f colorf(VertexHandle _vh) const override
{
return (mesh_.has_vertex_colors()
? color_cast<Vec3f>(mesh_.color(_vh))
: Vec3f(0, 0, 0));
}
Vec4f colorAf(VertexHandle _vh) const
Vec4f colorAf(VertexHandle _vh) const override
{
return (mesh_.has_vertex_colors()
? color_cast<Vec4f>(mesh_.color(_vh))
: Vec4f(0, 0, 0, 0));
}
Vec2f texcoord(VertexHandle _vh) const
Vec2f texcoord(VertexHandle _vh) const override
{
#if defined(OM_CC_GCC) && (OM_CC_VERSION<30000)
// Workaround!
@@ -164,61 +182,109 @@ public:
#endif
}
Vec2f texcoord(HalfedgeHandle _heh) const
Vec2f texcoord(HalfedgeHandle _heh) const override
{
return (mesh_.has_halfedge_texcoords2D()
? vector_cast<Vec2f>(mesh_.texcoord2D(_heh))
: Vec2f(0.0f, 0.0f));
}
OpenMesh::Attributes::StatusInfo status(VertexHandle _vh) const override
{
if (mesh_.has_vertex_status())
return mesh_.status(_vh);
return OpenMesh::Attributes::StatusInfo();
}
// get edge data
Vec3uc color(EdgeHandle _eh) const
Vec3uc color(EdgeHandle _eh) const override
{
return (mesh_.has_edge_colors()
? color_cast<Vec3uc>(mesh_.color(_eh))
: Vec3uc(0, 0, 0));
}
Vec4uc colorA(EdgeHandle _eh) const
Vec4uc colorA(EdgeHandle _eh) const override
{
return (mesh_.has_edge_colors()
? color_cast<Vec4uc>(mesh_.color(_eh))
: Vec4uc(0, 0, 0, 0));
}
Vec3ui colori(EdgeHandle _eh) const
Vec3ui colori(EdgeHandle _eh) const override
{
return (mesh_.has_edge_colors()
? color_cast<Vec3ui>(mesh_.color(_eh))
: Vec3ui(0, 0, 0));
}
Vec4ui colorAi(EdgeHandle _eh) const
Vec4ui colorAi(EdgeHandle _eh) const override
{
return (mesh_.has_edge_colors()
? color_cast<Vec4ui>(mesh_.color(_eh))
: Vec4ui(0, 0, 0, 0));
}
Vec3f colorf(EdgeHandle _eh) const
Vec3f colorf(EdgeHandle _eh) const override
{
return (mesh_.has_vertex_colors()
? color_cast<Vec3f>(mesh_.color(_eh))
: Vec3f(0, 0, 0));
}
Vec4f colorAf(EdgeHandle _eh) const
Vec4f colorAf(EdgeHandle _eh) const override
{
return (mesh_.has_vertex_colors()
? color_cast<Vec4f>(mesh_.color(_eh))
: Vec4f(0, 0, 0, 0));
}
OpenMesh::Attributes::StatusInfo status(EdgeHandle _eh) const override
{
if (mesh_.has_edge_status())
return mesh_.status(_eh);
return OpenMesh::Attributes::StatusInfo();
}
// get halfedge data
int get_halfedge_id(VertexHandle _vh) override
{
return mesh_.halfedge_handle(_vh).idx();
}
int get_halfedge_id(FaceHandle _fh) override
{
return mesh_.halfedge_handle(_fh).idx();
}
int get_next_halfedge_id(HalfedgeHandle _heh) override
{
return mesh_.next_halfedge_handle(_heh).idx();
}
int get_to_vertex_id(HalfedgeHandle _heh) override
{
return mesh_.to_vertex_handle(_heh).idx();
}
int get_face_id(HalfedgeHandle _heh) override
{
return mesh_.face_handle(_heh).idx();
}
OpenMesh::Attributes::StatusInfo status(HalfedgeHandle _heh) const override
{
if (mesh_.has_halfedge_status())
return mesh_.status(_heh);
return OpenMesh::Attributes::StatusInfo();
}
// get face data
unsigned int get_vhandles(FaceHandle _fh,
std::vector<VertexHandle>& _vhandles) const
std::vector<VertexHandle>& _vhandles) const override
{
unsigned int count(0);
_vhandles.clear();
@@ -230,7 +296,7 @@ public:
return count;
}
unsigned int get_face_texcoords(std::vector<Vec2f>& _hehandles) const
unsigned int get_face_texcoords(std::vector<Vec2f>& _hehandles) const override
{
unsigned int count(0);
_hehandles.clear();
@@ -244,7 +310,7 @@ public:
return count;
}
HalfedgeHandle getHeh(FaceHandle _fh, VertexHandle _vh) const
HalfedgeHandle getHeh(FaceHandle _fh, VertexHandle _vh) const override
{
typename Mesh::ConstFaceHalfedgeIter fh_it;
for(fh_it = mesh_.cfh_iter(_fh); fh_it.is_valid();++fh_it)
@@ -255,74 +321,92 @@ public:
return *fh_it;
}
Vec3f normal(FaceHandle _fh) const
Vec3f normal(FaceHandle _fh) const override
{
return (mesh_.has_face_normals()
? vector_cast<Vec3f>(mesh_.normal(_fh))
: Vec3f(0.0f, 0.0f, 0.0f));
}
Vec3uc color(FaceHandle _fh) const
Vec3d normald(FaceHandle _fh) const override
{
return (mesh_.has_face_normals()
? vector_cast<Vec3d>(mesh_.normal(_fh))
: Vec3d(0.0, 0.0, 0.0));
}
Vec3uc color(FaceHandle _fh) const override
{
return (mesh_.has_face_colors()
? color_cast<Vec3uc>(mesh_.color(_fh))
: Vec3uc(0, 0, 0));
}
Vec4uc colorA(FaceHandle _fh) const
Vec4uc colorA(FaceHandle _fh) const override
{
return (mesh_.has_face_colors()
? color_cast<Vec4uc>(mesh_.color(_fh))
: Vec4uc(0, 0, 0, 0));
}
Vec3ui colori(FaceHandle _fh) const
Vec3ui colori(FaceHandle _fh) const override
{
return (mesh_.has_face_colors()
? color_cast<Vec3ui>(mesh_.color(_fh))
: Vec3ui(0, 0, 0));
}
Vec4ui colorAi(FaceHandle _fh) const
Vec4ui colorAi(FaceHandle _fh) const override
{
return (mesh_.has_face_colors()
? color_cast<Vec4ui>(mesh_.color(_fh))
: Vec4ui(0, 0, 0, 0));
}
Vec3f colorf(FaceHandle _fh) const
Vec3f colorf(FaceHandle _fh) const override
{
return (mesh_.has_vertex_colors()
return (mesh_.has_face_colors()
? color_cast<Vec3f>(mesh_.color(_fh))
: Vec3f(0, 0, 0));
}
Vec4f colorAf(FaceHandle _fh) const
Vec4f colorAf(FaceHandle _fh) const override
{
return (mesh_.has_vertex_colors()
return (mesh_.has_face_colors()
? color_cast<Vec4f>(mesh_.color(_fh))
: Vec4f(0, 0, 0, 0));
}
virtual const BaseKernel* kernel() { return &mesh_; }
OpenMesh::Attributes::StatusInfo status(FaceHandle _fh) const override
{
if (mesh_.has_face_status())
return mesh_.status(_fh);
return OpenMesh::Attributes::StatusInfo();
}
virtual const BaseKernel* kernel() override { return &mesh_; }
// query number of faces, vertices, normals, texcoords
size_t n_vertices() const { return mesh_.n_vertices(); }
size_t n_faces() const { return mesh_.n_faces(); }
size_t n_edges() const { return mesh_.n_edges(); }
size_t n_vertices() const override { return mesh_.n_vertices(); }
size_t n_faces() const override { return mesh_.n_faces(); }
size_t n_edges() const override { return mesh_.n_edges(); }
// property information
bool is_triangle_mesh() const
bool is_triangle_mesh() const override
{ return Mesh::is_triangles(); }
bool has_vertex_normals() const { return mesh_.has_vertex_normals(); }
bool has_vertex_colors() const { return mesh_.has_vertex_colors(); }
bool has_vertex_texcoords() const { return mesh_.has_vertex_texcoords2D(); }
bool has_edge_colors() const { return mesh_.has_edge_colors(); }
bool has_face_normals() const { return mesh_.has_face_normals(); }
bool has_face_colors() const { return mesh_.has_face_colors(); }
bool has_vertex_normals() const override { return mesh_.has_vertex_normals(); }
bool has_vertex_colors() const override { return mesh_.has_vertex_colors(); }
bool has_vertex_texcoords() const override { return mesh_.has_vertex_texcoords2D(); }
bool has_vertex_status() const override { return mesh_.has_vertex_status(); }
bool has_edge_colors() const override { return mesh_.has_edge_colors(); }
bool has_edge_status() const override { return mesh_.has_edge_status(); }
bool has_halfedge_status() const override { return mesh_.has_halfedge_status(); }
bool has_face_normals() const override { return mesh_.has_face_normals(); }
bool has_face_colors() const override { return mesh_.has_face_colors(); }
bool has_face_status() const override { return mesh_.has_face_status(); }
private:

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
@@ -96,13 +91,22 @@ public:
// add a vertex with coordinate \c _point
virtual VertexHandle add_vertex(const Vec3f& _point) = 0;
// add a vertex with coordinate \c _point
virtual VertexHandle add_vertex(const Vec3d& _point) { return add_vertex(Vec3f(_point)); }
// add a vertex without coordinate. Use set_point to set the position deferred
virtual VertexHandle add_vertex() = 0;
// add an edge. Use set_next, set_vertex and set_face to set corresponding entities for halfedges
virtual HalfedgeHandle add_edge(VertexHandle _vh0, VertexHandle _vh1) = 0;
// add a face with indices _indices refering to vertices
typedef std::vector<VertexHandle> VHandles;
virtual FaceHandle add_face(const VHandles& _indices) = 0;
// add a face with incident halfedge
virtual FaceHandle add_face(HalfedgeHandle _heh) = 0;
// add texture coordinates per face, _vh references the first texcoord
virtual void add_face_texcoords( FaceHandle _fh, VertexHandle _vh, const std::vector<Vec2f>& _face_texcoords) = 0;
@@ -115,9 +119,15 @@ public:
// Set coordinate of the given vertex. Use this function, if you created a vertex without coordinate
virtual void set_point(VertexHandle _vh, const Vec3f& _point) = 0;
// Set outgoing halfedge for the given vertex.
virtual void set_halfedge(VertexHandle _vh, HalfedgeHandle _heh) = 0;
// set vertex normal
virtual void set_normal(VertexHandle _vh, const Vec3f& _normal) = 0;
// set vertex normal
virtual void set_normal(VertexHandle _vh, const Vec3d& _normal) = 0;
// set vertex color
virtual void set_color(VertexHandle _vh, const Vec3uc& _color) = 0;
@@ -133,6 +143,15 @@ public:
// set vertex texture coordinate
virtual void set_texcoord(VertexHandle _vh, const Vec2f& _texcoord) = 0;
// set vertex status
virtual void set_status(VertexHandle _vh, const OpenMesh::Attributes::StatusInfo& _status) = 0;
// set next halfedge handle
virtual void set_next(HalfedgeHandle _heh, HalfedgeHandle _next) = 0;
// set incident face handle for given halfedge
virtual void set_face(HalfedgeHandle _heh, FaceHandle _fh) = 0;
// set vertex texture coordinate
virtual void set_texcoord(HalfedgeHandle _heh, const Vec2f& _texcoord) = 0;
@@ -142,6 +161,9 @@ public:
// set 3d vertex texture coordinate
virtual void set_texcoord(HalfedgeHandle _heh, const Vec3f& _texcoord) = 0;
// set halfedge status
virtual void set_status(HalfedgeHandle _heh, const OpenMesh::Attributes::StatusInfo& _status) = 0;
// set edge color
virtual void set_color(EdgeHandle _eh, const Vec3uc& _color) = 0;
@@ -154,9 +176,15 @@ public:
// set edge color
virtual void set_color(EdgeHandle _eh, const Vec4f& _color) = 0;
// set edge status
virtual void set_status(EdgeHandle _eh, const OpenMesh::Attributes::StatusInfo& _status) = 0;
// set face normal
virtual void set_normal(FaceHandle _fh, const Vec3f& _normal) = 0;
// set face normal
virtual void set_normal(FaceHandle _fh, const Vec3d& _normal) = 0;
// set face color
virtual void set_color(FaceHandle _fh, const Vec3uc& _color) = 0;
@@ -169,12 +197,15 @@ public:
// set face color
virtual void set_color(FaceHandle _fh, const Vec4f& _color) = 0;
// set face status
virtual void set_status(FaceHandle _fh, const OpenMesh::Attributes::StatusInfo& _status) = 0;
// Store a property in the mesh mapping from an int to a texture file
// Use set_face_texindex to set the index for each face
virtual void add_texture_information( int _id , std::string _name ) = 0;
// get reference to base kernel
virtual BaseKernel* kernel() { return 0; }
virtual BaseKernel* kernel() { return nullptr; }
virtual bool is_triangle_mesh() const { return false; }

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
@@ -94,20 +89,30 @@ public:
typedef std::vector<VertexHandle> VHandles;
ImporterT(Mesh& _mesh) : mesh_(_mesh), halfedgeNormals_() {}
explicit ImporterT(Mesh& _mesh) : mesh_(_mesh), halfedgeNormals_() {}
virtual VertexHandle add_vertex(const Vec3f& _point)
virtual VertexHandle add_vertex(const Vec3f& _point) override
{
return mesh_.add_vertex(vector_cast<Point>(_point));
}
virtual VertexHandle add_vertex()
virtual VertexHandle add_vertex(const Vec3d& _point) override
{
return mesh_.add_vertex(vector_cast<Point>(_point));
}
virtual VertexHandle add_vertex() override
{
return mesh_.new_vertex();
}
virtual FaceHandle add_face(const VHandles& _indices)
virtual HalfedgeHandle add_edge(VertexHandle _vh0, VertexHandle _vh1) override
{
return mesh_.new_edge(_vh0, _vh1);
}
virtual FaceHandle add_face(const VHandles& _indices) override
{
FaceHandle fh;
@@ -192,14 +197,26 @@ public:
return fh;
}
virtual FaceHandle add_face(HalfedgeHandle _heh) override
{
auto fh = mesh_.new_face();
mesh_.set_halfedge_handle(fh, _heh);
return fh;
}
// vertex attributes
virtual void set_point(VertexHandle _vh, const Vec3f& _point)
virtual void set_point(VertexHandle _vh, const Vec3f& _point) override
{
mesh_.set_point(_vh,vector_cast<Point>(_point));
}
virtual void set_normal(VertexHandle _vh, const Vec3f& _normal)
virtual void set_halfedge(VertexHandle _vh, HalfedgeHandle _heh) override
{
mesh_.set_halfedge_handle(_vh, _heh);
}
virtual void set_normal(VertexHandle _vh, const Vec3f& _normal) override
{
if (mesh_.has_vertex_normals())
mesh_.set_normal(_vh, vector_cast<Normal>(_normal));
@@ -210,114 +227,169 @@ public:
halfedgeNormals_[_vh] = vector_cast<Normal>(_normal);
}
virtual void set_color(VertexHandle _vh, const Vec4uc& _color)
virtual void set_normal(VertexHandle _vh, const Vec3d& _normal) override
{
if (mesh_.has_vertex_normals())
mesh_.set_normal(_vh, vector_cast<Normal>(_normal));
//saves normals for half edges.
//they will be written, when the face is added
if (mesh_.has_halfedge_normals())
halfedgeNormals_[_vh] = vector_cast<Normal>(_normal);
}
virtual void set_color(VertexHandle _vh, const Vec4uc& _color) override
{
if (mesh_.has_vertex_colors())
mesh_.set_color(_vh, color_cast<Color>(_color));
}
virtual void set_color(VertexHandle _vh, const Vec3uc& _color)
virtual void set_color(VertexHandle _vh, const Vec3uc& _color) override
{
if (mesh_.has_vertex_colors())
mesh_.set_color(_vh, color_cast<Color>(_color));
}
virtual void set_color(VertexHandle _vh, const Vec4f& _color)
virtual void set_color(VertexHandle _vh, const Vec4f& _color) override
{
if (mesh_.has_vertex_colors())
mesh_.set_color(_vh, color_cast<Color>(_color));
}
virtual void set_color(VertexHandle _vh, const Vec3f& _color)
virtual void set_color(VertexHandle _vh, const Vec3f& _color) override
{
if (mesh_.has_vertex_colors())
mesh_.set_color(_vh, color_cast<Color>(_color));
}
virtual void set_texcoord(VertexHandle _vh, const Vec2f& _texcoord)
virtual void set_texcoord(VertexHandle _vh, const Vec2f& _texcoord) override
{
if (mesh_.has_vertex_texcoords2D())
mesh_.set_texcoord2D(_vh, vector_cast<TexCoord2D>(_texcoord));
}
virtual void set_texcoord(HalfedgeHandle _heh, const Vec2f& _texcoord)
virtual void set_status(VertexHandle _vh, const OpenMesh::Attributes::StatusInfo& _status) override
{
if (!mesh_.has_vertex_status())
mesh_.request_vertex_status();
mesh_.status(_vh) = _status;
}
virtual void set_next(HalfedgeHandle _heh, HalfedgeHandle _next) override
{
mesh_.set_next_halfedge_handle(_heh, _next);
}
virtual void set_face(HalfedgeHandle _heh, FaceHandle _fh) override
{
mesh_.set_face_handle(_heh, _fh);
}
virtual void set_texcoord(HalfedgeHandle _heh, const Vec2f& _texcoord) override
{
if (mesh_.has_halfedge_texcoords2D())
mesh_.set_texcoord2D(_heh, vector_cast<TexCoord2D>(_texcoord));
}
virtual void set_texcoord(VertexHandle _vh, const Vec3f& _texcoord)
virtual void set_texcoord(VertexHandle _vh, const Vec3f& _texcoord) override
{
if (mesh_.has_vertex_texcoords3D())
mesh_.set_texcoord3D(_vh, vector_cast<TexCoord3D>(_texcoord));
}
virtual void set_texcoord(HalfedgeHandle _heh, const Vec3f& _texcoord)
virtual void set_texcoord(HalfedgeHandle _heh, const Vec3f& _texcoord) override
{
if (mesh_.has_halfedge_texcoords3D())
mesh_.set_texcoord3D(_heh, vector_cast<TexCoord3D>(_texcoord));
}
virtual void set_status(HalfedgeHandle _heh, const OpenMesh::Attributes::StatusInfo& _status) override
{
if (!mesh_.has_halfedge_status())
mesh_.request_halfedge_status();
mesh_.status(_heh) = _status;
}
// edge attributes
virtual void set_color(EdgeHandle _eh, const Vec4uc& _color)
virtual void set_color(EdgeHandle _eh, const Vec4uc& _color) override
{
if (mesh_.has_edge_colors())
mesh_.set_color(_eh, color_cast<Color>(_color));
}
virtual void set_color(EdgeHandle _eh, const Vec3uc& _color)
virtual void set_color(EdgeHandle _eh, const Vec3uc& _color) override
{
if (mesh_.has_edge_colors())
mesh_.set_color(_eh, color_cast<Color>(_color));
}
virtual void set_color(EdgeHandle _eh, const Vec4f& _color)
virtual void set_color(EdgeHandle _eh, const Vec4f& _color) override
{
if (mesh_.has_edge_colors())
mesh_.set_color(_eh, color_cast<Color>(_color));
}
virtual void set_color(EdgeHandle _eh, const Vec3f& _color)
virtual void set_color(EdgeHandle _eh, const Vec3f& _color) override
{
if (mesh_.has_edge_colors())
mesh_.set_color(_eh, color_cast<Color>(_color));
}
virtual void set_status(EdgeHandle _eh, const OpenMesh::Attributes::StatusInfo& _status) override
{
if (!mesh_.has_edge_status())
mesh_.request_edge_status();
mesh_.status(_eh) = _status;
}
// face attributes
virtual void set_normal(FaceHandle _fh, const Vec3f& _normal)
virtual void set_normal(FaceHandle _fh, const Vec3f& _normal) override
{
if (mesh_.has_face_normals())
mesh_.set_normal(_fh, vector_cast<Normal>(_normal));
}
virtual void set_color(FaceHandle _fh, const Vec3uc& _color)
virtual void set_normal(FaceHandle _fh, const Vec3d& _normal) override
{
if (mesh_.has_face_normals())
mesh_.set_normal(_fh, vector_cast<Normal>(_normal));
}
virtual void set_color(FaceHandle _fh, const Vec3uc& _color) override
{
if (mesh_.has_face_colors())
mesh_.set_color(_fh, color_cast<Color>(_color));
}
virtual void set_color(FaceHandle _fh, const Vec4uc& _color)
virtual void set_color(FaceHandle _fh, const Vec4uc& _color) override
{
if (mesh_.has_face_colors())
mesh_.set_color(_fh, color_cast<Color>(_color));
}
virtual void set_color(FaceHandle _fh, const Vec3f& _color)
virtual void set_color(FaceHandle _fh, const Vec3f& _color) override
{
if (mesh_.has_face_colors())
mesh_.set_color(_fh, color_cast<Color>(_color));
}
virtual void set_color(FaceHandle _fh, const Vec4f& _color)
virtual void set_color(FaceHandle _fh, const Vec4f& _color) override
{
if (mesh_.has_face_colors())
mesh_.set_color(_fh, color_cast<Color>(_color));
}
virtual void add_face_texcoords( FaceHandle _fh, VertexHandle _vh, const std::vector<Vec2f>& _face_texcoords)
virtual void set_status(FaceHandle _fh, const OpenMesh::Attributes::StatusInfo& _status) override
{
if (!mesh_.has_face_status())
mesh_.request_face_status();
mesh_.status(_fh) = _status;
}
virtual void add_face_texcoords( FaceHandle _fh, VertexHandle _vh, const std::vector<Vec2f>& _face_texcoords) override
{
// get first halfedge handle
HalfedgeHandle cur_heh = mesh_.halfedge_handle(_fh);
@@ -334,7 +406,7 @@ public:
}
}
virtual void add_face_texcoords( FaceHandle _fh, VertexHandle _vh, const std::vector<Vec3f>& _face_texcoords)
virtual void add_face_texcoords( FaceHandle _fh, VertexHandle _vh, const std::vector<Vec3f>& _face_texcoords) override
{
// get first halfedge handle
HalfedgeHandle cur_heh = mesh_.halfedge_handle(_fh);
@@ -351,13 +423,15 @@ public:
}
}
virtual void set_face_texindex( FaceHandle _fh, int _texId ) {
virtual void set_face_texindex( FaceHandle _fh, int _texId ) override
{
if ( mesh_.has_face_texture_index() ) {
mesh_.set_texture_index(_fh , _texId);
}
}
virtual void add_texture_information( int _id , std::string _name ) {
virtual void add_texture_information( int _id , std::string _name ) override
{
OpenMesh::MPropHandleT< std::map< int, std::string > > property;
if ( !mesh_.get_property_handle(property,"TextureMapping") ) {
@@ -370,26 +444,26 @@ public:
// low-level access to mesh
virtual BaseKernel* kernel() { return &mesh_; }
virtual BaseKernel* kernel() override { return &mesh_; }
bool is_triangle_mesh() const
bool is_triangle_mesh() const override
{ return Mesh::is_triangles(); }
void reserve(unsigned int nV, unsigned int nE, unsigned int nF)
void reserve(unsigned int nV, unsigned int nE, unsigned int nF) override
{
mesh_.reserve(nV, nE, nF);
}
// query number of faces, vertices, normals, texcoords
size_t n_vertices() const { return mesh_.n_vertices(); }
size_t n_faces() const { return mesh_.n_faces(); }
size_t n_edges() const { return mesh_.n_edges(); }
size_t n_vertices() const override { return mesh_.n_vertices(); }
size_t n_faces() const override { return mesh_.n_faces(); }
size_t n_edges() const override { return mesh_.n_edges(); }
void prepare() { }
void prepare() override{ }
void finish() { }
void finish() override { }
private:

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=== INCLUDES ================================================================

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
@@ -53,10 +48,7 @@
//
//=============================================================================
#ifndef __BASEREADER_HH__
#define __BASEREADER_HH__
#pragma once
//=== INCLUDES ================================================================
@@ -96,7 +88,7 @@ class OPENMESHDLLEXPORT BaseReader
public:
/// Destructor
virtual ~BaseReader() {};
virtual ~BaseReader() {}
/// Returns a brief description of the file type that can be parsed.
virtual std::string get_description() const = 0;
@@ -156,7 +148,16 @@ protected:
* @return trimmed string
*/
static inline std::string &left_trim(std::string &_string) {
_string.erase(_string.begin(), std::find_if(_string.begin(), _string.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
// Find out if the compiler supports CXX11
#if ( __cplusplus >= 201103L || _MSVC_LANG >= 201103L )
// as with CXX11 we can use lambda expressions
_string.erase(_string.begin(), std::find_if(_string.begin(), _string.end(), [](int i)->int { return ! std::isspace(i); }));
#else
// we do what we did before
_string.erase(_string.begin(), std::find_if(_string.begin(), _string.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
#endif
return _string;
}
@@ -168,7 +169,18 @@ static inline std::string &left_trim(std::string &_string) {
* @return trimmed string
*/
static inline std::string &right_trim(std::string &_string) {
_string.erase(std::find_if(_string.rbegin(), _string.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), _string.end());
// Find out if the compiler supports CXX11
#if ( __cplusplus >= 201103L || _MSVC_LANG >= 201103L )
// as with CXX11 we can use lambda expressions
_string.erase(std::find_if(_string.rbegin(), _string.rend(), [](int i)->int { return ! std::isspace(i); } ).base(), _string.end());
#else
// we do what we did before
_string.erase(std::find_if(_string.rbegin(), _string.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), _string.end());
#endif
return _string;
}
@@ -189,5 +201,3 @@ static inline std::string &trim(std::string &_string) {
} // namespace IO
} // namespace OpenMesh
//=============================================================================
#endif
//=============================================================================

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//== INCLUDES =================================================================
@@ -140,13 +135,13 @@ read(const std::string& _filename, BaseImporter& _bi, Options& _opt)
{
#if defined(WIN32)
std::string::size_type dot = _filename.find_last_of("\\/");
std::string::size_type dot_pos = _filename.find_last_of("\\/");
#else
std::string::size_type dot = _filename.rfind("/");
std::string::size_type dot_pos = _filename.rfind("/");
#endif
path_ = (dot == std::string::npos)
path_ = (dot_pos == std::string::npos)
? "./"
: std::string(_filename.substr(0,dot+1));
: std::string(_filename.substr(0,dot_pos+1));
}
bool result = read(in, _bi, _opt);
@@ -540,6 +535,7 @@ read(std::istream& _in, BaseImporter& _bi, Options& _opt)
vhandles.clear();
face_texcoords.clear();
face_texcoords3d.clear();
// read full line after detecting a face
std::string faceLine;

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
@@ -92,16 +87,16 @@ public:
virtual ~_OBJReader_() { }
std::string get_description() const { return "Alias/Wavefront"; }
std::string get_extensions() const { return "obj"; }
std::string get_description() const override { return "Alias/Wavefront"; }
std::string get_extensions() const override { return "obj"; }
bool read(const std::string& _filename,
BaseImporter& _bi,
Options& _opt);
Options& _opt) override;
bool read(std::istream& _in,
BaseImporter& _bi,
Options& _opt);
Options& _opt) override;
private:
@@ -110,7 +105,7 @@ private:
{
public:
Material() { cleanup(); }
Material():Tr_(0),index_Kd_(0) { cleanup(); }
void cleanup()
{
@@ -142,7 +137,7 @@ private:
void set_Tr( float t )
{ Tr_=t; Tr_is_set_=true; }
void set_map_Kd( std::string _name, int _index_Kd )
void set_map_Kd( const std::string& _name, int _index_Kd )
{ map_Kd_ = _name, index_Kd_ = _index_Kd; map_Kd_is_set_ = true; };
const Vec3f& Kd( void ) const { return Kd_; }

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
#define LINE_LEN 4096

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
@@ -53,10 +48,7 @@
//
//=============================================================================
#ifndef __OFFREADER_HH__
#define __OFFREADER_HH__
#pragma once
//=== INCLUDES ================================================================
@@ -123,17 +115,17 @@ public:
/// Destructor
virtual ~_OFFReader_() {};
std::string get_description() const { return "Object File Format"; }
std::string get_extensions() const { return "off"; }
std::string get_magic() const { return "OFF"; }
std::string get_description() const override { return "Object File Format"; }
std::string get_extensions() const override { return "off"; }
std::string get_magic() const override { return "OFF"; }
bool read(const std::string& _filename,
BaseImporter& _bi,
Options& _opt);
Options& _opt) override;
bool can_u_read(const std::string& _filename) const;
bool can_u_read(const std::string& _filename) const override;
bool read(std::istream& _in, BaseImporter& _bi, Options& _opt );
bool read(std::istream& _in, BaseImporter& _bi, Options& _opt ) override;
private:
@@ -167,5 +159,3 @@ OPENMESHDLLEXPORT _OFFReader_& OFFReader();
} // namespace IO
} // namespace OpenMesh
//=============================================================================
#endif
//=============================================================================

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//== INCLUDES =================================================================
@@ -61,6 +56,7 @@
#include <OpenMesh/Core/Utils/Endian.hh>
#include <OpenMesh/Core/IO/OMFormat.hh>
#include <OpenMesh/Core/IO/reader/OMReader.hh>
#include <OpenMesh/Core/IO/writer/OMWriter.hh>
//=== NAMESPACES ==============================================================
@@ -176,6 +172,15 @@ bool _OMReader_::read_binary(std::istream& _is, BaseImporter& _bi, Options& _opt
bytes_ += restore(_is, header_, swap);
if (header_.version_ > _OMWriter_::get_version())
{
omerr() << "File uses .om version " << OMFormat::as_string(header_.version_) << " but reader only "
<< "supports up to version " << OMFormat::as_string(_OMWriter_::get_version()) << ".\n"
<< "Please update your OpenMesh." << std::endl;
return false;
}
while (!_is.eof()) {
bytes_ += restore(_is, chunk_header_, swap);
@@ -292,30 +297,67 @@ bool _OMReader_::read_binary_vertex_chunk(std::istream &_is, BaseImporter &_bi,
assert( chunk_header_.entity_ == Chunk::Entity_Vertex);
OpenMesh::Vec3f v3f;
OpenMesh::Vec3d v3d;
OpenMesh::Vec2f v2f;
OpenMesh::Vec3uc v3uc; // rgb
OpenMesh::Attributes::StatusInfo status;
OMFormat::Chunk::PropertyName custom_prop;
size_t vidx = 0;
switch (chunk_header_.type_) {
case Chunk::Type_Pos:
assert( OMFormat::dimensions(chunk_header_) == size_t(OpenMesh::Vec3f::dim()));
if (chunk_header_.bits_ == OMFormat::bits(0.0f)) // read floats
{
assert( OMFormat::dimensions(chunk_header_) == size_t(OpenMesh::Vec3f::dim()));
for (; vidx < header_.n_vertices_ && !_is.eof(); ++vidx) {
bytes_ += vector_restore(_is, v3f, _swap);
_bi.add_vertex(v3f);
for (; vidx < header_.n_vertices_ && !_is.eof(); ++vidx) {
bytes_ += vector_restore(_is, v3f, _swap);
_bi.add_vertex(v3f);
}
}
else if (chunk_header_.bits_ == OMFormat::bits(0.0)) // read doubles
{
assert( OMFormat::dimensions(chunk_header_) == size_t(OpenMesh::Vec3d::dim()));
for (; vidx < header_.n_vertices_ && !_is.eof(); ++vidx) {
bytes_ += vector_restore(_is, v3d, _swap);
_bi.add_vertex(v3d);
}
}
else
{
omerr() << "unknown Vector size" << std::endl;
}
break;
case Chunk::Type_Normal:
assert( OMFormat::dimensions(chunk_header_) == size_t(OpenMesh::Vec3f::dim()));
fileOptions_ += Options::VertexNormal;
for (; vidx < header_.n_vertices_ && !_is.eof(); ++vidx) {
bytes_ += vector_restore(_is, v3f, _swap);
if (fileOptions_.vertex_has_normal() && _opt.vertex_has_normal())
_bi.set_normal(VertexHandle(int(vidx)), v3f);
if (chunk_header_.bits_ == OMFormat::bits(0.0f)) // read floats
{
assert( OMFormat::dimensions(chunk_header_) == size_t(OpenMesh::Vec3f::dim()));
fileOptions_ += Options::VertexNormal;
for (; vidx < header_.n_vertices_ && !_is.eof(); ++vidx) {
bytes_ += vector_restore(_is, v3f, _swap);
if (fileOptions_.vertex_has_normal() && _opt.vertex_has_normal())
_bi.set_normal(VertexHandle(int(vidx)), v3f);
}
}
else if (chunk_header_.bits_ == OMFormat::bits(0.0)) // read doubles
{
assert( OMFormat::dimensions(chunk_header_) == size_t(OpenMesh::Vec3d::dim()));
fileOptions_ += Options::VertexNormal;
for (; vidx < header_.n_vertices_ && !_is.eof(); ++vidx) {
bytes_ += vector_restore(_is, v3d, _swap);
if (fileOptions_.vertex_has_normal() && _opt.vertex_has_normal())
_bi.set_normal(VertexHandle(int(vidx)), v3d);
}
}
else
{
omerr() << "Unknown vertex normal format" << std::endl;
}
break;
@@ -343,6 +385,20 @@ bool _OMReader_::read_binary_vertex_chunk(std::istream &_is, BaseImporter &_bi,
}
break;
case Chunk::Type_Status:
{
assert( OMFormat::dimensions(chunk_header_) == 1);
fileOptions_ += Options::Status;
for (; vidx < header_.n_vertices_ && !_is.eof(); ++vidx) {
bytes_ += restore(_is, status, _swap);
if (fileOptions_.vertex_has_status() && _opt.vertex_has_status())
_bi.set_status(VertexHandle(int(vidx)), status);
}
break;
}
case Chunk::Type_Custom:
bytes_ += restore_binary_custom_data(_is, _bi.kernel()->_get_vprop(property_name_), header_.n_vertices_, _swap);
@@ -351,13 +407,28 @@ bool _OMReader_::read_binary_vertex_chunk(std::istream &_is, BaseImporter &_bi,
break;
case Chunk::Type_Topology:
{
for (; vidx < header_.n_vertices_; ++vidx)
{
int halfedge_id = 0;
bytes_ += restore( _is, halfedge_id, OMFormat::Chunk::Integer_Size(chunk_header_.bits_), _swap );
_bi.set_halfedge(VertexHandle(static_cast<int>(vidx)), HalfedgeHandle(halfedge_id));
}
}
break;
default: // skip unknown chunks
{
omerr() << "Unknown chunk type ignored!\n";
size_t size_of = header_.n_vertices_ * OMFormat::vector_size(chunk_header_);
_is.ignore(size_of);
bytes_ += size_of;
size_t chunk_size = header_.n_vertices_ * OMFormat::vector_size(chunk_header_);
_is.ignore(chunk_size);
bytes_ += chunk_size;
break;
}
}
// all chunk data has been read..?!
@@ -375,35 +446,53 @@ bool _OMReader_::read_binary_face_chunk(std::istream &_is, BaseImporter &_bi, Op
size_t fidx = 0;
OpenMesh::Vec3f v3f; // normal
OpenMesh::Vec3d v3d; // normal as double
OpenMesh::Vec3uc v3uc; // rgb
OpenMesh::Attributes::StatusInfo status;
switch (chunk_header_.type_) {
case Chunk::Type_Topology: {
BaseImporter::VHandles vhandles;
size_t nV = 0;
size_t vidx = 0;
case Chunk::Type_Topology:
{
if (header_.version_ < OMFormat::mk_version(2,0))
{
// add faces based on vertex indices
BaseImporter::VHandles vhandles;
size_t nV = 0;
size_t vidx = 0;
switch (header_.mesh_) {
case 'T':
nV = 3;
break;
case 'Q':
nV = 4;
break;
}
for (; fidx < header_.n_faces_; ++fidx) {
if (header_.mesh_ == 'P')
bytes_ += restore(_is, nV, Chunk::Integer_16, _swap);
vhandles.clear();
for (size_t j = 0; j < nV; ++j) {
bytes_ += restore(_is, vidx, Chunk::Integer_Size(chunk_header_.bits_), _swap);
vhandles.push_back(VertexHandle(int(vidx)));
switch (header_.mesh_) {
case 'T':
nV = 3;
break;
case 'Q':
nV = 4;
break;
}
_bi.add_face(vhandles);
for (; fidx < header_.n_faces_; ++fidx) {
if (header_.mesh_ == 'P')
bytes_ += restore(_is, nV, Chunk::Integer_16, _swap);
vhandles.clear();
for (size_t j = 0; j < nV; ++j) {
bytes_ += restore(_is, vidx, Chunk::Integer_Size(chunk_header_.bits_), _swap);
vhandles.push_back(VertexHandle(int(vidx)));
}
_bi.add_face(vhandles);
}
}
else
{
// add faces by simply setting an incident halfedge
for (; fidx < header_.n_faces_; ++fidx)
{
int halfedge_id = 0;
bytes_ += restore( _is, halfedge_id, OMFormat::Chunk::Integer_Size(chunk_header_.bits_), _swap );
_bi.add_face(HalfedgeHandle(halfedge_id));
}
}
}
break;
@@ -412,10 +501,26 @@ bool _OMReader_::read_binary_face_chunk(std::istream &_is, BaseImporter &_bi, Op
assert( OMFormat::dimensions(chunk_header_) == size_t(OpenMesh::Vec3f::dim()));
fileOptions_ += Options::FaceNormal;
for (; fidx < header_.n_faces_ && !_is.eof(); ++fidx) {
bytes_ += vector_restore(_is, v3f, _swap);
if( fileOptions_.face_has_normal() && _opt.face_has_normal())
_bi.set_normal(FaceHandle(int(fidx)), v3f);
if (chunk_header_.bits_ == OMFormat::bits(0.0f)) // read floats
{
for (; fidx < header_.n_faces_ && !_is.eof(); ++fidx) {
bytes_ += vector_restore(_is, v3f, _swap);
if( fileOptions_.face_has_normal() && _opt.face_has_normal())
_bi.set_normal(FaceHandle(int(fidx)), v3f);
}
}
else if (chunk_header_.bits_ == OMFormat::bits(0.0)) // read doubles
{
for (; fidx < header_.n_faces_ && !_is.eof(); ++fidx) {
bytes_ += vector_restore(_is, v3d, _swap);
if( fileOptions_.face_has_normal() && _opt.face_has_normal())
_bi.set_normal(FaceHandle(int(fidx)), v3d);
}
}
else
{
omerr() << "Unknown face normal format" << std::endl;
}
break;
@@ -430,6 +535,19 @@ bool _OMReader_::read_binary_face_chunk(std::istream &_is, BaseImporter &_bi, Op
_bi.set_color(FaceHandle(int(fidx)), v3uc);
}
break;
case Chunk::Type_Status:
{
assert( OMFormat::dimensions(chunk_header_) == 1);
fileOptions_ += Options::Status;
for (; fidx < header_.n_faces_ && !_is.eof(); ++fidx) {
bytes_ += restore(_is, status, _swap);
if (fileOptions_.face_has_status() && _opt.face_has_status())
_bi.set_status(FaceHandle(int(fidx)), status);
}
break;
}
case Chunk::Type_Custom:
@@ -442,9 +560,9 @@ bool _OMReader_::read_binary_face_chunk(std::istream &_is, BaseImporter &_bi, Op
default: // skip unknown chunks
{
omerr() << "Unknown chunk type ignore!\n";
size_t size_of = OMFormat::chunk_data_size(header_, chunk_header_);
_is.ignore(size_of);
bytes_ += size_of;
size_t chunk_size = OMFormat::chunk_data_size(header_, chunk_header_);
_is.ignore(chunk_size);
bytes_ += chunk_size;
}
}
return fidx == header_.n_faces_;
@@ -453,7 +571,7 @@ bool _OMReader_::read_binary_face_chunk(std::istream &_is, BaseImporter &_bi, Op
//-----------------------------------------------------------------------------
bool _OMReader_::read_binary_edge_chunk(std::istream &_is, BaseImporter &_bi, Options &/*_opt */, bool _swap) const
bool _OMReader_::read_binary_edge_chunk(std::istream &_is, BaseImporter &_bi, Options &_opt, bool _swap) const
{
using OMFormat::Chunk;
@@ -461,6 +579,8 @@ bool _OMReader_::read_binary_edge_chunk(std::istream &_is, BaseImporter &_bi, Op
size_t b = bytes_;
OpenMesh::Attributes::StatusInfo status;
switch (chunk_header_.type_) {
case Chunk::Type_Custom:
@@ -468,11 +588,25 @@ bool _OMReader_::read_binary_edge_chunk(std::istream &_is, BaseImporter &_bi, Op
break;
case Chunk::Type_Status:
{
assert( OMFormat::dimensions(chunk_header_) == 1);
fileOptions_ += Options::Status;
for (size_t eidx = 0; eidx < header_.n_edges_ && !_is.eof(); ++eidx) {
bytes_ += restore(_is, status, _swap);
if (fileOptions_.edge_has_status() && _opt.edge_has_status())
_bi.set_status(EdgeHandle(int(eidx)), status);
}
break;
}
default:
// skip unknown type
size_t size_of = OMFormat::chunk_data_size(header_, chunk_header_);
_is.ignore(size_of);
bytes_ += size_of;
size_t chunk_size = OMFormat::chunk_data_size(header_, chunk_header_);
_is.ignore(chunk_size);
bytes_ += chunk_size;
}
return b < bytes_;
@@ -481,13 +615,14 @@ bool _OMReader_::read_binary_edge_chunk(std::istream &_is, BaseImporter &_bi, Op
//-----------------------------------------------------------------------------
bool _OMReader_::read_binary_halfedge_chunk(std::istream &_is, BaseImporter &_bi, Options &/* _opt */, bool _swap) const
bool _OMReader_::read_binary_halfedge_chunk(std::istream &_is, BaseImporter &_bi, Options & _opt, bool _swap) const
{
using OMFormat::Chunk;
assert( chunk_header_.entity_ == Chunk::Entity_Halfedge);
size_t b = bytes_;
OpenMesh::Attributes::StatusInfo status;
switch (chunk_header_.type_) {
case Chunk::Type_Custom:
@@ -495,12 +630,61 @@ bool _OMReader_::read_binary_halfedge_chunk(std::istream &_is, BaseImporter &_bi
bytes_ += restore_binary_custom_data(_is, _bi.kernel()->_get_hprop(property_name_), 2 * header_.n_edges_, _swap);
break;
case Chunk::Type_Topology:
{
std::vector<HalfedgeHandle> next_halfedges;
for (size_t e_idx = 0; e_idx < header_.n_edges_; ++e_idx)
{
int next_id_0 = -1;
int to_vertex_id_0 = -1;
int face_id_0 = -1;
bytes_ += restore( _is, next_id_0, OMFormat::Chunk::Integer_Size(chunk_header_.bits_), _swap );
bytes_ += restore( _is, to_vertex_id_0, OMFormat::Chunk::Integer_Size(chunk_header_.bits_), _swap );
bytes_ += restore( _is, face_id_0, OMFormat::Chunk::Integer_Size(chunk_header_.bits_), _swap );
int next_id_1 = -1;
int to_vertex_id_1 = -1;
int face_id_1 = -1;
bytes_ += restore( _is, next_id_1, OMFormat::Chunk::Integer_Size(chunk_header_.bits_), _swap );
bytes_ += restore( _is, to_vertex_id_1, OMFormat::Chunk::Integer_Size(chunk_header_.bits_), _swap );
bytes_ += restore( _is, face_id_1, OMFormat::Chunk::Integer_Size(chunk_header_.bits_), _swap );
auto heh0 = _bi.add_edge(VertexHandle(to_vertex_id_1), VertexHandle(to_vertex_id_0));
auto heh1 = HalfedgeHandle(heh0.idx() + 1);
next_halfedges.push_back(HalfedgeHandle(next_id_0));
next_halfedges.push_back(HalfedgeHandle(next_id_1));
_bi.set_face(heh0, FaceHandle(face_id_0));
_bi.set_face(heh1, FaceHandle(face_id_1));
}
for (size_t i = 0; i < next_halfedges.size(); ++i)
_bi.set_next(HalfedgeHandle(static_cast<int>(i)), next_halfedges[i]);
}
break;
case Chunk::Type_Status:
{
assert( OMFormat::dimensions(chunk_header_) == 1);
fileOptions_ += Options::Status;
for (size_t hidx = 0; hidx < header_.n_edges_ * 2 && !_is.eof(); ++hidx) {
bytes_ += restore(_is, status, _swap);
if (fileOptions_.halfedge_has_status() && _opt.halfedge_has_status())
_bi.set_status(HalfedgeHandle(int(hidx)), status);
}
break;
}
default:
// skip unknown chunk
omerr() << "Unknown chunk type ignored!\n";
size_t size_of = OMFormat::chunk_data_size(header_, chunk_header_);
_is.ignore(size_of);
bytes_ += size_of;
size_t chunk_size = OMFormat::chunk_data_size(header_, chunk_header_);
_is.ignore(chunk_size);
bytes_ += chunk_size;
}
return b < bytes_;
@@ -526,9 +710,9 @@ bool _OMReader_::read_binary_mesh_chunk(std::istream &_is, BaseImporter &_bi, Op
default:
// skip unknown chunk
size_t size_of = OMFormat::chunk_data_size(header_, chunk_header_);
_is.ignore(size_of);
bytes_ += size_of;
size_t chunk_size = OMFormat::chunk_data_size(header_, chunk_header_);
_is.ignore(chunk_size);
bytes_ += chunk_size;
}
return b < bytes_;

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
@@ -94,20 +89,20 @@ public:
_OMReader_();
virtual ~_OMReader_() { }
std::string get_description() const { return "OpenMesh File Format"; }
std::string get_extensions() const { return "om"; }
std::string get_magic() const { return "OM"; }
std::string get_description() const override { return "OpenMesh File Format"; }
std::string get_extensions() const override { return "om"; }
std::string get_magic() const override { return "OM"; }
bool read(const std::string& _filename,
BaseImporter& _bi,
Options& _opt );
Options& _opt ) override;
//! Stream Reader for std::istream input in binary format
bool read(std::istream& _is,
BaseImporter& _bi,
Options& _opt );
Options& _opt ) override;
virtual bool can_u_read(const std::string& _filename) const;
virtual bool can_u_read(const std::string& _filename) const override;
virtual bool can_u_read(std::istream& _is) const;

View File

@@ -39,13 +39,6 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
#define LINE_LEN 4096
//== INCLUDES =================================================================
@@ -135,6 +128,14 @@ bool _PLYReader_::read(std::istream& _in, BaseImporter& _bi, Options& _opt) {
return false;
}
// Reparse the header
if (!can_u_read(_in)) {
omerr() << "[PLYReader] : Unable to parse header\n";
return false;
}
// filter relevant options for reading
bool swap = _opt.check(Options::Swap);
@@ -218,16 +219,13 @@ void _PLYReader_::readCreateCustomProperty(std::istream& _in, BaseImporter& _bi,
}
//init vector
int numberOfValues;
read(_listType, _in, numberOfValues, OpenMesh::GenProg::Bool2Type<binary>());
std::vector<T> vec;
vec.reserve(numberOfValues);
unsigned int numberOfValues;
readInteger(_listType, _in, numberOfValues, OpenMesh::GenProg::Bool2Type<binary>());
std::vector<T> vec(numberOfValues);
//read and assign
for (int i = 0; i < numberOfValues; ++i)
for (unsigned int i = 0; i < numberOfValues; ++i)
{
T in;
read(_valueType, _in, in, OpenMesh::GenProg::Bool2Type<binary>());
vec.push_back(in);
read(_valueType, _in, vec[i], OpenMesh::GenProg::Bool2Type<binary>());
}
_bi.kernel()->property(prop,_h) = vec;
}
@@ -281,12 +279,6 @@ void _PLYReader_::readCustomProperty(std::istream& _in, BaseImporter& _bi, Handl
bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options& _opt) const {
// Reparse the header
if (!can_u_read(_in)) {
omerr() << "[PLYReader] : Unable to parse header\n";
return false;
}
unsigned int i, j, k, l, idx;
unsigned int nV;
OpenMesh::Vec3f v, n;
@@ -311,6 +303,14 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options
for (std::vector<ElementInfo>::iterator e_it = elements_.begin(); e_it != elements_.end(); ++e_it)
{
if (_in.eof()) {
if (err_enabled)
omerr().enable();
omerr() << "Unexpected end of file while reading." << std::endl;
return false;
}
if (e_it->element_== VERTEX)
{
// read vertices:
@@ -422,6 +422,12 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options
// faces
for (i = 0; i < faceCount_ && !_in.eof(); ++i) {
FaceHandle fh;
c[0] = 0;
c[1] = 0;
c[2] = 0;
c[3] = 255;
for (size_t propertyIndex = 0; propertyIndex < e_it->properties_.size(); ++propertyIndex) {
PropertyInfo prop = e_it->properties_[propertyIndex];
switch (prop.property) {
@@ -453,6 +459,38 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options
++complex_faces;
break;
case COLORRED:
if (prop.value == ValueTypeFLOAT32 || prop.value == ValueTypeFLOAT) {
_in >> tmp;
c[0] = static_cast<OpenMesh::Vec4i::value_type> (tmp * 255.0f);
} else
_in >> c[0];
break;
case COLORGREEN:
if (prop.value == ValueTypeFLOAT32 || prop.value == ValueTypeFLOAT) {
_in >> tmp;
c[1] = static_cast<OpenMesh::Vec4i::value_type> (tmp * 255.0f);
} else
_in >> c[1];
break;
case COLORBLUE:
if (prop.value == ValueTypeFLOAT32 || prop.value == ValueTypeFLOAT) {
_in >> tmp;
c[2] = static_cast<OpenMesh::Vec4i::value_type> (tmp * 255.0f);
} else
_in >> c[2];
break;
case COLORALPHA:
if (prop.value == ValueTypeFLOAT32 || prop.value == ValueTypeFLOAT) {
_in >> tmp;
c[3] = static_cast<OpenMesh::Vec4i::value_type> (tmp * 255.0f);
} else
_in >> c[3];
break;
case CUSTOM_PROP:
if (_opt.check(Options::Custom) && fh.is_valid())
readCustomProperty<false>(_in, _bi, fh, prop.name, prop.value, prop.listIndexType);
@@ -465,7 +503,8 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options
break;
}
}
if (_opt.face_has_color())
_bi.set_color(fh, Vec4uc(c));
}
}
else
@@ -480,14 +519,6 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options
}
}
if (_in.eof()) {
if (err_enabled)
omerr().enable();
omerr() << "Unexpected end of file while reading." << std::endl;
return false;
}
if(e_it->element_== FACE)
// stop reading after the faces since additional elements are not preserved anyway
break;
@@ -507,12 +538,6 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options
bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap*/, const Options& _opt) const {
// Reparse the header
if (!can_u_read(_in)) {
omerr() << "[PLYReader] : Unable to parse header\n";
return false;
}
OpenMesh::Vec3f v, n; // Vertex
OpenMesh::Vec2f t; // TexCoords
BaseImporter::VHandles vhandles;
@@ -579,29 +604,26 @@ bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap
readValue(prop.value, _in, t[1]);
break;
case COLORRED:
if (prop.value == ValueTypeFLOAT32 ||
prop.value == ValueTypeFLOAT) {
readValue(prop.value, _in, tmp);
if (prop.value == ValueTypeFLOAT32 || prop.value == ValueTypeFLOAT) {
readValue(prop.value, _in, tmp);
c[0] = static_cast<OpenMesh::Vec4i::value_type> (tmp * 255.0f);
c[0] = static_cast<OpenMesh::Vec4i::value_type> (tmp * 255.0f);
}
else
readInteger(prop.value, _in, c[0]);
readInteger(prop.value, _in, c[0]);
break;
case COLORGREEN:
if (prop.value == ValueTypeFLOAT32 ||
prop.value == ValueTypeFLOAT) {
readValue(prop.value, _in, tmp);
c[1] = static_cast<OpenMesh::Vec4i::value_type> (tmp * 255.0f);
}
else
readInteger(prop.value, _in, c[1]);
if (prop.value == ValueTypeFLOAT32 || prop.value == ValueTypeFLOAT) {
readValue(prop.value, _in, tmp);
c[1] = static_cast<OpenMesh::Vec4i::value_type> (tmp * 255.0f);
}
else
readInteger(prop.value, _in, c[1]);
break;
case COLORBLUE:
if (prop.value == ValueTypeFLOAT32 ||
prop.value == ValueTypeFLOAT) {
if (prop.value == ValueTypeFLOAT32 || prop.value == ValueTypeFLOAT) {
readValue(prop.value, _in, tmp);
c[2] = static_cast<OpenMesh::Vec4i::value_type> (tmp * 255.0f);
}
@@ -610,8 +632,7 @@ bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap
break;
case COLORALPHA:
if (prop.value == ValueTypeFLOAT32 ||
prop.value == ValueTypeFLOAT) {
if (prop.value == ValueTypeFLOAT32 || prop.value == ValueTypeFLOAT) {
readValue(prop.value, _in, tmp);
c[3] = static_cast<OpenMesh::Vec4i::value_type> (tmp * 255.0f);
}
@@ -645,6 +666,12 @@ bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap
else if (e_it->element_ == FACE) {
for (unsigned i = 0; i < e_it->count_ && !_in.eof(); ++i) {
FaceHandle fh;
c[0] = 0;
c[1] = 0;
c[2] = 0;
c[3] = 255;
for (size_t propertyIndex = 0; propertyIndex < e_it->properties_.size(); ++propertyIndex)
{
PropertyInfo prop = e_it->properties_[propertyIndex];
@@ -679,7 +706,38 @@ bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap
if (!fh.is_valid())
++complex_faces;
break;
case COLORRED:
if (prop.value == ValueTypeFLOAT32 ||
prop.value == ValueTypeFLOAT) {
readValue(prop.value, _in, tmp);
c[0] = static_cast<OpenMesh::Vec4i::value_type> (tmp * 255.0f);
} else
readInteger(prop.value, _in, c[0]);
break;
case COLORGREEN:
if (prop.value == ValueTypeFLOAT32 ||
prop.value == ValueTypeFLOAT) {
readValue(prop.value, _in, tmp);
c[1] = static_cast<OpenMesh::Vec4i::value_type> (tmp * 255.0f);
} else
readInteger(prop.value, _in, c[1]);
break;
case COLORBLUE:
if (prop.value == ValueTypeFLOAT32 ||
prop.value == ValueTypeFLOAT) {
readValue(prop.value, _in, tmp);
c[2] = static_cast<OpenMesh::Vec4i::value_type> (tmp * 255.0f);
} else
readInteger(prop.value, _in, c[2]);
break;
case COLORALPHA:
if (prop.value == ValueTypeFLOAT32 ||
prop.value == ValueTypeFLOAT) {
readValue(prop.value, _in, tmp);
c[3] = static_cast<OpenMesh::Vec4i::value_type> (tmp * 255.0f);
} else
readInteger(prop.value, _in, c[3]);
break;
case CUSTOM_PROP:
if (_opt.check(Options::Custom) && fh.is_valid())
readCustomProperty<true>(_in, _bi, fh, prop.name, prop.value, prop.listIndexType);
@@ -692,6 +750,8 @@ bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap
break;
}
}
if (_opt.face_has_color())
_bi.set_color(fh, Vec4uc(c));
}
}
else {
@@ -741,6 +801,12 @@ void _PLYReader_::readValue(ValueType _type, std::istream& _in, float& _value) c
restore(_in, tmp, options_.check(Options::MSB));
_value = tmp;
break;
case ValueTypeDOUBLE:
case ValueTypeFLOAT64:
double dtmp;
readValue(_type, _in, dtmp);
_value = static_cast<float>(dtmp);
break;
default:
_value = 0.0;
std::cerr << "unsupported conversion type to float: " << _type << std::endl;
@@ -905,9 +971,13 @@ void _PLYReader_::readValue(ValueType _type, std::istream& _in, int& _value) con
//-----------------------------------------------------------------------------
template<typename T>
void _PLYReader_::readInteger(ValueType _type, std::istream& _in, T& _value) const {
void _PLYReader_::readInteger(ValueType _type, std::istream& _in, int& _value) const {
static_assert(std::is_integral<T>::value, "Integral required.");
int16_t tmp_int16_t;
uint16_t tmp_uint16_t;
int32_t tmp_int32_t;
uint32_t tmp_uint32_t;
int8_t tmp_char;
@@ -915,6 +985,22 @@ void _PLYReader_::readInteger(ValueType _type, std::istream& _in, int& _value) c
switch (_type) {
case ValueTypeINT16:
case ValueTypeSHORT:
restore(_in, tmp_int16_t, options_.check(Options::MSB));
_value = tmp_int16_t;
break;
case ValueTypeUINT16:
case ValueTypeUSHORT:
restore(_in, tmp_uint16_t, options_.check(Options::MSB));
_value = tmp_uint16_t;
break;
case ValueTypeINT:
case ValueTypeINT32:
@@ -954,71 +1040,12 @@ void _PLYReader_::readInteger(ValueType _type, std::istream& _in, int& _value) c
default:
_value = 0;
std::cerr << "unsupported conversion type to int: " << _type << std::endl;
std::cerr << "unsupported conversion type to integral: " << _type << std::endl;
break;
}
}
//-----------------------------------------------------------------------------
void _PLYReader_::readInteger(ValueType _type, std::istream& _in, unsigned int& _value) const {
int32_t tmp_int32_t;
uint32_t tmp_uint32_t;
int8_t tmp_char;
uint8_t tmp_uchar;
switch (_type) {
case ValueTypeUINT:
case ValueTypeUINT32:
restore(_in, tmp_uint32_t, options_.check(Options::MSB));
_value = tmp_uint32_t;
break;
case ValueTypeINT:
case ValueTypeINT32:
restore(_in, tmp_int32_t, options_.check(Options::MSB));
_value = tmp_int32_t;
break;
case ValueTypeUCHAR:
case ValueTypeUINT8:
restore(_in, tmp_uchar, options_.check(Options::MSB));
_value = tmp_uchar;
break;
case ValueTypeCHAR:
case ValueTypeINT8:
restore(_in, tmp_char, options_.check(Options::MSB));
_value = tmp_char;
break;
default:
_value = 0;
std::cerr << "unsupported conversion type to unsigned int: " << _type << std::endl;
break;
}
}
//------------------------------------------------------------------------------
@@ -1062,7 +1089,7 @@ std::string get_property_name(std::string _string1, std::string _string2) {
//-----------------------------------------------------------------------------
_PLYReader_::ValueType get_property_type(std::string _string1, std::string _string2) {
_PLYReader_::ValueType get_property_type(std::string& _string1, std::string& _string2) {
if (_string1 == "float32" || _string2 == "float32")
@@ -1201,183 +1228,211 @@ bool _PLYReader_::can_u_read(std::istream& _is) const {
_is >> keyword;
while (keyword != "end_header") {
if (keyword == "comment") {
std::getline(_is, line);
} else if (keyword == "element") {
_is >> elementName;
_is >> elementCount;
if (keyword == "comment") {
std::getline(_is, line);
} else if (keyword == "element") {
_is >> elementName;
_is >> elementCount;
ElementInfo element;
element.name_ = elementName;
element.count_ = elementCount;
ElementInfo element;
element.name_ = elementName;
element.count_ = elementCount;
if (elementName == "vertex") {
vertexCount_ = elementCount;
element.element_ = VERTEX;
} else if (elementName == "face") {
faceCount_ = elementCount;
element.element_ = FACE;
} else {
omerr() << "PLY header unsupported element type: " << elementName << std::endl;
element.element_ = UNKNOWN;
}
if (elementName == "vertex") {
vertexCount_ = elementCount;
element.element_ = VERTEX;
} else if (elementName == "face") {
faceCount_ = elementCount;
element.element_ = FACE;
} else {
omerr() << "PLY header unsupported element type: " << elementName << std::endl;
element.element_ = UNKNOWN;
}
elements_.push_back(element);
} else if (keyword == "property") {
std::string tmp1;
std::string tmp2;
elements_.push_back(element);
} else if (keyword == "property") {
std::string tmp1;
std::string tmp2;
// Read first keyword, as it might be a list
_is >> tmp1;
// Read first keyword, as it might be a list
_is >> tmp1;
if (tmp1 == "list") {
_is >> listIndexType;
_is >> listEntryType;
_is >> propertyName;
if (tmp1 == "list") {
_is >> listIndexType;
_is >> listEntryType;
_is >> propertyName;
ValueType indexType = Unsupported;
ValueType entryType = Unsupported;
ValueType indexType = Unsupported;
ValueType entryType = Unsupported;
if (listIndexType == "uint8") {
indexType = ValueTypeUINT8;
} else if (listIndexType == "uchar") {
indexType = ValueTypeUCHAR;
} else if (listIndexType == "int") {
indexType = ValueTypeINT;
} else {
omerr() << "Unsupported Index type for property list: " << listIndexType << std::endl;
continue;
}
if (listIndexType == "uint8") {
indexType = ValueTypeUINT8;
} else if (listIndexType == "uint16") {
indexType = ValueTypeUINT16;
} else if (listIndexType == "uchar") {
indexType = ValueTypeUCHAR;
} else if (listIndexType == "int") {
indexType = ValueTypeINT;
} else {
omerr() << "Unsupported Index type for property list: " << listIndexType << std::endl;
return false;
}
entryType = get_property_type(listEntryType, listEntryType);
entryType = get_property_type(listEntryType, listEntryType);
if (entryType == Unsupported) {
omerr() << "Unsupported Entry type for property list: " << listEntryType << std::endl;
}
if (entryType == Unsupported) {
omerr() << "Unsupported Entry type for property list: " << listEntryType << std::endl;
}
PropertyInfo property(CUSTOM_PROP, entryType, propertyName);
property.listIndexType = indexType;
PropertyInfo property(CUSTOM_PROP, entryType, propertyName);
property.listIndexType = indexType;
if (elementName == "face")
{
// special case for vertex indices
if (propertyName == "vertex_index" || propertyName == "vertex_indices")
{
property.property = VERTEX_INDICES;
if (!elements_.back().properties_.empty())
{
omerr() << "Custom face Properties defined, before 'vertex_indices' property was defined. They will be skipped" << std::endl;
elements_.back().properties_.clear();
}
}
if (elementName == "face")
{
// special case for vertex indices
if (propertyName == "vertex_index" || propertyName == "vertex_indices")
{
property.property = VERTEX_INDICES;
}
else
omerr() << "property " << propertyName << " belongs to unsupported element " << elementName << std::endl;
elements_.back().properties_.push_back(property);
} else {
// as this is not a list property, read second value of property
_is >> tmp2;
// Extract name and type of property
// As the order seems to be different in some files, autodetect it.
ValueType valueType = get_property_type(tmp1, tmp2);
propertyName = get_property_name(tmp1, tmp2);
PropertyInfo entry;
//special treatment for some vertex properties.
if (elementName == "vertex") {
if (propertyName == "x") {
entry = PropertyInfo(XCOORD, valueType);
vertexDimension_++;
} else if (propertyName == "y") {
entry = PropertyInfo(YCOORD, valueType);
vertexDimension_++;
} else if (propertyName == "z") {
entry = PropertyInfo(ZCOORD, valueType);
vertexDimension_++;
} else if (propertyName == "nx") {
entry = PropertyInfo(XNORM, valueType);
options_ += Options::VertexNormal;
} else if (propertyName == "ny") {
entry = PropertyInfo(YNORM, valueType);
options_ += Options::VertexNormal;
} else if (propertyName == "nz") {
entry = PropertyInfo(ZNORM, valueType);
options_ += Options::VertexNormal;
} else if (propertyName == "u" || propertyName == "s") {
entry = PropertyInfo(TEXX, valueType);
options_ += Options::VertexTexCoord;
} else if (propertyName == "v" || propertyName == "t") {
entry = PropertyInfo(TEXY, valueType);
options_ += Options::VertexTexCoord;
} else if (propertyName == "red") {
entry = PropertyInfo(COLORRED, valueType);
options_ += Options::VertexColor;
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
options_ += Options::ColorFloat;
} else if (propertyName == "green") {
entry = PropertyInfo(COLORGREEN, valueType);
options_ += Options::VertexColor;
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
options_ += Options::ColorFloat;
} else if (propertyName == "blue") {
entry = PropertyInfo(COLORBLUE, valueType);
options_ += Options::VertexColor;
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
options_ += Options::ColorFloat;
} else if (propertyName == "diffuse_red") {
entry = PropertyInfo(COLORRED, valueType);
options_ += Options::VertexColor;
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
options_ += Options::ColorFloat;
} else if (propertyName == "diffuse_green") {
entry = PropertyInfo(COLORGREEN, valueType);
options_ += Options::VertexColor;
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
options_ += Options::ColorFloat;
} else if (propertyName == "diffuse_blue") {
entry = PropertyInfo(COLORBLUE, valueType);
options_ += Options::VertexColor;
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
options_ += Options::ColorFloat;
} else if (propertyName == "alpha") {
entry = PropertyInfo(COLORALPHA, valueType);
options_ += Options::VertexColor;
options_ += Options::ColorAlpha;
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
options_ += Options::ColorFloat;
}
}
//not a special property, load as custom
if (entry.value == Unsupported){
Property prop = CUSTOM_PROP;
options_ += Options::Custom;
entry = PropertyInfo(prop, valueType, propertyName);
}
if (entry.property != UNSUPPORTED)
if (!elements_.back().properties_.empty())
{
elements_.back().properties_.push_back(entry);
omerr() << "Custom face Properties defined, before 'vertex_indices' property was defined. They will be skipped" << std::endl;
elements_.back().properties_.clear();
}
} else {
options_ += Options::Custom;
}
}
else
omerr() << "property " << propertyName << " belongs to unsupported element " << elementName << std::endl;
elements_.back().properties_.push_back(property);
} else {
omlog() << "Unsupported keyword : " << keyword << std::endl;
// as this is not a list property, read second value of property
_is >> tmp2;
// Extract name and type of property
// As the order seems to be different in some files, autodetect it.
ValueType valueType = get_property_type(tmp1, tmp2);
propertyName = get_property_name(tmp1, tmp2);
PropertyInfo entry;
//special treatment for some vertex properties.
if (elementName == "vertex") {
if (propertyName == "x") {
entry = PropertyInfo(XCOORD, valueType);
vertexDimension_++;
} else if (propertyName == "y") {
entry = PropertyInfo(YCOORD, valueType);
vertexDimension_++;
} else if (propertyName == "z") {
entry = PropertyInfo(ZCOORD, valueType);
vertexDimension_++;
} else if (propertyName == "nx") {
entry = PropertyInfo(XNORM, valueType);
options_ += Options::VertexNormal;
} else if (propertyName == "ny") {
entry = PropertyInfo(YNORM, valueType);
options_ += Options::VertexNormal;
} else if (propertyName == "nz") {
entry = PropertyInfo(ZNORM, valueType);
options_ += Options::VertexNormal;
} else if (propertyName == "u" || propertyName == "s") {
entry = PropertyInfo(TEXX, valueType);
options_ += Options::VertexTexCoord;
} else if (propertyName == "v" || propertyName == "t") {
entry = PropertyInfo(TEXY, valueType);
options_ += Options::VertexTexCoord;
} else if (propertyName == "red") {
entry = PropertyInfo(COLORRED, valueType);
options_ += Options::VertexColor;
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
options_ += Options::ColorFloat;
} else if (propertyName == "green") {
entry = PropertyInfo(COLORGREEN, valueType);
options_ += Options::VertexColor;
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
options_ += Options::ColorFloat;
} else if (propertyName == "blue") {
entry = PropertyInfo(COLORBLUE, valueType);
options_ += Options::VertexColor;
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
options_ += Options::ColorFloat;
} else if (propertyName == "diffuse_red") {
entry = PropertyInfo(COLORRED, valueType);
options_ += Options::VertexColor;
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
options_ += Options::ColorFloat;
} else if (propertyName == "diffuse_green") {
entry = PropertyInfo(COLORGREEN, valueType);
options_ += Options::VertexColor;
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
options_ += Options::ColorFloat;
} else if (propertyName == "diffuse_blue") {
entry = PropertyInfo(COLORBLUE, valueType);
options_ += Options::VertexColor;
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
options_ += Options::ColorFloat;
} else if (propertyName == "alpha") {
entry = PropertyInfo(COLORALPHA, valueType);
options_ += Options::VertexColor;
options_ += Options::ColorAlpha;
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
options_ += Options::ColorFloat;
}
}
else if (elementName == "face") {
if (propertyName == "red") {
entry = PropertyInfo(COLORRED, valueType);
options_ += Options::FaceColor;
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
options_ += Options::ColorFloat;
} else if (propertyName == "green") {
entry = PropertyInfo(COLORGREEN, valueType);
options_ += Options::FaceColor;
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
options_ += Options::ColorFloat;
} else if (propertyName == "blue") {
entry = PropertyInfo(COLORBLUE, valueType);
options_ += Options::FaceColor;
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
options_ += Options::ColorFloat;
} else if (propertyName == "alpha") {
entry = PropertyInfo(COLORALPHA, valueType);
options_ += Options::FaceColor;
options_ += Options::ColorAlpha;
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
options_ += Options::ColorFloat;
}
}
//not a special property, load as custom
if (entry.value == Unsupported){
Property prop = CUSTOM_PROP;
options_ += Options::Custom;
entry = PropertyInfo(prop, valueType, propertyName);
}
if (entry.property != UNSUPPORTED)
{
elements_.back().properties_.push_back(entry);
}
}
streamPos = _is.tellg();
_is >> keyword;
if (_is.bad()) {
omerr() << "Error while reading PLY file header" << std::endl;
return false;
}
} else {
omlog() << "Unsupported keyword : " << keyword << std::endl;
}
streamPos = _is.tellg();
_is >> keyword;
if (_is.bad()) {
omerr() << "Error while reading PLY file header" << std::endl;
return false;
}
}
// As the binary data is directy after the end_header keyword

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
@@ -102,19 +97,19 @@ public:
_PLYReader_();
std::string get_description() const { return "PLY polygon file format"; }
std::string get_extensions() const { return "ply"; }
std::string get_magic() const { return "PLY"; }
std::string get_description() const override { return "PLY polygon file format"; }
std::string get_extensions() const override { return "ply"; }
std::string get_magic() const override { return "PLY"; }
bool read(const std::string& _filename,
BaseImporter& _bi,
Options& _opt);
Options& _opt) override;
bool read(std::istream& _is,
BaseImporter& _bi,
Options& _opt);
Options& _opt) override;
bool can_u_read(const std::string& _filename) const;
bool can_u_read(const std::string& _filename) const override;
enum ValueType {
Unsupported,
@@ -135,8 +130,6 @@ private:
bool read_ascii(std::istream& _in, BaseImporter& _bi, const Options& _opt) const;
bool read_binary(std::istream& _in, BaseImporter& _bi, bool swap, const Options& _opt) const;
float readToFloatValue(ValueType _type , std::fstream& _in) const;
void readValue(ValueType _type , std::istream& _in, float& _value) const;
void readValue(ValueType _type , std::istream& _in, double& _value) const;
void readValue(ValueType _type , std::istream& _in, unsigned int& _value) const;
@@ -146,8 +139,8 @@ private:
void readValue(ValueType _type , std::istream& _in, short& _value) const;
void readValue(ValueType _type , std::istream& _in, signed char& _value) const;
void readInteger(ValueType _type, std::istream& _in, int& _value) const;
void readInteger(ValueType _type, std::istream& _in, unsigned int& _value) const;
template<typename T>
void readInteger(ValueType _type, std::istream& _in, T& _value) const;
/// Read unsupported properties in PLY file
void consume_input(std::istream& _in, int _count) const {
@@ -219,6 +212,18 @@ private:
_in >> _value;
}
template<typename T>
inline void readInteger(_PLYReader_::ValueType _type, std::istream& _in, T& _value, OpenMesh::GenProg::TrueType /*_binary*/) const
{
readInteger(_type, _in, _value);
}
template<typename T>
inline void readInteger(_PLYReader_::ValueType _type, std::istream& _in, T& _value, OpenMesh::GenProg::FalseType /*_binary*/) const
{
_in >> _value;
}
//read and assign custom properties with the given type. Also creates property, if not exist
template<bool binary, typename T, typename Handle>
void readCreateCustomProperty(std::istream& _in, BaseImporter& _bi, Handle _h, const std::string& _propName, const ValueType _valueType, const ValueType _listType) const;

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//== INCLUDES =================================================================
@@ -176,7 +171,7 @@ class CmpVec
{
public:
CmpVec(float _eps=FLT_MIN) : eps_(_eps) {}
explicit CmpVec(float _eps=FLT_MIN) : eps_(_eps) {}
bool operator()( const Vec3f& _v0, const Vec3f& _v1 ) const
{

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
@@ -97,17 +92,17 @@ public:
virtual ~_STLReader_() {};
std::string get_description() const
std::string get_description() const override
{ return "Stereolithography Interface Format"; }
std::string get_extensions() const { return "stl stla stlb"; }
std::string get_extensions() const override { return "stl stla stlb"; }
bool read(const std::string& _filename,
BaseImporter& _bi,
Options& _opt);
Options& _opt) override;
bool read(std::istream& _in,
BaseImporter& _bi,
Options& _opt);
Options& _opt) override;
/** Set the threshold to be used for considering two point to be equal.
Can be used to merge small gaps */

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=== INCLUDES ================================================================

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
@@ -138,11 +133,13 @@ protected:
bool check(BaseExporter& _be, Options _opt) const
{
return (_opt.check(Options::VertexNormal ) <= _be.has_vertex_normals())
&& (_opt.check(Options::VertexTexCoord)<= _be.has_vertex_texcoords())
&& (_opt.check(Options::VertexColor) <= _be.has_vertex_colors())
&& (_opt.check(Options::FaceNormal) <= _be.has_face_normals())
&& (_opt.check(Options::FaceColor) <= _be.has_face_colors());
// Check for all Options. When we want to write them (_opt.check() ) , they have to be available ( has_ )
// Converts to not A (write them) or B (available)
return ( !_opt.check(Options::VertexNormal ) || _be.has_vertex_normals())
&& ( !_opt.check(Options::VertexTexCoord)|| _be.has_vertex_texcoords())
&& ( !_opt.check(Options::VertexColor) || _be.has_vertex_colors())
&& ( !_opt.check(Options::FaceNormal) || _be.has_face_normals())
&& ( !_opt.check(Options::FaceColor) || _be.has_face_colors());
}
};

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//== INCLUDES =================================================================
@@ -97,28 +92,32 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt, std::stream
return false;
}
// Set precision on output stream. The default is set via IOManager and passed through to all writers.
out.precision(_precision);
// Set fixed output to avoid problems with programs not reading scientific notation correctly
out << std::fixed;
{
#if defined(WIN32)
std::string::size_type dot = _filename.find_last_of("\\/");
std::string::size_type dotposition = _filename.find_last_of("\\/");
#else
std::string::size_type dot = _filename.rfind("/");
std::string::size_type dotposition = _filename.rfind("/");
#endif
if (dot == std::string::npos){
if (dotposition == std::string::npos){
path_ = "./";
objName_ = _filename;
}else{
path_ = _filename.substr(0,dot+1);
objName_ = _filename.substr(dot+1);
path_ = _filename.substr(0,dotposition+1);
objName_ = _filename.substr(dotposition+1);
}
//remove the file extension
dot = objName_.find_last_of(".");
dotposition = objName_.find_last_of(".");
if(dot != std::string::npos)
objName_ = objName_.substr(0,dot);
if(dotposition != std::string::npos)
objName_ = objName_.substr(0,dotposition);
}
bool result = write(out, _be, _opt, _precision);
@@ -207,7 +206,6 @@ _OBJWriter_::
write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _precision) const
{
unsigned int idx;
size_t i, j,nV, nF;
Vec3f v, n;
Vec2f t;
VertexHandle vh;
@@ -274,9 +272,9 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
std::vector<Vec2f> texCoords;
//add all texCoords to map
unsigned int num = _be.get_face_texcoords(texCoords);
for(unsigned int i = 0; i < num ; ++i)
for(size_t i = 0; i < num ; ++i)
{
texMap[texCoords[i]] = i;
texMap[texCoords[i]] = static_cast<int>(i);
}
}
@@ -304,7 +302,7 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
}
// vertex data (point, normals, texcoords)
for (i=0, nV=_be.n_vertices(); i<nV; ++i)
for (size_t i=0, nV=_be.n_vertices(); i<nV; ++i)
{
vh = VertexHandle(int(i));
v = _be.point(vh);
@@ -325,7 +323,7 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
&& !_opt.check(Options::FaceTexCoord);
// faces (indices starting at 1 not 0)
for (i=0, nF=_be.n_faces(); i<nF; ++i)
for (size_t i=0, nF=_be.n_faces(); i<nF; ++i)
{
if (useMatrial && _opt.check(Options::FaceColor) ){
@@ -352,7 +350,7 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
_be.get_vhandles(FaceHandle(int(i)), vhandles);
for (j=0; j< vhandles.size(); ++j)
for (size_t j=0; j< vhandles.size(); ++j)
{
// Write vertex index

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
@@ -93,14 +88,14 @@ public:
/// Destructor
virtual ~_OBJWriter_() {};
std::string get_description() const { return "Alias/Wavefront"; }
std::string get_extensions() const { return "obj"; }
std::string get_description() const override { return "Alias/Wavefront"; }
std::string get_extensions() const override { return "obj"; }
bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const;
bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const override;
bool write(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const;
bool write(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const override;
size_t binary_size(BaseExporter&, Options) const { return 0; }
size_t binary_size(BaseExporter&, Options) const override { return 0; }
private:

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//== INCLUDES =================================================================

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
@@ -102,14 +97,14 @@ public:
virtual ~_OFFWriter_() {};
std::string get_description() const { return "no description"; }
std::string get_extensions() const { return "off"; }
std::string get_description() const override { return "no description"; }
std::string get_extensions() const override { return "off"; }
bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const;
bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const override;
bool write(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const;
bool write(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const override;
size_t binary_size(BaseExporter& _be, Options _opt) const;
size_t binary_size(BaseExporter& _be, Options _opt) const override;
protected:

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//== INCLUDES =================================================================
@@ -86,7 +81,7 @@ _OMWriter_& OMWriter() { return __OMWriterInstance; }
const OMFormat::uchar _OMWriter_::magic_[3] = "OM";
const OMFormat::uint8 _OMWriter_::version_ = OMFormat::mk_version(1,2);
const OMFormat::uint8 _OMWriter_::version_ = OMFormat::mk_version(2,1);
_OMWriter_::
@@ -163,7 +158,7 @@ _OMWriter_::write(std::ostream& _os, BaseExporter& _be, Options _opt, std::strea
#ifndef DOXY_IGNORE_THIS
template <typename T> struct Enabler
{
Enabler( T& obj ) : obj_(obj)
explicit Enabler( T& obj ) : obj_(obj)
{}
~Enabler() { obj_.enable(); }
@@ -182,13 +177,13 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
size_t bytes = 0;
bool swap = _opt.check(Options::Swap) || (Endian::local() == Endian::MSB);
const bool swap =
_opt.check(Options::Swap) || (Endian::local() == Endian::MSB);
unsigned int i, nV, nF;
Vec3f v;
Vec3d vd;
Vec2f t;
std::vector<VertexHandle> vhandles;
// -------------------- write header
OMFormat::Header header;
@@ -218,14 +213,28 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
chunk_header.name_ = false;
chunk_header.entity_ = OMFormat::Chunk::Entity_Vertex;
chunk_header.type_ = OMFormat::Chunk::Type_Pos;
chunk_header.signed_ = OMFormat::is_signed(v[0]);
chunk_header.float_ = OMFormat::is_float(v[0]);
chunk_header.dim_ = OMFormat::dim(v);
chunk_header.bits_ = OMFormat::bits(v[0]);
if (_be.is_point_double())
{
chunk_header.signed_ = OMFormat::is_signed(vd[0]);
chunk_header.float_ = OMFormat::is_float(vd[0]);
chunk_header.dim_ = OMFormat::dim(vd);
chunk_header.bits_ = OMFormat::bits(vd[0]);
}
else
{
chunk_header.signed_ = OMFormat::is_signed(v[0]);
chunk_header.float_ = OMFormat::is_float(v[0]);
chunk_header.dim_ = OMFormat::dim(v);
chunk_header.bits_ = OMFormat::bits(v[0]);
}
bytes += store( _os, chunk_header, swap );
for (i=0, nV=header.n_vertices_; i<nV; ++i)
bytes += vector_store( _os, _be.point(VertexHandle(i)), swap );
if (_be.is_point_double())
for (i=0, nV=header.n_vertices_; i<nV; ++i)
bytes += vector_store( _os, _be.pointd(VertexHandle(i)), swap );
else
for (i=0, nV=header.n_vertices_; i<nV; ++i)
bytes += vector_store( _os, _be.point(VertexHandle(i)), swap );
}
@@ -233,18 +242,34 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
if (_be.n_vertices() && _opt.check( Options::VertexNormal ))
{
Vec3f n = _be.normal(VertexHandle(0));
Vec3d nd = _be.normald(VertexHandle(0));
chunk_header.name_ = false;
chunk_header.entity_ = OMFormat::Chunk::Entity_Vertex;
chunk_header.type_ = OMFormat::Chunk::Type_Normal;
chunk_header.signed_ = OMFormat::is_signed(n[0]);
chunk_header.float_ = OMFormat::is_float(n[0]);
chunk_header.dim_ = OMFormat::dim(n);
chunk_header.bits_ = OMFormat::bits(n[0]);
if (_be.is_normal_double())
{
chunk_header.signed_ = OMFormat::is_signed(nd[0]);
chunk_header.float_ = OMFormat::is_float(nd[0]);
chunk_header.dim_ = OMFormat::dim(nd);
chunk_header.bits_ = OMFormat::bits(nd[0]);
}
else
{
chunk_header.signed_ = OMFormat::is_signed(n[0]);
chunk_header.float_ = OMFormat::is_float(n[0]);
chunk_header.dim_ = OMFormat::dim(n);
chunk_header.bits_ = OMFormat::bits(n[0]);
}
bytes += store( _os, chunk_header, swap );
for (i=0, nV=header.n_vertices_; i<nV; ++i)
bytes += vector_store( _os, _be.normal(VertexHandle(i)), swap );
if (_be.is_normal_double())
for (i=0, nV=header.n_vertices_; i<nV; ++i)
bytes += vector_store( _os, _be.normald(VertexHandle(i)), swap );
else
for (i=0, nV=header.n_vertices_; i<nV; ++i)
bytes += vector_store( _os, _be.normal(VertexHandle(i)), swap );
}
// ---------- write vertex color
@@ -286,6 +311,50 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
}
// ---------- wirte halfedge data
if (_be.n_edges())
{
chunk_header.reserved_ = 0;
chunk_header.name_ = false;
chunk_header.entity_ = OMFormat::Chunk::Entity_Halfedge;
chunk_header.type_ = OMFormat::Chunk::Type_Topology;
chunk_header.signed_ = true;
chunk_header.float_ = true; // TODO: is this correct? This causes a scalar size of 1 in OMFormat.hh scalar_size which we need I think?
chunk_header.dim_ = OMFormat::Chunk::Dim_3D;
chunk_header.bits_ = OMFormat::needed_bits(_be.n_edges()*4); // *2 due to halfedge ids being stored, *2 due to signedness
bytes += store( _os, chunk_header, swap );
auto nE=header.n_edges_*2;
for (i=0; i<nE; ++i)
{
auto next_id = _be.get_next_halfedge_id(HalfedgeHandle(static_cast<int>(i)));
auto to_vertex_id = _be.get_to_vertex_id(HalfedgeHandle(static_cast<int>(i)));
auto face_id = _be.get_face_id(HalfedgeHandle(static_cast<int>(i)));
bytes += store( _os, next_id, OMFormat::Chunk::Integer_Size(chunk_header.bits_), swap );
bytes += store( _os, to_vertex_id, OMFormat::Chunk::Integer_Size(chunk_header.bits_), swap );
bytes += store( _os, face_id, OMFormat::Chunk::Integer_Size(chunk_header.bits_), swap );
}
}
// ---------- write vertex topology (outgoing halfedge)
if (_be.n_vertices())
{
chunk_header.reserved_ = 0;
chunk_header.name_ = false;
chunk_header.entity_ = OMFormat::Chunk::Entity_Vertex;
chunk_header.type_ = OMFormat::Chunk::Type_Topology;
chunk_header.signed_ = true;
chunk_header.float_ = true; // TODO: is this correct? This causes a scalar size of 1 in OMFormat.hh scalar_size which we need I think?
chunk_header.dim_ = OMFormat::Chunk::Dim_1D;
chunk_header.bits_ = OMFormat::needed_bits(_be.n_edges()*4); // *2 due to halfedge ids being stored, *2 due to signedness
bytes += store( _os, chunk_header, swap );
for (i=0, nV=header.n_vertices_; i<nV; ++i)
bytes += store( _os, _be.get_halfedge_id(VertexHandle(i)), OMFormat::Chunk::Integer_Size(chunk_header.bits_), swap );
}
// -------------------- write face data
// ---------- write topology
@@ -293,26 +362,17 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
chunk_header.name_ = false;
chunk_header.entity_ = OMFormat::Chunk::Entity_Face;
chunk_header.type_ = OMFormat::Chunk::Type_Topology;
chunk_header.signed_ = 0;
chunk_header.float_ = 0;
chunk_header.dim_ = OMFormat::Chunk::Dim_1D; // ignored
chunk_header.bits_ = OMFormat::needed_bits(_be.n_vertices());
chunk_header.signed_ = true;
chunk_header.float_ = true; // TODO: is this correct? This causes a scalar size of 1 in OMFormat.hh scalar_size which we need I think?
chunk_header.dim_ = OMFormat::Chunk::Dim_1D;
chunk_header.bits_ = OMFormat::needed_bits(_be.n_edges()*4); // *2 due to halfedge ids being stored, *2 due to signedness
bytes += store( _os, chunk_header, swap );
for (i=0, nF=header.n_faces_; i<nF; ++i)
{
nV = _be.get_vhandles(FaceHandle(i), vhandles);
if ( header.mesh_ == 'P' )
bytes += store( _os, vhandles.size(), OMFormat::Chunk::Integer_16, swap );
for (size_t j=0; j < vhandles.size(); ++j)
{
using namespace OMFormat;
using namespace GenProg;
bytes += store( _os, vhandles[j].idx(), Chunk::Integer_Size(chunk_header.bits_), swap );
}
auto size = OMFormat::Chunk::Integer_Size(chunk_header.bits_);
bytes += store( _os, _be.get_halfedge_id(FaceHandle(i)), size, swap);
}
}
@@ -328,19 +388,36 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
{
#endif
Vec3f n = _be.normal(FaceHandle(0));
Vec3d nd = _be.normald(FaceHandle(0));
chunk_header.name_ = false;
chunk_header.entity_ = OMFormat::Chunk::Entity_Face;
chunk_header.type_ = OMFormat::Chunk::Type_Normal;
chunk_header.signed_ = OMFormat::is_signed(n[0]);
chunk_header.float_ = OMFormat::is_float(n[0]);
chunk_header.dim_ = OMFormat::dim(n);
chunk_header.bits_ = OMFormat::bits(n[0]);
if (_be.is_normal_double())
{
chunk_header.signed_ = OMFormat::is_signed(nd[0]);
chunk_header.float_ = OMFormat::is_float(nd[0]);
chunk_header.dim_ = OMFormat::dim(nd);
chunk_header.bits_ = OMFormat::bits(nd[0]);
}
else
{
chunk_header.signed_ = OMFormat::is_signed(n[0]);
chunk_header.float_ = OMFormat::is_float(n[0]);
chunk_header.dim_ = OMFormat::dim(n);
chunk_header.bits_ = OMFormat::bits(n[0]);
}
bytes += store( _os, chunk_header, swap );
#if !NEW_STYLE
for (i=0, nF=header.n_faces_; i<nF; ++i)
bytes += vector_store( _os, _be.normal(FaceHandle(i)), swap );
if (_be.is_normal_double())
for (i=0, nF=header.n_faces_; i<nF; ++i)
bytes += vector_store( _os, _be.normald(FaceHandle(i)), swap );
else
for (i=0, nF=header.n_faces_; i<nF; ++i)
bytes += vector_store( _os, _be.normal(FaceHandle(i)), swap );
#else
bytes += bp->store(_os, swap );
}
@@ -384,51 +461,112 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
#endif
}
// ---------- write vertex status
if (_be.n_vertices() && _be.has_vertex_status() && _opt.check(Options::Status))
{
auto s = _be.status(VertexHandle(0));
chunk_header.name_ = false;
chunk_header.entity_ = OMFormat::Chunk::Entity_Vertex;
chunk_header.type_ = OMFormat::Chunk::Type_Status;
chunk_header.signed_ = false;
chunk_header.float_ = false;
chunk_header.dim_ = OMFormat::Chunk::Dim_1D;
chunk_header.bits_ = OMFormat::bits(s);
// std::clog << chunk_header << std::endl;
bytes += store(_os, chunk_header, swap);
for (i = 0, nV = header.n_vertices_; i < nV; ++i)
bytes += store(_os, _be.status(VertexHandle(i)), swap);
}
// ---------- write edge status
if (_be.n_edges() && _be.has_edge_status() && _opt.check(Options::Status))
{
auto s = _be.status(EdgeHandle(0));
chunk_header.name_ = false;
chunk_header.entity_ = OMFormat::Chunk::Entity_Edge;
chunk_header.type_ = OMFormat::Chunk::Type_Status;
chunk_header.signed_ = false;
chunk_header.float_ = false;
chunk_header.dim_ = OMFormat::Chunk::Dim_1D;
chunk_header.bits_ = OMFormat::bits(s);
// std::clog << chunk_header << std::endl;
bytes += store(_os, chunk_header, swap);
for (i = 0, nV = header.n_edges_; i < nV; ++i)
bytes += store(_os, _be.status(EdgeHandle(i)), swap);
}
// ---------- write halfedge status
if (_be.n_edges() && _be.has_halfedge_status() && _opt.check(Options::Status))
{
auto s = _be.status(HalfedgeHandle(0));
chunk_header.name_ = false;
chunk_header.entity_ = OMFormat::Chunk::Entity_Halfedge;
chunk_header.type_ = OMFormat::Chunk::Type_Status;
chunk_header.signed_ = false;
chunk_header.float_ = false;
chunk_header.dim_ = OMFormat::Chunk::Dim_1D;
chunk_header.bits_ = OMFormat::bits(s);
// std::clog << chunk_header << std::endl;
bytes += store(_os, chunk_header, swap);
for (i = 0, nV = header.n_edges_ * 2; i < nV; ++i)
bytes += store(_os, _be.status(HalfedgeHandle(i)), swap);
}
// ---------- write face status
if (_be.n_faces() && _be.has_face_status() && _opt.check(Options::Status))
{
auto s = _be.status(FaceHandle(0));
chunk_header.name_ = false;
chunk_header.entity_ = OMFormat::Chunk::Entity_Face;
chunk_header.type_ = OMFormat::Chunk::Type_Status;
chunk_header.signed_ = false;
chunk_header.float_ = false;
chunk_header.dim_ = OMFormat::Chunk::Dim_1D;
chunk_header.bits_ = OMFormat::bits(s);
// std::clog << chunk_header << std::endl;
bytes += store(_os, chunk_header, swap);
for (i = 0, nV = header.n_faces_; i < nV; ++i)
bytes += store(_os, _be.status(FaceHandle(i)), swap);
}
// -------------------- write custom properties
BaseKernel::const_prop_iterator prop;
for (prop = _be.kernel()->vprops_begin();
prop != _be.kernel()->vprops_end(); ++prop)
const auto store_property = [this, &_os, swap, &bytes](
const BaseKernel::const_prop_iterator _it_begin,
const BaseKernel::const_prop_iterator _it_end,
const OMFormat::Chunk::Entity _ent)
{
if ( !*prop ) continue;
if ( (*prop)->name()[1]==':') continue;
bytes += store_binary_custom_chunk(_os, **prop,
OMFormat::Chunk::Entity_Vertex, swap );
}
for (prop = _be.kernel()->fprops_begin();
prop != _be.kernel()->fprops_end(); ++prop)
{
if ( !*prop ) continue;
if ( (*prop)->name()[1]==':') continue;
bytes += store_binary_custom_chunk(_os, **prop,
OMFormat::Chunk::Entity_Face, swap );
}
for (prop = _be.kernel()->eprops_begin();
prop != _be.kernel()->eprops_end(); ++prop)
{
if ( !*prop ) continue;
if ( (*prop)->name()[1]==':') continue;
bytes += store_binary_custom_chunk(_os, **prop,
OMFormat::Chunk::Entity_Edge, swap );
}
for (prop = _be.kernel()->hprops_begin();
prop != _be.kernel()->hprops_end(); ++prop)
{
if ( !*prop ) continue;
if ( (*prop)->name()[1]==':') continue;
bytes += store_binary_custom_chunk(_os, **prop,
OMFormat::Chunk::Entity_Halfedge, swap );
}
for (prop = _be.kernel()->mprops_begin();
prop != _be.kernel()->mprops_end(); ++prop)
{
if ( !*prop ) continue;
if ( (*prop)->name()[1]==':') continue;
bytes += store_binary_custom_chunk(_os, **prop,
OMFormat::Chunk::Entity_Mesh, swap );
}
for (auto prop = _it_begin; prop != _it_end; ++prop)
{
if (!*prop || (*prop)->name().empty() ||
((*prop)->name().size() > 1 && (*prop)->name()[1] == ':'))
{ // skip dead and "private" properties (no name or name matches "?:*")
continue;
}
bytes += store_binary_custom_chunk(_os, **prop, _ent, swap);
}
};
store_property(_be.kernel()->vprops_begin(), _be.kernel()->vprops_end(),
OMFormat::Chunk::Entity_Vertex);
store_property(_be.kernel()->fprops_begin(), _be.kernel()->fprops_end(),
OMFormat::Chunk::Entity_Face);
store_property(_be.kernel()->eprops_begin(), _be.kernel()->eprops_end(),
OMFormat::Chunk::Entity_Edge);
store_property(_be.kernel()->hprops_begin(), _be.kernel()->hprops_end(),
OMFormat::Chunk::Entity_Halfedge);
store_property(_be.kernel()->mprops_begin(), _be.kernel()->mprops_end(),
OMFormat::Chunk::Entity_Mesh);
memset(&chunk_header, 0, sizeof(chunk_header));
chunk_header.name_ = false;

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
@@ -103,17 +98,17 @@ public:
/// Destructor
virtual ~_OMWriter_() {};
std::string get_description() const
std::string get_description() const override
{ return "OpenMesh Format"; }
std::string get_extensions() const
std::string get_extensions() const override
{ return "om"; }
bool write(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const;
bool write(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const override;
size_t binary_size(BaseExporter& _be, Options _opt) const override;
size_t binary_size(BaseExporter& _be, Options _opt) const;
static OMFormat::uint8 get_version() { return version_; }
protected:
@@ -121,7 +116,7 @@ protected:
static const OMFormat::uchar magic_[3];
static const OMFormat::uint8 version_;
bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const;
bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const override;
bool write_binary(std::ostream&, BaseExporter&, Options) const;

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//== INCLUDES =================================================================
@@ -127,14 +122,6 @@ write(std::ostream& _os, BaseExporter& _be, Options _opt, std::streamsize _preci
omerr() << "[PLYWriter] : Warning: Face normals are not supported and thus not exported! " << std::endl;
}
if ( _opt.check(Options::FaceColor) ) {
// Face normals are not supported
// Uncheck these options and output message that
// they are not written out even though they were requested
_opt.unset(Options::FaceColor);
omerr() << "[PLYWriter] : Warning: Face colors are not supported and thus not exported! " << std::endl;
}
options_ = _opt;
@@ -318,6 +305,24 @@ void _PLYWriter_::write_header(std::ostream& _out, BaseExporter& _be, Options& _
_out << "element face " << _be.n_faces() << '\n';
_out << "property list uchar int vertex_indices" << '\n';
if ( _opt.face_has_color() ){
if ( _opt.color_is_float() ) {
_out << "property float red" << '\n';
_out << "property float green" << '\n';
_out << "property float blue" << '\n';
if ( _opt.color_has_alpha() )
_out << "property float alpha" << '\n';
} else {
_out << "property uchar red" << '\n';
_out << "property uchar green" << '\n';
_out << "property uchar blue" << '\n';
if ( _opt.color_has_alpha() )
_out << "property uchar alpha" << '\n';
}
}
_ofProps = writeCustomTypeHeader(_out, _be.kernel()->fprops_begin(), _be.kernel()->fprops_end());
_out << "end_header" << '\n';
@@ -340,6 +345,7 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const
OpenMesh::Vec4f cAf;
OpenMesh::Vec2f t;
VertexHandle vh;
FaceHandle fh;
std::vector<VertexHandle> vhandles;
std::vector<CustomProperty> vProps;
@@ -405,12 +411,37 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const
// faces (indices starting at 0)
for (i=0, nF=int(_be.n_faces()); i<nF; ++i)
{
fh = FaceHandle(i);
// write vertex indices per face
nV = _be.get_vhandles(FaceHandle(i), vhandles);
nV = _be.get_vhandles(fh, vhandles);
_out << nV;
for (size_t j=0; j<vhandles.size(); ++j)
_out << " " << vhandles[j].idx();
// FaceColor
if ( _opt.face_has_color() ) {
//with alpha
if ( _opt.color_has_alpha() ){
if (_opt.color_is_float()) {
cAf = _be.colorAf(fh);
_out << " " << cAf;
} else {
cA = _be.colorAi(fh);
_out << " " << cA;
}
}else{
//without alpha
if (_opt.color_is_float()) {
cf = _be.colorf(fh);
_out << " " << cf;
} else {
c = _be.colori(fh);
_out << " " << c;
}
}
}
// write custom props
for (std::vector<CustomProperty>::iterator iter = fProps.begin(); iter < fProps.end(); ++iter)
write_customProp<false>(_out,*iter,i);
@@ -567,6 +598,7 @@ write_binary(std::ostream& _out, BaseExporter& _be, Options _opt) const
OpenMesh::Vec4uc c;
OpenMesh::Vec4f cf;
VertexHandle vh;
FaceHandle fh;
std::vector<VertexHandle> vhandles;
// vProps and fProps will be empty, until custom properties are supported by the binary writer
@@ -629,12 +661,35 @@ write_binary(std::ostream& _out, BaseExporter& _be, Options _opt) const
for (i=0, nF=int(_be.n_faces()); i<nF; ++i)
{
fh = FaceHandle(i);
//face
nV = _be.get_vhandles(FaceHandle(i), vhandles);
nV = _be.get_vhandles(fh, vhandles);
writeValue(ValueTypeUINT8, _out, nV);
for (size_t j=0; j<vhandles.size(); ++j)
writeValue(ValueTypeINT32, _out, vhandles[j].idx() );
// face color
if ( _opt.face_has_color() ) {
if ( _opt.color_is_float() ) {
cf = _be.colorAf(fh);
writeValue(ValueTypeFLOAT, _out, cf[0]);
writeValue(ValueTypeFLOAT, _out, cf[1]);
writeValue(ValueTypeFLOAT, _out, cf[2]);
if ( _opt.color_has_alpha() )
writeValue(ValueTypeFLOAT, _out, cf[3]);
} else {
c = _be.colorA(fh);
writeValue(ValueTypeUCHAR, _out, (int)c[0]);
writeValue(ValueTypeUCHAR, _out, (int)c[1]);
writeValue(ValueTypeUCHAR, _out, (int)c[2]);
if ( _opt.color_has_alpha() )
writeValue(ValueTypeUCHAR, _out, (int)c[3]);
}
}
for (std::vector<CustomProperty>::iterator iter = fProps.begin(); iter < fProps.end(); ++iter)
write_customProp<true>(_out,*iter,i);
}

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
@@ -87,6 +82,7 @@ namespace IO {
currently supported options:
- VertexColors
- FaceColors
- Binary
- Binary -> MSB
*/
@@ -99,14 +95,14 @@ public:
/// Destructor
virtual ~_PLYWriter_() {};
std::string get_description() const { return "PLY polygon file format"; }
std::string get_extensions() const { return "ply"; }
std::string get_description() const override { return "PLY polygon file format"; }
std::string get_extensions() const override { return "ply"; }
bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const;
bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const override;
bool write(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const;
bool write(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const override;
size_t binary_size(BaseExporter& _be, Options _opt) const;
size_t binary_size(BaseExporter& _be, Options _opt) const override;
enum ValueType {
Unsupported = 0,
@@ -124,7 +120,7 @@ private:
{
ValueType type;
const BaseProperty* property;
CustomProperty(const BaseProperty* const _p):type(Unsupported),property(_p){}
explicit CustomProperty(const BaseProperty* const _p):type(Unsupported),property(_p){}
};
const char* nameOfType_[12];

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//== INCLUDES =================================================================
@@ -158,7 +153,7 @@ write_stla(const std::string& _filename, BaseExporter& _be, Options /* _opt */)
int i, nF(int(_be.n_faces())), nV;
int i, nF(int(_be.n_faces()));
Vec3f a, b, c, n;
std::vector<VertexHandle> vhandles;
FaceHandle fh;
@@ -172,7 +167,7 @@ write_stla(const std::string& _filename, BaseExporter& _be, Options /* _opt */)
for (i=0; i<nF; ++i)
{
fh = FaceHandle(i);
nV = _be.get_vhandles(fh, vhandles);
const int nV = _be.get_vhandles(fh, vhandles);
if (nV == 3)
{
@@ -211,7 +206,7 @@ write_stla(std::ostream& _out, BaseExporter& _be, Options /* _opt */, std::strea
{
omlog() << "[STLWriter] : write ascii file\n";
int i, nF(int(_be.n_faces())), nV;
int i, nF(int(_be.n_faces()));
Vec3f a, b, c, n;
std::vector<VertexHandle> vhandles;
FaceHandle fh;
@@ -226,7 +221,7 @@ write_stla(std::ostream& _out, BaseExporter& _be, Options /* _opt */, std::strea
for (i=0; i<nF; ++i)
{
fh = FaceHandle(i);
nV = _be.get_vhandles(fh, vhandles);
const int nV = _be.get_vhandles(fh, vhandles);
if (nV == 3)
{
@@ -273,7 +268,7 @@ write_stlb(const std::string& _filename, BaseExporter& _be, Options /* _opt */)
}
int i, nF(int(_be.n_faces())), nV;
int i, nF(int(_be.n_faces()));
Vec3f a, b, c, n;
std::vector<VertexHandle> vhandles;
FaceHandle fh;
@@ -294,7 +289,7 @@ write_stlb(const std::string& _filename, BaseExporter& _be, Options /* _opt */)
for (i=0; i<nF; ++i)
{
fh = FaceHandle(i);
nV = _be.get_vhandles(fh, vhandles);
const int nV = _be.get_vhandles(fh, vhandles);
if (nV == 3)
{
@@ -344,7 +339,7 @@ write_stlb(std::ostream& _out, BaseExporter& _be, Options /* _opt */, std::strea
omlog() << "[STLWriter] : write binary file\n";
int i, nF(int(_be.n_faces())), nV;
int i, nF(int(_be.n_faces()));
Vec3f a, b, c, n;
std::vector<VertexHandle> vhandles;
FaceHandle fh;
@@ -366,7 +361,7 @@ write_stlb(std::ostream& _out, BaseExporter& _be, Options /* _opt */, std::strea
for (i=0; i<nF; ++i)
{
fh = FaceHandle(i);
nV = _be.get_vhandles(fh, vhandles);
const int nV = _be.get_vhandles(fh, vhandles);
if (nV == 3)
{

View File

@@ -39,12 +39,7 @@
* *
* ========================================================================= */
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
@@ -93,14 +88,14 @@ public:
/// Destructor
virtual ~_STLWriter_() {};
std::string get_description() const { return "Stereolithography Format"; }
std::string get_extensions() const { return "stl stla stlb"; }
std::string get_description() const override { return "Stereolithography Format"; }
std::string get_extensions() const override { return "stl stla stlb"; }
bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const;
bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const override;
bool write(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const;
bool write(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const override;
size_t binary_size(BaseExporter&, Options) const;
size_t binary_size(BaseExporter&, Options) const override;
private:
bool write_stla(const std::string&, BaseExporter&, Options) const;

View File

@@ -40,11 +40,7 @@ bool _VTKWriter_::write(const std::string& _filename, BaseExporter& _be, Options
bool _VTKWriter_::write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _precision) const
{
Vec3f v, n;
Vec2f t;
VertexHandle vh;
OpenMesh::Vec3f c;
OpenMesh::Vec4f cA;
// check exporter features
if (!check(_be, _opt)) {
@@ -78,7 +74,7 @@ bool _VTKWriter_::write(std::ostream& _out, BaseExporter& _be, Options _opt, std
_out << "POINTS " << _be.n_vertices() << " float\n";
size_t nv = _be.n_vertices();
for (size_t i = 0; i < nv; ++i) {
Vec3f v = _be.point(VertexHandle(int(i)));
const Vec3f v = _be.point(VertexHandle(int(i)));
_out << v[0] << ' ' << v[1] << ' ' << v[2] << '\n';
}

View File

@@ -29,13 +29,13 @@ class OPENMESHDLLEXPORT _VTKWriter_ : public BaseWriter
public:
_VTKWriter_();
std::string get_description() const { return "VTK"; }
std::string get_extensions() const { return "vtk"; }
std::string get_description() const override { return "VTK"; }
std::string get_extensions() const override { return "vtk"; }
bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const;
bool write(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const;
bool write(const std::string&, BaseExporter&, Options, std::streamsize _precision = 6) const override;
bool write(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const override;
size_t binary_size(BaseExporter&, Options) const { return 0; }
size_t binary_size(BaseExporter&, Options) const override { return 0; }
};
//== TYPE DEFINITION ==========================================================