From a93b9db852e398a9476fbdf0ad449a9360ae375a Mon Sep 17 00:00:00 2001 From: ouv Date: Thu, 22 Jan 2009 14:45:35 +0000 Subject: [PATCH] Fix for issue 0020122: EDF 923 VISU : deformed shape on scalar map, Performance & Clipping plane --- .../VISU_DeformedShapeAndScalarMapPL.cxx | 93 ++++++++++++++++++- .../VISU_DeformedShapeAndScalarMapPL.hxx | 23 +++++ src/PIPELINE/VISU_PipeLine.hxx | 2 + src/VISUGUI/VisuGUI_CacheDlg.cxx | 2 +- src/VISUGUI/VisuGUI_Prs3dTools.h | 4 +- src/VISU_I/VISU_ColoredPrs3dCache_i.cc | 4 +- 6 files changed, 122 insertions(+), 6 deletions(-) diff --git a/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx b/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx index 2165eb1c..001eb962 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,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 diff --git a/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.hxx b/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.hxx index 720b531e..05eedb53 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,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 diff --git a/src/PIPELINE/VISU_PipeLine.hxx b/src/PIPELINE/VISU_PipeLine.hxx index bc9fc307..ffc8138b 100644 --- a/src/PIPELINE/VISU_PipeLine.hxx +++ b/src/PIPELINE/VISU_PipeLine.hxx @@ -149,12 +149,14 @@ public: SetExtractBoundaryCells(bool theMode); //---------------------------------------------------------------------------- + virtual void RemoveAllClippingPlanes(); vtkIdType GetNumberOfClippingPlanes(); + virtual bool AddClippingPlane(vtkPlane* thePlane); diff --git a/src/VISUGUI/VisuGUI_CacheDlg.cxx b/src/VISUGUI/VisuGUI_CacheDlg.cxx index 23d07cf9..050ee390 100644 --- a/src/VISUGUI/VisuGUI_CacheDlg.cxx +++ b/src/VISUGUI/VisuGUI_CacheDlg.cxx @@ -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 diff --git a/src/VISUGUI/VisuGUI_Prs3dTools.h b/src/VISUGUI/VisuGUI_Prs3dTools.h index 3b0c57dc..76b11fce 100644 --- a/src/VISUGUI/VisuGUI_Prs3dTools.h +++ b/src/VISUGUI/VisuGUI_Prs3dTools.h @@ -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; diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc index 716b0377..ae32d74a 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc @@ -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 ) -- 2.39.2