...
 
Commits (9)
......@@ -108,12 +108,12 @@ public:
}
const OpenVolumeMeshStatus& mesh_status() const {
OpenVolumeMeshHandle h(0);
MeshHandle h(0);
return m_status_[h];
}
OpenVolumeMeshStatus& mesh_status() {
OpenVolumeMeshHandle h(0);
MeshHandle h(0);
return m_status_[h];
}
......
#pragma once
#include <type_traits>
namespace OpenVolumeMesh {
namespace Entity {
struct Vertex {};
struct Edge {};
struct HalfEdge {};
struct Face {};
struct HalfFace {};
struct Cell {};
struct Mesh {};
}
template<typename T>
struct is_entity : std::false_type {};
template<> struct is_entity<Entity::Vertex> : std::true_type {};
template<> struct is_entity<Entity::Edge> : std::true_type {};
template<> struct is_entity<Entity::HalfEdge> : std::true_type {};
template<> struct is_entity<Entity::Face> : std::true_type {};
template<> struct is_entity<Entity::HalfFace> : std::true_type {};
template<> struct is_entity<Entity::Cell> : std::true_type {};
template<> struct is_entity<Entity::Mesh> : std::true_type {};
} // namespace OpenVolumeMesh
#pragma once
#include "Entities.hh"
namespace OpenVolumeMesh {
class BaseProperty;
template <class T>
class OpenVolumeMeshPropertyT;
template <class E, typename >
class PropHandleT;
template <class PropT, class HandleT>
class PropertyPtr;
template<typename T, typename Entity>
class PropertyTT;
template<typename T> using VertexPropertyT = PropertyTT<T, Entity::Vertex>;
template<typename T> using EdgePropertyT = PropertyTT<T, Entity::Edge>;
template<typename T> using HalfEdgePropertyT = PropertyTT<T, Entity::HalfEdge>;
template<typename T> using FacePropertyT = PropertyTT<T, Entity::Face>;
template<typename T> using HalfFacePropertyT = PropertyTT<T, Entity::HalfFace>;
template<typename T> using CellPropertyT = PropertyTT<T, Entity::Cell>;
template<typename T> using MeshPropertyT = PropertyTT<T, Entity::Mesh>;
} // namespace OVM
......@@ -75,9 +75,7 @@ public:
name_(_name), persistent_(false), handle_(-1) {
}
OpenVolumeMeshBaseProperty(const OpenVolumeMeshBaseProperty& _rhs) :
name_(_rhs.name_), persistent_(_rhs.persistent_), handle_(_rhs.handle_.idx()) {
}
OpenVolumeMeshBaseProperty(const OpenVolumeMeshBaseProperty& _rhs) = default;
virtual ~OpenVolumeMeshBaseProperty() {}
......
......@@ -32,14 +32,6 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 36 $ *
* $Date: 2012-01-10 18:00:06 +0100 (Di, 10 Jan 2012) $ *
* $LastChangedBy: kremer $ *
* *
\*===========================================================================*/
#include <istream>
#include "OpenVolumeMeshHandle.hh"
......
......@@ -32,21 +32,13 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* $LastChangedBy$ *
* *
\*===========================================================================*/
#ifndef OPENVOLUMEMESHHANDLE_HH_
#define OPENVOLUMEMESHHANDLE_HH_
#pragma once
#include <algorithm>
#include <iosfwd>
#include <vector>
#include "Entities.hh"
#include "../System/FunctionalInclude.hh"
#include "../System/Deprecation.hh"
......@@ -95,14 +87,25 @@ private:
int idx_;
};
template<typename EntityTag,
typename = typename std::enable_if<is_entity<EntityTag>::value>::type>
class HandleT : public OpenVolumeMeshHandle
{
public:
using Entity = EntityTag;
explicit HandleT(int _idx = -1) : OpenVolumeMeshHandle(_idx) {}
};
// Default entity handles
class VertexHandle : public OpenVolumeMeshHandle { public: explicit VertexHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class EdgeHandle : public OpenVolumeMeshHandle { public: explicit EdgeHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class FaceHandle : public OpenVolumeMeshHandle { public: explicit FaceHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class CellHandle : public OpenVolumeMeshHandle { public: explicit CellHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class HalfEdgeHandle : public OpenVolumeMeshHandle { public: explicit HalfEdgeHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class HalfFaceHandle : public OpenVolumeMeshHandle { public: explicit HalfFaceHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
using VertexHandle = HandleT<Entity::Vertex>;
using HalfEdgeHandle = HandleT<Entity::HalfEdge>;
using EdgeHandle = HandleT<Entity::Edge>;
using HalfFaceHandle = HandleT<Entity::HalfFace>;
using FaceHandle = HandleT<Entity::Face>;
using CellHandle = HandleT<Entity::Cell>;
using MeshHandle = HandleT<Entity::Mesh>;
// Helper class that is used to decrease all handles
// exceeding a certain threshold
......@@ -176,4 +179,3 @@ std::istream& operator>>(std::istream& _istr, OpenVolumeMeshHandle& _handle);
} // Namespace OpenVolumeMesh
#endif /* OPENVOLUMEMESHHANDLE_HH_ */
......@@ -32,16 +32,7 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* $LastChangedBy$ *
* *
\*===========================================================================*/
#ifndef OPENVOLUMEMESHPROPERTY_HH
#define OPENVOLUMEMESHPROPERTY_HH
#pragma once
//== INCLUDES =================================================================
......@@ -81,18 +72,13 @@ public:
public:
/// Default constructor
OpenVolumeMeshPropertyT(const std::string& _name = "<unknown>", const T _def = T()) :
OpenVolumeMeshPropertyT(const std::string& _name = "<unknown>", const T &_def = T()) :
OpenVolumeMeshBaseProperty(_name),
def_(_def) {
}
/// Copy constructor
OpenVolumeMeshPropertyT(const OpenVolumeMeshPropertyT& _rhs) :
OpenVolumeMeshBaseProperty(_rhs),
data_(_rhs.data_),
def_(_rhs.def_) {
}
OpenVolumeMeshPropertyT(const OpenVolumeMeshPropertyT& _rhs) = default;
public:
// inherited from OpenVolumeMeshBaseProperty
......@@ -110,8 +96,10 @@ public:
data_.push_back(def_);
}
virtual void swap(size_t _i0, size_t _i1) {
std::swap(data_[_i0], data_[_i1]);
}
std::swap(data_[_i0], data_[_i1]);
}
virtual void copy(size_t _src_idx, size_t _dst_idx) {
data_[_dst_idx] = data_[_src_idx];
}
......@@ -125,8 +113,9 @@ public:
return data_.size();
}
virtual size_t element_size() const {
return sizeof(T);
}
return sizeof(T);
}
#ifndef DOXY_IGNORE_THIS
struct plus {
......@@ -136,11 +125,11 @@ public:
};
#endif
virtual size_t size_of() const {
if (element_size() != OpenVolumeMeshBaseProperty::UnknownSize)
return this->OpenVolumeMeshBaseProperty::size_of(n_elements());
return std::accumulate(data_.begin(), data_.end(), size_t(0), plus());
}
virtual size_t size_of() const {
if (element_size() != OpenVolumeMeshBaseProperty::UnknownSize)
return this->OpenVolumeMeshBaseProperty::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 {
return this->OpenVolumeMeshBaseProperty::size_of(_n_elem);
......@@ -230,296 +219,75 @@ private:
const T def_;
};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Property specialization for bool type.
//-----------------------------------------------------------------------------
/**
* Property specialization for bool type.
*/
template<>
class OpenVolumeMeshPropertyT<bool> : public OpenVolumeMeshBaseProperty {
public:
template <class PropT, class HandleT> friend class PropertyPtr;
typedef std::vector<bool> vector_type;
typedef bool value_type;
typedef vector_type::reference reference;
typedef vector_type::const_reference const_reference;
public:
OpenVolumeMeshPropertyT(const std::string& _name = "<unknown>", const bool _def = bool()) :
OpenVolumeMeshBaseProperty(_name),
def_(_def) {
}
public:
// inherited from OpenVolumeMeshBaseProperty
virtual void reserve(size_t _n) {
data_.reserve(_n);
}
virtual void resize(size_t _n) {
data_.resize(_n, def_);
}
virtual void clear() {
data_.clear();
vector_type().swap(data_);
}
virtual void push_back() {
data_.push_back(def_);
}
virtual void swap(size_t _i0, size_t _i1) {
bool t(data_[_i0]);
data_[_i0] = data_[_i1];
data_[_i1] = t;
}
virtual void copy(size_t _src_idx, size_t _dst_idx) {
data_[_dst_idx] = data_[_src_idx];
}
void delete_element(size_t _idx) {
data_.erase(data_.begin() + _idx);
}
public:
virtual size_t n_elements() const {
return data_.size();
}
virtual size_t element_size() const {
return OpenVolumeMeshBaseProperty::UnknownSize;
}
virtual size_t size_of() const {
return size_of(n_elements());
}
virtual size_t size_of(size_t _n_elem) const {
return _n_elem / 8 + ((_n_elem % 8) != 0);
}
// Function to serialize a property
virtual void serialize(std::ostream& _ostr) const {
for(vector_type::const_iterator it = data_.begin();
it != data_.end(); ++it) {
OpenVolumeMesh::serialize(_ostr, *it) << std::endl;
}
}
// Function to deserialize a property
virtual void deserialize(std::istream& _istr) {
for(unsigned int i = 0; i < n_elements(); ++i) {
value_type val;
OpenVolumeMesh::deserialize(_istr, val);
data_[i] = val;
}
}
public:
/// Access the i'th element. No range check is performed!
reference operator[](size_t _idx) {
assert(_idx < data_.size());
return data_[_idx];
}
/// Const access to the i'th element. No range check is performed!
const_reference operator[](size_t _idx) const {
assert(_idx < data_.size());
return data_[_idx];
}
/// Make a copy of self.
OpenVolumeMeshPropertyT<bool>* clone() const {
OpenVolumeMeshPropertyT<bool>* p = new OpenVolumeMeshPropertyT<bool> (
*this);
return p;
}
inline void OpenVolumeMeshPropertyT<bool>::swap(size_t _i0, size_t _i1)
{
// std::vector<bool>::swap(reference x, reference y) exists, but
// on libstdc++ with _GLIBCXX_DEBUG it doesn't compile
// (2018-02-26, libstdc++ 8.2.0)
vector_type::const_iterator begin() const { return data_.begin(); }
auto tmp = data_[_i0];
data_[_i0] = data_[_i1];
data_[_i1] = tmp;;
}
vector_type::iterator begin() { return data_.begin(); }
vector_type::const_iterator end() const { return data_.end(); }
vector_type::iterator end() { return data_.end(); }
template<>
inline size_t OpenVolumeMeshPropertyT<bool>::size_of(size_t _n_elem) const
{
return _n_elem / 8 + ((_n_elem % 8) != 0);
}
protected:
template<>
inline size_t OpenVolumeMeshPropertyT<bool>::size_of() const
{
return size_of(n_elements());
}
/// Delete multiple entries in list
virtual void delete_multiple_entries(const std::vector<bool>& _tags) {
template<>
inline size_t OpenVolumeMeshPropertyT<bool>::element_size() const
{
return OpenVolumeMeshBaseProperty::UnknownSize;
}
assert(_tags.size() == data_.size());
vector_type new_data;
vector_type::iterator d_it = data_.begin();
std::vector<bool>::const_iterator t_it = _tags.begin();
std::vector<bool>::const_iterator t_end = _tags.end();
for(; t_it != t_end; ++t_it, ++d_it) {
if(!*t_it) {
new_data.push_back(*d_it);
}
}
data_.swap(new_data);
template<>
inline void OpenVolumeMeshPropertyT<bool>::deserialize(std::istream& _istr)
{
for(unsigned int i = 0; i < n_elements(); ++i) {
value_type val;
OpenVolumeMesh::deserialize(_istr, val);
data_[i] = val;
}
}
private:
vector_type data_;
const bool def_;
};
//-----------------------------------------------------------------------------
/**
* Property specialization for std::string type.
*/
// Property specialization for std::string type.
//-----------------------------------------------------------------------------
template<>
class OpenVolumeMeshPropertyT<std::string> : public OpenVolumeMeshBaseProperty {
public:
template <class PropT, class HandleT> friend class PropertyPtr;
typedef std::string Value;
typedef std::vector<std::string> vector_type;
typedef std::string value_type;
typedef vector_type::reference reference;
typedef vector_type::const_reference const_reference;
public:
OpenVolumeMeshPropertyT(const std::string& _name = "<unknown>", const std::string& _def = "") :
OpenVolumeMeshBaseProperty(_name),
def_(_def) {
}
public:
// inherited from OpenVolumeMeshBaseProperty
virtual void reserve(size_t _n) {
data_.reserve(_n);
}
virtual void resize(size_t _n) {
data_.resize(_n, def_);
}
virtual void clear() {
data_.clear();
vector_type().swap(data_);
}
virtual void push_back() {
data_.push_back(def_);
}
virtual void swap(size_t _i0, size_t _i1) {
std::swap(data_[_i0], data_[_i1]);
}
virtual void copy(size_t _src_idx, size_t _dst_idx) {
data_[_dst_idx] = data_[_src_idx];
}
virtual void delete_element(size_t _idx) {
data_.erase(data_.begin() + _idx);
}
public:
virtual size_t n_elements() const {
return data_.size();
}
virtual size_t element_size() const {
return OpenVolumeMeshBaseProperty::UnknownSize;
}
virtual size_t size_of() const {
return sizeof(data_);
}
virtual size_t size_of(size_t /* _n_elem */) const {
return OpenVolumeMeshBaseProperty::UnknownSize;
}
virtual void stats(std::ostream& _ostr) const {
for(vector_type::const_iterator it = data_.begin();
it != data_.end(); ++it) {
_ostr << *it << " ";
}
}
// Function to serialize a property
virtual void serialize(std::ostream& _ostr) const {
for(vector_type::const_iterator it = data_.begin();
it != data_.end(); ++it) {
OpenVolumeMesh::serialize(_ostr, *it) << std::endl;
}
}
// Function to deserialize a property
virtual void deserialize(std::istream& _istr) {
for(unsigned int i = 0; i < n_elements(); ++i) {
OpenVolumeMesh::deserialize(_istr, data_[i]);
}
}
public:
const value_type* data() const {
if (data_.empty())
return 0;
return (value_type*) &data_[0];
}
/// Access the i'th element. No range check is performed!
reference operator[](size_t _idx) {
assert(_idx < data_.size());
return ((value_type*) &data_[0])[_idx];
}
/// Const access the i'th element. No range check is performed!
const_reference operator[](size_t _idx) const {
assert(_idx < data_.size());
return ((value_type*) &data_[0])[_idx];
}
OpenVolumeMeshPropertyT<value_type>* clone() const {
OpenVolumeMeshPropertyT<value_type>* p = new OpenVolumeMeshPropertyT<
value_type> (*this);
return p;
}
vector_type::const_iterator begin() const { return data_.begin(); }
vector_type::iterator begin() { return data_.begin(); }
vector_type::const_iterator end() const { return data_.end(); }
inline size_t OpenVolumeMeshPropertyT<std::string>::size_of(size_t) const
{
return OpenVolumeMeshBaseProperty::UnknownSize;
}
vector_type::iterator end() { return data_.end(); }
protected:
/// Delete multiple entries in list
virtual void delete_multiple_entries(const std::vector<bool>& _tags) {
assert(_tags.size() == data_.size());
vector_type new_data;
vector_type::iterator d_it = data_.begin();
std::vector<bool>::const_iterator t_it = _tags.begin();
std::vector<bool>::const_iterator t_end = _tags.end();
for(; t_it != t_end; ++t_it, ++d_it) {
if(!*t_it) {
new_data.push_back(*d_it);
}
}
data_.swap(new_data);
}
template<>
inline size_t OpenVolumeMeshPropertyT<std::string>::size_of() const
{
return sizeof(data_);
}
private:
template<>
inline size_t OpenVolumeMeshPropertyT<std::string>::element_size() const
{
return OpenVolumeMeshBaseProperty::UnknownSize;
}
vector_type data_;
const std::string def_;
};
//-----------------------------------------------------------------------------
} // Namespace OpenVolumeMesh
//=============================================================================
#endif // OPENVOLUMEMESHPROPERTY_HH defined
//=============================================================================
......@@ -32,13 +32,6 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* $LastChangedBy$ *
* *
\*===========================================================================*/
#include "PropertyDefines.hh"
......@@ -60,4 +53,13 @@ template <> const std::string typeName<std::vector<double> >(){ return "vector_d
template <> const std::string typeName<std::vector<VertexHandle> >(){ return "vector_vh"; }
template <> const std::string typeName<std::vector<HalfFaceHandle> >(){ return "vector_hfh"; }
template <> const std::string typeName<std::vector<std::vector<HalfFaceHandle> > >(){ return "vector_vector_hfh"; }
template <> const std::string entityTypeName<Entity::Vertex>() { return "VProp"; }
template <> const std::string entityTypeName<Entity::HalfEdge>(){ return "HEProp"; }
template <> const std::string entityTypeName<Entity::Edge>() { return "EProp"; }
template <> const std::string entityTypeName<Entity::Face>() { return "FProp"; }
template <> const std::string entityTypeName<Entity::HalfFace>(){ return "HFProp"; }
template <> const std::string entityTypeName<Entity::Cell>() { return "CProp"; }
template <> const std::string entityTypeName<Entity::Mesh>() { return "MProp"; }
} // Namespace OpenVolumeMesh
......@@ -32,22 +32,14 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* $LastChangedBy$ *
* *
\*===========================================================================*/
#ifndef PROPERTYDEFINES_HH_
#define PROPERTYDEFINES_HH_
#pragma once
#include <iosfwd>
#include <stdexcept>
#include <string>
#include <typeinfo>
#include "Entities.hh"
#include "PropertyHandles.hh"
#include "PropertyPtr.hh"
......@@ -78,103 +70,43 @@ template <> const std::string typeName<std::vector<VertexHandle> >();
template <> const std::string typeName<std::vector<HalfFaceHandle> >();
template <> const std::string typeName<std::vector<std::vector<HalfFaceHandle> > >();
/// Property classes for the different entity types
template<class T>
class VertexPropertyT : public PropertyPtr<OpenVolumeMeshPropertyT<T>, VertexPropHandle> {
public:
VertexPropertyT(const std::string& _name, ResourceManager& _resMan, VertexPropHandle _handle, const T _def = T());
virtual ~VertexPropertyT() {}
virtual BaseProperty* clone(ResourceManager &_resMan, OpenVolumeMeshHandle _handle) const;
virtual void serialize(std::ostream& _ostr) const;
virtual void deserialize(std::istream& _istr);
virtual const std::string entityType() const { return "VProp"; }
virtual const std::string typeNameWrapper() const { return typeName<T>(); }
private:
VertexPropertyT(OpenVolumeMeshPropertyT<T> *_prop, ResourceManager& _resMan, VertexPropHandle _handle);
};
template<class T>
class EdgePropertyT : public PropertyPtr<OpenVolumeMeshPropertyT<T>, EdgePropHandle> {
public:
EdgePropertyT(const std::string& _name, ResourceManager& _resMan, EdgePropHandle _handle, const T _def = T());
virtual ~EdgePropertyT() {}
virtual BaseProperty* clone(ResourceManager &_resMan, OpenVolumeMeshHandle _handle) const;
virtual void serialize(std::ostream& _ostr) const;
virtual void deserialize(std::istream& _istr);
virtual const std::string entityType() const { return "EProp"; }
virtual const std::string typeNameWrapper() const { return typeName<T>(); }
private:
EdgePropertyT(OpenVolumeMeshPropertyT<T> *_prop, ResourceManager& _resMan, EdgePropHandle _handle);
};
template<class T>
class HalfEdgePropertyT : public PropertyPtr<OpenVolumeMeshPropertyT<T>, HalfEdgePropHandle> {
public:
HalfEdgePropertyT(const std::string& _name, ResourceManager& _resMan, HalfEdgePropHandle _handle, const T _def = T());
virtual ~HalfEdgePropertyT() {}
virtual BaseProperty* clone(ResourceManager &_resMan, OpenVolumeMeshHandle _handle) const;
virtual void serialize(std::ostream& _ostr) const;
virtual void deserialize(std::istream& _istr);
virtual const std::string entityType() const { return "HEProp"; }
virtual const std::string typeNameWrapper() const { return typeName<T>(); }
private:
HalfEdgePropertyT(OpenVolumeMeshPropertyT<T> *_prop, ResourceManager& _resMan, HalfEdgePropHandle _handle);
};
template<class T>
class FacePropertyT : public PropertyPtr<OpenVolumeMeshPropertyT<T>, FacePropHandle> {
public:
FacePropertyT(const std::string& _name, ResourceManager& _resMan, FacePropHandle _handle, const T _def = T());
virtual ~FacePropertyT() {}
virtual BaseProperty* clone(ResourceManager &_resMan, OpenVolumeMeshHandle _handle) const;
virtual void serialize(std::ostream& _ostr) const;
virtual void deserialize(std::istream& _istr);
virtual const std::string entityType() const { return "FProp"; }
virtual const std::string typeNameWrapper() const { return typeName<T>(); }
private:
FacePropertyT(OpenVolumeMeshPropertyT<T> *_prop, ResourceManager& _resMan, FacePropHandle _handle);
};
template<class T>
class HalfFacePropertyT : public PropertyPtr<OpenVolumeMeshPropertyT<T>, HalfFacePropHandle> {
public:
HalfFacePropertyT(const std::string& _name, ResourceManager& _resMan, HalfFacePropHandle _handle, const T _def = T());
virtual ~HalfFacePropertyT() {}
virtual BaseProperty* clone(ResourceManager &_resMan, OpenVolumeMeshHandle _handle) const;
virtual void serialize(std::ostream& _ostr) const;
virtual void deserialize(std::istream& _istr);
virtual const std::string entityType() const { return "HFProp"; }
virtual const std::string typeNameWrapper() const { return typeName<T>(); }
private:
HalfFacePropertyT(OpenVolumeMeshPropertyT<T> *_prop, ResourceManager& _resMan, HalfFacePropHandle _handle);
};
template<class T>
class CellPropertyT : public PropertyPtr<OpenVolumeMeshPropertyT<T>, CellPropHandle> {
public:
CellPropertyT(const std::string& _name, ResourceManager& _resMan, CellPropHandle _handle, const T _def = T());
virtual ~CellPropertyT() {}
virtual BaseProperty* clone(ResourceManager &_resMan, OpenVolumeMeshHandle _handle) const;
virtual void serialize(std::ostream& _ostr) const;
virtual void deserialize(std::istream& _istr);
virtual const std::string entityType() const { return "CProp"; }
virtual const std::string typeNameWrapper() const { return typeName<T>(); }
private:
CellPropertyT(OpenVolumeMeshPropertyT<T> *_prop, ResourceManager& _resMan, CellPropHandle _handle);
};
template<class T>
class MeshPropertyT : public PropertyPtr<OpenVolumeMeshPropertyT<T>, MeshPropHandle> {
template<typename Entity>
const std::string entityTypeName();
template <> const std::string entityTypeName<Entity::Vertex>();
template <> const std::string entityTypeName<Entity::HalfEdge>();
template <> const std::string entityTypeName<Entity::Edge>();
template <> const std::string entityTypeName<Entity::Face>();
template <> const std::string entityTypeName<Entity::HalfFace>();
template <> const std::string entityTypeName<Entity::Cell>();
template <> const std::string entityTypeName<Entity::Mesh>();
template<typename T, typename Entity>
class PropertyTT : public PropertyPtr<OpenVolumeMeshPropertyT<T>, PropHandleT<Entity>> {
public:
MeshPropertyT(const std::string& _name, ResourceManager& _resMan, MeshPropHandle _handle, const T _def = T());
virtual ~MeshPropertyT() {}
using PropertyHandleT = OpenVolumeMesh::PropHandleT<Entity>;
PropertyTT(const std::string& _name, ResourceManager& _resMan, PropertyHandleT _handle, const T _def = T());
virtual ~PropertyTT() = default;
virtual BaseProperty* clone(ResourceManager &_resMan, OpenVolumeMeshHandle _handle) const;
virtual void serialize(std::ostream& _ostr) const;
virtual void deserialize(std::istream& _istr);
virtual const std::string entityType() const { return "MProp"; }
virtual const std::string entityType() const { return entityTypeName<Entity>(); }
virtual const std::string typeNameWrapper() const { return typeName<T>(); }
private:
MeshPropertyT(OpenVolumeMeshPropertyT<T> *_prop, ResourceManager& _resMan, MeshPropHandle _handle);
PropertyTT(OpenVolumeMeshPropertyT<T> *_prop, ResourceManager& _resMan, PropertyHandleT _handle);
};
template<typename T> using VertexPropertyT = PropertyTT<T, Entity::Vertex>;
template<typename T> using EdgePropertyT = PropertyTT<T, Entity::Edge>;
template<typename T> using HalfEdgePropertyT = PropertyTT<T, Entity::HalfEdge>;
template<typename T> using FacePropertyT = PropertyTT<T, Entity::Face>;
template<typename T> using HalfFacePropertyT = PropertyTT<T, Entity::HalfFace>;
template<typename T> using CellPropertyT = PropertyTT<T, Entity::Cell>;
template<typename T> using MeshPropertyT = PropertyTT<T, Entity::Mesh>;
} // Namespace OpenVolumeMesh
#if defined(INCLUDE_TEMPLATES) && !defined(PROPERTYDEFINEST_CC)
#include "PropertyDefinesT_impl.hh"
#endif
#endif /* PROPERTYDEFINES_HH_ */
......@@ -49,205 +49,36 @@
namespace OpenVolumeMesh {
/// Property classes for the different entity types
template<class T>
VertexPropertyT<T>::VertexPropertyT(const std::string& _name, ResourceManager& _resMan, VertexPropHandle _handle, const T _def) :
PropertyPtr<OpenVolumeMeshPropertyT<T>, VertexPropHandle>(new OpenVolumeMeshPropertyT<T>(_name, _def), _resMan, _handle) {
template<typename T, typename Entity>
PropertyTT<T,Entity>::PropertyTT(const std::string& _name, ResourceManager& _resMan, PropertyHandleT _handle, const T _def) :
PropertyPtr<OpenVolumeMeshPropertyT<T>, PropertyHandleT>(new OpenVolumeMeshPropertyT<T>(_name, _def), _resMan, _handle) {
}
template<class T>
VertexPropertyT<T>::VertexPropertyT(OpenVolumeMeshPropertyT<T> *_prop, ResourceManager &_resMan, VertexPropHandle _handle) :
PropertyPtr<OpenVolumeMeshPropertyT<T>, VertexPropHandle>(_prop, _resMan, _handle)
template<typename T, typename Entity>
PropertyTT<T,Entity>::PropertyTT(OpenVolumeMeshPropertyT<T> *_prop, ResourceManager &_resMan, PropertyHandleT _handle) :
PropertyPtr<OpenVolumeMeshPropertyT<T>, PropertyHandleT>(_prop, _resMan, _handle)
{
}
template<class T>
BaseProperty *VertexPropertyT<T>::clone(ResourceManager &_resMan, OpenVolumeMeshHandle _handle) const
template<typename T, typename Entity>
BaseProperty *PropertyTT<T,Entity>::clone(ResourceManager &_resMan, OpenVolumeMeshHandle _handle) const
{
auto prop_clone = ptr::shared_ptr<OpenVolumeMeshPropertyT<T>>::get()->clone();
return new VertexPropertyT<T>(prop_clone, _resMan, VertexPropHandle(_handle.idx()));
return new PropertyTT<T, Entity>(prop_clone, _resMan, PropertyHandleT(_handle.idx()));
}
template<class T>
void VertexPropertyT<T>::serialize(std::ostream& _ostr) const {
PropertyPtr<OpenVolumeMeshPropertyT<T>, VertexPropHandle>::get()->serialize(_ostr);
template<typename T, typename Entity>
void PropertyTT<T,Entity>::serialize(std::ostream& _ostr) const {
PropertyPtr<OpenVolumeMeshPropertyT<T>, PropertyHandleT>::get()->serialize(_ostr);
}
template<class T>
void VertexPropertyT<T>::deserialize(std::istream& _istr) {
PropertyPtr<OpenVolumeMeshPropertyT<T>, VertexPropHandle>::get()->deserialize(_istr);
template<typename T, typename Entity>
void PropertyTT<T,Entity>::deserialize(std::istream& _istr) {
PropertyPtr<OpenVolumeMeshPropertyT<T>, PropertyHandleT>::get()->deserialize(_istr);
}
template<class T>
EdgePropertyT<T>::EdgePropertyT(const std::string& _name, ResourceManager& _resMan, EdgePropHandle _handle, const T _def) :
PropertyPtr<OpenVolumeMeshPropertyT<T>, EdgePropHandle>(new OpenVolumeMeshPropertyT<T>(_name, _def), _resMan, _handle) {
}
template<class T>
EdgePropertyT<T>::EdgePropertyT(OpenVolumeMeshPropertyT<T> *_prop, ResourceManager &_resMan, EdgePropHandle _handle) :
PropertyPtr<OpenVolumeMeshPropertyT<T>, EdgePropHandle>(_prop, _resMan, _handle)
{
}
template<class T>
BaseProperty *EdgePropertyT<T>::clone(ResourceManager &_resMan, const OpenVolumeMeshHandle _handle) const
{
auto prop_clone = ptr::shared_ptr<OpenVolumeMeshPropertyT<T>>::get()->clone();
return new EdgePropertyT<T>(prop_clone, _resMan, EdgePropHandle(_handle.idx()));
}
template<class T>
void EdgePropertyT<T>::serialize(std::ostream& _ostr) const {
PropertyPtr<OpenVolumeMeshPropertyT<T>, EdgePropHandle>::get()->serialize(_ostr);
}
template<class T>
void EdgePropertyT<T>::deserialize(std::istream& _istr) {
PropertyPtr<OpenVolumeMeshPropertyT<T>, EdgePropHandle>::get()->deserialize(_istr);
}
template<class T>
HalfEdgePropertyT<T>::HalfEdgePropertyT(const std::string& _name, ResourceManager& _resMan, HalfEdgePropHandle _handle, const T _def) :
PropertyPtr<OpenVolumeMeshPropertyT<T>, HalfEdgePropHandle>(new OpenVolumeMeshPropertyT<T>(_name, _def), _resMan, _handle) {
}
template<class T>
HalfEdgePropertyT<T>::HalfEdgePropertyT(OpenVolumeMeshPropertyT<T> *_prop, ResourceManager &_resMan, HalfEdgePropHandle _handle) :
PropertyPtr<OpenVolumeMeshPropertyT<T>, HalfEdgePropHandle>(_prop, _resMan, _handle)
{
}
template<class T>
BaseProperty *HalfEdgePropertyT<T>::clone(ResourceManager &_resMan, const OpenVolumeMeshHandle _handle) const
{
auto prop_clone = ptr::shared_ptr<OpenVolumeMeshPropertyT<T>>::get()->clone();
return new HalfEdgePropertyT<T>(prop_clone, _resMan, HalfEdgePropHandle(_handle.idx()));
}
template<class T>
void HalfEdgePropertyT<T>::serialize(std::ostream& _ostr) const {
PropertyPtr<OpenVolumeMeshPropertyT<T>, HalfEdgePropHandle>::get()->serialize(_ostr);
}
template<class T>
void HalfEdgePropertyT<T>::deserialize(std::istream& _istr) {
PropertyPtr<OpenVolumeMeshPropertyT<T>, HalfEdgePropHandle>::get()->deserialize(_istr);
}
template<class T>
FacePropertyT<T>::FacePropertyT(const std::string& _name, ResourceManager& _resMan, FacePropHandle _handle, const T _def) :
PropertyPtr<OpenVolumeMeshPropertyT<T>, FacePropHandle>(new OpenVolumeMeshPropertyT<T>(_name, _def), _resMan, _handle) {
}
template<class T>
FacePropertyT<T>::FacePropertyT(OpenVolumeMeshPropertyT<T> *_prop, ResourceManager &_resMan, FacePropHandle _handle) :
PropertyPtr<OpenVolumeMeshPropertyT<T>, FacePropHandle>(_prop, _resMan, _handle)
{
}
template<class T>
BaseProperty *FacePropertyT<T>::clone(ResourceManager &_resMan, const OpenVolumeMeshHandle _handle) const
{
auto prop_clone = ptr::shared_ptr<OpenVolumeMeshPropertyT<T>>::get()->clone();
return new FacePropertyT<T>(prop_clone, _resMan, FacePropHandle(_handle.idx()));
}
template<class T>
void FacePropertyT<T>::serialize(std::ostream& _ostr) const {
PropertyPtr<OpenVolumeMeshPropertyT<T>, FacePropHandle>::get()->serialize(_ostr);
}
template<class T>
void FacePropertyT<T>::deserialize(std::istream& _istr) {
PropertyPtr<OpenVolumeMeshPropertyT<T>, FacePropHandle>::get()->deserialize(_istr);
}
template<class T>
HalfFacePropertyT<T>::HalfFacePropertyT(const std::string& _name, ResourceManager& _resMan, HalfFacePropHandle _handle, const T _def) :
PropertyPtr<OpenVolumeMeshPropertyT<T>, HalfFacePropHandle>(new OpenVolumeMeshPropertyT<T>(_name, _def), _resMan, _handle) {
}
template<class T>
HalfFacePropertyT<T>::HalfFacePropertyT(OpenVolumeMeshPropertyT<T> *_prop, ResourceManager &_resMan, HalfFacePropHandle _handle) :
PropertyPtr<OpenVolumeMeshPropertyT<T>, HalfFacePropHandle>(_prop, _resMan, _handle)
{
}
template<class T>
BaseProperty *HalfFacePropertyT<T>::clone(ResourceManager &_resMan, const OpenVolumeMeshHandle _handle) const
{
auto prop_clone = ptr::shared_ptr<OpenVolumeMeshPropertyT<T>>::get()->clone();
return new HalfFacePropertyT<T>(prop_clone, _resMan, HalfFacePropHandle(_handle.idx()));
}
template<class T>
void HalfFacePropertyT<T>::serialize(std::ostream& _ostr) const {
PropertyPtr<OpenVolumeMeshPropertyT<T>, HalfFacePropHandle>::get()->serialize(_ostr);
}
template<class T>
void HalfFacePropertyT<T>::deserialize(std::istream& _istr) {
PropertyPtr<OpenVolumeMeshPropertyT<T>, HalfFacePropHandle>::get()->deserialize(_istr);
}
template<class T>
CellPropertyT<T>::CellPropertyT(const std::string& _name, ResourceManager& _resMan, CellPropHandle _handle, const T _def) :
PropertyPtr<OpenVolumeMeshPropertyT<T>, CellPropHandle>(new OpenVolumeMeshPropertyT<T>(_name, _def), _resMan, _handle) {
}
template<class T>
CellPropertyT<T>::CellPropertyT(OpenVolumeMeshPropertyT<T> *_prop, ResourceManager &_resMan, CellPropHandle _handle) :
PropertyPtr<OpenVolumeMeshPropertyT<T>, CellPropHandle>(_prop, _resMan, _handle)
{
}
template<class T>
BaseProperty *CellPropertyT<T>::clone(ResourceManager &_resMan, const OpenVolumeMeshHandle _handle) const
{
auto prop_clone = ptr::shared_ptr<OpenVolumeMeshPropertyT<T>>::get()->clone();
return new CellPropertyT<T>(prop_clone, _resMan, CellPropHandle(_handle.idx()));
}
template<class T>
void CellPropertyT<T>::serialize(std::ostream& _ostr) const {
PropertyPtr<OpenVolumeMeshPropertyT<T>, CellPropHandle>::get()->serialize(_ostr);
}
template<class T>
void CellPropertyT<T>::deserialize(std::istream& _istr) {
PropertyPtr<OpenVolumeMeshPropertyT<T>, CellPropHandle>::get()->deserialize(_istr);
}
template<class T>
MeshPropertyT<T>::MeshPropertyT(const std::string& _name, ResourceManager& _resMan, MeshPropHandle _handle, const T _def) :
PropertyPtr<OpenVolumeMeshPropertyT<T>, MeshPropHandle>(new OpenVolumeMeshPropertyT<T>(_name, _def), _resMan, _handle) {
}
template<class T>
MeshPropertyT<T>::MeshPropertyT(OpenVolumeMeshPropertyT<T> *_prop, ResourceManager &_resMan, MeshPropHandle _handle) :
PropertyPtr<OpenVolumeMeshPropertyT<T>, MeshPropHandle>(_prop, _resMan, _handle)
{
}
template<class T>
BaseProperty *MeshPropertyT<T>::clone(ResourceManager &_resMan, const OpenVolumeMeshHandle _handle) const
{
auto prop_clone = ptr::shared_ptr<OpenVolumeMeshPropertyT<T>>::get()->clone();
return new MeshPropertyT<T>(prop_clone, _resMan, MeshPropHandle(_handle.idx()));
}
template<class T>
void MeshPropertyT<T>::serialize(std::ostream& _ostr) const {
PropertyPtr<OpenVolumeMeshPropertyT<T>, MeshPropHandle>::get()->serialize(_ostr);
}
template<class T>
void MeshPropertyT<T>::deserialize(std::istream& _istr) {
PropertyPtr<OpenVolumeMeshPropertyT<T>, MeshPropHandle>::get()->deserialize(_istr);
}
template <class T>
template<typename T>
const std::string typeName() {
throw std::runtime_error("Serialization is not supported for these data types!");
}
......
......@@ -32,59 +32,30 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* $LastChangedBy$ *
* *
\*===========================================================================*/
#ifndef PROPERTYHANDLES_HH_
#define PROPERTYHANDLES_HH_
#pragma once
#include "OpenVolumeMeshHandle.hh"
#include "Entities.hh"
namespace OpenVolumeMesh {
// Defines for property handles
class VertexPropHandle : public OpenVolumeMeshHandle {
public:
using OpenVolumeMeshHandle::OpenVolumeMeshHandle;
using EntityHandleT = VertexHandle;
};
class EdgePropHandle : public OpenVolumeMeshHandle {
public:
using OpenVolumeMeshHandle::OpenVolumeMeshHandle;
using EntityHandleT = EdgeHandle;
};
class HalfEdgePropHandle : public OpenVolumeMeshHandle {
public:
using OpenVolumeMeshHandle::OpenVolumeMeshHandle;
using EntityHandleT = HalfEdgeHandle;
};
class FacePropHandle : public OpenVolumeMeshHandle {
public:
using OpenVolumeMeshHandle::OpenVolumeMeshHandle;
using EntityHandleT = FaceHandle;
};
class HalfFacePropHandle : public OpenVolumeMeshHandle {
public:
using OpenVolumeMeshHandle::OpenVolumeMeshHandle;
using EntityHandleT = HalfFaceHandle;
};
class CellPropHandle : public OpenVolumeMeshHandle {
public:
using OpenVolumeMeshHandle::OpenVolumeMeshHandle;
using EntityHandleT = CellHandle;
};
class MeshPropHandle : public OpenVolumeMeshHandle
template<typename EntityTag,
typename = typename std::enable_if<is_entity<EntityTag>::value>::type>
class PropHandleT : public OpenVolumeMeshHandle
{
public:
using Entity = EntityTag;
using OpenVolumeMeshHandle::OpenVolumeMeshHandle;
using EntityHandleT = OpenVolumeMeshHandle;
};
using VertexPropHandle = PropHandleT<Entity::Vertex>;
using EdgePropHandle = PropHandleT<Entity::Edge>;
using HalfEdgePropHandle = PropHandleT<Entity::HalfEdge>;
using FacePropHandle = PropHandleT<Entity::Face>;
using HalfFacePropHandle = PropHandleT<Entity::HalfFace>;
using CellPropHandle = PropHandleT<Entity::Cell>;
using MeshPropHandle = PropHandleT<Entity::Mesh>;
} // Namespace OpenVolumeMesh
#endif /* PROPERTYHANDLES_HH_ */
......@@ -32,16 +32,8 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* $LastChangedBy$ *
* *
\*===========================================================================*/
#ifndef PROPERTYPTR_HH_
#define PROPERTYPTR_HH_
#pragma once
#include <string>
......@@ -74,7 +66,7 @@ public:
typedef typename PropT::reference reference;
typedef typename PropT::const_reference const_reference;
typedef typename HandleT::EntityHandleT EntityHandleT;
typedef OpenVolumeMesh::HandleT<typename HandleT::Entity> EntityHandleT;
/// Constructor
PropertyPtr(PropT* _ptr, ResourceManager& _resMan, HandleT _handle);
......@@ -129,4 +121,3 @@ protected:
#include "PropertyPtrT_impl.hh"
#endif
#endif /* PROPERTYPTR_HH_ */
......@@ -32,14 +32,6 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* $LastChangedBy$ *
* *
\*===========================================================================*/
#define PROPERTYPTRT_CC
#include "PropertyPtr.hh"
......
......@@ -32,16 +32,7 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* $LastChangedBy$ *
* *
\*===========================================================================*/
#ifndef RESOURCEMANAGER_HH_
#define RESOURCEMANAGER_HH_
#pragma once
#ifndef NDEBUG
#include <iostream>
......@@ -51,27 +42,12 @@
#include "OpenVolumeMeshProperty.hh"
#include "PropertyHandles.hh"
#include "ForwardDeclarations.hh"
namespace OpenVolumeMesh {
// Forward declarations
class BaseProperty;
template <class T>
class VertexPropertyT;
template <class T>
class EdgePropertyT;
template <class T>
class HalfEdgePropertyT;
template <class T>
class FacePropertyT;
template <class T>
class HalfFacePropertyT;
template <class T>
class CellPropertyT;
template <class T>
class MeshPropertyT;
template <class PropT, class HandleT>
class PropertyPtr;
class ResourceManager {
public:
......@@ -364,4 +340,3 @@ private:
#include "ResourceManagerT_impl.hh"
#endif
#endif /* RESOURCEMANAGER_HH_ */
......@@ -2021,3 +2021,19 @@ TEST_F(PolyhedralMeshBase, DeferredFastDelete) {
testDeferredDelete(mesh_);
}
TEST_F(PolyhedralMeshBase, HandleDefaultConstructors) {
VertexHandle vh;
ASSERT_FALSE(vh.is_valid());
EdgeHandle eh;
ASSERT_FALSE(eh.is_valid());
HalfEdgeHandle heh;
ASSERT_FALSE(heh.is_valid());
FaceHandle fh;
ASSERT_FALSE(fh.is_valid());
HalfFaceHandle hfh;
ASSERT_FALSE(hfh.is_valid());
CellHandle ch;
ASSERT_FALSE(ch.is_valid());
}