From 245f6d700020e4445fa5288498caae1136257109 Mon Sep 17 00:00:00 2001 From: apo Date: Tue, 30 Aug 2005 11:19:45 +0000 Subject: [PATCH] To separate MeshOnEntity and Family handling (first step) --- src/CONVERTOR/VISU_Convertor_impl.cxx | 8 +- src/CONVERTOR/VISU_Convertor_impl.hxx | 10 +- src/CONVERTOR/VISU_MedConvertor.cxx | 431 +++++++++++++++----------- src/CONVERTOR/VISU_MedConvertor.hxx | 29 +- src/VISU_I/VISU_CorbaMedConvertor.cxx | 393 ++++++++++++----------- src/VISU_I/VISU_CorbaMedConvertor.hxx | 33 +- 6 files changed, 532 insertions(+), 372 deletions(-) diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index 25e8ac3f..acac4c18 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -1366,7 +1366,7 @@ VISU_Convertor_impl if(!aMeshOnEntity->myIsVTKDone){ if(MYVTKDEBUG) aSource->DebugOn(); - LoadMeshOnEntity(aMeshOnEntity); + LoadMeshOnEntity(aMesh,aMeshOnEntity); GetPoints(aSource,aMesh); GetCellsOnEntity(aSource,aMeshOnEntity); @@ -1413,8 +1413,8 @@ VISU_Convertor_impl FindFamilyOnEntity(theMeshName,theEntity,theFamilyName); PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);; - PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity); PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity); + PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity); //Main part of code const TVTKSource& aSource = aFamily->GetSource(); @@ -1424,7 +1424,7 @@ VISU_Convertor_impl if(!aFamily->myIsVTKDone){ if(MYVTKDEBUG) aSource->DebugOn(); - LoadMeshOnEntity(aMeshOnEntity,theFamilyName); + LoadFamilyOnEntity(aMesh,aMeshOnEntity,aFamily); GetPoints(aSource,aMesh); GetCellsOnEntity(aSource,aMeshOnEntity,theFamilyName); @@ -1539,7 +1539,7 @@ VISU_Convertor_impl LoadValForTimeOnMesh(aMesh,aMeshOnEntity,aField,aValForTime); try{ - LoadMeshOnEntity(aVTKMeshOnEntity); + LoadMeshOnEntity(aMesh,aVTKMeshOnEntity); }catch(std::exception& exc){ aVTKMeshOnEntity = aMeshOnEntity; MSG(MYDEBUG,"Follow exception was occured :\n"<myMeshName; const TEntity& anEntity = theMeshOnEntity->myEntity; - PMeshImpl aMesh = myMeshMap[aMeshName]; int isPointsUpdated = 0, isCellsOnEntityUpdated = 0; if(anEntity == NODE_ENTITY){ - isPointsUpdated += LoadPoints(aMed,aMesh,theFamilyName); + isPointsUpdated += LoadPoints(aMed,theMesh); }else{ - isPointsUpdated += LoadPoints(aMed,aMesh); - isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,aMesh,theMeshOnEntity,theFamilyName); + isPointsUpdated += LoadPoints(aMed,theMesh); + isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,theMeshOnEntity); + } + + return (isPointsUpdated || isCellsOnEntityUpdated); +} + + +//--------------------------------------------------------------- +int +VISU_MedConvertor +::LoadFamilyOnEntity(VISU::PMeshImpl theMesh, + VISU::PMeshOnEntityImpl theMeshOnEntity, + VISU::PFamilyImpl theFamily) +{ + MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1()); + const TEntity& anEntity = theMeshOnEntity->myEntity; + + int isPointsUpdated = 0, isCellsOnEntityUpdated = 0; + if(anEntity == NODE_ENTITY){ + isPointsUpdated += LoadPointsOnFamily(aMed,theMesh,theFamily); + }else{ + isPointsUpdated += LoadPoints(aMed,theMesh); + isCellsOnEntityUpdated += LoadCellsOnFamily(aMed,theMesh,theMeshOnEntity,theFamily); } return (isPointsUpdated || isCellsOnEntityUpdated); @@ -904,11 +924,12 @@ VISU_MedConvertor const std::string& aFamilyName = aFamilyAndEntitySetIter->first; const TEntity& anEntity = aFamilyAndEntitySetIter->second; const PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity]; + PMEDFamily aFamily = VISU::GetFamily(aMeshOnEntity,aFamilyName); if(anEntity == NODE_ENTITY){ - isPointsUpdated += LoadPoints(aMed,theMesh,aFamilyName); + isPointsUpdated += LoadPointsOnFamily(aMed,theMesh,aFamily); }else{ isPointsUpdated += LoadPoints(aMed,theMesh); - isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,aMeshOnEntity,aFamilyName); + isCellsOnEntityUpdated += LoadCellsOnFamily(aMed,theMesh,aMeshOnEntity,aFamily); } } @@ -961,70 +982,87 @@ VISU_MedConvertor int VISU_MedConvertor ::LoadPoints(const MED::PWrapper& theMed, - VISU::PMEDMesh theMesh, - const string& theFamilyName) + VISU::PMEDMesh theMesh) { try{ //Check on existing family PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY]; - aMeshOnEntity->myEntity = NODE_ENTITY; aMeshOnEntity->myMeshName = theMesh->myName; - PMEDFamily aFamily = VISU::GetFamily(aMeshOnEntity,theFamilyName); + aMeshOnEntity->myEntity = NODE_ENTITY; + + INITMSG(MYDEBUG,"LoadPoints - theMesh->myIsDone = "<myIsDone<<"'\n"); //Check on loading already done if(theMesh->myIsDone) - if(!aFamily) - return 0; - else if(aFamily->myIsDone) - return 0; - - INITMSG(MYDEBUG,"LoadPoints - theMesh->myIsDone = "<myIsDone<< - "; theFamilyName = '"<GetPNodeInfo(theMesh->myMeshInfo); TInt aNbElem = aNodeInfo->GetNbElem(); + TInt aDim = theMesh->myDim; - if(!theMesh->myIsDone){ - TInt aDim = theMesh->myDim; + TNamedPointCoords& aCoords = theMesh->myNamedPointCoords; + if(EBooleen anIsNodeNum = aNodeInfo->IsElemNum()) + aCoords.Init(aNbElem,aDim,aNodeInfo->myElemNum); + else + aCoords.Init(aNbElem,aDim); + + for(int iDim = 0; iDim < aDim; iDim++) + aCoords.GetName(iDim) = aNodeInfo->GetCoordName(iDim); + + for(int iElem = 0; iElem < aNbElem; iElem++){ + TCoordSlice aVCoordSlice = aCoords.GetCoordSlice(iElem); + MED::TCCoordSlice aMCoordSlice = aNodeInfo->GetCoordSlice(iElem); + for(int iDim = 0; iDim < aDim; iDim++) + aVCoordSlice[iDim] = aMCoordSlice[iDim]; + } + + TCell2Connect& aConnForCellType = aMeshOnEntity->myGeom2Cell2Connect[VTK_VERTEX]; + aConnForCellType.resize(aNbElem); + for (int iElem = 0; iElem < aNbElem; iElem++) + aConnForCellType[iElem] = VISU::TConnect(1,iElem); + + theMesh->myIsDone = true; + + return 1; - TNamedPointCoords& aCoords = theMesh->myNamedPointCoords; - if(EBooleen anIsNodeNum = aNodeInfo->IsElemNum()) - aCoords.Init(aNbElem,aDim,aNodeInfo->myElemNum); - else - aCoords.Init(aNbElem,aDim); + }catch(std::exception& exc){ + throw; + }catch(...){ + EXCEPTION(runtime_error,"Unknown exception !!!"); + } - for(int iDim = 0; iDim < aDim; iDim++) - aCoords.GetName(iDim) = aNodeInfo->GetCoordName(iDim); - - for(int iElem = 0; iElem < aNbElem; iElem++){ - TCoordSlice aVCoordSlice = aCoords.GetCoordSlice(iElem); - MED::TCCoordSlice aMCoordSlice = aNodeInfo->GetCoordSlice(iElem); - for(int iDim = 0; iDim < aDim; iDim++) - aVCoordSlice[iDim] = aMCoordSlice[iDim]; - } + return 0; +} - TCell2Connect& aConnForCellType = aMeshOnEntity->myGeom2Cell2Connect[VTK_VERTEX]; - aConnForCellType.resize(aNbElem); - for (int iElem = 0; iElem < aNbElem; iElem++) - aConnForCellType[iElem] = VISU::TConnect(1,iElem); - - theMesh->myIsDone = true; - } - if(aFamily){ - if(!aFamily->myIsDone){ - if(aNbElem > 0){ - TSubMeshID& aSubMeshID = aFamily->myGeom2SubMeshID[VTK_VERTEX]; - for (int iElem = 0; iElem < aNbElem; iElem++) - if(aNodeInfo->GetFamNum(iElem) == aFamily->myId) - aSubMeshID.push_back(iElem); - } - aFamily->myIsDone = true; - } +//--------------------------------------------------------------- +int +VISU_MedConvertor +::LoadPointsOnFamily(const MED::PWrapper& theMed, + const VISU::PMEDMesh theMesh, + const VISU::PMEDFamily theFamily) +{ + try{ + if(theFamily->myIsDone) + return 0; + + //Main part of code + MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo); + TInt aNbElem = aNodeInfo->GetNbElem(); + + if(aNbElem > 0){ + TInt anId = theFamily->myId; + TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VTK_VERTEX]; + for(TInt iElem = 0; iElem < aNbElem; iElem++) + if(aNodeInfo->GetFamNum(iElem) == anId) + aSubMeshID.push_back(iElem); } + theFamily->myIsDone = true; + return 1; + }catch(std::exception& exc){ throw; }catch(...){ @@ -1038,32 +1076,21 @@ VISU_MedConvertor //--------------------------------------------------------------- int VISU_MedConvertor -::LoadCellsOnEntity(const MED::PWrapper& theMed, - VISU::PMEDMesh theMesh, - VISU::PMEDMeshOnEntity theMeshOnEntity, - const string& theFamilyName) +::LoadCellsOnEntity(const MED::PWrapper& theMed, + const VISU::PMEDMesh theMesh, + const VISU::PMEDMeshOnEntity theMeshOnEntity) { #ifndef _DEXCEPT_ try{ #endif - - //Check on existing family - PFamilyImpl aFamily = VISU::GetFamily(theMeshOnEntity,theFamilyName); - - //Check on loading already done - bool isCellsLoaded = !theMeshOnEntity->myGeom2Cell2Connect.empty(); - if(isCellsLoaded) - if(!aFamily) - return 0; - else if(!aFamily->myGeom2SubMeshID.empty()) - return 0; - - INITMSG(MYDEBUG,"LoadCellsOnEntity - theFamilyName = '"<myIsDone) + return 0; + const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo; MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(aMeshInfo); TInt aNbPoints = aNodeInfo->GetNbElem(); @@ -1093,64 +1120,50 @@ VISU_MedConvertor MED::PPolygoneInfo aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom); TInt aNbElem = aPolygoneInfo->GetNbElem(); - if(!isCellsLoaded){ - TCell2Connect& aCell2Connect = aGeom2Cell2Connect[aVGeom]; - aCell2Connect.resize(aNbElem); - - for(TInt iElem = 0; iElem < aNbElem; iElem++) { - MED::TCConnSlice aConnSlice = aPolygoneInfo->GetConnSlice(iElem); - TInt aNbConn = aPolygoneInfo->GetNbConn(iElem); - TConnect& anArray = aCell2Connect[iElem]; - anArray.resize(aNbConn); - for(TInt iConn = 0; iConn < aNbConn; iConn++) - anArray[iConn] = aConnSlice[iConn] - 1; - } - } - if(aFamily){ - TSubMeshID& aSubMeshID = aFamily->myGeom2SubMeshID[aVGeom]; - for(int iElem = 0; iElem < aNbElem; iElem++) - if(aPolygoneInfo->GetFamNum(iElem) == aFamily->myId) - aSubMeshID.push_back(iElem); + TCell2Connect& aCell2Connect = aGeom2Cell2Connect[aVGeom]; + aCell2Connect.resize(aNbElem); + + for(TInt iElem = 0; iElem < aNbElem; iElem++) { + MED::TCConnSlice aConnSlice = aPolygoneInfo->GetConnSlice(iElem); + TInt aNbConn = aPolygoneInfo->GetNbConn(iElem); + TConnect& anArray = aCell2Connect[iElem]; + anArray.resize(aNbConn); + for(TInt iConn = 0; iConn < aNbConn; iConn++) + anArray[iConn] = aConnSlice[iConn] - 1; } + break; } case MED::ePOLYEDRE: { MED::PPolyedreInfo aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom); TInt aNbElem = aPolyedreInfo->GetNbElem(); - if(!isCellsLoaded){ - TCell2Connect& aCell2Connect = aGeom2Cell2Connect[aVGeom]; - aCell2Connect.resize(aNbElem); + TCell2Connect& aCell2Connect = aGeom2Cell2Connect[aVGeom]; + aCell2Connect.resize(aNbElem); - for(TInt iElem = 0; iElem < aNbElem; iElem++){ - MED::TCConnSliceArr aConnSliceArr = aPolyedreInfo->GetConnSliceArr(iElem); - TConnect& anArray = aCell2Connect[iElem]; - typedef set TConnectSet; - TConnectSet aConnectSet; - TInt aNbFaces = aConnSliceArr.size(); - for(TInt iFace = 0; iFace < aNbFaces; iFace++){ - MED::TCConnSlice aConnSlice = aConnSliceArr[iFace]; - TInt aNbConn = aConnSlice.size(); - for(TInt iConn = 0; iConn < aNbConn; iConn++){ - aConnectSet.insert(aConnSlice[iConn]); - } + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + MED::TCConnSliceArr aConnSliceArr = aPolyedreInfo->GetConnSliceArr(iElem); + TConnect& anArray = aCell2Connect[iElem]; + typedef set TConnectSet; + TConnectSet aConnectSet; + TInt aNbFaces = aConnSliceArr.size(); + for(TInt iFace = 0; iFace < aNbFaces; iFace++){ + MED::TCConnSlice aConnSlice = aConnSliceArr[iFace]; + TInt aNbConn = aConnSlice.size(); + for(TInt iConn = 0; iConn < aNbConn; iConn++){ + aConnectSet.insert(aConnSlice[iConn]); } + } - int aNbConn = aConnectSet.size(); - anArray.resize(aNbConn); - TConnectSet::iterator anIter = aConnectSet.begin(); - for(int i = 0; anIter != aConnectSet.end(); anIter++, i++){ - TInt anId = *anIter; - anArray[i] = anId - 1; - } + int aNbConn = aConnectSet.size(); + anArray.resize(aNbConn); + TConnectSet::iterator anIter = aConnectSet.begin(); + for(int i = 0; anIter != aConnectSet.end(); anIter++, i++){ + TInt anId = *anIter; + anArray[i] = anId - 1; } } - if(aFamily){ - TSubMeshID& aSubMeshID = aFamily->myGeom2SubMeshID[aVGeom]; - for(int iElem = 0; iElem < aNbElem; iElem++) - if(aPolyedreInfo->GetFamNum(iElem) == aFamily->myId) - aSubMeshID.push_back(iElem); - } + break; } default: { @@ -1159,75 +1172,147 @@ VISU_MedConvertor MED::PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom); TInt aNbElem = aCellInfo->GetNbElem(); - if(!isCellsLoaded){ - TCell2Connect& aConnForCellType = aGeom2Cell2Connect[aVGeom]; - aConnForCellType.resize(aNbElem); - - int aMNbNodes = MEDGeom2NbNodes(aMGeom); - vector aConnect(aMNbNodes); + TCell2Connect& aConnForCellType = aGeom2Cell2Connect[aVGeom]; + aConnForCellType.resize(aNbElem); + + int aMNbNodes = MEDGeom2NbNodes(aMGeom); + vector aConnect(aMNbNodes); + + for (int iElem = 0; iElem < aNbElem; iElem++) { + MED::TCConnSlice aConnSlice = aCellInfo->GetConnSlice(iElem); + TConnect& anArray = aConnForCellType[iElem]; + anArray.resize(aVNbNodes); - for (int iElem = 0; iElem < aNbElem; iElem++) { - MED::TCConnSlice aConnSlice = aCellInfo->GetConnSlice(iElem); - TConnect& anArray = aConnForCellType[iElem]; - anArray.resize(aVNbNodes); - - if(anIsNodeNum){ - for(int iConn = 0; iConn < aMNbNodes; iConn++){ - aConnect[iConn] = aNodeIdMap[aConnSlice[iConn] - 1]; - } - }else{ - for(int iConn = 0; iConn < aMNbNodes; iConn++){ - aConnect[iConn] = aConnSlice[iConn] - 1; - } + if(anIsNodeNum){ + for(int iConn = 0; iConn < aMNbNodes; iConn++){ + aConnect[iConn] = aNodeIdMap[aConnSlice[iConn] - 1]; } - - switch(aMGeom){ - case MED::eTETRA4: - case MED::eTETRA10: - anArray[0] = aConnect[0]; - anArray[1] = aConnect[1]; - anArray[2] = aConnect[3]; - anArray[3] = aConnect[2]; - break; - case MED::ePYRA5: - case MED::ePYRA13: - anArray[0] = aConnect[0]; - anArray[1] = aConnect[3]; - anArray[2] = aConnect[2]; - anArray[3] = aConnect[1]; - anArray[4] = aConnect[4]; - break; - default: - for(int iNode = 0; iNode < aVNbNodes; iNode++) - anArray[iNode] = aConnect[iNode]; + }else{ + for(int iConn = 0; iConn < aMNbNodes; iConn++){ + aConnect[iConn] = aConnSlice[iConn] - 1; } + } + + switch(aMGeom){ + case MED::eTETRA4: + case MED::eTETRA10: + anArray[0] = aConnect[0]; + anArray[1] = aConnect[1]; + anArray[2] = aConnect[3]; + anArray[3] = aConnect[2]; + break; + case MED::ePYRA5: + case MED::ePYRA13: + anArray[0] = aConnect[0]; + anArray[1] = aConnect[3]; + anArray[2] = aConnect[2]; + anArray[3] = aConnect[1]; + anArray[4] = aConnect[4]; + break; + default: for(int iNode = 0; iNode < aVNbNodes; iNode++) - if(anArray[iNode] < 0 || aNbPoints <= anArray[iNode]) - EXCEPTION(runtime_error,"LoadCellsOnEntity - "<< - " aNbPoints("<myGeom2SubMeshID[aVGeom]; - for(int iElem = 0; iElem < aNbElem; iElem++) - if(aCellInfo->GetFamNum(iElem) == aFamily->myId) - aSubMeshID.push_back(iElem); - } + }} + } + theMeshOnEntity->myIsDone = true; + + return 1; + +#ifndef _DEXCEPT_ + }catch(std::exception& exc){ + throw; + }catch(...){ + EXCEPTION(runtime_error,"Unknown exception !!!"); + } +#endif + + return 0; +} + + +//--------------------------------------------------------------- +int +VISU_MedConvertor +::LoadCellsOnFamily(const MED::PWrapper& theMed, + const VISU::PMEDMesh theMesh, + const VISU::PMEDMeshOnEntity theMeshOnEntity, + const VISU::PMEDFamily theFamily) +{ +#ifndef _DEXCEPT_ + try{ +#endif + const TEntity& aVEntity = theMeshOnEntity->myEntity; + const MED::EEntiteMaillage& aMEntity = VTKEntityToMED(aVEntity); + + INITMSG(MYDEBUG,"LoadCellsOnFamily - aVEntity = "<myIsDone) + return 0; + + TInt anId = theFamily->myId; + + const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo; + const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size; + MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin(); + TGeom2Cell2Connect& aGeom2Cell2Connect = theMeshOnEntity->myGeom2Cell2Connect; + + for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){ + const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first; + int aVGeom = MEDGeomToVTK(aMGeom); + INITMSG(MYDEBUG,"aMGeom = "<GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom); + TInt aNbElem = aPolygoneInfo->GetNbElem(); + + TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aVGeom]; + for(int iElem = 0; iElem < aNbElem; iElem++) + if(aPolygoneInfo->GetFamNum(iElem) == anId) + aSubMeshID.push_back(iElem); + + break; } + case MED::ePOLYEDRE: { + MED::PPolyedreInfo aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom); + TInt aNbElem = aPolyedreInfo->GetNbElem(); + + TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aVGeom]; + for(int iElem = 0; iElem < aNbElem; iElem++) + if(aPolyedreInfo->GetFamNum(iElem) == anId) + aSubMeshID.push_back(iElem); + + break; } + default: { + int aVNbNodes = VTKGeom2NbNodes(aVGeom); + + MED::PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom); + TInt aNbElem = aCellInfo->GetNbElem(); + + TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aVGeom]; + for(int iElem = 0; iElem < aNbElem; iElem++) + if(aCellInfo->GetFamNum(iElem) == anId) + aSubMeshID.push_back(iElem); + }} } + + theFamily->myIsDone = true; + return 1; #ifndef _DEXCEPT_ }catch(std::exception& exc){ - theMeshOnEntity->myGeom2Cell2Connect.clear(); - throw; + throw;x }catch(...){ - theMeshOnEntity->myGeom2Cell2Connect.clear(); EXCEPTION(runtime_error,"Unknown exception !!!"); } #endif diff --git a/src/CONVERTOR/VISU_MedConvertor.hxx b/src/CONVERTOR/VISU_MedConvertor.hxx index 3394876e..35d903fe 100644 --- a/src/CONVERTOR/VISU_MedConvertor.hxx +++ b/src/CONVERTOR/VISU_MedConvertor.hxx @@ -125,9 +125,15 @@ protected: virtual int - LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, - const std::string& theFamilyName = ""); + LoadMeshOnEntity(VISU::PMeshImpl theMesh, + VISU::PMeshOnEntityImpl theMeshOnEntity); + virtual + int + LoadFamilyOnEntity(VISU::PMeshImpl theMesh, + VISU::PMeshOnEntityImpl theMeshOnEntity, + VISU::PFamilyImpl theFamily); + virtual int LoadMeshOnGroup(VISU::PMeshImpl theMesh, @@ -149,14 +155,23 @@ protected: int LoadPoints(const MED::PWrapper& theMed, - VISU::PMEDMesh theMesh, - const std::string& theFamilyName = ""); + const VISU::PMEDMesh theMesh); + + int + LoadPointsOnFamily(const MED::PWrapper& theMed, + const VISU::PMEDMesh theMesh, + const VISU::PMEDFamily theFamily); int LoadCellsOnEntity(const MED::PWrapper& theMed, - VISU::PMEDMesh theMesh, - VISU::PMEDMeshOnEntity theMeshOnEntity, - const std::string& theFamilyName = ""); + const VISU::PMEDMesh theMesh, + const VISU::PMEDMeshOnEntity theMeshOnEntity); + + int + LoadCellsOnFamily(const MED::PWrapper& theMed, + const VISU::PMEDMesh theMesh, + const VISU::PMEDMeshOnEntity theMeshOnEntity, + const VISU::PMEDFamily theFamily); int LoadValForTimeOnMesh(const MED::PWrapper& theMed, diff --git a/src/VISU_I/VISU_CorbaMedConvertor.cxx b/src/VISU_I/VISU_CorbaMedConvertor.cxx index 4d2df3a2..0b04fbe5 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.cxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.cxx @@ -866,28 +866,48 @@ VISU_MEDConvertor::Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator) //--------------------------------------------------------------- int -VISU_MEDConvertor::LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, - const string& theFamilyName) +VISU_MEDConvertor +::LoadMeshOnEntity(VISU::PMeshImpl theMesh, + VISU::PMeshOnEntityImpl theMeshOnEntity) { - //Main part of code - const string& aMeshName = theMeshOnEntity->myMeshName; const TEntity& aVEntity = theMeshOnEntity->myEntity; - PCMesh aMesh = myMeshMap[aMeshName]; - int isPointsUpdated; + int isPointsUpdated = 0, isCellsOnEntityUpdated = 0; if(aVEntity == NODE_ENTITY) - isPointsUpdated = LoadPoints(aMesh,theFamilyName); - else - isPointsUpdated = LoadPoints(aMesh); - int isCellsOnEntityUpdated = LoadCellsOnEntity(aMesh,theMeshOnEntity,theFamilyName); + isPointsUpdated += LoadPoints(theMesh); + else{ + isPointsUpdated += LoadPoints(theMesh); + isCellsOnEntityUpdated += LoadCellsOnEntity(theMesh,theMeshOnEntity); + } return (isPointsUpdated || isCellsOnEntityUpdated); } +//--------------------------------------------------------------- +int +VISU_MEDConvertor +::LoadFamilyOnEntity(VISU::PMeshImpl theMesh, + VISU::PMeshOnEntityImpl theMeshOnEntity, + VISU::PFamilyImpl theFamily) +{ + const TEntity& anEntity = theMeshOnEntity->myEntity; + int isPointsUpdated = 0, isCellsOnEntityUpdated = 0; + if(anEntity == NODE_ENTITY){ + isPointsUpdated += LoadPointsOnFamily(theMesh,theFamily); + }else{ + isPointsUpdated += LoadPoints(theMesh); + isCellsOnEntityUpdated += LoadCellsOnFamily(theMesh,theMeshOnEntity,theFamily); + } + + return (isPointsUpdated || isCellsOnEntityUpdated); +} + + //--------------------------------------------------------------- int -VISU_MEDConvertor::LoadMeshOnGroup(VISU::PMeshImpl theMesh, - const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) +VISU_MEDConvertor +::LoadMeshOnGroup(VISU::PMeshImpl theMesh, + const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) { //Main part of code int isPointsUpdated = 0; @@ -897,12 +917,13 @@ VISU_MEDConvertor::LoadMeshOnGroup(VISU::PMeshImpl theMesh, const string& aFamilyName = aFamilyAndEntitySetIter->first; const VISU::TEntity& aVEntity = aFamilyAndEntitySetIter->second; PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity]; + PCFamily aFamily = VISU::GetFamily(aMeshOnEntity,aFamilyName); if(aVEntity == VISU::NODE_ENTITY){ - isPointsUpdated += LoadPoints(theMesh,aFamilyName); + isPointsUpdated += LoadPointsOnFamily(theMesh,aFamily); isCellsOnEntityUpdated += LoadCellsOnEntity(theMesh,aMeshOnEntity); }else{ isPointsUpdated += LoadPoints(theMesh); - isCellsOnEntityUpdated += LoadCellsOnEntity(theMesh,aMeshOnEntity,aFamilyName); + isCellsOnEntityUpdated += LoadCellsOnFamily(theMesh,aMeshOnEntity,aFamily); } } @@ -912,10 +933,11 @@ VISU_MEDConvertor::LoadMeshOnGroup(VISU::PMeshImpl theMesh, //--------------------------------------------------------------- int -VISU_MEDConvertor::LoadValForTimeOnMesh(VISU::PMeshImpl theMesh, - VISU::PMeshOnEntityImpl theMeshOnEntity, - VISU::PFieldImpl theField, - VISU::PValForTimeImpl theValForTime) +VISU_MEDConvertor +::LoadValForTimeOnMesh(VISU::PMeshImpl theMesh, + VISU::PMeshOnEntityImpl theMeshOnEntity, + VISU::PFieldImpl theField, + VISU::PValForTimeImpl theValForTime) { //Main part of code int isPointsUpdated = LoadPoints(theMesh); @@ -928,23 +950,16 @@ VISU_MEDConvertor::LoadValForTimeOnMesh(VISU::PMeshImpl theMesh, //--------------------------------------------------------------- int -VISU_MEDConvertor::LoadPoints(VISU::PCMesh theMesh, - const string& theFamilyName) +VISU_MEDConvertor +::LoadPoints(VISU::PCMesh theMesh) { //Check on existing family PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY]; - PCFamily aFamily = GetFamily(aMeshOnEntity,theFamilyName); - + //Check on loading already done if(theMesh->myIsDone) - if(!aFamily) - return 0; - else if(!aFamily->myIsDone) - return 0; - - if(MYDEBUG) - MESSAGE("LoadPoints - theFamilyName = '"<myMesh; int aDim = theMesh->myDim; TNamedPointCoords& aCoords = theMesh->myNamedPointCoords; @@ -956,54 +971,64 @@ VISU_MEDConvertor::LoadPoints(VISU::PCMesh theMesh, throw std::runtime_error("LoadPoints >> There is no points in the mesh !!!"); SALOME_MED::double_array_var aCCoord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE); - if(!theMesh->myIsDone){ - for(int iElem = 0, anId = 0; iElem < aNbElem; iElem++){ - VISU::TCoordSlice aCoordSlice = aCoords.GetCoordSlice(iElem); - for(int iDim = 0; iDim < aDim; iDim++) - aCoordSlice[iDim] = aCCoord[anId++]; - } + for(int iElem = 0, anId = 0; iElem < aNbElem; iElem++){ + VISU::TCoordSlice aCoordSlice = aCoords.GetCoordSlice(iElem); + for(int iDim = 0; iDim < aDim; iDim++) + aCoordSlice[iDim] = aCCoord[anId++]; + } + + if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY"); + + TCell2Connect& aCell2Connect = aMeshOnEntity->myGeom2Cell2Connect[VTK_VERTEX]; + aCell2Connect.resize(aNbElem); + for(int iElem = 0; iElem < aNbElem; iElem++) + aCell2Connect[iElem] = TConnect(1,iElem); + + theMesh->myIsDone = true; - if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY"); + return 1; +} - TCell2Connect& aCell2Connect = aMeshOnEntity->myGeom2Cell2Connect[VTK_VERTEX]; - aCell2Connect.resize(aNbElem); - for(int iElem = 0; iElem < aNbElem; iElem++) - aCell2Connect[iElem] = TConnect(1,iElem); - - theMesh->myIsDone = true; - } - if(aFamily){ - if(!aFamily->myIsDone){ - if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily Geom2SubMeshID"); - - SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily; - CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements(); - TSubMeshID& aSubMeshID = aFamily->myGeom2SubMeshID[VTK_VERTEX]; - - if(!anIsOnAllElements){ - SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes(); - SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom[0]); - int aMaxElemId = aNbElem; - aNbElem = aCellNumForType->length(); - for(int iElem = 0; iElem < aNbElem; iElem++){ - int aTmp = aCellNumForType[iElem]-1; - if(0 > aTmp || aTmp >= aMaxElemId){ - static QString aString; - aString.sprintf("LoadPoints - aMaxElemId(%d) <= aCellNumForType[%d]=%d < 0",aMaxElemId,iElem,aTmp); - throw std::runtime_error(aString.latin1()); - } - aSubMeshID.push_back(aTmp); - } - }else{ - for(int iElem = 0; iElem < aNbElem; iElem++){ - aSubMeshID.push_back(iElem); - } - } +//--------------------------------------------------------------- +int +VISU_MEDConvertor +::LoadPointsOnFamily(VISU::PCMesh theMesh, + VISU::PCFamily theFamily) +{ + PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY]; - aFamily->myIsDone = true; + if(theFamily->myIsDone) + return 0; + + TNamedPointCoords& aCoords = theMesh->myNamedPointCoords; + int aNbElem = aCoords.GetNbPoints(); + + SALOME_MED::FAMILY_var aMedFamily = theFamily->myFamily; + CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements(); + TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VTK_VERTEX]; + + if(!anIsOnAllElements){ + SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes(); + SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom[0]); + int aMaxElemId = aNbElem; + aNbElem = aCellNumForType->length(); + for(int iElem = 0; iElem < aNbElem; iElem++){ + int aTmp = aCellNumForType[iElem]-1; + if(0 > aTmp || aTmp >= aMaxElemId){ + static QString aString; + aString.sprintf("LoadPointsOnFamily - aMaxElemId(%d) <= aCellNumForType[%d]=%d < 0",aMaxElemId,iElem,aTmp); + throw std::runtime_error(aString.latin1()); + } + aSubMeshID.push_back(aTmp); + } + }else{ + for(int iElem = 0; iElem < aNbElem; iElem++){ + aSubMeshID.push_back(iElem); } } + + theFamily->myIsDone = true; return 1; } @@ -1011,26 +1036,15 @@ VISU_MEDConvertor::LoadPoints(VISU::PCMesh theMesh, //--------------------------------------------------------------- int -VISU_MEDConvertor::LoadCellsOnEntity(VISU::PCMesh theMesh, - VISU::PCMeshOnEntity theMeshOnEntity, - const string& theFamilyName) +VISU_MEDConvertor +::LoadCellsOnEntity(VISU::PCMesh theMesh, + VISU::PCMeshOnEntity theMeshOnEntity) { - //Check on existing family - PCFamily aFamily = GetFamily(theMeshOnEntity,theFamilyName); - //Check on loading already done - bool isCellsLoaded = !theMeshOnEntity->myGeom2Cell2Connect.empty(); - if(isCellsLoaded) - if(!aFamily) - return 0; - else if(!aFamily->myGeom2SubMeshID.empty()) - return 0; + if(theMeshOnEntity->myIsDone) + return 0; SALOME_MED::SUPPORT_var& aMedSupport = theMeshOnEntity->mySupport; SALOME_MED::MESH_var aMedMesh = aMedSupport->getMesh(); - if(MYDEBUG) { - MESSAGE("LoadCellsOnEntity - theFamilyName = '"<> aNbPoints(%d) <= anArray[%d][%d]=%d < 0 !!!",aNbPoints,iNumElem,k,anArray[k]); - throw std::runtime_error(aString.latin1()); - } - aCell2Connect.push_back(anArray); + anArray[k] = aConnect[k]; } - //Workaround for MED Component data structure - int aSize = aCell2Connect.size(); - theMeshOnEntity->myCellsFirstIndex[aGeom] = TCMeshOnEntity::TIndexAndSize(aCounter,aSize); - aCounter += aSize; - } - } - } - //Filling aFamily Geom2SubMeshID - if(aFamily){ - SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily; - CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements(); - if(!anIsOnAllElements){ - SALOME_MED::medGeometryElement_array_var aGeoms = aMedFamily->getTypes(); - iGeomEnd = aGeoms->length(); - if(MYDEBUG) MESSAGE("LoadCellsOnEntity - iGeomEnd = "<getNumber(aGeom); - int aVGeom = MEDGeomToVTK(aGeom); - TSubMeshID& aSubMeshID = aFamily->myGeom2SubMeshID[aVGeom]; - int iNumElemEndTmp = theMeshOnEntity->myGeom2Cell2Connect[aVGeom].size(); - int iNumElemEnd = aCellNumForType->length(); - int aCounter = theMeshOnEntity->myCellsFirstIndex[aGeom].first; - if(MYDEBUG) - MESSAGE("LoadCellsOnEntity - aGeom = "<> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEndTmp,iNumElem,tmp); + aString.sprintf("ImportCells >> aNbPoints(%d) <= anArray[%d][%d]=%d < 0 !!!",aNbPoints,iNumElem,k,anArray[k]); throw std::runtime_error(aString.latin1()); } - aSubMeshID.push_back(tmp); - } + aCell2Connect.push_back(anArray); } - }else{ - const TGeom2Cell2Connect& aCellsConn = theMeshOnEntity->myGeom2Cell2Connect; - TGeom2Cell2Connect::const_iterator aCellsConnIter = aCellsConn.begin(); - for(; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){ - int aVGeom = aCellsConnIter->first; - const TCell2Connect& aCell2Connect = aCellsConnIter->second; - TSubMeshID& aSubMeshID = aFamily->myGeom2SubMeshID[aVGeom]; - int iNumElemEnd = aCell2Connect.size(); - for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - aSubMeshID.push_back(iNumElem); + //Workaround for MED Component data structure + int aSize = aCell2Connect.size(); + theMeshOnEntity->myCellsFirstIndex[aGeom] = TCMeshOnEntity::TIndexAndSize(aCounter,aSize); + aCounter += aSize; + } + } + + theMeshOnEntity->myIsDone = true; + + return 1; +} + + +//--------------------------------------------------------------- +int +VISU_MEDConvertor +::LoadCellsOnFamily(VISU::PCMesh theMesh, + VISU::PCMeshOnEntity theMeshOnEntity, + VISU::PCFamily theFamily) +{ + if(theFamily->myIsDone) + return 0; + + SALOME_MED::FAMILY_var aMedFamily = theFamily->myFamily; + CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements(); + if(!anIsOnAllElements){ + SALOME_MED::medGeometryElement_array_var aGeoms = aMedFamily->getTypes(); + int iGeomEnd = aGeoms->length(); + if(MYDEBUG) MESSAGE("LoadCellsOnEntity - iGeomEnd = "<getNumber(aGeom); + int aVGeom = MEDGeomToVTK(aGeom); + TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aVGeom]; + int iNumElemEndTmp = theMeshOnEntity->myGeom2Cell2Connect[aVGeom].size(); + int iNumElemEnd = aCellNumForType->length(); + int aCounter = theMeshOnEntity->myCellsFirstIndex[aGeom].first; + + if(MYDEBUG) + MESSAGE("LoadCellsOnFamily "<< + "- aGeom = "<> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEndTmp,iNumElem,tmp); + throw std::runtime_error(aString.latin1()); + } + aSubMeshID.push_back(tmp); } } + }else{ + const TGeom2Cell2Connect& aCellsConn = theMeshOnEntity->myGeom2Cell2Connect; + TGeom2Cell2Connect::const_iterator aCellsConnIter = aCellsConn.begin(); + for(; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){ + int aVGeom = aCellsConnIter->first; + const TCell2Connect& aCell2Connect = aCellsConnIter->second; + TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aVGeom]; + int iNumElemEnd = aCell2Connect.size(); + for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) + aSubMeshID.push_back(iNumElem); + } } + + theFamily->myIsDone = true; + return 1; } + template int ImportField(TArray& theArray, diff --git a/src/VISU_I/VISU_CorbaMedConvertor.hxx b/src/VISU_I/VISU_CorbaMedConvertor.hxx index 6366a060..f6f3b7d7 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.hxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.hxx @@ -112,8 +112,14 @@ class VISU_MEDConvertor: public VISU_Convertor_impl{ virtual int - LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, - const std::string& theFamilyName = ""); + LoadMeshOnEntity(VISU::PMeshImpl theMesh, + VISU::PMeshOnEntityImpl theMeshOnEntity); + + virtual + int + LoadFamilyOnEntity(VISU::PMeshImpl theMesh, + VISU::PMeshOnEntityImpl theMeshOnEntity, + VISU::PFamilyImpl theFamily); virtual int @@ -136,13 +142,20 @@ class VISU_MEDConvertor: public VISU_Convertor_impl{ {} int - LoadPoints(VISU::PCMesh theMesh, - const std::string& theFamilyName = "") ; + LoadPoints(VISU::PCMesh theMesh) ; + + int + LoadPointsOnFamily(VISU::PCMesh theMesh, + VISU::PCFamily theFamily) ; int LoadCellsOnEntity(VISU::PCMesh theMesh, + VISU::PCMeshOnEntity theMeshOnEntity); + + int + LoadCellsOnFamily(VISU::PCMesh theMesh, VISU::PCMeshOnEntity theMeshOnEntity, - const std::string& theFamilyName = ""); + VISU::PCFamily theFamily); int LoadField(VISU::PCMesh theMesh, @@ -152,14 +165,20 @@ class VISU_MEDConvertor: public VISU_Convertor_impl{ }; -class VISU_MEDFieldConvertor: public VISU_MEDConvertor{ +class VISU_MEDFieldConvertor: public VISU_MEDConvertor +{ protected: SALOME_MED::FIELD_var myField; + public: + VISU_MEDFieldConvertor(SALOME_MED::FIELD_ptr theField) : myField(SALOME_MED::FIELD::_duplicate(theField)) {} - virtual VISU_Convertor* Build() ; + + virtual + VISU_Convertor* + Build(); }; extern "C" { -- 2.39.2