plastimatch
Loading...
Searching...
No Matches
volume.h
Go to the documentation of this file.
1/* -----------------------------------------------------------------------
2 See COPYRIGHT.TXT and LICENSE.TXT for copyright and license information
3 ----------------------------------------------------------------------- */
4#ifndef _volume_h_
5#define _volume_h_
6
7#include "plmbase_config.h"
8
9#include "direction_cosines.h"
10#include "plm_int.h"
11#include "smart_pointer.h"
12#include "volume_macros.h"
13
14class Volume_header;
16
29
38{
39public:
41public:
42 plm_long dim[3]; // x, y, z Dims
43 plm_long npix; // # of voxels in volume
44 // = dim[0] * dim[1] * dim[2]
45 float origin[3];
46 float spacing[3];
48
49 enum Volume_pixel_type pix_type; // Voxel Data type
50 int vox_planes; // # planes per voxel
51 int pix_size; // # bytes per voxel
52 void* img; // Voxel Data
53
54public:
55 float step[9]; // direction_cosines * spacing
56 float proj[9]; // inv direction_cosines / spacing
57
58public:
59 Volume ();
60 Volume (
61 const plm_long dim[3],
62 const float origin[3],
63 const float spacing[3],
64 const float direction_cosines[9],
65 enum Volume_pixel_type vox_type,
66 int vox_planes
67 );
68 Volume (
69 const plm_long dim[3],
70 const float origin[3],
71 const float spacing[3],
72 const Direction_cosines& direction_cosines,
73 enum Volume_pixel_type vox_type,
74 int vox_planes
75 );
76 Volume (
77 const Volume_header& vh,
78 enum Volume_pixel_type vox_type,
79 int vox_planes
80 );
81 ~Volume ();
82public:
84 plm_long index (plm_long i, plm_long j, plm_long k) const {
85 return volume_index (this->dim, i, j, k);
86 }
88 plm_long index (plm_long ijk[3]) const {
89 return volume_index (this->dim, ijk);
90 }
92 void create (
93 const plm_long new_dim[3],
94 const float origin[3],
95 const float spacing[3],
96 const float direction_cosines[9],
97 enum Volume_pixel_type vox_type,
98 int vox_planes = 1
99 );
101 void create (
102 const Volume_header& vh,
103 enum Volume_pixel_type vox_type,
104 int vox_planes = 1
105 );
107 Volume::Pointer clone ();
108
112 Volume::Pointer clone (Volume_pixel_type new_type) const;
113
116 Volume::Pointer clone_empty ();
117
119 void convert (Volume_pixel_type new_type);
120
125 const float* get_origin (void) const;
126 void get_origin (float *) const;
131 void set_origin (const float origin[3]);
133 const plm_long *get_dim (void) {
134 return dim;
135 }
139 const float* get_spacing (void) const;
140 void get_spacing (float *) const;
144 void set_spacing (const float spacing[3]);
152 return direction_cosines;
153 }
155 return direction_cosines;
156 }
157 float* get_direction_matrix (void) {
158 return direction_cosines.get_matrix();
159 }
160 const float* get_direction_matrix (void) const {
161 return direction_cosines.get_matrix();
162 }
169 void set_direction_cosines (const float direction_cosines[9]);
170
174 void set_header (const Volume_header&);
175 void set_header (const Plm_image_header *);
176
180 template<class T> T* get_raw ();
181 template<class T> const T* get_raw () const;
182
187 const float* get_step (void) const;
192 const float* get_proj (void) const;
193
195 void position (float xyz[3], const plm_long ijk[3]) {
196 POSITION_FROM_COORDS (xyz, ijk, this->origin, this->step);
197 }
198
200 void coordinates (plm_long ijk[3], plm_long idx) {
201 COORDS_FROM_INDEX(ijk, idx, this->dim);
202 }
203
207 float get_ijk_value (const float xyz[3]) const;
208 void get_xyz_from_ijk (double xyz[3], const plm_long ijk[3]);
209
210 plm_long get_idx_from_xyz (const float xyz[3], bool* in);
211 void get_ijk_from_xyz (plm_long ijk[3], const float xyz[3], bool* in);
212 void get_ijk_from_xyz (float ijk[3], const float xyz[3], bool* in);
213
215 bool is_inside (const float ijk[3]) const;
216
220 void move_origin_to_idx (const plm_long ijk[3]);
221
224 void scale_inplace (float scale);
225
226 void debug ();
227 void direction_cosines_debug ();
228protected:
229 void allocate (void);
230 void init ();
231public:
232 /* Some day, these should become protected */
233 Volume* clone_raw ();
234private:
235 Volume (const Volume&);
236 void operator= (const Volume&);
237};
238
241PLMBASE_C_API void vf_pad_planar (Volume* vol, int size); // deprecated?
251PLMBASE_C_API void volume_matrix3x3inverse (float *out, const float *m);
252
253#endif
Definition direction_cosines.h:23
const float * get_matrix() const
Definition direction_cosines.cxx:188
The Plm_image_header class defines the geometry of an image. It defines image origin,...
Definition plm_image_header.h:24
Definition volume_header.h:17
The Volume class represents a three-dimensional volume on a uniform grid. The volume can be located a...
Definition volume.h:38
void coordinates(plm_long ijk[3], plm_long idx)
Return coordinates from index.
Definition volume.h:200
const Direction_cosines & get_direction_cosines(void) const
Definition volume.h:154
int pix_size
Definition volume.h:51
plm_long index(plm_long i, plm_long j, plm_long k) const
Return a linear index to a voxel.
Definition volume.h:84
SMART_POINTER_SUPPORT(Volume)
Direction_cosines & get_direction_cosines(void)
Get a pointer to the direction cosines. Direction cosines hold the orientation of a volume....
Definition volume.h:151
Direction_cosines direction_cosines
Definition volume.h:47
enum Volume_pixel_type pix_type
Definition volume.h:49
plm_long npix
Definition volume.h:43
float * get_direction_matrix(void)
Definition volume.h:157
const float * get_direction_matrix(void) const
Definition volume.h:160
void * img
Definition volume.h:52
void position(float xyz[3], const plm_long ijk[3])
Return a world coordinates of a voxel.
Definition volume.h:195
const plm_long * get_dim(void)
Get a pointer to the volume dimensions.
Definition volume.h:133
int vox_planes
Definition volume.h:50
plm_long index(plm_long ijk[3]) const
Return a linear index to a voxel.
Definition volume.h:88
#define PLMBASE_API
Definition plmbase_config.h:19
#define PLMBASE_C_API
Definition plmbase_config.h:18
EXTERNC void volume_convert_to_int32(Volume *ref)
Definition volume.cxx:542
EXTERNC void volume_convert_to_short(Volume *ref)
Definition volume.cxx:412
EXTERNC void volume_convert_to_float(Volume *ref)
Definition volume.cxx:379
Volume_pixel_type
Definition volume.h:17
@ PT_UCHAR
Definition volume.h:19
@ PT_UINT16
Definition volume.h:20
@ PT_UNDEFINED
Definition volume.h:18
@ PT_UCHAR_VEC_INTERLEAVED
Definition volume.h:27
@ PT_SHORT
Definition volume.h:21
@ PT_FLOAT
Definition volume.h:24
@ PT_UINT32
Definition volume.h:22
@ PT_VF_FLOAT_INTERLEAVED
Definition volume.h:25
@ PT_VF_FLOAT_PLANAR
Definition volume.h:26
@ PT_INT32
Definition volume.h:23
EXTERNC void volume_convert_to_uchar(Volume *ref)
Definition volume.cxx:443
EXTERNC void vf_convert_to_planar(Volume *ref)
Definition volume.cxx:621
EXTERNC Volume * volume_difference(Volume *vol, Volume *warped)
Definition volume.cxx:1012
EXTERNC void vf_pad_planar(Volume *vol, int size)
EXTERNC Volume * volume_clone(const Volume *ref)
Definition volume.cxx:335
EXTERNC Volume * volume_clone_empty(Volume *ref)
Definition volume.cxx:326
EXTERNC void volume_matrix3x3inverse(float *out, const float *m)
EXTERNC void volume_convert_to_uint32(Volume *ref)
Definition volume.cxx:508
EXTERNC void volume_convert_to_uint16(Volume *ref)
Definition volume.cxx:476
EXTERNC void vf_convert_to_interleaved(Volume *ref)
Definition volume.cxx:576
static plm_long volume_index(const plm_long dims[3], plm_long i, plm_long j, plm_long k)
Definition volume_macros.h:14
#define POSITION_FROM_COORDS(xyz, ijk, origin, step)
Definition volume_macros.h:82
#define COORDS_FROM_INDEX(ijk, idx, dim)
Definition volume_macros.h:33