00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00100 #ifndef __vtkMultiThreshold_h
00101 #define __vtkMultiThreshold_h
00102
00103 #include "vtkMultiBlockDataSetAlgorithm.h"
00104 #include "vtkMath.h"
00105
00106 #include <vtkstd/vector>
00107 #include <vtkstd/map>
00108 #include <vtkstd/set>
00109 #include <vtkstd/string>
00110
00111 class vtkCell;
00112 class vtkCellData;
00113 class vtkDataArray;
00114 class vtkGenericCell;
00115 class vtkPointSet;
00116 class vtkUnstructuredGrid;
00117
00118 class VTK_GRAPHICS_EXPORT vtkMultiThreshold : public vtkMultiBlockDataSetAlgorithm
00119 {
00120 public:
00121 vtkTypeMacro(vtkMultiThreshold,vtkMultiBlockDataSetAlgorithm);
00122 static vtkMultiThreshold* New();
00123 virtual void PrintSelf( ostream& os, vtkIndent indent );
00124
00125
00127 enum Closure {
00128 OPEN=0,
00129 CLOSED=1
00130 };
00132 enum Norm {
00133 LINFINITY_NORM=-3,
00134 L2_NORM=-2,
00135 L1_NORM=-1
00136 };
00138 enum SetOperation {
00139 AND,
00140 OR,
00141 XOR,
00142 WOR,
00143 NAND
00144 };
00145
00146
00148
00191 int AddIntervalSet( double xmin, double xmax, int omin, int omax,
00192 int assoc, const char* arrayName, int component, int allScalars );
00193 int AddIntervalSet( double xmin, double xmax, int omin, int omax,
00194 int assoc, int attribType, int component, int allScalars );
00196
00198
00204 int AddLowpassIntervalSet( double xmax, int assoc, const char* arrayName, int component, int allScalars );
00205 int AddHighpassIntervalSet( double xmin, int assoc, const char* arrayName, int component, int allScalars );
00206 int AddBandpassIntervalSet( double xmin, double xmax, int assoc, const char* arrayName, int component, int allScalars );
00207 int AddNotchIntervalSet( double xlo, double xhi, int assoc, const char* arrayName, int component, int allScalars );
00209
00212 int AddBooleanSet( int operation, int numInputs, int* inputs );
00213
00216 int OutputSet( int setId );
00217
00219 void Reset();
00220
00221
00223 typedef double (*TupleNorm)( vtkDataArray* arr, vtkIdType tuple, int component );
00224
00225
00226 class NormKey;
00227
00228
00229 class Interval;
00230
00231
00232 class BooleanSet;
00233
00235 class NormKey {
00236 public:
00237 int Association;
00238 int Type;
00239 vtkstd::string Name;
00240 int Component;
00241 int AllScalars;
00242 int InputArrayIndex;
00243 TupleNorm NormFunction;
00244
00246 void ComputeNorm( vtkIdType cellId, vtkCell* cell, vtkDataArray* array, double cellNorm[2] ) const;
00247
00249 bool operator < ( const NormKey& other ) const {
00250 if ( this->Association < other.Association )
00251 return true;
00252 else if ( this->Association > other.Association )
00253 return false;
00254
00255 if ( this->Component < other.Component )
00256 return true;
00257 else if ( this->Component > other.Component )
00258 return false;
00259
00260 if ( (! this->AllScalars) && other.AllScalars )
00261 return true;
00262 else if ( this->AllScalars && (! other.AllScalars) )
00263 return false;
00264
00265 if ( this->Type == -1 )
00266 {
00267 if ( other.Type == -1 )
00268 return this->Name < other.Name;
00269 return true;
00270 }
00271 else
00272 {
00273 return this->Type < other.Type;
00274 }
00275 }
00276 };
00277
00282 class Set {
00283 public:
00284 int Id;
00285 int OutputId;
00286
00288 Set() {
00289 this->OutputId = -1;
00290 }
00292 virtual ~Set() { }
00294 virtual void PrintNodeName( ostream& os );
00296 virtual void PrintNode( ostream& os ) = 0;
00298 virtual BooleanSet* GetBooleanSetPointer();
00299 virtual Interval* GetIntervalPointer();
00300 };
00301
00303 class Interval : public Set {
00304 public:
00306 double EndpointValues[2];
00308 int EndpointClosures[2];
00310 NormKey Norm;
00311
00316 int Match( double cellNorm[2] );
00317
00318 virtual ~Interval() { }
00319 virtual void PrintNode( ostream& os );
00320 virtual Interval* GetIntervalPointer();
00321 };
00322
00324 class BooleanSet : public Set {
00325 public:
00327 int Operator;
00329 vtkstd::vector<int> Inputs;
00330
00332 BooleanSet( int sId, int op, int* inBegin, int* inEnd ) : Inputs( inBegin, inEnd ) {
00333 this->Id = sId;
00334 this->Operator = op;
00335 }
00336 virtual ~BooleanSet() { }
00337 virtual void PrintNode( ostream& os );
00338 virtual BooleanSet* GetBooleanSetPointer();
00339 };
00340
00341
00342 protected:
00343
00344 vtkMultiThreshold();
00345 virtual ~vtkMultiThreshold();
00346
00347
00349
00360 enum Ruling {
00361 INCONCLUSIVE=-1,
00362 INCLUDE=-2,
00363 EXCLUDE=-3
00364 };
00365
00367
00369 virtual int RequestData( vtkInformation*, vtkInformationVector**, vtkInformationVector* );
00370
00374 virtual int FillInputPortInformation( int port, vtkInformation* info );
00375
00380 int NextArrayIndex;
00381
00383 int NumberOfOutputs;
00384
00385
00387 typedef vtkstd::vector<Interval*> IntervalList;
00389 typedef vtkstd::map<NormKey,IntervalList> RuleMap;
00390
00391 typedef vtkstd::vector<int> TruthTreeValues;
00392 typedef vtkstd::vector<TruthTreeValues> TruthTree;
00393
00396 RuleMap IntervalRules;
00397
00401 vtkstd::vector<Set*> Sets;
00402
00408 TruthTree DependentSets;
00409
00411
00413 void UpdateDependents(
00414 int id, vtkstd::set<int>& unresolvedOutputs, TruthTreeValues& setStates,
00415 vtkCellData* inCellData, vtkIdType cellId, vtkGenericCell* cell, vtkstd::vector<vtkUnstructuredGrid*>& outv );
00417
00419 int AddIntervalSet( NormKey& nk, double xmin, double xmax, int omin, int omax );
00420
00421
00422
00424 void PrintGraph( ostream& os );
00425
00426 vtkMultiThreshold( const vtkMultiThreshold& );
00427 void operator = ( const vtkMultiThreshold& );
00428 };
00429
00430 inline int vtkMultiThreshold::AddLowpassIntervalSet( double xmax, int assoc, const char* arrayName, int component, int allScalars )
00431 {
00432 return this->AddIntervalSet( vtkMath::NegInf(), xmax, CLOSED, CLOSED, assoc, arrayName, component, allScalars );
00433 }
00434
00435 inline int vtkMultiThreshold::AddHighpassIntervalSet( double xmin, int assoc, const char* arrayName, int component, int allScalars )
00436 {
00437 return this->AddIntervalSet( xmin, vtkMath::Inf(), CLOSED, CLOSED, assoc, arrayName, component, allScalars );
00438 }
00439
00440 inline int vtkMultiThreshold::AddBandpassIntervalSet(
00441 double xmin, double xmax, int assoc, const char* arrayName, int component, int allScalars )
00442 {
00443 return this->AddIntervalSet( xmin, xmax, CLOSED, CLOSED, assoc, arrayName, component, allScalars );
00444 }
00445
00446 inline int vtkMultiThreshold::AddNotchIntervalSet(
00447 double xlo, double xhi, int assoc, const char* arrayName, int component, int allScalars )
00448 {
00449 int band = this->AddIntervalSet( xlo, xhi, CLOSED, CLOSED, assoc, arrayName, component, allScalars );
00450 if ( band < 0 )
00451 {
00452 return -1;
00453 }
00454 return this->AddBooleanSet( NAND, 1, &band );
00455 }
00456
00457 inline vtkMultiThreshold::Interval* vtkMultiThreshold::Set::GetIntervalPointer()
00458 {
00459 return 0;
00460 }
00461
00462 inline vtkMultiThreshold::BooleanSet* vtkMultiThreshold::Set::GetBooleanSetPointer()
00463 {
00464 return 0;
00465 }
00466
00467 inline vtkMultiThreshold::Interval* vtkMultiThreshold::Interval::GetIntervalPointer()
00468 {
00469 return this;
00470 }
00471
00472 inline vtkMultiThreshold::BooleanSet* vtkMultiThreshold::BooleanSet::GetBooleanSetPointer()
00473 {
00474 return this;
00475 }
00476
00477 #endif // __vtkMultiThreshold_h