43 #ifndef RESOURCEMANAGER_HH_
44 #define RESOURCEMANAGER_HH_
49 #include "OpenVolumeMeshProperty.hh"
50 #include "PropertyHandles.hh"
52 namespace OpenVolumeMesh {
57 class VertexPropertyT;
61 class HalfEdgePropertyT;
65 class HalfFacePropertyT;
70 template <
class PropT,
class HandleT>
78 template <
class PropT,
class HandleT>
friend class PropertyPtr;
104 void clear_vertex_props() { clearVec(vertex_props_); }
106 void clear_edge_props() { clearVec(edge_props_); }
108 void clear_halfedge_props() { clearVec(halfedge_props_); }
110 void clear_face_props() { clearVec(face_props_); }
112 void clear_halfface_props() { clearVec(halfface_props_); }
114 void clear_cell_props() { clearVec(cell_props_); }
116 void clear_mesh_props() { clearVec(mesh_props_); }
121 virtual unsigned int n_edges()
const = 0;
125 virtual unsigned int n_faces()
const = 0;
129 virtual unsigned int n_cells()
const = 0;
131 template<
class T>
VertexPropertyT<T> request_vertex_property(
const std::string& _name = std::string(),
const T _def = T());
133 template<
class T>
EdgePropertyT<T> request_edge_property(
const std::string& _name = std::string(),
const T _def = T());
135 template<
class T>
HalfEdgePropertyT<T> request_halfedge_property(
const std::string& _name = std::string(),
const T _def = T());
137 template<
class T>
FacePropertyT<T> request_face_property(
const std::string& _name = std::string(),
const T _def = T());
139 template<
class T>
HalfFacePropertyT<T> request_halfface_property(
const std::string& _name = std::string(),
const T _def = T());
141 template<
class T>
CellPropertyT<T> request_cell_property(
const std::string& _name = std::string(),
const T _def = T());
143 template<
class T>
MeshPropertyT<T> request_mesh_property(
const std::string& _name = std::string(),
const T _def = T());
163 unsigned int n_vertex_props()
const {
return vertex_props_.size(); }
165 unsigned int n_edge_props()
const {
return edge_props_.size(); }
167 unsigned int n_halfedge_props()
const {
return halfedge_props_.size(); }
169 unsigned int n_face_props()
const {
return face_props_.size(); }
171 unsigned int n_halfface_props()
const {
return halfface_props_.size(); }
173 unsigned int n_cell_props()
const {
return cell_props_.size(); }
175 unsigned int n_mesh_props()
const {
return mesh_props_.size(); }
179 template<
class T>
void set_persistent(
EdgePropertyT<T>& _prop,
bool _flag =
true);
183 template<
class T>
void set_persistent(
FacePropertyT<T>& _prop,
bool _flag =
true);
187 template<
class T>
void set_persistent(
CellPropertyT<T>& _prop,
bool _flag =
true);
189 template<
class T>
void set_persistent(
MeshPropertyT<T>& _prop,
bool _flag =
true);
191 typedef std::vector<BaseProperty*> Properties;
193 Properties::const_iterator vertex_props_begin()
const {
return vertex_props_.begin(); }
195 Properties::const_iterator vertex_props_end()
const {
return vertex_props_.end(); }
197 Properties::const_iterator edge_props_begin()
const {
return edge_props_.begin(); }
199 Properties::const_iterator edge_props_end()
const {
return edge_props_.end(); }
201 Properties::const_iterator halfedge_props_begin()
const {
return halfedge_props_.begin(); }
203 Properties::const_iterator halfedge_props_end()
const {
return halfedge_props_.end(); }
205 Properties::const_iterator face_props_begin()
const {
return face_props_.begin(); }
207 Properties::const_iterator face_props_end()
const {
return face_props_.end(); }
209 Properties::const_iterator halfface_props_begin()
const {
return halfface_props_.begin(); }
211 Properties::const_iterator halfface_props_end()
const {
return halfface_props_.end(); }
213 Properties::const_iterator cell_props_begin()
const {
return cell_props_.begin(); }
215 Properties::const_iterator cell_props_end()
const {
return cell_props_.end(); }
217 Properties::const_iterator mesh_props_begin()
const {
return mesh_props_.begin(); }
219 Properties::const_iterator mesh_props_end()
const {
return mesh_props_.end(); }
221 template <
class FullPropT,
class PropIterT>
222 bool property_exists(
const PropIterT& _begin,
const PropIterT& _end,
const std::string& _name)
const {
224 if(_name.length() == 0) {
225 std::cerr <<
"Checking for the existance of anonymous properties is ambiguous!" << std::endl;
229 PropIterT it = _begin;
230 for(; it != _end; ++it) {
231 if((*it)->name() == _name &&
dynamic_cast<FullPropT*
>(*it) != NULL) {
238 template <
class PropT>
239 bool vertex_property_exists(
const std::string& _name)
const {
240 return property_exists<VertexPropertyT<PropT> >(vertex_props_begin(), vertex_props_end(), _name);
243 template <
class PropT>
244 bool edge_property_exists(
const std::string& _name)
const {
245 return property_exists<EdgePropertyT<PropT> >(edge_props_begin(), edge_props_end(), _name);
248 template <
class PropT>
249 bool halfedge_property_exists(
const std::string& _name)
const {
250 return property_exists<HalfEdgePropertyT<PropT> >(halfedge_props_begin(), halfedge_props_end(), _name);
253 template <
class PropT>
254 bool face_property_exists(
const std::string& _name)
const {
255 return property_exists<FacePropertyT<PropT> >(face_props_begin(), face_props_end(), _name);
258 template <
class PropT>
259 bool halfface_property_exists(
const std::string& _name)
const {
260 return property_exists<HalfFacePropertyT<PropT> >(halfface_props_begin(), halfface_props_end(), _name);
263 template <
class PropT>
264 bool cell_property_exists(
const std::string& _name)
const {
265 return property_exists<CellPropertyT<PropT> >(cell_props_begin(), cell_props_end(), _name);
268 template <
class PropT>
269 bool mesh_property_exists(
const std::string& _name)
const {
270 return property_exists<MeshPropertyT<PropT> >(mesh_props_begin(), mesh_props_end(), _name);
275 void delete_multiple_vertex_props(
const std::vector<bool>& _tags);
277 void delete_multiple_edge_props(
const std::vector<bool>& _tags);
279 void delete_multiple_face_props(
const std::vector<bool>& _tags);
281 void delete_multiple_cell_props(
const std::vector<bool>& _tags);
285 template<
class StdVecT>
286 void resize_props(StdVecT& _vec,
unsigned int _n);
288 template<
class StdVecT>
291 template<
class StdVecT>
292 void remove_property(StdVecT& _vec,
size_t _idx);
294 template<
class StdVecT,
class PropT,
class HandleT,
class T>
295 PropT request_property(StdVecT& _vec,
const std::string& _name,
size_t _size,
const T _def = T());
297 template<
class PropT>
298 void set_persistentT(PropT& _prop,
bool _flag);
300 template<
class StdVecT>
301 void clearVec(StdVecT& _vec);
303 Properties vertex_props_;
305 Properties edge_props_;
307 Properties halfedge_props_;
309 Properties face_props_;
311 Properties halfface_props_;
313 Properties cell_props_;
315 Properties mesh_props_;
320 #if defined(INCLUDE_TEMPLATES) && !defined(RESOURCEMANAGERT_CC)
321 #include "ResourceManagerT.cc"