simple_volume.h
Go to the documentation of this file.
00001 #ifndef __VCG_SIMPLE_VOLUME
00002 #define __VCG_SIMPLE_VOLUME
00003 #include<vector>
00004 namespace vcg 
00005 {
00006 
00007 template <class VOX_TYPE>
00008 class SimpleVolume
00009 {
00010 public:
00011   typedef VOX_TYPE VoxelType;
00012   std::vector<VoxelType> Vol;
00013   
00014   Point3i sz;   
00015   
00016   const Point3i &ISize() {return sz;};   
00017         
00018   void Init(Point3i _sz)
00019   {
00020     sz=_sz;
00021     Vol.resize(sz[0]*sz[1]*sz[2]);
00022   }
00023 
00024   float Val(const int &x,const int &y,const int &z) const {
00025       return cV(x,y,z).V(); 
00026     //else return numeric_limits<float>::quiet_NaN( ); 
00027   }
00028 
00029   float &Val(const int &x,const int &y,const int &z) {
00030       return V(x,y,z).V(); 
00031     //else return numeric_limits<float>::quiet_NaN( ); 
00032   }
00033 
00034         VOX_TYPE &V(const int &x,const int &y,const int &z) {
00035                 return Vol[x+y*sz[0]+z*sz[0]*sz[1]]; 
00036         }
00037 
00038         const VOX_TYPE &cV(const int &x,const int &y,const int &z) const {
00039                 return Vol[x+y*sz[0]+z*sz[0]*sz[1]]; 
00040         }
00041 
00042 
00043 typedef enum { XAxis=0,YAxis=1,ZAxis=2} VolumeAxis;
00044 
00045 template < class VertexPointerType,  VolumeAxis AxisVal >
00046   void GetIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointerType &v, const float thr)
00047 {
00048                         float f1 = Val(p1.X(), p1.Y(), p1.Z())-thr;
00049                         float f2 = Val(p2.X(), p2.Y(), p2.Z())-thr;
00050                         float u = (float) f1/(f1-f2);
00051                         if(AxisVal==XAxis) v->P().X() = (float) p1.X()*(1-u) + u*p2.X();
00052                     else v->P().X() = (float) p1.X();
00053                         if(AxisVal==YAxis) v->P().Y() = (float) p1.Y()*(1-u) + u*p2.Y();
00054                                       else v->P().Y() = (float) p1.Y();
00055                         if(AxisVal==ZAxis) v->P().Z() = (float) p1.Z()*(1-u) + u*p2.Z();
00056                                       else v->P().Z() = (float) p1.Z();
00057 }
00058 
00059 template < class VertexPointerType >
00060   void GetXIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointerType &v, const float thr)
00061 { GetIntercept<VertexPointerType,XAxis>(p1,p2,v,thr); }
00062 
00063 template < class VertexPointerType >
00064   void GetYIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointerType &v, const float thr)
00065 { GetIntercept<VertexPointerType,YAxis>(p1,p2,v,thr); }
00066 
00067 template < class VertexPointerType >
00068   void GetZIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointerType &v, const float thr)
00069 { GetIntercept<VertexPointerType,ZAxis>(p1,p2,v,thr); }
00070 };
00071 template <class VolumeType>
00072 class RawVolumeImporter
00073 {
00074 public:
00075   enum DataType
00076 {
00077                 // Funzioni superiori
00078   UNDEF=0,
00079   BYTE=1,
00080   SHORT=2,
00081   FLOAT=3
00082 };
00083 
00084 static bool Open(const char *filename, VolumeType &V, Point3i sz, DataType d)
00085 {
00086 return true;
00087 }
00088 };
00089 
00090 class SimpleVoxel
00091 {
00092 private:
00093   float _v;
00094 public:
00095   float &V() {return _v;};
00096   float V() const {return _v;};
00097 };
00098 } // end namespace 
00099 #endif // __VCG_SIMPLE_VOLUME


shape_reconstruction
Author(s): Roberto Martín-Martín
autogenerated on Sat Jun 8 2019 18:35:23