Cleaned up a bit for better handling of point clouds

This commit is contained in:
Paolo Cignoni 2013-09-11 11:11:10 +00:00
parent 646a31972f
commit 58471132ba
1 changed files with 104 additions and 144 deletions

View File

@ -20,44 +20,6 @@
* for more details. *
* *
****************************************************************************/
/****************************************************************************
History
$Log: not supported by cvs2svn $
Revision 1.11 2006/06/08 13:55:16 cignoni
Added ColorPreserving Cellbase template.
Revision 1.10 2006/05/26 10:18:11 cignoni
Re-adapted to ms compilers
Revision 1.9 2006/05/25 09:37:14 cignoni
Many changes for the different interpretation of hash_set between gcc and .net. Probably to be completed.
Revision 1.8 2006/05/24 16:42:22 m_di_benedetto
Corrected bbox inflation amount in case of _cellsize != 0
Revision 1.7 2006/05/24 15:16:01 cignoni
better comment to the init parameters
Revision 1.6 2006/05/24 08:54:04 cignoni
Added missing std:: to swap
Revision 1.5 2006/05/21 06:40:31 cignoni
Added DoubleFace management
Revision 1.4 2006/05/19 20:49:03 m_di_benedetto
Added check for empty generated mesh (prevent call to mesh allocator with zero vertices or faces).
Revision 1.3 2006/05/18 22:20:53 m_di_benedetto
added check for deleted faces and modified/added std namespace qualifier.
Revision 1.2 2006/05/18 13:59:20 cignoni
Some minor optimizations
Revision 1.1 2006/05/16 21:56:06 cignoni
First working Version
****************************************************************************/
#ifndef __VCGLIB_CLUSTERING
#define __VCGLIB_CLUSTERING
@ -129,7 +91,7 @@ class NearestToCenter
typedef typename MeshType::FaceType FaceType;
typedef BasicGrid<typename MeshType::ScalarType> GridType;
public:
public:
inline void AddVertex(MeshType &/*m*/, GridType &g, Point3i &pi, VertexType &v)
{
CoordType c;
@ -164,8 +126,6 @@ class NearestToCenter
};
template<class MeshType>
class AverageColorCell
{
@ -175,7 +135,7 @@ class AverageColorCell
typedef BasicGrid<typename MeshType::ScalarType> GridType;
public:
public:
inline void AddFaceVertex(MeshType &/*m*/, FaceType &f, int i)
{
p+=f.cV(i)->cP();
@ -186,10 +146,11 @@ class AverageColorCell
n+=f.cN();
cnt++;
}
inline void AddVertex(MeshType &/*m*/, GridType &/*g*/, Point3i &/*pi*/, VertexType &v)
inline void AddVertex(MeshType &m, GridType &/*g*/, Point3i &/*pi*/, VertexType &v)
{
p+=v.cP();
n+=v.cN();
if(tri::HasPerVertexColor(m))
c+=CoordType(v.C()[0],v.C()[1],v.C()[2]);
cnt++;
}
@ -300,7 +261,6 @@ class Clustering
Grid.voxel[2] = Grid.dim[2]/Grid.siz[2];
}
BasicGrid<ScalarType> Grid;
#ifdef _MSC_VER
@ -379,6 +339,7 @@ class Clustering
{
m.vert[i].P()=(*gi).second.Pos();
m.vert[i].N()=(*gi).second.N();
if(HasPerVertexColor(m))
m.vert[i].C()=(*gi).second.Col();
++i;
}
@ -389,10 +350,7 @@ class Clustering
{
m.Clear();
if (TriSet.empty() || GridCell.empty())
{
return;
}
if (GridCell.empty()) return;
Allocator<MeshType>::AddVertices(m,GridCell.size());
typename STDEXT::hash_map<HashedPoint3i,CellType>::iterator gi;
@ -400,11 +358,13 @@ class Clustering
for(gi=GridCell.begin();gi!=GridCell.end();++gi)
{
m.vert[i].P()=(*gi).second.Pos();
if(m.vert[i].HasColor())
m.vert[i].N()=(*gi).second.N();
if(HasPerVertexColor(m))
m.vert[i].C()=(*gi).second.Col();
(*gi).second.id=i;
++i;
}
Allocator<MeshType>::AddFaces(m,TriSet.size());
TriHashSetIterator ti;
i=0;