forked from ProstateBRP/ProstateNav
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvtkMRMLRobotNode.h
225 lines (165 loc) · 7 KB
/
vtkMRMLRobotNode.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*=auto=========================================================================
Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) All Rights Reserved.
See Doc/copyright/copyright.txt
or http://www.slicer.org/copyright/copyright.txt for details.
Program: 3D Slicer
Module: $RCSfile: vtkMRMLCurveAnalysisNode.h,v $
Date: $Date: 2006/03/19 17:12:29 $
Version: $Revision: 1.3 $
=========================================================================auto=*/
#ifndef __vtkMRMLRobotNode_h
#define __vtkMRMLRobotNode_h
#include "vtkOpenIGTLinkIFWin32Header.h"
#include "vtkMRML.h"
#include "vtkMRMLNode.h"
#include "vtkMRMLStorageNode.h"
#include "vtkObject.h"
#include "vtkProstateNavWin32Header.h"
#include "vtkMRMLLinearTransformNode.h"
#include <iostream>
#include <fstream>
class vtkMRMLModelNode;
class vtkMRMLScalarVolumeNode;
class vtkSlicerApplication;
class vtkProstateNavTargetDescriptor;
struct NeedleDescriptorStruct;
class VTK_PROSTATENAV_EXPORT vtkMRMLRobotNode : public vtkMRMLTransformableNode
{
public:
//----------------------------------------------------------------
// Constants Definitions
//----------------------------------------------------------------
//BTX
// Events
enum {
ChangeStatusEvent = 200907,
ChangeTargetEvent = 200908,
RobotMovedEvent = 200910
};
enum STATUS_ID {
StatusOff=0,
StatusOk,
StatusWarning,
StatusError
};
struct StatusDescriptor
{
std::string text;
STATUS_ID indicator; // this determines the background color
};
//ETX
///
/// Transformable node methods
/// Only linear transforms are supported
virtual bool CanApplyNonLinearTransforms();
virtual void ApplyTransform(vtkAbstractTransform* transform);
virtual void ApplyTransform(vtkMatrix4x4* transformMatrix);
public:
//----------------------------------------------------------------
// Standard methods for MRML nodes
//----------------------------------------------------------------
static vtkMRMLRobotNode *New();
vtkTypeMacro(vtkMRMLRobotNode,vtkMRMLTransformableNode);
virtual vtkMRMLNode* CreateNodeInstance();
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Set node attributes
virtual void ReadXMLAttributes( const char** atts);
// Description:
// Write this node's information to a MRML file in XML format.
virtual void WriteXML(ostream& of, int indent);
// Description:
// Copy the node's attributes to this object
virtual void Copy(vtkMRMLNode *node);
// Description:
// Updates other nodes in the scene depending on this node
// or updates this node if it depends on other nodes
virtual void UpdateScene(vtkMRMLScene *);
// Description:
// Update the stored reference to another node in the scene
virtual void UpdateReferenceID(const char *oldID, const char *newID);
// Description:
// Updates this node if it depends on other nodes
// when the node is deleted in the scene
virtual void UpdateReferences();
virtual void RemoveChildNodes();
// Description:
// Get node XML tag name (like Volume, Model)
virtual const char* GetNodeTagName()
{return "Robot";};
// method to propagate events generated in mrml
virtual void ProcessMRMLEvents ( vtkObject *caller, unsigned long event, void *callData );
virtual const char* GetWorkflowStepsString()
{return "PointTargeting PointVerification"; };
// Description:
// Get/Set robot target (vtkMRMLLinearTransformNode)
vtkGetStringMacro(TargetTransformNodeID);
vtkMRMLTransformNode* GetTargetTransformNode();
void SetAndObserveTargetTransformNodeID(const char *transformNodeID);
virtual int Init(vtkSlicerApplication* app, const char* moduleShareDir);
virtual int MoveTo(const char *transformNodeId) { return 0; };
virtual void SwitchStep(const char *stepName) {};
virtual int OnTimer() {return 1; };
// Computes needle orientation in unit vector, pointing towards then needle tip
// when the robot targets the specified point.
// needleDirection is a pointer to a double[3] array which is updated with the orientation
// Returns false if the information cannot be determined.
virtual bool GetNeedleDirectionAtTarget(vtkProstateNavTargetDescriptor *targetDesc, NeedleDescriptorStruct *needle, double* needleDirection) { return false; };
virtual bool ShowRobotAtTarget(vtkProstateNavTargetDescriptor *targetDesc, NeedleDescriptorStruct *needle) { return false; };
//BTX
virtual std::string GetTargetInfoText(vtkProstateNavTargetDescriptor *targetDesc, NeedleDescriptorStruct *needle) { return ""; };
// Split the full target info text (convert "main info*****additional info" to "main info"+"additional info")
static void SplitTargetInfoText(const std::string targetInfoText, std::string &mainInfo, std::string &additionalInfo);
static std::string GetTargetInfoSectionSeparator() { return "-----\n"; };
//ETX
// Description:
// Sets the transform to a coordinate system that is aligned with the robot base.
// This coordinate system is determined during the calibration and it is not changed after that.
virtual bool GetRobotBaseTransform(vtkMatrix4x4* transform) { return false; };
virtual int PerformRegistration(vtkMRMLScalarVolumeNode* volumeNode) { return 0; };
// The following method is defined tentatively to pass registration parameter.
virtual int PerformRegistration(vtkMRMLScalarVolumeNode* volumeNode, int param1, int param2) { return 0; };
// Description:
// Get calibration object (Z frame, fiducials, etc.) model and transform
virtual const char* GetCalibrationObjectModelId() {return ""; };
virtual const char* GetCalibrationObjectTransformId() { return ""; };
// Description:
// Get workspace object model (representing range of motion of the device)
virtual const char* GetWorkspaceObjectModelId() {return ""; };
// Description:
// Get robot model (representing the robot with the needle guide, etc.)
virtual const char* GetRobotModelId() {return ""; };
int GetStatusDescriptorCount();
// Description:
// returns 0 if failed
//BTX
int GetStatusDescriptor(unsigned int index, std::string &text, STATUS_ID &indicator);
//ETX
// Description:
// Set log file name. If NULL is specified, log function is disabled.
int OpenLogFile(const char* filename);
// Description:
// Write str into logfile with time stamp.
//BTX
int WriteLog(const char* format, ...);
//ETX
protected:
//----------------------------------------------------------------
// Constructor and destructor
//----------------------------------------------------------------
vtkMRMLRobotNode();
virtual ~vtkMRMLRobotNode();
vtkMRMLRobotNode(const vtkMRMLRobotNode&);
void operator=(const vtkMRMLRobotNode&);
vtkSetReferenceStringMacro(TargetTransformNodeID);
char *TargetTransformNodeID;
vtkMRMLTransformNode* TargetTransformNode;
//BTX
std::vector<StatusDescriptor> StatusDescriptors;
std::string ModuleShareDirectory; // needed for model files, etc.
std::ofstream FileStream;
//ETX
protected:
//
};
#endif