Slicer  4.13
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:
36 
37  vtkTypeMacro(vtkMRMLMeasurement, vtkObject);
38  void PrintSelf(ostream& os, vtkIndent indent) override;
39 
41  virtual void Initialize();
42 
45  virtual void ClearValue();
46 
48  virtual void Copy(vtkMRMLMeasurement* aEntry);
49 
54  {
55  OK = 0,
57  InternalError
58  };
59 
62  virtual void Compute() = 0;
63 
65  vtkSetMacro(Enabled, bool);
66  vtkGetMacro(Enabled, bool);
67  vtkBooleanMacro(Enabled, bool);
68 
70  vtkGetStringMacro(Name);
71  vtkSetStringMacro(Name);
72 
74  vtkGetMacro(Value, double);
75  void SetValue(double value);
76 
78  vtkGetMacro(ValueDefined, bool);
79 
81  vtkGetStringMacro(Units);
82  vtkSetStringMacro(Units);
83 
85  vtkGetStringMacro(Description);
86  vtkSetStringMacro(Description);
87 
89  vtkGetStringMacro(PrintFormat);
90  vtkSetStringMacro(PrintFormat);
91 
93  void SetQuantityCode(vtkCodedEntry* entry);
94  vtkGetObjectMacro(QuantityCode, vtkCodedEntry);
95 
97  void SetDerivationCode(vtkCodedEntry* entry);
98  vtkGetObjectMacro(DerivationCode, vtkCodedEntry);
99 
101  void SetUnitsCode(vtkCodedEntry* entry);
102  vtkGetObjectMacro(UnitsCode, vtkCodedEntry);
103 
105  void SetMethodCode(vtkCodedEntry* entry);
106  vtkGetObjectMacro(MethodCode, vtkCodedEntry);
107 
109  vtkGetMacro(LastComputationResult, int);
111  const char* GetLastComputationResultAsPrintableString();
112 
114  std::string GetValueWithUnitsAsPrintableString();
115 
117  std::string GetAsString();
118 
121  bool SetFromString(const std::string& content);
122 
124  void SetControlPointValues(vtkDoubleArray* inputValues);
125  vtkGetObjectMacro(ControlPointValues, vtkDoubleArray);
126 
127 #ifdef USE_POLYDATA_MEASUREMENTS
128  void SetPolyDataValues(vtkPolyData* inputValues);
130  vtkGetObjectMacro(PolyDataValues, vtkPolyData);
131 #endif
132 
134  void SetInputMRMLNode(vtkMRMLNode* node);
136  vtkMRMLNode* GetInputMRMLNode();
137 
138 protected:
140  ~vtkMRMLMeasurement() override;
142  void operator=(const vtkMRMLMeasurement&);
143 
144 protected:
145  bool Enabled{true};
146  char* Name{nullptr};
147  double Value{0.0};
148  bool ValueDefined{false};
149  char* Units{nullptr};
150  char* Description{nullptr};
151  char* PrintFormat{nullptr}; // for value (double), unit (string)
152  vtkCodedEntry* QuantityCode{nullptr}; // volume
153  vtkCodedEntry* DerivationCode{nullptr}; // min/max/mean
154  vtkCodedEntry* UnitsCode{nullptr}; // cubic millimeter
155  vtkCodedEntry* MethodCode{nullptr}; // Sum of segmented voxel volumes
156  ComputationResult LastComputationResult{InsufficientInput};
157 
159  vtkDoubleArray* ControlPointValues{nullptr};
160 #ifdef USE_POLYDATA_MEASUREMENTS
161  vtkPolyData* PolyDataValues{nullptr};
163 #endif
164  vtkWeakPointer<vtkMRMLNode> InputMRMLNode;
166 };
167 
168 #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