forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkFinitePlaneRepresentation.h
329 lines (278 loc) · 8.4 KB
/
vtkFinitePlaneRepresentation.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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
/*=========================================================================
Program: Visualization Toolkit
Module: vtkFinitePlaneRepresentation.h
Copyright (c)
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkFinitePlaneRepresentation
* @brief represent the vtkFinitePlaneWidget.
*
* This class is a concrete representation for the vtkFinitePlaneWidget. It
* represents a plane with three handles: one on two faces, plus a
* center handle. Through interaction with the widget, the plane
* representation can be arbitrarily positioned and modified in the 3D space.
*
* To use this representation, you normally use the PlaceWidget() method
* to position the widget at a specified region in space.
*
* @sa
* vtkFinitePlaneWidget vtkImplicitPlaneWidget2
*/
#ifndef vtkFinitePlaneRepresentation_h
#define vtkFinitePlaneRepresentation_h
#include "vtkInteractionWidgetsModule.h" // For export macro
#include "vtkWidgetRepresentation.h"
class vtkActor;
class vtkBox;
class vtkCellPicker;
class vtkConeSource;
class vtkFeatureEdges;
class vtkLineSource;
class vtkPolyData;
class vtkPolyDataMapper;
class vtkProperty;
class vtkSphereSource;
class vtkTransform;
class vtkTubeFilter;
class VTKINTERACTIONWIDGETS_EXPORT vtkFinitePlaneRepresentation : public vtkWidgetRepresentation
{
public:
/**
* Instantiate the class.
*/
static vtkFinitePlaneRepresentation *New();
//@{
/**
* Standard vtkObject methods
*/
vtkTypeMacro(vtkFinitePlaneRepresentation, vtkWidgetRepresentation);
void PrintSelf(ostream& os, vtkIndent indent) override;
//@}
/**
* Grab the polydata that defines the plane. The polydata contains a single
* polygon.
*/
void GetPolyData(vtkPolyData *pd);
//@{
/**
* Get the handle properties (the little balls are the handles). The
* properties of the handles, when selected or normal, can be
* specified.
*/
vtkGetObjectMacro(V1HandleProperty, vtkProperty);
vtkGetObjectMacro(V2HandleProperty, vtkProperty);
vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
//@}
//@{
/**
* Get the plane properties. The
* properties of the plane when selected and normal can be
* set.
*/
vtkGetObjectMacro(PlaneProperty, vtkProperty);
vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
//@}
//@{
/**
* Turn on/off tubing of the wire outline of the plane. The tube thickens
* the line by wrapping with a vtkTubeFilter.
*/
vtkSetMacro(Tubing, bool);
vtkGetMacro(Tubing, bool);
vtkBooleanMacro(Tubing, bool);
//@}
//@{
/**
* Enable/disable the drawing of the plane. In some cases the plane
* interferes with the object that it is operating on (i.e., the
* plane interferes with the cut surface it produces producing
* z-buffer artifacts.)
*/
void SetDrawPlane(bool plane);
vtkGetMacro(DrawPlane, bool);
vtkBooleanMacro(DrawPlane, bool);
//@}
//@{
/**
* Switches handles (the spheres) on or off by manipulating the underlying
* actor visibility.
*/
void SetHandles(bool handles);
virtual void HandlesOn();
virtual void HandlesOff();
//@}
//@{
/**
* These are methods that satisfy vtkWidgetRepresentation's API.
*/
void PlaceWidget(double bounds[6]) override;
void BuildRepresentation() override;
int ComputeInteractionState(int X, int Y, int modify=0) override;
void StartWidgetInteraction(double e[2]) override;
void WidgetInteraction(double e[2]) override;
double *GetBounds() override;
//@}
//@{
/**
* Methods supporting, and required by, the rendering process.
*/
void ReleaseGraphicsResources(vtkWindow*) override;
int RenderOpaqueGeometry(vtkViewport*) override;
int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
vtkTypeBool HasTranslucentPolygonalGeometry() override;
//@}
vtkSetClampMacro(InteractionState, int, Outside, Pushing);
//@{
/**
* Set/Get the origin of the plane.
*/
void SetOrigin(double x, double y, double z);
void SetOrigin(double x[3]);
vtkGetVector3Macro(Origin, double);
//@}
//@{
/**
* Set/Get the normal to the plane.
*/
void SetNormal(double x, double y, double z);
void SetNormal(double x[3]);
vtkGetVector3Macro(Normal, double);
//@}
//@{
/**
* Set/Get the v1 vector of the plane.
*/
void SetV1(double x, double y);
void SetV1(double x[2]);
vtkGetVector2Macro(V1, double);
//@}
//@{
/**
* Set/Get the v2 vector of the plane.
*/
void SetV2(double x, double y);
void SetV2(double x[2]);
vtkGetVector2Macro(V2, double);
//@}
//@{
/**
* Sets the visual appearance of the representation based on the
* state it is in. This state is usually the same as InteractionState.
*/
virtual void SetRepresentationState(int);
vtkGetMacro(RepresentationState, int);
//@}
//@{
/**
* Get the properties on the normal (line and cone).
*/
vtkGetObjectMacro(NormalProperty, vtkProperty);
vtkGetObjectMacro(SelectedNormalProperty, vtkProperty);
//@}
// Methods to manipulate the plane
void TranslateOrigin(double *p1, double *p2);
void MovePoint1(double *p1, double *p2);
void MovePoint2(double *p1, double *p2);
void Push(double *p1, double *p2);
void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
enum _InteractionState
{
Outside = 0,
MoveOrigin,
ModifyV1,
ModifyV2,
Moving,
Rotating,
Pushing
};
/*
* Register internal Pickers within PickingManager
*/
void RegisterPickers() override;
protected:
vtkFinitePlaneRepresentation();
~vtkFinitePlaneRepresentation() override;
virtual void CreateDefaultProperties();
// Size the glyphs representing hot spots (e.g., handles)
virtual void SizeHandles();
void SetHighlightNormal(int highlight);
void SetHighlightPlane(int highlight);
void SetHighlightHandle(vtkProp *prop);
double LastEventPosition[3];
// the representation state
int RepresentationState;
// the origin
vtkSphereSource *OriginGeometry;
vtkPolyDataMapper *OriginMapper;
vtkActor *OriginActor;
double Origin[3];
// the normal
double Normal[3];
// the previous normal
double PreviousNormal[3];
// the rotation transform
vtkTransform *Transform;
// the X Vector
vtkSphereSource *V1Geometry;
vtkPolyDataMapper *V1Mapper;
vtkActor *V1Actor;
double V1[3];
// the Y Vector
vtkSphereSource *V2Geometry;
vtkPolyDataMapper *V2Mapper;
vtkActor *V2Actor;
double V2[3];
// The + normal cone
vtkConeSource *ConeSource;
vtkPolyDataMapper *ConeMapper;
vtkActor *ConeActor;
// The + normal line
vtkLineSource *LineSource;
vtkPolyDataMapper *LineMapper;
vtkActor *LineActor;
// The - normal cone
vtkConeSource *ConeSource2;
vtkPolyDataMapper *ConeMapper2;
vtkActor *ConeActor2;
// The - normal line
vtkLineSource *LineSource2;
vtkPolyDataMapper *LineMapper2;
vtkActor *LineActor2;
// The finite plane
vtkPolyData *PlanePolyData;
vtkPolyDataMapper *PlaneMapper;
vtkActor *PlaneActor;
// Optional tubes are represented by extracting boundary edges
vtkFeatureEdges *Edges;
vtkTubeFilter *EdgesTuber;
vtkPolyDataMapper *EdgesMapper;
vtkActor *EdgesActor;
bool Tubing; //control whether tubing is on
bool DrawPlane; //control whether plane is on
// Picking objects
vtkCellPicker *HandlePicker;
vtkActor *CurrentHandle;
// Transform the planes (used for rotations)
vtkTransform *TransformRotation;
// Support GetBounds() method
vtkBox *BoundingBox;
// Properties used to control the appearance of selected objects and
// the manipulator in general.
vtkProperty *OriginHandleProperty;
vtkProperty *V1HandleProperty;
vtkProperty *V2HandleProperty;
vtkProperty *SelectedHandleProperty;
vtkProperty *PlaneProperty;
vtkProperty *SelectedPlaneProperty;
vtkProperty *NormalProperty;
vtkProperty *SelectedNormalProperty;
private:
vtkFinitePlaneRepresentation(const vtkFinitePlaneRepresentation&) = delete;
void operator=(const vtkFinitePlaneRepresentation&) = delete;
};
#endif