From: enk Date: Tue, 17 Oct 2006 13:11:26 +0000 (+0000) Subject: Fix for: Bug PAL13498 X-Git-Tag: V3_2_3pre1~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d39608e617b863555b20cde02a2ba8d3d62731ad;p=modules%2Fvisu.git Fix for: Bug PAL13498 Wrong or missing MED profiles support implementation in VISU CORBA MED convertor Added profiles support. --- diff --git a/src/VISU_I/VISU_CorbaMedConvertor.cxx b/src/VISU_I/VISU_CorbaMedConvertor.cxx index 26b5074b..cd8e5730 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.cxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.cxx @@ -173,6 +173,30 @@ namespace return VISU::eNONE; } + //--------------------------------------------------------------- + medGeometryElement + VISUGeomToMED(int theGeom) + { + switch(theGeom){ + case VISU::ePOINT1: return MED_POINT1; + case VISU::eSEG2: return MED_SEG2; + case VISU::eTRIA3: return MED_TRIA3; + case VISU::eQUAD4: return MED_QUAD4; + case VISU::eTETRA4: return MED_TETRA4; + case VISU::eHEXA8: return MED_HEXA8; + case VISU::ePENTA6: return MED_PENTA6; + case VISU::ePYRA5: return MED_PYRA5; + + case VISU::eSEG3: return MED_SEG3; + case VISU::eTRIA6: return MED_TRIA6; + case VISU::eQUAD8: return MED_QUAD8; + case VISU::eTETRA10: return MED_TETRA10; + case VISU::eHEXA20: return MED_HEXA20; + case VISU::ePENTA15: return MED_PENTA15; + case VISU::ePYRA13: return MED_PYRA13; + } + return medGeometryElement(-1); + } //--------------------------------------------------------------- medGeometryElement @@ -317,7 +341,212 @@ namespace return aMeshOnEntity; } - + + + PCSubProfile + CrSubProfile(const VISU::PCMesh theMesh, + const VISU::PCField theField, + const VISU::TCMeshOnEntity& theMeshOnEntity, + SALOME_MED::medGeometryElement theMGeom, + // SALOME_MED::long_array_var theGeom2Profile) + int nbElts) + { + if (MYDEBUG) MESSAGE("CrSubProfile"); + VISU::EGeometry aEGeom = MEDGeom2VISU(theMGeom); + vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom); + + PCSubProfile aSubProfile(new TCSubProfile()); + aSubProfile->myGeom = aEGeom; + aSubProfile->myMGeom = theMGeom; + aSubProfile->myStatus = eAddAll; + if(MYDEBUG) MESSAGE("theMGeom = "<myStatus = eRemoveAll; + else if( aTimeStampIter == (theMeshOnEntity.myCellsFirstIndex).end() && + theMGeom == SALOME_MED::MED_POINT1) + { + if(nbElts>0){ + aSubProfile->myName = ""; + aSubProfile->myStatus = eAddPart; + + aSubProfile->myNbCells = nbElts; + aSubProfile->myCellsSize = aSubProfile->myNbCells; + } + } + else + { + if(nbElts>0){ + aSubProfile->myName = ""; + aSubProfile->myStatus = eAddPart; + + aSubProfile->myNbCells = nbElts; + aSubProfile->myCellsSize = aSubProfile->myNbCells*aVNbNodes; + } + } + + if (MYDEBUG) MESSAGE("CrSubProfile done"); + return aSubProfile; + } + + TProfileKey + GetProfileKey(const VISU::PCMesh theMesh, + const VISU::PCField theField, + const VISU::PCValForTime theValForTime, + const VISU::TCMeshOnEntity& theMeshOnEntity) + { + if (MYDEBUG) MESSAGE("GetProfileKey"); + + TProfileKey aProfileKey; + + const TCellsFirstIndex& aFirstIndex = theMeshOnEntity.myCellsFirstIndex; + TCellsFirstIndex::const_iterator anIter = aFirstIndex.begin(); + int aNbElts = 0; + if(anIter==aFirstIndex.end() && + (theValForTime->myField->getSupport()->getEntity() == SALOME_MED::MED_NODE)) + { + SALOME_MED::medGeometryElement aMGeom = SALOME_MED::MED_POINT1; + + try{ + aNbElts = theValForTime->myField->getSupport()->getNumberOfElements(SALOME_MED::MED_NONE); + if(MYDEBUG)MESSAGE("aMGeom="<myField->getSupport()->getNumberOfElements(aMGeom);"); + } + + PCSubProfile aSubProfile = CrSubProfile(theMesh, + theField, + theMeshOnEntity, + aMGeom, + aNbElts); + aProfileKey.insert(aSubProfile); + } + + for(; anIter != aFirstIndex.end(); anIter++){ + SALOME_MED::medGeometryElement aMGeom = anIter->first; + try{ + aNbElts = theValForTime->myField->getSupport()->getNumberOfElements(aMGeom); + if(MYDEBUG)MESSAGE("aMGeom="<myField->getSupport()->getNumberOfElements(aMGeom);"); + continue; + } + PCSubProfile aSubProfile = CrSubProfile(theMesh, + theField, + theMeshOnEntity, + aMGeom, + aNbElts); + aProfileKey.insert(aSubProfile); + } + + if (MYDEBUG) MESSAGE("GetProfileKey done"); + return aProfileKey; + } + + void + InitProfile(VISU::PCMesh theMesh, + VISU::PCField theField, + VISU::PCValForTime theValForTime, + VISU::TCMeshOnEntity& theMeshOnEntity) + { + if (MYDEBUG) MESSAGE("InitProfile"); + + TProfileMap& aProfileMap = theMeshOnEntity.myProfileMap; + + TProfileKey aProfileKey = GetProfileKey(theMesh, + theField, + theValForTime, + theMeshOnEntity); + + TProfileMap::const_iterator anIter = aProfileMap.find(aProfileKey); + if(anIter != aProfileMap.end()){ + theValForTime->myProfile = anIter->second; + if(MYDEBUG) MESSAGE("aProfileMap.find(aProfileKey) aProfile->myGeom="); + }else{ + PCProfile aProfile(new TCProfile()); + TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile; + + TProfileKey::const_iterator anIter = aProfileKey.begin(); + for(; anIter != aProfileKey.end(); anIter++){ + PCSubProfile aSubProfile(*anIter); + + if(aProfile->myIsAll && aSubProfile->myStatus != eAddAll) + aProfile->myIsAll = false; + + VISU::EGeometry aEGeom = aSubProfile->myGeom; + aGeom2SubProfile[aEGeom] = aSubProfile; + } + + aProfileMap[aProfileKey] = aProfile; + theValForTime->myProfile = aProfile; + } + if (MYDEBUG) MESSAGE("InitProfile done"); + } + + void + LoadProfile(VISU::PCMesh theMesh, + VISU::PCField theField, + VISU::PCValForTime theValForTime, + VISU::PCMeshOnEntity theMeshOnEntity) + { + PCProfile aProfile = theValForTime->myProfile; + if (MYDEBUG) MESSAGE("LoadProfile aProfile->myIsDone="<myIsDone); + if(aProfile->myIsDone) + return; + + const TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile; + TGeom2SubProfile::const_iterator aGeom2SubProfileIter = aGeom2SubProfile.begin(); + if(aGeom2SubProfileIter==aGeom2SubProfile.end()){ + MESSAGE("Warning! No geom 2 sub profile"); + } + for(;aGeom2SubProfileIter!=aGeom2SubProfile.end();aGeom2SubProfileIter++){ + VISU::EGeometry aEGeom = aGeom2SubProfileIter->first; + medGeometryElement aMGeom = VISUGeomToMED(aEGeom); + PCSubProfile aSubProfile = aGeom2SubProfileIter->second; + SALOME_MED::long_array_var aGeom2ProfileIds; + std::vector aGeom2Profile; + if(!theValForTime->myField->getSupport()->isOnAllElements()){ + cout << __LINE__ << endl; + try{ + if(aMGeom == SALOME_MED::MED_POINT1) + aGeom2ProfileIds = theValForTime->myField->getSupport()->getNumberFromFile(SALOME_MED::MED_NONE); + else + aGeom2ProfileIds = theValForTime->myField->getSupport()->getNumberFromFile(aMGeom); + int aLen = aGeom2ProfileIds->length(); + if(MYDEBUG) MESSAGE(" - aMGeom="<" << anId << endl; + } + cout << endl; + } catch(...) { + continue; + } + } else { + cout << __LINE__ << endl; + SALOME_MED::medEntityMesh aMEntity = theValForTime->myField->getSupport()->getEntity(); + int aNbElts = theMesh->myMesh->getNumberOfElements(aMEntity,aMGeom); + for(int i=0;i0){ + TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID; + int aSize = aGeom2Profile.size(); + aSubMeshID.resize(aSize); + + + for(int anId = 0; anId < aSize; anId++){ + aSubMeshID[anId] = aGeom2Profile[anId]-1; // ENKENKENKENKENEKENKENKN + } + } + + } + + + aProfile->myIsDone = true; + if (MYDEBUG) MESSAGE("LoadProfile done"); + } } @@ -1014,6 +1243,7 @@ VISU_MEDConvertor TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; aCell2Connect.resize(aNbElem); + if(MYDEBUG) MESSAGE("LoadPoints - aNbElem="<myNbComp; - if(theField->myEntity == NODE_ENTITY){ - VISU::EGeometry aEGeom = VISU::ePOINT1; - int aNbGauss = theValForTime->GetNbGauss(aEGeom); - const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords; - int aNbElem = aCoords.GetNbPoints(); - - if(MYDEBUG) MESSAGE("ImportField - aNbElem = "<GetMeshValue(VISU::ePOINT1); - aMeshValue.Init(aNbElem,aNbGauss,aNbComp); - for(int iElem = 0, anId = 0; iElem < aNbElem; iElem++){ - TValueSliceArr aValueSliceArr = aMeshValue.GetGaussValueSliceArr(iElem); - for(int iGauss = 0; iGauss < aNbGauss; iGauss++){ - TValueSlice& aValueSlice = aValueSliceArr[iGauss]; - for(int iComp = 0; iComp < aNbComp; iComp++){ - aValueSlice[iComp] = theArray[anId++]; + + if(MYDEBUG) MESSAGE("- aNbComp = "<mySupport->getName(); + + if(theMeshOnEntity->mySupport->isOnAllElements() && + strcmp(aSupportName.in(),"SupportOnAll_MED_") > 1){ + + if(theField->myEntity == NODE_ENTITY){ + VISU::EGeometry aEGeom = VISU::ePOINT1; + int aNbGauss = theValForTime->GetNbGauss(aEGeom); + const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords; + int aNbElem = aCoords.GetNbPoints(); + + if(MYDEBUG) MESSAGE("ImportField - aNbElem = "<GetMeshValue(VISU::ePOINT1); + aMeshValue.Init(aNbElem,aNbGauss,aNbComp); + for(int iElem = 0, anId = 0; iElem < aNbElem; iElem++){ + TValueSliceArr aValueSliceArr = aMeshValue.GetGaussValueSliceArr(iElem); + for(int iGauss = 0; iGauss < aNbGauss; iGauss++){ + TValueSlice& aValueSlice = aValueSliceArr[iGauss]; + for(int iComp = 0; iComp < aNbComp; iComp++){ + aValueSlice[iComp] = theArray[anId++]; + } + } + } + } else { + SALOME_MED::medGeometryElement* aGeomElems; + const TEntity& aVEntity = theField->myEntity; + int iGeomEnd = GetEntity2Geom(aVEntity,aGeomElems); + for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){ + SALOME_MED::medGeometryElement aMGeom = aGeomElems[iGeom]; + VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom); + int aNbGauss = theValForTime->GetNbGauss(aEGeom); + const TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity->myCellsFirstIndex; + TCellsFirstIndex::const_iterator aCellsFirstIndexIter = aCellsFirstIndex.find(aMGeom); + if(aCellsFirstIndexIter != aCellsFirstIndex.end()){ + const TIndexAndSize& aIndexAndSize = aCellsFirstIndexIter->second; + if(MYDEBUG) + MESSAGE("ImportField - aMGeom = "<GetMeshValue(aEGeom); + aMeshValue.Init(aNbElem,aNbGauss,aNbComp); + for(int iElem = 0, anId = 0; iElem < aNbElem; iElem++, anId += aNbComp){ + TValueSliceArr aValueSliceArr = aMeshValue.GetGaussValueSliceArr(iElem); + for(int iGauss = 0; iGauss < aNbGauss; iGauss++){ + TValueSlice& aValueSlice = aValueSliceArr[iGauss]; + for(int iComp = 0; iComp < aNbComp; iComp++) + aValueSlice[iComp] = theArray[aStart+anId+iComp]; + } + } } } } - }else{ - SALOME_MED::medGeometryElement* aGeomElems; - const TEntity& aVEntity = theField->myEntity; - int iGeomEnd = GetEntity2Geom(aVEntity,aGeomElems); - for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){ - SALOME_MED::medGeometryElement aMGeom = aGeomElems[iGeom]; - VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom); + return 1; + } + + if(MYDEBUG) MESSAGE("Loading profile"); + theField->myDataSize = 0; + + InitProfile(theMesh,theField,theValForTime,theMeshOnEntity); + + LoadProfile(theMesh,theField,theValForTime,theMeshOnEntity); + + PCProfile aProfile = theValForTime->myProfile; + TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile; + + TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin(); + for(; anIter != aGeom2SubProfile.end(); anIter++){ + VISU::EGeometry aEGeom = anIter->first; + PCSubProfile aSubProfile(anIter->second); + + int aNbElem = aSubProfile->myNbCells; + theField->myDataSize += aNbElem*aNbComp; + + if(aSubProfile->myStatus != eRemoveAll){ int aNbGauss = theValForTime->GetNbGauss(aEGeom); - const TCMeshOnEntity::TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity->myCellsFirstIndex; - TCMeshOnEntity::TCellsFirstIndex::const_iterator aCellsFirstIndexIter = aCellsFirstIndex.find(aMGeom); - if(aCellsFirstIndexIter != aCellsFirstIndex.end()){ - const TCMeshOnEntity::TIndexAndSize& aIndexAndSize = aCellsFirstIndexIter->second; - if(MYDEBUG) - MESSAGE("ImportField - aMGeom = "<GetMeshValue(aEGeom); - aMeshValue.Init(aNbElem,aNbGauss,aNbComp); - for(int iElem = 0, anId = 0; iElem < aNbElem; iElem++, anId += aNbComp){ - TValueSliceArr aValueSliceArr = aMeshValue.GetGaussValueSliceArr(iElem); - for(int iGauss = 0; iGauss < aNbGauss; iGauss++){ - TValueSlice& aValueSlice = aValueSliceArr[iGauss]; - for(int iComp = 0; iComp < aNbComp; iComp++) - aValueSlice[iComp] = theArray[aStart+anId+iComp]; + + if(MYDEBUG) MESSAGE("- aEGeom = "<myIDMapperFilter; if(anIDMapperFilter->myIsVTKDone) @@ -1339,6 +1622,11 @@ VISU_MEDConvertor theValForTime->myProfile = aProfile; SALOME_MED::FIELD_var aMEDField = theValForTime->myField; + + SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport(); + + if(aMEDSupport->isOnAllElements()) aProfile->myIsDone = true; + SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField); if(!aFieldDouble->_is_nil()){ SALOME_MED::double_array_var anArray = aFieldDouble->getValue(SALOME_MED::MED_FULL_INTERLACE); @@ -1354,5 +1642,6 @@ VISU_MEDConvertor anIDMapperFilter->myIsVTKDone = true; + MESSAGE("VISU_MEDConvertor::LoadField done"); return 1; } diff --git a/src/VISU_I/VISU_CorbaMedConvertor.hxx b/src/VISU_I/VISU_CorbaMedConvertor.hxx index 97d47041..23770373 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.hxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.hxx @@ -37,6 +37,8 @@ namespace VISU { + typedef std::pair TIndexAndSize; // + typedef std::map TCellsFirstIndex; // key: SALOME_MED::medGeometryElement //--------------------------------------------------------------- struct TCMesh: virtual TMeshImpl { @@ -44,16 +46,40 @@ namespace VISU }; typedef SharedPtr PCMesh; + //--------------------------------------------------------------- + struct TCSubProfile: virtual TSubProfileImpl + { + SALOME_MED::medGeometryElement myMGeom; + }; + typedef SharedPtr PCSubProfile; //--------------------------------------------------------------- struct TCProfile: virtual TProfileImpl {}; typedef SharedPtr PCProfile; + //--------------------------------------------------------------- + struct TCGauss: virtual TGaussImpl + { + }; + typedef SharedPtr PCGauss; + + struct TCGaussSubMesh: virtual TGaussSubMeshImpl + { + }; + typedef SharedPtr PCGaussSubMesh; + //--------------------------------------------------------------- - struct TCSubMesh: virtual TSubMeshImpl + struct TCGaussMesh: virtual TGaussMeshImpl {}; + typedef SharedPtr PCGaussMesh; + + + //--------------------------------------------------------------- + struct TCSubMesh: virtual TSubMeshImpl + { + }; typedef SharedPtr PCSubMesh; @@ -61,8 +87,6 @@ namespace VISU struct TCMeshOnEntity: virtual TMeshOnEntityImpl { SALOME_MED::SUPPORT_var mySupport; - typedef std::pair TIndexAndSize; - typedef std::map TCellsFirstIndex; TCellsFirstIndex myCellsFirstIndex; }; typedef SharedPtr PCMeshOnEntity;