Merge branch 'master' into compile-time-connectivity-type
This commit is contained in:
@@ -82,6 +82,7 @@
|
||||
#include <OpenMesh/Core/IO/writer/STLWriter.hh>
|
||||
#include <OpenMesh/Core/IO/writer/OMWriter.hh>
|
||||
#include <OpenMesh/Core/IO/writer/PLYWriter.hh>
|
||||
#include <OpenMesh/Core/IO/writer/VTKWriter.hh>
|
||||
|
||||
//=== NAMESPACES ==============================================================
|
||||
|
||||
@@ -104,6 +105,7 @@ static BaseWriter* OFFWriterInstance = &OFFWriter();
|
||||
static BaseWriter* STLWriterInstance = &STLWriter();
|
||||
static BaseWriter* OMWriterInstance = &OMWriter();
|
||||
static BaseWriter* PLYWriterInstance = &PLYWriter();
|
||||
static BaseWriter* VTKWriterInstance = &VTKWriter();
|
||||
|
||||
|
||||
//=============================================================================
|
||||
|
||||
@@ -1201,185 +1201,187 @@ bool _PLYReader_::can_u_read(std::istream& _is) const {
|
||||
_is >> keyword;
|
||||
while (keyword != "end_header") {
|
||||
|
||||
if (keyword == "comment") {
|
||||
std::getline(_is, line);
|
||||
} else if (keyword == "element") {
|
||||
_is >> elementName;
|
||||
_is >> elementCount;
|
||||
if (keyword == "comment") {
|
||||
std::getline(_is, line);
|
||||
} else if (keyword == "element") {
|
||||
_is >> elementName;
|
||||
_is >> elementCount;
|
||||
|
||||
ElementInfo element;
|
||||
element.name_ = elementName;
|
||||
element.count_ = elementCount;
|
||||
ElementInfo element;
|
||||
element.name_ = elementName;
|
||||
element.count_ = elementCount;
|
||||
|
||||
if (elementName == "vertex") {
|
||||
vertexCount_ = elementCount;
|
||||
element.element_ = VERTEX;
|
||||
} else if (elementName == "face") {
|
||||
faceCount_ = elementCount;
|
||||
element.element_ = FACE;
|
||||
} else {
|
||||
omerr() << "PLY header unsupported element type: " << elementName << std::endl;
|
||||
element.element_ = UNKNOWN;
|
||||
}
|
||||
if (elementName == "vertex") {
|
||||
vertexCount_ = elementCount;
|
||||
element.element_ = VERTEX;
|
||||
} else if (elementName == "face") {
|
||||
faceCount_ = elementCount;
|
||||
element.element_ = FACE;
|
||||
} else {
|
||||
omerr() << "PLY header unsupported element type: " << elementName << std::endl;
|
||||
element.element_ = UNKNOWN;
|
||||
}
|
||||
|
||||
elements_.push_back(element);
|
||||
} else if (keyword == "property") {
|
||||
std::string tmp1;
|
||||
std::string tmp2;
|
||||
elements_.push_back(element);
|
||||
} else if (keyword == "property") {
|
||||
std::string tmp1;
|
||||
std::string tmp2;
|
||||
|
||||
// Read first keyword, as it might be a list
|
||||
_is >> tmp1;
|
||||
// Read first keyword, as it might be a list
|
||||
_is >> tmp1;
|
||||
|
||||
if (tmp1 == "list") {
|
||||
_is >> listIndexType;
|
||||
_is >> listEntryType;
|
||||
_is >> propertyName;
|
||||
if (tmp1 == "list") {
|
||||
_is >> listIndexType;
|
||||
_is >> listEntryType;
|
||||
_is >> propertyName;
|
||||
|
||||
ValueType indexType = Unsupported;
|
||||
ValueType entryType = Unsupported;
|
||||
ValueType indexType = Unsupported;
|
||||
ValueType entryType = Unsupported;
|
||||
|
||||
if (listIndexType == "uint8") {
|
||||
indexType = ValueTypeUINT8;
|
||||
} else if (listIndexType == "uchar") {
|
||||
indexType = ValueTypeUCHAR;
|
||||
} else if (listIndexType == "int") {
|
||||
indexType = ValueTypeINT;
|
||||
} else {
|
||||
omerr() << "Unsupported Index type for property list: " << listIndexType << std::endl;
|
||||
continue;
|
||||
}
|
||||
if (listIndexType == "uint8") {
|
||||
indexType = ValueTypeUINT8;
|
||||
} else if (listIndexType == "uint16") {
|
||||
indexType = ValueTypeUINT16;
|
||||
} else if (listIndexType == "uchar") {
|
||||
indexType = ValueTypeUCHAR;
|
||||
} else if (listIndexType == "int") {
|
||||
indexType = ValueTypeINT;
|
||||
} else {
|
||||
omerr() << "Unsupported Index type for property list: " << listIndexType << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
entryType = get_property_type(listEntryType, listEntryType);
|
||||
entryType = get_property_type(listEntryType, listEntryType);
|
||||
|
||||
if (entryType == Unsupported) {
|
||||
omerr() << "Unsupported Entry type for property list: " << listEntryType << std::endl;
|
||||
}
|
||||
if (entryType == Unsupported) {
|
||||
omerr() << "Unsupported Entry type for property list: " << listEntryType << std::endl;
|
||||
}
|
||||
|
||||
PropertyInfo property(CUSTOM_PROP, entryType, propertyName);
|
||||
property.listIndexType = indexType;
|
||||
PropertyInfo property(CUSTOM_PROP, entryType, propertyName);
|
||||
property.listIndexType = indexType;
|
||||
|
||||
if (elementName == "face")
|
||||
{
|
||||
// special case for vertex indices
|
||||
if (propertyName == "vertex_index" || propertyName == "vertex_indices")
|
||||
{
|
||||
property.property = VERTEX_INDICES;
|
||||
|
||||
if (!elements_.back().properties_.empty())
|
||||
{
|
||||
omerr() << "Custom face Properties defined, before 'vertex_indices' property was defined. They will be skipped" << std::endl;
|
||||
elements_.back().properties_.clear();
|
||||
}
|
||||
} else {
|
||||
options_ += Options::Custom;
|
||||
}
|
||||
if (elementName == "face")
|
||||
{
|
||||
// special case for vertex indices
|
||||
if (propertyName == "vertex_index" || propertyName == "vertex_indices")
|
||||
{
|
||||
property.property = VERTEX_INDICES;
|
||||
|
||||
}
|
||||
else
|
||||
omerr() << "property " << propertyName << " belongs to unsupported element " << elementName << std::endl;
|
||||
|
||||
elements_.back().properties_.push_back(property);
|
||||
|
||||
} else {
|
||||
// as this is not a list property, read second value of property
|
||||
_is >> tmp2;
|
||||
|
||||
|
||||
// Extract name and type of property
|
||||
// As the order seems to be different in some files, autodetect it.
|
||||
ValueType valueType = get_property_type(tmp1, tmp2);
|
||||
propertyName = get_property_name(tmp1, tmp2);
|
||||
|
||||
PropertyInfo entry;
|
||||
|
||||
//special treatment for some vertex properties.
|
||||
if (elementName == "vertex") {
|
||||
if (propertyName == "x") {
|
||||
entry = PropertyInfo(XCOORD, valueType);
|
||||
vertexDimension_++;
|
||||
} else if (propertyName == "y") {
|
||||
entry = PropertyInfo(YCOORD, valueType);
|
||||
vertexDimension_++;
|
||||
} else if (propertyName == "z") {
|
||||
entry = PropertyInfo(ZCOORD, valueType);
|
||||
vertexDimension_++;
|
||||
} else if (propertyName == "nx") {
|
||||
entry = PropertyInfo(XNORM, valueType);
|
||||
options_ += Options::VertexNormal;
|
||||
} else if (propertyName == "ny") {
|
||||
entry = PropertyInfo(YNORM, valueType);
|
||||
options_ += Options::VertexNormal;
|
||||
} else if (propertyName == "nz") {
|
||||
entry = PropertyInfo(ZNORM, valueType);
|
||||
options_ += Options::VertexNormal;
|
||||
} else if (propertyName == "u" || propertyName == "s") {
|
||||
entry = PropertyInfo(TEXX, valueType);
|
||||
options_ += Options::VertexTexCoord;
|
||||
} else if (propertyName == "v" || propertyName == "t") {
|
||||
entry = PropertyInfo(TEXY, valueType);
|
||||
options_ += Options::VertexTexCoord;
|
||||
} else if (propertyName == "red") {
|
||||
entry = PropertyInfo(COLORRED, valueType);
|
||||
options_ += Options::VertexColor;
|
||||
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
|
||||
options_ += Options::ColorFloat;
|
||||
} else if (propertyName == "green") {
|
||||
entry = PropertyInfo(COLORGREEN, valueType);
|
||||
options_ += Options::VertexColor;
|
||||
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
|
||||
options_ += Options::ColorFloat;
|
||||
} else if (propertyName == "blue") {
|
||||
entry = PropertyInfo(COLORBLUE, valueType);
|
||||
options_ += Options::VertexColor;
|
||||
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
|
||||
options_ += Options::ColorFloat;
|
||||
} else if (propertyName == "diffuse_red") {
|
||||
entry = PropertyInfo(COLORRED, valueType);
|
||||
options_ += Options::VertexColor;
|
||||
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
|
||||
options_ += Options::ColorFloat;
|
||||
} else if (propertyName == "diffuse_green") {
|
||||
entry = PropertyInfo(COLORGREEN, valueType);
|
||||
options_ += Options::VertexColor;
|
||||
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
|
||||
options_ += Options::ColorFloat;
|
||||
} else if (propertyName == "diffuse_blue") {
|
||||
entry = PropertyInfo(COLORBLUE, valueType);
|
||||
options_ += Options::VertexColor;
|
||||
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
|
||||
options_ += Options::ColorFloat;
|
||||
} else if (propertyName == "alpha") {
|
||||
entry = PropertyInfo(COLORALPHA, valueType);
|
||||
options_ += Options::VertexColor;
|
||||
options_ += Options::ColorAlpha;
|
||||
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
|
||||
options_ += Options::ColorFloat;
|
||||
}
|
||||
}
|
||||
|
||||
//not a special property, load as custom
|
||||
if (entry.value == Unsupported){
|
||||
Property prop = CUSTOM_PROP;
|
||||
options_ += Options::Custom;
|
||||
entry = PropertyInfo(prop, valueType, propertyName);
|
||||
}
|
||||
|
||||
if (entry.property != UNSUPPORTED)
|
||||
if (!elements_.back().properties_.empty())
|
||||
{
|
||||
elements_.back().properties_.push_back(entry);
|
||||
omerr() << "Custom face Properties defined, before 'vertex_indices' property was defined. They will be skipped" << std::endl;
|
||||
elements_.back().properties_.clear();
|
||||
}
|
||||
} else {
|
||||
options_ += Options::Custom;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
omerr() << "property " << propertyName << " belongs to unsupported element " << elementName << std::endl;
|
||||
|
||||
elements_.back().properties_.push_back(property);
|
||||
|
||||
} else {
|
||||
omlog() << "Unsupported keyword : " << keyword << std::endl;
|
||||
// as this is not a list property, read second value of property
|
||||
_is >> tmp2;
|
||||
|
||||
|
||||
// Extract name and type of property
|
||||
// As the order seems to be different in some files, autodetect it.
|
||||
ValueType valueType = get_property_type(tmp1, tmp2);
|
||||
propertyName = get_property_name(tmp1, tmp2);
|
||||
|
||||
PropertyInfo entry;
|
||||
|
||||
//special treatment for some vertex properties.
|
||||
if (elementName == "vertex") {
|
||||
if (propertyName == "x") {
|
||||
entry = PropertyInfo(XCOORD, valueType);
|
||||
vertexDimension_++;
|
||||
} else if (propertyName == "y") {
|
||||
entry = PropertyInfo(YCOORD, valueType);
|
||||
vertexDimension_++;
|
||||
} else if (propertyName == "z") {
|
||||
entry = PropertyInfo(ZCOORD, valueType);
|
||||
vertexDimension_++;
|
||||
} else if (propertyName == "nx") {
|
||||
entry = PropertyInfo(XNORM, valueType);
|
||||
options_ += Options::VertexNormal;
|
||||
} else if (propertyName == "ny") {
|
||||
entry = PropertyInfo(YNORM, valueType);
|
||||
options_ += Options::VertexNormal;
|
||||
} else if (propertyName == "nz") {
|
||||
entry = PropertyInfo(ZNORM, valueType);
|
||||
options_ += Options::VertexNormal;
|
||||
} else if (propertyName == "u" || propertyName == "s") {
|
||||
entry = PropertyInfo(TEXX, valueType);
|
||||
options_ += Options::VertexTexCoord;
|
||||
} else if (propertyName == "v" || propertyName == "t") {
|
||||
entry = PropertyInfo(TEXY, valueType);
|
||||
options_ += Options::VertexTexCoord;
|
||||
} else if (propertyName == "red") {
|
||||
entry = PropertyInfo(COLORRED, valueType);
|
||||
options_ += Options::VertexColor;
|
||||
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
|
||||
options_ += Options::ColorFloat;
|
||||
} else if (propertyName == "green") {
|
||||
entry = PropertyInfo(COLORGREEN, valueType);
|
||||
options_ += Options::VertexColor;
|
||||
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
|
||||
options_ += Options::ColorFloat;
|
||||
} else if (propertyName == "blue") {
|
||||
entry = PropertyInfo(COLORBLUE, valueType);
|
||||
options_ += Options::VertexColor;
|
||||
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
|
||||
options_ += Options::ColorFloat;
|
||||
} else if (propertyName == "diffuse_red") {
|
||||
entry = PropertyInfo(COLORRED, valueType);
|
||||
options_ += Options::VertexColor;
|
||||
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
|
||||
options_ += Options::ColorFloat;
|
||||
} else if (propertyName == "diffuse_green") {
|
||||
entry = PropertyInfo(COLORGREEN, valueType);
|
||||
options_ += Options::VertexColor;
|
||||
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
|
||||
options_ += Options::ColorFloat;
|
||||
} else if (propertyName == "diffuse_blue") {
|
||||
entry = PropertyInfo(COLORBLUE, valueType);
|
||||
options_ += Options::VertexColor;
|
||||
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
|
||||
options_ += Options::ColorFloat;
|
||||
} else if (propertyName == "alpha") {
|
||||
entry = PropertyInfo(COLORALPHA, valueType);
|
||||
options_ += Options::VertexColor;
|
||||
options_ += Options::ColorAlpha;
|
||||
if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
|
||||
options_ += Options::ColorFloat;
|
||||
}
|
||||
}
|
||||
|
||||
//not a special property, load as custom
|
||||
if (entry.value == Unsupported){
|
||||
Property prop = CUSTOM_PROP;
|
||||
options_ += Options::Custom;
|
||||
entry = PropertyInfo(prop, valueType, propertyName);
|
||||
}
|
||||
|
||||
if (entry.property != UNSUPPORTED)
|
||||
{
|
||||
elements_.back().properties_.push_back(entry);
|
||||
}
|
||||
}
|
||||
|
||||
streamPos = _is.tellg();
|
||||
_is >> keyword;
|
||||
if (_is.bad()) {
|
||||
omerr() << "Error while reading PLY file header" << std::endl;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
omlog() << "Unsupported keyword : " << keyword << std::endl;
|
||||
}
|
||||
|
||||
streamPos = _is.tellg();
|
||||
_is >> keyword;
|
||||
if (_is.bad()) {
|
||||
omerr() << "Error while reading PLY file header" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// As the binary data is directy after the end_header keyword
|
||||
|
||||
@@ -470,7 +470,7 @@ class GenericCirculatorT_DEPRECATED : protected GenericCirculatorBaseT<Mesh> {
|
||||
To be save, you can use the CW/CCW circulator definitions, which behave\
|
||||
the same as the original ones, without the previously mentioned issues."
|
||||
|
||||
DEPRECATED( DECREMENT_DEPRECATED_WARNINGS_TEXT )
|
||||
OM_DEPRECATED( DECREMENT_DEPRECATED_WARNINGS_TEXT )
|
||||
#endif // NO_DECREMENT_DEPRECATED_WARNINGS
|
||||
GenericCirculatorT_DEPRECATED& operator--() {
|
||||
assert(this->mesh_);
|
||||
@@ -488,7 +488,7 @@ class GenericCirculatorT_DEPRECATED : protected GenericCirculatorBaseT<Mesh> {
|
||||
|
||||
/// Post-decrement
|
||||
#ifndef NO_DECREMENT_DEPRECATED_WARNINGS
|
||||
DEPRECATED( DECREMENT_DEPRECATED_WARNINGS_TEXT )
|
||||
OM_DEPRECATED( DECREMENT_DEPRECATED_WARNINGS_TEXT )
|
||||
#undef DECREMENT_DEPRECATED_WARNINGS_TEXT
|
||||
#endif //NO_DECREMENT_DEPRECATED_WARNINGS
|
||||
GenericCirculatorT_DEPRECATED operator--(int) {
|
||||
@@ -542,7 +542,7 @@ class GenericCirculatorT_DEPRECATED : protected GenericCirculatorBaseT<Mesh> {
|
||||
return GenericCirculator_ValueHandleFns::is_valid(this->heh_,this->start_, this->lap_counter_);
|
||||
}
|
||||
|
||||
DEPRECATED("current_halfedge_handle() is an implementation detail and should not be accessed from outside the iterator class.")
|
||||
OM_DEPRECATED("current_halfedge_handle() is an implementation detail and should not be accessed from outside the iterator class.")
|
||||
/**
|
||||
* \deprecated
|
||||
* current_halfedge_handle() is an implementation detail and should not
|
||||
@@ -552,7 +552,7 @@ class GenericCirculatorT_DEPRECATED : protected GenericCirculatorBaseT<Mesh> {
|
||||
return this->heh_;
|
||||
}
|
||||
|
||||
DEPRECATED("Do not use this error prone implicit cast. Compare to end-iterator or use is_valid(), instead.")
|
||||
OM_DEPRECATED("Do not use this error prone implicit cast. Compare to end-iterator or use is_valid(), instead.")
|
||||
/**
|
||||
* \deprecated
|
||||
* Do not use this error prone implicit cast. Compare to the
|
||||
@@ -567,7 +567,7 @@ class GenericCirculatorT_DEPRECATED : protected GenericCirculatorBaseT<Mesh> {
|
||||
* \deprecated
|
||||
* This function clutters your code. Use dereferencing operators -> and * instead.
|
||||
*/
|
||||
DEPRECATED("This function clutters your code. Use dereferencing operators -> and * instead.")
|
||||
OM_DEPRECATED("This function clutters your code. Use dereferencing operators -> and * instead.")
|
||||
value_type handle() const {
|
||||
return **this;
|
||||
}
|
||||
@@ -578,7 +578,7 @@ class GenericCirculatorT_DEPRECATED : protected GenericCirculatorBaseT<Mesh> {
|
||||
* Implicit casts of iterators are unsafe. Use dereferencing operators
|
||||
* -> and * instead.
|
||||
*/
|
||||
DEPRECATED("Implicit casts of iterators are unsafe. Use dereferencing operators -> and * instead.")
|
||||
OM_DEPRECATED("Implicit casts of iterators are unsafe. Use dereferencing operators -> and * instead.")
|
||||
operator value_type() const {
|
||||
return **this;
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ class GenericIteratorT {
|
||||
* \deprecated
|
||||
* This function clutters your code. Use dereferencing operators -> and * instead.
|
||||
*/
|
||||
DEPRECATED("This function clutters your code. Use dereferencing operators -> and * instead.")
|
||||
OM_DEPRECATED("This function clutters your code. Use dereferencing operators -> and * instead.")
|
||||
value_handle handle() const {
|
||||
return hnd_;
|
||||
}
|
||||
@@ -137,7 +137,7 @@ class GenericIteratorT {
|
||||
* Implicit casts of iterators are unsafe. Use dereferencing operators
|
||||
* -> and * instead.
|
||||
*/
|
||||
DEPRECATED("Implicit casts of iterators are unsafe. Use dereferencing operators -> and * instead.")
|
||||
OM_DEPRECATED("Implicit casts of iterators are unsafe. Use dereferencing operators -> and * instead.")
|
||||
operator value_handle() const {
|
||||
return hnd_;
|
||||
}
|
||||
|
||||
@@ -162,27 +162,63 @@ public:
|
||||
*
|
||||
* \note The properties of the new edges, halfedges, and faces will be undefined!
|
||||
*
|
||||
* @param _eh Edge handle that should be splitted
|
||||
* @param _eh Edge handle that should be split
|
||||
* @param _vh Vertex handle that will be inserted at the edge
|
||||
*/
|
||||
void split(EdgeHandle _eh, VertexHandle _vh);
|
||||
|
||||
/** \brief Edge split (= 2-to-4 split)
|
||||
*
|
||||
*
|
||||
* The function will introduce two new faces ( non-boundary case) or
|
||||
* one additional face (if edge is boundary)
|
||||
*
|
||||
* \note The properties of the new edges, halfedges, and faces will be undefined!
|
||||
*
|
||||
* \note This is an override to prevent a direct call to PolyConnectivity split_edge,
|
||||
* which would introduce a singular vertex with valence 2 which is not allowed
|
||||
* on TriMeshes
|
||||
*
|
||||
* @param _eh Edge handle that should be split
|
||||
* @param _vh Vertex handle that will be inserted at the edge
|
||||
*/
|
||||
inline void split_edge(EdgeHandle _eh, VertexHandle _vh) { TriConnectivity::split(_eh, _vh); }
|
||||
|
||||
/** \brief Edge split (= 2-to-4 split)
|
||||
*
|
||||
* The function will introduce two new faces ( non-boundary case) or
|
||||
* one additional face (if edge is boundary)
|
||||
*
|
||||
* \note The properties of the new edges will be adjusted to the properties of the original edge
|
||||
* \note The properties of the new faces and halfedges will be undefined
|
||||
* \note The properties of the new edges and faces will be adjusted to the
|
||||
* properties of the original edge and face
|
||||
* \note The properties of the new halfedges will be undefined
|
||||
*
|
||||
* @param _eh Edge handle that should be splitted
|
||||
* @param _eh Edge handle that should be split
|
||||
* @param _vh Vertex handle that will be inserted at the edge
|
||||
*/
|
||||
void split_copy(EdgeHandle _eh, VertexHandle _vh);
|
||||
|
||||
/** \brief Edge split (= 2-to-4 split)
|
||||
*
|
||||
* The function will introduce two new faces ( non-boundary case) or
|
||||
* one additional face (if edge is boundary)
|
||||
*
|
||||
* \note The properties of the new edges and faces will be adjusted to the
|
||||
* properties of the original edge and face
|
||||
* \note The properties of the new halfedges will be undefined
|
||||
*
|
||||
* \note This is an override to prevent a direct call to PolyConnectivity split_edge_copy,
|
||||
* which would introduce a singular vertex with valence 2 which is not allowed
|
||||
* on TriMeshes
|
||||
*
|
||||
* @param _eh Edge handle that should be split
|
||||
* @param _vh Vertex handle that will be inserted at the edge
|
||||
*/
|
||||
inline void split_edge_copy(EdgeHandle _eh, VertexHandle _vh) { TriConnectivity::split_copy(_eh, _vh); }
|
||||
|
||||
/** \brief Face split (= 1-to-3) split, calls corresponding PolyMeshT function).
|
||||
*
|
||||
* @param _fh Face handle that should be splitted
|
||||
* @param _fh Face handle that should be split
|
||||
* @param _vh Vertex handle that will be inserted at the face
|
||||
*/
|
||||
inline void split(FaceHandle _fh, VertexHandle _vh)
|
||||
@@ -190,7 +226,7 @@ public:
|
||||
|
||||
/** \brief Face split (= 1-to-3) split, calls corresponding PolyMeshT function).
|
||||
*
|
||||
* @param _fh Face handle that should be splitted
|
||||
* @param _fh Face handle that should be split
|
||||
* @param _vh Vertex handle that will be inserted at the face
|
||||
*/
|
||||
inline void split_copy(FaceHandle _fh, VertexHandle _vh)
|
||||
|
||||
@@ -83,17 +83,17 @@
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# define DEPRECATED(msg) __declspec(deprecated(msg))
|
||||
# define OM_DEPRECATED(msg) __declspec(deprecated(msg))
|
||||
#elif defined(__GNUC__)
|
||||
# if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40500 /* Test for GCC >= 4.5.0 */
|
||||
# define DEPRECATED(msg) __attribute__ ((deprecated(msg)))
|
||||
# define OM_DEPRECATED(msg) __attribute__ ((deprecated(msg)))
|
||||
# else
|
||||
# define DEPRECATED(msg) __attribute__ ((deprecated))
|
||||
# define OM_DEPRECATED(msg) __attribute__ ((deprecated))
|
||||
# endif
|
||||
#elif defined(__clang__)
|
||||
# define DEPRECATED(msg) __attribute__ ((deprecated(msg)))
|
||||
# define OM_DEPRECATED(msg) __attribute__ ((deprecated(msg)))
|
||||
#else
|
||||
# define DEPRECATED(msg)
|
||||
# define OM_DEPRECATED(msg)
|
||||
#endif
|
||||
|
||||
typedef unsigned int uint;
|
||||
|
||||
212
src/OpenMesh/Tools/SmartTagger/SmartTaggerT.cc
Normal file
212
src/OpenMesh/Tools/SmartTagger/SmartTaggerT.cc
Normal file
@@ -0,0 +1,212 @@
|
||||
/* ========================================================================= *
|
||||
* *
|
||||
* OpenMesh *
|
||||
* Copyright (c) 2001-2015, RWTH-Aachen University *
|
||||
* Department of Computer Graphics and Multimedia *
|
||||
* All rights reserved. *
|
||||
* www.openmesh.org *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* This file is part of OpenMesh. *
|
||||
*---------------------------------------------------------------------------*
|
||||
* *
|
||||
* Redistribution and use in source and binary forms, with or without *
|
||||
* modification, are permitted provided that the following conditions *
|
||||
* are met: *
|
||||
* *
|
||||
* 1. Redistributions of source code must retain the above copyright notice, *
|
||||
* this list of conditions and the following disclaimer. *
|
||||
* *
|
||||
* 2. Redistributions in binary form must reproduce the above copyright *
|
||||
* notice, this list of conditions and the following disclaimer in the *
|
||||
* documentation and/or other materials provided with the distribution. *
|
||||
* *
|
||||
* 3. Neither the name of the copyright holder nor the names of its *
|
||||
* contributors may be used to endorse or promote products derived from *
|
||||
* this software without specific prior written permission. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
|
||||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
|
||||
* *
|
||||
* ========================================================================= */
|
||||
|
||||
/*===========================================================================*\
|
||||
* *
|
||||
* $Revision$ *
|
||||
* $Date$ *
|
||||
* *
|
||||
\*===========================================================================*/
|
||||
|
||||
#define OPENMESH_SMARTTAGGERT_C
|
||||
|
||||
//== INCLUDES =================================================================
|
||||
|
||||
#include "SmartTaggerT.hh"
|
||||
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
//== NAMESPACES ===============================================================
|
||||
|
||||
namespace OpenMesh {
|
||||
|
||||
//== IMPLEMENTATION ==========================================================
|
||||
|
||||
template <class Mesh, class EHandle, class EPHandle>
|
||||
SmartTaggerT<Mesh, EHandle, EPHandle>::
|
||||
SmartTaggerT(Mesh& _mesh, unsigned int _tag_range)
|
||||
: mesh_(_mesh),
|
||||
current_base_(0),
|
||||
tag_range_(_tag_range)
|
||||
{
|
||||
// add new property
|
||||
mesh_.add_property(ep_tag_);
|
||||
|
||||
// reset all tags once
|
||||
all_tags_to_zero();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
template <class Mesh, class EHandle, class EPHandle>
|
||||
SmartTaggerT<Mesh, EHandle, EPHandle>::
|
||||
~SmartTaggerT()
|
||||
{
|
||||
mesh_.remove_property(ep_tag_);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
template <class Mesh, class EHandle, class EPHandle>
|
||||
void
|
||||
SmartTaggerT<Mesh, EHandle, EPHandle>::
|
||||
untag_all()
|
||||
{
|
||||
unsigned int max_uint = std::numeric_limits<unsigned int>::max();
|
||||
|
||||
if( current_base_ < max_uint - 2*tag_range_)
|
||||
current_base_ += tag_range_;
|
||||
else
|
||||
{
|
||||
//overflow -> reset all tags
|
||||
#ifdef STV_DEBUG_CHECKS
|
||||
std::cerr << "Tagging Overflow occured...\n";
|
||||
#endif
|
||||
current_base_ = 0;
|
||||
all_tags_to_zero();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
template <class Mesh, class EHandle, class EPHandle>
|
||||
void
|
||||
SmartTaggerT<Mesh, EHandle, EPHandle>::
|
||||
untag_all( const unsigned int _new_tag_range)
|
||||
{
|
||||
set_tag_range(_new_tag_range);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
template <class Mesh, class EHandle, class EPHandle>
|
||||
void
|
||||
SmartTaggerT<Mesh, EHandle, EPHandle>::
|
||||
set_tag ( const EHandle _eh, unsigned int _tag)
|
||||
{
|
||||
#ifdef STV_DEBUG_CHECKS
|
||||
if( _tag > tag_range_)
|
||||
std::cerr << "ERROR in set_tag tag range!!!\n";
|
||||
#endif
|
||||
|
||||
mesh_.property(ep_tag_, _eh) = current_base_ + _tag;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
template <class Mesh, class EHandle, class EPHandle>
|
||||
unsigned int
|
||||
SmartTaggerT<Mesh, EHandle, EPHandle>::
|
||||
get_tag ( const EHandle _eh) const
|
||||
{
|
||||
unsigned int t = mesh_.property(ep_tag_, _eh);
|
||||
|
||||
#ifdef STV_DEBUG_CHECKS
|
||||
if( t > current_base_ + tag_range_)
|
||||
std::cerr << "ERROR in get_tag tag range!!!\n";
|
||||
#endif
|
||||
|
||||
if( t<= current_base_) return 0;
|
||||
else return t-current_base_;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
template <class Mesh, class EHandle, class EPHandle>
|
||||
bool
|
||||
SmartTaggerT<Mesh, EHandle, EPHandle>::
|
||||
is_tagged( const EHandle _eh) const
|
||||
{
|
||||
return bool(get_tag(_eh));
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
template <class Mesh, class EHandle, class EPHandle>
|
||||
void
|
||||
SmartTaggerT<Mesh, EHandle, EPHandle>::
|
||||
set_tag_range( const unsigned int _tag_range)
|
||||
{
|
||||
if( _tag_range <= tag_range_)
|
||||
{
|
||||
untag_all();
|
||||
tag_range_ = _tag_range;
|
||||
}
|
||||
else
|
||||
{
|
||||
tag_range_ = _tag_range;
|
||||
untag_all();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
template <class Mesh, class EHandle, class EPHandle>
|
||||
void
|
||||
SmartTaggerT<Mesh, EHandle, EPHandle>::
|
||||
all_tags_to_zero()
|
||||
{
|
||||
// iterate over property vector
|
||||
for(unsigned int i=0; i<mesh_.property(ep_tag_).n_elements(); ++i)
|
||||
{
|
||||
mesh_.property(ep_tag_)[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
} // namespace OpenMesh
|
||||
//=============================================================================
|
||||
249
src/OpenMesh/Tools/SmartTagger/SmartTaggerT.hh
Normal file
249
src/OpenMesh/Tools/SmartTagger/SmartTaggerT.hh
Normal file
@@ -0,0 +1,249 @@
|
||||
/* ========================================================================= *
|
||||
* *
|
||||
* OpenMesh *
|
||||
* Copyright (c) 2001-2015, RWTH-Aachen University *
|
||||
* Department of Computer Graphics and Multimedia *
|
||||
* All rights reserved. *
|
||||
* www.openmesh.org *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* This file is part of OpenMesh. *
|
||||
*---------------------------------------------------------------------------*
|
||||
* *
|
||||
* Redistribution and use in source and binary forms, with or without *
|
||||
* modification, are permitted provided that the following conditions *
|
||||
* are met: *
|
||||
* *
|
||||
* 1. Redistributions of source code must retain the above copyright notice, *
|
||||
* this list of conditions and the following disclaimer. *
|
||||
* *
|
||||
* 2. Redistributions in binary form must reproduce the above copyright *
|
||||
* notice, this list of conditions and the following disclaimer in the *
|
||||
* documentation and/or other materials provided with the distribution. *
|
||||
* *
|
||||
* 3. Neither the name of the copyright holder nor the names of its *
|
||||
* contributors may be used to endorse or promote products derived from *
|
||||
* this software without specific prior written permission. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
|
||||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
|
||||
* *
|
||||
* ========================================================================= */
|
||||
|
||||
/*===========================================================================*\
|
||||
* *
|
||||
* $Revision$ *
|
||||
* $Date$ *
|
||||
* *
|
||||
\*===========================================================================*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
//== INCLUDES =================================================================
|
||||
|
||||
// OpenMesh
|
||||
#include <OpenMesh/Core/Utils/Property.hh>
|
||||
#include <OpenMesh/Core/System/omstream.hh>
|
||||
|
||||
|
||||
//== DEFINES ==================================================================
|
||||
|
||||
#define STV_DEBUG_CHECKS
|
||||
|
||||
//== NAMESPACES ===============================================================
|
||||
|
||||
namespace OpenMesh {
|
||||
|
||||
//== FORWARD DECLARATIONS =====================================================
|
||||
|
||||
// Smarttagging for vertices
|
||||
template< class Mesh> class SmartTaggerVT;
|
||||
// Smarttagging for edges
|
||||
template< class Mesh> class SmartTaggerET;
|
||||
// Smarttagging for faces
|
||||
template< class Mesh> class SmartTaggerFT;
|
||||
// Smarttagging for halfedges
|
||||
template< class Mesh> class SmartTaggerHT;
|
||||
|
||||
|
||||
//== CLASS DEFINITION =========================================================
|
||||
|
||||
|
||||
/** \page smarttagger_docu Smart Tagger
|
||||
|
||||
The smart tagger can be used to tag vertices/halfedges/edges/faces on the mesh. It provides
|
||||
an O(1) reset function to untag all primitives at once.
|
||||
|
||||
Usage:
|
||||
|
||||
\code
|
||||
SmartTaggerVT< MeshType > tagger(mesh);
|
||||
|
||||
// Reset tagged flag on all vertices
|
||||
tagger.untag_all();
|
||||
|
||||
// Check if something is tagged
|
||||
bool tag = tagger.is_tagged(vh);
|
||||
|
||||
// Set tagged:
|
||||
tagger.set_tag(vh);
|
||||
\endcode
|
||||
|
||||
For details see OpenMesh::SmartTaggerT
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/** \brief Smart Tagger
|
||||
*
|
||||
* A tagger class to be used on OpenMesh. It provides an O(1) reset function for the property.
|
||||
* - Smarttagging for vertices: SmartTaggerVT;
|
||||
* - Smarttagging for edges: SmartTaggerET;
|
||||
* - Smarttagging for faces: SmartTaggerFT;
|
||||
* - Smarttagging for halfedges: SmartTaggerHT;
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* \code
|
||||
* SmartTaggerVT< MeshType >* tagger = new SmartTaggerVT< MeshType > (mesh_);
|
||||
*
|
||||
* // Reset tagged flag on all vertices
|
||||
* tagger.untag_all();
|
||||
*
|
||||
* // Check if something is tagged
|
||||
* bool tag = tagger.is_tagged(vh);
|
||||
*
|
||||
* // Set tagged:
|
||||
* tagger.set_tag(vh);
|
||||
* \endcode
|
||||
*/
|
||||
template <class Mesh, class EHandle, class EPHandle>
|
||||
class SmartTaggerT
|
||||
{
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
SmartTaggerT(Mesh& _mesh, unsigned int _tag_range = 1);
|
||||
|
||||
/// Destructor
|
||||
~SmartTaggerT();
|
||||
|
||||
/** \brief untag all elements
|
||||
*
|
||||
*/
|
||||
inline void untag_all();
|
||||
|
||||
/** \brief untag all elements and set new tag_range
|
||||
*
|
||||
* @param _new_tag_range New tag range of the tagger
|
||||
*/
|
||||
inline void untag_all( const unsigned int _new_tag_range);
|
||||
|
||||
/** \brief set tag to a value in [0..tag_range]
|
||||
*
|
||||
* @param _eh Edge handle for the tag
|
||||
* @param _tag Tag value
|
||||
*/
|
||||
inline void set_tag ( const EHandle _eh, unsigned int _tag = 1);
|
||||
|
||||
/** \brief get tag value in range [0..tag_range]
|
||||
*
|
||||
* @param _eh Edge handle for the tag
|
||||
* @return Current tag value at that edge
|
||||
*/
|
||||
inline unsigned int get_tag ( const EHandle _eh) const;
|
||||
|
||||
/** \brief overloaded member for boolean tags
|
||||
*
|
||||
* @param _eh Edge handle for the tag
|
||||
* @return Current tag value at that edge
|
||||
*/
|
||||
inline bool is_tagged( const EHandle _eh) const;
|
||||
|
||||
/** \brief set new tag range and untag_all
|
||||
*
|
||||
* Set new tag range and reset tagger
|
||||
*
|
||||
* @param _tag_range New tag range of the tagger
|
||||
*/
|
||||
inline void set_tag_range( const unsigned int _tag_range);
|
||||
|
||||
protected:
|
||||
|
||||
inline void all_tags_to_zero();
|
||||
|
||||
protected:
|
||||
|
||||
// Reference to Mesh
|
||||
Mesh& mesh_;
|
||||
|
||||
// property which holds the current tags
|
||||
EPHandle ep_tag_;
|
||||
|
||||
// current tags range is [current_base_+1...current_base_+tag_range_]
|
||||
unsigned int current_base_;
|
||||
|
||||
// number of different tagvalues available
|
||||
unsigned int tag_range_;
|
||||
};
|
||||
|
||||
|
||||
//== SPECIALIZATION ===========================================================
|
||||
|
||||
// define standard Tagger
|
||||
template< class Mesh>
|
||||
class SmartTaggerVT
|
||||
: public SmartTaggerT< Mesh, typename Mesh::VertexHandle, OpenMesh::VPropHandleT<unsigned int> >
|
||||
{
|
||||
public:
|
||||
typedef SmartTaggerT< Mesh, typename Mesh::VertexHandle, OpenMesh::VPropHandleT<unsigned int> > BaseType;
|
||||
SmartTaggerVT(Mesh& _mesh, unsigned int _tag_range = 1) : BaseType(_mesh, _tag_range) {}
|
||||
};
|
||||
|
||||
template< class Mesh>
|
||||
class SmartTaggerET
|
||||
: public SmartTaggerT< Mesh, typename Mesh::EdgeHandle, OpenMesh::EPropHandleT<unsigned int> >
|
||||
{
|
||||
public:
|
||||
typedef SmartTaggerT< Mesh, typename Mesh::EdgeHandle, OpenMesh::EPropHandleT<unsigned int> > BaseType;
|
||||
SmartTaggerET(Mesh& _mesh, unsigned int _tag_range = 1) : BaseType(_mesh, _tag_range) {}
|
||||
};
|
||||
|
||||
template< class Mesh>
|
||||
class SmartTaggerFT
|
||||
: public SmartTaggerT< Mesh, typename Mesh::FaceHandle, OpenMesh::FPropHandleT<unsigned int> >
|
||||
{
|
||||
public:
|
||||
typedef SmartTaggerT< Mesh, typename Mesh::FaceHandle, OpenMesh::FPropHandleT<unsigned int> > BaseType;
|
||||
SmartTaggerFT(Mesh& _mesh, unsigned int _tag_range = 1): BaseType(_mesh, _tag_range) {}
|
||||
};
|
||||
|
||||
template< class Mesh>
|
||||
class SmartTaggerHT
|
||||
: public SmartTaggerT< Mesh, typename Mesh::HalfedgeHandle, OpenMesh::HPropHandleT<unsigned int> >
|
||||
{
|
||||
public:
|
||||
typedef SmartTaggerT< Mesh, typename Mesh::HalfedgeHandle, OpenMesh::HPropHandleT<unsigned int> > BaseType;
|
||||
SmartTaggerHT(Mesh& _mesh, unsigned int _tag_range = 1): BaseType(_mesh, _tag_range){}
|
||||
};
|
||||
|
||||
|
||||
//=============================================================================
|
||||
} // namespace OpenMesh
|
||||
//=============================================================================
|
||||
#if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SMARTTAGGERT_C)
|
||||
#define OPENMESH_SMARTTAGGERT_TEMPLATES
|
||||
#include "SmartTaggerT.cc"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user