X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FDriverMED%2FDriverMED_W_SMESHDS_Mesh.cxx;h=a1902daac8aafe9f4cfc43d9c83906a2e769242f;hb=49ff23c9;hp=552a214173a4ced4d3dceb04323d14485458801b;hpb=d3e1cabf77f67408ac401e2d387e721605cb3b10;p=modules%2Fsmesh.git diff --git a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx index 552a21417..a1902daac 100644 --- a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx @@ -31,12 +31,12 @@ #include "MED_Factory.hxx" #include "MED_Utilities.hxx" #include "SMDS_IteratorOnIterators.hxx" -#include "SMDS_MeshElement.hxx" #include "SMDS_MeshNode.hxx" -#include "SMDS_PolyhedralVolumeOfNodes.hxx" #include "SMDS_SetIterator.hxx" #include "SMESHDS_Mesh.hxx" +#include + #include #include #include @@ -64,11 +64,41 @@ DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh(): myDoAllInGroups(false) {} -void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName) +void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName, int theMinor) { + myMinor = theMinor; Driver_SMESHDS_Mesh::SetFile(theFileName); } +/*! + * MED version is either the latest available, or with an inferior minor, + * to ensure backward compatibility on writing med files. + */ +string DriverMED_W_SMESHDS_Mesh::GetVersionString(int theVersion, int theNbDigits) +{ + TInt majeur, mineur, release; + majeur=MED_MAJOR_NUM; + mineur=MED_MINOR_NUM; + release=MED_RELEASE_NUM; + TInt imposedMineur = mineur; + + if (theVersion < 0) + imposedMineur = mineur; + else if (theVersion > MED_MINOR_NUM) + imposedMineur = mineur; + else + imposedMineur = theVersion; + + ostringstream name; + if ( theNbDigits > 0 ) + name << majeur; + if ( theNbDigits > 1 ) + name << "." << imposedMineur; + if ( theNbDigits > 2 ) + name << "." << release; + return name.str(); +} + void DriverMED_W_SMESHDS_Mesh::AddGroup(SMESHDS_GroupBase* theGroup) { myGroups.push_back(theGroup); @@ -313,10 +343,6 @@ namespace Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() { Status aResult = DRS_OK; - if (myMesh->hasConstructionEdges() || myMesh->hasConstructionFaces()) { - INFOS("SMDS_MESH with hasConstructionEdges() or hasConstructionFaces() do not supports!!!"); - return DRS_FAIL; - } try { //MESSAGE("Perform - myFile : "<next(); aBounds[0] = min(aBounds[0],aNode->X()); aBounds[1] = max(aBounds[1],aNode->X()); - + aBounds[2] = min(aBounds[2],aNode->Y()); aBounds[3] = max(aBounds[3],aNode->Y()); @@ -407,7 +433,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() } } - SMDS_NodeIteratorPtr aNodesIter = myMesh->nodesIterator(/*idInceasingOrder=*/true); + SMDS_NodeIteratorPtr aNodesIter = myMesh->nodesIterator(); switch ( aSpaceDimension ) { case 3: aCoordHelperPtr.reset(new TCoordHelper(aNodesIter,aXYZGetCoord,aXYZName)); @@ -431,7 +457,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() } } - MED::PWrapper myMed = CrWrapperW(myFile); + MED::PWrapper myMed = CrWrapperW(myFile, myMinor); PMeshInfo aMeshInfo = myMed->CrMeshInfo(aMeshDimension,aSpaceDimension,aMeshName); //MESSAGE("Add - aMeshName : "<GetName()); myMed->SetMeshInfo(aMeshInfo); @@ -677,7 +703,11 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() SMDSAbs_Volume)); aTElemTypeDatas.push_back( TElemTypeData(anEntity, ePENTA15, - nbElemInfo.NbPrisms( ORDER_QUADRATIC ), + nbElemInfo.NbQuadPrisms(), + SMDSAbs_Volume)); + aTElemTypeDatas.push_back( TElemTypeData(anEntity, + ePENTA18, + nbElemInfo.NbBiQuadPrisms(), SMDSAbs_Volume)); aTElemTypeDatas.push_back( TElemTypeData(anEntity, eHEXA8, @@ -729,6 +759,13 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() continue; } + // build map of family numbers for this type + if ( !isElemFamMapBuilt[ aElemTypeData->_smdsType ]) + { + fillElemFamilyMap( anElemFamMap, aFamilies, aElemTypeData->_smdsType ); + isElemFamMapBuilt[ aElemTypeData->_smdsType ] = true; + } + // iterator on elements of a current type SMDS_ElemIteratorPtr elemIterator; int iElem = 0; @@ -799,18 +836,16 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() // Treat POLYEDREs // ---------------- - else if (aElemTypeData->_geomType == ePOLYEDRE ) + else if ( aElemTypeData->_geomType == ePOLYEDRE ) { elemIterator = myMesh->elementGeomIterator( SMDSGeom_POLYHEDRA ); - + if ( nbPolyhedronNodes == 0 ) { // Count nb of nodes while ( elemIterator->more() ) { const SMDS_MeshElement* anElem = elemIterator->next(); - const SMDS_VtkVolume *aPolyedre = dynamic_cast(anElem); - if ( !aPolyedre ) continue; - nbPolyhedronNodes += aPolyedre->NbNodes(); - nbPolyhedronFaces += aPolyedre->NbFaces(); + nbPolyhedronNodes += anElem->NbNodes(); + nbPolyhedronFaces += anElem->NbFaces(); if ( ++iElem == aElemTypeData->_nbElems ) break; } @@ -835,8 +870,8 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() TInt iFace = 0, iNode = 0; while ( elemIterator->more() ) { - const SMDS_MeshElement* anElem = elemIterator->next(); - const SMDS_VtkVolume *aPolyedre = dynamic_cast(anElem); + const SMDS_MeshElement* anElem = elemIterator->next(); + const SMDS_MeshVolume *aPolyedre = myMesh->DownCast< SMDS_MeshVolume >( anElem ); if ( !aPolyedre ) continue; // index TInt aNbFaces = aPolyedre->NbFaces(); @@ -879,13 +914,6 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() // allocate data arrays PBallInfo aBallInfo = myMed->CrBallInfo( aMeshInfo, aElemTypeData->_nbElems ); - // build map of family numbers for this type - if ( !isElemFamMapBuilt[ aElemTypeData->_smdsType ]) - { - fillElemFamilyMap( anElemFamMap, aFamilies, aElemTypeData->_smdsType ); - isElemFamMapBuilt[ aElemTypeData->_smdsType ] = true; - } - elemIterator = myMesh->elementsIterator( SMDSAbs_Ball ); while ( elemIterator->more() ) { @@ -917,7 +945,6 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() { // Treat standard types // --------------------- - // allocate data arrays PCellInfo aCellInfo = myMed->CrCellInfo( aMeshInfo, aElemTypeData->_entity, @@ -926,13 +953,6 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() theConnMode, theIsElemNum, theIsElemNames); - // build map of family numbers for this type - if ( !isElemFamMapBuilt[ aElemTypeData->_smdsType ]) - { - //cout << " fillElemFamilyMap()" << endl; - fillElemFamilyMap( anElemFamMap, aFamilies, aElemTypeData->_smdsType ); - isElemFamMapBuilt[ aElemTypeData->_smdsType ] = true; - } TInt aNbNodes = MED::GetNbNodes(aElemTypeData->_geomType); elemIterator = myMesh->elementsIterator( aElemTypeData->_smdsType ); @@ -967,10 +987,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() // store data in a file myMed->SetCellInfo(aCellInfo); } - } // loop on geom types - - } catch(const std::exception& exc) { INFOS("The following exception was caught:\n\t"<