]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To implement more accurate memory size calculation
authorapo <apo@opencascade.com>
Mon, 4 Dec 2006 08:56:41 +0000 (08:56 +0000)
committerapo <apo@opencascade.com>
Mon, 4 Dec 2006 08:56:41 +0000 (08:56 +0000)
src/CONVERTOR/VISU_Convertor_impl.cxx
src/CONVERTOR/VISU_Convertor_impl.hxx
src/CONVERTOR/VISU_MedConvertor.cxx
src/CONVERTOR/VISU_MedConvertor.hxx
src/VISU_I/VISU_GaussPoints_i.cc
src/VISU_I/VISU_Prs3d_i.cc
src/VISU_I/VISU_ScalarMap_i.cc

index ac3462d5cee26df737141eb45c87d4c738aea016..c889ff2d34bb205ede1753b6d70d1b18860dd44a 100644 (file)
@@ -315,6 +315,17 @@ namespace VISU
     return "";
   }
 
+  unsigned long int
+  TNamedPointCoords
+  ::GetMemorySize()
+  {
+    size_t aSize = TPointCoords::GetMemorySize();
+    aSize += myObj2VTKID.size() * sizeof(vtkIdType) * 2;
+    aSize += myVectorID.size() * sizeof(vtkIdType);
+    return aSize;
+  }
+
+
   //---------------------------------------------------------------
   TMeshImpl::TMeshImpl():
     myPoints(vtkPoints::New()),
@@ -2865,7 +2876,7 @@ VISU_Convertor_impl
   }else
     aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum);
 
-  cout<<"VISU_Convertor_impl::GetTimeStampOnMeshSize - "<<aSize<<"; "<<(anIDMapperFilter->myIsVTKDone)<<endl;
+  //cout<<"VISU_Convertor_impl::GetTimeStampOnMeshSize - "<<aSize<<"; "<<(anIDMapperFilter->myIsVTKDone)<<endl;
   return aSize;
 }
 
@@ -2897,7 +2908,7 @@ VISU_Convertor_impl
   }else
     aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum);
 
-  cout<<"VISU_Convertor_impl::GetTimeStampOnGaussPtsSize - "<<aSize<<"; "<<(aGaussPtsIDFilter->myIsVTKDone)<<endl;
+  //cout<<"VISU_Convertor_impl::GetTimeStampOnGaussPtsSize - "<<aSize<<"; "<<(aGaussPtsIDFilter->myIsVTKDone)<<endl;
   return aSize;
 }
 
index e8256438cb830d000f9b6ab5aa2c3ddf869415c8..3dd566de31e98a82c236fec8fa76957c6c576c7c 100644 (file)
@@ -252,7 +252,7 @@ namespace VISU
   protected:
     typedef TVector<std::string> TPointsDim;
     TPointsDim myPointsDim; //!< Keeps name of each dimension
-    TVectorID myVectorID; //!< Keeps object numeration
+    TVectorID myVectorID; //!< Keeps objects numeration
     TObj2VTKID myObj2VTKID; //!< Keeps mapping from object number to VTK one
 
   public:
@@ -285,6 +285,11 @@ namespace VISU
     virtual
     std::string 
     GetNodeName(vtkIdType theObjID) const;
+
+    //! Gets memory size used by the instance (bytes).
+    virtual
+    unsigned long int
+    GetMemorySize();
   };
   typedef SharedPtr<TNamedPointCoords> PNamedPointCoords;
 
index 77c4351bc672620c0e6db9983e9131a193178822..f8fa135e9fb68f8178c71b686dd5d9c1e34b9da3 100644 (file)
@@ -1001,14 +1001,16 @@ namespace
   TMEDNamedPointCoords
   ::Init(vtkIdType theNbPoints,
         vtkIdType theDim,
-        const MED::PNodeInfo& theNodeInfo)
+        const MED::PNodeInfo& theNodeInfo,
+        MED::EVersion theVersion)
   {
+    myVersion = theVersion;
     if(theNodeInfo->IsElemNum())
       TNamedPointCoords::Init(theNbPoints,theDim,theNodeInfo->myElemNum);
     else
       TNamedPointCoords::Init(theNbPoints,theDim);
     if(theNodeInfo->IsElemNames())
-      myNodeInfo = theNodeInfo;
+      myElemNames = theNodeInfo->myElemNames;
   }
 
   void
@@ -1020,15 +1022,32 @@ namespace
     TNamedPointCoords::Init(theNbPoints,theDim);
   }
 
+  MED::TInt
+  GetPNOMLength(MED::EVersion theVersion)
+  {
+    if(theVersion == MED::eV2_1)
+      return MED::GetPNOMLength<MED::eV2_1>();
+    return MED::GetPNOMLength<MED::eV2_2>();
+  }
+
   std::string 
   TMEDNamedPointCoords
   ::GetNodeName(vtkIdType theObjID) const
   {
-    if(myNodeInfo)
-      return myNodeInfo->GetElemName(theObjID);
+    if(!myElemNames.empty())
+      return GetString(theObjID, GetPNOMLength(myVersion), myElemNames);
     return TNamedPointCoords::GetNodeName(theObjID);
   }
 
+  unsigned long int
+  TMEDNamedPointCoords
+  ::GetMemorySize()
+  {
+    size_t aSize = TNamedPointCoords::GetMemorySize();
+    aSize += myElemNames.size() * sizeof(char);
+    return aSize;
+  }
+
 
   //---------------------------------------------------------------
   vtkIdType
@@ -1080,7 +1099,8 @@ namespace
   //---------------------------------------------------------------
   void
   TMEDSubMesh
-  ::Init(const MED::PElemInfo& theElemInfo)
+  ::Init(const MED::PElemInfo& theElemInfo,
+        MED::EVersion theVersion)
   {
     myIsElemNum = theElemInfo->IsElemNum();
 
@@ -1088,7 +1108,7 @@ namespace
       myElemNum = theElemInfo->myElemNum;
 
     if(theElemInfo->IsElemNames())
-      myElemInfo = theElemInfo;
+      myElemNames = theElemInfo->myElemNames;
   }
 
 
@@ -1114,11 +1134,21 @@ namespace
   TMEDSubMesh
   ::GetElemName(vtkIdType theObjID) const
   {
-    if(myElemInfo)
-      return myElemInfo->GetElemName(theObjID);
+    if(!myElemNames.empty())
+      return GetString(theObjID, GetPNOMLength(myVersion), myElemNames);
     return TSubMeshImpl::GetElemName(theObjID);
   }
 
+  unsigned long int
+  TMEDSubMesh
+  ::GetMemorySize()
+  {
+    size_t aSize = TSubMeshImpl::GetMemorySize();
+    aSize += myElemNum.size() * sizeof(MED::TInt);
+    aSize += myElemNames.size() * sizeof(char);
+    return aSize;
+  }
+
   struct TSetIsDone
   {
     bool& myIsDone;
@@ -1766,7 +1796,7 @@ VISU_MedConvertor
       
       PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords;
       TMEDNamedPointCoords& aCoords = aNamedPointCoords;
-      aCoords.Init(aNbElem,aDim,aNodeInfo);
+      aCoords.Init(aNbElem,aDim,aNodeInfo,theMed->GetVersion());
       
       for(int iDim = 0; iDim < aDim; iDim++)
        aCoords.GetName(iDim) = aNodeInfo->GetCoordName(iDim);
@@ -1781,7 +1811,7 @@ VISU_MedConvertor
       TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
       PMEDSubMesh aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new TMEDSubMesh());
       
-      aSubMesh->Init(MED::PElemInfo(aNodeInfo)); 
+      aSubMesh->Init(MED::PElemInfo(aNodeInfo),theMed->GetVersion()); 
       aSubMesh->myNbCells = theMesh->myNbPoints;
       aSubMesh->myCellsSize = 2*theMesh->myNbPoints;
       
@@ -2037,7 +2067,7 @@ VISU_MedConvertor
        if(aNbElem > 0){
          PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh());
          
-         aSubMesh->Init(MED::PElemInfo(aPolygoneInfo)); 
+         aSubMesh->Init(MED::PElemInfo(aPolygoneInfo),theMed->GetVersion()); 
          aSubMesh->myNbCells = aNbElem;      
 
          TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
@@ -2062,7 +2092,7 @@ VISU_MedConvertor
        if(aNbElem > 0){
          PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh());
          
-         aSubMesh->Init((MED::PElemInfo)aPolyedreInfo); 
+         aSubMesh->Init(MED::PElemInfo(aPolyedreInfo),theMed->GetVersion()); 
          aSubMesh->myNbCells = aNbElem;      
 
          TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
@@ -2105,7 +2135,7 @@ VISU_MedConvertor
        if(aNbElem > 0){
          PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh());
          
-         aSubMesh->Init((MED::PElemInfo)aCellInfo); 
+         aSubMesh->Init(MED::PElemInfo(aCellInfo), theMed->GetVersion()); 
          aSubMesh->myNbCells = aNbElem;      
          aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1);
 
index c467f0c13339ff24e35fbf8b9fed52f5d6ea1c54..15e31e9cbc18ab251825e68a0055c07a75745d68 100644 (file)
 
 namespace VISU
 {
-  typedef TVector<TName> TNames;
-
   //---------------------------------------------------------------
   class TMEDNamedPointCoords: public virtual TNamedPointCoords
   {
-    MED::PNodeInfo myNodeInfo;
-    TNames myPointNames;
+    MED::EVersion myVersion;
+    MED::TString myElemNames;
   public:
     void
     Init(vtkIdType theNbPoints,
         vtkIdType theDim,
-        const MED::PNodeInfo& theNodeInfo);
+        const MED::PNodeInfo& theNodeInfo,
+        MED::EVersion theVersion);
 
     void
     Init(vtkIdType theNbPoints,
@@ -50,6 +49,11 @@ namespace VISU
     virtual
     std::string 
     GetNodeName(vtkIdType theObjID) const;
+
+    //! Gets memory size used by the instance (bytes).
+    virtual
+    unsigned long int
+    GetMemorySize();
   };
   typedef SharedPtr<TMEDNamedPointCoords> PMEDNamedPointCoords;
 
@@ -135,10 +139,13 @@ namespace VISU
 
     MED::EBooleen myIsElemNum;
     MED::TElemNum myElemNum;
-    MED::PElemInfo myElemInfo;
+
+    MED::EVersion myVersion;
+    MED::TString myElemNames;
 
     void
-    Init(const MED::PElemInfo& theElemInfo);
+    Init(const MED::PElemInfo& theElemInfo,
+        MED::EVersion theVersion);
 
     void
     Init(const MED::PGrilleInfo& theGrilleInfo);
@@ -150,6 +157,11 @@ namespace VISU
     virtual
     std::string 
     GetElemName(vtkIdType theObjID) const;
+
+    //! Gets memory size used by the instance (bytes).
+    virtual
+    unsigned long int
+    GetMemorySize();
   };
   typedef SharedPtr<TMEDSubMesh> PMEDSubMesh;
 
index 2341f2095b7f8169f50a478d14a6d13daead3883..d5e7cec9c89f753e263d71b8a1f3d5d0a5cf9905 100644 (file)
@@ -61,28 +61,28 @@ VISU::GaussPoints_i
             CORBA::Long theTimeStampNumber,
             bool theIsMemoryCheck)
 {
+  size_t aResult = 0;
+  if(theEntity == VISU::NODE)
+    return aResult;
   try{
-    if(theEntity == VISU::NODE)
-      return 0;
-    size_t aResult = VISU::ScalarMap_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theTimeStampNumber,false);
-    if(theIsMemoryCheck && aResult){
-      VISU::Result_i::TInput* anInput = theResult->GetInput();
-      size_t aSize = anInput->GetTimeStampOnGaussPtsSize(theMeshName,
-                                                        (VISU::TEntity)theEntity,
-                                                        theFieldName,
-                                                        theTimeStampNumber);
+    VISU::Result_i::TInput* anInput = theResult->GetInput();
+    size_t aSize = anInput->GetTimeStampOnGaussPtsSize(theMeshName,
+                                                      (VISU::TEntity)theEntity,
+                                                      theFieldName,
+                                                      theTimeStampNumber);
+      aResult = 1;
+    if(theIsMemoryCheck){
       aSize *= INCMEMORY;
       aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
       if(MYDEBUG) 
        MESSAGE("GaussPoints_i::IsPossible - CheckAvailableMemory = "<<float(aSize)<<"; aResult = "<<aResult);
     }
-    return aResult;
   }catch(std::exception& exc){
     INFOS("Follow exception was occured :\n"<<exc.what());
   }catch(...){
     INFOS("Unknown exception was occured!");
   }
-  return 0;
+  return aResult;
 }
 
 //----------------------------------------------------------------------------
@@ -273,8 +273,8 @@ VISU::GaussPoints_i
                                                           GetTimeStampNumber());
   // Convert to mega bytes
   aMemorySize += aSize / (1024.0 * 1024.0);
-  cout<<"GaussPoints_i::GetMemorySize - "<<this<<"; anInput = "<<aMemorySize<<endl;
-  cout<<endl;
+  //cout<<"GaussPoints_i::GetMemorySize - "<<this<<"; anInput = "<<aMemorySize<<endl;
+  //cout<<endl;
   return aMemorySize;
 }
 
index 7d157700ac7ef8667f9e65152931b5d32d1a40e2..9c83f499b162905dfc27f5dc290090c2fc61afc8 100644 (file)
@@ -623,7 +623,7 @@ VISU::Prs3d_i
 {
   // To calculate memory used by VISU PipeLine
   CORBA::Float aSize = GetPipeLine()->GetMemorySize();
-  cout<<"Prs3d_i::GetMemorySize - "<<this<<"; GetPipeLine = "<<aSize / (1024.0 * 1024.0)<<endl;
+  //cout<<"Prs3d_i::GetMemorySize - "<<this<<"; GetPipeLine = "<<aSize / (1024.0 * 1024.0)<<endl;
 
   // To calculate memory used by VISU Actos
   int anEnd = myActorCollection->GetNumberOfItems();
@@ -631,7 +631,7 @@ VISU::Prs3d_i
     if(vtkObject* anObject = myActorCollection->GetItemAsObject(anId))
       if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anObject)){
        aSize += anActor->GetMemorySize();
-       cout<<"Prs3d_i::GetMemorySize - "<<this<<"; anActor = "<<aSize / (1024.0 * 1024.0)<<endl;
+       //cout<<"Prs3d_i::GetMemorySize - "<<this<<"; anActor = "<<aSize / (1024.0 * 1024.0)<<endl;
       }
 
   // Convert to mega bytes
index 2b142fa4475da1d57d295265bffa84e7955f164a..9b6a88c825c914a770c85876244ea47790b48fb2 100644 (file)
@@ -64,9 +64,9 @@ VISU::ScalarMap_i
                                                     (VISU::TEntity)theEntity,
                                                     theFieldName,
                                                     theTimeStampNumber);
-      aSize *= INCMEMORY;
       aResult = 1;
       if(theIsMemoryCheck){
+       aSize *= INCMEMORY;
        aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
        if(MYDEBUG) 
          MESSAGE("ScalarMap_i::IsPossible - CheckAvailableMemory = "<<float(aSize)<<"; aResult = "<<aResult);
@@ -195,8 +195,8 @@ VISU::ScalarMap_i
                                                       GetTimeStampNumber());
   // Convert to mega bytes
   aMemorySize += aSize / (1024.0 * 1024.0);
-  cout<<"ScalarMap_i::GetMemorySize - "<<this<<"; anInput = "<<aMemorySize<<endl;
-  cout<<endl;
+  //cout<<"ScalarMap_i::GetMemorySize - "<<this<<"; anInput = "<<aMemorySize<<endl;
+  //cout<<endl;
   return aMemorySize;
 }