1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkVolumePicker.h
5 
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10      This software is distributed WITHOUT ANY WARRANTY; without even
11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12      PURPOSE.  See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /**
16  * @class   vtkVolumePicker
17  * @brief   ray-cast picker enhanced for volumes
18  *
19  * vtkVolumePicker is a subclass of vtkCellPicker.  It has one
20  * advantage over vtkCellPicker for volumes: it will be able to
21  * correctly perform picking when CroppingPlanes are present.  This
22  * isn't possible for vtkCellPicker since it doesn't link to
23  * the VolumeRendering classes and hence cannot access information
24  * about the CroppingPlanes.
25  *
26  * @sa
27  * vtkPicker vtkPointPicker vtkCellPicker
28  *
29  * @par Thanks:
30  * This class was contributed to VTK by David Gobbi on behalf of Atamai Inc.
31  */
32 
33 #ifndef vtkVolumePicker_h
34 #define vtkVolumePicker_h
35 
36 #include "vtkCellPicker.h"
37 #include "vtkRenderingVolumeModule.h" // For export macro
38 
39 class VTKRENDERINGVOLUME_EXPORT vtkVolumePicker : public vtkCellPicker
40 {
41 public:
42   static vtkVolumePicker* New();
43   vtkTypeMacro(vtkVolumePicker, vtkCellPicker);
44   void PrintSelf(ostream& os, vtkIndent indent) override;
45 
46   ///@{
47   /**
48    * Set whether to pick the cropping planes of props that have them.
49    * If this is set, then the pick will be done on the cropping planes
50    * rather than on the data. The GetCroppingPlaneId() method will return
51    * the index of the cropping plane of the volume that was picked.  This
52    * setting is only relevant to the picking of volumes.
53    */
54   vtkSetMacro(PickCroppingPlanes, vtkTypeBool);
55   vtkBooleanMacro(PickCroppingPlanes, vtkTypeBool);
56   vtkGetMacro(PickCroppingPlanes, vtkTypeBool);
57   ///@}
58 
59   ///@{
60   /**
61    * Get the index of the cropping plane that the pick ray passed
62    * through on its way to the prop. This will be set regardless
63    * of whether PickCroppingPlanes is on.  The crop planes are ordered
64    * as follows: xmin, xmax, ymin, ymax, zmin, zmax.  If the volume is
65    * not cropped, the value will bet set to -1.
66    */
67   vtkGetMacro(CroppingPlaneId, int);
68   ///@}
69 
70 protected:
71   vtkVolumePicker();
72   ~vtkVolumePicker() override;
73 
74   void ResetPickInfo() override;
75 
76   double IntersectVolumeWithLine(const double p1[3], const double p2[3], double t1, double t2,
77     vtkProp3D* prop, vtkAbstractVolumeMapper* mapper) override;
78 
79   static int ClipLineWithCroppingRegion(const double bounds[6], const int extent[6], int flags,
80     const double x1[3], const double x2[3], double t1, double t2, int& extentPlaneId,
81     int& numSegments, double* t1List, double* t2List, double* s1List, int* planeIdList);
82 
83   vtkTypeBool PickCroppingPlanes;
84   int CroppingPlaneId;
85 
86 private:
87   vtkVolumePicker(const vtkVolumePicker&) = delete;
88   void operator=(const vtkVolumePicker&) = delete;
89 };
90 
91 #endif
92