Made uniform the use of size_t instead of int in the vast majority of the allocate.h functions
This commit is contained in:
parent
6b106d97fb
commit
afc802107a
|
@ -59,7 +59,7 @@ void ReorderAttribute(ATTR_CONT &c,std::vector<size_t> & newVertIndex, MeshType
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class MeshType, class ATTR_CONT>
|
template <class MeshType, class ATTR_CONT>
|
||||||
void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
|
void ResizeAttribute(ATTR_CONT &c, size_t sz, MeshType &/*m*/){
|
||||||
typename std::set<typename MeshType::PointerToAttribute>::iterator ai;
|
typename std::set<typename MeshType::PointerToAttribute>::iterator ai;
|
||||||
for(ai =c.begin(); ai != c.end(); ++ai)
|
for(ai =c.begin(); ai != c.end(); ++ai)
|
||||||
((typename MeshType::PointerToAttribute)(*ai)).Resize(sz);
|
((typename MeshType::PointerToAttribute)(*ai)).Resize(sz);
|
||||||
|
@ -162,7 +162,7 @@ void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
|
||||||
\param pu a PointerUpdater initialized so that it can be used to update pointers to vertices that could have become invalid after this adding.
|
\param pu a PointerUpdater initialized so that it can be used to update pointers to vertices that could have become invalid after this adding.
|
||||||
\retval the iterator to the first element added.
|
\retval the iterator to the first element added.
|
||||||
*/
|
*/
|
||||||
static VertexIterator AddVertices(MeshType &m,int n, PointerUpdater<VertexPointer> &pu)
|
static VertexIterator AddVertices(MeshType &m, size_t n, PointerUpdater<VertexPointer> &pu)
|
||||||
{
|
{
|
||||||
VertexIterator last;
|
VertexIterator last;
|
||||||
if(n == 0) return m.vert.end();
|
if(n == 0) return m.vert.end();
|
||||||
|
@ -207,7 +207,7 @@ void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
|
||||||
|
|
||||||
// e poiche' lo spazio e' cambiato si ricalcola anche last da zero
|
// e poiche' lo spazio e' cambiato si ricalcola anche last da zero
|
||||||
}
|
}
|
||||||
unsigned int siz=(unsigned int)m.vert.size()-n;
|
size_t siz=(size_t)(m.vert.size()-n);
|
||||||
|
|
||||||
last = m.vert.begin();
|
last = m.vert.begin();
|
||||||
advance(last,siz);
|
advance(last,siz);
|
||||||
|
@ -217,7 +217,7 @@ void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
|
||||||
|
|
||||||
/** \brief Wrapper to AddVertices(); no PointerUpdater
|
/** \brief Wrapper to AddVertices(); no PointerUpdater
|
||||||
*/
|
*/
|
||||||
static VertexIterator AddVertices(MeshType &m, int n)
|
static VertexIterator AddVertices(MeshType &m, size_t n)
|
||||||
{
|
{
|
||||||
PointerUpdater<VertexPointer> pu;
|
PointerUpdater<VertexPointer> pu;
|
||||||
return AddVertices(m, n,pu);
|
return AddVertices(m, n,pu);
|
||||||
|
@ -225,7 +225,7 @@ void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
|
||||||
|
|
||||||
/** \brief Wrapper to AddVertices() no PointerUpdater but a vector of VertexPointer pointers to be updated
|
/** \brief Wrapper to AddVertices() no PointerUpdater but a vector of VertexPointer pointers to be updated
|
||||||
*/
|
*/
|
||||||
static VertexIterator AddVertices(MeshType &m, int n, std::vector<VertexPointer *> &local_vec)
|
static VertexIterator AddVertices(MeshType &m, size_t n, std::vector<VertexPointer *> &local_vec)
|
||||||
{
|
{
|
||||||
PointerUpdater<VertexPointer> pu;
|
PointerUpdater<VertexPointer> pu;
|
||||||
VertexIterator v_ret = AddVertices(m, n,pu);
|
VertexIterator v_ret = AddVertices(m, n,pu);
|
||||||
|
@ -276,7 +276,7 @@ void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
|
||||||
\param pu a PointerUpdater initialized so that it can be used to update pointers to edges that could have become invalid after this adding.
|
\param pu a PointerUpdater initialized so that it can be used to update pointers to edges that could have become invalid after this adding.
|
||||||
\retval the iterator to the first element added.
|
\retval the iterator to the first element added.
|
||||||
*/
|
*/
|
||||||
static EdgeIterator AddEdges(MeshType &m,int n, PointerUpdater<EdgePointer> &pu)
|
static EdgeIterator AddEdges(MeshType &m, size_t n, PointerUpdater<EdgePointer> &pu)
|
||||||
{
|
{
|
||||||
EdgeIterator last;
|
EdgeIterator last;
|
||||||
if(n == 0) return m.edge.end();
|
if(n == 0) return m.edge.end();
|
||||||
|
@ -315,7 +315,7 @@ void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
|
||||||
if(!(*hi).IsD())
|
if(!(*hi).IsD())
|
||||||
if ((*hi).cHEp()!=0) pu.Update((*hi).HEp());
|
if ((*hi).cHEp()!=0) pu.Update((*hi).HEp());
|
||||||
}
|
}
|
||||||
unsigned int siz=(unsigned int)m.edge.size()-n;
|
size_t siz=(size_t)(m.edge.size()-n);
|
||||||
|
|
||||||
last = m.edge.begin();
|
last = m.edge.begin();
|
||||||
advance(last,siz);
|
advance(last,siz);
|
||||||
|
@ -349,7 +349,7 @@ void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
|
||||||
/** Function to add n edges to the mesh.
|
/** Function to add n edges to the mesh.
|
||||||
First wrapper, with no parameters
|
First wrapper, with no parameters
|
||||||
*/
|
*/
|
||||||
static EdgeIterator AddEdges(MeshType &m, int n)
|
static EdgeIterator AddEdges(MeshType &m, size_t n)
|
||||||
{
|
{
|
||||||
PointerUpdater<EdgePointer> pu;
|
PointerUpdater<EdgePointer> pu;
|
||||||
return AddEdges(m, n,pu);
|
return AddEdges(m, n,pu);
|
||||||
|
@ -358,7 +358,7 @@ void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
|
||||||
/** Function to add n edges to the mesh.
|
/** Function to add n edges to the mesh.
|
||||||
Second Wrapper, with a vector of vertex pointers to be updated.
|
Second Wrapper, with a vector of vertex pointers to be updated.
|
||||||
*/
|
*/
|
||||||
static EdgeIterator AddEdges(MeshType &m, int n, std::vector<EdgePointer*> &local_vec)
|
static EdgeIterator AddEdges(MeshType &m, size_t n, std::vector<EdgePointer*> &local_vec)
|
||||||
{
|
{
|
||||||
PointerUpdater<EdgePointer> pu;
|
PointerUpdater<EdgePointer> pu;
|
||||||
EdgeIterator v_ret = AddEdges(m, n,pu);
|
EdgeIterator v_ret = AddEdges(m, n,pu);
|
||||||
|
@ -380,7 +380,7 @@ void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
|
||||||
\param pu a PointerUpdater initialized so that it can be used to update pointers to edges that could have become invalid after this adding.
|
\param pu a PointerUpdater initialized so that it can be used to update pointers to edges that could have become invalid after this adding.
|
||||||
\retval the iterator to the first element added.
|
\retval the iterator to the first element added.
|
||||||
*/
|
*/
|
||||||
static HEdgeIterator AddHEdges(MeshType &m,int n, PointerUpdater<HEdgePointer> &pu)
|
static HEdgeIterator AddHEdges(MeshType &m, size_t n, PointerUpdater<HEdgePointer> &pu)
|
||||||
{
|
{
|
||||||
HEdgeIterator last;
|
HEdgeIterator last;
|
||||||
if(n == 0) return m.hedge.end();
|
if(n == 0) return m.hedge.end();
|
||||||
|
@ -399,36 +399,27 @@ void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
|
||||||
|
|
||||||
if(pu.NeedUpdate())
|
if(pu.NeedUpdate())
|
||||||
{
|
{
|
||||||
int ii = 0;
|
if(HasFHAdjacency(m)) {
|
||||||
FaceIterator fi;
|
for (FaceIterator fi=m.face.begin(); fi!=m.face.end(); ++fi)
|
||||||
for (fi=m.face.begin(); fi!=m.face.end(); ++fi)
|
|
||||||
{
|
{
|
||||||
if(HasFHAdjacency(m))
|
|
||||||
if(!(*fi).IsD() && (*fi).FHp())
|
if(!(*fi).IsD() && (*fi).FHp())
|
||||||
pu.Update((*fi).FHp());
|
pu.Update((*fi).FHp());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
{
|
if(HasVHAdjacency(m)) {
|
||||||
VertexIterator vi;
|
for (VertexIterator vi=m.vert.begin(); vi!=m.vert.end(); ++vi)
|
||||||
for (vi=m.vert.begin(); vi!=m.vert.end(); ++vi)
|
if(!(*vi).IsD() && (*vi).cVHp()!=0)
|
||||||
if(HasVHAdjacency(m))
|
|
||||||
if(!(*vi).IsD())
|
|
||||||
if ((*vi).cVHp()!=0)
|
|
||||||
pu.Update((*vi).VHp());
|
pu.Update((*vi).VHp());
|
||||||
}
|
}
|
||||||
|
if(HasEHAdjacency(m)) {
|
||||||
{
|
for (EdgeIterator ei=m.edge.begin(); ei!=m.edge.end(); ++ei)
|
||||||
EdgeIterator ei;
|
if(!(*ei).IsD() && (*ei).cEHp()!=0)
|
||||||
for (ei=m.edge.begin(); ei!=m.edge.end(); ++ei)
|
|
||||||
if(HasEHAdjacency(m))
|
|
||||||
if(!(*ei).IsD())
|
|
||||||
if ((*ei).cEHp()!=0)
|
|
||||||
pu.Update((*ei).EHp());
|
pu.Update((*ei).EHp());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
int ii = 0;
|
||||||
HEdgeIterator hi = m.hedge.begin();
|
HEdgeIterator hi = m.hedge.begin();
|
||||||
while(ii < m.hn - n)// cycle on all the faces except the new ones
|
while(ii < m.hn - int(n))// cycle on all the faces except the new ones
|
||||||
{
|
{
|
||||||
if(!(*hi).IsD())
|
if(!(*hi).IsD())
|
||||||
{
|
{
|
||||||
|
@ -437,12 +428,10 @@ void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
|
||||||
if(HasHOppAdjacency(m)) pu.Update((*hi).HOp());
|
if(HasHOppAdjacency(m)) pu.Update((*hi).HOp());
|
||||||
++ii;
|
++ii;
|
||||||
}
|
}
|
||||||
|
|
||||||
++hi;
|
++hi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
size_t siz = (size_t)(m.hedge.size()-n);
|
||||||
unsigned int siz = (unsigned int)m.hedge.size()-n;
|
|
||||||
|
|
||||||
last = m.hedge.begin();
|
last = m.hedge.begin();
|
||||||
advance(last,siz);
|
advance(last,siz);
|
||||||
|
@ -453,7 +442,7 @@ void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
|
||||||
/** Function to add n vertices to the mesh.
|
/** Function to add n vertices to the mesh.
|
||||||
First wrapper, with no parameters
|
First wrapper, with no parameters
|
||||||
*/
|
*/
|
||||||
static HEdgeIterator AddHEdges(MeshType &m, int n)
|
static HEdgeIterator AddHEdges(MeshType &m, size_t n)
|
||||||
{
|
{
|
||||||
PointerUpdater<HEdgePointer> pu;
|
PointerUpdater<HEdgePointer> pu;
|
||||||
return AddHEdges(m, n,pu);
|
return AddHEdges(m, n,pu);
|
||||||
|
@ -462,7 +451,7 @@ void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
|
||||||
/** Function to add n vertices to the mesh.
|
/** Function to add n vertices to the mesh.
|
||||||
Second Wrapper, with a vector of vertex pointers to be updated.
|
Second Wrapper, with a vector of vertex pointers to be updated.
|
||||||
*/
|
*/
|
||||||
static HEdgeIterator AddHEdges(MeshType &m, int n, std::vector<HEdgePointer*> &local_vec)
|
static HEdgeIterator AddHEdges(MeshType &m, size_t n, std::vector<HEdgePointer*> &local_vec)
|
||||||
{
|
{
|
||||||
PointerUpdater<HEdgePointer> pu;
|
PointerUpdater<HEdgePointer> pu;
|
||||||
HEdgeIterator v_ret = AddHEdges(m, n,pu);
|
HEdgeIterator v_ret = AddHEdges(m, n,pu);
|
||||||
|
@ -553,7 +542,7 @@ void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
|
||||||
/** \brief Function to add n faces to the mesh.
|
/** \brief Function to add n faces to the mesh.
|
||||||
First wrapper, with no parameters
|
First wrapper, with no parameters
|
||||||
*/
|
*/
|
||||||
static FaceIterator AddFaces(MeshType &m, int n)
|
static FaceIterator AddFaces(MeshType &m, size_t n)
|
||||||
{
|
{
|
||||||
PointerUpdater<FacePointer> pu;
|
PointerUpdater<FacePointer> pu;
|
||||||
return AddFaces(m,n,pu);
|
return AddFaces(m,n,pu);
|
||||||
|
@ -562,7 +551,7 @@ void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
|
||||||
/** \brief Function to add n faces to the mesh.
|
/** \brief Function to add n faces to the mesh.
|
||||||
Second Wrapper, with a vector of face pointer to be updated.
|
Second Wrapper, with a vector of face pointer to be updated.
|
||||||
*/
|
*/
|
||||||
static FaceIterator AddFaces(MeshType &m, int n,std::vector<FacePointer *> &local_vec)
|
static FaceIterator AddFaces(MeshType &m, size_t n,std::vector<FacePointer *> &local_vec)
|
||||||
{
|
{
|
||||||
PointerUpdater<FacePointer> pu;
|
PointerUpdater<FacePointer> pu;
|
||||||
FaceIterator f_ret= AddFaces(m,n,pu);
|
FaceIterator f_ret= AddFaces(m,n,pu);
|
||||||
|
@ -585,7 +574,7 @@ void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
|
||||||
\param pu a PointerUpdater initialized so that it can be used to update pointers to edges that could have become invalid after this adding.
|
\param pu a PointerUpdater initialized so that it can be used to update pointers to edges that could have become invalid after this adding.
|
||||||
\retval the iterator to the first element added.
|
\retval the iterator to the first element added.
|
||||||
*/
|
*/
|
||||||
static FaceIterator AddFaces(MeshType &m, int n, PointerUpdater<FacePointer> &pu)
|
static FaceIterator AddFaces(MeshType &m, size_t n, PointerUpdater<FacePointer> &pu)
|
||||||
{
|
{
|
||||||
pu.Clear();
|
pu.Clear();
|
||||||
if(n == 0) return m.face.end();
|
if(n == 0) return m.face.end();
|
||||||
|
@ -598,7 +587,7 @@ void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
|
||||||
m.face.resize(m.face.size()+n);
|
m.face.resize(m.face.size()+n);
|
||||||
m.fn+=n;
|
m.fn+=n;
|
||||||
|
|
||||||
unsigned int siz=(unsigned int)m.face.size()-n;
|
size_t siz=(size_t)(m.face.size()-n);
|
||||||
FaceIterator firstNewFace = m.face.begin();
|
FaceIterator firstNewFace = m.face.begin();
|
||||||
advance(firstNewFace,siz);
|
advance(firstNewFace,siz);
|
||||||
|
|
||||||
|
@ -706,7 +695,7 @@ void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
|
||||||
static void PermutateVertexVector(MeshType &m, PointerUpdater<VertexPointer> &pu)
|
static void PermutateVertexVector(MeshType &m, PointerUpdater<VertexPointer> &pu)
|
||||||
{
|
{
|
||||||
if(m.vert.empty()) return;
|
if(m.vert.empty()) return;
|
||||||
for(unsigned int i=0;i<m.vert.size();++i)
|
for(size_t i=0;i<m.vert.size();++i)
|
||||||
{
|
{
|
||||||
if(pu.remap[i]<size_t(m.vn))
|
if(pu.remap[i]<size_t(m.vn))
|
||||||
{
|
{
|
||||||
|
@ -754,9 +743,9 @@ void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
|
||||||
if(HasEVAdjacency(m))
|
if(HasEVAdjacency(m))
|
||||||
for(EdgeIterator ei=m.edge.begin();ei!=m.edge.end();++ei)
|
for(EdgeIterator ei=m.edge.begin();ei!=m.edge.end();++ei)
|
||||||
if(!(*ei).IsD())
|
if(!(*ei).IsD())
|
||||||
for(unsigned int i=0;i<2;++i)
|
|
||||||
{
|
{
|
||||||
pu.Update((*ei).V(i));
|
pu.Update((*ei).V(0));
|
||||||
|
pu.Update((*ei).V(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -836,7 +825,7 @@ void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
|
||||||
assert((int)pos==m.en);
|
assert((int)pos==m.en);
|
||||||
|
|
||||||
// the actual copying of the data.
|
// the actual copying of the data.
|
||||||
for(unsigned int i=0;i<m.edge.size();++i)
|
for(size_t i=0;i<m.edge.size();++i)
|
||||||
{
|
{
|
||||||
if(pu.remap[i]<size_t(m.en)) // uninitialized entries in the remap vector has max_int value;
|
if(pu.remap[i]<size_t(m.en)) // uninitialized entries in the remap vector has max_int value;
|
||||||
{
|
{
|
||||||
|
@ -1523,7 +1512,7 @@ public:
|
||||||
|
|
||||||
// copy the padded container in the new one
|
// copy the padded container in the new one
|
||||||
_handle->Resize(m.vert.size());
|
_handle->Resize(m.vert.size());
|
||||||
for(unsigned int i = 0; i < m.vert.size(); ++i){
|
for(size_t i = 0; i < m.vert.size(); ++i){
|
||||||
ATTR_TYPE * dest = &(*_handle)[i];
|
ATTR_TYPE * dest = &(*_handle)[i];
|
||||||
char * ptr = (char*)( ((SimpleTempDataBase *)pa._handle)->DataBegin());
|
char * ptr = (char*)( ((SimpleTempDataBase *)pa._handle)->DataBegin());
|
||||||
memcpy((void*)dest ,
|
memcpy((void*)dest ,
|
||||||
|
@ -1550,7 +1539,7 @@ public:
|
||||||
|
|
||||||
// copy the padded container in the new one
|
// copy the padded container in the new one
|
||||||
_handle->Resize(m.edge.size());
|
_handle->Resize(m.edge.size());
|
||||||
for(unsigned int i = 0; i < m.edge.size(); ++i){
|
for(size_t i = 0; i < m.edge.size(); ++i){
|
||||||
ATTR_TYPE * dest = &(*_handle)[i];
|
ATTR_TYPE * dest = &(*_handle)[i];
|
||||||
char * ptr = (char*)( ((SimpleTempDataBase *)pa._handle)->DataBegin());
|
char * ptr = (char*)( ((SimpleTempDataBase *)pa._handle)->DataBegin());
|
||||||
memcpy((void*)dest ,
|
memcpy((void*)dest ,
|
||||||
|
@ -1578,7 +1567,7 @@ public:
|
||||||
|
|
||||||
// copy the padded container in the new one
|
// copy the padded container in the new one
|
||||||
_handle->Resize(m.face.size());
|
_handle->Resize(m.face.size());
|
||||||
for(unsigned int i = 0; i < m.face.size(); ++i){
|
for(size_t i = 0; i < m.face.size(); ++i){
|
||||||
ATTR_TYPE * dest = &(*_handle)[i];
|
ATTR_TYPE * dest = &(*_handle)[i];
|
||||||
char * ptr = (char*)( ((SimpleTempDataBase *)pa._handle)->DataBegin());
|
char * ptr = (char*)( ((SimpleTempDataBase *)pa._handle)->DataBegin());
|
||||||
memcpy((void*)dest ,
|
memcpy((void*)dest ,
|
||||||
|
|
Loading…
Reference in New Issue