From 6a4a89f450b7f589e6b1d9185abf900927f14595 Mon Sep 17 00:00:00 2001 From: apo Date: Wed, 31 Aug 2005 06:33:27 +0000 Subject: [PATCH] To intoduce ID's mapping for MeshOnEntity --- src/CONVERTOR/VISU_Convertor_impl.cxx | 33 +++--- src/CONVERTOR/VISU_Convertor_impl.hxx | 21 ++-- src/CONVERTOR/VISU_MedConvertor.cxx | 162 ++++++++++++++------------ 3 files changed, 115 insertions(+), 101 deletions(-) diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index b40c5c0e..0a7cdb97 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -718,11 +718,12 @@ namespace aCellTypesArray->SetNumberOfComponents(1); aCellTypesArray->SetNumberOfTuples(aNbCells); - const VISU::TGeom2Cell2Connect& aGeom2Cell2Connect = theMeshOnEntity->myGeom2Cell2Connect; - VISU::TGeom2Cell2Connect::const_iterator aGeom2Cell2ConnectIter = aGeom2Cell2Connect.begin(); - for(vtkIdType i = 0, j = 0; aGeom2Cell2ConnectIter != aGeom2Cell2Connect.end(); aGeom2Cell2ConnectIter++){ - const VISU::TCell2Connect& anArray = aGeom2Cell2ConnectIter->second; - vtkIdType aGeom = aGeom2Cell2ConnectIter->first; + const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh; + VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin(); + for(vtkIdType i = 0, j = 0; anIter != aGeom2SubMesh.end(); anIter++){ + const vtkIdType& aGeom = anIter->first; + const VISU::TSubMeshImpl& aSubMesh = anIter->second; + const VISU::TCell2Connect& anArray = aSubMesh.myCell2Connect; INITMSG(MYDEBUG,"aGeom = "<> There is no elements on the family !!!"); @@ -934,12 +937,14 @@ namespace vtkIdType aNbNodes = VTKGeom2NbNodes(aGeom); const TSubMeshID& aSubMeshID = theSubProfile->mySubMeshID; - const TGeom2Cell2Connect& aGeom2Cell2Connect = theMeshOnEntity->myGeom2Cell2Connect; - TGeom2Cell2Connect::const_iterator aConnectIter = aGeom2Cell2Connect.find(aGeom); - if(aConnectIter == aGeom2Cell2Connect.end()) + + const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh; + VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.find(aGeom); + if(anIter == aGeom2SubMesh.end()) EXCEPTION(runtime_error,"GetCells >> There is no elements for the GEOM("<second; + const VISU::TSubMeshImpl& aSubMesh = anIter->second; + const TCell2Connect& aCell2Connect = aSubMesh.myCell2Connect; vtkCellArray* aConnectivity = vtkCellArray::New(); aConnectivity->Allocate(aCellsSize,0); diff --git a/src/CONVERTOR/VISU_Convertor_impl.hxx b/src/CONVERTOR/VISU_Convertor_impl.hxx index f0ea15b8..644192c3 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.hxx +++ b/src/CONVERTOR/VISU_Convertor_impl.hxx @@ -277,11 +277,20 @@ namespace VISU //--------------------------------------------------------------- typedef TVector TConnect; typedef TVector TCell2Connect; - typedef std::map TGeom2Cell2Connect; + + struct TSubMeshImpl: virtual TSource + { + TCell2Connect myCell2Connect; + }; + typedef SharedPtr PSubMeshImpl; + + + //--------------------------------------------------------------- + typedef std::map TGeom2SubMesh; struct TMeshOnEntityImpl: virtual TMeshOnEntity, virtual TSource { - TGeom2Cell2Connect myGeom2Cell2Connect; + TGeom2SubMesh myGeom2SubMesh; virtual vtkIdType @@ -296,14 +305,6 @@ namespace VISU typedef SharedPtr PMeshOnEntityImpl; - //--------------------------------------------------------------- - struct TSubMeshImpl: virtual TSource - { - TSubMeshID mySubMeshID; - }; - typedef SharedPtr PSubMeshImpl; - - //--------------------------------------------------------------- typedef std::map TGeom2SubMeshID; diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 9b199fa1..ac8ae78f 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -1010,7 +1010,9 @@ VISU_MedConvertor aVCoordSlice[iDim] = aMCoordSlice[iDim]; } - TCell2Connect& aConnForCellType = aMeshOnEntity->myGeom2Cell2Connect[VTK_VERTEX]; + TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh; + TSubMeshImpl& aSubMesh = aGeom2SubMesh[VTK_VERTEX]; + TCell2Connect& aConnForCellType = aSubMesh.myCell2Connect; aConnForCellType.resize(aNbElem); for (int iElem = 0; iElem < aNbElem; iElem++) aConnForCellType[iElem] = VISU::TConnect(1,iElem); @@ -1102,7 +1104,7 @@ VISU_MedConvertor const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size; MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin(); - TGeom2Cell2Connect& aGeom2Cell2Connect = theMeshOnEntity->myGeom2Cell2Connect; + TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh; for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){ const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first; @@ -1112,48 +1114,52 @@ VISU_MedConvertor case MED::ePOLYGONE: { MED::PPolygoneInfo aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom); TInt aNbElem = aPolygoneInfo->GetNbElem(); - - 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(aNbElem > 0){ + TSubMeshImpl& aSubMesh = aGeom2SubMesh[aVGeom]; + TCell2Connect& aCell2Connect = aSubMesh.myCell2Connect; + 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(); - TCell2Connect& aCell2Connect = aGeom2Cell2Connect[aVGeom]; - aCell2Connect.resize(aNbElem); + if(aNbElem > 0){ + TSubMeshImpl& aSubMesh = aGeom2SubMesh[aVGeom]; + TCell2Connect& aCell2Connect = aSubMesh.myCell2Connect; + 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 std::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; + } } } @@ -1165,54 +1171,57 @@ VISU_MedConvertor MED::PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom); TInt aNbElem = aCellInfo->GetNbElem(); - TCell2Connect& aConnForCellType = aGeom2Cell2Connect[aVGeom]; - aConnForCellType.resize(aNbElem); + if(aNbElem > 0){ + TSubMeshImpl& aSubMesh = aGeom2SubMesh[aVGeom]; + TCell2Connect& aCell2Connect = aSubMesh.myCell2Connect; + aCell2Connect.resize(aNbElem); - int aMNbNodes = MEDGeom2NbNodes(aMGeom); - vector aConnect(aMNbNodes); + TInt aMNbNodes = MEDGeom2NbNodes(aMGeom); + TVector aConnect(aMNbNodes); - 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]; + for(TInt iElem = 0; iElem < aNbElem; iElem++) { + MED::TCConnSlice aConnSlice = aCellInfo->GetConnSlice(iElem); + TConnect& anArray = aCell2Connect[iElem]; + anArray.resize(aVNbNodes); + + if(anIsNodeNum){ + for(TInt iConn = 0; iConn < aMNbNodes; iConn++){ + aConnect[iConn] = aNodeIdMap[aConnSlice[iConn] - 1]; + } + }else{ + for(int iConn = 0; iConn < aMNbNodes; iConn++){ + aConnect[iConn] = aConnSlice[iConn] - 1; + } } - }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++) + anArray[iNode] = aConnect[iNode]; } - } - - 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]; + if(anArray[iNode] < 0 || aNbPoints <= anArray[iNode]) + EXCEPTION(runtime_error,"LoadCellsOnEntity - "<< + " aNbPoints("<myGeom2Size; MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin(); - TGeom2Cell2Connect& aGeom2Cell2Connect = theMeshOnEntity->myGeom2Cell2Connect; for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){ const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first; MED::PElemInfo anElemInfo; -- 2.39.2