Small change to the init of the simple volume class to include the correct initialization of the actual space occuped by the volume

This commit is contained in:
Paolo Cignoni 2014-08-13 06:48:20 +00:00
parent 181cef32fa
commit 211274ab04
2 changed files with 26 additions and 34 deletions

View File

@ -63,16 +63,6 @@ namespace vcg
{
public:
enum Dimension {X, Y, Z};
#if defined(__GNUC__)
typedef unsigned int size_t;
#else
#ifdef _WIN64
typedef unsigned __int64 size_t;
#else
typedef _W64 unsigned int size_t;
#endif
#endif
typedef typename vcg::tri::Allocator< TRIMESH_TYPE > AllocatorType;
typedef typename TRIMESH_TYPE::ScalarType ScalarType;
typedef typename TRIMESH_TYPE::VertexType VertexType;

View File

@ -97,10 +97,12 @@ public:
void Init(Point3i _sz)
void Init(Point3i _sz, Box3x bb)
{
siz=_sz;
this->bbox = bb;
Vol.resize(siz[0]*siz[1]*siz[2]);
this->ComputeDimAndVoxel();
}
@ -178,36 +180,36 @@ private:
template<class EXTRACTOR_TYPE>
void BuildMesh(MeshType &mesh, VolumeType &volume, EXTRACTOR_TYPE &extractor, const float threshold, vcg::CallBackPos * cb=0)
{
{
Init(volume);
_volume = &volume;
_mesh = &mesh;
_mesh->Clear();
_volume = &volume;
_mesh = &mesh;
_mesh->Clear();
_thr=threshold;
vcg::Point3i p1, p2;
vcg::Point3i p1, p2;
Begin();
extractor.Initialize();
for (int j=_bbox.min.Y(); j<(_bbox.max.Y()-1)-1; j+=1)
Begin();
extractor.Initialize();
for (int j=_bbox.min.Y(); j<(_bbox.max.Y()-1)-1; j+=1)
{
if(cb && ((j%10)==0) ) cb(j*_bbox.DimY()/100.0,"Marching volume");
for (int i=_bbox.min.X(); i<(_bbox.max.X()-1)-1; i+=1)
{
for (int k=_bbox.min.Z(); k<(_bbox.max.Z()-1)-1; k+=1)
{
p1.X()=i; p1.Y()=j; p1.Z()=k;
p2.X()=i+1; p2.Y()=j+1; p2.Z()=k+1;
for (int i=_bbox.min.X(); i<(_bbox.max.X()-1)-1; i+=1)
{
for (int k=_bbox.min.Z(); k<(_bbox.max.Z()-1)-1; k+=1)
{
p1.X()=i; p1.Y()=j; p1.Z()=k;
p2.X()=i+1; p2.Y()=j+1; p2.Z()=k+1;
extractor.ProcessCell(p1, p2);
}
}
NextSlice();
}
extractor.Finalize();
_volume = NULL;
_mesh = NULL;
};
}
NextSlice();
}
extractor.Finalize();
_volume = NULL;
_mesh = NULL;
}
float V(int pi, int pj, int pk)
{
@ -354,6 +356,6 @@ protected:
}
};
} // end namespace
} // end namespace
} // end namespace tri
} // end namespace vcg
#endif // __VCGTEST_WALKER