From f086d05e421826fdd8a2063f4dea96245afdf3ab Mon Sep 17 00:00:00 2001 From: rkv Date: Thu, 8 May 2008 10:11:42 +0000 Subject: [PATCH] Filter by scalars range --- src/PIPELINE/VISU_ColoredPL.cxx | 64 ++++++++++++++++++++++++++--- src/PIPELINE/VISU_ColoredPL.hxx | 14 +++++-- src/PIPELINE/VISU_IsoSurfacesPL.cxx | 3 +- 3 files changed, 71 insertions(+), 10 deletions(-) diff --git a/src/PIPELINE/VISU_ColoredPL.cxx b/src/PIPELINE/VISU_ColoredPL.cxx index 5b7b0e3c..dc254482 100644 --- a/src/PIPELINE/VISU_ColoredPL.cxx +++ b/src/PIPELINE/VISU_ColoredPL.cxx @@ -41,7 +41,10 @@ VISU_ColoredPL myMapperTable(VISU_LookupTable::New()), myBarTable(VISU_LookupTable::New()), myExtractor(VISU_Extractor::New()), - myFieldTransform(VISU_FieldTransform::New()) + myFieldTransform(VISU_FieldTransform::New()), + myThreshold(vtkThreshold::New()), // RKV + myPassFilter(vtkPassThroughFilter::New()), // RKV + myIsFiltered(false) // RKV { myMapperTable->Delete(); myMapperTable->SetScale(VTK_SCALE_LINEAR); @@ -54,6 +57,10 @@ VISU_ColoredPL myExtractor->Delete(); myFieldTransform->Delete(); + + myThreshold->AllScalarsOn(); // RKV + myThreshold->Delete(); // RKV + myPassFilter->Delete(); // RKV } @@ -74,6 +81,12 @@ VISU_ColoredPL aTime = std::max(aTime, myBarTable->GetMTime()); aTime = std::max(aTime, myExtractor->GetMTime()); aTime = std::max(aTime, myFieldTransform->GetMTime()); + // RKV : Begin + if (IsFiltered()) { + aTime = std::max(aTime, myThreshold->GetMTime()); + } + aTime = std::max(aTime, myPassFilter->GetMTime()); + // RKV : End return aTime; } @@ -89,7 +102,8 @@ VISU_ColoredPL if(VISU_ColoredPL *aPipeLine = dynamic_cast(thePipeLine)){ if(theIsCopyInput) - SetScalarRange(aPipeLine->GetScalarRange()); + SetScalarRange(aPipeLine->GetScalarRange(), aPipeLine->IsFiltered()); // RKV +// RKV SetScalarRange(aPipeLine->GetScalarRange()); SetScalarMode(aPipeLine->GetScalarMode()); SetNbColors(aPipeLine->GetNbColors()); SetScaling(aPipeLine->GetScaling()); @@ -144,7 +158,6 @@ VISU_ColoredPL theExtractor->SetScalarMode(theScalarMode); } - //---------------------------------------------------------------------------- void VISU_ColoredPL @@ -153,8 +166,8 @@ VISU_ColoredPL SetScalarMode(theScalarMode, GetInput(), myExtractor); } - //---------------------------------------------------------------------------- +/* RKV void VISU_ColoredPL ::SetScalarRange(vtkFloatingPointType theRange[2]) @@ -168,6 +181,33 @@ VISU_ColoredPL myFieldTransform->SetScalarRange(theRange); myBarTable->SetRange(theRange); } +*/ +// RKV : Begin +void +VISU_ColoredPL +::SetScalarRange(vtkFloatingPointType theRange[2], const bool isFiltered) +{ + // isFiltered - if true then drop cells which are not in the scalar range + if(theRange[0] > theRange[1]) + return; + + if(VISU::CheckIsSameRange(GetScalarRange(), theRange) && (myIsFiltered == isFiltered)) + return; + + myFieldTransform->SetScalarRange(theRange); + myBarTable->SetRange(theRange); + myIsFiltered = isFiltered; + if (IsFiltered()) { + // Include threshold filter between the transform and the pass filters. + myThreshold->SetInput(myFieldTransform->GetOutput()); + myThreshold->ThresholdBetween(theRange[0], theRange[1]); + myPassFilter->SetInput(myThreshold->GetOutput()); + } else { + // Exclude threshold filter before the pass filter. + myPassFilter->SetInput(myFieldTransform->GetOutput()); + } +} + // RKV : End //---------------------------------------------------------------------------- vtkFloatingPointType* @@ -232,9 +272,17 @@ vtkPointSet* VISU_ColoredPL ::GetClippedInput() { - if(GetFieldTransformFilter()->GetInput()) +/* RKV if(GetFieldTransformFilter()->GetInput()) GetFieldTransformFilter()->Update(); return GetFieldTransformFilter()->GetUnstructuredGridOutput(); + */ + // RKV : Begin + // The pass filter is used here for possibility to include/exclude + // threshold filter before it. + if(myPassFilter->GetInput()) + myPassFilter->Update(); + return myPassFilter->GetUnstructuredGridOutput(); + // RKV : End } @@ -245,6 +293,9 @@ VISU_ColoredPL { myExtractor->SetInput(Superclass::GetClippedInput()); myFieldTransform->SetInput(myExtractor->GetOutput()); + // The pass filter is used here for possibility to include/exclude + // threshold filter before it. + myPassFilter->SetInput(myFieldTransform->GetOutput()); // RKV GetMapperHolder()->SetLookupTable(GetMapperTable()); GetMapper()->SetUseLookupTableScalarRange(true); @@ -360,5 +411,6 @@ VISU_ColoredPL { vtkFloatingPointType aRange[2]; GetSourceRange(aRange); - SetScalarRange(aRange); +// RKV SetScalarRange(aRange); + SetScalarRange(aRange, myIsFiltered); // RKV } diff --git a/src/PIPELINE/VISU_ColoredPL.hxx b/src/PIPELINE/VISU_ColoredPL.hxx index c22351b8..d66ba185 100644 --- a/src/PIPELINE/VISU_ColoredPL.hxx +++ b/src/PIPELINE/VISU_ColoredPL.hxx @@ -31,12 +31,13 @@ #include "VISU_PipeLine.hxx" #include +#include // RKV +#include // RKV class VISU_Extractor; class VISU_FieldTransform; class VISU_LookupTable; - //---------------------------------------------------------------------------- class VISU_ColoredPL : public VISU_PipeLine { @@ -62,7 +63,8 @@ public: virtual void - SetScalarRange(vtkFloatingPointType theRange[2]); + SetScalarRange(vtkFloatingPointType theRange[2], const bool isFiltered); // RKV +// RKV SetScalarRange(vtkFloatingPointType theRange[2]); virtual void @@ -80,6 +82,10 @@ public: int GetNbColors(); +// RKV : Begin + //---------------------------------------------------------------------------- + bool IsFiltered() {return myIsFiltered;}; +// RKV : End //---------------------------------------------------------------------------- public: virtual @@ -191,7 +197,9 @@ private: vtkSmartPointer myBarTable; vtkSmartPointer myExtractor; vtkSmartPointer myFieldTransform; - + vtkSmartPointer myThreshold; // RKV + vtkSmartPointer myPassFilter; // RKV + bool myIsFiltered; // RKV }; #endif diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.cxx b/src/PIPELINE/VISU_IsoSurfacesPL.cxx index bea9854f..2afeb44d 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.cxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.cxx @@ -115,7 +115,8 @@ void VISU_IsoSurfacesPL ::SetScalarRange(vtkFloatingPointType theRange[2]) { - Superclass::SetScalarRange(theRange); +// RKV Superclass::SetScalarRange(theRange); + Superclass::SetScalarRange(theRange, IsFiltered()); // RKV SetRange(myRange); } -- 2.39.2