1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkLassoStencilSource.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   vtkLassoStencilSource
17  * @brief   Create a stencil from a contour
18  *
19  * vtkLassoStencilSource will create an image stencil from a
20  * set of points that define a contour.  Its output can be
21  * used with vtkImageStecil or other vtk classes that apply
22  * a stencil to an image.
23  * @sa
24  * vtkROIStencilSource vtkPolyDataToImageStencil
25  * @par Thanks:
26  * Thanks to David Gobbi for contributing this class to VTK.
27  */
28 
29 #ifndef vtkLassoStencilSource_h
30 #define vtkLassoStencilSource_h
31 
32 #include "vtkImageStencilSource.h"
33 #include "vtkImagingStencilModule.h" // For export macro
34 
35 class vtkPoints;
36 class vtkSpline;
37 class vtkLSSPointMap;
38 
39 class VTKIMAGINGSTENCIL_EXPORT vtkLassoStencilSource : public vtkImageStencilSource
40 {
41 public:
42   static vtkLassoStencilSource* New();
43   vtkTypeMacro(vtkLassoStencilSource, vtkImageStencilSource);
44   void PrintSelf(ostream& os, vtkIndent indent) override;
45 
46   enum
47   {
48     POLYGON = 0,
49     SPLINE = 1
50   };
51 
52   ///@{
53   /**
54    * The shape to use, default is "Polygon".  The spline is a
55    * cardinal spline.  Bezier splines are not yet supported.
56    */
57   vtkGetMacro(Shape, int);
58   vtkSetClampMacro(Shape, int, POLYGON, SPLINE);
SetShapeToPolygon()59   void SetShapeToPolygon() { this->SetShape(POLYGON); }
SetShapeToSpline()60   void SetShapeToSpline() { this->SetShape(SPLINE); }
61   virtual const char* GetShapeAsString();
62   ///@}
63 
64   ///@{
65   /**
66    * The points that make up the lassoo.  The loop does not
67    * have to be closed, the last point will automatically be
68    * connected to the first point by a straight line segment.
69    */
70   virtual void SetPoints(vtkPoints* points);
71   vtkGetObjectMacro(Points, vtkPoints);
72   ///@}
73 
74   ///@{
75   /**
76    * The slice orientation.  The default is 2, which is XY.
77    * Other values are 0, which is YZ, and 1, which is XZ.
78    */
79   vtkGetMacro(SliceOrientation, int);
80   vtkSetClampMacro(SliceOrientation, int, 0, 2);
81   ///@}
82 
83   ///@{
84   /**
85    * The points for a particular slice.  This will override the
86    * points that were set by calling SetPoints() for the slice.
87    * To clear the setting, call SetSlicePoints(slice, nullptr).
88    */
89   virtual void SetSlicePoints(int i, vtkPoints* points);
90   virtual vtkPoints* GetSlicePoints(int i);
91   ///@}
92 
93   /**
94    * Remove points from all slices.
95    */
96   virtual void RemoveAllSlicePoints();
97 
98   /**
99    * Overload GetMTime() to include the timestamp on the points.
100    */
101   vtkMTimeType GetMTime() override;
102 
103 protected:
104   vtkLassoStencilSource();
105   ~vtkLassoStencilSource() override;
106 
107   int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
108 
109   int Shape;
110   int SliceOrientation;
111   vtkPoints* Points;
112   vtkSpline* SplineX;
113   vtkSpline* SplineY;
114   vtkLSSPointMap* PointMap;
115 
116 private:
117   vtkLassoStencilSource(const vtkLassoStencilSource&) = delete;
118   void operator=(const vtkLassoStencilSource&) = delete;
119 };
120 
121 #endif
122