MeVisLab Toolbox Reference
CSOVoxelSet.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 
15 
16 #pragma once
17 
18 
19 #include "MLCSOIncludes.h"
20 #include <CSOBase/CSODefines.h>
21 
22 ML_START_NAMESPACE
23 
24 
25 typedef std::vector<Vector3> VoxelVector;
26 typedef std::vector<MLdouble> VoxelValueVector;
27 
28 
29 // Forward declaration.
30 class CSOVoxelSetList;
31 
32 
34 
36 {
37 public:
38 
39  int x = -1;
40  int y = -1;
41 };
42 
44 
50 {
51 
52 public:
53 
57  CSOVoxelSet(const CSOVoxelSet &csoVoxelSet);
59  virtual ~CSOVoxelSet();
60 
61  /* METHODS */
62 
64  void addVoxelValuePositions(const std::vector<Vector3>& positions, const std::vector<MLdouble>& values);
66  void addVoxelValuePositions(const std::vector<VoxelPosition>& positions, const std::vector<MLdouble>& values);
68  size_t numTotalVoxels() const;
70  Vector3 getVoxelPositionOfTotal(size_t index) const;
72  double getVoxelValueOfTotal(size_t index) const;
73 
75  inline void setVoxelToWorldMatrix(const Matrix4& voxelToWorldMatrix) { _voxelToWorldMatrix = voxelToWorldMatrix; }
77  inline const Matrix4& getVoxelToWorldMatrix() const { return _voxelToWorldMatrix; }
78 
80  size_t numSlices() const;
82  unsigned int startingSlice() const;
84  unsigned int endingSlice() const;
86  const VoxelVector& getPositionsAt(size_t index) const;
88  const VoxelValueVector& getValuesAt(size_t index) const;
90  unsigned int numVoxelsOnSliceAt(size_t sliceIndex) const;
92  Vector3 getVoxelPositionAtSlice(size_t sliceIndex, size_t voxelIndex) const;
94  void getVoxelPositionAtSlice(size_t sliceIndex, size_t voxelIndex, int& x, int& y);
96  bool getVoxelValueAtSlice(size_t sliceIndex, size_t voxelIndex, double& val) const;
98  inline Vector3 getBoundingBoxV1() const { return _boundingBoxV1; }
100  inline Vector3 getBoundingBoxV2() const { return _boundingBoxV2; }
102  inline MLdouble getMinVoxelValue() const { return _minVoxelValue; }
104  inline MLdouble getMaxVoxelValue() const { return _maxVoxelValue; }
105 
107  inline void setCSOVoxelSetList(CSOVoxelSetList* list) { _csoVoxelSetList = list; }
109  inline CSOVoxelSetList* csoVoxelSetList() const { return _csoVoxelSetList; }
111  inline unsigned int numGroups() const { return static_cast<unsigned int>(_groupIds.size()); }
113  inline int groupIdAt(size_t index) const { return _groupIds[index]; }
115  inline void addCSOVoxelSetGroupId(int groupId) { _groupIds.push_back(groupId); }
116 
118  inline void setLabel(const std::string& labelArg) { _label = labelArg; }
120  inline const std::string& label() const { return _label; }
122  inline void setCreator(const std::string& creatorArg) { _creator = creatorArg; }
124  inline const std::string& creator() const { return _creator; }
126  inline void setTimepoint(int timepointArg) { _timepoint = timepointArg; }
128  inline int timepoint() const { return _timepoint; }
130  inline void setDescription(const std::string& descriptionArg) { _description = descriptionArg; }
132  inline const std::string& description() const { return _description; }
133 
134 
136  inline void setUniqueId(int id) { _uniqueId = id; }
138  inline int uniqueId() const { return _uniqueId; }
139 
140 
141 protected:
142 
143 private:
144 
145  /* MEMBER VARIABLES */
146 
147  std::vector<VoxelVector> _sliceVoxels;
148  std::vector<VoxelValueVector> _sliceVoxelValues;
149 
150  int _startingSlice;
151  int _endingSlice;
152 
153  int _uniqueId;
154  std::string _label;
155  std::string _description;
156  std::string _creator;
157  int _timepoint;
158 
159  Matrix4 _voxelToWorldMatrix;
160 
161  Vector3 _boundingBoxV1;
162  Vector3 _boundingBoxV2;
163 
164  std::vector<int> _groupIds;
165 
166  CSOVoxelSetList* _csoVoxelSetList;
167 
168  MLdouble _minVoxelValue;
169  MLdouble _maxVoxelValue;
170 
171  /* METHODS */
172 
174  void _sortToSlices(const std::vector<Vector3>& positions, const std::vector<MLdouble>& values);
175 };
176 
178 
179 ML_END_NAMESPACE
#define MLCSO_EXPORT
Defines export symbols for classes, so they can be used in other DLLs.
Definition: MLCSOSystem.h:23
The CSOVoxelSet represents a contour segmentation object in discrete voxel coordinates.
Definition: CSOVoxelSet.h:50
void setCSOVoxelSetList(CSOVoxelSetList *list)
Sets the CSOVoxelSetList pointer.
Definition: CSOVoxelSet.h:107
CSOVoxelSet()
Standard constructor. The unique id is initialized with 0.
void setCreator(const std::string &creatorArg)
Sets the creator.
Definition: CSOVoxelSet.h:122
void getVoxelPositionAtSlice(size_t sliceIndex, size_t voxelIndex, int &x, int &y)
Fills up the given x and y variables by a voxel position on a certain slice at a certain index.
const std::string & label() const
Returns the label.
Definition: CSOVoxelSet.h:120
MLdouble getMinVoxelValue() const
Returns the minimum voxel value.
Definition: CSOVoxelSet.h:102
Vector3 getVoxelPositionOfTotal(size_t index) const
Returns a voxel position regardless of its slice.
void addVoxelValuePositions(const std::vector< VoxelPosition > &positions, const std::vector< MLdouble > &values)
Adds a vector of positions at once (MLint).
void addCSOVoxelSetGroupId(int groupId)
Adds an id of a Group.
Definition: CSOVoxelSet.h:115
const VoxelValueVector & getValuesAt(size_t index) const
Returns the list of values at a given index.
bool getVoxelValueAtSlice(size_t sliceIndex, size_t voxelIndex, double &val) const
Returns a voxel value for a given slice at a given index.
unsigned int numVoxelsOnSliceAt(size_t sliceIndex) const
Returns the number of voxels for the given slice.
Vector3 getBoundingBoxV2() const
Returns the max bounding box corner.
Definition: CSOVoxelSet.h:100
void addVoxelValuePositions(const std::vector< Vector3 > &positions, const std::vector< MLdouble > &values)
Adds a vector of positions at once (double).
int timepoint() const
Returns the timepoint.
Definition: CSOVoxelSet.h:128
void setDescription(const std::string &descriptionArg)
Sets the description.
Definition: CSOVoxelSet.h:130
int groupIdAt(size_t index) const
Returns the id of a Group at the given index.
Definition: CSOVoxelSet.h:113
const std::string & description() const
Returns the description.
Definition: CSOVoxelSet.h:132
Vector3 getVoxelPositionAtSlice(size_t sliceIndex, size_t voxelIndex) const
Returns a voxel position for a given slice at a given index.
const std::string & creator() const
Returns the creator.
Definition: CSOVoxelSet.h:124
unsigned int endingSlice() const
Returns the ending slice.
MLdouble getMaxVoxelValue() const
Returns the maximum voxel value.
Definition: CSOVoxelSet.h:104
const VoxelVector & getPositionsAt(size_t index) const
Returns the list of positions at a given index.
unsigned int numGroups() const
Returns the number of Groups this is in.
Definition: CSOVoxelSet.h:111
const Matrix4 & getVoxelToWorldMatrix() const
Returns the voxel-to-world matrix.
Definition: CSOVoxelSet.h:77
Vector3 getBoundingBoxV1() const
Returns the min bounding box corner.
Definition: CSOVoxelSet.h:98
void setLabel(const std::string &labelArg)
Sets the label.
Definition: CSOVoxelSet.h:118
int uniqueId() const
Returns the unique id.
Definition: CSOVoxelSet.h:138
virtual ~CSOVoxelSet()
Standard destructor.
CSOVoxelSetList * csoVoxelSetList() const
Returns the CSOVoxelSetList pointer.
Definition: CSOVoxelSet.h:109
double getVoxelValueOfTotal(size_t index) const
Returns a voxel value regardless of its slice.
void setUniqueId(int id)
Sets the unique id.
Definition: CSOVoxelSet.h:136
size_t numTotalVoxels() const
Returns the number of total voxel positions.
size_t numSlices() const
Returns the number of slices the voxels are spread over.
void setVoxelToWorldMatrix(const Matrix4 &voxelToWorldMatrix)
Sets the voxel-to-world matrix.
Definition: CSOVoxelSet.h:75
unsigned int startingSlice() const
Returns the starting slice.
void setTimepoint(int timepointArg)
Sets the timepoint.
Definition: CSOVoxelSet.h:126
CSOVoxelSet(const CSOVoxelSet &csoVoxelSet)
Copy constructor; the unique id is initialized with 0.
double MLdouble
Definition: mlTypeDefs.h:223
std::vector< MLdouble > VoxelValueVector
Definition: CSOVoxelSet.h:26
std::vector< Vector3 > VoxelVector
Definition: CSOVoxelSet.h:25