1 /*=========================================================================
4 Module: $RCSfile: volume.hxx,v $
6 Date: $Date: 2009/01/26 11:22:49 $
7 Version: $Revision: 1.4 $
9 Copyright: (c) 2002, 2003
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notice for more information.
16 =========================================================================*/
18 #ifndef KGFO__VOLUME__HXX
19 #define KGFO__VOLUME__HXX
29 //#endif // KGFO_USE_IDO
32 #include <vtkImageData.h>
33 #endif // KGFO_USE_VTK
35 class creaMaracasVisu_EXPORT kVolume
39 enum Creator{ VTK, IDO, SELF };
40 enum Coord{ CX = 0, CY = 1, CZ = 2 };
41 enum Type{ CHAR = 0, FLOAT = 1, DOUBLE = 2,
42 INT = 3, SHORT = 4, UCHAR = 5,
43 UINT = 6, USHORT = 7 };
45 static const int SIZETypes[];
46 static const void* BLANK;
47 static const void* NOALLOC;
50 static const vtkIdType VTKTypes[];
52 #endif // KGFO_USE_VTK
55 // static const int IDOTypes[];
57 //#endif // KGFO_USE_IDO
64 uint xdim, uint ydim, uint zdim,
65 double xsize = 1, double ysize = 1, double zsize = 1,
72 kVolume( const kVolume& org );
73 kVolume& operator=( const kVolume& org );
74 void copyFrom( const kVolume& org );
76 virtual ~kVolume( ) { deallocate( ); }
78 Type getType( ) const { return( _type ); }
80 bool sameDimension( const kVolume& comp );
82 const uint* getDimensions( ) const { return( _dims ); }
83 uint getWidth( ) const { return( _dims[ CX ] ); }
84 uint getHeight( ) const { return( _dims[ CY ] ); }
85 uint getDepth( ) const { return( _dims[ CZ ] ); }
86 uint getNcols( ) const { return( _dims[ CX ] ); }
87 uint getNrows( ) const { return( _dims[ CY ] ); }
88 uint getNplanes( ) const { return( _dims[ CZ ] ); }
89 uint getXdim( ) const { return( _dims[ CX ] ); }
90 uint getYdim( ) const { return( _dims[ CY ] ); }
91 uint getZdim( ) const { return( _dims[ CZ ] ); }
93 void setDimensions( uint* dims )
95 memcpy( _dims, dims, 3 * sizeof( uint ) );
97 void setWidth( uint w ) { _dims[ CX ] = w; }
98 void setHeight( uint h ) { _dims[ CY ] = h; }
99 void setDepth( uint d ) { _dims[ CZ ] = d; }
100 void setNcols( uint c ) { _dims[ CX ] = c; }
101 void setNrows( uint r ) { _dims[ CY ] = r; }
102 void setNplanes( uint p ) { _dims[ CZ ] = p; }
103 void setXdim( uint x ) { _dims[ CX ] = x; }
104 void setYdim( uint y ) { _dims[ CY ] = y; }
105 void setZdim( uint z ) { _dims[ CZ ] = z; }
107 const double *getSizes( ) const { return( _sizes ); }
108 double getXsize( ) const { return( _sizes[ CX ] ); }
109 double getYsize( ) const { return( _sizes[ CY ] ); }
110 double getZsize( ) const { return( _sizes[ CZ ] ); }
112 void setSizes( double* sizes )
114 memcpy( _sizes, sizes, 3 * sizeof( double ) );
116 void setXsize( double x ) { _sizes[ CX ] = x; }
117 void setYsize( double y ) { _sizes[ CY ] = y; }
118 void setZsize( double z ) { _sizes[ CZ ] = z; }
120 void* getData1D( ) { return( _raw ); }
121 const void* getData1D( ) const { return( _raw ); }
123 void** getData2D( ) { return( _columns ); }
124 void** const getData2D( ) const { return( _columns ); }
126 void*** getData3D( ) { return( _images ); }
127 void*** const getData3D( ) const { return( _images ); }
129 void reset( ) { memset( _raw, 0, getRawSizeInBytes( ) ); }
131 ulong getRawSize( ) const
133 return( ( ulong )_dims[ CX ] *
134 ( ulong )_dims[ CY ] *
135 ( ulong )_dims[ CZ ] );
137 ulong getRawSizeInBytes( ) const
139 return( SIZETypes[ _type ] * getRawSize( ) );
142 double getPixel( uint x, uint y, uint z ) const;
143 void setPixel( double v, uint x, uint y, uint z );
145 void convertCast( Type type );
146 void convertScale( Type type, double min, double max );
147 void normalize( double min, double max )
149 convertScale( _type, min, max );
152 void getMinMax( double& min, double& max ) const;
153 double getMin( ) const;
154 double getMax( ) const;
155 //double GetMaxIntSphere( double* p, const double r ) const;
156 unsigned short GetMaxIntSphere2( double* p, const double r );
180 * Creators/copiers from a vtkImageData object.
181 * C++ creators allows you to create a kVolume cast to you vtkImageData
182 * object, but if extent != bounds, you can expect a weird behaviour.
183 * If you want to forget all about extents, then crop your volume or
184 * use either the operator= or the copyFrom method.
186 kVolume( vtkImageData* org );
187 kVolume& operator=( vtkImageData* org );
188 void copyFrom( vtkImageData* org );
190 vtkImageData* castVtk( ) const { return( _vtk ); }
191 operator vtkImageData*( ) const { return( _vtk ); }
197 #endif // KGFO_USE_VTK
200 //#ifdef KGFO_USE_IDO
204 // kVolume( PPPVOLUME org );
206 // kVolume& operator=( PPPVOLUME org );
207 // void copyFrom( PPPVOLUME org );
209 // PPPVOLUME castIdo( ) const
211 // return( ( PPPVOLUME )( &_privateIdo[ 1 ] ) );
213 // operator PPPVOLUME( ) const
215 // return( ( PPPVOLUME )( &_privateIdo[ 1 ] ) );
217 // operator PPPVOLUME_CHAR( ) const
219 // return( ( PPPVOLUME_CHAR )( &_privateIdo[ 1 ] ) );
221 // operator PPPVOLUME_FLOAT( ) const
223 // return( ( PPPVOLUME_FLOAT )( &_privateIdo[ 1 ] ) );
225 // operator PPPVOLUME_DOUBLE( ) const
227 // return( ( PPPVOLUME_DOUBLE )( &_privateIdo[ 1 ] ) );
229 // operator PPPVOLUME_LONG( ) const
231 // return( ( PPPVOLUME_LONG )( &_privateIdo[ 1 ] ) );
233 // operator PPPVOLUME_SHORT( ) const
235 // return( ( PPPVOLUME_SHORT )( &_privateIdo[ 1 ] ) );
237 // operator PPPVOLUME_UCHAR( ) const
239 // return( ( PPPVOLUME_UCHAR )( &_privateIdo[ 1 ] ) );
241 // operator PPPVOLUME_ULONG( ) const
243 // return( ( PPPVOLUME_ULONG )( &_privateIdo[ 1 ] ) );
245 // operator PPPVOLUME_USHORT( ) const
247 // return( ( PPPVOLUME_USHORT )( &_privateIdo[ 1 ] ) );
252 // PRIVATE_VOLUME* _privateIdo;
254 //#endif // KGFO_USE_IDO
257 #endif // KGFO__VOLUME__HXX