From: apo Date: Thu, 21 Jul 2005 11:42:11 +0000 (+0000) Subject: Improve Gauss Mesh data structure. Next step X-Git-Tag: BR-D5-38-2003_D2005-12-09~160 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1dda619053fef3fe5f479b0aa3fb1675487a0f32;p=modules%2Fvisu.git Improve Gauss Mesh data structure. Next step --- diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index f1a7cc74..bb55d5e6 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -57,8 +57,8 @@ static float ERR_SIZE_CALC = 1.00; static int MYVTKDEBUG = 0; #ifdef _DEBUG_ -static int MYDEBUG = 1; -static int MYDEBUGWITHFILES = 1; +static int MYDEBUG = 0; +static int MYDEBUGWITHFILES = 0; #else static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; @@ -67,7 +67,7 @@ static int MYDEBUGWITHFILES = 0; namespace VISU { - + //--------------------------------------------------------------- TSource::TSource(): myNbCells(0), myCellsSize(0), @@ -78,6 +78,7 @@ namespace VISU } + //--------------------------------------------------------------- TMeshImpl::TMeshImpl(): myPoints(vtkPoints::New()), myIsInitialized(false), @@ -86,6 +87,8 @@ namespace VISU myPoints->Delete(); } + + //--------------------------------------------------------------- TSubProfileImpl::TSubProfileImpl(): myStatus(eNone) { @@ -93,22 +96,7 @@ namespace VISU } - bool - TGaussSubMeshLess:: - operator()(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight) const - { - PGaussImpl aLeft(theLeft->myGauss), aRight(theRight->myGauss); - - if(aLeft->myGeom != aRight->myGeom) - return aLeft->myGeom < aRight->myGeom; - - if(aLeft->myName != aRight->myName) - return aLeft->myName < aRight->myName; - - return TSubProfileLess()(theLeft->mySubProfile,theRight->mySubProfile); - } - - + //--------------------------------------------------------------- bool TSubProfileLess ::operator()(const PSubProfile& theLeft, const PSubProfile& theRight) const @@ -120,6 +108,7 @@ namespace VISU } + //--------------------------------------------------------------- TProfileImpl::TProfileImpl(): myIsAll(true), myIsInitialized(false), @@ -129,11 +118,37 @@ namespace VISU } + //--------------------------------------------------------------- TGaussSubMeshImpl::TGaussSubMeshImpl(): myStatus(eNone) {} + //--------------------------------------------------------------- + bool + TGaussSubMeshLess:: + operator()(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight) const + { + PGaussImpl aLeft(theLeft->myGauss), aRight(theRight->myGauss); + + if(aLeft->myGeom != aRight->myGeom) + return aLeft->myGeom < aRight->myGeom; + + if(aLeft->myName != aRight->myName) + return aLeft->myName < aRight->myName; + + return TSubProfileLess()(theLeft->mySubProfile,theRight->mySubProfile); + } + + + //--------------------------------------------------------------- + TGaussMeshImpl + ::TGaussMeshImpl(): + myIsInitialized(false) + {} + + + //--------------------------------------------------------------- pair TMeshOnEntityImpl ::GetCellsDims(const string& theFamilyName) const @@ -151,6 +166,7 @@ namespace VISU } + //--------------------------------------------------------------- int TValForTimeImpl ::GetNbGauss(vtkIdType theGeom) const @@ -164,6 +180,7 @@ namespace VISU } + //--------------------------------------------------------------- vtkIdType VTKGeom2NbNodes(vtkIdType theGeom) { @@ -184,6 +201,7 @@ namespace VISU namespace { + //--------------------------------------------------------------- template std::string dtos(const std::string& fmt, T val) @@ -193,6 +211,8 @@ namespace return aString.latin1(); } + + //--------------------------------------------------------------- enum ECoordName{eX, eY, eZ, eNone}; typedef VISU::TCoord (*TGetCoord)(const VISU::TMeshImpl::TPointsCoord&, int); diff --git a/src/CONVERTOR/VISU_Convertor_impl.hxx b/src/CONVERTOR/VISU_Convertor_impl.hxx index 09a8e3e8..6cadc0ba 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.hxx +++ b/src/CONVERTOR/VISU_Convertor_impl.hxx @@ -81,6 +81,7 @@ namespace VISU //--------------------------------------------------------------- typedef std::map TGeom2SubProfile; + struct TProfileImpl: virtual TProfile { TProfileImpl(); @@ -117,8 +118,15 @@ namespace VISU //--------------------------------------------------------------- + typedef std::map TGeom2GaussSubMesh; + struct TGaussMeshImpl: virtual TGaussMesh - {}; + { + TGaussMeshImpl(); + + bool myIsInitialized; + TGeom2GaussSubMesh myGeom2GaussSubMesh; + }; //--------------------------------------------------------------- diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 38c82660..10af20dc 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -179,33 +179,105 @@ namespace{ } + //--------------------------------------------------------------- + TProfileKey + GetProfileKey(const MED::TTimeStampVal& theTimeStampVal, + const VISU::TMEDMeshOnEntity& theMeshOnEntity, + const MED::TGeom2Size& theGeom2Size) + { + INITMSG(MYDEBUG,"GetProfileKey"<first; + PSubProfile aSubProfile = CrSubProfile(aMGeom,theGeom2Size,aGeom2Profile); + aProfileKey.insert(aSubProfile); + } + + return aProfileKey; + } + + + //--------------------------------------------------------------- + void + InitProfile(MED::TTimeStampVal& theTimeStampVal, + VISU::TMEDMeshOnEntity& theMeshOnEntity, + const MED::TGeom2Size& theGeom2Size, + VISU::TMEDValForTime& theValForTime) + { + INITMSG(MYDEBUG,"InitProfile"<second; + }else{ + PMEDProfile aProfile(new TMEDProfile()); + TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile; + + TProfileKey::const_iterator anIter = aProfileKey.begin(); + for(; anIter != aProfileKey.end(); anIter++){ + PMEDSubProfile aSubProfile(*anIter); + + if(aProfile->myIsAll && aSubProfile->myStatus != eAddAll) + aProfile->myIsAll = false; + + vtkIdType aVGeom = aSubProfile->myGeom; + aGeom2SubProfile[aVGeom] = aSubProfile; + } + aProfileMap[aProfileKey] = aProfile; + theValForTime.myProfile = aProfile; + } + } + + //--------------------------------------------------------------- TGaussKey GetGaussKey(const MED::TTimeStampVal& theTimeStampVal, const VISU::TMEDMeshOnEntity& theMeshOnEntity, - const MED::TGeom2Size& theGeom2Size) + const MED::TGeom2Size& theGeom2Size, + VISU::TMEDValForTime& theValForTime) { INITMSG(MYDEBUG,"GetGaussKey"<myGeom2SubProfile; + TGaussKey aGaussKey; const TGeom2Profile& aGeom2Profile = theTimeStampVal.GetGeom2Profile(); const TTimeStampInfo& aTimeStampInfo = theTimeStampVal.GetTimeStampInfo(); const TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.GetGeom2Gauss(); + const TGeom2Size& aGeom2Size = theMeshOnEntity.myGeom2Size; TGeom2Size::const_iterator anIter = aGeom2Size.begin(); for(; anIter != aGeom2Size.end(); anIter++){ EGeometrieElement aMGeom = anIter->first; + vtkIdType aVGeom = MEDGeomToVTK(aMGeom); + vtkIdType aVNbNodes = VTKGeom2NbNodes(aVGeom); + PMEDGaussSubMesh aGaussSubMesh(new TMEDGaussSubMesh()); aGaussSubMesh->myStatus = eAddAll; - PSubProfile aSubProfile = CrSubProfile(aMGeom,theGeom2Size,aGeom2Profile); - aGaussSubMesh->mySubProfile = aSubProfile; + TGeom2SubProfile::iterator anIter2 = aGeom2SubProfile.find(aVGeom); + if(anIter2 == aGeom2SubProfile.end()){ + INITMSG(MYDEBUG,"anIter2 == aGeom2SubProfile.end!!"<mySubProfile = anIter2->second; PMEDGauss aGauss(new TMEDGauss()); aGaussSubMesh->myGauss = aGauss; - vtkIdType aVGeom = MEDGeomToVTK(aMGeom); - vtkIdType aVNbNodes = VTKGeom2NbNodes(aVGeom); aGauss->myGeom = aVGeom; std::string aName; @@ -252,68 +324,57 @@ namespace{ } - //--------------------------------------------------------------- - TProfileKey - GetProfileKey(const MED::TTimeStampVal& theTimeStampVal, - const VISU::TMEDMeshOnEntity& theMeshOnEntity, - const MED::TGeom2Size& theGeom2Size) - { - INITMSG(MYDEBUG,"GetProfileKey"<first; - PSubProfile aSubProfile = CrSubProfile(aMGeom,theGeom2Size,aGeom2Profile); - aProfileKey.insert(aSubProfile); - } - - return aProfileKey; - } - - //--------------------------------------------------------------- void - InitProfile(MED::TTimeStampVal& theTimeStampVal, - VISU::TMEDValForTime& theValForTime, - VISU::TMEDMeshOnEntity& theMeshOnEntity, - const MED::TGeom2Size& theGeom2Size) + InitGaussMesh(MED::TTimeStampVal& theTimeStampVal, + VISU::TMEDMeshOnEntity& theMeshOnEntity, + const MED::TGeom2Size& theGeom2Size, + VISU::TMEDValForTime& theValForTime) { - INITMSG(MYDEBUG,"InitProfile"<second; + TGaussKey aGaussKey = GetGaussKey(theTimeStampVal, + theMeshOnEntity, + theGeom2Size, + theValForTime); + + TGaussMeshMap::const_iterator anIter = aGaussMeshMap.find(aGaussKey); + if(anIter != aGaussMeshMap.end()){ + theValForTime.myGaussMesh = anIter->second; }else{ - PMEDProfile aProfile(new TMEDProfile()); - TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile; + PMEDGaussMesh aGaussMesh(new TMEDGaussMesh()); + TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh; - TProfileKey::const_iterator anIter = aProfileKey.begin(); - for(; anIter != aProfileKey.end(); anIter++){ - PMEDSubProfile aSubProfile(*anIter); - - if(aProfile->myIsAll && aSubProfile->myStatus != eAddAll) - aProfile->myIsAll = false; - - vtkIdType aVGeom = aSubProfile->myGeom; - aGeom2SubProfile[aVGeom] = aSubProfile; + TGaussKey::const_iterator anIter = aGaussKey.begin(); + for(; anIter != aGaussKey.end(); anIter++){ + PMEDGaussSubMesh aGaussSubMesh(*anIter); + PMEDGauss aGauss = aGaussSubMesh->myGauss; + vtkIdType aVGeom = aGauss->myGeom; + aGeom2GaussSubMesh[aVGeom] = aGaussSubMesh; } - aProfileMap[aProfileKey] = aProfile; - theValForTime.myProfile = aProfile; + aGaussMeshMap[aGaussKey] = aGaussMesh; + theValForTime.myGaussMesh = aGaussMesh; } } + + //--------------------------------------------------------------- + void + InitGaussProfile(MED::TTimeStampVal& theTimeStampVal, + VISU::TMEDMeshOnEntity& theMeshOnEntity, + const MED::TGeom2Size& theGeom2Size, + VISU::TMEDValForTime& theValForTime) + { + // The order of the function calls is important + InitProfile(theTimeStampVal,theMeshOnEntity,theGeom2Size,theValForTime); + InitGaussMesh(theTimeStampVal,theMeshOnEntity,theGeom2Size,theValForTime); + } } + +//--------------------------------------------------------------- extern "C" VISU_Convertor* CreateConvertor(const string& theFileName) @@ -328,6 +389,8 @@ VISU_MedConvertor myName = myFileInfo.baseName().latin1(); } + +//--------------------------------------------------------------- VISU_Convertor* VISU_MedConvertor ::Build() @@ -666,14 +729,10 @@ VISU_MedConvertor aValForTime->myTime = VISU::TTime(aDt,anUnitDt); INITMSG(MYDEBUG,"aDt = "<myGaussMap; const TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->GetGeom2Gauss(); @@ -697,6 +756,8 @@ VISU_MedConvertor return this; } + +//--------------------------------------------------------------- int VISU_MedConvertor ::LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, @@ -717,6 +778,7 @@ VISU_MedConvertor } +//--------------------------------------------------------------- int VISU_MedConvertor ::LoadMeshOnGroup(VISU::PMeshImpl theMesh, @@ -741,6 +803,8 @@ VISU_MedConvertor return (isPointsUpdated || isCellsOnEntityUpdated); } + +//--------------------------------------------------------------- int VISU_MedConvertor ::LoadFieldOnMesh(VISU::PMeshImpl theMesh, @@ -757,6 +821,7 @@ VISU_MedConvertor } +//--------------------------------------------------------------- int VISU_MedConvertor ::LoadPoints(const MED::PWrapper& theMed, @@ -818,6 +883,7 @@ VISU_MedConvertor } +//--------------------------------------------------------------- int VISU_MedConvertor ::LoadCellsOnEntity(const MED::PWrapper& theMed, @@ -1015,6 +1081,7 @@ VISU_MedConvertor } +//--------------------------------------------------------------- void LoadProfile(MED::TTimeStampVal& theTimeStampVal, VISU::TMEDValForTime& theValForTime, @@ -1039,7 +1106,8 @@ LoadProfile(MED::TTimeStampVal& theTimeStampVal, PMEDSubProfile aSubProfile = anIter2->second; aSubProfile->mySubMeshID = aProfileInfo->myElemNum; - INITMSG(MYDEBUG,"aVGeom = "<myIsInitialized) + return; + + const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh; + const TTimeStampInfo& aTimeStampInfo = theTimeStampVal.GetTimeStampInfo(); + const TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.GetGeom2Gauss(); + TGeom2Gauss::const_iterator anIter = aGeom2Gauss.begin(); + for(; anIter != aGeom2Gauss.end(); anIter++){ + MED::PGaussInfo aGaussInfo = anIter->second; + MED::EGeometrieElement aMGeom = anIter->first; + vtkIdType aVGeom = MEDGeomToVTK(aMGeom); + + TGeom2GaussSubMesh::const_iterator anIter2 = aGeom2GaussSubMesh.find(aVGeom); + if(anIter2 != aGeom2GaussSubMesh.end()){ + PMEDGaussSubMesh aGaussSubMesh = anIter2->second; + PMEDSubProfile aSubProfile = aGaussSubMesh->mySubProfile; + + INITMSG(MYDEBUG, + "- aVGeom = "<