]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To introduce GetMemorySize(): size_t for VISU_Actor instances to calculate GetMemoryS...
authorapo <apo@opencascade.com>
Mon, 27 Nov 2006 16:37:18 +0000 (16:37 +0000)
committerapo <apo@opencascade.com>
Mon, 27 Nov 2006 16:37:18 +0000 (16:37 +0000)
14 files changed:
src/OBJECT/VISU_Actor.cxx
src/OBJECT/VISU_Actor.h
src/OBJECT/VISU_GaussPtsAct.cxx
src/OBJECT/VISU_GaussPtsAct.h
src/OBJECT/VISU_MeshAct.cxx
src/OBJECT/VISU_MeshAct.h
src/OBJECT/VISU_ScalarMapAct.cxx
src/OBJECT/VISU_ScalarMapAct.h
src/OBJECT/VISU_VectorsAct.h
src/VISU_I/VISU_ColoredPrs3d_i.cc
src/VISU_I/VISU_ColoredPrs3d_i.hh
src/VISU_I/VISU_Mesh_i.cc
src/VISU_I/VISU_Prs3d_i.cc
src/VISU_I/VISU_Prs3d_i.hh

index ab83c393083764d7cb99f277cf21d7f62e7e2ebe..6d945d86d526573d4c36b7886b6dab6433f753dd 100644 (file)
@@ -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
index 30f719102e1f9521d3e90fd695bef5dbe1c573e2..fab9ea4caaf135db223b949319f7d1798d47e511 100644 (file)
@@ -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
index ac8ca23961befa6ce8a222d79f576e2901a005c2..d1b0ad56ce41b49eb0830077a2af20bbbf258e06 100644 (file)
@@ -184,6 +184,18 @@ VISU_GaussPtsAct
   return myGaussPointsPL.GetPointer();
 }
 
+//----------------------------------------------------------------------------
+void
+VISU_GaussPtsAct
+::DeepCopy(VISU_Actor *theActor)
+{
+  if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(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);
index 2603a820a9d7597ce4abf9fe7bbcbb44a8972bae..47fbbd3a384f0445ce9035384fddcff47839021e 100644 (file)
@@ -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:
   //----------------------------------------------------------------------------
index 17a8072d4f138241a696ff659704d5d6cbff10f3..c7a09833e811faf7302fbeee57025bf18398d4aa 100644 (file)
@@ -76,6 +76,20 @@ VISU_MeshAct
 }
 
 
+//----------------------------------------------------------------------------
+void
+VISU_MeshAct
+::DeepCopy(VISU_Actor *theActor)
+{
+  if(VISU_MeshAct* anActor = dynamic_cast<VISU_MeshAct*>(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
index bc358e6be37aa15e4f1d42aadbcf4d6dae9942c5..65fd0bb839e93985472d177db8dca833b1183495 100644 (file)
@@ -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);
index e9ce7e184fc283863a2acd8d028457c61e2fd6a8..bc938f98b232794b60acdd87056f19c8e88ea842 100644 (file)
 #include <vtkRenderer.h>
 #include <vtkProperty.h>
 
+//----------------------------------------------------------------------------
 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<VISU_ScalarMapAct*>(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();
+}
+
+//----------------------------------------------------------------------------
index 0b6a4839f7cb47074275a37b2088a51195682995..78d04005f09f831975c1c3260983097b5c89f028 100644 (file)
@@ -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;
index c9d2d0624077cd06a7fa61b78b49ef5bec4fbc63..d4c4ce7719c52701d461988bbe21f499812fab1b 100644 (file)
@@ -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);
 
index f5d0ded129dcbceb7e6a9eb5cf5cc05531ee6e7a..797a56d98154b200a84b8eb28b93114cd84f9925 100644 (file)
@@ -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*
index 5897f443052c36924e27ab21038592bc59d540c0..5fb857813e74ac3d6d60c9bbd756361e3b053682 100644 (file)
@@ -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();
index 8a1e22d90a9d3cf13d7f75d468d0f9c228b9ee4e..2a75b5c3e2771af5a4b8f0e6cee39abba4435bcb 100644 (file)
@@ -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
 }
index 1ac89d41b4bd47a75161541bda343f0fe4e1aca8..f972fe8ef3c16795ecd264c8f9140b20a3c285e9 100644 (file)
 #include "SALOME_Event.hxx"
 
 #include <vtkActorCollection.h>
+#include <vtkUnstructuredGrid.h>
 #include <vtkDataSet.h>
 #include <vtkMapper.h>
 
 #include <boost/bind.hpp>
 
-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<Result_i*>(GetServant(theResult).in()));
+  SetCResult(dynamic_cast<VISU::Result_i*>(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<VISU_Actor*>(anObject))
+       aSize += anActor->GetMemorySize();
+  
+  return aSize / (1024.0 * 1024.0);
+}
+
 //----------------------------------------------------------------------------
 VISU::Result_i* 
 VISU::GetResult(SALOMEDS::SObject_var theSObject)
index 3afc8c0f0f4f43a3092ddcb0fe441c86c83f3775..ae38e76ce62f500231df1a4f7f2d6220d966cfc3 100644 (file)
@@ -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