Merge remote-tracking branch 'origin/master' into previous_halfedge

This commit is contained in:
Daniel Savchenko
2023-08-24 13:11:01 +02:00
58 changed files with 256 additions and 259 deletions

View File

@@ -170,8 +170,9 @@ class VectorT {
}
/// construct from an array
explicit VectorT(container&& _array) {
values_ = _array;
explicit VectorT(container&& _array) :
values_(_array)
{
}
/// copy & cast constructor (explicit)

View File

@@ -320,7 +320,7 @@ VectorT<Scalar, DIM>& minimize(VectorT<Scalar, DIM>& _v1, VectorT<Scalar, DIM>&
/// \relates OpenMesh::VectorT
/// non-member max
template<typename Scalar, int DIM>
VectorT<Scalar, DIM> max(VectorT<Scalar, DIM>& _v1, VectorT<Scalar, DIM>& _v2) {
VectorT<Scalar, DIM> max(const VectorT<Scalar, DIM>& _v1, const VectorT<Scalar, DIM>& _v2) {
return VectorT<Scalar, DIM>(_v1).maximize(_v2);
}
@@ -328,7 +328,7 @@ VectorT<Scalar, DIM> max(VectorT<Scalar, DIM>& _v1, VectorT<Scalar, DIM>& _v2) {
/// \relates OpenMesh::VectorT
/// non-member min
template<typename Scalar, int DIM>
VectorT<Scalar, DIM> min(VectorT<Scalar, DIM>& _v1, VectorT<Scalar, DIM>& _v2) {
VectorT<Scalar, DIM> min(const VectorT<Scalar, DIM>& _v1, const VectorT<Scalar, DIM>& _v2) {
return VectorT<Scalar, DIM>(_v1).minimize(_v2);
}

View File

@@ -74,7 +74,7 @@ namespace IO {
short int read_short(FILE* _in, bool _swap)
{
union u1 { short int s; unsigned char c[2]; } sc;
fread((char*)sc.c, 1, 2, _in);
fread(reinterpret_cast<char*>(sc.c), 1, 2, _in);
if (_swap) std::swap(sc.c[0], sc.c[1]);
return sc.s;
}
@@ -86,7 +86,7 @@ short int read_short(FILE* _in, bool _swap)
int read_int(FILE* _in, bool _swap)
{
union u2 { int i; unsigned char c[4]; } ic;
fread((char*)ic.c, 1, 4, _in);
fread(reinterpret_cast<char*>(ic.c), 1, 4, _in);
if (_swap) {
std::swap(ic.c[0], ic.c[3]);
std::swap(ic.c[1], ic.c[2]);
@@ -101,7 +101,7 @@ int read_int(FILE* _in, bool _swap)
float read_float(FILE* _in, bool _swap)
{
union u3 { float f; unsigned char c[4]; } fc;
fread((char*)fc.c, 1, 4, _in);
fread(reinterpret_cast<char*>(fc.c), 1, 4, _in);
if (_swap) {
std::swap(fc.c[0], fc.c[3]);
std::swap(fc.c[1], fc.c[2]);
@@ -116,7 +116,7 @@ float read_float(FILE* _in, bool _swap)
double read_double(FILE* _in, bool _swap)
{
union u4 { double d; unsigned char c[8]; } dc;
fread((char*)dc.c, 1, 8, _in);
fread(reinterpret_cast<char*>(dc.c), 1, 8, _in);
if (_swap) {
std::swap(dc.c[0], dc.c[7]);
std::swap(dc.c[1], dc.c[6]);
@@ -131,7 +131,7 @@ double read_double(FILE* _in, bool _swap)
short int read_short(std::istream& _in, bool _swap)
{
union u1 { short int s; unsigned char c[2]; } sc;
_in.read((char*)sc.c, 2);
_in.read(reinterpret_cast<char*>(sc.c), 2);
if (_swap) std::swap(sc.c[0], sc.c[1]);
return sc.s;
}
@@ -143,7 +143,7 @@ short int read_short(std::istream& _in, bool _swap)
int read_int(std::istream& _in, bool _swap)
{
union u2 { int i; unsigned char c[4]; } ic;
_in.read((char*)ic.c, 4);
_in.read(reinterpret_cast<char*>(ic.c), 4);
if (_swap) {
std::swap(ic.c[0], ic.c[3]);
std::swap(ic.c[1], ic.c[2]);
@@ -158,7 +158,7 @@ int read_int(std::istream& _in, bool _swap)
float read_float(std::istream& _in, bool _swap)
{
union u3 { float f; unsigned char c[4]; } fc;
_in.read((char*)fc.c, 4);
_in.read(reinterpret_cast<char*>(fc.c), 4);
if (_swap) {
std::swap(fc.c[0], fc.c[3]);
std::swap(fc.c[1], fc.c[2]);
@@ -173,7 +173,7 @@ float read_float(std::istream& _in, bool _swap)
double read_double(std::istream& _in, bool _swap)
{
union u4 { double d; unsigned char c[8]; } dc;
_in.read((char*)dc.c, 8);
_in.read(reinterpret_cast<char*>(dc.c), 8);
if (_swap) {
std::swap(dc.c[0], dc.c[7]);
std::swap(dc.c[1], dc.c[6]);
@@ -192,7 +192,7 @@ void write_short(short int _i, FILE* _out, bool _swap)
union u1 { short int s; unsigned char c[2]; } sc;
sc.s = _i;
if (_swap) std::swap(sc.c[0], sc.c[1]);
fwrite((char*)sc.c, 1, 2, _out);
fwrite(reinterpret_cast<char*>(sc.c), 1, 2, _out);
}
@@ -207,7 +207,7 @@ void write_int(int _i, FILE* _out, bool _swap)
std::swap(ic.c[0], ic.c[3]);
std::swap(ic.c[1], ic.c[2]);
}
fwrite((char*)ic.c, 1, 4, _out);
fwrite(reinterpret_cast<char*>(ic.c), 1, 4, _out);
}
@@ -222,7 +222,7 @@ void write_float(float _f, FILE* _out, bool _swap)
std::swap(fc.c[0], fc.c[3]);
std::swap(fc.c[1], fc.c[2]);
}
fwrite((char*)fc.c, 1, 4, _out);
fwrite(reinterpret_cast<char*>(fc.c), 1, 4, _out);
}
@@ -239,7 +239,7 @@ void write_double(double _d, FILE* _out, bool _swap)
std::swap(dc.c[2], dc.c[5]);
std::swap(dc.c[3], dc.c[4]);
}
fwrite((char*)dc.c, 1, 8, _out);
fwrite(reinterpret_cast<char*>(dc.c), 1, 8, _out);
}
@@ -251,7 +251,7 @@ void write_short(short int _i, std::ostream& _out, bool _swap)
union u1 { short int s; unsigned char c[2]; } sc;
sc.s = _i;
if (_swap) std::swap(sc.c[0], sc.c[1]);
_out.write((char*)sc.c, 2);
_out.write(reinterpret_cast<char*>(sc.c), 2);
}
@@ -266,7 +266,7 @@ void write_int(int _i, std::ostream& _out, bool _swap)
std::swap(ic.c[0], ic.c[3]);
std::swap(ic.c[1], ic.c[2]);
}
_out.write((char*)ic.c, 4);
_out.write(reinterpret_cast<char*>(ic.c), 4);
}
@@ -281,7 +281,7 @@ void write_float(float _f, std::ostream& _out, bool _swap)
std::swap(fc.c[0], fc.c[3]);
std::swap(fc.c[1], fc.c[2]);
}
_out.write((char*)fc.c, 4);
_out.write(reinterpret_cast<char*>(fc.c), 4);
}
@@ -298,7 +298,7 @@ void write_double(double _d, std::ostream& _out, bool _swap)
std::swap(dc.c[2], dc.c[5]);
std::swap(dc.c[3], dc.c[4]);
}
_out.write((char*)dc.c, 8);
_out.write(reinterpret_cast<char*>(dc.c), 8);
}

View File

@@ -141,8 +141,8 @@ namespace OMFormat {
size_t restore( std::istream& _is, bool _swap )
{
if (_is.read( (char*)this, 4 ).eof())
return 0;
if (_is.read( reinterpret_cast<char*>(this) , 4 ).eof())
return 0;
size_t bytes = 4;
bytes += binary<uint32_t>::restore( _is, n_vertices_, _swap );
@@ -307,7 +307,7 @@ namespace OMFormat {
/// Return the size of chunk data in bytes
inline size_t chunk_data_size( Header& _hdr, Chunk::Header& _chunk_hdr )
inline size_t chunk_data_size( const Header& _hdr, const Chunk::Header& _chunk_hdr )
{
size_t C;
switch( _chunk_hdr.entity_ )
@@ -327,7 +327,7 @@ namespace OMFormat {
return C * vector_size( _chunk_hdr );
}
inline size_t chunk_size( Header& _hdr, Chunk::Header& _chunk_hdr )
inline size_t chunk_size( const Header& _hdr, const Chunk::Header& _chunk_hdr )
{
return chunk_header_size() + chunk_data_size( _hdr, _chunk_hdr );
}

View File

@@ -80,11 +80,6 @@ namespace IO {
//-----------------------------------------------------------------------------
// struct binary, helper for storing/restoring
#define X \
std::ostringstream msg; \
msg << "Type not supported: " << typeid(value_type).name(); \
throw std::logic_error(msg.str())
/// \struct binary SR_binary.hh <OpenMesh/Core/IO/SR_binary.hh>
///
/// The struct defines how to store and restore the type T.
@@ -119,7 +114,11 @@ template < typename T, typename = void > struct binary
const value_type& /* _v */,
bool /* _swap */ = false ,
bool /* store_size */ = true ) // for vectors
{ X; return 0; }
{
std::ostringstream msg;
msg << "Type not supported: " << typeid(value_type).name();
throw std::logic_error(msg.str());
}
/// Restore a value of T and return the number of bytes read
static
@@ -127,7 +126,11 @@ template < typename T, typename = void > struct binary
value_type& /* _v */,
bool /* _swap */ = false ,
bool /* store_size */ = true ) // for vectors
{ X; return 0; }
{
std::ostringstream msg;
msg << "Type not supported: " << typeid(value_type).name();
throw std::logic_error(msg.str());
}
};
#undef X

View File

@@ -190,20 +190,20 @@ SIMPLE_BINARY(unsigned long);
static size_t store( std::ostream& _os, const value_type& _val, \
bool _swap=false) { \
value_type tmp = _val; \
size_t i, b = size_of(_val), N = value_type::size_; \
size_t b = size_of(_val), N = value_type::size_; \
if (_swap) \
for (i=0; i<N; ++i) \
for (size_t i=0; i<N; ++i) \
reverse_byte_order( tmp[i] ); \
_os.write( (const char*)&tmp[0], b ); \
return _os.good() ? b : 0; \
} \
\
static size_t restore( std::istream& _is, value_type& _val, \
bool _swap=false) { \
size_t i, N=value_type::size_; \
bool _swap=false) { \
size_t N=value_type::size_; \
size_t b = N * sizeof(value_type::value_type); \
_is.read( (char*)&_val[0], b ); \
if (_swap) for (i=0; i<N; ++i) \
if (_swap) for (size_t i=0; i<N; ++i) \
reverse_byte_order( _val[i] ); \
return _is.good() ? b : 0; \
} \

View File

@@ -121,14 +121,12 @@ public:
VHandles::const_iterator it, it2, end(_indices.end());
// test for valid vertex indices
for (it=_indices.begin(); it!=end; ++it)
if (! mesh_.is_valid_handle(*it))
{
// Test if all vertex handles are valid. If not, we throw an error.
if ( std::any_of(_indices.begin(),_indices.end(),[this](const VertexHandle& vh){ return !mesh_.is_valid_handle(vh); } ) )
{
omerr() << "ImporterT: Face contains invalid vertex index\n";
return fh;
}
}
// don't allow double vertices
for (it=_indices.begin(); it!=end; ++it)

View File

@@ -140,8 +140,7 @@ _OFFReader_::read(std::istream& _in, BaseImporter& _bi, Options& _opt )
}
// filter relevant options for reading
bool swap = _opt.check( Options::Swap );
bool swap_required = _opt.check( Options::Swap );
userOptions_ = _opt;
@@ -159,7 +158,7 @@ _OFFReader_::read(std::istream& _in, BaseImporter& _bi, Options& _opt )
options_ += Options::ColorAlpha;
return (options_.is_binary() ?
read_binary(_in, _bi, _opt, swap) :
read_binary(_in, _bi, _opt, swap_required) :
read_ascii(_in, _bi, _opt));
}

View File

@@ -166,12 +166,12 @@ bool _OMReader_::read_ascii(std::istream& /* _is */, BaseImporter& /* _bi */, Op
bool _OMReader_::read_binary(std::istream& _is, BaseImporter& _bi, Options& _opt) const
{
bool swap = _opt.check(Options::Swap) || (Endian::local() == Endian::MSB);
bool swap_required = _opt.check(Options::Swap) || (Endian::local() == Endian::MSB);
// Initialize byte counter
bytes_ = 0;
bytes_ += restore(_is, header_, swap);
bytes_ += restore(_is, header_, swap_required);
if (header_.version_ > _OMWriter_::get_version())
@@ -183,7 +183,7 @@ bool _OMReader_::read_binary(std::istream& _is, BaseImporter& _bi, Options& _opt
}
while (!_is.eof()) {
bytes_ += restore(_is, chunk_header_, swap);
bytes_ += restore(_is, chunk_header_, swap_required);
if (_is.eof())
break;
@@ -191,30 +191,30 @@ bool _OMReader_::read_binary(std::istream& _is, BaseImporter& _bi, Options& _opt
// Is this a named property restore the name
if (chunk_header_.name_) {
OMFormat::Chunk::PropertyName pn;
bytes_ += restore(_is, property_name_, swap);
bytes_ += restore(_is, property_name_, swap_required);
}
// Read in the property data. If it is an anonymous or unknown named
// property, then skip data.
switch (chunk_header_.entity_) {
case OMFormat::Chunk::Entity_Vertex:
if (!read_binary_vertex_chunk(_is, _bi, _opt, swap))
if (!read_binary_vertex_chunk(_is, _bi, _opt, swap_required))
return false;
break;
case OMFormat::Chunk::Entity_Face:
if (!read_binary_face_chunk(_is, _bi, _opt, swap))
if (!read_binary_face_chunk(_is, _bi, _opt, swap_required))
return false;
break;
case OMFormat::Chunk::Entity_Edge:
if (!read_binary_edge_chunk(_is, _bi, _opt, swap))
if (!read_binary_edge_chunk(_is, _bi, _opt, swap_required))
return false;
break;
case OMFormat::Chunk::Entity_Halfedge:
if (!read_binary_halfedge_chunk(_is, _bi, _opt, swap))
if (!read_binary_halfedge_chunk(_is, _bi, _opt, swap_required))
return false;
break;
case OMFormat::Chunk::Entity_Mesh:
if (!read_binary_mesh_chunk(_is, _bi, _opt, swap))
if (!read_binary_mesh_chunk(_is, _bi, _opt, swap_required))
return false;
break;
case OMFormat::Chunk::Entity_Sentinel:
@@ -291,7 +291,7 @@ bool _OMReader_::supports(const OMFormat::uint8 /* version */) const
//-----------------------------------------------------------------------------
bool _OMReader_::read_binary_vertex_chunk(std::istream &_is, BaseImporter &_bi, Options &_opt, bool _swap) const
bool _OMReader_::read_binary_vertex_chunk(std::istream &_is, BaseImporter &_bi, const Options &_opt, bool _swap) const
{
using OMFormat::Chunk;
@@ -447,7 +447,7 @@ bool _OMReader_::read_binary_vertex_chunk(std::istream &_is, BaseImporter &_bi,
//-----------------------------------------------------------------------------
bool _OMReader_::read_binary_face_chunk(std::istream &_is, BaseImporter &_bi, Options &_opt, bool _swap) const
bool _OMReader_::read_binary_face_chunk(std::istream &_is, BaseImporter &_bi, const Options &_opt, bool _swap) const
{
using OMFormat::Chunk;
@@ -589,7 +589,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, const Options &_opt, bool _swap) const
{
using OMFormat::Chunk;
@@ -641,7 +641,7 @@ 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, const Options & _opt, bool _swap) const
{
using OMFormat::Chunk;
@@ -749,7 +749,7 @@ bool _OMReader_::read_binary_halfedge_chunk(std::istream &_is, BaseImporter &_bi
//-----------------------------------------------------------------------------
bool _OMReader_::read_binary_mesh_chunk(std::istream &_is, BaseImporter &_bi, Options& _opt , bool _swap) const
bool _OMReader_::read_binary_mesh_chunk(std::istream &_is, BaseImporter &_bi, const Options& _opt , bool _swap) const
{
using OMFormat::Chunk;

View File

@@ -126,27 +126,27 @@ private:
bool read_binary_vertex_chunk( std::istream &_is,
BaseImporter &_bi,
Options &_opt,
const Options &_opt,
bool _swap) const;
bool read_binary_face_chunk( std::istream &_is,
BaseImporter &_bi,
Options &_opt,
const Options &_opt,
bool _swap) const;
bool read_binary_edge_chunk( std::istream &_is,
BaseImporter &_bi,
Options &_opt,
const Options &_opt,
bool _swap) const;
bool read_binary_halfedge_chunk( std::istream &_is,
BaseImporter &_bi,
Options &_opt,
const Options &_opt,
bool _swap) const;
bool read_binary_mesh_chunk( std::istream &_is,
BaseImporter &_bi,
Options &_opt,
const Options &_opt,
bool _swap) const;
size_t restore_binary_custom_data(std::istream& _is,

View File

@@ -142,7 +142,7 @@ bool _PLYReader_::read(std::istream& _in, BaseImporter& _bi, Options& _opt) {
}
// filter relevant options for reading
bool swap = _opt.check(Options::Swap);
bool swap_required = _opt.check(Options::Swap);
userOptions_ = _opt;
@@ -178,7 +178,7 @@ bool _PLYReader_::read(std::istream& _in, BaseImporter& _bi, Options& _opt) {
// if ( options_.is_binary() && userOptions_.color_has_alpha() )
// options_ += Options::ColorAlpha;
return (options_.is_binary() ? read_binary(_in, _bi, swap, _opt) : read_ascii(_in, _bi, _opt));
return (options_.is_binary() ? read_binary(_in, _bi, swap_required, _opt) : read_ascii(_in, _bi, _opt));
}
@@ -1384,8 +1384,7 @@ bool _PLYReader_::can_u_read(std::istream& _is) const {
elements_.push_back(element);
} else if (keyword == "property") {
std::string tmp1;
std::string tmp2;
std::string tmp1;
// Read first keyword, as it might be a list
_is >> tmp1;
@@ -1448,6 +1447,9 @@ bool _PLYReader_::can_u_read(std::istream& _is) const {
elements_.back().properties_.push_back(property);
} else {
std::string tmp2;
// as this is not a list property, read second value of property
_is >> tmp2;

View File

@@ -183,7 +183,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
size_t bytes = 0;
const bool swap =
const bool swap_required =
_writeOptions.check(Options::Swap) || (Endian::local() == Endian::MSB);
unsigned int i, nV, nF;
@@ -202,7 +202,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
header.n_faces_ = int(_be.n_faces());
header.n_edges_ = int(_be.n_edges());
bytes += store( _os, header, swap );
bytes += store( _os, header, swap_required );
// ---------------------------------------- write chunks
@@ -234,13 +234,13 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
chunk_header.bits_ = OMFormat::bits(v[0]);
}
bytes += store( _os, chunk_header, swap );
bytes += store( _os, chunk_header, swap_required );
if (_be.is_point_double())
for (i=0, nV=header.n_vertices_; i<nV; ++i)
bytes += vector_store( _os, _be.pointd(VertexHandle(i)), swap );
bytes += vector_store( _os, _be.pointd(VertexHandle(i)), swap_required );
else
for (i=0, nV=header.n_vertices_; i<nV; ++i)
bytes += vector_store( _os, _be.point(VertexHandle(i)), swap );
bytes += vector_store( _os, _be.point(VertexHandle(i)), swap_required );
}
@@ -268,13 +268,13 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
chunk_header.bits_ = OMFormat::bits(n[0]);
}
bytes += store( _os, chunk_header, swap );
bytes += store( _os, chunk_header, swap_required );
if (_be.is_normal_double())
for (i=0, nV=header.n_vertices_; i<nV; ++i)
bytes += vector_store( _os, _be.normald(VertexHandle(i)), swap );
bytes += vector_store( _os, _be.normald(VertexHandle(i)), swap_required );
else
for (i=0, nV=header.n_vertices_; i<nV; ++i)
bytes += vector_store( _os, _be.normal(VertexHandle(i)), swap );
bytes += vector_store( _os, _be.normal(VertexHandle(i)), swap_required );
}
@@ -291,9 +291,9 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
chunk_header.dim_ = OMFormat::dim( c );
chunk_header.bits_ = OMFormat::bits( c[0] );
bytes += store( _os, chunk_header, swap );
bytes += store( _os, chunk_header, swap_required );
for (i=0, nV=header.n_vertices_; i<nV; ++i)
bytes += vector_store( _os, _be.color(VertexHandle(i)), swap );
bytes += vector_store( _os, _be.color(VertexHandle(i)), swap_required );
}
// ---------- write vertex texture coords
@@ -309,10 +309,10 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
chunk_header.dim_ = OMFormat::dim(t);
chunk_header.bits_ = OMFormat::bits(t[0]);
bytes += store(_os, chunk_header, swap);
bytes += store(_os, chunk_header, swap_required);
for (i = 0, nV = header.n_vertices_; i < nV; ++i)
bytes += vector_store(_os, _be.texcoord(VertexHandle(i)), swap);
bytes += vector_store(_os, _be.texcoord(VertexHandle(i)), swap_required);
}
@@ -328,7 +328,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
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 );
bytes += store( _os, chunk_header, swap_required );
auto nE=header.n_edges_*2;
for (i=0; i<nE; ++i)
{
@@ -336,9 +336,9 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
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 );
bytes += store( _os, next_id, OMFormat::Chunk::Integer_Size(chunk_header.bits_), swap_required );
bytes += store( _os, to_vertex_id, OMFormat::Chunk::Integer_Size(chunk_header.bits_), swap_required );
bytes += store( _os, face_id, OMFormat::Chunk::Integer_Size(chunk_header.bits_), swap_required );
}
}
@@ -357,11 +357,11 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
chunk_header.dim_ = OMFormat::dim(t);
chunk_header.bits_ = OMFormat::bits(t[0]);
bytes += store(_os, chunk_header, swap);
bytes += store(_os, chunk_header, swap_required);
unsigned int nHE;
for (i = 0, nHE = header.n_edges_*2; i < nHE; ++i)
bytes += vector_store(_os, _be.texcoord(HalfedgeHandle(i)), swap);
bytes += vector_store(_os, _be.texcoord(HalfedgeHandle(i)), swap_required);
}
//---------------------------------------------------------------
@@ -378,9 +378,9 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
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 );
bytes += store( _os, chunk_header, swap_required );
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 );
bytes += store( _os, _be.get_halfedge_id(VertexHandle(i)), OMFormat::Chunk::Integer_Size(chunk_header.bits_), swap_required );
}
@@ -396,12 +396,12 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
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 );
bytes += store( _os, chunk_header, swap_required );
for (i=0, nF=header.n_faces_; i<nF; ++i)
{
auto size = OMFormat::Chunk::Integer_Size(chunk_header.bits_);
bytes += store( _os, _be.get_halfedge_id(FaceHandle(i)), size, swap);
bytes += store( _os, _be.get_halfedge_id(FaceHandle(i)), size, swap_required);
}
}
@@ -438,14 +438,14 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
chunk_header.bits_ = OMFormat::bits(n[0]);
}
bytes += store( _os, chunk_header, swap );
bytes += store( _os, chunk_header, swap_required );
#if !NEW_STYLE
if (_be.is_normal_double())
for (i=0, nF=header.n_faces_; i<nF; ++i)
bytes += vector_store( _os, _be.normald(FaceHandle(i)), swap );
bytes += vector_store( _os, _be.normald(FaceHandle(i)), swap_required );
else
for (i=0, nF=header.n_faces_; i<nF; ++i)
bytes += vector_store( _os, _be.normal(FaceHandle(i)), swap );
bytes += vector_store( _os, _be.normal(FaceHandle(i)), swap_required );
#else
bytes += bp->store(_os, swap );
@@ -478,10 +478,10 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
chunk_header.dim_ = OMFormat::dim( c );
chunk_header.bits_ = OMFormat::bits( c[0] );
bytes += store( _os, chunk_header, swap );
bytes += store( _os, chunk_header, swap_required );
#if !NEW_STYLE
for (i=0, nF=header.n_faces_; i<nF; ++i)
bytes += vector_store( _os, _be.color(FaceHandle(i)), swap );
bytes += vector_store( _os, _be.color(FaceHandle(i)), swap_required );
#else
bytes += bp->store(_os, swap);
}
@@ -503,10 +503,10 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
chunk_header.bits_ = OMFormat::bits(s);
// std::clog << chunk_header << std::endl;
bytes += store(_os, chunk_header, swap);
bytes += store(_os, chunk_header, swap_required);
for (i = 0, nV = header.n_vertices_; i < nV; ++i)
bytes += store(_os, _be.status(VertexHandle(i)), swap);
bytes += store(_os, _be.status(VertexHandle(i)), swap_required);
}
// ---------- write edge status
@@ -522,10 +522,10 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
chunk_header.bits_ = OMFormat::bits(s);
// std::clog << chunk_header << std::endl;
bytes += store(_os, chunk_header, swap);
bytes += store(_os, chunk_header, swap_required);
for (i = 0, nV = header.n_edges_; i < nV; ++i)
bytes += store(_os, _be.status(EdgeHandle(i)), swap);
bytes += store(_os, _be.status(EdgeHandle(i)), swap_required);
}
// ---------- write halfedge status
@@ -541,10 +541,10 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
chunk_header.bits_ = OMFormat::bits(s);
// std::clog << chunk_header << std::endl;
bytes += store(_os, chunk_header, swap);
bytes += store(_os, chunk_header, swap_required);
for (i = 0, nV = header.n_edges_ * 2; i < nV; ++i)
bytes += store(_os, _be.status(HalfedgeHandle(i)), swap);
bytes += store(_os, _be.status(HalfedgeHandle(i)), swap_required);
}
// ---------- write face status
@@ -560,17 +560,17 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
chunk_header.bits_ = OMFormat::bits(s);
// std::clog << chunk_header << std::endl;
bytes += store(_os, chunk_header, swap);
bytes += store(_os, chunk_header, swap_required);
for (i = 0, nV = header.n_faces_; i < nV; ++i)
bytes += store(_os, _be.status(FaceHandle(i)), swap);
bytes += store(_os, _be.status(FaceHandle(i)), swap_required);
}
// -------------------- write custom properties
if (_writeOptions.check(Options::Custom))
{
const auto store_property = [this, &_os, swap, &bytes](
const auto store_property = [this, &_os, swap_required, &bytes](
const BaseKernel::const_prop_iterator _it_begin,
const BaseKernel::const_prop_iterator _it_end,
const OMFormat::Chunk::Entity _ent)
@@ -582,7 +582,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
{ // skip dead and "private" properties (no name or name matches "?:*")
continue;
}
bytes += store_binary_custom_chunk(_os, **prop, _ent, swap);
bytes += store_binary_custom_chunk(_os, **prop, _ent, swap_required);
}
};
@@ -601,7 +601,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
memset(&chunk_header, 0, sizeof(chunk_header));
chunk_header.name_ = false;
chunk_header.entity_ = OMFormat::Chunk::Entity_Sentinel;
bytes += store(_os, chunk_header, swap);
bytes += store(_os, chunk_header, swap_required);
omlog() << "#bytes written: " << bytes << std::endl;

View File

@@ -139,7 +139,7 @@ write(std::ostream& _os, BaseExporter& _be, const Options& _writeOptions, std::s
bool
_STLWriter_::
write_stla(const std::string& _filename, BaseExporter& _be, Options /* _opt */) const
write_stla(const std::string& _filename, const BaseExporter& _be, Options /* _opt */) const
{
omlog() << "[STLWriter] : write ascii file\n";
@@ -204,7 +204,7 @@ write_stla(const std::string& _filename, BaseExporter& _be, Options /* _opt */)
bool
_STLWriter_::
write_stla(std::ostream& _out, BaseExporter& _be, Options /* _opt */, std::streamsize _precision) const
write_stla(std::ostream& _out, const BaseExporter& _be, Options /* _opt */, std::streamsize _precision) const
{
omlog() << "[STLWriter] : write ascii file\n";
@@ -256,7 +256,7 @@ write_stla(std::ostream& _out, BaseExporter& _be, Options /* _opt */, std::strea
bool
_STLWriter_::
write_stlb(const std::string& _filename, BaseExporter& _be, Options /* _opt */) const
write_stlb(const std::string& _filename, const BaseExporter& _be, Options /* _opt */) const
{
omlog() << "[STLWriter] : write binary file\n";
@@ -336,7 +336,7 @@ write_stlb(const std::string& _filename, BaseExporter& _be, Options /* _opt */)
bool
_STLWriter_::
write_stlb(std::ostream& _out, BaseExporter& _be, Options /* _opt */, std::streamsize _precision) const
write_stlb(std::ostream& _out, const BaseExporter& _be, Options /* _opt */, std::streamsize _precision) const
{
omlog() << "[STLWriter] : write binary file\n";

View File

@@ -98,10 +98,10 @@ public:
size_t binary_size(BaseExporter&, const Options&) const override;
private:
bool write_stla(const std::string&, BaseExporter&, Options) const;
bool write_stla(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const;
bool write_stlb(const std::string&, BaseExporter&, Options) const;
bool write_stlb(std::ostream&, BaseExporter&, Options, std::streamsize _precision = 6) const;
bool write_stla(const std::string&, const BaseExporter&, Options) const;
bool write_stla(std::ostream&, const BaseExporter&, Options, std::streamsize _precision = 6) const;
bool write_stlb(const std::string&, const BaseExporter&, Options) const;
bool write_stlb(std::ostream&, const BaseExporter&, Options, std::streamsize _precision = 6) const;
};

View File

@@ -40,8 +40,6 @@ bool _VTKWriter_::write(const std::string& _filename, BaseExporter& _be, const O
bool _VTKWriter_::write(std::ostream& _out, BaseExporter& _be, const Options& _writeOptions, std::streamsize _precision) const
{
VertexHandle vh;
// check exporter features
if (!check(_be, _writeOptions)) {
return false;

View File

@@ -738,7 +738,7 @@ public:
typedef typename HandleContainer::const_iterator
const_iterator;
public:
ExtStatusSetT(ArrayKernel& _kernel, size_t _capacity_hint = 0)
explicit ExtStatusSetT(ArrayKernel& _kernel, size_t _capacity_hint = 0)
: Base(_kernel)
{ handles_.reserve(_capacity_hint); }

View File

@@ -68,18 +68,18 @@ namespace Iterators {
template<class Mesh, class CenterEntityHandle, bool CW>
class GenericCirculator_CenterEntityFnsT {
public:
static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter);
static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter);
static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter);
static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter);
};
template<class Mesh>
class GenericCirculator_CenterEntityFnsT<Mesh, typename Mesh::VertexHandle, true> {
public:
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) {
heh = mesh->cw_rotated_halfedge_handle(heh);
if (heh == start) ++lap_counter;
}
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) {
if (heh == start) --lap_counter;
heh = mesh->ccw_rotated_halfedge_handle(heh);
}
@@ -88,11 +88,11 @@ class GenericCirculator_CenterEntityFnsT<Mesh, typename Mesh::VertexHandle, true
template<class Mesh>
class GenericCirculator_CenterEntityFnsT<Mesh, typename Mesh::FaceHandle, true> {
public:
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) {
heh = mesh->next_halfedge_handle(heh);
if (heh == start) ++lap_counter;
}
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) {
if (heh == start) --lap_counter;
heh = mesh->prev_halfedge_handle(heh);
}
@@ -104,11 +104,11 @@ class GenericCirculator_CenterEntityFnsT<Mesh, typename Mesh::FaceHandle, true>
template<class Mesh>
class GenericCirculator_CenterEntityFnsT<Mesh, typename Mesh::VertexHandle, false> {
public:
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) {
heh = mesh->ccw_rotated_halfedge_handle(heh);
if (heh == start) ++lap_counter;
}
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) {
if (heh == start) --lap_counter;
heh = mesh->cw_rotated_halfedge_handle(heh);
}
@@ -117,11 +117,11 @@ class GenericCirculator_CenterEntityFnsT<Mesh, typename Mesh::VertexHandle, fals
template<class Mesh>
class GenericCirculator_CenterEntityFnsT<Mesh, typename Mesh::FaceHandle, false> {
public:
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) {
heh = mesh->prev_halfedge_handle(heh);
if (heh == start) ++lap_counter;
}
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) {
if (heh == start) --lap_counter;
heh = mesh->next_halfedge_handle(heh);
}
@@ -171,10 +171,10 @@ class GenericCirculator_ValueHandleFnsT {
}
}
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) {
GenericCirculator_CenterEntityFnsT<Mesh, CenterEntityHandle, CW>::increment(mesh, heh, start, lap_counter);
}
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) {
GenericCirculator_CenterEntityFnsT<Mesh, CenterEntityHandle, CW>::decrement(mesh, heh, start, lap_counter);
}
};
@@ -426,10 +426,10 @@ class GenericCirculator_ValueHandleFnsT_DEPRECATED {
return ( heh.is_valid() && ((start != heh) || (lap_counter == 0 )) );
}
inline static void init(const Mesh*, typename Mesh::HalfedgeHandle&, typename Mesh::HalfedgeHandle&, int&) {};
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) {
GenericCirculator_CenterEntityFnsT<Mesh, CenterEntityHandle, true>::increment(mesh, heh, start, lap_counter);
}
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) {
GenericCirculator_CenterEntityFnsT<Mesh, CenterEntityHandle, true>::decrement(mesh, heh, start, lap_counter);
}
};
@@ -442,16 +442,16 @@ class GenericCirculator_ValueHandleFnsT_DEPRECATED<Mesh, CenterEntityHandle, typ
inline static bool is_valid(const typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, const int lap_counter) {
return ( heh.is_valid() && ((start != heh) || (lap_counter == 0 )));
}
inline static void init(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
inline static void init(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) {
if (heh.is_valid() && !GenericCirculator_DereferenciabilityCheck::isDereferenciable(mesh, heh) && lap_counter == 0 )
increment(mesh, heh, start, lap_counter);
};
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) {
do {
GenericCirculator_CenterEntityFnsT<Mesh, CenterEntityHandle, true>::increment(mesh, heh, start, lap_counter);
} while (is_valid(heh, start, lap_counter) && !GenericCirculator_DereferenciabilityCheck::isDereferenciable(mesh, heh));
}
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) {
do {
GenericCirculator_CenterEntityFnsT<Mesh, CenterEntityHandle, true>::decrement(mesh, heh, start, lap_counter);
} while (is_valid(heh, start, lap_counter) && !GenericCirculator_DereferenciabilityCheck::isDereferenciable(mesh, heh));

View File

@@ -174,7 +174,7 @@ PolyConnectivity::add_face(const VertexHandle* _vertex_handles, size_t _vhs_size
// search a free gap
// free gap will be between boundary_prev and boundary_next
outer_prev = opposite_halfedge_handle(inner_next);
outer_next = opposite_halfedge_handle(inner_prev);
//outer_next = opposite_halfedge_handle(inner_prev);
boundary_prev = outer_prev;
do
boundary_prev =
@@ -494,11 +494,8 @@ void PolyConnectivity::delete_vertex(VertexHandle _vh, bool _delete_isolated_ver
// delete collected faces
std::vector<FaceHandle>::iterator fh_it(face_handles.begin()),
fh_end(face_handles.end());
for (; fh_it!=fh_end; ++fh_it)
delete_face(*fh_it, _delete_isolated_vertices);
for (auto delete_fh_it : face_handles)
delete_face(delete_fh_it, _delete_isolated_vertices);
status(_vh).set_deleted(true);
}

View File

@@ -429,7 +429,7 @@ typename PolyMeshT<Kernel>::Normal
PolyMeshT<Kernel>::
calc_normal(EdgeHandle _eh) const
{
Normal n(0);
Normal n(0, 0, 0);
for (int i = 0; i < 2; ++i)
{
const auto heh = this->halfedge_handle(_eh, i);

View File

@@ -286,7 +286,7 @@ class PropertyManager {
Storage::swap(rhs, *this);
}
static bool propertyExists(PolyConnectivity &mesh, const char *propname) {
static bool propertyExists(const PolyConnectivity &mesh, const char *propname) {
PROPTYPE dummy;
return mesh.get_property_handle(dummy, propname);
}