35 #include "ResourceManager.hh" 36 #include "BaseProperty.hh" 40 ResourceManager::ResourceManager(
const ResourceManager &other)
45 ResourceManager::ResourceManager(ResourceManager &&other)
47 *
this = std::move(other);
50 ResourceManager& ResourceManager::operator=(
const ResourceManager &other)
55 assignAllPropertiesFrom<false>(&other);
60 ResourceManager& ResourceManager::operator=(ResourceManager &&other)
65 assignAllPropertiesFrom<true>(&other);
70 ResourceManager::~ResourceManager() {
73 clearVec(vertex_props_);
74 clearVec(edge_props_);
75 clearVec(halfedge_props_);
76 clearVec(face_props_);
77 clearVec(halfface_props_);
78 clearVec(cell_props_);
79 clearVec(mesh_props_);
84 resize_props(vertex_props_, _nv);
89 resize_props(edge_props_, _ne);
90 resize_props(halfedge_props_, _ne*2u);
95 resize_props(face_props_, _nf);
96 resize_props(halfface_props_, _nf*2u);
101 resize_props(cell_props_, _nc);
104 void ResourceManager::vertex_deleted(
const VertexHandle& _h) {
106 entity_deleted(vertex_props_, _h);
109 void ResourceManager::edge_deleted(
const EdgeHandle& _h) {
111 entity_deleted(edge_props_, _h);
116 void ResourceManager::face_deleted(
const FaceHandle& _h) {
118 entity_deleted(face_props_, _h);
123 void ResourceManager::cell_deleted(
const CellHandle& _h) {
125 entity_deleted(cell_props_, _h);
130 swap_property_elements(cell_props_begin(), cell_props_end(), _h1, _h2);
135 swap_property_elements(face_props_begin(), face_props_end(), _h1, _h2);
140 swap_property_elements(halfface_props_begin(), halfface_props_end(), _h1, _h2);
145 swap_property_elements(edge_props_begin(), edge_props_end(), _h1, _h2);
150 swap_property_elements(halfedge_props_begin(), halfedge_props_end(), _h1, _h2);
155 swap_property_elements(vertex_props_begin(), vertex_props_end(), _h1, _h2);
160 remove_property(vertex_props_, _handle.
uidx());
165 remove_property(edge_props_, _handle.
uidx());
170 remove_property(halfedge_props_, _handle.
uidx());
175 remove_property(face_props_, _handle.
uidx());
180 remove_property(halfface_props_, _handle.
uidx());
185 remove_property(cell_props_, _handle.
uidx());
190 remove_property(mesh_props_, _handle.idx());
193 void ResourceManager::delete_multiple_vertex_props(
const std::vector<bool>& _tags) {
195 Properties::iterator vp_it = vertex_props_.begin();
196 Properties::iterator vp_end = vertex_props_.end();
197 for(; vp_it != vp_end; ++vp_it) {
198 (*vp_it)->delete_multiple_entries(_tags);
202 void ResourceManager::delete_multiple_edge_props(
const std::vector<bool>& _tags) {
204 Properties::iterator ep_it = edge_props_.begin();
205 Properties::iterator ep_end = edge_props_.end();
206 for(; ep_it != ep_end; ++ep_it) {
207 (*ep_it)->delete_multiple_entries(_tags);
210 std::vector<bool> hetags;
211 for(std::vector<bool>::const_iterator t_it = _tags.begin(),
212 t_end = _tags.end(); t_it != t_end; ++t_it) {
213 hetags.push_back(*t_it);
214 hetags.push_back(*t_it);
216 Properties::iterator hep_it = halfedge_props_.begin();
217 Properties::iterator hep_end = halfedge_props_.end();
218 for(; hep_it != hep_end; ++hep_it) {
219 (*hep_it)->delete_multiple_entries(hetags);
223 void ResourceManager::delete_multiple_face_props(
const std::vector<bool>& _tags) {
225 Properties::iterator fp_it = face_props_.begin();
226 Properties::iterator fp_end = face_props_.end();
227 for(; fp_it != fp_end; ++fp_it) {
228 (*fp_it)->delete_multiple_entries(_tags);
231 std::vector<bool> hftags;
232 for(std::vector<bool>::const_iterator t_it = _tags.begin(),
233 t_end = _tags.end(); t_it != t_end; ++t_it) {
234 hftags.push_back(*t_it);
235 hftags.push_back(*t_it);
237 Properties::iterator hfp_it = halfface_props_.begin();
238 Properties::iterator hfp_end = halfface_props_.end();
239 for(; hfp_it != hfp_end; ++hfp_it) {
240 (*hfp_it)->delete_multiple_entries(hftags);
244 void ResourceManager::delete_multiple_cell_props(
const std::vector<bool>& _tags) {
246 Properties::iterator cp_it = cell_props_.begin();
247 Properties::iterator cp_end = cell_props_.end();
248 for(; cp_it != cp_end; ++cp_it) {
249 (*cp_it)->delete_multiple_entries(_tags);
254 void ResourceManager::assignProperties(
typename std::conditional<Move, Properties&, const Properties&>::type src,
260 out.reserve(src.size());
263 for (
auto it = dest.begin(); it != dest.end(); ++it) {
265 if (dstprop->name() == srcprop->name()
266 && dstprop->internal_type_name() == srcprop->internal_type_name())
268 out.push_back(dstprop);
271 dstprop->move_values_from(srcprop);
273 dstprop->assign_values_from(srcprop);
281 out.push_back(srcprop);
287 updatePropHandles(out);
288 dest = std::move(out);
292 void ResourceManager::assignAllPropertiesFrom(
typename std::conditional<Move, ResourceManager*, const ResourceManager*>::type other)
294 assignProperties<Move>(other->vertex_props_, vertex_props_);
295 assignProperties<Move>(other->edge_props_, edge_props_);
296 assignProperties<Move>(other->halfedge_props_, halfedge_props_);
297 assignProperties<Move>(other->face_props_, face_props_);
298 assignProperties<Move>(other->halfface_props_, halfface_props_);
299 assignProperties<Move>(other->cell_props_, cell_props_);
300 assignProperties<Move>(other->mesh_props_, mesh_props_);
304 ResourceManager::Properties&
305 ResourceManager::entity_props<Entity::Vertex>()
307 return vertex_props_;
310 ResourceManager::Properties&
311 ResourceManager::entity_props<Entity::Edge>()
316 ResourceManager::Properties&
317 ResourceManager::entity_props<Entity::HalfEdge>()
319 return halfedge_props_;
322 ResourceManager::Properties&
323 ResourceManager::entity_props<Entity::Face>()
328 ResourceManager::Properties&
329 ResourceManager::entity_props<Entity::HalfFace>()
331 return halfface_props_;
334 ResourceManager::Properties&
335 ResourceManager::entity_props<Entity::Cell>()
340 ResourceManager::Properties&
341 ResourceManager::entity_props<Entity::Mesh>()
347 size_t ResourceManager::n<Entity::Vertex>()
352 size_t ResourceManager::n<Entity::Edge>()
357 size_t ResourceManager::n<Entity::HalfEdge>()
362 size_t ResourceManager::n<Entity::Face>()
367 size_t ResourceManager::n<Entity::HalfFace>()
373 size_t ResourceManager::n<Entity::Cell>()
379 size_t ResourceManager::n<Entity::Mesh>()
void resize_cprops(size_t _nc)
Change size of stored cell properties.
virtual size_t n_edges() const =0
Get number of edges in mesh.
void resize_eprops(size_t _ne)
Change size of stored edge properties.
virtual size_t n_cells() const =0
Get number of cells in mesh.
size_t uidx() const
return unsigned idx - handle must be valid
virtual size_t n_halfedges() const =0
Get number of halfedges in mesh.
void resize_fprops(size_t _nf)
Change size of stored face properties.
virtual size_t n_halffaces() const =0
Get number of halffaces in mesh.
virtual size_t n_vertices() const =0
Get number of vertices in mesh.
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.