47#include <OpenVolumeMesh/Config/Export.hh>
48#include <OpenVolumeMesh/Core/Entities.hh>
49#include <OpenVolumeMesh/Core/EntityUtils.hh>
50#include <OpenVolumeMesh/Core/ForwardDeclarations.hh>
51#include <OpenVolumeMesh/Core/detail/Tracking.hh>
52#include <OpenVolumeMesh/Core/Properties/PropertyIterator.hh>
53#include <OpenVolumeMesh/Core/Properties/PropertyStorageBase.hh>
54#include <OpenVolumeMesh/Core/Properties/PropertyPtr.hh>
57namespace OpenVolumeMesh {
61 using Properties = std::set<PropertyStorageBase*>;
73 using PersistentProperties = std::set<std::shared_ptr<PropertyStorageBase>>;
75 template <
class T,
typename EntityTag>
78 template<
class EntityTag>
79 void resize_props(
size_t _n);
81 template<
class EntityTag>
82 void reserve_props(
size_t _n);
84 template<
class Handle>
85 void entity_deleted(Handle);
87 template<
typename T,
typename EntityTag>
88 std::optional<PropertyPtr<T, EntityTag>> internal_find_property(
const std::string& _name)
const;
90 template<
typename T,
typename EntityTag>
101 template<
typename EntityTag>
110 void resize_vprops(
size_t _nv);
113 void resize_eprops(
size_t _ne);
116 void resize_fprops(
size_t _nf);
119 void resize_cprops(
size_t _nc);
121 void reserve_vprops(
size_t n);
122 void reserve_eprops(
size_t n);
123 void reserve_fprops(
size_t n);
124 void reserve_cprops(
size_t n);
131 template <
typename Handle>
132 void swap_property_elements(Handle _idx_a, Handle _idx_b);
134 template <
typename Handle>
135 void copy_property_elements(Handle _idx_a, Handle _idx_b);
139 void clear_all_props();
141 template<
typename EntityTag>
void clear_props();
144 template<
typename EntityTag>
162 template<
typename EntityTag>
size_t n_props()
const;
165 template<
typename EntityTag>
size_t n_persistent_props()
const;
170 template<
typename T,
typename EntityTag>
175 template<
typename T,
typename EntityTag>
176 [[deprecated(
"Use create_{shared,persistent}_property instead")]]
177 std::optional<PropertyPtr<T, EntityTag>>
create_property(std::string _name = std::string(),
const T _def = T());
181 template<
typename T,
typename EntityTag>
182 std::optional<PropertyPtr<T, EntityTag>> create_shared_property(std::string _name,
const T _def = T());
186 template<
typename T,
typename EntityTag>
187 std::optional<PropertyPtr<T, EntityTag>> create_persistent_property(std::string _name,
const T _def = T());
191 template<
typename T,
typename EntityTag>
196 template<
typename T,
typename EntityTag>
197 std::optional<PropertyPtr<T, EntityTag>> get_property(
const std::string& _name);
201 template<
typename T,
typename EntityTag>
202 std::optional<const PropertyPtr<T, EntityTag>> get_property(
const std::string& _name)
const;
204 template <
typename T,
typename EntityTag>
205 bool property_exists(
const std::string& _name)
const
207 return internal_find_property<T, EntityTag>(_name).has_value();
211 template<
typename T,
class EntityTag>
212 void set_persistent(PropertyPtr<T, EntityTag>& _prop,
bool _enable =
true);
214 template<
typename T,
class EntityTag>
215 void set_shared(PropertyPtr<T, EntityTag>& _prop,
bool _enable =
true);
217 template<
typename EntityTag>
218 PropertyIterator<PersistentProperties::const_iterator>
219 persistent_props_begin()
const
220 {
return persistent_props_.get<EntityTag>().cbegin();}
222 template<
typename EntityTag>
223 PropertyIterator<PersistentProperties::const_iterator>
224 persistent_props_end()
const
225 {
return persistent_props_.get<EntityTag>().cend();}
231 inline void clear_edge_props() { clear_props<Entity::Edge>();}
232 inline void clear_halfedge_props() { clear_props<Entity::HalfEdge>();}
233 inline void clear_face_props() { clear_props<Entity::Face>();}
234 inline void clear_halfface_props() { clear_props<Entity::HalfFace>();}
235 inline void clear_cell_props() { clear_props<Entity::Cell>();}
236 inline void clear_mesh_props() { clear_props<Entity::Mesh>();}
239 template<
class T> VertexPropertyT<T> request_vertex_property (
const std::string& _name = std::string(),
const T _def = T());
240 template<
class T> EdgePropertyT<T> request_edge_property (
const std::string& _name = std::string(),
const T _def = T());
241 template<
class T> HalfEdgePropertyT<T> request_halfedge_property(
const std::string& _name = std::string(),
const T _def = T());
242 template<
class T> FacePropertyT<T> request_face_property (
const std::string& _name = std::string(),
const T _def = T());
243 template<
class T> HalfFacePropertyT<T> request_halfface_property(
const std::string& _name = std::string(),
const T _def = T());
244 template<
class T> CellPropertyT<T> request_cell_property (
const std::string& _name = std::string(),
const T _def = T());
245 template<
class T> MeshPropertyT<T> request_mesh_property (
const std::string& _name = std::string(),
const T _def = T());
252 size_t n_vertex_props()
const {
return n_props<Entity::Vertex>();}
253 auto vertex_props_begin()
const {
return persistent_props_begin<Entity::Vertex>();}
254 auto vertex_props_end()
const {
return persistent_props_end <Entity::Vertex>();}
260 {
return create_shared_property<T, Entity::Vertex>(std::move(_name), std::move(_def)); }
266 {
return create_persistent_property<T, Entity::Vertex>(std::move(_name), std::move(_def)); }
272 {
return create_private_property<T, Entity::Vertex>(std::move(_name), std::move(_def)); }
278 return get_property<T, Entity::Vertex>(_name);
285 return get_property<T, Entity::Vertex>(_name);
289 bool vertex_property_exists(
const std::string& _name)
const {
290 return property_exists<T, Entity::Vertex>(_name);
299 size_t n_edge_props()
const {
return n_props<Entity::Edge>();}
300 auto edge_props_begin()
const {
return persistent_props_begin<Entity::Edge>();}
301 auto edge_props_end()
const {
return persistent_props_end <Entity::Edge>();}
307 {
return create_shared_property<T, Entity::Edge>(std::move(_name), std::move(_def)); }
313 {
return create_persistent_property<T, Entity::Edge>(std::move(_name), std::move(_def)); }
319 {
return create_private_property<T, Entity::Edge>(std::move(_name), std::move(_def)); }
325 return get_property<T, Entity::Edge>(_name);
332 return get_property<T, Entity::Edge>(_name);
336 bool edge_property_exists(
const std::string& _name)
const {
337 return property_exists<T, Entity::Edge>(_name);
346 size_t n_halfedge_props()
const {
return n_props<Entity::HalfEdge>();}
347 auto halfedge_props_begin()
const {
return persistent_props_begin<Entity::HalfEdge>();}
348 auto halfedge_props_end()
const {
return persistent_props_end <Entity::HalfEdge>();}
354 {
return create_shared_property<T, Entity::HalfEdge>(std::move(_name), std::move(_def)); }
360 {
return create_persistent_property<T, Entity::HalfEdge>(std::move(_name), std::move(_def)); }
366 {
return create_private_property<T, Entity::HalfEdge>(std::move(_name), std::move(_def)); }
372 return get_property<T, Entity::HalfEdge>(_name);
379 return get_property<T, Entity::HalfEdge>(_name);
383 bool halfedge_property_exists(
const std::string& _name)
const {
384 return property_exists<T, Entity::HalfEdge>(_name);
393 size_t n_face_props()
const {
return n_props<Entity::Face>();}
394 auto face_props_begin()
const {
return persistent_props_begin<Entity::Face>();}
395 auto face_props_end()
const {
return persistent_props_end <Entity::Face>();}
401 {
return create_shared_property<T, Entity::Face>(std::move(_name), std::move(_def)); }
407 {
return create_persistent_property<T, Entity::Face>(std::move(_name), std::move(_def)); }
413 {
return create_private_property<T, Entity::Face>(std::move(_name), std::move(_def)); }
419 return get_property<T, Entity::Face>(_name);
426 return get_property<T, Entity::Face>(_name);
430 bool face_property_exists(
const std::string& _name)
const {
431 return property_exists<T, Entity::Face>(_name);
440 size_t n_halfface_props()
const {
return n_props<Entity::HalfFace>();}
441 auto halfface_props_begin()
const {
return persistent_props_begin<Entity::HalfFace>();}
442 auto halfface_props_end()
const {
return persistent_props_end <Entity::HalfFace>();}
448 {
return create_shared_property<T, Entity::HalfFace>(std::move(_name), std::move(_def)); }
454 {
return create_persistent_property<T, Entity::HalfFace>(std::move(_name), std::move(_def)); }
460 {
return create_private_property<T, Entity::HalfFace>(std::move(_name), std::move(_def)); }
466 return get_property<T, Entity::HalfFace>(_name);
473 return get_property<T, Entity::HalfFace>(_name);
477 bool halfface_property_exists(
const std::string& _name)
const {
478 return property_exists<T, Entity::HalfFace>(_name);
487 size_t n_cell_props()
const {
return n_props<Entity::Cell>();}
488 auto cell_props_begin()
const {
return persistent_props_begin<Entity::Cell>();}
489 auto cell_props_end()
const {
return persistent_props_end <Entity::Cell>();}
495 {
return create_shared_property<T, Entity::Cell>(std::move(_name), std::move(_def)); }
501 {
return create_persistent_property<T, Entity::Cell>(std::move(_name), std::move(_def)); }
507 {
return create_private_property<T, Entity::Cell>(std::move(_name), std::move(_def)); }
513 return get_property<T, Entity::Cell>(_name);
520 return get_property<T, Entity::Cell>(_name);
524 bool cell_property_exists(
const std::string& _name)
const {
525 return property_exists<T, Entity::Cell>(_name);
534#include <OpenVolumeMesh/Core/ResourceManagerT_impl.hh>
std::optional< const VertexPropertyPtr< T > > get_vertex_property(const std::string &_name) const
HalfEdgePropertyPtr< T > create_private_halfedge_property(std::string _name={}, const T _def=T()) const
std::optional< HalfEdgePropertyPtr< T > > create_shared_halfedge_property(std::string _name, const T _def=T())
std::optional< EdgePropertyPtr< T > > create_persistent_edge_property(std::string _name, const T _def=T())
std::optional< FacePropertyPtr< T > > create_shared_face_property(std::string _name, const T _def=T())
std::optional< HalfFacePropertyPtr< T > > get_halfface_property(const std::string &_name)
VertexPropertyPtr< T > create_private_vertex_property(std::string _name={}, const T _def=T()) const
FacePropertyPtr< T > create_private_face_property(std::string _name={}, const T _def=T()) const
std::optional< HalfFacePropertyPtr< T > > create_shared_halfface_property(std::string _name, const T _def=T())
std::optional< FacePropertyPtr< T > > create_persistent_face_property(std::string _name, const T _def=T())
size_t n() const
Get number of entities of given kind in mesh.
std::optional< CellPropertyPtr< T > > get_cell_property(const std::string &_name)
std::optional< HalfEdgePropertyPtr< T > > create_persistent_halfedge_property(std::string _name, const T _def=T())
virtual size_t n_edges() const =0
Get number of edges in mesh.
std::optional< PropertyPtr< T, EntityTag > > create_property(std::string _name=std::string(), const T _def=T())
std::optional< FacePropertyPtr< T > > get_face_property(const std::string &_name)
std::optional< VertexPropertyPtr< T > > get_vertex_property(const std::string &_name)
std::optional< EdgePropertyPtr< T > > get_edge_property(const std::string &_name)
virtual size_t n_faces() const =0
Get number of faces in mesh.
virtual size_t n_halffaces() const =0
Get number of halffaces in mesh.
std::optional< CellPropertyPtr< T > > create_shared_cell_property(std::string _name, const T _def=T())
std::optional< VertexPropertyPtr< T > > create_persistent_vertex_property(std::string _name, const T _def=T())
std::optional< HalfEdgePropertyPtr< T > > get_halfedge_property(const std::string &_name)
EdgePropertyPtr< T > create_private_edge_property(std::string _name={}, const T _def=T()) const
virtual size_t n_halfedges() const =0
Get number of halfedges in mesh.
std::optional< VertexPropertyPtr< T > > create_shared_vertex_property(std::string _name, const T _def=T())
std::optional< HalfFacePropertyPtr< T > > create_persistent_halfface_property(std::string _name, const T _def=T())
void clear_vertex_props()
convenience functions:
std::optional< EdgePropertyPtr< T > > create_shared_edge_property(std::string _name, const T _def=T())
virtual size_t n_cells() const =0
Get number of cells in mesh.
std::optional< const EdgePropertyPtr< T > > get_edge_property(const std::string &_name) const
std::optional< const HalfEdgePropertyPtr< T > > get_halfedge_property(const std::string &_name) const
HalfFacePropertyPtr< T > create_private_halfface_property(std::string _name={}, const T _def=T()) const
std::optional< const HalfFacePropertyPtr< T > > get_halfface_property(const std::string &_name) const
std::optional< CellPropertyPtr< T > > create_persistent_cell_property(std::string _name, const T _def=T())
std::optional< const FacePropertyPtr< T > > get_face_property(const std::string &_name) const
virtual size_t n_vertices() const =0
Get number of vertices in mesh.
std::optional< const CellPropertyPtr< T > > get_cell_property(const std::string &_name) const
CellPropertyPtr< T > create_private_cell_property(std::string _name={}, const T _def=T()) const