]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Implementation of clipping planes support for ScalarMapOnDeformedShape
authorapo <apo@opencascade.com>
Thu, 10 May 2007 15:04:31 +0000 (15:04 +0000)
committerapo <apo@opencascade.com>
Thu, 10 May 2007 15:04:31 +0000 (15:04 +0000)
src/PIPELINE/VISU_PipeLine.cxx
src/PIPELINE/VISU_PipeLine.hxx
src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx
src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx

index ea4f8da731f70e01c74e934428b0ae0055c5a074..704dd556d9846d348f6fd457665681533098bb60 100644 (file)
@@ -38,7 +38,6 @@
 #include <vtkUnstructuredGrid.h>
 
 #include <vtkPlane.h>
-#include <vtkExtractGeometry.h>
 #include <vtkImplicitBoolean.h>
 #include <vtkImplicitFunction.h>
 #include <vtkImplicitFunctionCollection.h>
index 92e6296e22611875849269c0a0a706dad3c1cbcf..fc360f6b62956326365b39029a191cf0d2c0e34f 100644 (file)
@@ -145,12 +145,14 @@ public:
                     vtkFloatingPointType theMinSize = 1024*1024.0);
 
   // Clipping planes
+  virtual
   void 
   RemoveAllClippingPlanes();
 
   vtkIdType
   GetNumberOfClippingPlanes() const;
 
+  virtual
   bool
   AddClippingPlane(vtkPlane* thePlane);
 
@@ -200,6 +202,7 @@ public:
   const VISU::PIDMapper&  
   GetIDMapper()const;
 
+  virtual
   void
   SetImplicitFunction(vtkImplicitFunction *theFunction);
 
index 6a0be83a0c1ccecb4d739a6685d2b4675bc7ac0c..202d14cf97e7477c64db6f6e80ec13c288d430ad 100644 (file)
 #include "VTKViewer_TransformFilter.h"
 #include "VTKViewer_Transform.h"
 
+#include "SALOME_ExtractGeometry.h"
+
+#include <vtkPlane.h>
+#include <vtkImplicitBoolean.h>
+#include <vtkImplicitFunction.h>
+#include <vtkImplicitFunctionCollection.h>
+
 #include <vtkWarpVector.h>
 #include <vtkUnstructuredGrid.h>
 #include <vtkPointDataToCellData.h>
@@ -52,20 +59,25 @@ vtkStandardNewMacro(VISU_ScalarMapOnDeformedShapePL)
  * \li myScalars is vtk shared pointer to vtkUnstructuredGrid - scalars data
 */
 VISU_ScalarMapOnDeformedShapePL
-::VISU_ScalarMapOnDeformedShapePL()
+::VISU_ScalarMapOnDeformedShapePL():
+  myScalarsExtractGeometry(SALOME_ExtractGeometry::New())
 {
+  myCellDataToPointData = VISU_CellDataToPointData::New();
+
   myWarpVector = vtkWarpVector::New();
 
-  myScalarsMergeFilter = VISU_MergeFilter::New();
-  myScalarsMergeFilter->SetMergingInputs(true);
+  myScalarsExtractGeometry->SetInput(myMergeFilter->GetOutput());
+  vtkImplicitBoolean* anImplicitBoolean = vtkImplicitBoolean::New();
+  myScalarsExtractGeometry->SetImplicitFunction(anImplicitBoolean);
+  anImplicitBoolean->SetOperationTypeToIntersection();
+  anImplicitBoolean->Delete();
 
   myScalarsExtractor = VISU_Extractor::New();
 
   myScalarsFieldTransform = VISU_FieldTransform::New();
 
-  myCellDataToPointData = VISU_CellDataToPointData::New();
-
-  myScalars = myMergeFilter->GetOutput();
+  myScalarsMergeFilter = VISU_MergeFilter::New();
+  myScalarsMergeFilter->SetMergingInputs(true);
 }
 
 /*!
@@ -79,6 +91,8 @@ VISU_ScalarMapOnDeformedShapePL
 
   myScalarsMergeFilter->Delete();
   
+  myScalarsExtractGeometry->Delete();
+
   myScalarsExtractor->Delete();
 
   myScalarsFieldTransform->Delete();
@@ -86,6 +100,77 @@ VISU_ScalarMapOnDeformedShapePL
   myCellDataToPointData->Delete();
 }
 
+/*!
+ * Copy information about pipline.
+ * Copy scale and scalars.
+ */
+void
+VISU_ScalarMapOnDeformedShapePL
+::ShallowCopy(VISU_PipeLine *thePipeLine)
+{
+  VISU_ScalarMapOnDeformedShapePL *aPipeLine = dynamic_cast<VISU_ScalarMapOnDeformedShapePL*>(thePipeLine);
+  if(aPipeLine){
+     SetScale(aPipeLine->GetScale());
+     SetScalars(aPipeLine->GetScalars());
+  }
+  Superclass::ShallowCopy(thePipeLine);
+}
+
+//=======================================================================
+void
+VISU_ScalarMapOnDeformedShapePL
+::SetImplicitFunction(vtkImplicitFunction *theFunction)
+{
+  Superclass::SetImplicitFunction(theFunction);
+
+  myScalarsExtractGeometry->SetImplicitFunction(theFunction);
+} 
+
+
+void
+VISU_ScalarMapOnDeformedShapePL
+::RemoveAllClippingPlanes()
+{
+  Superclass::RemoveAllClippingPlanes();
+
+  if(vtkImplicitBoolean* aBoolean = myScalarsExtractGeometry->GetImplicitBoolean()){
+    vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
+    aFunction->RemoveAllItems();
+    aBoolean->Modified(); // VTK bug
+  }
+}
+
+
+bool 
+VISU_ScalarMapOnDeformedShapePL
+::AddClippingPlane(vtkPlane* thePlane)
+{
+  Superclass::AddClippingPlane(thePlane);
+
+  if (thePlane) {
+    if (vtkImplicitBoolean* aBoolean = myScalarsExtractGeometry->GetImplicitBoolean()) {
+      vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
+      aFunction->AddItem(thePlane);
+
+      // Check, that at least one cell present after clipping.
+      // This check was introduced because of bug IPAL8849.
+      if (GetScalarsClippedInput()->GetNumberOfCells() < 1)
+        return false;
+    }
+  }
+  return true;
+}
+
+
+VISU_PipeLine::TInput* 
+VISU_ScalarMapOnDeformedShapePL
+::GetScalarsClippedInput()
+{
+  if(myScalarsExtractGeometry->GetInput())
+    myScalarsExtractGeometry->Update();
+  return myScalarsExtractGeometry->GetOutput();
+}
+
 //=======================================================================
 void
 VISU_ScalarMapOnDeformedShapePL
@@ -169,43 +254,29 @@ VISU_ScalarMapOnDeformedShapePL
   SetScale(VISU_DeformedShapePL::GetDefaultScale(this));
 }
 
-/*!
- * Copy information about pipline.
- * Copy scale and scalars.
- */
-void
-VISU_ScalarMapOnDeformedShapePL
-::ShallowCopy(VISU_PipeLine *thePipeLine)
-{
-  VISU_ScalarMapOnDeformedShapePL *aPipeLine = dynamic_cast<VISU_ScalarMapOnDeformedShapePL*>(thePipeLine);
-  if(aPipeLine){
-     SetScale(aPipeLine->GetScale());
-     SetScalars(aPipeLine->GetScalars());
-  }
-  Superclass::ShallowCopy(thePipeLine);
-}
-
 /*!
  * Set scalars.
  * Sets vtkDataSet with scalars values to VISU_Extractor filter for scalars extraction.
  */
 void
 VISU_ScalarMapOnDeformedShapePL
-::SetScalars(vtkDataSet *theScalars)
+::SetScalars(TInput *theScalars)
 {
-  myScalars = theScalars;
+  myScalarsExtractGeometry->SetInput(theScalars);
 }
 
 /*!
  * Get pointer to input scalars.
  */
-vtkPointSet* 
+VISU_PipeLine::TInput* 
 VISU_ScalarMapOnDeformedShapePL
 ::GetScalars()
 {
-  return myScalars.GetPointer();
+  vtkDataSet* aDataSet = myScalarsExtractGeometry->GetInput();
+  return dynamic_cast<VISU_PipeLine::TInput*>(aDataSet);
 }
 
+
 /*!
  * Sets scale for deformed shape
  */
index e1f805f300db16c48f79a3403056305ef968c6b9..cd53b31f6793cb4bd68c8ef201172e8d600a1ad9 100644 (file)
@@ -55,6 +55,19 @@ public:
   void
   ShallowCopy(VISU_PipeLine *thePipeLine);
 
+  // Clipping planes
+  virtual
+  void 
+  RemoveAllClippingPlanes();
+
+  virtual
+  bool
+  AddClippingPlane(vtkPlane* thePlane);
+
+  virtual
+  void
+  SetImplicitFunction(vtkImplicitFunction *theFunction);
+
   virtual
   void
   SetScale(vtkFloatingPointType theScale);
@@ -85,10 +98,10 @@ public:
 
   virtual
   void
-  SetScalars(vtkDataSet *theScalars);
+  SetScalars(TInput *theScalars);
 
   virtual
-  vtkPointSet* 
+  TInput* 
   GetScalars();
 
 public:
@@ -120,11 +133,14 @@ protected:
   TInsertCustomPL*
   InsertCustomPL();
 
+  TInput* 
+  GetScalarsClippedInput();
+
   vtkFloatingPointType myScaleFactor;
   vtkWarpVector  *myWarpVector;
   VISU_MergeFilter *myScalarsMergeFilter;
-  vtkSmartPointer<vtkUnstructuredGrid> myScalars;
   VISU_CellDataToPointData* myCellDataToPointData;
+  SALOME_ExtractGeometry* myScalarsExtractGeometry;
   VISU_FieldTransform* myScalarsFieldTransform;
   VISU_Extractor* myScalarsExtractor;
 };