Corrected the behavoiour of the allocate::Compact when managing uninitialized and null element in adjacency
This commit is contained in:
parent
4665f36e40
commit
f62e07ee66
|
@ -142,7 +142,7 @@ namespace tri {
|
||||||
SimplexPointerType oldBase;
|
SimplexPointerType oldBase;
|
||||||
SimplexPointerType newEnd;
|
SimplexPointerType newEnd;
|
||||||
SimplexPointerType oldEnd;
|
SimplexPointerType oldEnd;
|
||||||
std::vector<size_t> remap;
|
std::vector<size_t> remap; // this vector keep the new position of an element. Uninitialized elements have max_int value to denote an element that has not to be remapped.
|
||||||
|
|
||||||
bool preventUpdateFlag; /// when true no update is considered necessary.
|
bool preventUpdateFlag; /// when true no update is considered necessary.
|
||||||
};
|
};
|
||||||
|
@ -599,12 +599,13 @@ namespace tri {
|
||||||
{
|
{
|
||||||
assert(!m.vert[i].IsD());
|
assert(!m.vert[i].IsD());
|
||||||
m.vert[ pu.remap [i] ].ImportData(m.vert[i]);
|
m.vert[ pu.remap [i] ].ImportData(m.vert[i]);
|
||||||
if(HasPerVertexVFAdjacency(m) &&HasPerFaceVFAdjacency(m) )
|
if(HasVFAdjacency(m))
|
||||||
if (m.vert[i].cVFp()!=0)
|
if (m.vert[i].IsVFInitialized())
|
||||||
{
|
{
|
||||||
m.vert[ pu.remap[i] ].VFp() = m.vert[i].cVFp();
|
m.vert[ pu.remap[i] ].VFp() = m.vert[i].cVFp();
|
||||||
m.vert[ pu.remap[i] ].VFi() = m.vert[i].cVFi();
|
m.vert[ pu.remap[i] ].VFi() = m.vert[i].cVFi();
|
||||||
}
|
}
|
||||||
|
else m.vert [ pu.remap[i] ].VFClear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -793,7 +794,7 @@ namespace tri {
|
||||||
\brief Compact vector of faces removing deleted elements.
|
\brief Compact vector of faces removing deleted elements.
|
||||||
|
|
||||||
Deleted elements are put to the end of the vector and the vector is resized. Order between elements is preserved but not their position (hence the PointerUpdater)
|
Deleted elements are put to the end of the vector and the vector is resized. Order between elements is preserved but not their position (hence the PointerUpdater)
|
||||||
After calling this function the \c IsD() test in the scanning a vector, is no more necessary.
|
Immediately after calling this function the \c IsD() test during the scanning a vector, is no more necessary.
|
||||||
\warning It should not be called when TemporaryData is active (but works correctly if attributes are present)
|
\warning It should not be called when TemporaryData is active (but works correctly if attributes are present)
|
||||||
*/
|
*/
|
||||||
static void CompactFaceVector( MeshType &m, PointerUpdater<FacePointer> &pu )
|
static void CompactFaceVector( MeshType &m, PointerUpdater<FacePointer> &pu )
|
||||||
|
@ -805,9 +806,7 @@ namespace tri {
|
||||||
pu.remap.resize( m.face.size(),std::numeric_limits<size_t>::max() );
|
pu.remap.resize( m.face.size(),std::numeric_limits<size_t>::max() );
|
||||||
|
|
||||||
size_t pos=0;
|
size_t pos=0;
|
||||||
size_t i=0;
|
for(size_t i=0;i<m.face.size();++i)
|
||||||
|
|
||||||
for(i=0;i<m.face.size();++i)
|
|
||||||
{
|
{
|
||||||
if(!m.face[i].IsD())
|
if(!m.face[i].IsD())
|
||||||
{
|
{
|
||||||
|
@ -817,12 +816,15 @@ namespace tri {
|
||||||
m.face[pos].V(0) = m.face[i].V(0);
|
m.face[pos].V(0) = m.face[i].V(0);
|
||||||
m.face[pos].V(1) = m.face[i].V(1);
|
m.face[pos].V(1) = m.face[i].V(1);
|
||||||
m.face[pos].V(2) = m.face[i].V(2);
|
m.face[pos].V(2) = m.face[i].V(2);
|
||||||
if(HasPerVertexVFAdjacency(m) && HasPerFaceVFAdjacency(m))
|
if(HasVFAdjacency(m))
|
||||||
for(int j=0;j<3;++j)
|
for(int j=0;j<3;++j)
|
||||||
if (m.face[i].cVFp(j)!=0) {
|
{
|
||||||
|
if (m.face[i].IsVFInitialized(j)) {
|
||||||
m.face[pos].VFp(j) = m.face[i].cVFp(j);
|
m.face[pos].VFp(j) = m.face[i].cVFp(j);
|
||||||
m.face[pos].VFi(j) = m.face[i].cVFi(j);
|
m.face[pos].VFi(j) = m.face[i].cVFi(j);
|
||||||
}
|
}
|
||||||
|
else m.face[pos].VFClear(j);
|
||||||
|
}
|
||||||
if(HasFFAdjacency(m))
|
if(HasFFAdjacency(m))
|
||||||
for(int j=0;j<3;++j)
|
for(int j=0;j<3;++j)
|
||||||
if (m.face[i].cFFp(j)!=0) {
|
if (m.face[i].cFFp(j)!=0) {
|
||||||
|
@ -839,21 +841,22 @@ namespace tri {
|
||||||
// reorder the optional atttributes in m.face_attr to reflect the changes
|
// reorder the optional atttributes in m.face_attr to reflect the changes
|
||||||
ReorderAttribute(m.face_attr,pu.remap,m);
|
ReorderAttribute(m.face_attr,pu.remap,m);
|
||||||
|
|
||||||
// Loop on the vertices to correct VF relation
|
|
||||||
VertexIterator vi;
|
|
||||||
FacePointer fbase=&m.face[0];
|
FacePointer fbase=&m.face[0];
|
||||||
for (vi=m.vert.begin(); vi!=m.vert.end(); ++vi)
|
|
||||||
|
// Loop on the vertices to correct VF relation
|
||||||
|
if(HasVFAdjacency(m))
|
||||||
|
{
|
||||||
|
for (VertexIterator vi=m.vert.begin(); vi!=m.vert.end(); ++vi)
|
||||||
if(!(*vi).IsD())
|
if(!(*vi).IsD())
|
||||||
{
|
{
|
||||||
if(HasPerVertexVFAdjacency(m) &&HasPerFaceVFAdjacency(m) )
|
if ((*vi).IsVFInitialized() && (*vi).VFp()!=0 )
|
||||||
if ((*vi).cVFp()!=0)
|
|
||||||
{
|
{
|
||||||
size_t oldIndex = (*vi).cVFp() - fbase;
|
size_t oldIndex = (*vi).cVFp() - fbase;
|
||||||
assert(fbase <= (*vi).cVFp() && oldIndex < pu.remap.size());
|
assert(fbase <= (*vi).cVFp() && oldIndex < pu.remap.size());
|
||||||
(*vi).VFp() = fbase+pu.remap[oldIndex];
|
(*vi).VFp() = fbase+pu.remap[oldIndex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Loop on the faces to correct VF and FF relations
|
// Loop on the faces to correct VF and FF relations
|
||||||
pu.oldBase = &m.face[0];
|
pu.oldBase = &m.face[0];
|
||||||
|
@ -866,20 +869,20 @@ namespace tri {
|
||||||
// resize the optional atttributes in m.face_attr to reflect the changes
|
// resize the optional atttributes in m.face_attr to reflect the changes
|
||||||
ResizeAttribute(m.face_attr,m.fn,m);
|
ResizeAttribute(m.face_attr,m.fn,m);
|
||||||
|
|
||||||
FaceIterator fi;
|
// now we update the various (not null) face pointers (inside VF and FF relations)
|
||||||
for(fi=m.face.begin();fi!=m.face.end();++fi)
|
for(FaceIterator fi=m.face.begin();fi!=m.face.end();++fi)
|
||||||
if(!(*fi).IsD())
|
if(!(*fi).IsD())
|
||||||
{
|
{
|
||||||
if(HasPerVertexVFAdjacency(m) &&HasPerFaceVFAdjacency(m) )
|
if(HasVFAdjacency(m))
|
||||||
for(i=0;i<3;++i)
|
for(int i=0;i<3;++i)
|
||||||
if ((*fi).cVFp(i)!=0)
|
if ((*fi).IsVFInitialized(i) && (*fi).VFp(i)!=0 )
|
||||||
{
|
{
|
||||||
size_t oldIndex = (*fi).VFp(i) - fbase;
|
size_t oldIndex = (*fi).VFp(i) - fbase;
|
||||||
assert(fbase <= (*fi).VFp(i) && oldIndex < pu.remap.size());
|
assert(fbase <= (*fi).VFp(i) && oldIndex < pu.remap.size());
|
||||||
(*fi).VFp(i) = fbase+pu.remap[oldIndex];
|
(*fi).VFp(i) = fbase+pu.remap[oldIndex];
|
||||||
}
|
}
|
||||||
if(HasFFAdjacency(m))
|
if(HasFFAdjacency(m))
|
||||||
for(i=0;i<3;++i)
|
for(int i=0;i<3;++i)
|
||||||
if ((*fi).cFFp(i)!=0)
|
if ((*fi).cFFp(i)!=0)
|
||||||
{
|
{
|
||||||
size_t oldIndex = (*fi).FFp(i) - fbase;
|
size_t oldIndex = (*fi).FFp(i) - fbase;
|
||||||
|
|
Loading…
Reference in New Issue