Merge branch 'cpp_check' into 'master'

Cpp check

See merge request OpenMesh/OpenMesh!221
This commit is contained in:
Jan Möbius
2019-05-29 09:53:13 +02:00
66 changed files with 514 additions and 486 deletions

4
CI/ci-cppcheck.sh Normal file → Executable file
View File

@@ -20,7 +20,7 @@ echo -e "${NC}"
echo "Please Wait ..."
# Run cppcheck and output into file
cppcheck --enable=all . -I src -i Doc/ --force --suppress=unusedFunction -UCTIME --suppress=missingIncludeSystem --inline-suppr --quiet -Umin -Umax -DOPENMESHDLLEXPORT="" -UPRIVATE_NODE_TYPESYSTEM_SOURCE -USO_NODE_ABSTRACT_SOURCE -USO_NODE_SOURCE -UCLOCK_REALTIME_HR -i src/OpenMesh/Apps/Unsupported/ 2>&1 | tee cppcheck.log
cppcheck --enable=all . -I src -i Doc/ -i src/Unittests --force --suppress=unusedFunction -UCTIME --suppress=missingIncludeSystem --inline-suppr --quiet -Umin -Umax -DOPENMESHDLLEXPORT="" -UPRIVATE_NODE_TYPESYSTEM_SOURCE -USO_NODE_ABSTRACT_SOURCE -USO_NODE_SOURCE -UCLOCK_REALTIME_HR -i src/OpenMesh/Apps/Unsupported/ 2>&1 | tee cppcheck.log
COUNT=$(wc -l < cppcheck.log )
@@ -30,7 +30,7 @@ echo "CPPCHECK Summary"
echo "=============================================================================="
echo -e "${NC}"
MAX_COUNT=0
MAX_COUNT=27
if [ $COUNT -gt $MAX_COUNT ]; then
echo -e ${WARNING}

View File

@@ -19,7 +19,7 @@ if ( WIN32 )
list(APPEND ADDITIONAL_CMAKE_EXE_LINKER_FLAGS "/LARGEADDRESSAWARE" )
list(APPEND ADDITIONAL_CMAKE_SHARED_LINKER_FLAGS "/LARGEADDRESSAWARE" )
list(APPEND ADDITIONAL_CMAKE_MODULE_LINKER_FLAGS "/LARGEADDRESSAWARE" )
endif()
endif()
endif()
@@ -45,10 +45,12 @@ endif( WIN32 )
if (UNIX)
set ( ADDITIONAL_CXX_FLAGS )
set ( ADDITIONAL_CXX_DEBUG_FLAGS )
set ( ADDITIONAL_CXX_RELEASE_FLAGS )
set ( ADDITIONAL_CXX_RELWITHDEBINFO_FLAGS )
set ( ADDITIONAL_C_FLAGS )
set ( ADDITIONAL_C_DEBUG_FLAGS )
set ( ADDITIONAL_C_RELEASE_FLAGS )
set ( ADDITIONAL_C_RELWITHDEBINFO_FLAGS )
@@ -58,19 +60,13 @@ if (UNIX)
################################################################################
# add our standard flags for Template inclusion
list(APPEND ADDITIONAL_CXX_DEBUG_FLAGS "-DINCLUDE_TEMPLATES" )
list(APPEND ADDITIONAL_CXX_RELEASE_FLAGS "-DINCLUDE_TEMPLATES" )
list(APPEND ADDITIONAL_CXX_RELWITHDEBINFO_FLAGS "-DINCLUDE_TEMPLATES" )
list(APPEND ADDITIONAL_CXX_FLAGS "-DINCLUDE_TEMPLATES" )
list(APPEND ADDITIONAL_C_FLAGS "-DINCLUDE_TEMPLATES" )
# add our standard flags for Template inclusion
list(APPEND ADDITIONAL_C_DEBUG_FLAGS "-DINCLUDE_TEMPLATES" )
list(APPEND ADDITIONAL_C_RELEASE_FLAGS "-DINCLUDE_TEMPLATES" )
list(APPEND ADDITIONAL_C_RELWITHDEBINFO_FLAGS "-DINCLUDE_TEMPLATES" )
################################################################################
# OS Defines
################################################################################
if (APPLE)
add_definitions( -DARCH_DARWIN )
endif()
@@ -91,7 +87,7 @@ if (UNIX)
################################################################################
# Warnings
################################################################################
# Add the standard compiler warnings
if ( NOT COMPILER_WARNINGS )
@@ -104,18 +100,27 @@ if (UNIX)
set ( COMPILER_WARNINGS "" CACHE STRINGLIST "This list contains the warning flags used during compilation " )
ELSE ()
set ( COMPILER_WARNINGS "-W" "-Wall" "-Wno-unused" "-Wextra" "-Wno-variadic-macros" CACHE STRINGLIST "This list contains the warning flags used during compilation " )
ENDIF()
ENDIF()
endif ( NOT COMPILER_WARNINGS )
list(APPEND ADDITIONAL_CXX_DEBUG_FLAGS ${COMPILER_WARNINGS} )
list(APPEND ADDITIONAL_CXX_RELEASE_FLAGS ${COMPILER_WARNINGS} )
list(APPEND ADDITIONAL_CXX_RELWITHDEBINFO_FLAGS ${COMPILER_WARNINGS} )
list(APPEND ADDITIONAL_C_DEBUG_FLAGS ${COMPILER_WARNINGS} )
list(APPEND ADDITIONAL_C_RELEASE_FLAGS ${COMPILER_WARNINGS} )
list(APPEND ADDITIONAL_C_RELWITHDEBINFO_FLAGS ${COMPILER_WARNINGS} )
list(APPEND ADDITIONAL_CXX_FLAGS ${COMPILER_WARNINGS} )
list(APPEND ADDITIONAL_C_FLAGS ${COMPILER_WARNINGS} )
if ("${CMAKE_CXX_COMPILER}" MATCHES ".*clang.*")
list(APPEND ADDITIONAL_CXX_FLAGS "-Weverything")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-c++98-compat")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-padded")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-old-style-cast")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-documentation-unknown-command")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-unreachable-code-return")
# enable later:
list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-sign-conversion")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-deprecated")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-weak-vtables")
endif()
################################################################################
# STL Vector checks
################################################################################
@@ -147,43 +152,49 @@ if (UNIX)
################################################################################
# Add the debug flags
foreach( flag ${ADDITIONAL_CXX_DEBUG_FLAGS} )
if( NOT CMAKE_CXX_FLAGS_DEBUG MATCHES "${flag}" )
foreach( flag ${ADDITIONAL_CXX_FLAGS} ${ADDITIONAL_CXX_DEBUG_FLAGS} )
list (FIND ${CMAKE_CXX_FLAGS_DEBUG} ${flag} _index)
if (${_index} EQUAL -1)
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${flag} ")
endif()
endforeach()
# Add the release flags
foreach( flag ${ADDITIONAL_CXX_RELEASE_FLAGS} )
if( NOT CMAKE_CXX_FLAGS_RELEASE MATCHES "${flag}" )
foreach( flag ${ADDITIONAL_CXX_FLAGS} ${ADDITIONAL_CXX_RELEASE_FLAGS} )
list (FIND ${CMAKE_CXX_FLAGS_RELEASE} ${flag} _index)
if (${_index} EQUAL -1)
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${flag} ")
endif()
endforeach()
# Add the release with debug info flags
foreach( flag ${ADDITIONAL_CXX_RELWITHDEBINFO_FLAGS} )
if( NOT CMAKE_CXX_FLAGS_RELWITHDEBINFO MATCHES "${flag}" )
foreach( flag ${ADDITIONAL_CXX_FLAGS} ${ADDITIONAL_CXX_RELWITHDEBINFO_FLAGS} )
list (FIND ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${flag} _index)
if (${_index} EQUAL -1)
set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${flag} ")
endif()
endforeach()
# Add the debug flags
foreach( flag ${ADDITIONAL_C_DEBUG_FLAGS} )
if( NOT CMAKE_C_FLAGS_DEBUG MATCHES "${flag}" )
foreach( flag ${ADDITIONAL_C_FLAGS} ${ADDITIONAL_C_DEBUG_FLAGS} )
list (FIND ${CMAKE_C_FLAGS_DEBUG} ${flag} _index)
if (${_index} EQUAL -1)
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${flag} ")
endif()
endforeach()
# Add the release flags
foreach( flag ${ADDITIONAL_C_RELEASE_FLAGS} )
if( NOT CMAKE_C_FLAGS_RELEASE MATCHES "${flag}" )
foreach( flag ${ADDITIONAL_C_FLAGS} ${ADDITIONAL_C_RELEASE_FLAGS} )
list (FIND ${CMAKE_C_FLAGS_RELEASE} ${flag} _index)
if (${_index} EQUAL -1)
set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${flag} ")
endif()
endforeach()
# Add the release with debug info flags
foreach( flag ${ADDITIONAL_C_RELWITHDEBINFO_FLAGS} )
if( NOT CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES "${flag}" )
foreach( flag ${ADDITIONAL_C_FLAGS} ${ADDITIONAL_C_RELWITHDEBINFO_FLAGS} )
list (FIND ${CMAKE_C_FLAGS_RELWITHDEBINFO} ${flag} _index)
if (${_index} EQUAL -1)
set( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${flag} ")
endif()
endforeach()

View File

@@ -144,7 +144,7 @@ public:
public: // inherited
bool open_mesh(const char* _filename, OpenMesh::IO::Options _opt)
bool open_mesh(const char* _filename, OpenMesh::IO::Options _opt) override
{
bool rc;
@@ -170,7 +170,7 @@ protected slots:
protected:
virtual void keyPressEvent(QKeyEvent* _event);
virtual void keyPressEvent(QKeyEvent* _event) override;
private:

View File

@@ -216,7 +216,7 @@ decimate(const std::string &_ifname,
using namespace std;
Mesh mesh;
OpenMesh::IO::Options opt;
OpenMesh::IO::Options readopt;
OpenMesh::Utils::Timer timer;
// ---------------------------------------- read source mesh
@@ -227,7 +227,7 @@ decimate(const std::string &_ifname,
if (gverbose)
clog << _ifname << endl;
if ( !(rc = OpenMesh::IO::read_mesh(mesh, _ifname, opt)) )
if ( !(rc = OpenMesh::IO::read_mesh(mesh, _ifname, readopt)) )
{
cerr << " ERROR: read failed!" << endl;
return rc;
@@ -238,7 +238,7 @@ decimate(const std::string &_ifname,
{
// ---- 0 - For module NormalFlipping one needs face normals
if ( !opt.check( OpenMesh::IO::Options::FaceNormal ) )
if ( !readopt.check( OpenMesh::IO::Options::FaceNormal ) )
{
if ( !mesh.has_face_normals() )
mesh.request_face_normals();
@@ -420,11 +420,11 @@ decimate(const std::string &_ifname,
ofname.insert(++pos, n );
}
OpenMesh::IO::Options opt;
OpenMesh::IO::Options writeopt;
//opt += OpenMesh::IO::Options::Binary;
if ( !OpenMesh::IO::write_mesh(mesh, ofname, opt ) )
if ( !OpenMesh::IO::write_mesh(mesh, ofname, writeopt ) )
{
std::cerr << " Cannot write decimated mesh to file '"
<< ofname << "'\n";

View File

@@ -94,8 +94,12 @@ public:
public:
/// default constructor
ProgViewerWidget(QWidget* _parent=0)
: MeshViewerWidget(_parent)
explicit ProgViewerWidget(QWidget* _parent=0)
: MeshViewerWidget(_parent),
n_base_vertices_(0),
n_base_faces_(0),
n_detail_vertices_(0),
n_max_vertices_(0)
{
timer_ = new QTimer(this);
@@ -133,7 +137,7 @@ private:
/// coarsen mesh down to _n vertices
void coarsen(unsigned int _n);
virtual void keyPressEvent(QKeyEvent* _event);
virtual void keyPressEvent(QKeyEvent* _event) override;
// mesh data
bool animateRefinement_;

View File

@@ -77,7 +77,7 @@ public:
public:
/// default constructor
MeshViewerWidgetT(QWidget* _parent=0)
explicit MeshViewerWidgetT(QWidget* _parent=0)
: QGLViewerWidget(_parent),
f_strips_(false),
tex_id_(0),
@@ -85,7 +85,8 @@ public:
strips_(mesh_),
use_color_(true),
show_vnormals_(false),
show_fnormals_(false)
show_fnormals_(false),
normal_scale_(1.0)
{
add_draw_mode("Points");
add_draw_mode("Hidden-Line");
@@ -116,7 +117,7 @@ public:
protected:
/// inherited drawing method
virtual void draw_scene(const std::string& _draw_mode);
virtual void draw_scene(const std::string& _draw_mode) override;
protected:
@@ -170,7 +171,7 @@ protected: // Strip support
protected: // inherited
virtual void keyPressEvent( QKeyEvent* _event);
virtual void keyPressEvent( QKeyEvent* _event) override;
protected:

View File

@@ -74,7 +74,7 @@ public:
typedef QGLWidget Super;
// Default constructor.
QGLViewerWidget( QWidget* _parent=0 );
explicit QGLViewerWidget( QWidget* _parent=0 );
//
QGLViewerWidget( QGLFormat& _fmt, QWidget* _parent=0 );

View File

@@ -72,7 +72,7 @@ public:
typedef MeshViewerWidgetT<Mesh> Base;
/// default constructor
MeshViewerWidget(QWidget* _parent=0)
explicit MeshViewerWidget(QWidget* _parent=0)
: Base(_parent)
{}
@@ -80,7 +80,7 @@ public:
~MeshViewerWidget() {}
/// open mesh
inline bool open_mesh(const char* _filename, OpenMesh::IO::Options _opt)
inline bool open_mesh(const char* _filename, OpenMesh::IO::Options _opt) override
{
if ( Base::open_mesh( _filename, _opt ) )
{

View File

@@ -78,7 +78,14 @@ namespace OpenMesh {
//== IMPLEMENTATION ==========================================================
VDPMSynthesizerViewerWidget::VDPMSynthesizerViewerWidget(QWidget* _parent, const char* _name)
: MeshViewerWidget(_parent)
: MeshViewerWidget(_parent),
kappa_square_(0.0),
adaptive_mode_(false),
n_base_vertices_(0),
n_base_edges_(0),
n_base_faces_(0),
n_details_(0)
{
adaptive_mode_ = true;
}

View File

@@ -107,7 +107,7 @@ public:
public: // inherited
void initialize(void)
void initialize(void) override
{
BaseModQ::initialize();
n_vertices_ = BaseModQ::mesh().n_vertices();

View File

@@ -89,17 +89,17 @@ protected:
inline static Scalar compute_limit_weight(uint _valence)
{
double proj_weight = compute_proj_weight(_valence);
proj_weight = proj_weight/(proj_weight + _valence);//normalize the proj_weight
double weight = (3.0/8.0)/(1.0 - proj_weight + (3.0/8.0));
double proj_weight_value = compute_proj_weight(_valence);
proj_weight_value = proj_weight_value/(proj_weight_value + _valence);//normalize the proj_weight
double weight = (3.0/8.0)/(1.0 - proj_weight_value + (3.0/8.0));
return (Scalar)weight;
}
inline static Scalar compute_step_weight(uint _valence)
{
double proj_weight = compute_proj_weight(_valence);
proj_weight = proj_weight/(proj_weight + _valence);//normalize the proj_weight
double weight = proj_weight - (3.0/8.0);
double proj_weight_value = compute_proj_weight(_valence);
proj_weight_value = proj_weight_value/(proj_weight_value + _valence);//normalize the proj_weight
double weight = proj_weight_value - (3.0/8.0);
return (Scalar)weight;
}

View File

@@ -112,7 +112,7 @@ public:
{}
template <class _Point>
QuadricT(const _Point& _pt)
explicit QuadricT(const _Point& _pt)
{
set_distance_to_point(_pt);
}

View File

@@ -147,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
@@ -159,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

@@ -252,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() ); }

View File

@@ -84,7 +84,7 @@ class ExporterT : public BaseExporter
public:
// Constructor
ExporterT(const Mesh& _mesh) : mesh_(_mesh) {}
explicit ExporterT(const Mesh& _mesh) : mesh_(_mesh) {}
// get vertex data

View File

@@ -89,7 +89,7 @@ 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) override

View File

@@ -135,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);

View File

@@ -87,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:
@@ -105,7 +105,7 @@ private:
{
public:
Material() { cleanup(); }
Material():Tr_(0),index_Kd_(0) { cleanup(); }
void cleanup()
{
@@ -137,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

@@ -118,17 +118,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:

View File

@@ -387,10 +387,12 @@ bool _OMReader_::read_binary_vertex_chunk(std::istream &_is, BaseImporter &_bi,
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..?!
@@ -505,9 +507,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_;
@@ -549,9 +551,9 @@ bool _OMReader_::read_binary_edge_chunk(std::istream &_is, BaseImporter &_bi, Op
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_;
@@ -627,9 +629,9 @@ bool _OMReader_::read_binary_halfedge_chunk(std::istream &_is, BaseImporter &_bi
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_;
@@ -655,9 +657,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

@@ -89,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

@@ -97,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,

View File

@@ -92,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

@@ -133,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

@@ -100,24 +100,24 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt, std::stream
{
#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);
@@ -206,7 +206,7 @@ _OBJWriter_::
write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _precision) const
{
unsigned int idx;
size_t i, j,nV, nF;
size_t nV, nF;
Vec3f v, n;
Vec2f t;
VertexHandle vh;
@@ -273,7 +273,7 @@ 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;
}
@@ -303,7 +303,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);
@@ -324,7 +324,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) ){
@@ -351,7 +351,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

@@ -88,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

@@ -97,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

@@ -98,15 +98,15 @@ 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;
size_t binary_size(BaseExporter& _be, Options _opt) const override;
static OMFormat::uint8 get_version() { return version_; }
@@ -116,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

@@ -95,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,
@@ -120,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

@@ -88,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,7 +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;
Vec3f n;
Vec2f t;
VertexHandle vh;
OpenMesh::Vec3f c;
@@ -78,7 +78,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 ==========================================================

View File

@@ -340,10 +340,10 @@ public:
void clean_keep_reservation();
// --- number of items ---
size_t n_vertices() const { return vertices_.size(); }
size_t n_halfedges() const { return 2*edges_.size(); }
size_t n_edges() const { return edges_.size(); }
size_t n_faces() const { return faces_.size(); }
size_t n_vertices() const override { return vertices_.size(); }
size_t n_halfedges() const override { return 2*edges_.size(); }
size_t n_edges() const override { return edges_.size(); }
size_t n_faces() const override { return faces_.size(); }
bool vertices_empty() const { return vertices_.empty(); }
bool halfedges_empty() const { return edges_.empty(); }
@@ -697,7 +697,7 @@ public:
typedef StatusSetT<Handle> Base;
public:
AutoStatusSetT(ArrayKernel& _kernel)
explicit AutoStatusSetT(ArrayKernel& _kernel)
: StatusSetT<Handle>(_kernel, _kernel.pop_bit_mask(Handle()))
{ /*assert(size() == 0);*/ } //the set should be empty on creation

View File

@@ -1121,7 +1121,7 @@ public:
typedef ITER_TYPE iterator;
typedef ITER_TYPE const_iterator;
EntityRange(CONTAINER_TYPE &container) : container_(container) {}
explicit EntityRange(CONTAINER_TYPE &container) : container_(container) {}
ITER_TYPE begin() const { return (container_.*begin_fn)(); }
ITER_TYPE end() const { return (container_.*end_fn)(); }

View File

@@ -97,7 +97,7 @@ class PolyMesh_ArrayKernelT
public:
PolyMesh_ArrayKernelT() {}
template<class OtherTraits>
PolyMesh_ArrayKernelT( const TriMesh_ArrayKernelT<OtherTraits> & t)
explicit PolyMesh_ArrayKernelT( const TriMesh_ArrayKernelT<OtherTraits> & t)
{
//assign the connectivity and standard properties
this->assign(t, true);

View File

@@ -97,7 +97,7 @@ class TriMesh_ArrayKernelT
public:
TriMesh_ArrayKernelT() {}
template<class OtherTraits>
TriMesh_ArrayKernelT( const PolyMesh_ArrayKernelT<OtherTraits> & t)
explicit TriMesh_ArrayKernelT( const PolyMesh_ArrayKernelT<OtherTraits> & t)
{
//assign the connectivity and standard properties
this->assign(t,true);

View File

@@ -92,7 +92,7 @@ class multiplex_target : public basic_multiplex_target
{
public:
explicit multiplex_target(T& _t) : target_(_t) {}
virtual void operator<<(const std::string& _s) { target_ << _s; }
virtual void operator<<(const std::string& _s) override { target_ << _s; }
private:
T& target_;
};

View File

@@ -99,7 +99,7 @@ public:
public:
/// Default constructor
PropertyT(const std::string& _name = "<unknown>")
explicit PropertyT(const std::string& _name = "<unknown>")
: BaseProperty(_name)
{}
@@ -109,22 +109,22 @@ public:
public: // inherited from BaseProperty
virtual void reserve(size_t _n) { data_.reserve(_n); }
virtual void resize(size_t _n) { data_.resize(_n); }
virtual void clear() { data_.clear(); vector_type().swap(data_); }
virtual void push_back() { data_.push_back(T()); }
virtual void swap(size_t _i0, size_t _i1)
virtual void reserve(size_t _n) override { data_.reserve(_n); }
virtual void resize(size_t _n) override { data_.resize(_n); }
virtual void clear() override { data_.clear(); vector_type().swap(data_); }
virtual void push_back() override { data_.push_back(T()); }
virtual void swap(size_t _i0, size_t _i1) override
{ std::swap(data_[_i0], data_[_i1]); }
virtual void copy(size_t _i0, size_t _i1)
virtual void copy(size_t _i0, size_t _i1) override
{ data_[_i1] = data_[_i0]; }
public:
virtual void set_persistent( bool _yn )
virtual void set_persistent( bool _yn ) override
{ check_and_set_persistent<T>( _yn ); }
virtual size_t n_elements() const { return data_.size(); }
virtual size_t element_size() const { return IO::size_of<T>(); }
virtual size_t n_elements() const override { return data_.size(); }
virtual size_t element_size() const override { return IO::size_of<T>(); }
#ifndef DOXY_IGNORE_THIS
struct plus {
@@ -133,17 +133,17 @@ public:
};
#endif
virtual size_t size_of(void) const
virtual size_t size_of(void) const override
{
if (element_size() != IO::UnknownSize)
return this->BaseProperty::size_of(n_elements());
return std::accumulate(data_.begin(), data_.end(), size_t(0), plus());
}
virtual size_t size_of(size_t _n_elem) const
virtual size_t size_of(size_t _n_elem) const override
{ return this->BaseProperty::size_of(_n_elem); }
virtual size_t store( std::ostream& _ostr, bool _swap ) const
virtual size_t store( std::ostream& _ostr, bool _swap ) const override
{
if ( IO::is_streamable<vector_type>() )
return IO::store(_ostr, data_, _swap );
@@ -153,7 +153,7 @@ public:
return bytes;
}
virtual size_t restore( std::istream& _istr, bool _swap )
virtual size_t restore( std::istream& _istr, bool _swap ) override
{
if ( IO::is_streamable<vector_type>() )
return IO::restore(_istr, data_, _swap );
@@ -199,7 +199,7 @@ public: // data access interface
}
/// Make a copy of self.
PropertyT<T>* clone() const
PropertyT<T>* clone() const override
{
PropertyT<T>* p = new PropertyT<T>( *this );
return p;
@@ -230,37 +230,37 @@ public:
public:
PropertyT(const std::string& _name = "<unknown>")
explicit PropertyT(const std::string& _name = "<unknown>")
: BaseProperty(_name)
{ }
public: // inherited from BaseProperty
virtual void reserve(size_t _n) { data_.reserve(_n); }
virtual void resize(size_t _n) { data_.resize(_n); }
virtual void clear() { data_.clear(); vector_type().swap(data_); }
virtual void push_back() { data_.push_back(bool()); }
virtual void swap(size_t _i0, size_t _i1)
virtual void reserve(size_t _n) override { data_.reserve(_n); }
virtual void resize(size_t _n) override { data_.resize(_n); }
virtual void clear() override { data_.clear(); vector_type().swap(data_); }
virtual void push_back() override { data_.push_back(bool()); }
virtual void swap(size_t _i0, size_t _i1) override
{ bool t(data_[_i0]); data_[_i0]=data_[_i1]; data_[_i1]=t; }
virtual void copy(size_t _i0, size_t _i1)
virtual void copy(size_t _i0, size_t _i1) override
{ data_[_i1] = data_[_i0]; }
public:
virtual void set_persistent( bool _yn )
virtual void set_persistent( bool _yn ) override
{
check_and_set_persistent<bool>( _yn );
}
virtual size_t n_elements() const { return data_.size(); }
virtual size_t element_size() const { return UnknownSize; }
virtual size_t size_of() const { return size_of( n_elements() ); }
virtual size_t size_of(size_t _n_elem) const
virtual size_t n_elements() const override { return data_.size(); }
virtual size_t element_size() const override { return UnknownSize; }
virtual size_t size_of() const override { return size_of( n_elements() ); }
virtual size_t size_of(size_t _n_elem) const override
{
return _n_elem / 8 + ((_n_elem % 8)!=0);
}
size_t store( std::ostream& _ostr, bool /* _swap */ ) const
size_t store( std::ostream& _ostr, bool /* _swap */ ) const override
{
size_t bytes = 0;
@@ -299,7 +299,7 @@ public:
return bytes;
}
size_t restore( std::istream& _istr, bool /* _swap */ )
size_t restore( std::istream& _istr, bool /* _swap */ ) override
{
size_t bytes = 0;
@@ -394,40 +394,40 @@ public:
public:
PropertyT(const std::string& _name = "<unknown>")
explicit PropertyT(const std::string& _name = "<unknown>")
: BaseProperty(_name)
{ }
public: // inherited from BaseProperty
virtual void reserve(size_t _n) { data_.reserve(_n); }
virtual void resize(size_t _n) { data_.resize(_n); }
virtual void clear() { data_.clear(); vector_type().swap(data_); }
virtual void push_back() { data_.push_back(std::string()); }
virtual void swap(size_t _i0, size_t _i1) {
virtual void reserve(size_t _n) override { data_.reserve(_n); }
virtual void resize(size_t _n) override { data_.resize(_n); }
virtual void clear() override { data_.clear(); vector_type().swap(data_); }
virtual void push_back() override { data_.push_back(std::string()); }
virtual void swap(size_t _i0, size_t _i1) override {
std::swap(data_[_i0], data_[_i1]);
}
virtual void copy(size_t _i0, size_t _i1)
virtual void copy(size_t _i0, size_t _i1) override
{ data_[_i1] = data_[_i0]; }
public:
virtual void set_persistent( bool _yn )
virtual void set_persistent( bool _yn ) override
{ check_and_set_persistent<std::string>( _yn ); }
virtual size_t n_elements() const { return data_.size(); }
virtual size_t element_size() const { return UnknownSize; }
virtual size_t size_of() const
virtual size_t n_elements() const override { return data_.size(); }
virtual size_t element_size() const override { return UnknownSize; }
virtual size_t size_of() const override
{ return IO::size_of( data_ ); }
virtual size_t size_of(size_t /* _n_elem */) const
virtual size_t size_of(size_t /* _n_elem */) const override
{ return UnknownSize; }
/// Store self as one binary block. Max. length of a string is 65535 bytes.
size_t store( std::ostream& _ostr, bool _swap ) const
size_t store( std::ostream& _ostr, bool _swap ) const override
{ return IO::store( _ostr, data_, _swap ); }
size_t restore( std::istream& _istr, bool _swap )
size_t restore( std::istream& _istr, bool _swap ) override
{ return IO::restore( _istr, data_, _swap ); }
public:

View File

@@ -322,21 +322,21 @@ private:
#ifndef DOXY_IGNORE_THIS
struct Reserve
{
Reserve(size_t _n) : n_(_n) {}
explicit Reserve(size_t _n) : n_(_n) {}
void operator()(BaseProperty* _p) const { if (_p) _p->reserve(n_); }
size_t n_;
};
struct Resize
{
Resize(size_t _n) : n_(_n) {}
explicit Resize(size_t _n) : n_(_n) {}
void operator()(BaseProperty* _p) const { if (_p) _p->resize(n_); }
size_t n_;
};
struct ResizeIfSmaller
{
ResizeIfSmaller(size_t _n) : n_(_n) {}
explicit ResizeIfSmaller(size_t _n) : n_(_n) {}
void operator()(BaseProperty* _p) const { if (_p && _p->n_elements() < n_) _p->resize(n_); }
size_t n_;
};
@@ -357,7 +357,7 @@ private:
struct Delete
{
Delete() {}
void operator()(BaseProperty* _p) const { if (_p) delete _p; _p=NULL; }
void operator()(BaseProperty* _p) const { if (_p) delete _p; }
};
#endif

View File

@@ -94,7 +94,7 @@ public: //-------------------------------------------------------- public types
typedef typename ModuleList::iterator ModuleListIterator;
public: //------------------------------------------------------ public methods
BaseDecimaterT(Mesh& _mesh);
explicit BaseDecimaterT(Mesh& _mesh);
virtual ~BaseDecimaterT();
/** Initialize decimater and decimating modules.

View File

@@ -89,7 +89,7 @@ public: //-------------------------------------------------------- public types
public: //------------------------------------------------------ public methods
/// Constructor
DecimaterT( Mesh& _mesh );
explicit DecimaterT( Mesh& _mesh );
/// Destructor
~DecimaterT();

View File

@@ -72,7 +72,7 @@ class ModIndependentSetsT: public ModBaseT<MeshT> {
;
/// Constructor
ModIndependentSetsT(MeshT &_mesh) :
explicit ModIndependentSetsT(MeshT &_mesh) :
Base(_mesh, true) {
}

View File

@@ -208,9 +208,9 @@ public:
// the smaller the factor, the smaller normal_deviation_ gets
// thus creating a stricter constraint
// division by error_tolerance_factor_ is for normalization
Scalar normal_deviation = normal_deviation_ * static_cast<Scalar>( 180.0 / M_PI * _factor / this->error_tolerance_factor_);
Scalar normal_deviation_value = normal_deviation_ * static_cast<Scalar>( 180.0 / M_PI * _factor / this->error_tolerance_factor_);
set_normal_deviation(normal_deviation);
set_normal_deviation(normal_deviation_value);
this->error_tolerance_factor_ = _factor;
}
}

View File

@@ -86,7 +86,7 @@ public:
public:
/// Constructor
ModNormalFlippingT( MeshT &_mesh) : Base(_mesh, true)
explicit ModNormalFlippingT( MeshT &_mesh) : Base(_mesh, true)
{
set_max_normal_deviation( 90.0f );
const bool mesh_has_normals = _mesh.has_face_normals();
@@ -159,8 +159,8 @@ public:
// the smaller the factor, the smaller max_deviation_ gets
// thus creating a stricter constraint
// division by error_tolerance_factor_ is for normalization
double max_normal_deviation = (max_deviation_ * 180.0/M_PI) * _factor / this->error_tolerance_factor_;
set_max_normal_deviation(max_normal_deviation);
double max_normal_deviation_value = (max_deviation_ * 180.0/M_PI) * _factor / this->error_tolerance_factor_;
set_max_normal_deviation(max_normal_deviation_value);
this->error_tolerance_factor_ = _factor;
}
}

View File

@@ -90,7 +90,7 @@ public:
{
/// Initializing constructor copies appropriate handles from
/// collapse information \c _ci.
Info( const CollapseInfo& _ci )
explicit Info( const CollapseInfo& _ci )
: v0(_ci.v0), v1(_ci.v1), vl(_ci.vl),vr(_ci.vr)
{}
@@ -108,7 +108,7 @@ public:
public:
/// Constructor
ModProgMeshT( MeshT &_mesh ) : Base(_mesh, true)
explicit ModProgMeshT( MeshT &_mesh ) : Base(_mesh, true)
{
Base::mesh().add_property( idx_ );
}

View File

@@ -85,7 +85,7 @@ public:
/** Constructor
* \internal
*/
ModQuadricT( MeshT &_mesh )
explicit ModQuadricT( MeshT &_mesh )
: Base(_mesh, false)
{
unset_max_err();
@@ -103,7 +103,7 @@ public:
public: // inherited
/// Initalize the module and prepare the mesh for decimation.
virtual void initialize(void);
virtual void initialize(void) override;
/** Compute collapse priority based on error quadrics.
*
@@ -138,7 +138,7 @@ public: // inherited
}
/// set the percentage of maximum quadric error
void set_error_tolerance_factor(double _factor);
void set_error_tolerance_factor(double _factor) override;

View File

@@ -97,7 +97,7 @@ class ModRoundnessT : public ModBaseT<MeshT>
public:
/// Constructor
ModRoundnessT( MeshT &_dec ) :
explicit ModRoundnessT( MeshT &_dec ) :
Base(_dec, false),
min_r_(-1.0)
{ }

View File

@@ -79,7 +79,7 @@ private:
public:
JacobiLaplaceSmootherT( Mesh& _mesh ) : LaplaceSmootherT<Mesh>(_mesh) {}
explicit JacobiLaplaceSmootherT( Mesh& _mesh ) : LaplaceSmootherT<Mesh>(_mesh) {}
// override: alloc umbrellas
void smooth(unsigned int _n);

View File

@@ -83,7 +83,7 @@ public:
typedef typename SmootherT<Mesh>::EdgeHandle EdgeHandle;
LaplaceSmootherT( Mesh& _mesh );
explicit LaplaceSmootherT( Mesh& _mesh );
virtual ~LaplaceSmootherT();

View File

@@ -134,7 +134,6 @@ compute_weights(LaplaceWeighting _weighting)
typename Mesh::EdgeIter e_it, e_end(Base::mesh_.edges_end());
typename Mesh::HalfedgeHandle heh0, heh1, heh2;
typename Mesh::VertexHandle v0, v1;
const typename Mesh::Point *p0, *p1, *p2;
typename Mesh::Normal d0, d1;
typename Mesh::Scalar weight, lb(-1.0), ub(1.0);
@@ -171,7 +170,9 @@ compute_weights(LaplaceWeighting _weighting)
case CotWeighting:
{
for (e_it=Base::mesh_.edges_begin(); e_it!=e_end; ++e_it)
{
{
const typename Mesh::Point *p0, *p1, *p2;
weight = 0.0;
heh0 = Base::mesh_.halfedge_handle(*e_it, 0);

View File

@@ -146,7 +146,7 @@ public:
public:
/// Constructor
CompositeT(Mesh& _mesh)
explicit CompositeT(Mesh& _mesh)
: subdiv_type_(0),
subdiv_rule_(NULL), /*first_rule_(NULL), last_rule_(NULL),*/ mesh_(_mesh)
{ }
@@ -256,15 +256,15 @@ protected:
protected: // helper
// get current generation from state
state_t generation(state_t _s) { return _s-(_s % n_rules()); }
state_t generation( VH _vh ) { return generation(mesh_.data(_vh).state()); }
state_t generation( EH _eh ) { return generation(mesh_.data(_eh).state()); }
state_t generation( FH _fh ) { return generation(mesh_.data(_fh).state()); }
state_t generation(state_t _s) const { return _s-(_s % n_rules()); }
state_t generation( VH _vh ) const { return generation(mesh_.data(_vh).state()); }
state_t generation( EH _eh ) const { return generation(mesh_.data(_eh).state()); }
state_t generation( FH _fh ) const { return generation(mesh_.data(_fh).state()); }
private:
// short cuts
Rule* t_rule() { return subdiv_rule_; }
Rule* t_rule() const { return subdiv_rule_; }
Rule* f_rule() { return rule_sequence_.front(); }
Rule* l_rule() { return rule_sequence_.back(); }

View File

@@ -96,7 +96,7 @@ struct RuleHandleT : public BaseHandle
protected:\
friend class CompositeT<mesh_type>; \
public: \
const char *type() const { return #classname; } \
const char *type() const override { return #classname; } \
typedef classname<mesh_type> Self; \
typedef RuleHandleT< Self > Handle
@@ -118,7 +118,7 @@ public:
protected:
/// Default constructor
RuleInterfaceT(Mesh& _mesh) : mesh_(_mesh) {};
RuleInterfaceT(Mesh& _mesh) : mesh_(_mesh),prev_rule_(nullptr),subdiv_rule_(nullptr),subdiv_type_(0),number_(0),n_rules_(0) {};
public:
@@ -358,12 +358,12 @@ protected:
Self* prev_rule() { return prev_rule_; }
void set_subdiv_rule(Self*& _n) { subdiv_rule_ = _n; }
Self* subdiv_rule() { return subdiv_rule_; }
Self* subdiv_rule() const { return subdiv_rule_; }
void set_number(int _n) { number_ = _n; }
void set_n_rules(int _n) { n_rules_ = _n; }
int n_rules() { return n_rules_; }
int n_rules() const { return n_rules_; }
void set_subdiv_type(int _n)
{ assert(_n == 3 || _n == 4); subdiv_type_ = _n; }

View File

@@ -242,7 +242,7 @@ public:
explicit FVc(M& _mesh) : Inherited(_mesh) { init_coeffs(50); }
void raise(typename M::VertexHandle& _vh, state_t _target_state);
void raise(typename M::VertexHandle& _vh, state_t _target_state) override;
MIPS_WARN_WA(Face) // avoid warning
MIPS_WARN_WA(Edge) // avoid warning
@@ -412,7 +412,7 @@ public:
explicit EVc(M& _mesh) : Inherited(_mesh) { init_coeffs(50); }
void raise(typename M::VertexHandle& _vh, state_t _target_state);
void raise(typename M::VertexHandle& _vh, state_t _target_state) override;
MIPS_WARN_WA(Face) // avoid warning
MIPS_WARN_WA(Edge) // avoid warning

View File

@@ -114,15 +114,15 @@ public:
public:
const char *name() const { return "Uniform CatmullClark"; }
const char *name() const override { return "Uniform CatmullClark"; }
protected:
/// Initialize properties and weights
virtual bool prepare( MeshType& _m );
virtual bool prepare( MeshType& _m ) override;
/// Remove properties and weights
virtual bool cleanup( MeshType& _m );
virtual bool cleanup( MeshType& _m ) override;
/** \brief Execute n subdivision steps
*
@@ -131,7 +131,7 @@ protected:
* @param _update_points Unused here
* @return successful?
*/
virtual bool subdivide( MeshType& _m, size_t _n , const bool _update_points = true);
virtual bool subdivide( MeshType& _m, size_t _n , const bool _update_points = true) override;
private:

View File

@@ -102,13 +102,13 @@ public:
public: // inherited interface
virtual const char *name( void ) const = 0;
virtual const char *name( void ) const override = 0;
protected: // inherited interface
bool prepare( MeshType& _m );
bool prepare( MeshType& _m ) override;
bool subdivide( MeshType& _m, size_t _n, const bool _update_points = true )
bool subdivide( MeshType& _m, size_t _n, const bool _update_points = true ) override
{
assert( p_mesh_ == &_m );
@@ -124,7 +124,7 @@ protected: // inherited interface
#ifdef NDEBUG
bool cleanup( MeshType& )
#else
bool cleanup( MeshType& _m )
bool cleanup( MeshType& _m ) override
#endif
{
assert( p_mesh_ == &_m );

View File

@@ -86,6 +86,7 @@ struct CompositeTraits : public OpenMesh::DefaultTraits
FaceTraits
{
private:
typedef typename Refs::HalfedgeHandle HalfedgeHandle;
typedef typename Refs::Scalar Scalar;

View File

@@ -82,16 +82,16 @@ public:
public:
CompositeLoopT() : Inherited() {};
CompositeLoopT(MeshType& _mesh) : Inherited(_mesh) {};
explicit CompositeLoopT(MeshType& _mesh) : Inherited(_mesh) {};
~CompositeLoopT() {}
public:
const char *name() const { return "Uniform Composite Loop"; }
const char *name() const override { return "Uniform Composite Loop"; }
protected: // inherited interface
void apply_rules(void)
void apply_rules(void) override
{
Inherited::Tvv4();
Inherited::VdE();
@@ -119,7 +119,7 @@ protected:
weights_.end(), compute_weight() );
}
double operator()(size_t _valence) { return weights_[_valence]; }
double operator()(size_t _valence) override { return weights_[_valence]; }
/// \internal
struct compute_weight

View File

@@ -82,16 +82,16 @@ public:
public:
CompositeSqrt3T() : Inherited() {};
CompositeSqrt3T(MeshType& _mesh) : Inherited(_mesh) {};
explicit CompositeSqrt3T(MeshType& _mesh) : Inherited(_mesh) {};
~CompositeSqrt3T() {}
public:
const char *name() const { return "Uniform Composite Sqrt3"; }
const char *name() const override { return "Uniform Composite Sqrt3"; }
protected: // inherited interface
void apply_rules(void)
void apply_rules(void) override
{
Inherited::Tvv3();
Inherited::VF();
@@ -117,7 +117,7 @@ protected:
weights_.end(), compute_weight() );
}
double operator()(size_t _valence) { return weights_[_valence]; }
double operator()(size_t _valence) override { return weights_[_valence]; }
/** \internal
*/

View File

@@ -106,7 +106,7 @@ public:
{ init_weights(); }
LoopT( mesh_t& _m ) : parent_t(_m), _1over8( 1.0/8.0 ), _3over8( 3.0/8.0 )
explicit LoopT( mesh_t& _m ) : parent_t(_m), _1over8( 1.0/8.0 ), _3over8( 3.0/8.0 )
{ init_weights(); }
@@ -116,7 +116,7 @@ public:
public:
const char *name() const { return "Uniform Loop"; }
const char *name() const override { return "Uniform Loop"; }
/// Pre-compute weights
@@ -130,7 +130,7 @@ public:
protected:
bool prepare( mesh_t& _m )
bool prepare( mesh_t& _m ) override
{
_m.add_property( vp_pos_ );
_m.add_property( ep_pos_ );
@@ -138,7 +138,7 @@ protected:
}
bool cleanup( mesh_t& _m )
bool cleanup( mesh_t& _m ) override
{
_m.remove_property( vp_pos_ );
_m.remove_property( ep_pos_ );
@@ -146,7 +146,7 @@ protected:
}
bool subdivide( mesh_t& _m, size_t _n, const bool _update_points = true)
bool subdivide( mesh_t& _m, size_t _n, const bool _update_points = true) override
{
///TODO:Implement fixed positions

View File

@@ -107,7 +107,7 @@ public:
{ init_weights(); }
ModifiedButterflyT( mesh_t& _m) : parent_t(_m)
explicit ModifiedButterflyT( mesh_t& _m) : parent_t(_m)
{ init_weights(); }
@@ -117,7 +117,7 @@ public:
public:
const char *name() const { return "Uniform Spectral"; }
const char *name() const override { return "Uniform Spectral"; }
/// Pre-compute weights
@@ -158,7 +158,7 @@ public:
protected:
bool prepare( mesh_t& _m )
bool prepare( mesh_t& _m ) override
{
_m.add_property( vp_pos_ );
_m.add_property( ep_pos_ );
@@ -166,7 +166,7 @@ protected:
}
bool cleanup( mesh_t& _m )
bool cleanup( mesh_t& _m ) override
{
_m.remove_property( vp_pos_ );
_m.remove_property( ep_pos_ );
@@ -174,7 +174,7 @@ protected:
}
bool subdivide( MeshType& _m, size_t _n , const bool _update_points = true)
bool subdivide( MeshType& _m, size_t _n , const bool _update_points = true) override
{
///TODO:Implement fixed positions

View File

@@ -119,7 +119,7 @@ public:
InterpolatingSqrt3LGT(void) : parent_t()
{ init_weights(); }
InterpolatingSqrt3LGT(MeshType &_m) : parent_t(_m)
explicit InterpolatingSqrt3LGT(MeshType &_m) : parent_t(_m)
{ init_weights(); }
virtual ~InterpolatingSqrt3LGT() {}
@@ -128,7 +128,7 @@ public:
public:
const char *name() const { return "Uniform Interpolating Sqrt3"; }
const char *name() const override { return "Uniform Interpolating Sqrt3"; }
/// Pre-compute weights
void init_weights(size_t _max_valence=50)
@@ -170,7 +170,7 @@ public:
protected:
bool prepare( MeshType& _m )
bool prepare( MeshType& _m ) override
{
_m.request_edge_status();
_m.add_property( fp_pos_ );
@@ -183,7 +183,7 @@ protected:
}
bool cleanup( MeshType& _m )
bool cleanup( MeshType& _m ) override
{
_m.release_edge_status();
_m.remove_property( fp_pos_ );
@@ -193,7 +193,7 @@ protected:
}
bool subdivide( MeshType& _m, size_t _n , const bool _update_points = true)
bool subdivide( MeshType& _m, size_t _n , const bool _update_points = true) override
{
///TODO:Implement fixed positions

View File

@@ -112,7 +112,7 @@ public:
Sqrt3T(void) : parent_t(), _1over3( real_t(1.0/3.0) ), _1over27( real_t(1.0/27.0) )
{ init_weights(); }
Sqrt3T(MeshType &_m) : parent_t(_m), _1over3( real_t(1.0/3.0) ), _1over27( real_t(1.0/27.0) )
explicit Sqrt3T(MeshType &_m) : parent_t(_m), _1over3( real_t(1.0/3.0) ), _1over27( real_t(1.0/27.0) )
{ init_weights(); }
virtual ~Sqrt3T() {}
@@ -121,7 +121,7 @@ public:
public:
const char *name() const { return "Uniform Sqrt3"; }
const char *name() const override { return "Uniform Sqrt3"; }
/// Pre-compute weights
@@ -135,7 +135,7 @@ public:
protected:
bool prepare( MeshType& _m )
bool prepare( MeshType& _m ) override
{
_m.request_edge_status();
_m.add_property( vp_pos_ );
@@ -148,7 +148,7 @@ protected:
}
bool cleanup( MeshType& _m )
bool cleanup( MeshType& _m ) override
{
_m.release_edge_status();
_m.remove_property( vp_pos_ );
@@ -157,7 +157,7 @@ protected:
return true;
}
bool subdivide( MeshType& _m, size_t _n , const bool _update_points = true)
bool subdivide( MeshType& _m, size_t _n , const bool _update_points = true) override
{
///TODO:Implement fixed positions

View File

@@ -152,7 +152,7 @@ public:
{}
#else
/// Construct with a given \c HeapIterface.
HeapT(const HeapInterface &_interface)
explicit HeapT(const HeapInterface &_interface)
: HeapVector(), interface_(_interface)
{}
#endif
@@ -258,9 +258,9 @@ public:
bool check()
{
bool ok(true);
unsigned int i, j;
for (i=0; i<size(); ++i)
for (unsigned int i=0; i<size(); ++i)
{
unsigned int j;
if (((j=left(i))<size()) && interface_.greater(entry(i), entry(j)))
{
omerr() << "Heap condition violated\n";
@@ -351,12 +351,11 @@ HeapT<HeapEntry, HeapInterface>::
downheap(size_t _idx)
{
const HeapEntry h = entry(_idx);
size_t childIdx;
const size_t s = size();
while(_idx < s)
{
childIdx = left(_idx);
size_t childIdx = left(_idx);
if (childIdx >= s) break;
if ((childIdx + 1 < s) && (interface_.less(entry(childIdx + 1), entry(childIdx))))

View File

@@ -88,7 +88,7 @@ public:
/// Default constructor
StripifierT(Mesh& _mesh);
explicit StripifierT(Mesh& _mesh);
/// Destructor
~StripifierT();

View File

@@ -100,11 +100,11 @@ public:
TimerImplWin32(void);
~TimerImplWin32(void) { ; }
virtual void reset(void);
virtual void start(void);
virtual void stop(void);
virtual void cont(void);
virtual double seconds(void) const;
virtual void reset(void) override;
virtual void start(void) override;
virtual void stop(void) override;
virtual void cont(void) override;
virtual double seconds(void) const override;
};
TimerImplWin32::TimerImplWin32(void)
@@ -198,10 +198,10 @@ public:
~TimerImplGToD()
{ }
virtual void reset(void) { seconds_ = 0.0; }
virtual void start(void) { seconds_ = 0.0; gettimeofday( &start_, &tz_ ); }
virtual void reset(void) override { seconds_ = 0.0; }
virtual void start(void) override { seconds_ = 0.0; gettimeofday( &start_, &tz_ ); }
virtual void stop(void)
virtual void stop(void) override
{
gettimeofday( &stop_, &tz_ );
@@ -209,9 +209,9 @@ public:
seconds_ += (double)(stop_.tv_usec- start_.tv_usec)*1e-6;
}
virtual void cont(void) { gettimeofday( &start_, &tz_); }
virtual void cont(void) override { gettimeofday( &start_, &tz_); }
virtual double seconds() const { return seconds_; }
virtual double seconds() const override { return seconds_; }
private:
@@ -234,11 +234,11 @@ public:
TimerImplStd() : freq_(clockticks),count_(0),start_(0) { reset(); }
~TimerImplStd() { ; }
virtual void reset(void) { count_ = 0; }
virtual void start(void) { count_ = 0; start_ = clock(); }
virtual void stop(void);
virtual void cont(void) { start_ = clock(); }
virtual double seconds(void) const { return (double)count_/(double)freq_; }
virtual void reset(void) override { count_ = 0; }
virtual void start(void) override { count_ = 0; start_ = clock(); }
virtual void stop(void) override;
virtual void cont(void) override { start_ = clock(); }
virtual double seconds(void) const override { return (double)count_/(double)freq_; }
protected:
unsigned long freq_;

View File

@@ -37,183 +37,183 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
* ========================================================================= */
//=============================================================================
//
// CLASS newClass
//
//=============================================================================
#ifndef OPENMESH_VDPROGMESH_VHIERARCHYWINDOWS_HH
#define OPENMESH_VDPROGMESH_VHIERARCHYWINDOWS_HH
//== INCLUDES =================================================================
#include <OpenMesh/Tools/VDPM/VHierarchy.hh>
#include <algorithm>
//== FORWARDDECLARATIONS ======================================================
//== NAMESPACES ===============================================================
namespace OpenMesh {
namespace VDPM {
//== CLASS DEFINITION =========================================================
/** \todo VHierarchyWindow documentation
*/
class VHierarchyWindow
{
private:
// reference of vertex hierarchy
VHierarchy *vhierarchy_;
// bits buffer (byte units)
unsigned char *buffer_;
int buffer_min_;
size_t buffer_max_;
int current_pos_;
// window (byte units)
int window_min_;
int window_max_;
// # of right shift (bit units)
unsigned char n_shift_; // [0, 7]
unsigned char flag8(unsigned char n_shift) const
{ return 0x80 >> n_shift; }
unsigned char flag8(VHierarchyNodeHandle _node_handle) const
{
assert(_node_handle.idx() >= 0);
return 0x80 >> (unsigned int) (_node_handle.idx() % 8);
}
int byte_idx(VHierarchyNodeHandle _node_handle) const
{
assert(_node_handle.idx() >= 0);
return _node_handle.idx() / 8;
}
int buffer_idx(VHierarchyNodeHandle _node_handle) const
{ return byte_idx(_node_handle) - buffer_min_; }
bool before_window(VHierarchyNodeHandle _node_handle) const
{ return (_node_handle.idx()/8 < window_min_) ? true : false; }
bool after_window(VHierarchyNodeHandle _node_handle) const
{ return (_node_handle.idx()/8 < window_max_) ? false : true; }
bool underflow(VHierarchyNodeHandle _node_handle) const
{ return (_node_handle.idx()/8 < buffer_min_) ? true : false; }
bool overflow(VHierarchyNodeHandle _node_handle) const
{ return (_node_handle.idx()/8 < int(buffer_max_) ) ? false : true; }
bool update_buffer(VHierarchyNodeHandle _node_handle);
public:
VHierarchyWindow();
VHierarchyWindow(VHierarchy &_vhierarchy);
~VHierarchyWindow(void);
void set_vertex_hierarchy(VHierarchy &_vhierarchy)
{ vhierarchy_ = &_vhierarchy; }
void begin()
{
int new_window_min = window_min_;
for (current_pos_=window_min_-buffer_min_;
current_pos_ < window_size(); ++current_pos_)
{
if (buffer_[current_pos_] == 0)
++new_window_min;
else
{
n_shift_ = 0;
while ((buffer_[current_pos_] & flag8(n_shift_)) == 0)
++n_shift_;
break;
}
}
window_min_ = new_window_min;
}
void next()
{
++n_shift_;
if (n_shift_ == 8)
{
n_shift_ = 0;
++current_pos_;
}
while (current_pos_ < window_max_-buffer_min_)
{
if (buffer_[current_pos_] != 0) // if the current byte has non-zero bits
{
while (n_shift_ != 8)
{
if ((buffer_[current_pos_] & flag8(n_shift_)) != 0)
return; // find 1 bit in the current byte
++n_shift_;
}
}
n_shift_ = 0;
++current_pos_;
}
}
bool end() { return !(current_pos_ < window_max_-buffer_min_); }
int window_size() const { return window_max_ - window_min_; }
size_t buffer_size() const { return buffer_max_ - buffer_min_; }
VHierarchyNodeHandle node_handle()
{
return VHierarchyNodeHandle(8*(buffer_min_+current_pos_) + (int)n_shift_);
}
void activate(VHierarchyNodeHandle _node_handle)
{
update_buffer(_node_handle);
buffer_[buffer_idx(_node_handle)] |= flag8(_node_handle);
window_min_ = std::min(window_min_, byte_idx(_node_handle));
window_max_ = std::max(window_max_, 1+byte_idx(_node_handle));
}
void inactivate(VHierarchyNodeHandle _node_handle)
{
if (is_active(_node_handle) != true) return;
buffer_[buffer_idx(_node_handle)] ^= flag8(_node_handle);
}
bool is_active(VHierarchyNodeHandle _node_handle) const
{
if (before_window(_node_handle) == true ||
after_window(_node_handle) == true)
return false;
return ((buffer_[buffer_idx(_node_handle)] & flag8(_node_handle)) > 0);
}
void init(VHierarchyNodeHandleContainer &_roots);
void update_with_vsplit(VHierarchyNodeHandle _parent_handle);
void update_with_ecol(VHierarchyNodeHandle _parent_handle);
};
//=============================================================================
} // namespace VDPM
} // namespace OpenMesh
//=============================================================================
#endif // OPENMESH_VDPROGMESH_VHIERARCHYWINDOWS_HH
//=============================================================================
* ========================================================================= */
//=============================================================================
//
// CLASS newClass
//
//=============================================================================
#ifndef OPENMESH_VDPROGMESH_VHIERARCHYWINDOWS_HH
#define OPENMESH_VDPROGMESH_VHIERARCHYWINDOWS_HH
//== INCLUDES =================================================================
#include <OpenMesh/Tools/VDPM/VHierarchy.hh>
#include <algorithm>
//== FORWARDDECLARATIONS ======================================================
//== NAMESPACES ===============================================================
namespace OpenMesh {
namespace VDPM {
//== CLASS DEFINITION =========================================================
/** \todo VHierarchyWindow documentation
*/
class VHierarchyWindow
{
private:
// reference of vertex hierarchy
VHierarchy *vhierarchy_;
// bits buffer (byte units)
unsigned char *buffer_;
int buffer_min_;
size_t buffer_max_;
int current_pos_;
// window (byte units)
int window_min_;
int window_max_;
// # of right shift (bit units)
unsigned char n_shift_; // [0, 7]
unsigned char flag8(unsigned char n_shift) const
{ return 0x80 >> n_shift; }
unsigned char flag8(VHierarchyNodeHandle _node_handle) const
{
assert(_node_handle.idx() >= 0);
return 0x80 >> (unsigned int) (_node_handle.idx() % 8);
}
int byte_idx(VHierarchyNodeHandle _node_handle) const
{
assert(_node_handle.idx() >= 0);
return _node_handle.idx() / 8;
}
int buffer_idx(VHierarchyNodeHandle _node_handle) const
{ return byte_idx(_node_handle) - buffer_min_; }
bool before_window(VHierarchyNodeHandle _node_handle) const
{ return (_node_handle.idx()/8 < window_min_) ? true : false; }
bool after_window(VHierarchyNodeHandle _node_handle) const
{ return (_node_handle.idx()/8 < window_max_) ? false : true; }
bool underflow(VHierarchyNodeHandle _node_handle) const
{ return (_node_handle.idx()/8 < buffer_min_) ? true : false; }
bool overflow(VHierarchyNodeHandle _node_handle) const
{ return (_node_handle.idx()/8 < int(buffer_max_) ) ? false : true; }
bool update_buffer(VHierarchyNodeHandle _node_handle);
public:
VHierarchyWindow();
explicit VHierarchyWindow(VHierarchy &_vhierarchy);
~VHierarchyWindow(void);
void set_vertex_hierarchy(VHierarchy &_vhierarchy)
{ vhierarchy_ = &_vhierarchy; }
void begin()
{
int new_window_min = window_min_;
for (current_pos_=window_min_-buffer_min_;
current_pos_ < window_size(); ++current_pos_)
{
if (buffer_[current_pos_] == 0)
++new_window_min;
else
{
n_shift_ = 0;
while ((buffer_[current_pos_] & flag8(n_shift_)) == 0)
++n_shift_;
break;
}
}
window_min_ = new_window_min;
}
void next()
{
++n_shift_;
if (n_shift_ == 8)
{
n_shift_ = 0;
++current_pos_;
}
while (current_pos_ < window_max_-buffer_min_)
{
if (buffer_[current_pos_] != 0) // if the current byte has non-zero bits
{
while (n_shift_ != 8)
{
if ((buffer_[current_pos_] & flag8(n_shift_)) != 0)
return; // find 1 bit in the current byte
++n_shift_;
}
}
n_shift_ = 0;
++current_pos_;
}
}
bool end() { return !(current_pos_ < window_max_-buffer_min_); }
int window_size() const { return window_max_ - window_min_; }
size_t buffer_size() const { return buffer_max_ - buffer_min_; }
VHierarchyNodeHandle node_handle()
{
return VHierarchyNodeHandle(8*(buffer_min_+current_pos_) + (int)n_shift_);
}
void activate(VHierarchyNodeHandle _node_handle)
{
update_buffer(_node_handle);
buffer_[buffer_idx(_node_handle)] |= flag8(_node_handle);
window_min_ = std::min(window_min_, byte_idx(_node_handle));
window_max_ = std::max(window_max_, 1+byte_idx(_node_handle));
}
void inactivate(VHierarchyNodeHandle _node_handle)
{
if (is_active(_node_handle) != true) return;
buffer_[buffer_idx(_node_handle)] ^= flag8(_node_handle);
}
bool is_active(VHierarchyNodeHandle _node_handle) const
{
if (before_window(_node_handle) == true ||
after_window(_node_handle) == true)
return false;
return ((buffer_[buffer_idx(_node_handle)] & flag8(_node_handle)) > 0);
}
void init(VHierarchyNodeHandleContainer &_roots);
void update_with_vsplit(VHierarchyNodeHandle _parent_handle);
void update_with_ecol(VHierarchyNodeHandle _parent_handle);
};
//=============================================================================
} // namespace VDPM
} // namespace OpenMesh
//=============================================================================
#endif // OPENMESH_VDPROGMESH_VHIERARCHYWINDOWS_HH
//=============================================================================