From: apo Date: Tue, 22 Mar 2005 10:32:59 +0000 (+0000) Subject: [Bug PAL7444] display mesh takes a lot of more memory in 2.1.0 than in 2.0.0. X-Git-Tag: T_3_0_0_a1~20 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1eea5485d119de1f044c0bb06c4bfd557a9572b1;p=modules%2Fsmesh.git [Bug PAL7444] display mesh takes a lot of more memory in 2.1.0 than in 2.0.0. --- diff --git a/src/OBJECT/SMESH_Actor.cxx b/src/OBJECT/SMESH_Actor.cxx index d9e353c18..f3794ec5e 100644 --- a/src/OBJECT/SMESH_Actor.cxx +++ b/src/OBJECT/SMESH_Actor.cxx @@ -68,6 +68,7 @@ #include #include #include +#include #include "utilities.h" @@ -242,7 +243,7 @@ SMESH_ActorDef::SMESH_ActorDef(){ myBaseActor->myGeomFilter->SetInside(true); myPickableActor = myBaseActor; - + myHighlightProp = vtkProperty::New(); myHighlightProp->SetAmbient(1.0); myHighlightProp->SetDiffuse(0.0); @@ -599,7 +600,8 @@ void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled ) } -void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled){ +void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled) +{ vtkUnstructuredGrid* aGrid = GetUnstructuredGrid(); myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints(); if(myIsCellsLabeled){ @@ -818,18 +820,6 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj, setName(theName); myVisualObj = theVisualObj; - myNodeActor->myVisualObj = myVisualObj; - myBaseActor->myVisualObj = myVisualObj; - - myHighlitableActor->myVisualObj = myVisualObj; - myNodeHighlitableActor->myVisualObj = myVisualObj; - - my1DActor->myVisualObj = myVisualObj; - my1DExtActor->myVisualObj = myVisualObj; - - my2DActor->myVisualObj = myVisualObj; - my3DActor->myVisualObj = myVisualObj; - myVisualObj->Update(theIsClear); myNodeActor->Init(myVisualObj,myImplicitBoolean); @@ -1063,7 +1053,7 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){ my3DActor->VisibilityOn(); } - if(myIsPointsLabeled){ + if(myIsPointsLabeled){ myPointLabels->VisibilityOn(); myNodeActor->VisibilityOn(); } @@ -1172,7 +1162,7 @@ void SMESH_ActorDef::SetRepresentation(int theMode){ case ePoint: myPickableActor = myNodeActor; myNodeActor->SetVisibility(true); - + aProp = aBackProp = myNodeProp; aReperesent = SMESH_DeviceActor::ePoint; break; @@ -1456,9 +1446,67 @@ int SMESH_ActorDef::GetObjDimension( const int theObjId ) return myVisualObj->GetElemDimension( theObjId ); } +bool +SMESH_ActorDef:: +IsImplicitFunctionUsed() const +{ + return myBaseActor->IsImplicitFunctionUsed(); +} + +void +SMESH_ActorDef:: +SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed) +{ + myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed); + myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed); + + myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed); + myNodeHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed); + + my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed); + my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed); + + my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed); + my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed); +} + +vtkIdType +SMESH_ActorDef:: +AddClippingPlane(vtkPlane* thePlane) +{ + if(thePlane){ + myImplicitBoolean->GetFunction()->AddItem(thePlane); + myCippingPlaneCont.push_back(thePlane); + if(!IsImplicitFunctionUsed()) + SetImplicitFunctionUsed(true); + } + return myCippingPlaneCont.size(); +} + +void +SMESH_ActorDef:: +RemoveAllClippingPlanes() +{ + myImplicitBoolean->GetFunction()->RemoveAllItems(); + myImplicitBoolean->GetFunction()->Modified(); // VTK bug + myCippingPlaneCont.clear(); + SetImplicitFunctionUsed(false); +} -vtkImplicitBoolean* SMESH_ActorDef::GetPlaneContainer(){ - return myImplicitBoolean; +vtkIdType +SMESH_ActorDef:: +GetNumberOfClippingPlanes() +{ + return myCippingPlaneCont.size(); +} + +vtkPlane* +SMESH_ActorDef:: +GetClippingPlane(vtkIdType theID) +{ + if(theID >= myCippingPlaneCont.size()) + return NULL; + return myCippingPlaneCont[theID].Get(); } diff --git a/src/OBJECT/SMESH_Actor.h b/src/OBJECT/SMESH_Actor.h index ad041c275..dcb8d11e8 100644 --- a/src/OBJECT/SMESH_Actor.h +++ b/src/OBJECT/SMESH_Actor.h @@ -104,7 +104,10 @@ class SMESH_Actor: public SALOME_Actor virtual void SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane) = 0; virtual void GetPlaneParam(float theDir[3], float& theDist, vtkPlane* thePlane) = 0; - virtual vtkImplicitBoolean* GetPlaneContainer() = 0; + virtual void RemoveAllClippingPlanes() = 0; + virtual vtkIdType GetNumberOfClippingPlanes() = 0; + virtual vtkPlane* GetClippingPlane(vtkIdType theID) = 0; + virtual vtkIdType AddClippingPlane(vtkPlane* thePlane) = 0; virtual TVisualObjPtr GetObject() = 0; diff --git a/src/OBJECT/SMESH_ActorDef.h b/src/OBJECT/SMESH_ActorDef.h index 943fc5ee5..ea3f8d029 100644 --- a/src/OBJECT/SMESH_ActorDef.h +++ b/src/OBJECT/SMESH_ActorDef.h @@ -32,6 +32,28 @@ #include "SMESH_Actor.h" #include "SMESH_Object.h" +#include + +template +class TVTKSmartPtr: public vtkSmartPointer +{ +public: + TVTKSmartPtr() {} + TVTKSmartPtr(T* r, bool theIsOwner = false): vtkSmartPointer(r) { + if(r && theIsOwner) + r->Delete(); + } + TVTKSmartPtr& operator()(T* r, bool theIsOwner = false){ + vtkSmartPointer::operator=(r); + if(r && theIsOwner) + r->Delete(); + return *this; + } + TVTKSmartPtr& operator=(T* r){ vtkSmartPointer::operator=(r); return *this;} + T* Get() const { return GetPointer();} +}; + + class vtkProperty; class vtkShrinkFilter; class vtkPolyDataMapper; @@ -153,7 +175,10 @@ class SMESH_ActorDef : public SMESH_Actor{ virtual void SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane); virtual void GetPlaneParam(float theDir[3], float& theDist, vtkPlane* thePlane); - virtual vtkImplicitBoolean* GetPlaneContainer(); + virtual void RemoveAllClippingPlanes(); + virtual vtkIdType GetNumberOfClippingPlanes(); + virtual vtkPlane* GetClippingPlane(vtkIdType theID); + virtual vtkIdType AddClippingPlane(vtkPlane* thePlane); virtual TVisualObjPtr GetObject() { return myVisualObj;} @@ -161,6 +186,9 @@ class SMESH_ActorDef : public SMESH_Actor{ virtual long GetControlsPrecision() const { return myControlsPrecision; } protected: + void SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed); + bool IsImplicitFunctionUsed() const; + TVisualObjPtr myVisualObj; vtkTimeStamp* myTimeStamp; @@ -213,7 +241,9 @@ class SMESH_ActorDef : public SMESH_Actor{ vtkSelectVisiblePoints* myClsSelectVisiblePoints; vtkImplicitBoolean* myImplicitBoolean; - + typedef TVTKSmartPtr TPlanePtr; + typedef std::vector TCippingPlaneCont; + TCippingPlaneCont myCippingPlaneCont; long myControlsPrecision; SMESH_ActorDef(); diff --git a/src/OBJECT/SMESH_DeviceActor.cxx b/src/OBJECT/SMESH_DeviceActor.cxx index 21bf977b2..337aba648 100644 --- a/src/OBJECT/SMESH_DeviceActor.cxx +++ b/src/OBJECT/SMESH_DeviceActor.cxx @@ -21,10 +21,10 @@ // // // -// File : SMESH_Actor.cxx -// Author : Nicolas REJNERI +// File : SMESH_DeviceActor.cxx +// Author : // Module : SMESH -// $Header$Header: /home/server/cvs/SMESH/SMESH_SRC/src/OBJECT/SMESH_DeviceActor.cxx,v 1.7 2005/02/02 12:17:51 apo Exp $ +// $Header$ #include "SMESH_DeviceActor.h" @@ -76,7 +76,6 @@ vtkStandardNewMacro(SMESH_DeviceActor); SMESH_DeviceActor::SMESH_DeviceActor(){ - if(MYDEBUG) MESSAGE("SMESH_DeviceActor"); myIsShrunk = false; myIsShrinkable = false; myRepresentation = eSurface; @@ -93,7 +92,9 @@ SMESH_DeviceActor::SMESH_DeviceActor(){ myShrinkFilter = vtkShrinkFilter::New(); myExtractGeometry = SMESH_ExtractGeometry::New(); + myExtractGeometry->SetReleaseDataFlag(true); myExtractGeometry->SetStoreMapping(true); + myIsImplicitFunctionUsed = false; myExtractUnstructuredGrid = SALOME_ExtractUnstructuredGrid::New(); myExtractUnstructuredGrid->SetStoreMapping(true); @@ -160,6 +161,23 @@ void SMESH_DeviceActor::Init(TVisualObjPtr theVisualObj, } +void +SMESH_DeviceActor:: +SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed) +{ + if(myIsImplicitFunctionUsed == theIsImplicitFunctionUsed) + return; + + int anId = 0; + if(theIsImplicitFunctionUsed) + myPassFilter[ anId ]->SetInput( myExtractGeometry->GetOutput() ); + else + myPassFilter[ anId ]->SetInput( myMergeFilter->GetOutput() ); + + myIsImplicitFunctionUsed = theIsImplicitFunctionUsed; +} + + void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){ if(theGrid){ //myIsShrinkable = theGrid->GetNumberOfCells() > 10; @@ -172,7 +190,7 @@ void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){ myExtractGeometry->SetInput(myMergeFilter->GetOutput()); int anId = 0; - myPassFilter[ anId ]->SetInput( myExtractGeometry->GetOutput() ); + myPassFilter[ anId ]->SetInput( myMergeFilter->GetOutput() ); myPassFilter[ anId + 1]->SetInput( myPassFilter[ anId ]->GetOutput() ); anId++; // 1 @@ -513,9 +531,9 @@ void SMESH_DeviceActor::UnShrink() { } -void SMESH_DeviceActor::SetRepresentation(EReperesent theMode){ +void SMESH_DeviceActor::SetRepresentation(EReperesent theMode){ switch(theMode){ - case ePoint: + case ePoint: myGeomFilter->SetInside(true); GetProperty()->SetRepresentation(0); break; @@ -524,8 +542,8 @@ void SMESH_DeviceActor::SetRepresentation(EReperesent theMode){ GetProperty()->SetRepresentation(1); break; default : - GetProperty()->SetRepresentation(theMode); myGeomFilter->SetInside(false); + GetProperty()->SetRepresentation(theMode); } myRepresentation = theMode; GetProperty()->Modified(); @@ -552,14 +570,18 @@ int SMESH_DeviceActor::GetVisibility(){ int SMESH_DeviceActor::GetNodeObjId(int theVtkID){ - vtkIdType anID = myExtractGeometry->GetNodeObjId(theVtkID); + vtkIdType anID = theVtkID; + + if(IsImplicitFunctionUsed()) + anID = myExtractGeometry->GetNodeObjId(theVtkID); + vtkIdType aRetID = myVisualObj->GetNodeObjId(anID); if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "<