1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkThresholdTextureCoords.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   vtkThresholdTextureCoords
17  * @brief   compute 1D, 2D, or 3D texture coordinates based on scalar threshold
18  *
19  * vtkThresholdTextureCoords is a filter that generates texture coordinates for
20  * any input dataset type given a threshold criterion. The criterion can take
21  * three forms: 1) greater than a particular value (ThresholdByUpper());
22  * 2) less than a particular value (ThresholdByLower(); or 3) between two
23  * values (ThresholdBetween(). If the threshold criterion is satisfied,
24  * the "in" texture coordinate will be set (this can be specified by the
25  * user). If the threshold criterion is not satisfied the "out" is set.
26  *
27  * @warning
28  * There is a texture map - texThres.vtk - that can be used in conjunction
29  * with this filter. This map defines a "transparent" region for texture
30  * coordinates 0<=r<0.5, and an opaque full intensity map for texture
31  * coordinates 0.5<r<=1.0. There is a small transition region for r=0.5.
32  *
33  * @sa
34  * vtkThreshold vtkThresholdPoints vtkTextureMapToPlane vtkTextureMapToSphere
35  * vtkTextureMapToCylinder
36 */
37 
38 #ifndef vtkThresholdTextureCoords_h
39 #define vtkThresholdTextureCoords_h
40 
41 #include "vtkFiltersTextureModule.h" // For export macro
42 #include "vtkDataSetAlgorithm.h"
43 
44 class VTKFILTERSTEXTURE_EXPORT vtkThresholdTextureCoords : public vtkDataSetAlgorithm
45 {
46 public:
47   static vtkThresholdTextureCoords *New();
48   vtkTypeMacro(vtkThresholdTextureCoords,vtkDataSetAlgorithm);
49   void PrintSelf(ostream& os, vtkIndent indent) override;
50 
51   /**
52    * Criterion is cells whose scalars are less than lower threshold.
53    */
54   void ThresholdByLower(double lower);
55 
56   /**
57    * Criterion is cells whose scalars are less than upper threshold.
58    */
59   void ThresholdByUpper(double upper);
60 
61   /**
62    * Criterion is cells whose scalars are between lower and upper thresholds.
63    */
64   void ThresholdBetween(double lower, double upper);
65 
66   //@{
67   /**
68    * Return the upper and lower thresholds.
69    */
70   vtkGetMacro(UpperThreshold,double);
71   vtkGetMacro(LowerThreshold,double);
72   //@}
73 
74   //@{
75   /**
76    * Set the desired dimension of the texture map.
77    */
78   vtkSetClampMacro(TextureDimension,int,1,3);
79   vtkGetMacro(TextureDimension,int);
80   //@}
81 
82   //@{
83   /**
84    * Set the texture coordinate value for point satisfying threshold criterion.
85    */
86   vtkSetVector3Macro(InTextureCoord,double);
87   vtkGetVectorMacro(InTextureCoord,double,3);
88   //@}
89 
90   //@{
91   /**
92    * Set the texture coordinate value for point NOT satisfying threshold
93    * criterion.
94    */
95   vtkSetVector3Macro(OutTextureCoord,double);
96   vtkGetVectorMacro(OutTextureCoord,double,3);
97   //@}
98 
99 protected:
100   vtkThresholdTextureCoords();
~vtkThresholdTextureCoords()101   ~vtkThresholdTextureCoords() override {}
102 
103   // Usual data generation method
104   int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override;
105 
106   double LowerThreshold;
107   double UpperThreshold;
108 
109   int TextureDimension;
110 
111   double InTextureCoord[3];
112   double OutTextureCoord[3];
113 
114   int (vtkThresholdTextureCoords::*ThresholdFunction)(double s);
115 
Lower(double s)116   int Lower(double s) {return ( s <= this->LowerThreshold ? 1 : 0 );};
Upper(double s)117   int Upper(double s) {return ( s >= this->UpperThreshold ? 1 : 0 );};
Between(double s)118   int Between(double s) {return ( s >= this->LowerThreshold ?
119                                ( s <= this->UpperThreshold ? 1 : 0 ) : 0 );};
120 private:
121   vtkThresholdTextureCoords(const vtkThresholdTextureCoords&) = delete;
122   void operator=(const vtkThresholdTextureCoords&) = delete;
123 };
124 
125 #endif
126