43 #ifndef RESOURCEMANAGER_HH_ 44 #define RESOURCEMANAGER_HH_ 52 #include "OpenVolumeMeshProperty.hh" 53 #include "PropertyHandles.hh" 60 class VertexPropertyT;
64 class HalfEdgePropertyT;
68 class HalfFacePropertyT;
73 template <
class PropT,
class HandleT>
81 template <
class PropT,
class HandleT>
friend class PropertyPtr;
117 template <
typename PropIterator,
typename Handle>
118 void swap_property_elements(PropIterator _begin, PropIterator _end, Handle _h1, Handle _h2)
120 PropIterator p_iter = _begin;
121 for (; p_iter != _end; ++p_iter)
122 (*p_iter)->swap_elements(_h1, _h2);
128 void clear_vertex_props() { clearVec(vertex_props_); }
130 void clear_edge_props() { clearVec(edge_props_); }
132 void clear_halfedge_props() { clearVec(halfedge_props_); }
134 void clear_face_props() { clearVec(face_props_); }
136 void clear_halfface_props() { clearVec(halfface_props_); }
138 void clear_cell_props() { clearVec(cell_props_); }
140 void clear_mesh_props() { clearVec(mesh_props_); }
145 virtual size_t n_edges()
const = 0;
149 virtual size_t n_faces()
const = 0;
153 virtual size_t n_cells()
const = 0;
155 template<
class T>
VertexPropertyT<T> request_vertex_property(
const std::string& _name = std::string(),
const T _def = T());
157 template<
class T>
EdgePropertyT<T> request_edge_property(
const std::string& _name = std::string(),
const T _def = T());
159 template<
class T>
HalfEdgePropertyT<T> request_halfedge_property(
const std::string& _name = std::string(),
const T _def = T());
161 template<
class T>
FacePropertyT<T> request_face_property(
const std::string& _name = std::string(),
const T _def = T());
163 template<
class T>
HalfFacePropertyT<T> request_halfface_property(
const std::string& _name = std::string(),
const T _def = T());
165 template<
class T>
CellPropertyT<T> request_cell_property(
const std::string& _name = std::string(),
const T _def = T());
167 template<
class T>
MeshPropertyT<T> request_mesh_property(
const std::string& _name = std::string(),
const T _def = T());
187 size_t n_vertex_props()
const {
return vertex_props_.size(); }
189 size_t n_edge_props()
const {
return edge_props_.size(); }
191 size_t n_halfedge_props()
const {
return halfedge_props_.size(); }
193 size_t n_face_props()
const {
return face_props_.size(); }
195 size_t n_halfface_props()
const {
return halfface_props_.size(); }
197 size_t n_cell_props()
const {
return cell_props_.size(); }
199 size_t n_mesh_props()
const {
return mesh_props_.size(); }
203 template<
class T>
void set_persistent(
EdgePropertyT<T>& _prop,
bool _flag =
true);
207 template<
class T>
void set_persistent(
FacePropertyT<T>& _prop,
bool _flag =
true);
211 template<
class T>
void set_persistent(
CellPropertyT<T>& _prop,
bool _flag =
true);
213 template<
class T>
void set_persistent(
MeshPropertyT<T>& _prop,
bool _flag =
true);
215 typedef std::vector<BaseProperty*> Properties;
217 Properties::const_iterator vertex_props_begin()
const {
return vertex_props_.begin(); }
219 Properties::const_iterator vertex_props_end()
const {
return vertex_props_.end(); }
221 Properties::const_iterator edge_props_begin()
const {
return edge_props_.begin(); }
223 Properties::const_iterator edge_props_end()
const {
return edge_props_.end(); }
225 Properties::const_iterator halfedge_props_begin()
const {
return halfedge_props_.begin(); }
227 Properties::const_iterator halfedge_props_end()
const {
return halfedge_props_.end(); }
229 Properties::const_iterator face_props_begin()
const {
return face_props_.begin(); }
231 Properties::const_iterator face_props_end()
const {
return face_props_.end(); }
233 Properties::const_iterator halfface_props_begin()
const {
return halfface_props_.begin(); }
235 Properties::const_iterator halfface_props_end()
const {
return halfface_props_.end(); }
237 Properties::const_iterator cell_props_begin()
const {
return cell_props_.begin(); }
239 Properties::const_iterator cell_props_end()
const {
return cell_props_.end(); }
241 Properties::const_iterator mesh_props_begin()
const {
return mesh_props_.begin(); }
243 Properties::const_iterator mesh_props_end()
const {
return mesh_props_.end(); }
247 template <
class FullPropT,
class PropIterT>
248 bool property_exists(
const PropIterT& _begin,
const PropIterT& _end,
const std::string& _name)
const {
252 std::cerr <<
"property_exists(): Checking for the existence of anonymous properties is" << std::endl;
253 std::cerr <<
"ambiguous!" << std::endl;
258 PropIterT it = _begin;
259 for(; it != _end; ++it) {
260 if((*it)->name() == _name &&
dynamic_cast<FullPropT*
>(*it) != NULL) {
269 template <
class PropT>
270 bool vertex_property_exists(
const std::string& _name)
const {
271 return property_exists<VertexPropertyT<PropT> >(vertex_props_begin(), vertex_props_end(), _name);
274 template <
class PropT>
275 bool edge_property_exists(
const std::string& _name)
const {
276 return property_exists<EdgePropertyT<PropT> >(edge_props_begin(), edge_props_end(), _name);
279 template <
class PropT>
280 bool halfedge_property_exists(
const std::string& _name)
const {
281 return property_exists<HalfEdgePropertyT<PropT> >(halfedge_props_begin(), halfedge_props_end(), _name);
284 template <
class PropT>
285 bool face_property_exists(
const std::string& _name)
const {
286 return property_exists<FacePropertyT<PropT> >(face_props_begin(), face_props_end(), _name);
289 template <
class PropT>
290 bool halfface_property_exists(
const std::string& _name)
const {
291 return property_exists<HalfFacePropertyT<PropT> >(halfface_props_begin(), halfface_props_end(), _name);
294 template <
class PropT>
295 bool cell_property_exists(
const std::string& _name)
const {
296 return property_exists<CellPropertyT<PropT> >(cell_props_begin(), cell_props_end(), _name);
299 template <
class PropT>
300 bool mesh_property_exists(
const std::string& _name)
const {
301 return property_exists<MeshPropertyT<PropT> >(mesh_props_begin(), mesh_props_end(), _name);
306 void delete_multiple_vertex_props(
const std::vector<bool>& _tags);
308 void delete_multiple_edge_props(
const std::vector<bool>& _tags);
310 void delete_multiple_face_props(
const std::vector<bool>& _tags);
312 void delete_multiple_cell_props(
const std::vector<bool>& _tags);
316 template<
class StdVecT>
317 void resize_props(StdVecT& _vec,
size_t _n);
319 template<
class StdVecT>
322 template<
class StdVecT>
323 void remove_property(StdVecT& _vec,
size_t _idx);
325 template<
class StdVecT,
class PropT,
class HandleT,
class T>
326 PropT request_property(StdVecT& _vec,
const std::string& _name,
size_t _size,
const T _def = T());
328 template<
class PropT>
329 void set_persistentT(PropT& _prop,
bool _flag);
331 template<
class StdVecT>
332 void clearVec(StdVecT& _vec);
334 Properties vertex_props_;
336 Properties edge_props_;
338 Properties halfedge_props_;
340 Properties face_props_;
342 Properties halfface_props_;
344 Properties cell_props_;
346 Properties mesh_props_;
351 #if defined(INCLUDE_TEMPLATES) && !defined(RESOURCEMANAGERT_CC) 352 #include "ResourceManagerT.cc"
virtual size_t n_halffaces() const =0
Get number of halffaces in mesh.
Property classes for the different entity types.
void resize_cprops(size_t _nc)
Change size of stored cell properties.
virtual size_t n_faces() const =0
Get number of faces in mesh.
void resize_vprops(size_t _nv)
Change size of stored vertex properties.
virtual size_t n_cells() const =0
Get number of cells in mesh.
virtual size_t n_edges() const =0
Get number of edges in mesh.
virtual size_t n_vertices() const =0
Get number of vertices in mesh.
void resize_eprops(size_t _ne)
Change size of stored edge properties.
void resize_fprops(size_t _nf)
Change size of stored face properties.
virtual size_t n_halfedges() const =0
Get number of halfedges in mesh.