Just refactored a bit the simple volume class used for example in the marching cube
This commit is contained in:
parent
773e2bdb1e
commit
7c93452e94
|
@ -33,18 +33,9 @@ class SimpleVolume : public BasicGrid<float>
|
|||
{
|
||||
public:
|
||||
typedef VOX_TYPE VoxelType;
|
||||
std::vector<VoxelType> Vol;
|
||||
|
||||
// Point3i siz; /// Dimensioni griglia come numero di celle per lato
|
||||
|
||||
const Point3i &ISize() {return siz;} /// Dimensioni griglia come numero di celle per lato
|
||||
|
||||
void Init(Point3i _sz)
|
||||
{
|
||||
siz=_sz;
|
||||
Vol.resize(siz[0]*siz[1]*siz[2]);
|
||||
}
|
||||
|
||||
float Val(const int &x,const int &y,const int &z) const {
|
||||
return cV(x,y,z).V();
|
||||
//else return numeric_limits<float>::quiet_NaN( );
|
||||
|
@ -68,6 +59,23 @@ public:
|
|||
}
|
||||
|
||||
|
||||
template < class VertexPointerType >
|
||||
void GetXIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointerType &v, const float thr)
|
||||
{ GetIntercept<VertexPointerType,XAxis>(p1,p2,v,thr); }
|
||||
|
||||
template < class VertexPointerType >
|
||||
void GetYIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointerType &v, const float thr)
|
||||
{ GetIntercept<VertexPointerType,YAxis>(p1,p2,v,thr); }
|
||||
|
||||
template < class VertexPointerType >
|
||||
void GetZIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointerType &v, const float thr)
|
||||
{ GetIntercept<VertexPointerType,ZAxis>(p1,p2,v,thr); }
|
||||
|
||||
/// The following members/methods are just for this particular case.
|
||||
/// The above one are the one required by the marching cube interface.
|
||||
|
||||
std::vector<VoxelType> Vol;
|
||||
|
||||
typedef enum { XAxis=0,YAxis=1,ZAxis=2} VolumeAxis;
|
||||
|
||||
template < class VertexPointerType, VolumeAxis AxisVal >
|
||||
|
@ -86,17 +94,16 @@ public:
|
|||
if(VoxelType::HasNormal()) v->N() = V(p1).N()*(1-u) + V(p2).N()*u;
|
||||
}
|
||||
|
||||
template < class VertexPointerType >
|
||||
void GetXIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointerType &v, const float thr)
|
||||
{ GetIntercept<VertexPointerType,XAxis>(p1,p2,v,thr); }
|
||||
|
||||
template < class VertexPointerType >
|
||||
void GetYIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointerType &v, const float thr)
|
||||
{ GetIntercept<VertexPointerType,YAxis>(p1,p2,v,thr); }
|
||||
|
||||
template < class VertexPointerType >
|
||||
void GetZIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointerType &v, const float thr)
|
||||
{ GetIntercept<VertexPointerType,ZAxis>(p1,p2,v,thr); }
|
||||
void Init(Point3i _sz)
|
||||
{
|
||||
siz=_sz;
|
||||
Vol.resize(siz[0]*siz[1]*siz[2]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
class SimpleVoxel
|
||||
|
|
Loading…
Reference in New Issue