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 
103 #ifndef vtkMultiThreshold_h
104 #define vtkMultiThreshold_h
105 
106 #include "vtkFiltersGeneralModule.h" // For export macro
108 #include "vtkMath.h" // for Inf() and NegInf()
109 
110 #include <vector> // for lists of threshold rules
111 #include <map> // for IntervalRules map
112 #include <set> // for UpdateDependents()
113 #include <string> // for holding array names in NormKey
114 
115 class vtkCell;
116 class vtkCellData;
117 class vtkDataArray;
118 class vtkGenericCell;
119 class vtkPointSet;
120 class vtkUnstructuredGrid;
121 
123 {
124 public:
126  static vtkMultiThreshold* New();
127  virtual void PrintSelf( ostream& os, vtkIndent indent );
128 
129  //BTX
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  };
143  AND,
144  OR,
145  XOR,
146  WOR,
147  NAND
148  };
149  //ETX
150 
152 
195  int AddIntervalSet( double xmin, double xmax, int omin, int omax,
196  int assoc, const char* arrayName, int component, int allScalars );
197  int AddIntervalSet( double xmin, double xmax, int omin, int omax,
198  int assoc, int attribType, int component, int allScalars );
200 
202 
208  int AddLowpassIntervalSet( double xmax, int assoc, const char* arrayName, int component, int allScalars );
209  int AddHighpassIntervalSet( double xmin, int assoc, const char* arrayName, int component, int allScalars );
210  int AddBandpassIntervalSet( double xmin, double xmax, int assoc, const char* arrayName, int component, int allScalars );
211  int AddNotchIntervalSet( double xlo, double xhi, int assoc, const char* arrayName, int component, int allScalars );
213 
216  int AddBooleanSet( int operation, int numInputs, int* inputs );
217 
220  int OutputSet( int setId );
221 
223  void Reset();
224 
225  //BTX
227  typedef double (*TupleNorm)( vtkDataArray* arr, vtkIdType tuple, int component );
228 
229  // NormKey must be able to use TupleNorm typedef:
230  class NormKey;
231 
232  // Interval must be able to use NormKey typedef:
233  class Interval;
234 
235  // Set needs to refer to boolean set pointers
236  class BooleanSet;
237 
239  class NormKey {
240  public:
241  int Association; // vtkDataObject::FIELD_ASSOCIATION_POINTS or vtkDataObject::FIELD_ASSOCIATION_CELLS
242  int Type; // -1 => use Name, otherwise: vtkDataSetAttributes::{SCALARS, VECTORS, TENSORS, NORMALS, TCOORDS, GLOBALIDS}
243  std::string Name; // Either empty or (when ArrayType == -1) an input array name
244  int Component; // LINFINITY_NORM, L1_NORM, L2_NORM or an integer component number
245  int AllScalars; // For Association == vtkDataObject::FIELD_ASSOCIATION_POINTS, must all points be in the interval?
246  int InputArrayIndex; // The number passed to vtkAlgorithm::SetInputArrayToProcess()
247  TupleNorm NormFunction; // A function pointer to compute the norm (or fetcht the correct component) of a tuple.
248 
250  void ComputeNorm( vtkIdType cellId, vtkCell* cell, vtkDataArray* array, double cellNorm[2] ) const;
251 
253  bool operator < ( const NormKey& other ) const {
254  if ( this->Association < other.Association )
255  return true;
256  else if ( this->Association > other.Association )
257  return false;
258 
259  if ( this->Component < other.Component )
260  return true;
261  else if ( this->Component > other.Component )
262  return false;
263 
264  if ( (! this->AllScalars) && other.AllScalars )
265  return true;
266  else if ( this->AllScalars && (! other.AllScalars) )
267  return false;
268 
269  if ( this->Type == -1 )
270  {
271  if ( other.Type == -1 )
272  return this->Name < other.Name;
273  return true;
274  }
275  else
276  {
277  return this->Type < other.Type;
278  }
279  }
280  };
281 
286  class Set {
287  public:
288  int Id;
289  int OutputId;
290 
292  Set() {
293  this->OutputId = -1;
294  }
296  virtual ~Set() { }
298  virtual void PrintNodeName( ostream& os );
300  virtual void PrintNode( ostream& os ) = 0;
302  virtual BooleanSet* GetBooleanSetPointer();
303  virtual Interval* GetIntervalPointer();
304  };
305 
307  class Interval : public Set {
308  public:
310  double EndpointValues[2];
312  int EndpointClosures[2];
315 
320  int Match( double cellNorm[2] );
321 
322  virtual ~Interval() { }
323  virtual void PrintNode( ostream& os );
324  virtual Interval* GetIntervalPointer();
325  };
326 
328  class BooleanSet : public Set {
329  public:
331  int Operator;
333  std::vector<int> Inputs;
334 
336  BooleanSet( int sId, int op, int* inBegin, int* inEnd ) : Inputs( inBegin, inEnd ) {
337  this->Id = sId;
338  this->Operator = op;
339  }
340  virtual ~BooleanSet() { }
341  virtual void PrintNode( ostream& os );
342  virtual BooleanSet* GetBooleanSetPointer();
343  };
344  //ETX
345 
346 protected:
347 
349  virtual ~vtkMultiThreshold();
350 
351  //BTX
353 
364  enum Ruling {
365  INCONCLUSIVE=-1,
366  INCLUDE=-2,
367  EXCLUDE=-3
368  };
369  //ETX
371 
374 
378  virtual int FillInputPortInformation( int port, vtkInformation* info );
379 
385 
388 
389  //BTX
391  typedef std::vector<Interval*> IntervalList;
393  typedef std::map<NormKey,IntervalList> RuleMap;
394 
395  typedef std::vector<int> TruthTreeValues;
396  typedef std::vector<TruthTreeValues> TruthTree;
397 
400  RuleMap IntervalRules;
401 
405  std::vector<Set*> Sets;
406 
412  TruthTree DependentSets;
413 
415 
417  void UpdateDependents(
418  int id, std::set<int>& unresolvedOutputs, TruthTreeValues& setStates,
419  vtkCellData* inCellData, vtkIdType cellId, vtkGenericCell* cell, std::vector<vtkUnstructuredGrid*>& outv );
421 
423  int AddIntervalSet( NormKey& nk, double xmin, double xmax, int omin, int omax );
424 
425  //ETX
426 
428  void PrintGraph( ostream& os );
429 
430  vtkMultiThreshold( const vtkMultiThreshold& ); // Not implemented.
431  void operator = ( const vtkMultiThreshold& ); // Not implemented.
432 };
433 
434 inline int vtkMultiThreshold::AddLowpassIntervalSet( double xmax, int assoc, const char* arrayName, int component, int allScalars )
435 {
436  return this->AddIntervalSet( vtkMath::NegInf(), xmax, CLOSED, CLOSED, assoc, arrayName, component, allScalars );
437 }
438 
439 inline int vtkMultiThreshold::AddHighpassIntervalSet( double xmin, int assoc, const char* arrayName, int component, int allScalars )
440 {
441  return this->AddIntervalSet( xmin, vtkMath::Inf(), CLOSED, CLOSED, assoc, arrayName, component, allScalars );
442 }
443 
445  double xmin, double xmax, int assoc, const char* arrayName, int component, int allScalars )
446 {
447  return this->AddIntervalSet( xmin, xmax, CLOSED, CLOSED, assoc, arrayName, component, allScalars );
448 }
449 
451  double xlo, double xhi, int assoc, const char* arrayName, int component, int allScalars )
452 {
453  int band = this->AddIntervalSet( xlo, xhi, CLOSED, CLOSED, assoc, arrayName, component, allScalars );
454  if ( band < 0 )
455  {
456  return -1;
457  }
458  return this->AddBooleanSet( NAND, 1, &band );
459 }
460 
462 {
463  return 0;
464 }
465 
467 {
468  return 0;
469 }
470 
472 {
473  return this;
474 }
475 
477 {
478  return this;
479 }
480 
481 #endif // vtkMultiThreshold_h
std::vector< Set * > Sets
static double NegInf()
Only include elements that don't belong to any input set.
A subset of a mesh represented by a range of acceptable attribute values.
virtual ~Set()
Virtual destructor since we have virtual members.
int Operator
The boolean operation that will be performed on the inputs to obtain the output.
A subset of a mesh represented as a boolean set operation.
std::vector< TruthTreeValues > TruthTree
int AddBooleanSet(int operation, int numInputs, int *inputs)
Store vtkAlgorithm input/output information.
static double Inf()
represent and manipulate cell attribute data
Definition: vtkCellData.h:37
int OutputId
A unique identifier for this set.
virtual Interval * GetIntervalPointer()
Set()
The index of the output mesh that will hold this set or -1 if the set is not output.
BooleanSet(int sId, int op, int *inBegin, int *inEnd)
Construct a new set with the given ID, operator, and inputs.
NormKey Norm
This contains information about the attribute over which the interval is defined. ...
virtual BooleanSet * GetBooleanSetPointer()
Avoid dynamic_casts. Subclasses must override.
std::vector< Interval * > IntervalList
A list of pointers to IntervalSets.
abstract class for specifying dataset behavior
Definition: vtkPointSet.h:44
Include elements that belong to an odd number of input sets (a kind of "winding XOR") ...
int vtkIdType
Definition: vtkType.h:275
int AddBandpassIntervalSet(double xmin, double xmax, int assoc, const char *arrayName, int component, int allScalars)
int AddIntervalSet(double xmin, double xmax, int omin, int omax, int assoc, const char *arrayName, int component, int allScalars)
Superclass for algorithms that produce only vtkMultiBlockDataSet as output.
VTKCOMMONCORE_EXPORT bool operator<(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
provides thread-safe access to cells
static vtkMultiBlockDataSetAlgorithm * New()
int AddLowpassIntervalSet(double xmax, int assoc, const char *arrayName, int component, int allScalars)
abstract class to specify cell behavior
Definition: vtkCell.h:61
int AddHighpassIntervalSet(double xmin, int assoc, const char *arrayName, int component, int allScalars)
a simple class to control print indentation
Definition: vtkIndent.h:38
Closure
Whether the endpoint value of an interval should be included or excluded.
std::vector< int > Inputs
A list of input sets. These may be IntervalSets or BooleanSets.
dataset represents arbitrary combinations of all possible cell types
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
Include an element if it belongs to exactly one input set.
#define VTKFILTERSGENERAL_EXPORT
virtual Interval * GetIntervalPointer()
Specify a closed interval.
std::map< NormKey, IntervalList > RuleMap
A map describing the IntervalSets that share a common attribute and norm.
int AddNotchIntervalSet(double xlo, double xhi, int assoc, const char *arrayName, int component, int allScalars)
Only include an element if it belongs to all the input sets.
virtual int FillInputPortInformation(int port, vtkInformation *info)
void PrintSelf(ostream &os, vtkIndent indent)
SetOperation
Operations that can be performed on sets to generate another set. Most of these operators take 2 or m...
Store zero or more vtkInformation instances.
A class with comparison operator used to index input array norms used in threshold rules...
Norm
Norms that can be used to threshold vector attributes.
Include an element if it belongs to any input set.
Threshold cells within multiple intervals.
virtual BooleanSet * GetBooleanSetPointer()
Avoid dynamic_casts. Subclasses must override.
A base class for representing threshold sets.
std::vector< int > TruthTreeValues