Computer Assited Medical Intervention Tool Kit  version 4.1
Geometry.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 
26 #ifndef GEOMETRY_H
27 #define GEOMETRY_H
28 
29 // -- Core stuff
30 #include "CamiTKAPI.h"
31 #include "InterfaceGeometry.h"
32 
33 #include <QMap>
34 
35 //-- VTK Classes
36 class vtkPointSet;
37 class vtkAlgorithmOutput;
38 class vtkDataSetMapper;
39 class vtkActor;
40 class vtkProp;
41 class vtkTexture;
42 class vtkGlyph3D;
43 class vtkTransform;
44 class vtkTubeFilter;
45 class vtkCastToConcrete;
46 class vtkTextMapper;
47 class vtkSphereSource;
48 class vtkTransformFilter;
49 
50 namespace camitk {
127 
128 public:
140  Geometry(QString label, vtkSmartPointer<vtkPointSet> pointSet, const InterfaceGeometry::RenderingModes mode = InterfaceGeometry::Surface);
141 
143  ~Geometry() override;
144 
146  const QString getLabel() const {
147  return label;
148  }
149 
151  void setLabel(QString newName) {
152  label = newName;
153  updateLabel();
154  }
155 
160  vtkSmartPointer<vtkPointSet> getPointSet() {
163  return pointSet;
164  }
165 
167  void setPointSet(vtkSmartPointer<vtkPointSet> ds) override;
168 
170  void setMeshWorldTransform(vtkSmartPointer<vtkTransform>) override;
171 
173  vtkSmartPointer<vtkAlgorithmOutput> getDataPort() const {
174  return dataOutput;
175  }
176 
178  void setDataConnection(vtkSmartPointer<vtkAlgorithmOutput>) override;
179 
181  void setPointData(vtkSmartPointer<vtkDataArray>) override;
182 
187  vtkSmartPointer<vtkActor> getActor(const RenderingModes) override;
188 
190  vtkSmartPointer<vtkProp> getProp(const QString&) override;
191 
193  unsigned int getNumberOfProp() const override;
194 
196  vtkSmartPointer<vtkProp> getProp(unsigned int) override;
197 
201  bool addProp(const QString&, vtkSmartPointer<vtkProp>) override;
202 
206  bool removeProp(const QString&) override;
207 
209  void setTexture(vtkSmartPointer<vtkTexture> texture) override;
210 
212  void pointPicked(vtkIdType, bool) {};
213 
215  void cellPicked(vtkIdType, bool) {};
216 
218 
221 
223  void getBounds(double* bounds) override;
224 
226  double getBoundingRadius() override;
227 
229  void setPointPosition(const unsigned int orderNumber, const double x, const double y, const double z) override;
230 
232 
233 
236 
238  void setRenderingModes(const RenderingModes rMode) {
239  renderingModes = rMode;
240  }
241 
243  const RenderingModes getRenderingModes() const {
244  return renderingModes;
245  }
246 
248  void setEnhancedModes(const EnhancedModes) override;
249 
251  const EnhancedModes getEnhancedModes() const {
252  return enhancedModes;
253  }
254 
256  void setActorColor(const RenderingModes, double*) override;
257 
259  void setActorColor(const RenderingModes, const double, const double, const double) override;
260 
262  void getActorColor(const RenderingModes, double*) override;
263 
265  void setColor(const double, const double, const double) override;
266 
268  void setColor(const double, const double, const double, const double) override;
269 
271  void setActorOpacity(const RenderingModes, const double) override;
272 
274  double getActorOpacity(const RenderingModes) const override;
275 
277  void setOpacity(const double) override;
278 
280  void setMapperScalarRange(double min, double max) override;
281 
283  void setGlyphType(const GlyphTypes type, const double size = 0.0) override;
284 
286  void setLinesAsTubes(bool tubes = false) override;
287 
289 
290 
291 private:
292 
295  vtkSmartPointer<vtkPointSet> pointSet;
298 
300  vtkSmartPointer<vtkAlgorithmOutput> dataOutput;
301 
303  vtkSmartPointer<vtkAlgorithmOutput> customPipelineOutput;
304 
306  vtkSmartPointer<vtkCastToConcrete> concreteData;
307 
309  vtkSmartPointer<vtkDataSetMapper> mapper;
310 
312  QMap<QString, vtkSmartPointer<vtkProp> > extraProp;
313 
315  vtkSmartPointer<vtkTextMapper> labelActorMapper;
316 
318  vtkSmartPointer<vtkActor> surfaceActor;
319 
321  vtkSmartPointer<vtkActor> wireframeActor;
322 
324  vtkSmartPointer<vtkActor> pointsActor;
325 
327  vtkSmartPointer<vtkTexture> texture;
328 
330  vtkSmartPointer<vtkTubeFilter> tube;
331 
333  vtkSmartPointer<vtkTransformFilter> worldTransformFilter;
334 
336  vtkSmartPointer<vtkSphereSource> sphereGeom;
338 
342  InterfaceGeometry::RenderingModes renderingModes;
343 
345  InterfaceGeometry::EnhancedModes enhancedModes;
346 
348  double alphaShaded;
349 
351  QString label;
352 
354  double glyphSize;
355 
357  void buildLabel();
358 
360  void updateLabel();
361 
363  void buildGlyph(const GlyphTypes type);
364 
370  void createPointCloudVisualization();
372 
376  double surfaceColor[4];
378  double wireframeColor[4];
379  double pointsColor[4];
381 
387  double oldPointsColor[4];
389 protected:
390  vtkSmartPointer< vtkPointSet > New();
391 };
392 
393 
394 
395 }
396 
397 #endif
InterfaceGeometry::RenderingModes renderingModes
Definition: Geometry.h:342
vtkSmartPointer< vtkSphereSource > sphereGeom
the sphere glyph
Definition: Geometry.h:336
vtkSmartPointer< vtkActor > pointsActor
the point actor that manages the representation as a set of points
Definition: Geometry.h:324
vtkSmartPointer< vtkTubeFilter > tube
the tube filter (creates tubes insead of lines)
Definition: Geometry.h:330
double oldAlphaSurface
Definition: Geometry.h:384
void pointPicked(vtkIdType, bool)
a vtkPoint of the structured was picked (to be reimplemented in a Component inherited class if needed...
Definition: Geometry.h:212
QMap< QString, vtkSmartPointer< vtkProp > > extraProp
The additional map for prop (include at least "label" and "glyph".
Definition: Geometry.h:312
const EnhancedModes getEnhancedModes() const
get the current enhanced mode
Definition: Geometry.h:251
Definition: Action.cpp:36
const QString getLabel() const
get the label of this Geometry instance
Definition: Geometry.h:146
double glyphSize
current size of glyph (0.0 means no glyph)
Definition: Geometry.h:354
vtkSmartPointer< vtkAlgorithmOutput > dataOutput
to be able to set external custom pipeline
Definition: Geometry.h:300
#define CAMITK_API
Definition: CamiTKAPI.h:49
double oldAlphaWireframe
Definition: Geometry.h:385
vtkSmartPointer< vtkDataSetMapper > mapper
the VTK mapper
Definition: Geometry.h:309
void setRenderingModes(const RenderingModes rMode)
Set the actor associated to a rendering mode visible or not.
Definition: Geometry.h:238
InterfaceGeometry::EnhancedModes enhancedModes
Enhanced mode options (the way actors are rendered: normal, hidden, highlighted, shaded) ...
Definition: Geometry.h:345
vtkSmartPointer< vtkAlgorithmOutput > customPipelineOutput
the external custom pipeline output (equals to dataOuput if no custom pipeline plugged) ...
Definition: Geometry.h:303
the surface is visible
Definition: InterfaceGeometry.h:67
vtkSmartPointer< vtkCastToConcrete > concreteData
the filter to convert the DataSet to get a correct vtkPipeline output port
Definition: Geometry.h:306
double alphaShaded
Opacity value when this object must be shaded.
Definition: Geometry.h:348
vtkSmartPointer< vtkTexture > texture
texture of this object.
Definition: Geometry.h:327
void setLabel(QString newName)
set the label of this Geometry instance
Definition: Geometry.h:151
vtkSmartPointer< vtkActor > surfaceActor
the surface actor that manages the surfacic representation
Definition: Geometry.h:318
A 3D representation of a vtkPointSet to be displayed in a InteractiveViewer, this class implements th...
Definition: Geometry.h:126
vtkSmartPointer< vtkTextMapper > labelActorMapper
the mapper to create the text
Definition: Geometry.h:315
vtkSmartPointer< vtkAlgorithmOutput > getDataPort() const
get the custom algorithm pipeline input.
Definition: Geometry.h:173
This class describes what are the methods to implement for a Geometry (rendering parameters, input/output, filters, picking parameters...)
Definition: InterfaceGeometry.h:61
double oldAlphaPoints
Definition: Geometry.h:386
vtkSmartPointer< vtkActor > wireframeActor
the wireframe actor that manages the representation as wireframe
Definition: Geometry.h:321
void cellPicked(vtkIdType, bool)
a vtkCell of the structured was picked (to be reimplemented in a Component inherited class if needed)...
Definition: Geometry.h:215
const RenderingModes getRenderingModes() const
Return if the actor associated to a rendering mode is currently visible or not.
Definition: Geometry.h:243
vtkSmartPointer< vtkTransformFilter > worldTransformFilter
the transform filter to place the mesh correctly with respect to its Frame
Definition: Geometry.h:333
QString label
the label
Definition: Geometry.h:351