Computer Assited Medical Intervention Tool Kit  version 5.0
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-2021 Univ. Grenoble Alpes, CNRS, Grenoble INP, TIMC, 38000 Grenoble, France
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 override {
147  return label;
148  }
149 
151  void setLabel(QString newName) override {
152  label = newName;
153  updateLabel();
154  }
155 
160  vtkSmartPointer<vtkPointSet> getPointSet() override {
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 override {
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  void setTexture(vtkSmartPointer<vtkTexture> texture) override;
191 
193  void pointPicked(vtkIdType, bool) override {};
194 
196  void cellPicked(vtkIdType, bool) override {};
197 
199 
209 
211  vtkSmartPointer<vtkProp> getProp(const QString&) override;
212 
214  unsigned int getNumberOfProp() const override;
215 
217  vtkSmartPointer<vtkProp> getProp(unsigned int) override;
218 
222  bool addProp(const QString&, vtkSmartPointer<vtkProp>) override final;
223 
227  bool removeProp(const QString&) override;
229 
232 
234  void getBounds(double* bounds) override final;
235 
237  double getBoundingRadius() override final;
238 
240  void setPointPosition(const unsigned int orderNumber, const double x, const double y, const double z) override;
241 
243 
244 
247 
249  void setRenderingModes(const RenderingModes rMode) override {
250  renderingModes = rMode;
251  }
252 
254  const RenderingModes getRenderingModes() const override {
255  return renderingModes;
256  }
257 
259  void setEnhancedModes(const EnhancedModes) override;
260 
262  const EnhancedModes getEnhancedModes() const override {
263  return enhancedModes;
264  }
265 
267  void setActorColor(const RenderingModes, double*) override;
268 
270  void setActorColor(const RenderingModes, const double, const double, const double) override;
271 
273  void getActorColor(const RenderingModes, double*) override final;
274 
276  void setColor(const double, const double, const double) override;
277 
279  void setColor(const double, const double, const double, const double) override;
280 
282  void setActorOpacity(const RenderingModes, const double) override final;
283 
285  double getActorOpacity(const RenderingModes) const override;
286 
288  void setOpacity(const double) override;
289 
291  void setMapperScalarRange(double min, double max) override;
292 
294  void setGlyphType(const GlyphTypes type, const double size = 0.0) override final;
295 
297  void setLinesAsTubes(bool tubes = false) override;
298 
300 
301 
302 private:
303 
306  vtkSmartPointer<vtkPointSet> pointSet;
309 
311  vtkSmartPointer<vtkAlgorithmOutput> dataOutput;
312 
314  vtkSmartPointer<vtkAlgorithmOutput> customPipelineOutput;
315 
317  vtkSmartPointer<vtkCastToConcrete> concreteData;
318 
320  vtkSmartPointer<vtkDataSetMapper> mapper;
321 
323  vtkSmartPointer<vtkTextMapper> labelActorMapper;
324 
326  vtkSmartPointer<vtkActor> surfaceActor;
327 
329  vtkSmartPointer<vtkActor> wireframeActor;
330 
332  vtkSmartPointer<vtkActor> pointsActor;
333 
335  vtkSmartPointer<vtkTexture> texture;
336 
338  vtkSmartPointer<vtkTubeFilter> tube;
339 
341  vtkSmartPointer<vtkTransformFilter> worldTransformFilter;
342 
344  vtkSmartPointer<vtkSphereSource> sphereGeom;
346 
350  InterfaceGeometry::RenderingModes renderingModes;
351 
353  InterfaceGeometry::EnhancedModes enhancedModes;
354 
356  double alphaShaded;
357 
359  QString label;
360 
362  double glyphSize;
363 
365  void buildLabel();
366 
368  void updateLabel();
369 
371  void buildGlyph(const GlyphTypes type);
372 
378  void createPointCloudVisualization();
380 
384  double surfaceColor[4];
386  double wireframeColor[4];
387  double pointsColor[4];
389 
392  double oldAlphaSurface;
393  double oldAlphaWireframe;
394  double oldAlphaPoints;
396 
400 
402  QMap<QString, vtkSmartPointer<vtkProp> > extraProp;
404 
405 };
406 
407 
408 
409 }
410 
411 #endif
camitk::Geometry::setActorOpacity
void setActorOpacity(const RenderingModes, const double) override final
Set the opacity of this representation modes. WARNING color field (surfaceColor, ....
Definition: Geometry.cpp:606
camitk::Geometry::customPipelineOutput
vtkSmartPointer< vtkAlgorithmOutput > customPipelineOutput
the external custom pipeline output (equals to dataOuput if no custom pipeline plugged)
Definition: Geometry.h:314
camitk::InterfaceGeometry::Shaded
@ Shaded
the object is shaded
Definition: InterfaceGeometry.h:77
camitk::Geometry::mapper
vtkSmartPointer< vtkDataSetMapper > mapper
the VTK mapper
Definition: Geometry.h:320
camitk::Geometry::concreteData
vtkSmartPointer< vtkCastToConcrete > concreteData
the filter to convert the DataSet to get a correct vtkPipeline output port
Definition: Geometry.h:317
camitk::Geometry
A 3D representation of a vtkPointSet to be displayed in a InteractiveViewer, this class implements th...
Definition: Geometry.h:126
camitk::Geometry::setLabel
void setLabel(QString newName) override
set the label of this Geometry instance
Definition: Geometry.h:151
camitk::Geometry::label
QString label
the label
Definition: Geometry.h:359
camitk::InterfaceGeometry::Normal
@ Normal
the object is normally displayed
Definition: InterfaceGeometry.h:75
CamiTKAPI.h
camitk::Geometry::pointsColor
double pointsColor[4]
Definition: Geometry.h:387
camitk::Geometry::setEnhancedModes
void setEnhancedModes(const EnhancedModes) override
set the enhanced mode
Definition: Geometry.cpp:705
a
#define a
Geometry.h
camitk::Geometry::wireframeActor
vtkSmartPointer< vtkActor > wireframeActor
the wireframe actor that manages the representation as wireframe
Definition: Geometry.h:329
camitk::Geometry::sphereGeom
vtkSmartPointer< vtkSphereSource > sphereGeom
the sphere glyph
Definition: Geometry.h:344
camitk::InterfaceGeometry::Surface
@ Surface
the surface is visible
Definition: InterfaceGeometry.h:67
camitk::Geometry::setPointSet
void setPointSet(vtkSmartPointer< vtkPointSet > ds) override
set the input data of the Geometry,
Definition: Geometry.cpp:195
camitk::Geometry::oldAlphaSurface
double oldAlphaSurface
Definition: Geometry.h:392
camitk::Geometry::labelActorMapper
vtkSmartPointer< vtkTextMapper > labelActorMapper
the mapper to create the text
Definition: Geometry.h:323
camitk::Geometry::getBoundingRadius
double getBoundingRadius() override final
compute the object's bounding sphere radius
Definition: Geometry.cpp:792
camitk::Geometry::updateLabel
void updateLabel()
update position and text of the label
Definition: Geometry.cpp:428
camitk::Geometry::setMapperScalarRange
void setMapperScalarRange(double min, double max) override
Set the mapper scalar range.
Definition: Geometry.cpp:664
camitk::Geometry::texture
vtkSmartPointer< vtkTexture > texture
texture of this object.
Definition: Geometry.h:335
camitk::Geometry::dataOutput
vtkSmartPointer< vtkAlgorithmOutput > dataOutput
to be able to set external custom pipeline
Definition: Geometry.h:311
camitk::Geometry::setTexture
void setTexture(vtkSmartPointer< vtkTexture > texture) override
Set a texture to this object.
Definition: Geometry.cpp:669
camitk::Geometry::setPointData
void setPointData(vtkSmartPointer< vtkDataArray >) override
set the point data (may contains a lookup table)
Definition: Geometry.cpp:814
camitk::Geometry::setLinesAsTubes
void setLinesAsTubes(bool tubes=false) override
display lines as tubes (depeding of the boolean) (only work if the Geometry was defined using a vtkPo...
Definition: Geometry.cpp:762
camitk::InterfaceGeometry::Highlighted
@ Highlighted
the object is highlighted
Definition: InterfaceGeometry.h:78
camitk::Geometry::getActor
vtkSmartPointer< vtkActor > getActor(const RenderingModes) override
Return the actor representing this representation mode (returns nullptr if hightlight mode is Hidden)...
Definition: Geometry.cpp:269
camitk::InterfaceGeometry::Hidden
@ Hidden
the object is hidden
Definition: InterfaceGeometry.h:76
camitk::Geometry::getProp
vtkSmartPointer< vtkProp > getProp(const QString &) override
Return the vtkProp (actors, volumes and annotations) corresponding to the given name.
Definition: Geometry.cpp:467
camitk::Geometry::oldAlphaPoints
double oldAlphaPoints
Definition: Geometry.h:394
camitk::Geometry::setColor
void setColor(const double, const double, const double) override
Set an (r,g,b) color to all representation modes, without changing the opacity.
Definition: Geometry.cpp:590
camitk::Geometry::alphaShaded
double alphaShaded
Opacity value when this object must be shaded.
Definition: Geometry.h:356
camitk::Geometry::setDataConnection
void setDataConnection(vtkSmartPointer< vtkAlgorithmOutput >) override
call this method with the custom algorithm pipeline output
Definition: Geometry.cpp:250
InterfaceGeometry.h
camitk::Geometry::pointSet
vtkSmartPointer< vtkPointSet > pointSet
Definition: Geometry.h:308
camitk::InterfaceGeometry
This class describes what are the methods to implement for a Geometry (rendering parameters,...
Definition: InterfaceGeometry.h:61
camitk::Geometry::renderingModes
InterfaceGeometry::RenderingModes renderingModes
Definition: Geometry.h:350
camitk::Geometry::getEnhancedModes
const EnhancedModes getEnhancedModes() const override
get the current enhanced mode
Definition: Geometry.h:262
camitk::Geometry::pointsActor
vtkSmartPointer< vtkActor > pointsActor
the point actor that manages the representation as a set of points
Definition: Geometry.h:332
camitk::Geometry::Geometry
Geometry(QString label, vtkSmartPointer< vtkPointSet > pointSet, const InterfaceGeometry::RenderingModes mode=InterfaceGeometry::Surface)
instantiate a Geometry using existing stuff.
Definition: Geometry.cpp:82
camitk::Geometry::oldAlphaWireframe
double oldAlphaWireframe
Definition: Geometry.h:393
camitk::Geometry::getDataPort
vtkSmartPointer< vtkAlgorithmOutput > getDataPort() const override
get the custom algorithm pipeline input.
Definition: Geometry.h:173
camitk::Geometry::setOpacity
void setOpacity(const double) override
Set the opacity of this object. WARNING color field (surfaceColor, ...) are not modified!
Definition: Geometry.cpp:659
camitk::Geometry::getBounds
void getBounds(double *bounds) override final
compute the object's bounding box [xmin,xmax, ymin,ymax, zmin,zmax]
Definition: Geometry.cpp:787
camitk::Geometry::~Geometry
~Geometry() override
destructor
Definition: Geometry.cpp:170
camitk::Geometry::wireframeColor
double wireframeColor[4]
Definition: Geometry.h:386
camitk::addProp
addProp(axes)
camitk::Geometry::worldTransformFilter
vtkSmartPointer< vtkTransformFilter > worldTransformFilter
the transform filter to place the mesh correctly with respect to its Frame
Definition: Geometry.h:341
camitk::InterfaceGeometry::Sphere
@ Sphere
the glyph is a nice sphere
Definition: InterfaceGeometry.h:85
camitk::Geometry::tube
vtkSmartPointer< vtkTubeFilter > tube
the tube filter (creates tubes insead of lines)
Definition: Geometry.h:338
camitk::Geometry::buildLabel
void buildLabel()
build the label extra prop
Definition: Geometry.cpp:404
camitk::transform
vtkSmartPointer< vtkTransform > transform
Definition: RendererWidget.cpp:372
camitk::Geometry::setGlyphType
void setGlyphType(const GlyphTypes type, const double size=0.0) override final
set the glyph information
Definition: Geometry.cpp:680
camitk::InterfaceGeometry::Points
@ Points
the points are visible
Definition: InterfaceGeometry.h:69
camitk::Geometry::getRenderingModes
const RenderingModes getRenderingModes() const override
Return if the actor associated to a rendering mode is currently visible or not.
Definition: Geometry.h:254
camitk::Geometry::extraProp
QMap< QString, vtkSmartPointer< vtkProp > > extraProp
The additional map for prop (include at least "label" and "glyph")
Definition: Geometry.h:402
camitk::Geometry::surfaceActor
vtkSmartPointer< vtkActor > surfaceActor
the surface actor that manages the surfacic representation
Definition: Geometry.h:326
camitk::Geometry::cellPicked
void cellPicked(vtkIdType, bool) override
a vtkCell of the structured was picked (to be reimplemented in a Component inherited class if needed)
Definition: Geometry.h:196
camitk::Geometry::removeProp
bool removeProp(const QString &) override
remove a given additional prop.
Definition: Geometry.cpp:495
camitk::Geometry::glyphSize
double glyphSize
current size of glyph (0.0 means no glyph)
Definition: Geometry.h:362
camitk::Geometry::enhancedModes
InterfaceGeometry::EnhancedModes enhancedModes
Enhanced mode options (the way actors are rendered: normal, hidden, highlighted, shaded)
Definition: Geometry.h:353
camitk::Geometry::getActorColor
void getActorColor(const RenderingModes, double *) override final
Get the color of given representation modes in the second parameter, i.e. double[4] (r,...
Definition: Geometry.cpp:566
camitk::Geometry::getActorOpacity
double getActorOpacity(const RenderingModes) const override
Return the opacity of a given renderng mode.
Definition: Geometry.cpp:643
camitk::removeProp
void removeProp(vtkSmartPointer< vtkProp > p, bool refresh=false)
remove the given vtkProp (e.g.
camitk::Geometry::pointPicked
void pointPicked(vtkIdType, bool) override
a vtkPoint of the structured was picked (to be reimplemented in a Component inherited class if needed...
Definition: Geometry.h:193
camitk::Geometry::buildGlyph
void buildGlyph(const GlyphTypes type)
build the glyph extra prop (sphere glyph by default)
Definition: Geometry.cpp:331
camitk::InterfaceGeometry::Wireframe
@ Wireframe
the wireframe is visible
Definition: InterfaceGeometry.h:68
camitk::Geometry::setPointPosition
void setPointPosition(const unsigned int orderNumber, const double x, const double y, const double z) override
set a given point position
Definition: Geometry.cpp:516
camitk::Geometry::surfaceColor
double surfaceColor[4]
Definition: Geometry.h:385
camitk::Geometry::getLabel
const QString getLabel() const override
get the label of this Geometry instance
Definition: Geometry.h:146
camitk::Geometry::setActorColor
void setActorColor(const RenderingModes, double *) override
Set the color of given representation modes.
Definition: Geometry.cpp:522
camitk::Geometry::setMeshWorldTransform
void setMeshWorldTransform(vtkSmartPointer< vtkTransform >) override
Set the world transform (if the Geometry depends on another Frame)
Definition: Geometry.cpp:242
camitk::Geometry::getNumberOfProp
unsigned int getNumberOfProp() const override
return the number of additional prop
Definition: Geometry.cpp:485
camitk::Geometry::createPointCloudVisualization
void createPointCloudVisualization()
force visualization of point cloud If the point set does only contains a point cloud,...
Definition: Geometry.cpp:216
camitk::InterfaceGeometry::NoGlyph
@ NoGlyph
there are no glyph type attached to the geometry
Definition: InterfaceGeometry.h:84
camitk::Geometry::addProp
bool addProp(const QString &, vtkSmartPointer< vtkProp >) override final
insert an additional prop, defining it by its name (default visibility = false)
Definition: Geometry.cpp:456
CAMITK_API
#define CAMITK_API
Definition: CamiTKAPI.h:49
camitk
Definition: Action.cpp:35