]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for issue 0020122: EDF 923 VISU : deformed shape on scalar map, Performance ...
authorouv <ouv@opencascade.com>
Thu, 22 Jan 2009 14:45:35 +0000 (14:45 +0000)
committerouv <ouv@opencascade.com>
Thu, 22 Jan 2009 14:45:35 +0000 (14:45 +0000)
src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx
src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.hxx
src/PIPELINE/VISU_PipeLine.hxx
src/VISUGUI/VisuGUI_CacheDlg.cxx
src/VISUGUI/VisuGUI_Prs3dTools.h
src/VISU_I/VISU_ColoredPrs3dCache_i.cc

index 2165eb1c717bc6b534fbf05d9e97c76ae3e907c2..001eb96202583888c5209ac67b28c531aa8fad77 100644 (file)
 #include "VISU_MergeFilter.hxx"
 #include "VISU_ElnoDisassembleFilter.hxx"
 #include "VISU_PipeLineUtils.hxx"
+#include "SALOME_ExtractGeometry.h"
 
+#include <vtkPlane.h>
 #include <vtkWarpVector.h>
+#include <vtkImplicitBoolean.h>
+#include <vtkImplicitFunction.h>
 #include <vtkUnstructuredGrid.h>
 #include <vtkCellDataToPointData.h>
 #include <vtkPointDataToCellData.h>
+#include <vtkImplicitFunctionCollection.h>
 
 
 //----------------------------------------------------------------------------
@@ -69,6 +74,12 @@ VISU_DeformedShapeAndScalarMapPL
 
   myCellDataToPointData = vtkCellDataToPointData::New();
   myScalarsElnoDisassembleFilter = VISU_ElnoDisassembleFilter::New();
+
+  vtkImplicitBoolean* anImplicitBoolean = vtkImplicitBoolean::New();
+  anImplicitBoolean->SetOperationTypeToIntersection();
+
+  myExtractGeometry = SALOME_ExtractGeometry::New();
+  myExtractGeometry->SetImplicitFunction(anImplicitBoolean);
 }
 
 //----------------------------------------------------------------------------
@@ -203,7 +214,8 @@ VISU_DeformedShapeAndScalarMapPL
 {
   vtkDataSet* aScalars = GetScalars();
   myScalarsElnoDisassembleFilter->SetInput(aScalars);
-  myScalarsExtractor->SetInput(myScalarsElnoDisassembleFilter->GetOutput());
+  myExtractGeometry->SetInput(myScalarsElnoDisassembleFilter->GetOutput());
+  myScalarsExtractor->SetInput(myExtractGeometry->GetOutput());
 
   if(VISU::IsDataOnCells(myScalarsElnoDisassembleFilter->GetOutput()))
     GetMapper()->SetScalarModeToUseCellData();
@@ -224,6 +236,7 @@ VISU_DeformedShapeAndScalarMapPL
   Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
 
   if(VISU_DeformedShapeAndScalarMapPL *aPipeLine = dynamic_cast<VISU_DeformedShapeAndScalarMapPL*>(thePipeLine)){
+     SetImplicitFunction(aPipeLine->GetImplicitFunction());
      SetScale(aPipeLine->GetScale());
      SetScalars(aPipeLine->GetScalars());
   }
@@ -256,6 +269,84 @@ VISU_DeformedShapeAndScalarMapPL
   return myScalars.GetPointer();
 }
 
+//----------------------------------------------------------------------------
+/*!
+ * Removes all clipping planes (for myScalars)
+ */
+void
+VISU_DeformedShapeAndScalarMapPL
+::RemoveAllClippingPlanes()
+{
+  if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){
+    vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
+    aFunction->RemoveAllItems();
+    aBoolean->Modified();
+  }
+  Superclass::RemoveAllClippingPlanes();
+}
+
+//----------------------------------------------------------------------------
+/*!
+ * Removes a clipping plane (for myScalars)
+ */
+void
+VISU_DeformedShapeAndScalarMapPL
+::RemoveClippingPlane(vtkIdType theID)
+{
+  if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){
+    vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
+    if(theID >= 0 && theID < aFunction->GetNumberOfItems())
+      aFunction->RemoveItem(theID);
+    aBoolean->Modified();
+  }
+  Superclass::RemoveClippingPlane(theID);
+}
+
+//----------------------------------------------------------------------------
+/*!
+ * Adds a clipping plane (for myScalars)
+ */
+bool 
+VISU_DeformedShapeAndScalarMapPL
+::AddClippingPlane(vtkPlane* thePlane)
+{
+  if (thePlane) {
+    if (vtkImplicitBoolean* aBoolean = myExtractGeometry->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.
+      vtkDataSet* aClippedDataSet = GetClippedInput();
+      if(aClippedDataSet->GetNumberOfCells() < 1)
+        return false;
+    }
+  }
+  return Superclass::AddClippingPlane(thePlane);
+}
+
+//----------------------------------------------------------------------------
+/*!
+ * Sets implicit function of clipping
+ */
+void
+VISU_DeformedShapeAndScalarMapPL
+::SetImplicitFunction(vtkImplicitFunction *theFunction)
+{
+  myExtractGeometry->SetImplicitFunction(theFunction);
+} 
+
+//----------------------------------------------------------------------------
+/*!
+ * Gets implicit function of clipping
+ */
+vtkImplicitFunction * 
+VISU_DeformedShapeAndScalarMapPL
+::GetImplicitFunction()
+{
+  return myExtractGeometry->GetImplicitFunction();
+}
+
 //----------------------------------------------------------------------------
 /*!
  * Sets scale for deformed shape
index 720b531ea5feb3ba81ecb08532388e652f594aad..05eedb53e5806c4b6d78fd9899c44a4302a10f5c 100644 (file)
@@ -36,6 +36,8 @@ class vtkUnstructuredGrid;
 class vtkCellDataToPointData;
 class vtkPointDataToCellData;
 class VISU_ElnoDisassembleFilter;
+class SALOME_ExtractGeometry;
+class vtkImplicitFunction;
 
 
 //----------------------------------------------------------------------------
@@ -88,6 +90,26 @@ public:
   vtkDataSet* 
   GetScalars();
 
+  virtual
+  void 
+  RemoveAllClippingPlanes();
+
+  virtual
+  void
+  RemoveClippingPlane(vtkIdType theID);
+
+  virtual
+  bool
+  AddClippingPlane(vtkPlane* thePlane);
+
+  virtual
+  void
+  SetImplicitFunction(vtkImplicitFunction *theFunction);
+
+  virtual
+  vtkImplicitFunction* 
+  GetImplicitFunction();
+
 public:
   //! Redefined method for initialization of the pipeline.
   virtual
@@ -144,6 +166,7 @@ private:
   VISU_FieldTransform* myScalarsFieldTransform;
   VISU_Extractor* myScalarsExtractor;
   VISU_ElnoDisassembleFilter* myScalarsElnoDisassembleFilter;
+  SALOME_ExtractGeometry* myExtractGeometry;
 };
 
 #endif
index bc9fc307b03d4cd15fdde9e730a5068c44a62dc6..ffc8138b2547ceb59c1b7621ff94be05b59a33ff 100644 (file)
@@ -149,12 +149,14 @@ public:
   SetExtractBoundaryCells(bool theMode);
 
   //----------------------------------------------------------------------------
+  virtual
   void 
   RemoveAllClippingPlanes();
 
   vtkIdType
   GetNumberOfClippingPlanes();
 
+  virtual
   bool
   AddClippingPlane(vtkPlane* thePlane);
 
index 23d07cf9328a8e57f477500698ab7e7a363a4fe9..050ee390a1bcf3466cf741724f61b37ce4507f31 100644 (file)
@@ -68,7 +68,7 @@ VisuGUI_CacheDlg::VisuGUI_CacheDlg( VISU::ColoredPrs3dCache_var theCache,
   long aMb = 1024 * 1024;
   bool isLimitedMemory = myCache->GetMemoryMode() == VISU::ColoredPrs3dCache::LIMITED;
   double aLimitedMemory = myCache->GetLimitedMemory();
-  double aFreeMemory = (double)VISU_PipeLine::GetAvailableMemory( 2048 * aMb ) / (double)aMb;
+  double aFreeMemory = (double)VISU_PipeLine::GetAvailableMemory( 8192 * aMb ) / (double)aMb;
   double anUsedMemory = myCache->GetMemorySize();
   double aLimitedMemoryMax = 
 #ifdef WNT
index 3b0c57dce45a4bd785403ce360fc4d9a3b46a272..76b11fce1fedf35420034db983cdae7b89a56bfc 100644 (file)
@@ -146,7 +146,7 @@ namespace VISU
        if( anEnlargeType == VISU::ColoredPrs3dCache::IMPOSSIBLE )
        {
          size_t aMb = 1024 * 1024;
-         double aFreeMemory = double(VISU_PipeLine::GetAvailableMemory(2048*aMb)) / double(aMb);
+         double aFreeMemory = double(VISU_PipeLine::GetAvailableMemory(8192*aMb)) / double(aMb);
 
          CORBA::Float aNecessaryMemory = aRequiredMemory - aFreeMemory - anUsedMemory;
          SUIT_MessageBox::warning(GetDesktop(theModule),
@@ -163,7 +163,7 @@ namespace VISU
                                      QObject::tr("WRN_VISU"),
                                      QObject::tr("WRN_EXTRA_MEMORY_REQUIRED").arg(aRequiredMemory),
                                      QObject::tr("&OK"), QObject::tr("&Cancel"),
-                                     0, 1, 0) == 1)
+                                     0, 1) == 1)
            {
              QApplication::restoreOverrideCursor();
              return NULL;
index 716b037726179d73729d6e0d98403941a9d47265..ae32d74a0d325fddee24954940851e14d78ddd2f 100644 (file)
@@ -351,7 +351,7 @@ VISU::ColoredPrs3dCache_i
       theRequiredMemory = int( aMemoryUsed + aMemoryNeeded ) + 1;
 
       size_t aMb = 1024 * 1024;
-      double aFreeMemory = double(VISU_PipeLine::GetAvailableMemory(2048*aMb)) / double(aMb);
+      double aFreeMemory = double(VISU_PipeLine::GetAvailableMemory(8192*aMb)) / double(aMb);
       anEnlargeType = aMemoryNeeded < aFreeMemory ?
        VISU::ColoredPrs3dCache::ENLARGE : VISU::ColoredPrs3dCache::IMPOSSIBLE;
     }
@@ -455,7 +455,7 @@ VISU::ColoredPrs3dCache_i
     return;
 
   size_t aMb = 1024 * 1024;
-  double aFreeMemory = double(VISU_PipeLine::GetAvailableMemory(2048*aMb)) / double(aMb);
+  double aFreeMemory = double(VISU_PipeLine::GetAvailableMemory(8192*aMb)) / double(aMb);
   CORBA::Float aMemoryUsed = GetDeviceMemorySize();
   CORBA::Float aMemoryNeeded = theMemorySize - aMemoryUsed;
   if( aMemoryNeeded > aFreeMemory )