35 #include "ResourceManager.hh" 39 ResourceManager::ResourceManager(
const ResourceManager &other)
44 ResourceManager::ResourceManager(ResourceManager &&other)
46 *
this = std::move(other);
49 ResourceManager& ResourceManager::operator=(
const ResourceManager &other)
54 assignAllPropertiesFrom<false>(&other);
59 ResourceManager& ResourceManager::operator=(ResourceManager &&other)
64 assignAllPropertiesFrom<true>(&other);
69 ResourceManager::~ResourceManager() {
72 clearVec(vertex_props_);
73 clearVec(edge_props_);
74 clearVec(halfedge_props_);
75 clearVec(face_props_);
76 clearVec(halfface_props_);
77 clearVec(cell_props_);
78 clearVec(mesh_props_);
83 resize_props(vertex_props_, _nv);
88 resize_props(edge_props_, _ne);
89 resize_props(halfedge_props_, _ne*2u);
94 resize_props(face_props_, _nf);
95 resize_props(halfface_props_, _nf*2u);
100 resize_props(cell_props_, _nc);
103 void ResourceManager::vertex_deleted(
const VertexHandle& _h) {
105 entity_deleted(vertex_props_, _h);
108 void ResourceManager::edge_deleted(
const EdgeHandle& _h) {
110 entity_deleted(edge_props_, _h);
115 void ResourceManager::face_deleted(
const FaceHandle& _h) {
117 entity_deleted(face_props_, _h);
122 void ResourceManager::cell_deleted(
const CellHandle& _h) {
124 entity_deleted(cell_props_, _h);
129 swap_property_elements(cell_props_begin(), cell_props_end(), _h1, _h2);
134 swap_property_elements(face_props_begin(), face_props_end(), _h1, _h2);
139 swap_property_elements(halfface_props_begin(), halfface_props_end(), _h1, _h2);
144 swap_property_elements(edge_props_begin(), edge_props_end(), _h1, _h2);
149 swap_property_elements(halfedge_props_begin(), halfedge_props_end(), _h1, _h2);
154 swap_property_elements(vertex_props_begin(), vertex_props_end(), _h1, _h2);
159 remove_property(vertex_props_, _handle.
uidx());
164 remove_property(edge_props_, _handle.
uidx());
169 remove_property(halfedge_props_, _handle.
uidx());
174 remove_property(face_props_, _handle.
uidx());
179 remove_property(halfface_props_, _handle.
uidx());
184 remove_property(cell_props_, _handle.
uidx());
189 remove_property(mesh_props_, _handle.idx());
192 void ResourceManager::delete_multiple_vertex_props(
const std::vector<bool>& _tags) {
194 Properties::iterator vp_it = vertex_props_.begin();
195 Properties::iterator vp_end = vertex_props_.end();
196 for(; vp_it != vp_end; ++vp_it) {
197 (*vp_it)->delete_multiple_entries(_tags);
201 void ResourceManager::delete_multiple_edge_props(
const std::vector<bool>& _tags) {
203 Properties::iterator ep_it = edge_props_.begin();
204 Properties::iterator ep_end = edge_props_.end();
205 for(; ep_it != ep_end; ++ep_it) {
206 (*ep_it)->delete_multiple_entries(_tags);
209 std::vector<bool> hetags;
210 for(std::vector<bool>::const_iterator t_it = _tags.begin(),
211 t_end = _tags.end(); t_it != t_end; ++t_it) {
212 hetags.push_back(*t_it);
213 hetags.push_back(*t_it);
215 Properties::iterator hep_it = halfedge_props_.begin();
216 Properties::iterator hep_end = halfedge_props_.end();
217 for(; hep_it != hep_end; ++hep_it) {
218 (*hep_it)->delete_multiple_entries(hetags);
222 void ResourceManager::delete_multiple_face_props(
const std::vector<bool>& _tags) {
224 Properties::iterator fp_it = face_props_.begin();
225 Properties::iterator fp_end = face_props_.end();
226 for(; fp_it != fp_end; ++fp_it) {
227 (*fp_it)->delete_multiple_entries(_tags);
230 std::vector<bool> hftags;
231 for(std::vector<bool>::const_iterator t_it = _tags.begin(),
232 t_end = _tags.end(); t_it != t_end; ++t_it) {
233 hftags.push_back(*t_it);
234 hftags.push_back(*t_it);
236 Properties::iterator hfp_it = halfface_props_.begin();
237 Properties::iterator hfp_end = halfface_props_.end();
238 for(; hfp_it != hfp_end; ++hfp_it) {
239 (*hfp_it)->delete_multiple_entries(hftags);
243 void ResourceManager::delete_multiple_cell_props(
const std::vector<bool>& _tags) {
245 Properties::iterator cp_it = cell_props_.begin();
246 Properties::iterator cp_end = cell_props_.end();
247 for(; cp_it != cp_end; ++cp_it) {
248 (*cp_it)->delete_multiple_entries(_tags);
253 void ResourceManager::assignProperties(
typename std::conditional<Move, Properties&, const Properties&>::type src,
259 out.reserve(src.size());
262 for (
auto it = dest.begin(); it != dest.end(); ++it) {
264 if (dstprop->name() == srcprop->name()
265 && dstprop->internal_type_name() == srcprop->internal_type_name())
267 out.push_back(dstprop);
270 dstprop->move_values_from(srcprop);
272 dstprop->assign_values_from(srcprop);
280 out.push_back(srcprop);
286 updatePropHandles(out);
287 dest = std::move(out);
291 void ResourceManager::assignAllPropertiesFrom(
typename std::conditional<Move, ResourceManager*, const ResourceManager*>::type other)
293 assignProperties<Move>(other->vertex_props_, vertex_props_);
294 assignProperties<Move>(other->edge_props_, edge_props_);
295 assignProperties<Move>(other->halfedge_props_, halfedge_props_);
296 assignProperties<Move>(other->face_props_, face_props_);
297 assignProperties<Move>(other->halfface_props_, halfface_props_);
298 assignProperties<Move>(other->cell_props_, cell_props_);
299 assignProperties<Move>(other->mesh_props_, mesh_props_);
void resize_cprops(size_t _nc)
Change size of stored cell properties.
void resize_eprops(size_t _ne)
Change size of stored edge properties.
size_t uidx() const
return unsigned idx - handle must be valid
void resize_fprops(size_t _nf)
Change size of stored face properties.
void resize_vprops(size_t _nv)
Change size of stored vertex properties.