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 
100 #ifndef __vtkMultiThreshold_h
101 #define __vtkMultiThreshold_h
102 
104 #include "vtkMath.h" // for Inf() and NegInf()
105 
106 #include <vtkstd/vector> // for lists of threshold rules
107 #include <vtkstd/map> // for IntervalRules map
108 #include <vtkstd/set> // for UpdateDependents()
109 #include <vtkstd/string> // for holding array names in NormKey
110 
111 class vtkCell;
112 class vtkCellData;
113 class vtkDataArray;
114 class vtkGenericCell;
115 class vtkPointSet;
116 class vtkUnstructuredGrid;
117 
119 {
120 public:
122  static vtkMultiThreshold* New();
123  virtual void PrintSelf( ostream& os, vtkIndent indent );
124 
125  //BTX
127  enum Closure {
128  OPEN=0,
129  CLOSED=1
130  };
132  enum Norm {
133  LINFINITY_NORM=-3,
134  L2_NORM=-2,
135  L1_NORM=-1
136  };
139  AND,
140  OR,
141  XOR,
142  WOR,
143  NAND
144  };
145  //ETX
146 
148 
191  int AddIntervalSet( double xmin, double xmax, int omin, int omax,
192  int assoc, const char* arrayName, int component, int allScalars );
193  int AddIntervalSet( double xmin, double xmax, int omin, int omax,
194  int assoc, int attribType, int component, int allScalars );
196 
198 
204  int AddLowpassIntervalSet( double xmax, int assoc, const char* arrayName, int component, int allScalars );
205  int AddHighpassIntervalSet( double xmin, int assoc, const char* arrayName, int component, int allScalars );
206  int AddBandpassIntervalSet( double xmin, double xmax, int assoc, const char* arrayName, int component, int allScalars );
207  int AddNotchIntervalSet( double xlo, double xhi, int assoc, const char* arrayName, int component, int allScalars );
209 
212  int AddBooleanSet( int operation, int numInputs, int* inputs );
213 
216  int OutputSet( int setId );
217 
219  void Reset();
220 
221  //BTX
223  typedef double (*TupleNorm)( vtkDataArray* arr, vtkIdType tuple, int component );
224 
225  // NormKey must be able to use TupleNorm typedef:
226  class NormKey;
227 
228  // Interval must be able to use NormKey typedef:
229  class Interval;
230 
231  // Set needs to refer to boolean set pointers
232  class BooleanSet;
233 
235  class NormKey {
236  public:
237  int Association; // vtkDataObject::FIELD_ASSOCIATION_POINTS or vtkDataObject::FIELD_ASSOCIATION_CELLS
238  int Type; // -1 => use Name, otherwise: vtkDataSetAttributes::{SCALARS, VECTORS, TENSORS, NORMALS, TCOORDS, GLOBALIDS}
239  vtkstd::string Name; // Either empty or (when ArrayType == -1) an input array name
240  int Component; // LINFINITY_NORM, L1_NORM, L2_NORM or an integer component number
241  int AllScalars; // For Association == vtkDataObject::FIELD_ASSOCIATION_POINTS, must all points be in the interval?
242  int InputArrayIndex; // The number passed to vtkAlgorithm::SetInputArrayToProcess()
243  TupleNorm NormFunction; // A function pointer to compute the norm (or fetcht the correct component) of a tuple.
244 
246  void ComputeNorm( vtkIdType cellId, vtkCell* cell, vtkDataArray* array, double cellNorm[2] ) const;
247 
249  bool operator < ( const NormKey& other ) const {
250  if ( this->Association < other.Association )
251  return true;
252  else if ( this->Association > other.Association )
253  return false;
254 
255  if ( this->Component < other.Component )
256  return true;
257  else if ( this->Component > other.Component )
258  return false;
259 
260  if ( (! this->AllScalars) && other.AllScalars )
261  return true;
262  else if ( this->AllScalars && (! other.AllScalars) )
263  return false;
264 
265  if ( this->Type == -1 )
266  {
267  if ( other.Type == -1 )
268  return this->Name < other.Name;
269  return true;
270  }
271  else
272  {
273  return this->Type < other.Type;
274  }
275  }
276  };
277 
282  class Set {
283  public:
284  int Id;
285  int OutputId;
286 
288  Set() {
289  this->OutputId = -1;
290  }
292  virtual ~Set() { }
294  virtual void PrintNodeName( ostream& os );
296  virtual void PrintNode( ostream& os ) = 0;
298  virtual BooleanSet* GetBooleanSetPointer();
299  virtual Interval* GetIntervalPointer();
300  };
301 
303  class Interval : public Set {
304  public:
306  double EndpointValues[2];
308  int EndpointClosures[2];
311 
316  int Match( double cellNorm[2] );
317 
318  virtual ~Interval() { }
319  virtual void PrintNode( ostream& os );
320  virtual Interval* GetIntervalPointer();
321  };
322 
324  class BooleanSet : public Set {
325  public:
327  int Operator;
329  vtkstd::vector<int> Inputs;
330 
332  BooleanSet( int sId, int op, int* inBegin, int* inEnd ) : Inputs( inBegin, inEnd ) {
333  this->Id = sId;
334  this->Operator = op;
335  }
336  virtual ~BooleanSet() { }
337  virtual void PrintNode( ostream& os );
338  virtual BooleanSet* GetBooleanSetPointer();
339  };
340  //ETX
341 
342 protected:
343 
345  virtual ~vtkMultiThreshold();
346 
347  //BTX
349 
360  enum Ruling {
361  INCONCLUSIVE=-1,
362  INCLUDE=-2,
363  EXCLUDE=-3
364  };
365  //ETX
367 
370 
374  virtual int FillInputPortInformation( int port, vtkInformation* info );
375 
381 
384 
385  //BTX
387  typedef vtkstd::vector<Interval*> IntervalList;
389  typedef vtkstd::map<NormKey,IntervalList> RuleMap;
390 
391  typedef vtkstd::vector<int> TruthTreeValues;
392  typedef vtkstd::vector<TruthTreeValues> TruthTree;
393 
396  RuleMap IntervalRules;
397 
401  vtkstd::vector<Set*> Sets;
402 
408  TruthTree DependentSets;
409 
411 
413  void UpdateDependents(
414  int id, vtkstd::set<int>& unresolvedOutputs, TruthTreeValues& setStates,
415  vtkCellData* inCellData, vtkIdType cellId, vtkGenericCell* cell, vtkstd::vector<vtkUnstructuredGrid*>& outv );
417 
419  int AddIntervalSet( NormKey& nk, double xmin, double xmax, int omin, int omax );
420 
421  //ETX
422 
424  void PrintGraph( ostream& os );
425 
426  vtkMultiThreshold( const vtkMultiThreshold& ); // Not implemented.
427  void operator = ( const vtkMultiThreshold& ); // Not implemented.
428 };
429 
430 inline int vtkMultiThreshold::AddLowpassIntervalSet( double xmax, int assoc, const char* arrayName, int component, int allScalars )
431 {
432  return this->AddIntervalSet( vtkMath::NegInf(), xmax, CLOSED, CLOSED, assoc, arrayName, component, allScalars );
433 }
434 
435 inline int vtkMultiThreshold::AddHighpassIntervalSet( double xmin, int assoc, const char* arrayName, int component, int allScalars )
436 {
437  return this->AddIntervalSet( xmin, vtkMath::Inf(), CLOSED, CLOSED, assoc, arrayName, component, allScalars );
438 }
439 
441  double xmin, double xmax, int assoc, const char* arrayName, int component, int allScalars )
442 {
443  return this->AddIntervalSet( xmin, xmax, CLOSED, CLOSED, assoc, arrayName, component, allScalars );
444 }
445 
447  double xlo, double xhi, int assoc, const char* arrayName, int component, int allScalars )
448 {
449  int band = this->AddIntervalSet( xlo, xhi, CLOSED, CLOSED, assoc, arrayName, component, allScalars );
450  if ( band < 0 )
451  {
452  return -1;
453  }
454  return this->AddBooleanSet( NAND, 1, &band );
455 }
456 
458 {
459  return 0;
460 }
461 
463 {
464  return 0;
465 }
466 
468 {
469  return this;
470 }
471 
473 {
474  return this;
475 }
476 
477 #endif // __vtkMultiThreshold_h
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.
#define VTK_GRAPHICS_EXPORT
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.
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:36
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.
vtkstd::vector< Set * > Sets
vtkstd::vector< Interval * > IntervalList
A list of pointers to IntervalSets.
abstract class for specifying dataset behavior
Definition: vtkPointSet.h:40
Include elements that belong to an odd number of input sets (a kind of "winding XOR") ...
int vtkIdType
Definition: vtkType.h:255
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.
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:57
int AddHighpassIntervalSet(double xmin, int assoc, const char *arrayName, int component, int allScalars)
vtkstd::vector< int > TruthTreeValues
a simple class to control print indentation
Definition: vtkIndent.h:37
Closure
Whether the endpoint value of an interval should be included or excluded.
VTK_COMMON_EXPORT bool operator<(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
dataset represents arbitrary combinations of all possible cell types
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:53
Include an element if it belongs to exactly one input set.
vtkstd::vector< TruthTreeValues > TruthTree
virtual Interval * GetIntervalPointer()
Specify a closed interval.
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)
vtkstd::vector< int > Inputs
A list of input sets. These may be IntervalSets or BooleanSets.
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.
vtkstd::map< NormKey, IntervalList > RuleMap
A map describing the IntervalSets that share a common attribute and norm.
virtual BooleanSet * GetBooleanSetPointer()
Avoid dynamic_casts. Subclasses must override.
A base class for representing threshold sets.