VTK
vtkMultiThreshold.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkMultiThreshold.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 Copyright (c) Sandia Corporation
17 See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
18----------------------------------------------------------------------------*/
19
104#ifndef vtkMultiThreshold_h
105#define vtkMultiThreshold_h
106
107#include "vtkFiltersGeneralModule.h" // For export macro
109#include "vtkMath.h" // for Inf() and NegInf()
110
111#include <vector> // for lists of threshold rules
112#include <map> // for IntervalRules map
113#include <set> // for UpdateDependents()
114#include <string> // for holding array names in NormKey
115
116class vtkCell;
117class vtkCellData;
118class vtkDataArray;
119class vtkGenericCell;
120class vtkPointSet;
122
123class VTKFILTERSGENERAL_EXPORT vtkMultiThreshold : public vtkMultiBlockDataSetAlgorithm
124{
125public:
128 void PrintSelf( ostream& os, vtkIndent indent ) VTK_OVERRIDE;
129
131 enum Closure {
132 OPEN=0,
133 CLOSED=1
134 };
136 enum Norm {
137 LINFINITY_NORM=-3,
138 L2_NORM=-2,
139 L1_NORM=-1
140 };
147 NAND
148 };
149
151
193 int AddIntervalSet( double xmin, double xmax, int omin, int omax,
194 int assoc, const char* arrayName, int component, int allScalars );
195 int AddIntervalSet( double xmin, double xmax, int omin, int omax,
196 int assoc, int attribType, int component, int allScalars );
198
200
207 int AddLowpassIntervalSet( double xmax, int assoc, const char* arrayName, int component, int allScalars );
208 int AddHighpassIntervalSet( double xmin, int assoc, const char* arrayName, int component, int allScalars );
209 int AddBandpassIntervalSet( double xmin, double xmax, int assoc, const char* arrayName, int component, int allScalars );
210 int AddNotchIntervalSet( double xlo, double xhi, int assoc, const char* arrayName, int component, int allScalars );
212
216 int AddBooleanSet( int operation, int numInputs, int* inputs );
217
221 int OutputSet( int setId );
222
226 void Reset();
227
229 typedef double (*TupleNorm)( vtkDataArray* arr, vtkIdType tuple, int component );
230
231 // NormKey must be able to use TupleNorm typedef:
232 class NormKey;
233
234 // Interval must be able to use NormKey typedef:
235 class Interval;
236
237 // Set needs to refer to boolean set pointers
238 class BooleanSet;
239
241 class NormKey {
242 public:
243 int Association; // vtkDataObject::FIELD_ASSOCIATION_POINTS or vtkDataObject::FIELD_ASSOCIATION_CELLS
244 int Type; // -1 => use Name, otherwise: vtkDataSetAttributes::{SCALARS, VECTORS, TENSORS, NORMALS, TCOORDS, GLOBALIDS}
245 std::string Name; // Either empty or (when ArrayType == -1) an input array name
246 int Component; // LINFINITY_NORM, L1_NORM, L2_NORM or an integer component number
247 int AllScalars; // For Association == vtkDataObject::FIELD_ASSOCIATION_POINTS, must all points be in the interval?
248 int InputArrayIndex; // The number passed to vtkAlgorithm::SetInputArrayToProcess()
249 TupleNorm NormFunction; // A function pointer to compute the norm (or fetcht the correct component) of a tuple.
250
252 void ComputeNorm( vtkIdType cellId, vtkCell* cell, vtkDataArray* array, double cellNorm[2] ) const;
253
255 bool operator < ( const NormKey& other ) const {
256 if ( this->Association < other.Association )
257 return true;
258 else if ( this->Association > other.Association )
259 return false;
260
261 if ( this->Component < other.Component )
262 return true;
263 else if ( this->Component > other.Component )
264 return false;
265
266 if ( (! this->AllScalars) && other.AllScalars )
267 return true;
268 else if ( this->AllScalars && (! other.AllScalars) )
269 return false;
270
271 if ( this->Type == -1 )
272 {
273 if ( other.Type == -1 )
274 return this->Name < other.Name;
275 return true;
276 }
277 else
278 {
279 return this->Type < other.Type;
280 }
281 }
282 };
283
288 class Set {
289 public:
290 int Id;
292
294 Set() {
295 this->OutputId = -1;
296 }
298 virtual ~Set() { }
300 virtual void PrintNodeName( ostream& os );
302 virtual void PrintNode( ostream& os ) = 0;
304 virtual BooleanSet* GetBooleanSetPointer();
305 virtual Interval* GetIntervalPointer();
306 };
307
309 class Interval : public Set {
310 public:
312 double EndpointValues[2];
314 int EndpointClosures[2];
317
322 int Match( double cellNorm[2] );
323
324 ~Interval() VTK_OVERRIDE { }
325 void PrintNode( ostream& os ) VTK_OVERRIDE;
326 Interval* GetIntervalPointer() VTK_OVERRIDE;
327 };
328
330 class BooleanSet : public Set {
331 public:
335 std::vector<int> Inputs;
336
338 BooleanSet( int sId, int op, int* inBegin, int* inEnd ) : Inputs( inBegin, inEnd ) {
339 this->Id = sId;
340 this->Operator = op;
341 }
342 ~BooleanSet() VTK_OVERRIDE { }
343 void PrintNode( ostream& os ) VTK_OVERRIDE;
344 BooleanSet* GetBooleanSetPointer() VTK_OVERRIDE;
345 };
346
347protected:
348
350 ~vtkMultiThreshold() VTK_OVERRIDE;
351
366 enum Ruling {
367 INCONCLUSIVE=-1,
368 INCLUDE=-2,
369 EXCLUDE=-3
370 };
371
376
383
390
395
397 typedef std::vector<Interval*> IntervalList;
399 typedef std::map<NormKey,IntervalList> RuleMap;
400
401 typedef std::vector<int> TruthTreeValues;
402 typedef std::vector<TruthTreeValues> TruthTree;
403
408
413 std::vector<Set*> Sets;
414
422
427 int id, std::set<int>& unresolvedOutputs, TruthTreeValues& setStates,
428 vtkCellData* inCellData, vtkIdType cellId, vtkGenericCell* cell, std::vector<vtkUnstructuredGrid*>& outv );
429
433 int AddIntervalSet( NormKey& nk, double xmin, double xmax, int omin, int omax );
434
438 void PrintGraph( ostream& os );
439
440 vtkMultiThreshold( const vtkMultiThreshold& ) VTK_DELETE_FUNCTION;
441 void operator = ( const vtkMultiThreshold& ) VTK_DELETE_FUNCTION;
442};
443
444inline int vtkMultiThreshold::AddLowpassIntervalSet( double xmax, int assoc, const char* arrayName, int component, int allScalars )
445{
446 return this->AddIntervalSet( vtkMath::NegInf(), xmax, CLOSED, CLOSED, assoc, arrayName, component, allScalars );
447}
448
449inline int vtkMultiThreshold::AddHighpassIntervalSet( double xmin, int assoc, const char* arrayName, int component, int allScalars )
450{
451 return this->AddIntervalSet( xmin, vtkMath::Inf(), CLOSED, CLOSED, assoc, arrayName, component, allScalars );
452}
453
455 double xmin, double xmax, int assoc, const char* arrayName, int component, int allScalars )
456{
457 return this->AddIntervalSet( xmin, xmax, CLOSED, CLOSED, assoc, arrayName, component, allScalars );
458}
459
461 double xlo, double xhi, int assoc, const char* arrayName, int component, int allScalars )
462{
463 int band = this->AddIntervalSet( xlo, xhi, CLOSED, CLOSED, assoc, arrayName, component, allScalars );
464 if ( band < 0 )
465 {
466 return -1;
467 }
468 return this->AddBooleanSet( NAND, 1, &band );
469}
470
472{
473 return 0;
474}
475
477{
478 return 0;
479}
480
482{
483 return this;
484}
485
487{
488 return this;
489}
490
491#endif // vtkMultiThreshold_h
represent and manipulate cell attribute data
Definition: vtkCellData.h:39
abstract class to specify cell behavior
Definition: vtkCell.h:60
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
provides thread-safe access to cells
a simple class to control print indentation
Definition: vtkIndent.h:40
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
static double NegInf()
Special IEEE-754 number used to represent negative infinity.
static double Inf()
Special IEEE-754 number used to represent positive infinity.
Superclass for algorithms that produce only vtkMultiBlockDataSet as output.
A subset of a mesh represented as a boolean set operation.
int Operator
The boolean operation that will be performed on the inputs to obtain the output.
BooleanSet(int sId, int op, int *inBegin, int *inEnd)
Construct a new set with the given ID, operator, and inputs.
void PrintNode(ostream &os) override
Print a graphviz node name for use in an edge statement.
std::vector< int > Inputs
A list of input sets. These may be IntervalSets or BooleanSets.
BooleanSet * GetBooleanSetPointer() override
Avoid dynamic_casts. Subclasses must override.
A subset of a mesh represented by a range of acceptable attribute values.
void PrintNode(ostream &os) override
Print a graphviz node name for use in an edge statement.
int Match(double cellNorm[2])
Does the specified range fall inside the interval? For cell-centered attributes, only cellNorm[0] is ...
NormKey Norm
This contains information about the attribute over which the interval is defined.
Interval * GetIntervalPointer() override
A class with comparison operator used to index input array norms used in threshold rules.
void ComputeNorm(vtkIdType cellId, vtkCell *cell, vtkDataArray *array, double cellNorm[2]) const
Compute the norm of a cell by calling NormFunction for all its points or for its single cell-centered...
A base class for representing threshold sets.
int OutputId
A unique identifier for this set.
virtual Interval * GetIntervalPointer()
virtual void PrintNodeName(ostream &os)
Print a graphviz node label statement (with fancy node name and shape).
virtual ~Set()
Virtual destructor since we have virtual members.
virtual void PrintNode(ostream &os)=0
Print a graphviz node name for use in an edge statement.
virtual BooleanSet * GetBooleanSetPointer()
Avoid dynamic_casts. Subclasses must override.
Set()
The index of the output mesh that will hold this set or -1 if the set is not output.
Threshold cells within multiple intervals.
TruthTree DependentSets
A list of boolean sets whose values depend on the given set.
int NumberOfOutputs
The number of output datasets.
static vtkMultiThreshold * New()
Ruling
When an interval is evaluated, its value is used to update a truth table.
Norm
Norms that can be used to threshold vector attributes.
std::vector< Set * > Sets
A list of rules keyed by their unique integer ID.
std::vector< Interval * > IntervalList
A list of pointers to IntervalSets.
int NextArrayIndex
A variable used to store the next index to use when calling SetInputArrayToProcess.
RuleMap IntervalRules
A set of threshold rules sorted by the attribute+norm to which they are applied.
int AddBandpassIntervalSet(double xmin, double xmax, int assoc, const char *arrayName, int component, int allScalars)
std::vector< int > TruthTreeValues
void Reset()
Remove all the intervals currently defined.
vtkMultiThreshold(const vtkMultiThreshold &) VTK_DELETE_FUNCTION
int AddLowpassIntervalSet(double xmax, int assoc, const char *arrayName, int component, int allScalars)
These convenience members make it easy to insert closed intervals.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void PrintGraph(ostream &os)
Print out a graphviz-formatted text description of all the sets.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This function performs the actual thresholding.
int AddBooleanSet(int operation, int numInputs, int *inputs)
Create a new mesh subset using boolean operations on pre-existing sets.
int OutputSet(int setId)
Create an output mesh containing a boolean or interval subset of the input mesh.
int AddIntervalSet(double xmin, double xmax, int omin, int omax, int assoc, int attribType, int component, int allScalars)
int AddIntervalSet(double xmin, double xmax, int omin, int omax, int assoc, const char *arrayName, int component, int allScalars)
Add a mesh subset to be computed by thresholding an attribute of the input mesh.
int AddNotchIntervalSet(double xlo, double xhi, int assoc, const char *arrayName, int component, int allScalars)
SetOperation
Operations that can be performed on sets to generate another set. Most of these operators take 2 or m...
@ WOR
Include elements that belong to an odd number of input sets (a kind of "winding XOR")
@ XOR
Include an element if it belongs to exactly one input set.
@ AND
Only include an element if it belongs to all the input sets.
@ OR
Include an element if it belongs to any input set.
void UpdateDependents(int id, std::set< int > &unresolvedOutputs, TruthTreeValues &setStates, vtkCellData *inCellData, vtkIdType cellId, vtkGenericCell *cell, std::vector< vtkUnstructuredGrid * > &outv)
Recursively update the setStates and unresolvedOutputs vectors based on this->DependentSets.
int AddHighpassIntervalSet(double xmin, int assoc, const char *arrayName, int component, int allScalars)
Closure
Whether the endpoint value of an interval should be included or excluded.
std::map< NormKey, IntervalList > RuleMap
A map describing the IntervalSets that share a common attribute and norm.
int FillInputPortInformation(int port, vtkInformation *info) override
We accept any mesh that is descended from vtkPointSet.
std::vector< TruthTreeValues > TruthTree
int AddIntervalSet(NormKey &nk, double xmin, double xmax, int omin, int omax)
A utility method called by the public AddInterval members.
abstract class for specifying dataset behavior
Definition: vtkPointSet.h:43
dataset represents arbitrary combinations of all possible cell types
@ component
Definition: vtkX3D.h:175
@ info
Definition: vtkX3D.h:376
@ port
Definition: vtkX3D.h:447
@ string
Definition: vtkX3D.h:490
int vtkIdType
Definition: vtkType.h:287
VTKCOMMONCORE_EXPORT bool operator<(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)