Added very useful "IsValidPointer" functions that check that a given pointer is within the reasonable bounds for a given mesh (eg. given a vertex pointer it checks that it is between begin and end of the vertex vector)
This commit is contained in:
parent
298714ccea
commit
6f0d5cb168
|
@ -51,6 +51,15 @@ size_t Index(MeshType &m, const typename MeshType::EdgeType* e) {return e-&*m.e
|
|||
template<class MeshType>
|
||||
size_t Index(MeshType &m, const typename MeshType::HEdgeType* h) {return h-&*m.hedge.begin();}
|
||||
|
||||
template<class MeshType>
|
||||
bool IsValidPointer( MeshType & m, const typename MeshType::VertexType *vp) { return ( (vp >= &*m.vert.begin()) && ( vp < &*m.vert.end()) ); }
|
||||
template<class MeshType>
|
||||
bool IsValidPointer( MeshType & m, const typename MeshType::EdgeType *ep) { return ( (ep >= &*m.edge.begin()) && ( ep < &*m.edge.end()) ); }
|
||||
template<class MeshType>
|
||||
bool IsValidPointer( MeshType & m, const typename MeshType::FaceType *fp) { return ( (fp >= &*m.face.begin()) && ( fp < &*m.face.end()) ); }
|
||||
template<class MeshType>
|
||||
bool IsValidPointer( MeshType & m, const typename MeshType::HEdgeType *hp) { return ( (hp >= &*m.hedge.begin())&& ( hp < &*m.hedge.end()) ); }
|
||||
|
||||
template <class MeshType, class ATTR_CONT>
|
||||
void ReorderAttribute(ATTR_CONT &c, std::vector<size_t> & newVertIndex, MeshType & /* m */){
|
||||
typename std::set<typename MeshType::PointerToAttribute>::iterator ai;
|
||||
|
@ -711,6 +720,15 @@ public:
|
|||
}
|
||||
else m.vert [ pu.remap[i] ].VFClear();
|
||||
}
|
||||
if(HasVEAdjacency(m))
|
||||
{
|
||||
if (m.vert[i].IsVEInitialized())
|
||||
{
|
||||
m.vert[ pu.remap[i] ].VEp() = m.vert[i].cVEp();
|
||||
m.vert[ pu.remap[i] ].VEi() = m.vert[i].cVEi();
|
||||
}
|
||||
else m.vert [ pu.remap[i] ].VEClear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -836,8 +854,8 @@ public:
|
|||
m.edge[ pu.remap[i] ].V(0) = m.edge[i].cV(0);
|
||||
m.edge[ pu.remap[i] ].V(1) = m.edge[i].cV(1);
|
||||
// Now just copy the adjacency pointers (without changing them, to be done later)
|
||||
if(HasPerVertexVEAdjacency(m) && HasPerEdgeVEAdjacency(m) )
|
||||
if (m.edge[i].cVEp(0)!=0)
|
||||
if(HasVEAdjacency(m))
|
||||
//if (m.edge[i].cVEp(0)!=0)
|
||||
{
|
||||
m.edge[ pu.remap[i] ].VEp(0) = m.edge[i].cVEp(0);
|
||||
m.edge[ pu.remap[i] ].VEi(0) = m.edge[i].cVEi(0);
|
||||
|
@ -873,7 +891,7 @@ public:
|
|||
ResizeAttribute(m.edge_attr,m.en,m);
|
||||
|
||||
// Loop on the vertices to update the pointers of VE relation
|
||||
if(HasPerVertexVEAdjacency(m) &&HasPerEdgeVEAdjacency(m))
|
||||
if(HasVEAdjacency(m))
|
||||
for (VertexIterator vi=m.vert.begin(); vi!=m.vert.end(); ++vi)
|
||||
if(!(*vi).IsD()) pu.Update((*vi).VEp());
|
||||
|
||||
|
@ -881,7 +899,7 @@ public:
|
|||
for(EdgeIterator ei=m.edge.begin();ei!=m.edge.end();++ei)
|
||||
for(unsigned int i=0;i<2;++i)
|
||||
{
|
||||
if(HasPerVertexVEAdjacency(m) &&HasPerEdgeVEAdjacency(m))
|
||||
if(HasVEAdjacency(m))
|
||||
pu.Update((*ei).VEp(i));
|
||||
if(HasEEAdjacency(m))
|
||||
pu.Update((*ei).EEp(i));
|
||||
|
|
Loading…
Reference in New Issue