1 /*=========================================================================
4 Module: $RCSfile: volume.hxx,v $
6 Date: $Date: 2010/04/29 16:05:37 $
7 Version: $Revision: 1.8 $
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
25 #include <vtkImageData.h>
26 #endif // KGFO_USE_VTK
28 class creaMaracasVisu_EXPORT kVolume
32 enum Creator{ VTK, IDO, SELF };
33 enum Coord{ CX = 0, CY = 1, CZ = 2 };
34 enum Type{ CHAR = 0, FLOAT = 1, DOUBLE = 2,
35 INT = 3, SHORT = 4, UCHAR = 5,
36 UINT = 6, USHORT = 7 };
38 static const int SIZETypes[];
39 static const void* BLANK;
40 static const void* NOALLOC;
43 static const vtkIdType VTKTypes[];
45 #endif // KGFO_USE_VTK
52 uint32_t xdim, uint32_t ydim, uint32_t zdim,
53 double xsize = 1, double ysize = 1, double zsize = 1,
60 kVolume( const kVolume& org );
61 kVolume& operator=( const kVolume& org );
62 void copyFrom( const kVolume& org );
64 virtual ~kVolume( ) { deallocate( ); }
66 Type getType( ) const { return( _type ); }
68 bool sameDimension( const kVolume& comp );
70 const uint32_t* getDimensions( ) const { return( _dims ); }
71 uint32_t getWidth( ) const { return( _dims[ CX ] ); }
72 uint32_t getHeight( ) const { return( _dims[ CY ] ); }
73 uint32_t getDepth( ) const { return( _dims[ CZ ] ); }
74 uint32_t getNcols( ) const { return( _dims[ CX ] ); }
75 uint32_t getNrows( ) const { return( _dims[ CY ] ); }
76 uint32_t getNplanes( ) const { return( _dims[ CZ ] ); }
77 uint32_t getXdim( ) const { return( _dims[ CX ] ); }
78 uint32_t getYdim( ) const { return( _dims[ CY ] ); }
79 uint32_t getZdim( ) const { return( _dims[ CZ ] ); }
81 void setDimensions( uint32_t* dims )
83 memcpy( _dims, dims, 3 * sizeof( uint32_t ) );
85 void setWidth( uint32_t w ) { _dims[ CX ] = w; }
86 void setHeight( uint32_t h ) { _dims[ CY ] = h; }
87 void setDepth( uint32_t d ) { _dims[ CZ ] = d; }
88 void setNcols( uint32_t c ) { _dims[ CX ] = c; }
89 void setNrows( uint32_t r ) { _dims[ CY ] = r; }
90 void setNplanes( uint32_t p ) { _dims[ CZ ] = p; }
91 void setXdim( uint32_t x ) { _dims[ CX ] = x; }
92 void setYdim( uint32_t y ) { _dims[ CY ] = y; }
93 void setZdim( uint32_t z ) { _dims[ CZ ] = z; }
95 const double *getSizes( ) const { return( _sizes ); }
96 double getXsize( ) const { return( _sizes[ CX ] ); }
97 double getYsize( ) const { return( _sizes[ CY ] ); }
98 double getZsize( ) const { return( _sizes[ CZ ] ); }
100 void setSizes( double* sizes )
102 memcpy( _sizes, sizes, 3 * sizeof( double ) );
104 void setXsize( double x ) { _sizes[ CX ] = x; }
105 void setYsize( double y ) { _sizes[ CY ] = y; }
106 void setZsize( double z ) { _sizes[ CZ ] = z; }
108 void* getData1D( ) { return( _raw ); }
109 const void* getData1D( ) const { return( _raw ); }
111 void** getData2D( ) { return( _columns ); }
112 void** const getData2D( ) const { return( _columns ); }
114 void*** getData3D( ) { return( _images ); }
115 void*** const getData3D( ) const { return( _images ); }
117 void reset( ) { memset( _raw, 0, getRawSizeInBytes( ) ); }
119 ulong getRawSize( ) const
121 return( ( ulong )_dims[ CX ] *
122 ( ulong )_dims[ CY ] *
123 ( ulong )_dims[ CZ ] );
125 ulong getRawSizeInBytes( ) const
127 return( SIZETypes[ _type ] * getRawSize( ) );
130 double getPixel( uint x, uint y, uint z ) const;
131 void setPixel( double v, uint x, uint y, uint z );
133 void convertCast( Type type );
134 void convertScale( Type type, double min, double max );
135 void normalize( double min, double max )
137 convertScale( _type, min, max );
140 void getMinMax( double& min, double& max ) const;
141 double getMin( ) const;
142 double getMax( ) const;
143 //double GetMaxIntSphere( double* p, const double r ) const;
144 unsigned short GetMaxIntSphere2( double* p, const double r );
168 * Creators/copiers from a vtkImageData object.
169 * C++ creators allows you to create a kVolume cast to you vtkImageData
170 * object, but if extent != bounds, you can expect a weird behaviour.
171 * If you want to forget all about extents, then crop your volume or
172 * use either the operator= or the copyFrom method.
174 kVolume( vtkImageData* org );
175 kVolume& operator=( vtkImageData* org );
176 void copyFrom( vtkImageData* org );
178 vtkImageData* castVtk( ) const { return( _vtk ); }
179 operator vtkImageData*( ) const { return( _vtk ); }
185 #endif // KGFO_USE_VTK
189 #endif // KGFO__VOLUME__HXX