Slicer  4.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLMeasurement.h
Go to the documentation of this file.
1 /*=auto=========================================================================
2 
3 Portions (c) Copyright 2017 Brigham and Women's Hospital (BWH) All Rights Reserved.
4 
5 See COPYRIGHT.txt
6 or http://www.slicer.org/copyright/copyright.txt for details.
7 
8 =========================================================================auto=*/
9 
10 #ifndef __vtkMRMLMeasurement_h
11 #define __vtkMRMLMeasurement_h
12 
13 //#define USE_POLYDATA_MEASUREMENTS
14 
15 // MRML includes
16 #include <vtkCodedEntry.h>
17 #include "vtkMRMLNode.h"
18 
19 // VTK includes
20 #include <vtkDoubleArray.h>
21 #include <vtkObject.h>
22 #include <vtkPolyData.h>
23 #include <vtkSmartPointer.h>
24 
33 class VTK_MRML_EXPORT vtkMRMLMeasurement : public vtkObject
34 {
35 public:
40  {
41  NoChange=0,
42  OK,
44  InternalError
45  };
46 
47  vtkTypeMacro(vtkMRMLMeasurement, vtkObject);
48  void PrintSelf(ostream& os, vtkIndent indent) override;
49 
51  virtual void Initialize();
52 
55  virtual void ClearValue(ComputationResult computationResult=NoChange);
56 
58  virtual void Copy(vtkMRMLMeasurement* aEntry);
59 
62  virtual void Compute() = 0;
63 
65  vtkSetMacro(Enabled, bool);
66  vtkGetMacro(Enabled, bool);
67  vtkBooleanMacro(Enabled, bool);
68 
70  vtkGetMacro(Name, std::string);
71  vtkSetMacro(Name, std::string);
72 
74  vtkGetMacro(Value, double);
75  void SetValue(double value);
76 
79  void SetValue(double value, const std::string& units, const std::string& printFormat, int lastComputationResult);
80 
82  vtkGetMacro(ValueDefined, bool);
83 
85  vtkGetMacro(Units, std::string);
86  vtkSetMacro(Units, std::string);
87 
89  vtkGetMacro(Description, std::string);
90  vtkSetMacro(Description, std::string);
91 
93  vtkGetMacro(PrintFormat, std::string);
94  vtkSetMacro(PrintFormat, std::string);
95 
97  void SetQuantityCode(vtkCodedEntry* entry);
98  vtkGetObjectMacro(QuantityCode, vtkCodedEntry);
99 
101  void SetDerivationCode(vtkCodedEntry* entry);
102  vtkGetObjectMacro(DerivationCode, vtkCodedEntry);
103 
105  void SetUnitsCode(vtkCodedEntry* entry);
106  vtkGetObjectMacro(UnitsCode, vtkCodedEntry);
107 
109  void SetMethodCode(vtkCodedEntry* entry);
110  vtkGetObjectMacro(MethodCode, vtkCodedEntry);
111 
113  vtkGetMacro(LastComputationResult, int);
115  const char* GetLastComputationResultAsPrintableString();
116 
118  std::string GetValueWithUnitsAsPrintableString();
119 
121  std::string GetAsString();
122 
125  bool SetFromString(const std::string& content);
126 
128  void SetControlPointValues(vtkDoubleArray* inputValues);
129  vtkGetObjectMacro(ControlPointValues, vtkDoubleArray);
130 
131 #ifdef USE_POLYDATA_MEASUREMENTS
132  void SetPolyDataValues(vtkPolyData* inputValues);
134  vtkGetObjectMacro(PolyDataValues, vtkPolyData);
135 #endif
136 
138  void SetInputMRMLNode(vtkMRMLNode* node);
140  vtkMRMLNode* GetInputMRMLNode();
141 
142 protected:
144  ~vtkMRMLMeasurement() override;
146  void operator=(const vtkMRMLMeasurement&);
147 
148 protected:
149  bool Enabled{true};
150  std::string Name;
151  double Value{0.0};
152  bool ValueDefined{false};
153  std::string Units;
154  std::string Description;
155  std::string PrintFormat; // for value (double), unit (string)
156  vtkCodedEntry* QuantityCode{nullptr}; // volume
157  vtkCodedEntry* DerivationCode{nullptr}; // min/max/mean
158  vtkCodedEntry* UnitsCode{nullptr}; // cubic millimeter
159  vtkCodedEntry* MethodCode{nullptr}; // Sum of segmented voxel volumes
160  ComputationResult LastComputationResult{InsufficientInput};
161 
163  vtkDoubleArray* ControlPointValues{nullptr};
164 #ifdef USE_POLYDATA_MEASUREMENTS
165  vtkPolyData* PolyDataValues{nullptr};
167 #endif
168  vtkWeakPointer<vtkMRMLNode> InputMRMLNode;
170 };
171 
172 #endif
Class for storing well-defined measurement results, using coded entries.
Simple class for storing standard coded entries (coding scheme, value, meaning triplets) ...
Definition: vtkCodedEntry.h:26
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167