1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkBooleanTexture.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   vtkBooleanTexture
17  * @brief   generate 2D texture map based on combinations of inside, outside, and on region boundary
18  *
19  *
20  * vtkBooleanTexture is a filter to generate a 2D texture map based on
21  * combinations of inside, outside, and on region boundary. The "region" is
22  * implicitly represented via 2D texture coordinates. These texture
23  * coordinates are normally generated using a filter like
24  * vtkImplicitTextureCoords, which generates the texture coordinates for
25  * any implicit function.
26  *
27  * vtkBooleanTexture generates the map according to the s-t texture
28  * coordinates plus the notion of being in, on, or outside of a
29  * region. An in region is when the texture coordinate is between
30  * (0,0.5-thickness/2).  An out region is where the texture coordinate
31  * is (0.5+thickness/2). An on region is between
32  * (0.5-thickness/2,0.5+thickness/2). The combination in, on, and out
33  * for each of the s-t texture coordinates results in 16 possible
34  * combinations (see text). For each combination, a different value of
35  * intensity and transparency can be assigned. To assign maximum intensity
36  * and/or opacity use the value 255. A minimum value of 0 results in
37  * a black region (for intensity) and a fully transparent region (for
38  * transparency).
39  *
40  * @sa
41  * vtkImplicitTextureCoords vtkThresholdTextureCoords
42  */
43 
44 #ifndef vtkBooleanTexture_h
45 #define vtkBooleanTexture_h
46 
47 #include "vtkImageAlgorithm.h"
48 #include "vtkImagingHybridModule.h" // For export macro
49 
50 class VTKIMAGINGHYBRID_EXPORT vtkBooleanTexture : public vtkImageAlgorithm
51 {
52 public:
53   static vtkBooleanTexture* New();
54 
55   vtkTypeMacro(vtkBooleanTexture, vtkImageAlgorithm);
56   void PrintSelf(ostream& os, vtkIndent indent) override;
57 
58   ///@{
59   /**
60    * Set the X texture map dimension.
61    */
62   vtkSetMacro(XSize, int);
63   vtkGetMacro(XSize, int);
64   ///@}
65 
66   ///@{
67   /**
68    * Set the Y texture map dimension.
69    */
70   vtkSetMacro(YSize, int);
71   vtkGetMacro(YSize, int);
72   ///@}
73 
74   ///@{
75   /**
76    * Set the thickness of the "on" region.
77    */
78   vtkSetMacro(Thickness, int);
79   vtkGetMacro(Thickness, int);
80   ///@}
81 
82   ///@{
83   /**
84    * Specify intensity/transparency for "in/in" region.
85    */
86   vtkSetVector2Macro(InIn, unsigned char);
87   vtkGetVectorMacro(InIn, unsigned char, 2);
88   ///@}
89 
90   ///@{
91   /**
92    * Specify intensity/transparency for "in/out" region.
93    */
94   vtkSetVector2Macro(InOut, unsigned char);
95   vtkGetVectorMacro(InOut, unsigned char, 2);
96   ///@}
97 
98   ///@{
99   /**
100    * Specify intensity/transparency for "out/in" region.
101    */
102   vtkSetVector2Macro(OutIn, unsigned char);
103   vtkGetVectorMacro(OutIn, unsigned char, 2);
104   ///@}
105 
106   ///@{
107   /**
108    * Specify intensity/transparency for "out/out" region.
109    */
110   vtkSetVector2Macro(OutOut, unsigned char);
111   vtkGetVectorMacro(OutOut, unsigned char, 2);
112   ///@}
113 
114   ///@{
115   /**
116    * Specify intensity/transparency for "on/on" region.
117    */
118   vtkSetVector2Macro(OnOn, unsigned char);
119   vtkGetVectorMacro(OnOn, unsigned char, 2);
120   ///@}
121 
122   ///@{
123   /**
124    * Specify intensity/transparency for "on/in" region.
125    */
126   vtkSetVector2Macro(OnIn, unsigned char);
127   vtkGetVectorMacro(OnIn, unsigned char, 2);
128   ///@}
129 
130   ///@{
131   /**
132    * Specify intensity/transparency for "on/out" region.
133    */
134   vtkSetVector2Macro(OnOut, unsigned char);
135   vtkGetVectorMacro(OnOut, unsigned char, 2);
136   ///@}
137 
138   ///@{
139   /**
140    * Specify intensity/transparency for "in/on" region.
141    */
142   vtkSetVector2Macro(InOn, unsigned char);
143   vtkGetVectorMacro(InOn, unsigned char, 2);
144   ///@}
145 
146   ///@{
147   /**
148    * Specify intensity/transparency for "out/on" region.
149    */
150   vtkSetVector2Macro(OutOn, unsigned char);
151   vtkGetVectorMacro(OutOn, unsigned char, 2);
152   ///@}
153 
154 protected:
155   vtkBooleanTexture();
156   ~vtkBooleanTexture() override = default;
157 
158   int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
159   void ExecuteDataWithInformation(vtkDataObject* data, vtkInformation* outInfo) override;
160 
161   int XSize;
162   int YSize;
163 
164   int Thickness;
165   unsigned char InIn[2];
166   unsigned char InOut[2];
167   unsigned char OutIn[2];
168   unsigned char OutOut[2];
169   unsigned char OnOn[2];
170   unsigned char OnIn[2];
171   unsigned char OnOut[2];
172   unsigned char InOn[2];
173   unsigned char OutOn[2];
174 
175 private:
176   vtkBooleanTexture(const vtkBooleanTexture&) = delete;
177   void operator=(const vtkBooleanTexture&) = delete;
178 };
179 
180 #endif
181