From b91e4526228134ecb4047b2396eb053a1bd62e48 Mon Sep 17 00:00:00 2001 From: apo Date: Mon, 27 Nov 2006 16:37:18 +0000 Subject: [PATCH] To introduce GetMemorySize(): size_t for VISU_Actor instances to calculate GetMemorySize of corresponding presentations in a more accuate way --- src/OBJECT/VISU_Actor.cxx | 31 +++++++++++++++++------ src/OBJECT/VISU_Actor.h | 9 ++++++- src/OBJECT/VISU_GaussPtsAct.cxx | 41 +++++++++++++++++++++++++++++++ src/OBJECT/VISU_GaussPtsAct.h | 27 +++++++++++++++++--- src/OBJECT/VISU_MeshAct.cxx | 35 ++++++++++++++++++++++++++ src/OBJECT/VISU_MeshAct.h | 14 ++++++++++- src/OBJECT/VISU_ScalarMapAct.cxx | 35 ++++++++++++++++++++++++++ src/OBJECT/VISU_ScalarMapAct.h | 10 ++++++++ src/OBJECT/VISU_VectorsAct.h | 3 ++- src/VISU_I/VISU_ColoredPrs3d_i.cc | 7 +----- src/VISU_I/VISU_ColoredPrs3d_i.hh | 3 +++ src/VISU_I/VISU_Mesh_i.cc | 9 +++---- src/VISU_I/VISU_Prs3d_i.cc | 26 ++++++++++++++++---- src/VISU_I/VISU_Prs3d_i.hh | 10 ++++++++ 14 files changed, 230 insertions(+), 30 deletions(-) diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index ab83c393..6d945d86 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -109,16 +109,23 @@ VISU_Actor //---------------------------------------------------------------------------- void VISU_Actor -::ShallowCopy(vtkProp *prop) +::DeepCopy(VISU_Actor *theActor) { - VISU_Actor *anActor = VISU_Actor::SafeDownCast(prop); - if(anActor != NULL){ - setName(anActor->getName()); - if(anActor->hasIO()) setIO(anActor->getIO()); - } - Superclass::ShallowCopy(prop); + highlight(theActor->isHighlighted()); + SetRepresentation(theActor->GetRepresentation()); + SetShrinkable(theActor->IsShrunkable()); + SetShrinkFactor(theActor->GetShrinkFactor()); + if(theActor->IsShrunk()) + SetShrink(); + else + UnShrink(); + SetOpacity(theActor->GetOpacity()); + SetLineWidth(theActor->GetLineWidth()); + SetPosition(theActor->GetPosition()); } + +//---------------------------------------------------------------------------- void VISU_Actor ::ShallowCopyPL(VISU_PipeLine* thePipeLine) @@ -406,6 +413,16 @@ VISU_Actor return GetCurrentPL()->GetOutput(); } +//---------------------------------------------------------------------------- +unsigned long int +VISU_Actor +::GetMemorySize() +{ + vtkDataSet* aDataSet = GetMapper()->GetInput(); + unsigned long int aSize = aDataSet->GetActualMemorySize(); + return aSize * 1024; +} + //---------------------------------------------------------------------------- vtkIdType VISU_Actor diff --git a/src/OBJECT/VISU_Actor.h b/src/OBJECT/VISU_Actor.h index 30f71910..fab9ea4c 100644 --- a/src/OBJECT/VISU_Actor.h +++ b/src/OBJECT/VISU_Actor.h @@ -69,8 +69,10 @@ class VTKOCC_EXPORT VISU_Actor : VISU_Actor* New(); + //! Copies all properties from the given actor + virtual void - ShallowCopy(vtkProp *prop); + DeepCopy(VISU_Actor *theActor); virtual void @@ -194,6 +196,11 @@ class VTKOCC_EXPORT VISU_Actor : vtkDataSet* GetInput(); + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + //---------------------------------------------------------------------------- virtual vtkIdType diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index ac8ca239..d1b0ad56 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -184,6 +184,18 @@ VISU_GaussPtsAct return myGaussPointsPL.GetPointer(); } +//---------------------------------------------------------------------------- +void +VISU_GaussPtsAct +::DeepCopy(VISU_Actor *theActor) +{ + if(VISU_GaussPtsAct* anActor = dynamic_cast(theActor)){ + Superclass::DeepCopy(theActor); + SetBarVisibility(anActor->GetBarVisibility()); + } +} + +//---------------------------------------------------------------------------- void VISU_GaussPtsAct ::ShallowCopyPL(VISU_PipeLine* thePipeLine) @@ -229,6 +241,17 @@ VISU_GaussPtsAct } +//---------------------------------------------------------------------------- +unsigned long int +VISU_GaussPtsAct +::GetMemorySize() +{ + unsigned long int aSize = Superclass::GetMemorySize(); + vtkDataSet* aDataSet = myDeviceActor->GetMapper()->GetInput(); + aSize += aDataSet->GetActualMemorySize() * 1024; + return aSize; +} + //---------------------------------------------------------------------------- void VISU_GaussPtsAct @@ -1424,6 +1447,24 @@ VISU_GaussPtsAct1 Superclass::OnInteractorEvent(theEvent); } +//---------------------------------------------------------------------------- +unsigned long int +VISU_GaussPtsAct1 +::GetMemorySize() +{ + unsigned long int aSize = Superclass::GetMemorySize(); + { + vtkDataSet* aDataSet = myInsideDeviceActor->GetMapper()->GetInput(); + aSize += aDataSet->GetActualMemorySize() * 1024; + } + { + vtkDataSet* aDataSet = myOutsideDeviceActor->GetMapper()->GetInput(); + aSize += aDataSet->GetActualMemorySize() * 1024; + } + return aSize; +} + + //============================================================================== vtkStandardNewMacro(VISU_GaussPtsAct2); diff --git a/src/OBJECT/VISU_GaussPtsAct.h b/src/OBJECT/VISU_GaussPtsAct.h index 2603a820..47fbbd3a 100644 --- a/src/OBJECT/VISU_GaussPtsAct.h +++ b/src/OBJECT/VISU_GaussPtsAct.h @@ -94,6 +94,11 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor VISU_GaussPointsPL* GetGaussPointsPL(); + //! Copies all properties from the given actor + virtual + void + DeepCopy(VISU_Actor *theActor); + virtual void ShallowCopyPL(VISU_PipeLine* thePipeLine); @@ -114,6 +119,11 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor vtkDataSet* GetInput(); + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + //---------------------------------------------------------------------------- virtual void @@ -176,7 +186,9 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor bool GetBarVisibility(); - virtual void SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl); + virtual + void + SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl); //! Return the information about pipeline magnification changing. /*! True indicates that magnification is increased, false - decreased. */ @@ -376,8 +388,15 @@ class VTKOCC_EXPORT VISU_GaussPtsAct1 : public VISU_GaussPtsAct void SetTransform(VTKViewer_Transform* theTransform); - virtual void SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl); + virtual + void + SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl); + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + protected: //---------------------------------------------------------------------------- VISU_GaussPtsAct1(); @@ -455,7 +474,9 @@ class VTKOCC_EXPORT VISU_GaussPtsAct2 : public VISU_GaussPtsAct void SetVisibility(int theMode); - virtual void SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl); + virtual + void + SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl); protected: //---------------------------------------------------------------------------- diff --git a/src/OBJECT/VISU_MeshAct.cxx b/src/OBJECT/VISU_MeshAct.cxx index 17a8072d..c7a09833 100644 --- a/src/OBJECT/VISU_MeshAct.cxx +++ b/src/OBJECT/VISU_MeshAct.cxx @@ -76,6 +76,20 @@ VISU_MeshAct } +//---------------------------------------------------------------------------- +void +VISU_MeshAct +::DeepCopy(VISU_Actor *theActor) +{ + if(VISU_MeshAct* anActor = dynamic_cast(theActor)){ + Superclass::DeepCopy(theActor); + GetSurfaceProperty()->DeepCopy(anActor->GetSurfaceProperty()); + GetEdgeProperty()->DeepCopy(anActor->GetEdgeProperty()); + GetNodeProperty()->DeepCopy(anActor->GetNodeProperty()); + } +} + + //---------------------------------------------------------------------------- void VISU_MeshAct @@ -213,6 +227,27 @@ VISU_MeshAct myEdgeActor->SetRepresentation(SVTK::Representation::Wireframe); } +//---------------------------------------------------------------------------- +unsigned long int +VISU_MeshAct +::GetMemorySize() +{ + unsigned long int aSize = Superclass::GetMemorySize(); + { + vtkDataSet* aDataSet = mySurfaceActor->GetMapper()->GetInput(); + aSize += aDataSet->GetActualMemorySize() * 1024; + } + { + vtkDataSet* aDataSet = myEdgeActor->GetMapper()->GetInput(); + aSize += aDataSet->GetActualMemorySize() * 1024; + } + { + vtkDataSet* aDataSet = myNodeActor->GetMapper()->GetInput(); + aSize += aDataSet->GetActualMemorySize() * 1024; + } + return aSize; +} + //---------------------------------------------------------------------------- int VISU_MeshAct diff --git a/src/OBJECT/VISU_MeshAct.h b/src/OBJECT/VISU_MeshAct.h index bc358e6b..65fd0bb8 100644 --- a/src/OBJECT/VISU_MeshAct.h +++ b/src/OBJECT/VISU_MeshAct.h @@ -44,7 +44,14 @@ class VTKOCC_EXPORT VISU_MeshAct : public VISU_Actor { public: vtkTypeMacro(VISU_MeshAct,VISU_Actor); - static VISU_MeshAct* New(); + static + VISU_MeshAct* + New(); + + //! Copies all properties from the given actor + virtual + void + DeepCopy(VISU_Actor *theActor); //! Apply view transformation virtual @@ -99,6 +106,11 @@ class VTKOCC_EXPORT VISU_MeshAct : public VISU_Actor void UnShrink(); + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + virtual int RenderOpaqueGeometry(vtkViewport *ren); diff --git a/src/OBJECT/VISU_ScalarMapAct.cxx b/src/OBJECT/VISU_ScalarMapAct.cxx index e9ce7e18..bc938f98 100644 --- a/src/OBJECT/VISU_ScalarMapAct.cxx +++ b/src/OBJECT/VISU_ScalarMapAct.cxx @@ -34,8 +34,10 @@ #include #include +//---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_ScalarMapAct); +//---------------------------------------------------------------------------- VISU_ScalarMapAct ::VISU_ScalarMapAct() { @@ -52,12 +54,27 @@ VISU_ScalarMapAct myProperty->DeepCopy(aProperty); } +//---------------------------------------------------------------------------- VISU_ScalarMapAct ::~VISU_ScalarMapAct() { myScalarBar->Delete(); } +//---------------------------------------------------------------------------- +void +VISU_ScalarMapAct +::DeepCopy(VISU_Actor *theActor) +{ + if(VISU_ScalarMapAct* anActor = dynamic_cast(theActor)){ + Superclass::DeepCopy(theActor); + SetBarVisibility(anActor->GetBarVisibility()); + SetShading(anActor->IsShading()); + } +} + + +//---------------------------------------------------------------------------- void VISU_ScalarMapAct ::AddToRender(vtkRenderer* theRenderer) @@ -68,6 +85,7 @@ VISU_ScalarMapAct theRenderer->AddActor2D(myScalarBar); } +//---------------------------------------------------------------------------- void VISU_ScalarMapAct ::RemoveFromRender(vtkRenderer* theRenderer) @@ -78,6 +96,7 @@ VISU_ScalarMapAct Superclass::RemoveFromRender(theRenderer); } +//---------------------------------------------------------------------------- void VISU_ScalarMapAct ::SetVisibility(int theMode) @@ -88,6 +107,7 @@ VISU_ScalarMapAct myScalarBar->SetVisibility(myBarVisibility && theMode); } +//---------------------------------------------------------------------------- int VISU_ScalarMapAct ::GetBarVisibility() @@ -95,6 +115,7 @@ VISU_ScalarMapAct return myBarVisibility; } +//---------------------------------------------------------------------------- VISU_ScalarBarActor* VISU_ScalarMapAct ::GetScalarBar() @@ -102,6 +123,7 @@ VISU_ScalarMapAct return myScalarBar; } +//---------------------------------------------------------------------------- void VISU_ScalarMapAct ::SetBarVisibility(bool theMode) @@ -111,6 +133,7 @@ VISU_ScalarMapAct } +//---------------------------------------------------------------------------- void VISU_ScalarMapAct ::SetRepresentation(int theMode) @@ -121,6 +144,7 @@ VISU_ScalarMapAct } +//---------------------------------------------------------------------------- void VISU_ScalarMapAct ::SetShading(bool theOn) @@ -139,6 +163,7 @@ VISU_ScalarMapAct } } +//---------------------------------------------------------------------------- bool VISU_ScalarMapAct ::IsShading() @@ -147,3 +172,13 @@ VISU_ScalarMapAct return (aProperty->GetAmbient() == 0 && aProperty->GetDiffuse() == 1); } + +//---------------------------------------------------------------------------- +unsigned long int +VISU_ScalarMapAct +::GetMemorySize() +{ + return Superclass::GetMemorySize(); +} + +//---------------------------------------------------------------------------- diff --git a/src/OBJECT/VISU_ScalarMapAct.h b/src/OBJECT/VISU_ScalarMapAct.h index 0b6a4839..78d04005 100644 --- a/src/OBJECT/VISU_ScalarMapAct.h +++ b/src/OBJECT/VISU_ScalarMapAct.h @@ -44,6 +44,11 @@ class VTKOCC_EXPORT VISU_ScalarMapAct : public VISU_Actor ~VISU_ScalarMapAct(); + //! Copies all properties from the given actor + virtual + void + DeepCopy(VISU_Actor *theActor); + virtual void AddToRender(vtkRenderer* theRenderer); @@ -80,6 +85,11 @@ class VTKOCC_EXPORT VISU_ScalarMapAct : public VISU_Actor bool IsShading(); + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + protected: VISU_ScalarMapAct(); bool myBarVisibility; diff --git a/src/OBJECT/VISU_VectorsAct.h b/src/OBJECT/VISU_VectorsAct.h index c9d2d062..d4c4ce77 100644 --- a/src/OBJECT/VISU_VectorsAct.h +++ b/src/OBJECT/VISU_VectorsAct.h @@ -34,7 +34,8 @@ class VTKViewer_Transform; class VISU_VectorsPL; -class VTKOCC_EXPORT VISU_VectorsAct : public VISU_ScalarMapAct { +class VTKOCC_EXPORT VISU_VectorsAct : public VISU_ScalarMapAct +{ public: vtkTypeMacro(VISU_VectorsAct,VISU_ScalarMapAct); diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index f5d0ded1..797a56d9 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -44,8 +44,6 @@ static int MYDEBUG = 0; static int MYDEBUG = 0; #endif -static int INCMEMORY = 4; - //============================================================================ VISU::ColoredPrs3d_i:: @@ -349,10 +347,7 @@ CORBA::Float VISU::ColoredPrs3d_i ::GetMemorySize() { - vtkDataSet* aDataSet = GetPipeLine()->GetMapper()->GetInput(); - vtkFloatingPointType aSize = aDataSet->GetActualMemorySize(); - vtkFloatingPointType aMemorySize = aSize * INCMEMORY / 1024.0; // in Mb - return CORBA::Float(aMemorySize); + return TSuperClass::GetMemorySize(); } VISU::ColoredPrs3dHolder::BasicInput* diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index 5897f443..5fb85781 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -216,10 +216,13 @@ namespace VISU std::string GetCTitle(); + //---------------------------------------------------------------------------- + //! Gets memory size actually used by the presentation (Mb). virtual CORBA::Float GetMemorySize(); + //---------------------------------------------------------------------------- //! Returns presentation input VISU::ColoredPrs3dHolder::BasicInput* GetBasicInput(); diff --git a/src/VISU_I/VISU_Mesh_i.cc b/src/VISU_I/VISU_Mesh_i.cc index 8a1e22d9..2a75b5c3 100644 --- a/src/VISU_I/VISU_Mesh_i.cc +++ b/src/VISU_I/VISU_Mesh_i.cc @@ -36,9 +36,6 @@ #include "SUIT_ResourceMgr.h" -using namespace VISU; -using namespace std; - #ifdef _DEBUG_ static int MYDEBUG = 0; #else @@ -71,7 +68,7 @@ VISU::Mesh_i //---------------------------------------------------------------------------- VISU::Mesh_i -::Mesh_i(Result_i* theResult) : +::Mesh_i(VISU::Result_i* theResult) : PrsObject_i(theResult->GetStudyDocument()), Prs3d_i(theResult,false), myMeshPL(VISU_MeshPL::New()) @@ -82,7 +79,7 @@ VISU::Mesh_i //---------------------------------------------------------------------------- VISU::Mesh_i -::Mesh_i(Result_i* theResult, +::Mesh_i(VISU::Result_i* theResult, SALOMEDS::SObject_ptr theSObject) : PrsObject_i(theResult->GetStudyDocument()), Prs3d_i(theResult,theSObject), @@ -95,7 +92,7 @@ VISU::Mesh_i //---------------------------------------------------------------------------- void VISU::Mesh_i -::SameAs(const Prs3d_i* theOrigin) +::SameAs(const VISU::Prs3d_i* theOrigin) { return; // "SameAs" command for mesh is not valid in current architecture } diff --git a/src/VISU_I/VISU_Prs3d_i.cc b/src/VISU_I/VISU_Prs3d_i.cc index 1ac89d41..f972fe8e 100644 --- a/src/VISU_I/VISU_Prs3d_i.cc +++ b/src/VISU_I/VISU_Prs3d_i.cc @@ -33,14 +33,12 @@ #include "SALOME_Event.hxx" #include +#include #include #include #include -using namespace VISU; -using namespace std; - #ifdef _DEBUG_ static int MYDEBUG = 0; #else @@ -154,7 +152,7 @@ VISU::Prs3d_i } //---------------------------------------------------------------------------- -Result_i* +VISU::Result_i* VISU::Prs3d_i ::GetCResult() const { @@ -167,7 +165,7 @@ void VISU::Prs3d_i ::SetResultObject(VISU::Result_ptr theResult) { - SetCResult(dynamic_cast(GetServant(theResult).in())); + SetCResult(dynamic_cast(GetServant(theResult).in())); } @@ -577,6 +575,24 @@ VISU::Prs3d_i } +//---------------------------------------------------------------------------- +CORBA::Float +VISU::Prs3d_i +::GetMemorySize() +{ + static int INCMEMORY = 4; + vtkDataSet* aDataSet = GetPipeLine()->GetInput(); + CORBA::Float aSize = aDataSet->GetActualMemorySize() * (INCMEMORY - 1); + + int anEnd = myActorCollection->GetNumberOfItems(); + for(int anId = 0; anId < anEnd; anId++) + if(vtkObject* anObject = myActorCollection->GetItemAsObject(anId)) + if(VISU_Actor* anActor = dynamic_cast(anObject)) + aSize += anActor->GetMemorySize(); + + return aSize / (1024.0 * 1024.0); +} + //---------------------------------------------------------------------------- VISU::Result_i* VISU::GetResult(SALOMEDS::SObject_var theSObject) diff --git a/src/VISU_I/VISU_Prs3d_i.hh b/src/VISU_I/VISU_Prs3d_i.hh index 3afc8c0f..ae38e76c 100644 --- a/src/VISU_I/VISU_Prs3d_i.hh +++ b/src/VISU_I/VISU_Prs3d_i.hh @@ -72,6 +72,10 @@ namespace VISU Prs3d_i(const Prs3d_i&); public: + //---------------------------------------------------------------------------- + typedef PrsObject_i TSuperClass; + typedef VISU::Prs3d TInterface; + //---------------------------------------------------------------------------- //! A constructor to create a fresh instance of the class Prs3d_i(); @@ -238,6 +242,12 @@ namespace VISU CORBA::Float& theDy, CORBA::Float& theDz); + //---------------------------------------------------------------------------- + //! Gets memory size actually used by the presentation (Mb). + virtual + CORBA::Float + GetMemorySize(); + //---------------------------------------------------------------------------- //! Return modified time of the presentation virtual -- 2.39.2