From: enk Date: Mon, 17 Apr 2006 14:12:16 +0000 (+0000) Subject: Implementation of Support of structured mesh X-Git-Tag: T3_2_0b1_pre1~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=151aa0b21a1a1fa7ab02def33409995144119d3e;p=modules%2Fvisu.git Implementation of Support of structured mesh --- diff --git a/src/CONVERTOR/VISU_ConvertorDef.hxx b/src/CONVERTOR/VISU_ConvertorDef.hxx index 0fedadc5..69ec195d 100644 --- a/src/CONVERTOR/VISU_ConvertorDef.hxx +++ b/src/CONVERTOR/VISU_ConvertorDef.hxx @@ -73,6 +73,9 @@ namespace VISU struct TValForTime; typedef SharedPtr PValForTime; + + struct TGrille; + typedef SharedPtr PGrille; } #endif diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 3697d9db..6ce12edc 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -622,6 +622,85 @@ namespace } } + //--------------------------------------------------------------- + void + BuildMeshGrilleOnEntityMap(PMEDMesh theMesh, + const MED::TEntityInfo& theEntityInfo, + const MED::PGrilleInfo& theGrilleInfo, + const MED::PWrapper& theMEDWrapper) + { + TTimerLog aTimerLog(MYDEBUG,"BuildMeshGrilleOnEntityMap"); + INITMSG(MYDEBUG,"BuildMeshGrilleOnEntityMap"<myMeshInfo; + const std::string& aMeshName = theMesh->myName; + TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; + MED::TEntityInfo::const_iterator anEntityIter = theEntityInfo.begin(); + for(; anEntityIter != theEntityInfo.end(); anEntityIter++){ + const MED::EEntiteMaillage& aMEntity = anEntityIter->first; + const MED::TGeom2Size& aGeom2Size = anEntityIter->second; + + TEntity aVEntity = MEDEntityToVTK(aMEntity); + PMEDMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TMEDMeshOnEntity()); + aMeshOnEntity->myEntity = aVEntity; + aMeshOnEntity->myMeshName = aMeshName; + aMeshOnEntity->myGeom2Size = aGeom2Size; +// TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize; + + INITMSG(MYDEBUG, + "- aMEntity = "<GetPNodeInfo(aMeshInfo); + MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo); + + aMesh->myNbPoints = aNodeInfo->GetNbElem(); + aMesh->myEntityInfo = anEntityInfo; + + INITMSG(MYDEBUG,"aMeshName = '"<GetPGrilleInfo(aMeshInfo); + + MED::TEntityInfo anEntityInfo; + anEntityInfo[MED::eNOEUD][MED::ePOINT1] = aGrilleInfo->GetNbNodes(); + anEntityInfo[aGrilleInfo->GetEntity()][aGrilleInfo->GetGeom()] = aGrilleInfo->GetNbCells(); + aMesh->myNbPoints = aGrilleInfo->GetNbNodes(); + aMesh->myEntityInfo = anEntityInfo; + #ifndef _DEXCEPT_ - }catch(std::exception& exc){ - MSG(MYDEBUG,"Follow exception was occured in:\n"<myIsDone) return 0; - //Main part of code - MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo); - TInt aNbElem = aNodeInfo->GetNbElem(); - TInt aDim = theMesh->myDim; - - PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords; - TMEDNamedPointCoords& aCoords = aNamedPointCoords; - aCoords.Init(aNbElem,aDim,aNodeInfo); - - for(int iDim = 0; iDim < aDim; iDim++) - aCoords.GetName(iDim) = aNodeInfo->GetCoordName(iDim); + MED::EMaillage aType = theMesh->myMeshInfo->GetType(); - for(int iElem = 0; iElem < aNbElem; iElem++){ - TCoordSlice aVCoordSlice = aCoords.GetCoordSlice(iElem); - MED::TCCoordSlice aMCoordSlice = aNodeInfo->GetCoordSlice(iElem); + if(aType == MED::eNON_STRUCTURE){ + //Main part of code + MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo); + TInt aNbElem = aNodeInfo->GetNbElem(); + TInt aDim = theMesh->myDim; + + PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords; + TMEDNamedPointCoords& aCoords = aNamedPointCoords; + aCoords.Init(aNbElem,aDim,aNodeInfo); + for(int iDim = 0; iDim < aDim; iDim++) - aVCoordSlice[iDim] = aMCoordSlice[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]; + } + + TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh; + PMEDSubMesh aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new TMEDSubMesh()); + + aSubMesh->Init(MED::PElemInfo(aNodeInfo)); + aSubMesh->myNbCells = theMesh->myNbPoints; + aSubMesh->myCellsSize = 2*theMesh->myNbPoints; + + TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; + aCell2Connect.resize(aNbElem); + for (int iElem = 0; iElem < aNbElem; iElem++) + aCell2Connect[iElem] = VISU::TConnect(1,iElem); + } // END NON_STRUCTURED + else { // STRUCTURED + //Main part of code + MED::PGrilleInfo aGrilleInfo = theMed->GetPGrilleInfo(theMesh->myMeshInfo); + TInt aNbElem = aGrilleInfo->GetNbNodes(); + TInt aDim = theMesh->myDim; + + PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords; + TMEDNamedPointCoords& aCoords = aNamedPointCoords; + aCoords.Init(aNbElem,aDim,aGrilleInfo); + + for(int iDim = 0; iDim < aDim; iDim++) + aCoords.GetName(iDim) = aGrilleInfo->GetCoordName(iDim); + + for(int iElem = 0; iElem < aNbElem; iElem++){ + TCoordSlice aVCoordSlice = aCoords.GetCoordSlice(iElem); + MED::TNodeCoord aMCoord = aGrilleInfo->GetCoord(iElem); + for(int iDim = 0; iDim < aDim; iDim++){ + aVCoordSlice[iDim] = aMCoord[iDim]; + } + } + + TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh; + PMEDSubMesh aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new TMEDSubMesh()); + + aSubMesh->Init(aGrilleInfo); + aSubMesh->myNbCells = theMesh->myNbPoints; + aSubMesh->myCellsSize = 2*theMesh->myNbPoints; + + TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; + aCell2Connect.resize(aNbElem); + for (int iElem = 0; iElem < aNbElem; iElem++) + aCell2Connect[iElem] = VISU::TConnect(1,iElem); + } - TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh; - PMEDSubMesh aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new TMEDSubMesh()); - - aSubMesh->Init(aNodeInfo); - aSubMesh->myNbCells = theMesh->myNbPoints; - aSubMesh->myCellsSize = 2*theMesh->myNbPoints; - - TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; - aCell2Connect.resize(aNbElem); - for (int iElem = 0; iElem < aNbElem; iElem++) - aCell2Connect[iElem] = VISU::TConnect(1,iElem); - theMesh->myIsDone = true; return 1; @@ -1620,6 +1790,99 @@ VISU_MedConvertor return 0; const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo; + + MED::EMaillage aType = aMeshInfo->GetType(); + + if(aType == MED::eSTRUCTURE){ + + MED::PGrilleInfo aGrilleInfo = theMed->GetPGrilleInfo(aMeshInfo); + TInt aNbPoints = aGrilleInfo->GetNbNodes(); + + std::map aNodeIdMap; + EBooleen anIsNodeNum = MED::eFAUX; + + const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size; + MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin(); + TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh; + + for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){ + const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first; + VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom); + INITMSG(MYDEBUG,"aMGeom = "<GetNbCells(); + + if(aNbElem > 0){ + PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh()); + + aSubMesh->Init(aGrilleInfo); + aSubMesh->myNbCells = aNbElem; + aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1); + + TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; + aCell2Connect.resize(aNbElem); + + TInt aMNbNodes = MEDGeom2NbNodes(aMGeom); + TVector aConnect(aMNbNodes); + + for(TInt iElem = 0; iElem < aNbElem; iElem++) { + MED::TIntVector aConn = aGrilleInfo->GetConn(iElem); + TConnect& anArray = aCell2Connect[iElem]; + anArray.resize(aVNbNodes); + + if(anIsNodeNum){ + for(TInt iConn = 0; iConn < aMNbNodes; iConn++){ + aConnect[iConn] = aNodeIdMap[aConn[iConn] - 1]; + } + }else{ + for(int iConn = 0; iConn < aMNbNodes; ++iConn){ + aConnect[iConn] = aConn[iConn]; + } + } + + switch(aMGeom){ + case MED::eQUAD4: + anArray[0] = aConnect[0]; + anArray[1] = aConnect[2]; + anArray[2] = aConnect[3]; + anArray[3] = aConnect[1]; + break; + case MED::eHEXA8: + anArray[0] = aConnect[0]; + anArray[1] = aConnect[2]; + anArray[2] = aConnect[3]; + anArray[3] = aConnect[1]; + anArray[4] = aConnect[4]; + anArray[5] = aConnect[6]; + anArray[6] = aConnect[7]; + anArray[7] = aConnect[5]; + break; + default: + for(int iNode = 0; iNode < aVNbNodes; iNode++) + anArray[iNode] = aConnect[iNode]; + } + + for(int iNode = 0; iNode < aVNbNodes; iNode++) + if(anArray[iNode] < 0 || aNbPoints <= anArray[iNode]) + EXCEPTION(runtime_error,"LoadCellsOnEntity - "<< + " aNbPoints("<myIsDone = true; + + return 1; + + } + MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(aMeshInfo); TInt aNbPoints = aNodeInfo->GetNbElem(); @@ -1650,7 +1913,7 @@ VISU_MedConvertor if(aNbElem > 0){ PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh()); - aSubMesh->Init(aPolygoneInfo); + aSubMesh->Init(MED::PElemInfo(aPolygoneInfo)); aSubMesh->myNbCells = aNbElem; TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; @@ -1675,7 +1938,7 @@ VISU_MedConvertor if(aNbElem > 0){ PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh()); - aSubMesh->Init(aPolyedreInfo); + aSubMesh->Init((MED::PElemInfo)aPolyedreInfo); aSubMesh->myNbCells = aNbElem; TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; @@ -1718,7 +1981,7 @@ VISU_MedConvertor if(aNbElem > 0){ PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh()); - aSubMesh->Init(aCellInfo); + aSubMesh->Init((MED::PElemInfo)aCellInfo); aSubMesh->myNbCells = aNbElem; aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1); @@ -1840,6 +2103,8 @@ VISU_MedConvertor }} } + // END NON_STRUCTURED + theMeshOnEntity->myIsDone = true; return 1; @@ -1984,23 +2249,7 @@ LoadProfile(const MED::PWrapper& theMed, const PMEDSubProfile& aSubProfile = anIter->second; MED::EGeometrieElement aMGeom = aSubProfile->myMGeom; MED::PElemInfo anElemInfo; - if(aMEntity == MED::eNOEUD) - anElemInfo = theMed->GetPNodeInfo(aMeshInfo); - else{ - switch(aMGeom){ - case MED::ePOLYGONE: { - anElemInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom); - break; - } - case MED::ePOLYEDRE: { - anElemInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom); - break; - } - default: { - anElemInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom); - break; - }} - } + anElemInfo = theMed->GetPElemInfo(aMeshInfo,aMEntity,aMGeom); aSubProfile->myIsElemNum = anElemInfo->IsElemNum(); aSubProfile->myElemNum = anElemInfo->myElemNum; } @@ -2021,6 +2270,10 @@ LoadGaussMesh(const MED::PWrapper& theMed, TTimerLog aTimerLog(MYDEBUG,"LoadGaussMesh"); INITMSG(MYDEBUG,"LoadGaussMesh"<myMeshInfo->GetType() == MED::eSTRUCTURE) + EXCEPTION(runtime_error,"LoadGaussMesh - Gauss Points localization error!!!"); + PMEDGaussMesh aGaussMesh = theValForTime.myGaussMesh; if(!aGaussMesh || aGaussMesh->myIsDone) return; diff --git a/src/CONVERTOR/VISU_MedConvertor.hxx b/src/CONVERTOR/VISU_MedConvertor.hxx index 0ce3377a..76010e8f 100644 --- a/src/CONVERTOR/VISU_MedConvertor.hxx +++ b/src/CONVERTOR/VISU_MedConvertor.hxx @@ -32,6 +32,11 @@ namespace VISU vtkIdType theDim, const MED::PNodeInfo& theNodeInfo); + void + Init(vtkIdType theNbPoints, + vtkIdType theDim, + const MED::PGrilleInfo& theGrilleInfo); + virtual std::string GetNodeName(vtkIdType theObjID) const; @@ -125,6 +130,9 @@ namespace VISU void Init(const MED::PElemInfo& theElemInfo); + void + Init(const MED::PGrilleInfo& theGrilleInfo); + virtual vtkIdType GetElemObjID(vtkIdType theID) const;