From 0544c46e8674de26e997b61ae8e70acd774cdc3c Mon Sep 17 00:00:00 2001 From: ouv Date: Thu, 22 Jan 2009 14:49:21 +0000 Subject: [PATCH] Fix for issue 0020122: EDF 923 VISU : deformed shape on scalar map, Performance & Clipping plane --- .../VISU_DeformedShapeAndScalarMapPL.cxx | 76 ++++++++++++++++++- .../VISU_DeformedShapeAndScalarMapPL.hxx | 19 +++++ src/PIPELINE/VISU_PipeLine.hxx | 4 +- src/VISUGUI/VisuGUI_CacheDlg.cxx | 2 +- src/VISUGUI/VisuGUI_Prs3dTools.h | 2 +- src/VISU_I/VISU_ColoredPrs3dCache_i.cc | 4 +- 6 files changed, 100 insertions(+), 7 deletions(-) diff --git a/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx b/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx index 2165eb1c..d52de6e4 100644 --- a/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx +++ b/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx @@ -34,11 +34,16 @@ #include "VISU_MergeFilter.hxx" #include "VISU_ElnoDisassembleFilter.hxx" #include "VISU_PipeLineUtils.hxx" +#include "SALOME_ExtractGeometry.h" +#include #include +#include +#include #include #include #include +#include //---------------------------------------------------------------------------- @@ -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(thePipeLine)){ + SetImplicitFunction(aPipeLine->GetImplicitFunction()); SetScale(aPipeLine->GetScale()); SetScalars(aPipeLine->GetScalars()); } @@ -256,6 +269,67 @@ 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(); +} + +//---------------------------------------------------------------------------- +/*! + * 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 diff --git a/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.hxx b/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.hxx index 720b531e..7a969402 100644 --- a/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.hxx +++ b/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.hxx @@ -36,6 +36,8 @@ class vtkUnstructuredGrid; class vtkCellDataToPointData; class vtkPointDataToCellData; class VISU_ElnoDisassembleFilter; +class SALOME_ExtractGeometry; +class vtkImplicitFunction; //---------------------------------------------------------------------------- @@ -88,6 +90,22 @@ public: vtkDataSet* GetScalars(); + virtual + void + RemoveAllClippingPlanes(); + + virtual + bool + AddClippingPlane(vtkPlane* thePlane); + + virtual + void + SetImplicitFunction(vtkImplicitFunction *theFunction); + + virtual + vtkImplicitFunction* + GetImplicitFunction(); + public: //! Redefined method for initialization of the pipeline. virtual @@ -144,6 +162,7 @@ private: VISU_FieldTransform* myScalarsFieldTransform; VISU_Extractor* myScalarsExtractor; VISU_ElnoDisassembleFilter* myScalarsElnoDisassembleFilter; + SALOME_ExtractGeometry* myExtractGeometry; }; #endif diff --git a/src/PIPELINE/VISU_PipeLine.hxx b/src/PIPELINE/VISU_PipeLine.hxx index 9bdc8a9a..14a5a1b8 100644 --- a/src/PIPELINE/VISU_PipeLine.hxx +++ b/src/PIPELINE/VISU_PipeLine.hxx @@ -146,13 +146,13 @@ public: SetExtractBoundaryCells(bool theMode); //---------------------------------------------------------------------------- - void + virtual void RemoveAllClippingPlanes(); vtkIdType GetNumberOfClippingPlanes(); - bool + virtual bool AddClippingPlane(vtkPlane* thePlane); virtual diff --git a/src/VISUGUI/VisuGUI_CacheDlg.cxx b/src/VISUGUI/VisuGUI_CacheDlg.cxx index ed5f0bfa..78d1a34d 100644 --- a/src/VISUGUI/VisuGUI_CacheDlg.cxx +++ b/src/VISUGUI/VisuGUI_CacheDlg.cxx @@ -66,7 +66,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 diff --git a/src/VISUGUI/VisuGUI_Prs3dTools.h b/src/VISUGUI/VisuGUI_Prs3dTools.h index 305a9898..8e7aafdf 100644 --- a/src/VISUGUI/VisuGUI_Prs3dTools.h +++ b/src/VISUGUI/VisuGUI_Prs3dTools.h @@ -144,7 +144,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::warn1(GetDesktop(theModule), diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc index 534c49a5..bc7cb43d 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc @@ -349,7 +349,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; } @@ -444,7 +444,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 ) -- 2.39.2