From: apo Date: Tue, 1 Mar 2005 07:34:37 +0000 (+0000) Subject: Fix on [Bug PAL8193] Can't "Import Structure" freebord.med file X-Git-Tag: smh_before_merge~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=38122ff76f5b05678f171077e361c302309210a2;p=modules%2Fvisu.git Fix on [Bug PAL8193] Can't "Import Structure" freebord.med file The BUG is caused by different runtime behaviour of SALOME_MED::FAMILY depend on is it defined on all elements or not. --- diff --git a/src/VISU_I/VISU_CorbaMedConvertor.cxx b/src/VISU_I/VISU_CorbaMedConvertor.cxx index 58e3d6eb..12f262df 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.cxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.cxx @@ -542,8 +542,10 @@ VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED) VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity); CORBA::String_var aSupportName = aMEDSupport->getName(); - if(aMEDSupport->isOnAllElements()){ - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - Support isOnAllElements = '"< 0){ + if(MYDEBUG) + MESSAGE("VISU_MEDConvertor::Build - Support isOnAllElements = '"<> There is no points in the mesh !!!"); + + if (iNumElemEnd <= 0) + throw std::runtime_error("LoadPoints >> There is no points in the mesh !!!"); + aPointsCoord.resize(theMesh->myDim*iNumElemEnd,0.0); SALOME_MED::double_array_var coord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE); if(!isPointsLoaded){ for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) for(int iDim = 0, iNumElem2Dim = iNumElem*theMesh->myDim; iDim < theMesh->myDim; iDim++, iNumElem2Dim++) aPointsCoord[iNumElem2Dim] = coord[iNumElem2Dim]; + if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY"); + TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aMeshOnEntity->myCellsConn[VTK_VERTEX]; aConnForCellType.resize(iNumElemEnd); for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) @@ -915,20 +942,29 @@ VISU_MEDConvertor::LoadPoints(VISU::PCMesh theMesh, } if(aFamily){ if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily SubMesh"); + SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily; + CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements(); TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[VTK_VERTEX]; - SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes(); - SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom[0]); - int iNumElemEndTmp = iNumElemEnd; - iNumElemEnd = aCellNumForType->length(); - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) { - int tmp = aCellNumForType[iNumElem]-1; - if(0 > tmp || tmp >= iNumElemEndTmp) { - static QString aString; - aString.sprintf("LoadPoints >> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEnd,iNumElem,tmp); - throw std::runtime_error(aString.latin1()); + + if(!anIsOnAllElements){ + SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes(); + SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom[0]); + int iNumElemEndTmp = iNumElemEnd; + iNumElemEnd = aCellNumForType->length(); + for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) { + int tmp = aCellNumForType[iNumElem]-1; + if(0 > tmp || tmp >= iNumElemEndTmp) { + static QString aString; + aString.sprintf("LoadPoints >> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEnd,iNumElem,tmp); + throw std::runtime_error(aString.latin1()); + } + aSubMeshOnCellType.insert(tmp); + } + }else{ + for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++){ + aSubMeshOnCellType.insert(iNumElem); } - aSubMeshOnCellType.insert(tmp); } } return 1; @@ -1023,29 +1059,43 @@ VISU_MEDConvertor::LoadCellsOnEntity(VISU::PCMesh theMesh, //Filling aFamily SubMesh if(aFamily){ SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily; - SALOME_MED::medGeometryElement_array_var aGeoms = aMedFamily->getTypes(); - iGeomEnd = aGeoms->length(); - if(MYDEBUG) MESSAGE("LoadCellsOnEntity - iGeomEnd = "<getNumber(aGeom); - int aVGeom = MEDGeomToVTK(aGeom); - TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVGeom]; - int iNumElemEndTmp = theMeshOnEntity->myCellsConn[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); - throw std::runtime_error(aString.latin1()); + 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); + TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVGeom]; + int iNumElemEndTmp = theMeshOnEntity->myCellsConn[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); + throw std::runtime_error(aString.latin1()); + } + aSubMeshOnCellType.insert(tmp); } - aSubMeshOnCellType.insert(tmp); + } + }else{ + const TMeshOnEntityImpl::TCellsConn& aCellsConn = theMeshOnEntity->myCellsConn; + TMeshOnEntityImpl::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin(); + for(int anId = 0; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){ + int aVGeom = aCellsConnIter->first; + const TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aCellsConnIter->second; + TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVGeom]; + int iNumElemEnd = aConnForCellType.size(); + for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) + aSubMeshOnCellType.insert(iNumElem); } } }