42 #include <type_traits> 44 #include "../System/Compiler.hh" 45 #include "OpenVolumeMesh/Config/Export.hh" 46 #include "OpenVolumeMeshProperty.hh" 47 #include "PropertyHandles.hh" 48 #include "TypeName.hh" 49 #include "ForwardDeclarations.hh" 69 template <
class PropT,
class HandleT>
friend class PropertyPtr;
72 void resize_vprops(
size_t _nv);
75 void resize_eprops(
size_t _ne);
78 void resize_fprops(
size_t _nf);
81 void resize_cprops(
size_t _nc);
105 template <
typename PropIterator,
typename Handle>
106 void swap_property_elements(PropIterator _begin, PropIterator _end, Handle _h1, Handle _h2)
108 PropIterator p_iter = _begin;
109 for (; p_iter != _end; ++p_iter)
110 (*p_iter)->swap_elements(_h1.uidx(), _h2.uidx());
116 void clear_vertex_props() { clearVec(vertex_props_); }
118 void clear_edge_props() { clearVec(edge_props_); }
120 void clear_halfedge_props() { clearVec(halfedge_props_); }
122 void clear_face_props() { clearVec(face_props_); }
124 void clear_halfface_props() { clearVec(halfface_props_); }
126 void clear_cell_props() { clearVec(cell_props_); }
128 void clear_mesh_props() { clearVec(mesh_props_); }
131 virtual size_t n_vertices()
const = 0;
133 virtual size_t n_edges()
const = 0;
135 virtual size_t n_halfedges()
const = 0;
137 virtual size_t n_faces()
const = 0;
139 virtual size_t n_halffaces()
const = 0;
141 virtual size_t n_cells()
const = 0;
146 template<
typename T,
typename EntityTag>
152 template<
typename T,
typename EntityTag>
153 std::optional<PropertyTT<T, EntityTag>> create_property(
const std::string& _name = std::string(),
const T _def = T());
157 template<
typename T,
typename EntityTag>
158 std::optional<PropertyTT<T, EntityTag>> get_property(
const std::string& _name = std::string());
161 template<
class T>
VertexPropertyT<T> request_vertex_property(
const std::string& _name = std::string(),
const T _def = T());
163 template<
class T>
EdgePropertyT<T> request_edge_property(
const std::string& _name = std::string(),
const T _def = T());
165 template<
class T>
HalfEdgePropertyT<T> request_halfedge_property(
const std::string& _name = std::string(),
const T _def = T());
167 template<
class T>
FacePropertyT<T> request_face_property(
const std::string& _name = std::string(),
const T _def = T());
169 template<
class T>
HalfFacePropertyT<T> request_halfface_property(
const std::string& _name = std::string(),
const T _def = T());
171 template<
class T>
CellPropertyT<T> request_cell_property(
const std::string& _name = std::string(),
const T _def = T());
173 template<
class T>
MeshPropertyT<T> request_mesh_property(
const std::string& _name = std::string(),
const T _def = T());
194 size_t n_vertex_props()
const {
return vertex_props_.size(); }
196 size_t n_edge_props()
const {
return edge_props_.size(); }
198 size_t n_halfedge_props()
const {
return halfedge_props_.size(); }
200 size_t n_face_props()
const {
return face_props_.size(); }
202 size_t n_halfface_props()
const {
return halfface_props_.size(); }
204 size_t n_cell_props()
const {
return cell_props_.size(); }
206 size_t n_mesh_props()
const {
return mesh_props_.size(); }
208 template<
typename T,
class EntityTag>
211 typedef std::vector<BaseProperty*> Properties;
213 Properties::const_iterator vertex_props_begin()
const {
return vertex_props_.begin(); }
215 Properties::const_iterator vertex_props_end()
const {
return vertex_props_.end(); }
217 Properties::const_iterator edge_props_begin()
const {
return edge_props_.begin(); }
219 Properties::const_iterator edge_props_end()
const {
return edge_props_.end(); }
221 Properties::const_iterator halfedge_props_begin()
const {
return halfedge_props_.begin(); }
223 Properties::const_iterator halfedge_props_end()
const {
return halfedge_props_.end(); }
225 Properties::const_iterator face_props_begin()
const {
return face_props_.begin(); }
227 Properties::const_iterator face_props_end()
const {
return face_props_.end(); }
229 Properties::const_iterator halfface_props_begin()
const {
return halfface_props_.begin(); }
231 Properties::const_iterator halfface_props_end()
const {
return halfface_props_.end(); }
233 Properties::const_iterator cell_props_begin()
const {
return cell_props_.begin(); }
235 Properties::const_iterator cell_props_end()
const {
return cell_props_.end(); }
237 Properties::const_iterator mesh_props_begin()
const {
return mesh_props_.begin(); }
239 Properties::const_iterator mesh_props_end()
const {
return mesh_props_.end(); }
243 template <
class FullPropT,
class PropIterT>
244 bool property_exists(
const PropIterT& _begin,
const PropIterT& _end,
const std::string& _name)
const 246 auto type_name = get_type_name<typename FullPropT::value_type>();
250 std::cerr <<
"property_exists(): Checking for the existence of anonymous properties is" << std::endl;
251 std::cerr <<
"ambiguous!" << std::endl;
256 PropIterT it = _begin;
257 for(; it != _end; ++it)
259 if((*it)->name() == _name
260 && (*it)->internal_type_name() == type_name)
270 template <
class PropT>
271 bool vertex_property_exists(
const std::string& _name)
const {
272 return property_exists<VertexPropertyT<PropT> >(vertex_props_begin(), vertex_props_end(), _name);
275 template <
class PropT>
276 bool edge_property_exists(
const std::string& _name)
const {
277 return property_exists<EdgePropertyT<PropT> >(edge_props_begin(), edge_props_end(), _name);
280 template <
class PropT>
281 bool halfedge_property_exists(
const std::string& _name)
const {
282 return property_exists<HalfEdgePropertyT<PropT> >(halfedge_props_begin(), halfedge_props_end(), _name);
285 template <
class PropT>
286 bool face_property_exists(
const std::string& _name)
const {
287 return property_exists<FacePropertyT<PropT> >(face_props_begin(), face_props_end(), _name);
290 template <
class PropT>
291 bool halfface_property_exists(
const std::string& _name)
const {
292 return property_exists<HalfFacePropertyT<PropT> >(halfface_props_begin(), halfface_props_end(), _name);
295 template <
class PropT>
296 bool cell_property_exists(
const std::string& _name)
const {
297 return property_exists<CellPropertyT<PropT> >(cell_props_begin(), cell_props_end(), _name);
300 template <
class PropT>
301 bool mesh_property_exists(
const std::string& _name)
const {
302 return property_exists<MeshPropertyT<PropT> >(mesh_props_begin(), mesh_props_end(), _name);
307 void delete_multiple_vertex_props(
const std::vector<bool>& _tags);
309 void delete_multiple_edge_props(
const std::vector<bool>& _tags);
311 void delete_multiple_face_props(
const std::vector<bool>& _tags);
313 void delete_multiple_cell_props(
const std::vector<bool>& _tags);
317 template<
class StdVecT>
318 void resize_props(StdVecT& _vec,
size_t _n);
320 template<
class StdVecT>
323 template<
class StdVecT>
324 void remove_property(StdVecT& _vec,
size_t _idx);
326 template<
typename T,
typename EntityTag>
329 template<
typename T,
typename EntityTag>
332 template<
class StdVecT>
333 void clearVec(StdVecT& _vec);
335 template<
class StdVecT>
336 void updatePropHandles(StdVecT& _vec);
339 void assignProperties(
typename std::conditional<Move, Properties&, const Properties&>::type src,
342 void assignAllPropertiesFrom(
typename std::conditional<Move, ResourceManager*, const ResourceManager*>::type src);
344 Properties vertex_props_;
346 Properties edge_props_;
348 Properties halfedge_props_;
350 Properties face_props_;
352 Properties halfface_props_;
354 Properties cell_props_;
356 Properties mesh_props_;
358 template<
typename Entity>
359 Properties &entity_props();
361 template<
typename Entity>
367 #if defined(INCLUDE_TEMPLATES) && !defined(RESOURCEMANAGERT_CC) 368 #include "ResourceManagerT_impl.hh"