X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FDriverMED%2FDriverMED_W_SMESHDS_Mesh.cxx;h=b4ab8dbe401b4a8caf9d5649d61359ea9f110ea3;hp=ade26b2b7ab24e514ee69914ca26ab4dcc4586f6;hb=193c49c87753b6ccabb2b5e6dc935aa480d2d43e;hpb=bd8f1aee7c78f7d2eb82bd4fec5e08c9e3d280ce diff --git a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx index ade26b2b7..b4ab8dbe4 100644 --- a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -24,19 +24,21 @@ // File : DriverMED_W_SMESHDS_Mesh.cxx // Module : SMESH // -#include #include "DriverMED_W_SMESHDS_Mesh.h" -#include "DriverMED_Family.h" -#include "SMESHDS_Mesh.hxx" +#include "DriverMED_Family.h" +#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 "utilities.h" +#include -#include "MED_Utilities.hxx" #define _EDF_NODE_IDS_ //#define _ELEMENTS_BY_DIM_ @@ -46,25 +48,28 @@ using namespace MED; DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh(): + myMedVersion(MED::eV2_2), myAllSubMeshes (false), myDoGroupOfNodes (false), myDoGroupOfEdges (false), myDoGroupOfFaces (false), myDoGroupOfVolumes (false), myDoGroupOf0DElems(false), - myDoGroupOfBalls(false) + myDoGroupOfBalls(false), + myAutoDimension(true), + myAddODOnVertices(false) {} void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName, - MED::EVersion theId) + MED::EVersion theId) { - myMed = CrWrapper(theFileName,theId); Driver_SMESHDS_Mesh::SetFile(theFileName); + myMedVersion = theId; } void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName) { - return SetFile(theFileName,MED::eV2_2); + Driver_SMESHDS_Mesh::SetFile(theFileName); } string DriverMED_W_SMESHDS_Mesh::GetVersionString(const MED::EVersion theVersion, int theNbDigits) @@ -97,7 +102,7 @@ void DriverMED_W_SMESHDS_Mesh::AddAllSubMeshes() void DriverMED_W_SMESHDS_Mesh::AddSubMesh(SMESHDS_SubMesh* theSubMesh, int theID) { - mySubMeshes[theID] = theSubMesh; + mySubMeshes.push_back( theSubMesh ); } void DriverMED_W_SMESHDS_Mesh::AddGroupOfNodes() @@ -120,7 +125,8 @@ void DriverMED_W_SMESHDS_Mesh::AddGroupOfVolumes() myDoGroupOfVolumes = true; } -namespace{ +namespace +{ typedef double (SMDS_MeshNode::* TGetCoord)() const; typedef const char* TName; typedef const char* TUnit; @@ -287,6 +293,20 @@ namespace{ // return elem_famNum->second; return aDefaultFamilyId; } + + //================================================================================ + /*! + * \brief Returns iterator on sub-meshes + */ + //================================================================================ + + SMESHDS_SubMeshIteratorPtr getIterator( std::vector& mySubMeshes ) + { + return SMESHDS_SubMeshIteratorPtr + ( new SMDS_SetIterator + < const SMESHDS_SubMesh*, std::vector< SMESHDS_SubMesh* >::iterator >( mySubMeshes.begin(), + mySubMeshes.end() )); + } } Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() @@ -311,12 +331,13 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() } // Mesh dimension definition - TInt aSpaceDimension; + TInt aSpaceDimension = 3; TCoordHelperPtr aCoordHelperPtr; { bool anIsXDimension = false; bool anIsYDimension = false; bool anIsZDimension = false; + if ( myAutoDimension ) { SMDS_NodeIteratorPtr aNodesIter = myMesh->nodesIterator(); double aBounds[6]; @@ -390,6 +411,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() if ( myMesh->NbVolumes() > 0 ) aMeshDimension = 3; + MED::PWrapper myMed = CrWrapper(myFile,myMedVersion); PMeshInfo aMeshInfo = myMed->CrMeshInfo(aMeshDimension,aSpaceDimension,aMeshName); MESSAGE("Add - aMeshName : "<GetName()); myMed->SetMeshInfo(aMeshInfo); @@ -416,7 +438,6 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() if (myDoGroupOfBalls && nbBalls) myBallsDefaultFamilyId = REST_BALL_FAMILY; MESSAGE("Perform - aFamilyInfo"); - //cout << " DriverMED_Family::MakeFamilies() " << endl; list aFamilies; if (myAllSubMeshes) { aFamilies = DriverMED_Family::MakeFamilies @@ -429,7 +450,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() myDoGroupOfBalls && nbBalls); } else { aFamilies = DriverMED_Family::MakeFamilies - (mySubMeshes, myGroups, + (getIterator( mySubMeshes ), myGroups, myDoGroupOfNodes && nbNodes, myDoGroupOfEdges && nbEdges, myDoGroupOfFaces && nbFaces, @@ -437,7 +458,6 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() myDoGroupOf0DElems && nb0DElements, myDoGroupOfBalls && nbBalls); } - //cout << " myMed->SetFamilyInfo() " << endl; list::iterator aFamsIter; for (aFamsIter = aFamilies.begin(); aFamsIter != aFamilies.end(); aFamsIter++) { @@ -458,7 +478,6 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() const EConnectivite theConnMode = eNOD; TInt aNbNodes = myMesh->NbNodes(); - //cout << " myMed->CrNodeInfo() aNbNodes = " << aNbNodes << endl; PNodeInfo aNodeInfo = myMed->CrNodeInfo(aMeshInfo, aNbNodes, theMode, theSystem, theIsElemNum, theIsElemNames); @@ -478,7 +497,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() int aNodeID = aCoordHelperPtr->GetID(); aNodeInfo->SetElemNum( iNode, aNodeID ); #ifdef _EDF_NODE_IDS_ - aNodeIdMap[aNodeID] = iNode+1; + aNodeIdMap.insert( aNodeIdMap.end(), make_pair( aNodeID, iNode+1 )); #endif // family number const SMDS_MeshNode* aNode = aCoordHelperPtr->GetNode(); @@ -509,6 +528,22 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() bool polyTypesSupported = myMed->CrPolygoneInfo(aMeshInfo,eMAILLE,ePOLYGONE,0,0); TInt nbPolygonNodes = 0, nbPolyhedronNodes = 0, nbPolyhedronFaces = 0; + // nodes on VERTEXes where 0D elements are absent + std::vector nodesOf0D; + std::vector< SMDS_ElemIteratorPtr > iterVec; + SMDS_ElemIteratorPtr iterVecIter; + if ( myAddODOnVertices && getNodesOfMissing0DOnVert( myMesh, nodesOf0D )) + { + iterVec.resize(2); + iterVec[0] = myMesh->elementsIterator( SMDSAbs_0DElement ); + iterVec[1] = SMDS_ElemIteratorPtr + ( new SMDS_ElementVectorIterator( nodesOf0D.begin(), nodesOf0D.end() )); + + typedef SMDS_IteratorOnIterators + < const SMDS_MeshElement *, std::vector< SMDS_ElemIteratorPtr > > TItIterator; + iterVecIter = SMDS_ElemIteratorPtr( new TItIterator( iterVec )); + } + // collect info on all geom types list< TElemTypeData > aTElemTypeDatas; @@ -519,7 +554,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() #endif aTElemTypeDatas.push_back(TElemTypeData(anEntity, ePOINT1, - nbElemInfo.Nb0DElements(), + nbElemInfo.Nb0DElements() + nodesOf0D.size(), SMDSAbs_0DElement)); #ifdef _ELEMENTS_BY_DIM_ anEntity = eSTRUCT_ELEMENT; @@ -532,28 +567,33 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() anEntity = eARETE; #endif aTElemTypeDatas.push_back( TElemTypeData(anEntity, - eSEG2, - nbElemInfo.NbEdges( ORDER_LINEAR ), - SMDSAbs_Edge)); + eSEG2, + nbElemInfo.NbEdges( ORDER_LINEAR ), + SMDSAbs_Edge)); aTElemTypeDatas.push_back( TElemTypeData(anEntity, - eSEG3, - nbElemInfo.NbEdges( ORDER_QUADRATIC ), - SMDSAbs_Edge)); + eSEG3, + nbElemInfo.NbEdges( ORDER_QUADRATIC ), + SMDSAbs_Edge)); #ifdef _ELEMENTS_BY_DIM_ anEntity = eFACE; #endif aTElemTypeDatas.push_back( TElemTypeData(anEntity, - eTRIA3, - nbElemInfo.NbTriangles( ORDER_LINEAR ), - SMDSAbs_Face)); + eTRIA3, + nbElemInfo.NbTriangles( ORDER_LINEAR ), + SMDSAbs_Face)); aTElemTypeDatas.push_back( TElemTypeData(anEntity, - eTRIA6, - nbElemInfo.NbTriangles( ORDER_QUADRATIC ), - SMDSAbs_Face)); + eTRIA6, + nbElemInfo.NbTriangles( ORDER_QUADRATIC ) - + nbElemInfo.NbBiQuadTriangles(), + SMDSAbs_Face)); + aTElemTypeDatas.push_back( TElemTypeData(anEntity, + eTRIA7, + nbElemInfo.NbBiQuadTriangles(), + SMDSAbs_Face)); aTElemTypeDatas.push_back( TElemTypeData(anEntity, - eQUAD4, - nbElemInfo.NbQuadrangles( ORDER_LINEAR ), - SMDSAbs_Face)); + eQUAD4, + nbElemInfo.NbQuadrangles( ORDER_LINEAR ), + SMDSAbs_Face)); aTElemTypeDatas.push_back( TElemTypeData(anEntity, eQUAD8, nbElemInfo.NbQuadrangles( ORDER_QUADRATIC ) - @@ -566,37 +606,46 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() if ( polyTypesSupported ) { aTElemTypeDatas.push_back( TElemTypeData(anEntity, ePOLYGONE, - nbElemInfo.NbPolygons(), + nbElemInfo.NbPolygons( ORDER_LINEAR ), SMDSAbs_Face)); // we need one more loop on poly elements to count nb of their nodes aTElemTypeDatas.push_back( TElemTypeData(anEntity, ePOLYGONE, - nbElemInfo.NbPolygons(), + nbElemInfo.NbPolygons( ORDER_LINEAR ), + SMDSAbs_Face)); + aTElemTypeDatas.push_back( TElemTypeData(anEntity, + ePOLYGON2, + nbElemInfo.NbPolygons( ORDER_QUADRATIC ), + SMDSAbs_Face)); + // we need one more loop on QUAD poly elements to count nb of their nodes + aTElemTypeDatas.push_back( TElemTypeData(anEntity, + ePOLYGON2, + nbElemInfo.NbPolygons( ORDER_QUADRATIC ), SMDSAbs_Face)); } #ifdef _ELEMENTS_BY_DIM_ anEntity = eMAILLE; #endif aTElemTypeDatas.push_back( TElemTypeData(anEntity, - eTETRA4, - nbElemInfo.NbTetras( ORDER_LINEAR ), - SMDSAbs_Volume)); + eTETRA4, + nbElemInfo.NbTetras( ORDER_LINEAR ), + SMDSAbs_Volume)); aTElemTypeDatas.push_back( TElemTypeData(anEntity, - eTETRA10, - nbElemInfo.NbTetras( ORDER_QUADRATIC ), - SMDSAbs_Volume)); + eTETRA10, + nbElemInfo.NbTetras( ORDER_QUADRATIC ), + SMDSAbs_Volume)); aTElemTypeDatas.push_back( TElemTypeData(anEntity, - ePYRA5, - nbElemInfo.NbPyramids( ORDER_LINEAR ), - SMDSAbs_Volume)); + ePYRA5, + nbElemInfo.NbPyramids( ORDER_LINEAR ), + SMDSAbs_Volume)); aTElemTypeDatas.push_back( TElemTypeData(anEntity, - ePYRA13, - nbElemInfo.NbPyramids( ORDER_QUADRATIC ), - SMDSAbs_Volume)); + ePYRA13, + nbElemInfo.NbPyramids( ORDER_QUADRATIC ), + SMDSAbs_Volume)); aTElemTypeDatas.push_back( TElemTypeData(anEntity, - ePENTA6, - nbElemInfo.NbPrisms( ORDER_LINEAR ), - SMDSAbs_Volume)); + ePENTA6, + nbElemInfo.NbPrisms( ORDER_LINEAR ), + SMDSAbs_Volume)); aTElemTypeDatas.push_back( TElemTypeData(anEntity, ePENTA15, nbElemInfo.NbPrisms( ORDER_QUADRATIC ), @@ -667,9 +716,14 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() // Treat POLYGONs // --------------- - if ( aElemTypeData->_geomType == ePOLYGONE ) + if ( aElemTypeData->_geomType == ePOLYGONE || + aElemTypeData->_geomType == ePOLYGON2 ) { - elemIterator = myMesh->elementGeomIterator( SMDSGeom_POLYGON ); + if ( aElemTypeData->_geomType == ePOLYGONE ) + elemIterator = myMesh->elementEntityIterator( SMDSEntity_Polygon ); + else + elemIterator = myMesh->elementEntityIterator( SMDSEntity_Quad_Polygon ); + if ( nbPolygonNodes == 0 ) { // Count nb of nodes while ( elemIterator->more() ) { @@ -719,9 +773,10 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() break; } myMed->SetPolygoneInfo(aPolygoneInfo); - } - } + nbPolygonNodes = 0; // to treat next polygon type + } + } // Treat POLYEDREs // ---------------- @@ -863,6 +918,8 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() TInt aNbNodes = MED::GetNbNodes(aElemTypeData->_geomType); elemIterator = myMesh->elementsIterator( aElemTypeData->_smdsType ); + if ( aElemTypeData->_smdsType == SMDSAbs_0DElement && ! nodesOf0D.empty() ) + elemIterator = iterVecIter; while ( elemIterator->more() ) { const SMDS_MeshElement* anElem = elemIterator->next(); @@ -911,3 +968,31 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() mySubMeshes.clear(); return aResult; } + +//================================================================================ +/*! + * \brief Returns nodes on VERTEXes where 0D elements are absent + */ +//================================================================================ + +bool DriverMED_W_SMESHDS_Mesh:: +getNodesOfMissing0DOnVert(SMESHDS_Mesh* meshDS, + std::vector& nodes) +{ + nodes.clear(); + for ( int i = 1; i <= meshDS->MaxShapeIndex(); ++i ) + { + if ( meshDS->IndexToShape( i ).ShapeType() != TopAbs_VERTEX ) + continue; + if ( SMESHDS_SubMesh* sm = meshDS->MeshElements(i) ) { + SMDS_NodeIteratorPtr nIt= sm->GetNodes(); + while (nIt->more()) + { + const SMDS_MeshNode* n = nIt->next(); + if ( n->NbInverseElements( SMDSAbs_0DElement ) == 0 ) + nodes.push_back( n ); + } + } + } + return !nodes.empty(); +}