]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Filter by scalars range
authorrkv <rkv@opencascade.com>
Thu, 8 May 2008 10:11:42 +0000 (10:11 +0000)
committerrkv <rkv@opencascade.com>
Thu, 8 May 2008 10:11:42 +0000 (10:11 +0000)
src/PIPELINE/VISU_ColoredPL.cxx
src/PIPELINE/VISU_ColoredPL.hxx
src/PIPELINE/VISU_IsoSurfacesPL.cxx

index 5b7b0e3c278ac788ddc90316438873ce5318268f..dc254482a6e1586809dc72aec82425ddfdd5fb32 100644 (file)
@@ -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<VISU_ColoredPL*>(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
 }
index c22351b86169e115fce9aa1a49bf9145679b0a94..d66ba1859252055a88077fd483f6ee40a44a1e28 100644 (file)
 #include "VISU_PipeLine.hxx"
 
 #include <vtkSmartPointer.h>
+#include <vtkThreshold.h> // RKV
+#include <vtkPassThroughFilter.h> // 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<VISU_LookupTable> myBarTable;
   vtkSmartPointer<VISU_Extractor> myExtractor;
   vtkSmartPointer<VISU_FieldTransform> myFieldTransform;
-  
+  vtkSmartPointer<vtkThreshold> myThreshold; // RKV
+  vtkSmartPointer<vtkPassThroughFilter> myPassFilter; // RKV
+  bool myIsFiltered; // RKV
 };
   
 #endif
index bea9854f35cfe9ffd5ba52774d85447d5dcf67e6..2afeb44d2bbf24413274d8efc3296c176e6a4762 100644 (file)
@@ -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);
 }