fixed bug in const copy of mesh attributes

This commit is contained in:
Luigi Malomo 2021-03-29 17:29:44 +02:00
parent 7973ee6b48
commit 895f8b0d03
1 changed files with 66 additions and 54 deletions

View File

@ -669,64 +669,76 @@ static void MeshAppendConst(
// If the left mesh has attributes that are not in the right mesh, their values for the elements // If the left mesh has attributes that are not in the right mesh, their values for the elements
// of the right mesh will be uninitialized // of the right mesh will be uninitialized
unsigned int id_r; unsigned int id_r;
typename std::set< PointerToAttribute >::iterator al, ar; typename std::set< PointerToAttribute >::iterator al, ar;
// per vertex attributes // per vertex attributes
for(al = ml.vert_attr.begin(); al != ml.vert_attr.end(); ++al) for (al = ml.vert_attr.begin(); al != ml.vert_attr.end(); ++al)
if(!(*al)._name.empty()){ if(!(*al)._name.empty())
ar = mr.vert_attr.find(*al); {
if(ar!= mr.vert_attr.end()){ ar = mr.vert_attr.find(*al);
id_r = 0; if (ar != mr.vert_attr.end())
for (auto v: mr.vert){ {
if( !v.IsD() && (!selected || v.IsS())) id_r = 0;
(*al)._handle->CopyValue(remap.vert[Index(mr,v)], id_r, (*ar)._handle); for (const auto & v : mr.vert)
++id_r; {
} if( !v.IsD() && (!selected || v.IsS()))
} (*al)._handle->CopyValue(remap.vert[Index(mr,v)], id_r, (*ar)._handle);
} ++id_r;
}
}
}
// per edge attributes // per edge attributes
for(al = ml.edge_attr.begin(); al != ml.edge_attr.end(); ++al) for (al = ml.edge_attr.begin(); al != ml.edge_attr.end(); ++al)
if(!(*al)._name.empty()){ if (!(*al)._name.empty())
ar = mr.edge_attr.find(*al); {
if(ar!= mr.edge_attr.end()){ ar = mr.edge_attr.find(*al);
id_r = 0; if (ar!= mr.edge_attr.end())
for (auto e: mr.edge){ {
if( !e.IsD() && (!selected || e.IsS())) id_r = 0;
(*al)._handle->CopyValue(remap.edge[Index(mr,e)], id_r, (*ar)._handle); for (const auto & e : mr.edge)
++id_r; {
} if( !e.IsD() && (!selected || e.IsS()))
} (*al)._handle->CopyValue(remap.edge[Index(mr,e)], id_r, (*ar)._handle);
} ++id_r;
}
}
}
// per face attributes // per face attributes
for(al = ml.face_attr.begin(); al != ml.face_attr.end(); ++al) for (al = ml.face_attr.begin(); al != ml.face_attr.end(); ++al)
if(!(*al)._name.empty()){ if (!(*al)._name.empty())
ar = mr.face_attr.find(*al); {
if(ar!= mr.face_attr.end()){ ar = mr.face_attr.find(*al);
id_r = 0; if (ar!= mr.face_attr.end())
for (auto f: mr.face) { {
if( !f.IsD() && (!selected || f.IsS())) id_r = 0;
(*al)._handle->CopyValue(remap.face[Index(mr,f)], id_r, (*ar)._handle); for (const auto & f : mr.face)
++id_r; {
} if( !f.IsD() && (!selected || f.IsS()))
} (*al)._handle->CopyValue(remap.face[Index(mr,f)], id_r, (*ar)._handle);
} ++id_r;
}
}
}
// per tetra attributes // per tetra attributes
for(al = ml.tetra_attr.begin(); al != ml.tetra_attr.end(); ++al) for (al = ml.tetra_attr.begin(); al != ml.tetra_attr.end(); ++al)
if(!(*al)._name.empty()){ if (!(*al)._name.empty())
ar = mr.tetra_attr.find(*al); {
if(ar!= mr.tetra_attr.end()){ ar = mr.tetra_attr.find(*al);
id_r = 0; if (ar!= mr.tetra_attr.end())
for (auto t: mr.tetra) { {
if( !t.IsD() && (!selected || t.IsS())) id_r = 0;
(*al)._handle->CopyValue(remap.tetra[Index(mr, t)], id_r, (*ar)._handle); for (const auto & t: mr.tetra)
++id_r; {
} if( !t.IsD() && (!selected || t.IsS()))
} (*al)._handle->CopyValue(remap.tetra[Index(mr, t)], id_r, (*ar)._handle);
} ++id_r;
}
}
}
// per mesh attributes // per mesh attributes
// if both ml and mr have an attribute with the same name, no action is done // if both ml and mr have an attribute with the same name, no action is done