From: apo Date: Mon, 19 Feb 2007 12:52:57 +0000 (+0000) Subject: To fix an external bug with "contraintes.med" file X-Git-Tag: WP1_2_3_19-02-2007_Bug_fixing~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7cf2ad3e9931c5fde541fe3c79f90763a471835d;p=modules%2Fvisu.git To fix an external bug with "contraintes.med" file --- diff --git a/src/CONVERTOR/VISU_Convertor.hxx b/src/CONVERTOR/VISU_Convertor.hxx index ba84f66a..1d1cd451 100644 --- a/src/CONVERTOR/VISU_Convertor.hxx +++ b/src/CONVERTOR/VISU_Convertor.hxx @@ -145,7 +145,7 @@ public: GetTimeStampOnMesh(const std::string& theMeshName, const VISU::TEntity& theEntity, const std::string& theFieldName, - int theStampsNum) = 0; + int theTimeStampNumber) = 0; //! Get Gauss Points mesh with attached values for corresponding MED TIMESTAMP virtual @@ -153,7 +153,7 @@ public: GetTimeStampOnGaussPts(const std::string& theMeshName, const VISU::TEntity& theEntity, const std::string& theFieldName, - int theStampsNum) = 0; + int theTimeStampNumber) = 0; //! Get amount of memory to build vtkDataSet for corresponding MED TIMESTAMP on mesh virtual @@ -161,7 +161,8 @@ public: GetTimeStampOnMeshSize(const std::string& theMeshName, const VISU::TEntity& theEntity, const std::string& theFieldName, - int theStampsNum) = 0; + int theTimeStampNumber, + bool& theIsEstimated) = 0; //! Get amount of memory to build vtkDataSet for corresponding MED TIMESTAMP on Gauss Points virtual @@ -169,7 +170,8 @@ public: GetTimeStampOnGaussPtsSize(const std::string& theMeshName, const VISU::TEntity& theEntity, const std::string& theFieldName, - int theStampsNum) = 0; + int theTimeStampNumber, + bool& theIsEstimated) = 0; //! Get amount of memory to build all MED TIMESTAMPS for corresponding MED FIELD virtual @@ -191,7 +193,7 @@ public: GetTimeStamp(const std::string& theMeshName, const VISU::TEntity& theEntity, const std::string& theFieldName, - int theStampsNum) = 0; + int theTimeStampNumber) = 0; //! Allow to generate pretty name for MED TIMESTAMP static diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index 5054f0a4..1442f995 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -1318,7 +1318,8 @@ VISU_Convertor_impl ::GetTimeStampOnMeshSize(const std::string& theMeshName, const VISU::TEntity& theEntity, const std::string& theFieldName, - int theStampsNum) + int theTimeStampNumber, + bool& theIsEstimated) { size_t aSize = 0; @@ -1326,7 +1327,7 @@ VISU_Convertor_impl TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName, theEntity, theFieldName, - theStampsNum); + theTimeStampNumber); VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp); VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = aValForTime->myUnstructuredGridIDMapper; @@ -1334,11 +1335,13 @@ VISU_Convertor_impl VISU::PIDMapper anIDMapper = GetTimeStampOnMesh(theMeshName, theEntity, theFieldName, - theStampsNum); + theTimeStampNumber); anIDMapper->GetOutput(); aSize += anIDMapper->GetMemorySize(); }else - aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum); + aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theTimeStampNumber); + + theIsEstimated = !(anUnstructuredGridIDMapper->myIsVTKDone); //cout<<"VISU_Convertor_impl::GetTimeStampOnMeshSize - "<myIsVTKDone)<(aFindTimeStamp); VISU::PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter; @@ -1366,11 +1370,13 @@ VISU_Convertor_impl VISU::PGaussPtsIDMapper aGaussPtsIDMapper = GetTimeStampOnGaussPts(theMeshName, theEntity, theFieldName, - theStampsNum); + theTimeStampNumber); aGaussPtsIDMapper->GetOutput(); aSize += aGaussPtsIDMapper->GetMemorySize(); }else - aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum); + aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theTimeStampNumber); + + theIsEstimated = !(aGaussPtsIDFilter->myIsVTKDone); //cout<<"VISU_Convertor_impl::GetTimeStampOnGaussPtsSize - "<myIsVTKDone)<(aResult, theMeshName, theEntity, theFieldName, theTimeId, + anUsedMemory, aRequiredMemory); if( anEnlargeType == VISU::ColoredPrs3dCache::IMPOSSIBLE ) { - long aMb = 1024 * 1024; - double aFreeMemory = (double)VISU_PipeLine::GetAvailableMemory( 2048 * aMb ) / (double)aMb; + size_t aMb = 1024 * 1024; + double aFreeMemory = double(VISU_PipeLine::GetAvailableMemory(2048*aMb)) / double(aMb); + CORBA::Float aNecessaryMemory = aRequiredMemory - aFreeMemory - anUsedMemory; SUIT_MessageBox::warn1(GetDesktop(theModule), QObject::tr("WRN_VISU"), - QObject::tr("ERR_NO_MEMORY_TO_BUILD").arg(aRequiredMemory - aFreeMemory), + QObject::tr("ERR_NO_MEMORY_TO_BUILD").arg(aNecessaryMemory), QObject::tr("&OK") ); QApplication::restoreOverrideCursor(); return NULL; diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc index 9d285a70..320fc577 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc @@ -344,9 +344,9 @@ VISU::ColoredPrs3dCache_i theRequiredMemory = int( aMemoryUsed + aMemoryNeeded ) + 1; - long aMb = 1024 * 1024; - double aFreeMemory = (double)VISU_PipeLine::GetAvailableMemory( 2048 * aMb ) / (double)aMb; - anEnlargeType = theRequiredMemory < aFreeMemory ? + size_t aMb = 1024 * 1024; + double aFreeMemory = double(VISU_PipeLine::GetAvailableMemory(2048*aMb)) / double(aMb); + anEnlargeType = aMemoryNeeded < aFreeMemory ? VISU::ColoredPrs3dCache::ENLARGE : VISU::ColoredPrs3dCache::IMPOSSIBLE; } } @@ -437,9 +437,11 @@ VISU::ColoredPrs3dCache_i if( fabs( myLimitedMemory - theMemorySize ) < 1 / VTK_LARGE_FLOAT ) return; - long aMb = 1024 * 1024; - double aFreeMemory = (double)VISU_PipeLine::GetAvailableMemory( 2048 * aMb ) / (double)aMb; - if( theMemorySize > aFreeMemory ) + size_t aMb = 1024 * 1024; + double aFreeMemory = double(VISU_PipeLine::GetAvailableMemory(2048*aMb)) / double(aMb); + CORBA::Float aMemoryUsed = GetDeviceMemorySize(); + CORBA::Float aMemoryNeeded = theMemorySize - aMemoryUsed; + if( aMemoryNeeded > aFreeMemory ) return; ClearCache(theMemorySize); diff --git a/src/VISU_I/VISU_ColoredPrs3dFactory.cc b/src/VISU_I/VISU_ColoredPrs3dFactory.cc index 5634f014..427eb46e 100644 --- a/src/VISU_I/VISU_ColoredPrs3dFactory.cc +++ b/src/VISU_I/VISU_ColoredPrs3dFactory.cc @@ -140,6 +140,7 @@ namespace VISU VISU::Entity theEntity, const std::string& theFieldName, CORBA::Long theIteration, + CORBA::Float& theUsedMemory, CORBA::Float& theRequiredMemory) { VISU::ColoredPrs3dCache::EnlargeType anEnlargeType = VISU::ColoredPrs3dCache::NO_ENLARGE; @@ -154,6 +155,7 @@ namespace VISU SALOMEDS::Study_var aStudy = aResult->GetStudyDocument(); VISU::ColoredPrs3dCache_var aCache = ColoredPrs3dCache_i::GetInstance(aStudy); + theUsedMemory = aCache->GetMemorySize(); anEnlargeType = aCache->GetRequiredMemory(theType, anInput, theRequiredMemory); } return anEnlargeType; diff --git a/src/VISU_I/VISU_ColoredPrs3dFactory.hh b/src/VISU_I/VISU_ColoredPrs3dFactory.hh index b36aec0c..5ae97c37 100644 --- a/src/VISU_I/VISU_ColoredPrs3dFactory.hh +++ b/src/VISU_I/VISU_ColoredPrs3dFactory.hh @@ -198,6 +198,7 @@ namespace VISU VISU::Entity theEntity, const std::string& theFieldName, CORBA::Long theTimeStampNumber, + CORBA::Float& theUsedMemory, CORBA::Float& theRequiredMemory); @@ -210,6 +211,7 @@ namespace VISU VISU::Entity theEntity, const std::string& theFieldName, CORBA::Long theTimeStampNumber, + CORBA::Float& theUsedMemory, CORBA::Float& theRequiredMemory) { typedef typename TL::TColoredType2Enum::TResult TEnum; @@ -220,6 +222,7 @@ namespace VISU theEntity, theFieldName, theTimeStampNumber, + theUsedMemory, theRequiredMemory); } diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index 4c13191b..02a20b45 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -132,10 +132,18 @@ VISU::ColoredPrs3d_i if(anIsCreatNew) CreatePipeLine(NULL); // to create proper pipeline - DoSetInput(anIsCreatNew, theReInit); + try{ + DoSetInput(anIsCreatNew, theReInit); + }catch(std::exception& exc){ + INFOS("Follow exception was occured :\n"<GetInput(); size_t aSize = anInput->GetTimeStampOnGaussPtsSize(theMeshName, (VISU::TEntity)theEntity, theFieldName, - theTimeStampNumber); + theTimeStampNumber, + anIsEstimated); aResult = 1; if(theIsMemoryCheck){ - aSize *= INCMEMORY; + if(anIsEstimated) + aSize *= INCMEMORY; aResult = VISU_PipeLine::CheckAvailableMemory(aSize); if(MYDEBUG) MESSAGE("GaussPoints_i::IsPossible - CheckAvailableMemory = "<