+ //---------------------------------------------------------------
+ int
+ MEDGeom2NbNodes(int theMEDGeomType)
+ {
+ switch(theMEDGeomType){
+ case SALOME_MED::MED_NONE:
+ return 0;
+ case SALOME_MED::MED_POINT1:
+ return 1;
+ case SALOME_MED::MED_SEG2:
+ return 2;
+ case SALOME_MED::MED_SEG3:
+ return 3;
+ case SALOME_MED::MED_TRIA3:
+ return 3;
+ case SALOME_MED::MED_TRIA6:
+ return 6;
+ case SALOME_MED::MED_QUAD4:
+ return 4;
+ case SALOME_MED::MED_QUAD8:
+ return 8;
+ case SALOME_MED::MED_TETRA4:
+ return 4;
+ case SALOME_MED::MED_TETRA10:
+ return 10;
+ case SALOME_MED::MED_HEXA8:
+ return 8;
+ case SALOME_MED::MED_HEXA20:
+ return 20;
+ case SALOME_MED::MED_PENTA6:
+ return 6;
+ case SALOME_MED::MED_PENTA15:
+ return 15;
+ case SALOME_MED::MED_PYRA5:
+ return 5;
+ case SALOME_MED::MED_PYRA13:
+ return 13;
+ }
+ return -1;
+ }
+
+
+ //---------------------------------------------------------------
+ VISU::EGeometry
+ MEDGeom2VISU(SALOME_MED::medGeometryElement theGeom)
+ {
+ switch(theGeom){
+ case SALOME_MED::MED_POINT1:
+ return VISU::ePOINT1;
+ case SALOME_MED::MED_SEG2:
+ return VISU::eSEG2;
+ case SALOME_MED::MED_SEG3:
+ return VISU::eSEG3;
+ case SALOME_MED::MED_TRIA3:
+ return VISU::eTRIA3;
+ case SALOME_MED::MED_TRIA6:
+ return VISU::eTRIA6;
+ case SALOME_MED::MED_QUAD4:
+ return VISU::eQUAD4;
+ case SALOME_MED::MED_QUAD8:
+ return VISU::eQUAD8;
+ case SALOME_MED::MED_TETRA4:
+ return VISU::eTETRA4;
+ case SALOME_MED::MED_TETRA10:
+ return VISU::eTETRA10;
+ case SALOME_MED::MED_HEXA8:
+ return VISU::eHEXA8;
+ case SALOME_MED::MED_HEXA20:
+ return VISU::eHEXA20;
+ case SALOME_MED::MED_PENTA6:
+ return VISU::ePENTA6;
+ case SALOME_MED::MED_PENTA15:
+ return VISU::ePENTA15;
+ case SALOME_MED::MED_PYRA5:
+ return VISU::ePYRA5;
+ case SALOME_MED::MED_PYRA13:
+ return VISU::ePYRA13;
+ case SALOME_MED::MED_POLYGON:
+ return VISU::ePOLYGONE;
+ case SALOME_MED::MED_POLYHEDRA:
+ return VISU::ePOLYEDRE;
+ }
+ return VISU::eNONE;
+ }
+
+ //---------------------------------------------------------------
+ SALOME_MED::medGeometryElement
+ VISUGeomToMED(int theGeom)
+ {
+ switch(theGeom){
+ case VISU::ePOINT1:
+ return SALOME_MED::MED_POINT1;
+ case VISU::eSEG2:
+ return SALOME_MED::MED_SEG2;
+ case VISU::eTRIA3:
+ return SALOME_MED::MED_TRIA3;
+ case VISU::eQUAD4:
+ return SALOME_MED::MED_QUAD4;
+ case VISU::eTETRA4:
+ return SALOME_MED::MED_TETRA4;
+ case VISU::eHEXA8:
+ return SALOME_MED::MED_HEXA8;
+ case VISU::ePENTA6:
+ return SALOME_MED::MED_PENTA6;
+ case VISU::ePYRA5:
+ return SALOME_MED::MED_PYRA5;
+
+ case VISU::eSEG3:
+ return SALOME_MED::MED_SEG3;
+ case VISU::eTRIA6:
+ return SALOME_MED::MED_TRIA6;
+ case VISU::eQUAD8:
+ return SALOME_MED::MED_QUAD8;
+ case VISU::eTETRA10:
+ return SALOME_MED::MED_TETRA10;
+ case VISU::eHEXA20:
+ return SALOME_MED::MED_HEXA20;
+ case VISU::ePENTA15:
+ return SALOME_MED::MED_PENTA15;
+ case VISU::ePYRA13:
+ return SALOME_MED::MED_PYRA13;
+ case VISU::ePOLYGONE:
+ return SALOME_MED::MED_POLYGON;
+ case VISU::ePOLYEDRE:
+ return SALOME_MED::MED_POLYHEDRA;
+ }
+ return SALOME_MED::medGeometryElement(-1);
+ }
+
+ //---------------------------------------------------------------
+ SALOME_MED::medGeometryElement
+ VTKGeomToMED(int theVTKGeomType)
+ {
+ switch(theVTKGeomType){
+ case VTK_VERTEX:
+ return SALOME_MED::MED_POINT1;
+ case VTK_LINE:
+ return SALOME_MED::MED_SEG2;
+ case VTK_TRIANGLE:
+ return SALOME_MED::MED_TRIA3;
+ case VTK_QUAD:
+ return SALOME_MED::MED_QUAD4;
+ case VTK_TETRA:
+ return SALOME_MED::MED_TETRA4;
+ case VTK_HEXAHEDRON:
+ return SALOME_MED::MED_HEXA8;
+ case VTK_WEDGE:
+ return SALOME_MED::MED_PENTA6;
+ case VTK_PYRAMID:
+ return SALOME_MED::MED_PYRA5;
+ case VTK_POLYGON:
+ return SALOME_MED::MED_POLYGON;
+ }
+ return SALOME_MED::medGeometryElement(-1);
+ }
+
+ //---------------------------------------------------------------
+ VISU::TEntity
+ MEDEntityToVTK(SALOME_MED::medEntityMesh theMEDEntity)
+ {
+ switch(theMEDEntity){
+ case SALOME_MED::MED_NODE:
+ return VISU::NODE_ENTITY;
+ case SALOME_MED::MED_EDGE:
+ return VISU::EDGE_ENTITY;
+ case SALOME_MED::MED_FACE:
+ return VISU::FACE_ENTITY;
+ case SALOME_MED::MED_CELL:
+ return VISU::CELL_ENTITY;
+ }
+ return VISU::TEntity(-1);
+ }
+
+ //---------------------------------------------------------------
+ SALOME_MED::medEntityMesh
+ VTKEntityToMED(VISU::TEntity theVTKEntity)
+ {
+ switch(theVTKEntity){
+ case VISU::NODE_ENTITY:
+ return SALOME_MED::MED_NODE;
+ case VISU::EDGE_ENTITY:
+ return SALOME_MED::MED_EDGE;
+ case VISU::FACE_ENTITY:
+ return SALOME_MED::MED_FACE;
+ case VISU::CELL_ENTITY:
+ return SALOME_MED::MED_CELL;
+ }
+ return SALOME_MED::medEntityMesh(-1);
+ }
+
+
+ //---------------------------------------------------------------
+ std::string
+ GetSObjectName(SALOMEDS::SObject_ptr aSObject)
+ {
+ SALOMEDS::GenericAttribute_var anAttr;
+ if (aSObject->FindAttribute(anAttr,"AttributeName")) {
+ SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ CORBA::String_var aString = aName->Value();
+ return aString.in();
+ }
+ return "";
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ GetCellsSize(vtkIdType& theNbCells,
+ vtkIdType& theCellsSize,
+ SALOME_MED::MESH_ptr theMEDMesh,
+ const VISU::TEntity& theVEntity)
+ {
+ theNbCells = theCellsSize = 0;
+ if(MYDEBUG) MESSAGE("GetCellsSize - theVEntity = "<<theVEntity);
+ const SALOME_MED::medEntityMesh& aMEntity = VTKEntityToMED(theVEntity);
+ SALOME_MED::MESH::connectivityInfos_var connInfo=theMEDMesh->getConnectGlobal(aMEntity);
+ int iGeomEnd = connInfo->meshTypes.length();
+ for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
+ int iNumElemEnd = connInfo->numberOfElements[iGeom];
+ if(iNumElemEnd > 0){
+ if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<<iNumElemEnd);
+ theCellsSize += iNumElemEnd + connInfo->nodalConnectivityLength[iGeom];
+ theNbCells += iNumElemEnd;
+ }
+ }
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ GetCellsSize(vtkIdType& theNbCells,
+ vtkIdType& theCellsSize,
+ SALOME_MED::FAMILY_ptr theMEDFamily)
+ {
+ theNbCells = theCellsSize = 0;
+ SALOME_MED::SUPPORT::supportInfos_var suppInfo=theMEDFamily->getSupportGlobal();
+ int iGeomEnd = suppInfo->types.length();
+ if(MYDEBUG) MESSAGE("GetCellsSize - iGeomEnd = "<<iGeomEnd);
+ for(int iGeom = 0; iGeom < iGeomEnd; iGeom++) {
+ int iNumElemEnd = suppInfo->nbEltTypes[iGeom];
+ if(iNumElemEnd > 0){
+ if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<<iNumElemEnd);
+ theNbCells += iNumElemEnd;
+ theCellsSize += iNumElemEnd + suppInfo->nodalConnectivityLength[iGeom];
+ }
+ }
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ GetCellsSize(VISU::PCMesh theMesh,
+ SALOME_MED::MESH_ptr theMEDMesh,
+ const VISU::TEntity& theEntity)
+ {
+ VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
+ VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[theEntity];
+ if(theEntity == VISU::NODE_ENTITY){
+ aMeshOnEntity->myNbCells = theMesh->myNbPoints;
+ aMeshOnEntity->myCellsSize = 2*theMesh->myNbPoints;
+ }else{
+ GetCellsSize(aMeshOnEntity->myNbCells,aMeshOnEntity->myCellsSize,theMEDMesh,theEntity);
+ }
+ }
+
+
+ //---------------------------------------------------------------
+ VISU::PCMeshOnEntity
+ InitMeshOnEntity(const VISU::PCMesh& theMesh,
+ const VISU::TEntity& theEntity,
+ const VISU::PCMeshOnEntity& theMeshOnEntity)
+ {
+ VISU::PCMeshOnEntity aMeshOnEntity;
+ VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
+ VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(theEntity);
+ if(anIter == aMeshOnEntityMap.end()){
+ aMeshOnEntity.reset(new VISU::TCMeshOnEntity());
+ *aMeshOnEntity = *theMeshOnEntity;
+ aMeshOnEntity->myEntity = theEntity;
+ aMeshOnEntityMap[theEntity] = aMeshOnEntity;
+ }else
+ aMeshOnEntity = anIter->second;
+
+ GetCellsSize(theMesh,theMesh->myMesh,theEntity);
+
+ return aMeshOnEntity;
+ }
+
+
+ VISU::PCSubProfile
+ CrSubProfile(const VISU::PCMesh theMesh,
+ const VISU::PCField theField,
+ const VISU::TCMeshOnEntity& theMeshOnEntity,
+ SALOME_MED::medGeometryElement theMGeom,
+ int theNbElems)
+ {
+ if (MYDEBUG) MESSAGE("CrSubProfile");
+ VISU::EGeometry aEGeom = MEDGeom2VISU(theMGeom);
+ vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
+
+ VISU::PCSubProfile aSubProfile(new VISU::TCSubProfile());
+ aSubProfile->myGeom = aEGeom;
+ aSubProfile->myMGeom = theMGeom;
+ aSubProfile->myStatus = VISU::eAddAll;
+ if(MYDEBUG) MESSAGE("theMGeom = "<<theMGeom);
+ const VISU::TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity.myCellsFirstIndex;
+ VISU::TCellsFirstIndex::const_iterator aTimeStampIter = aCellsFirstIndex.find(theMGeom);
+ if(aTimeStampIter == (theMeshOnEntity.myCellsFirstIndex).end() &&
+ theMGeom != SALOME_MED::MED_POINT1)
+ aSubProfile->myStatus = VISU::eRemoveAll;
+ else if(aTimeStampIter == aCellsFirstIndex.end() && theMGeom == SALOME_MED::MED_POINT1){
+ if(theNbElems > 0){
+ aSubProfile->myName = "";
+ aSubProfile->myStatus = VISU::eAddPart;
+
+ aSubProfile->myNbCells = theNbElems;
+ aSubProfile->myCellsSize = aSubProfile->myNbCells;
+ }
+ }else{
+ if(theNbElems > 0){
+ aSubProfile->myName = "";
+ aSubProfile->myStatus = VISU::eAddPart;
+
+ aSubProfile->myNbCells = theNbElems;
+ aSubProfile->myCellsSize = aSubProfile->myNbCells*aVNbNodes;
+ }
+ }
+
+ if (MYDEBUG) MESSAGE("CrSubProfile done");
+ return aSubProfile;
+ }
+
+ VISU::TProfileKey
+ GetProfileKey(const VISU::PCMesh theMesh,
+ const VISU::PCField theField,
+ const VISU::PCValForTime theValForTime,
+ const VISU::TCMeshOnEntity& theMeshOnEntity)
+ {
+ if (MYDEBUG) MESSAGE("GetProfileKey");
+
+ VISU::TProfileKey aProfileKey;
+
+ const VISU::TCellsFirstIndex& aFirstIndex = theMeshOnEntity.myCellsFirstIndex;
+ VISU::TCellsFirstIndex::const_iterator anIter = aFirstIndex.begin();
+ SALOME_MED::SUPPORT_var aSupport = theValForTime->myField->getSupport();
+ int aNbElems = 0;
+ if(anIter == aFirstIndex.end() && aSupport->getEntity() == SALOME_MED::MED_NODE){
+ SALOME_MED::medGeometryElement aMGeom = SALOME_MED::MED_POINT1;
+ try{
+ aNbElems = aSupport->getNumberOfElements(SALOME_MED::MED_NONE);
+ if(MYDEBUG)MESSAGE("aMGeom="<<aMGeom<<" aNbElems="<<aNbElems);
+ }catch(...){
+ MESSAGE("Error in theValForTime->myField->getSupport()->getNumberOfElements(aMGeom);");
+ }
+
+ VISU::PCSubProfile aSubProfile = CrSubProfile(theMesh,
+ theField,
+ theMeshOnEntity,
+ aMGeom,
+ aNbElems);
+ aProfileKey.insert(aSubProfile);
+ }
+
+ for(; anIter != aFirstIndex.end(); anIter++){
+ SALOME_MED::medGeometryElement aMGeom = anIter->first;
+ try{
+ aNbElems = aSupport->getNumberOfElements(aMGeom);
+ if(MYDEBUG)MESSAGE("aMGeom="<<aMGeom<<" aNbElems="<<aNbElems);
+ } catch(...){
+ MESSAGE("Error in theValForTime->myField->getSupport()->getNumberOfElements(aMGeom);");
+ continue;
+ }
+ VISU::PCSubProfile aSubProfile = CrSubProfile(theMesh,
+ theField,
+ theMeshOnEntity,
+ aMGeom,
+ aNbElems);
+ 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");
+
+ VISU::TProfileMap& aProfileMap = theMeshOnEntity.myProfileMap;
+
+ VISU::TProfileKey aProfileKey = GetProfileKey(theMesh,
+ theField,
+ theValForTime,
+ theMeshOnEntity);
+
+ VISU::TProfileMap::const_iterator anIter = aProfileMap.find(aProfileKey);
+ if(anIter != aProfileMap.end()){
+ theValForTime->myProfile = anIter->second;
+ if(MYDEBUG) MESSAGE("aProfileMap.find(aProfileKey) aProfile->myGeom=");
+ }else{
+ VISU::PCProfile aProfile(new VISU::TCProfile());
+ VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
+
+ VISU::TProfileKey::const_iterator anIter = aProfileKey.begin();
+ for(; anIter != aProfileKey.end(); anIter++){
+ VISU::PCSubProfile aSubProfile(*anIter);
+
+ if(aProfile->myIsAll && aSubProfile->myStatus != VISU::eAddAll)
+ aProfile->myIsAll = false;
+
+ VISU::EGeometry aEGeom = aSubProfile->myGeom;
+ aGeom2SubProfile[aEGeom] = aSubProfile;
+ }
+
+ aProfileMap[aProfileKey] = aProfile;
+ theValForTime->myProfile = aProfile;
+ }
+ if (MYDEBUG) MESSAGE("InitProfile done");
+ }