1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH DriverMED : driver to read and write 'med' files
24 // File : DriverMED_W_SMESHDS_Mesh.cxx
29 #include "DriverMED_W_SMESHDS_Mesh.h"
30 #include "DriverMED_Family.h"
32 #include "SMESHDS_Mesh.hxx"
33 #include "SMDS_MeshElement.hxx"
34 #include "SMDS_MeshNode.hxx"
35 #include "SMDS_PolyhedralVolumeOfNodes.hxx"
37 #include "utilities.h"
39 #include "MED_Utilities.hxx"
41 #define _EDF_NODE_IDS_
42 //#define _ELEMENTS_BY_DIM_
48 DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh():
49 myAllSubMeshes (false),
50 myDoGroupOfNodes (false),
51 myDoGroupOfEdges (false),
52 myDoGroupOfFaces (false),
53 myDoGroupOfVolumes (false)
56 void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName,
59 myMed = CrWrapper(theFileName,theId);
60 Driver_SMESHDS_Mesh::SetFile(theFileName);
63 void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName)
65 return SetFile(theFileName,MED::eV2_2);
68 string DriverMED_W_SMESHDS_Mesh::GetVersionString(const MED::EVersion theVersion, int theNbDigits)
70 TInt majeur, mineur, release;
71 majeur = mineur = release = 0;
72 // if ( theVersion == eV2_1 )
73 // MED::GetVersionRelease<eV2_1>(majeur, mineur, release);
75 MED::GetVersionRelease<eV2_2>(majeur, mineur, release);
77 if ( theNbDigits > 0 )
79 if ( theNbDigits > 1 )
80 name << "." << mineur;
81 if ( theNbDigits > 2 )
82 name << "." << release;
86 void DriverMED_W_SMESHDS_Mesh::AddGroup(SMESHDS_GroupBase* theGroup)
88 myGroups.push_back(theGroup);
91 void DriverMED_W_SMESHDS_Mesh::AddAllSubMeshes()
93 myAllSubMeshes = true;
96 void DriverMED_W_SMESHDS_Mesh::AddSubMesh(SMESHDS_SubMesh* theSubMesh, int theID)
98 mySubMeshes[theID] = theSubMesh;
101 void DriverMED_W_SMESHDS_Mesh::AddGroupOfNodes()
103 myDoGroupOfNodes = true;
106 void DriverMED_W_SMESHDS_Mesh::AddGroupOfEdges()
108 myDoGroupOfEdges = true;
111 void DriverMED_W_SMESHDS_Mesh::AddGroupOfFaces()
113 myDoGroupOfFaces = true;
116 void DriverMED_W_SMESHDS_Mesh::AddGroupOfVolumes()
118 myDoGroupOfVolumes = true;
122 typedef double (SMDS_MeshNode::* TGetCoord)() const;
123 typedef const char* TName;
124 typedef const char* TUnit;
126 // name length in a mesh must be equal to 16 :
133 TUnit aUnit[3] = {M,M,M};
136 TGetCoord aXYZGetCoord[3] = {
141 TName aXYZName[3] = {X,Y,Z};
144 TGetCoord aXYGetCoord[2] = {
148 TName aXYName[2] = {X,Y};
150 TGetCoord aYZGetCoord[2] = {
154 TName aYZName[2] = {Y,Z};
156 TGetCoord aXZGetCoord[2] = {
160 TName aXZName[2] = {X,Z};
163 TGetCoord aXGetCoord[1] = {
166 TName aXName[1] = {X};
168 TGetCoord aYGetCoord[1] = {
171 TName aYName[1] = {Y};
173 TGetCoord aZGetCoord[1] = {
176 TName aZName[1] = {Z};
180 SMDS_NodeIteratorPtr myNodeIter;
181 const SMDS_MeshNode* myCurrentNode;
182 TGetCoord* myGetCoord;
186 TCoordHelper(const SMDS_NodeIteratorPtr& theNodeIter,
187 TGetCoord* theGetCoord,
189 TUnit* theUnit = aUnit):
190 myNodeIter(theNodeIter),
191 myGetCoord(theGetCoord),
195 virtual ~TCoordHelper(){}
197 return myNodeIter->more() &&
198 (myCurrentNode = myNodeIter->next());
200 const SMDS_MeshNode* GetNode(){
201 return myCurrentNode;
203 MED::TIntVector::value_type GetID(){
204 return myCurrentNode->GetID();
206 MED::TFloatVector::value_type GetCoord(TInt theCoodId){
207 return (myCurrentNode->*myGetCoord[theCoodId])();
209 MED::TStringVector::value_type GetName(TInt theDimId){
210 return myName[theDimId];
212 MED::TStringVector::value_type GetUnit(TInt theDimId){
213 return myUnit[theDimId];
216 typedef boost::shared_ptr<TCoordHelper> TCoordHelperPtr;
218 //-------------------------------------------------------
220 * \brief Structure describing element type
222 //-------------------------------------------------------
225 EEntiteMaillage _entity;
226 EGeometrieElement _geomType;
228 SMDSAbs_ElementType _smdsType;
230 TElemTypeData (EEntiteMaillage entity, EGeometrieElement geom, TInt nb, SMDSAbs_ElementType type)
231 : _entity(entity), _geomType(geom), _nbElems( nb ), _smdsType( type ) {}
235 typedef NCollection_DataMap< Standard_Address, int > TElemFamilyMap;
237 //================================================================================
239 * \brief Fills element to famaly ID map for element type.
240 * Removes all families of anElemType
242 //================================================================================
244 void fillElemFamilyMap( TElemFamilyMap & anElemFamMap,
245 list<DriverMED_FamilyPtr> & aFamilies,
246 const SMDSAbs_ElementType anElemType)
248 anElemFamMap.Clear();
249 //anElemFamMap.clear();
250 list<DriverMED_FamilyPtr>::iterator aFamsIter = aFamilies.begin();
251 while ( aFamsIter != aFamilies.end() )
253 if ((*aFamsIter)->GetType() != anElemType) {
257 int aFamId = (*aFamsIter)->GetId();
258 const set<const SMDS_MeshElement *>& anElems = (*aFamsIter)->GetElements();
259 set<const SMDS_MeshElement *>::const_iterator anElemsIter = anElems.begin();
260 for (; anElemsIter != anElems.end(); anElemsIter++)
262 anElemFamMap.Bind( (Standard_Address)*anElemsIter, aFamId );
263 //anElemFamMap[*anElemsIter] = aFamId;
265 // remove a family from the list
266 aFamilies.erase( aFamsIter++ );
271 //================================================================================
273 * \brief For an element, return family ID found in the map or a default one
275 //================================================================================
277 int getFamilyId( const TElemFamilyMap & anElemFamMap,
278 const SMDS_MeshElement* anElement,
279 const int aDefaultFamilyId)
281 if ( anElemFamMap.IsBound( (Standard_Address) anElement ))
282 return anElemFamMap( (Standard_Address) anElement );
283 // TElemFamilyMap::iterator elem_famNum = anElemFamMap.find( anElement );
284 // if ( elem_famNum != anElemFamMap.end() )
285 // return elem_famNum->second;
286 return aDefaultFamilyId;
290 Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
292 Status aResult = DRS_OK;
293 if (myMesh->hasConstructionEdges() || myMesh->hasConstructionFaces()) {
294 INFOS("SMDS_MESH with hasConstructionEdges() or hasConstructionFaces() do not supports!!!");
298 MESSAGE("Perform - myFile : "<<myFile);
300 // Creating the MED mesh for corresponding SMDS structure
301 //-------------------------------------------------------
303 if (myMeshId != -1) {
304 ostringstream aMeshNameStr;
305 aMeshNameStr<<myMeshId;
306 aMeshName = aMeshNameStr.str();
308 aMeshName = myMeshName;
311 // Mesh dimension definition
312 TInt aSpaceDimension;
313 TCoordHelperPtr aCoordHelperPtr;
315 bool anIsXDimension = false;
316 bool anIsYDimension = false;
317 bool anIsZDimension = false;
319 SMDS_NodeIteratorPtr aNodesIter = myMesh->nodesIterator();
321 if(aNodesIter->more()){
322 const SMDS_MeshNode* aNode = aNodesIter->next();
323 aBounds[0] = aBounds[1] = aNode->X();
324 aBounds[2] = aBounds[3] = aNode->Y();
325 aBounds[4] = aBounds[5] = aNode->Z();
327 while(aNodesIter->more()){
328 const SMDS_MeshNode* aNode = aNodesIter->next();
329 aBounds[0] = min(aBounds[0],aNode->X());
330 aBounds[1] = max(aBounds[1],aNode->X());
332 aBounds[2] = min(aBounds[2],aNode->Y());
333 aBounds[3] = max(aBounds[3],aNode->Y());
335 aBounds[4] = min(aBounds[4],aNode->Z());
336 aBounds[5] = max(aBounds[5],aNode->Z());
340 anIsXDimension = (aBounds[1] - aBounds[0]) + abs(aBounds[1]) + abs(aBounds[0]) > EPS;
341 anIsYDimension = (aBounds[3] - aBounds[2]) + abs(aBounds[3]) + abs(aBounds[2]) > EPS;
342 anIsZDimension = (aBounds[5] - aBounds[4]) + abs(aBounds[5]) + abs(aBounds[4]) > EPS;
343 aSpaceDimension = anIsXDimension + anIsYDimension + anIsZDimension;
346 // PAL16857(SMESH not conform to the MED convention):
347 if ( aSpaceDimension == 2 && anIsZDimension ) // 2D only if mesh is in XOY plane
349 // PAL18941(a saved study with a mesh belong Z is opened and the mesh is belong X)
350 if ( aSpaceDimension == 1 && !anIsXDimension ) {// 1D only if mesh is along OX
351 if ( anIsYDimension ) {
353 anIsXDimension = true;
360 SMDS_NodeIteratorPtr aNodesIter = myMesh->nodesIterator(/*idInceasingOrder=*/true);
361 switch(aSpaceDimension){
363 aCoordHelperPtr.reset(new TCoordHelper(aNodesIter,aXYZGetCoord,aXYZName));
366 if(anIsXDimension && anIsYDimension)
367 aCoordHelperPtr.reset(new TCoordHelper(aNodesIter,aXYGetCoord,aXYName));
368 if(anIsYDimension && anIsZDimension)
369 aCoordHelperPtr.reset(new TCoordHelper(aNodesIter,aYZGetCoord,aYZName));
370 if(anIsXDimension && anIsZDimension)
371 aCoordHelperPtr.reset(new TCoordHelper(aNodesIter,aXZGetCoord,aXZName));
375 aCoordHelperPtr.reset(new TCoordHelper(aNodesIter,aXGetCoord,aXName));
377 aCoordHelperPtr.reset(new TCoordHelper(aNodesIter,aYGetCoord,aYName));
379 aCoordHelperPtr.reset(new TCoordHelper(aNodesIter,aZGetCoord,aZName));
383 TInt aMeshDimension = 0;
384 if ( myMesh->NbEdges() > 0 )
386 if ( myMesh->NbFaces() > 0 )
388 if ( myMesh->NbVolumes() > 0 )
391 PMeshInfo aMeshInfo = myMed->CrMeshInfo(aMeshDimension,aSpaceDimension,aMeshName);
392 MESSAGE("Add - aMeshName : "<<aMeshName<<"; "<<aMeshInfo->GetName());
393 myMed->SetMeshInfo(aMeshInfo);
395 // Storing SMDS groups and sub-meshes as med families
396 //----------------------------------------------------
397 int myNodesDefaultFamilyId = 0;
398 int my0DElementsDefaultFamilyId = 0;
399 int myEdgesDefaultFamilyId = 0;
400 int myFacesDefaultFamilyId = 0;
401 int myVolumesDefaultFamilyId = 0;
402 int nbNodes = myMesh->NbNodes();
403 //int nb0DElements = myMesh->Nb0DElements();
404 int nbEdges = myMesh->NbEdges();
405 int nbFaces = myMesh->NbFaces();
406 int nbVolumes = myMesh->NbVolumes();
407 if (myDoGroupOfNodes && nbNodes)
408 myNodesDefaultFamilyId = REST_NODES_FAMILY;
409 if (myDoGroupOfEdges && nbEdges)
410 myEdgesDefaultFamilyId = REST_EDGES_FAMILY;
411 if (myDoGroupOfFaces && nbFaces)
412 myFacesDefaultFamilyId = REST_FACES_FAMILY;
413 if (myDoGroupOfVolumes && nbVolumes)
414 myVolumesDefaultFamilyId = REST_VOLUMES_FAMILY;
416 MESSAGE("Perform - aFamilyInfo");
417 //cout << " DriverMED_Family::MakeFamilies() " << endl;
418 list<DriverMED_FamilyPtr> aFamilies;
419 if (myAllSubMeshes) {
420 aFamilies = DriverMED_Family::MakeFamilies
421 (myMesh->SubMeshes(), myGroups,
422 myDoGroupOfNodes && nbNodes,
423 myDoGroupOfEdges && nbEdges,
424 myDoGroupOfFaces && nbFaces,
425 myDoGroupOfVolumes && nbVolumes);
427 aFamilies = DriverMED_Family::MakeFamilies
428 (mySubMeshes, myGroups,
429 myDoGroupOfNodes && nbNodes,
430 myDoGroupOfEdges && nbEdges,
431 myDoGroupOfFaces && nbFaces,
432 myDoGroupOfVolumes && nbVolumes);
434 //cout << " myMed->SetFamilyInfo() " << endl;
435 list<DriverMED_FamilyPtr>::iterator aFamsIter;
436 for (aFamsIter = aFamilies.begin(); aFamsIter != aFamilies.end(); aFamsIter++)
438 PFamilyInfo aFamilyInfo = (*aFamsIter)->GetFamilyInfo(myMed,aMeshInfo);
439 myMed->SetFamilyInfo(aFamilyInfo);
442 // Storing SMDS nodes to the MED file for the MED mesh
443 //----------------------------------------------------
444 #ifdef _EDF_NODE_IDS_
445 typedef map<TInt,TInt> TNodeIdMap;
446 TNodeIdMap aNodeIdMap;
448 const EModeSwitch theMode = eFULL_INTERLACE;
449 const ERepere theSystem = eCART;
450 const EBooleen theIsElemNum = eVRAI;
451 const EBooleen theIsElemNames = eFAUX;
452 const EConnectivite theConnMode = eNOD;
454 TInt aNbNodes = myMesh->NbNodes();
455 //cout << " myMed->CrNodeInfo() aNbNodes = " << aNbNodes << endl;
456 PNodeInfo aNodeInfo = myMed->CrNodeInfo(aMeshInfo, aNbNodes,
457 theMode, theSystem, theIsElemNum, theIsElemNames);
459 //cout << " fillElemFamilyMap( SMDSAbs_Node )" << endl;
460 // find family numbers for nodes
461 TElemFamilyMap anElemFamMap;
462 fillElemFamilyMap( anElemFamMap, aFamilies, SMDSAbs_Node );
464 for (TInt iNode = 0; aCoordHelperPtr->Next(); iNode++)
467 TCoordSlice aTCoordSlice = aNodeInfo->GetCoordSlice( iNode );
468 for(TInt iCoord = 0; iCoord < aSpaceDimension; iCoord++){
469 aTCoordSlice[iCoord] = aCoordHelperPtr->GetCoord(iCoord);
472 int aNodeID = aCoordHelperPtr->GetID();
473 aNodeInfo->SetElemNum( iNode, aNodeID );
474 #ifdef _EDF_NODE_IDS_
475 aNodeIdMap[aNodeID] = iNode+1;
478 const SMDS_MeshNode* aNode = aCoordHelperPtr->GetNode();
479 int famNum = getFamilyId( anElemFamMap, aNode, myNodesDefaultFamilyId );
480 aNodeInfo->SetFamNum( iNode, famNum );
482 anElemFamMap.Clear();
484 // coordinate names and units
485 for (TInt iCoord = 0; iCoord < aSpaceDimension; iCoord++) {
486 aNodeInfo->SetCoordName( iCoord, aCoordHelperPtr->GetName(iCoord));
487 aNodeInfo->SetCoordUnit( iCoord, aCoordHelperPtr->GetUnit(iCoord));
490 //cout << " SetNodeInfo(aNodeInfo)" << endl;
491 MESSAGE("Perform - aNodeInfo->GetNbElem() = "<<aNbNodes);
492 myMed->SetNodeInfo(aNodeInfo);
493 aNodeInfo.reset(); // free memory used for arrays
496 // Storing SMDS elements to the MED file for the MED mesh
497 //-------------------------------------------------------
498 // Write one element type at once in order to minimize memory usage (PAL19276)
500 const SMDS_MeshInfo& nbElemInfo = myMesh->GetMeshInfo();
502 // poly elements are not supported by med-2.1
503 bool polyTypesSupported = myMed->CrPolygoneInfo(aMeshInfo,eMAILLE,ePOLYGONE,0,0);
504 TInt nbPolygonNodes = 0, nbPolyhedronNodes = 0, nbPolyhedronFaces = 0;
506 // collect info on all geom types
508 list< TElemTypeData > aTElemTypeDatas;
510 EEntiteMaillage anEntity = eMAILLE;
511 #ifdef _ELEMENTS_BY_DIM_
512 anEntity = eNOEUD_ELEMENT;
514 aTElemTypeDatas.push_back(TElemTypeData(anEntity,
516 nbElemInfo.Nb0DElements(),
518 #ifdef _ELEMENTS_BY_DIM_
521 aTElemTypeDatas.push_back( TElemTypeData(anEntity,
523 nbElemInfo.NbEdges( ORDER_LINEAR ),
525 aTElemTypeDatas.push_back( TElemTypeData(anEntity,
527 nbElemInfo.NbEdges( ORDER_QUADRATIC ),
529 #ifdef _ELEMENTS_BY_DIM_
532 aTElemTypeDatas.push_back( TElemTypeData(anEntity,
534 nbElemInfo.NbTriangles( ORDER_LINEAR ),
536 aTElemTypeDatas.push_back( TElemTypeData(anEntity,
538 nbElemInfo.NbTriangles( ORDER_QUADRATIC ),
540 aTElemTypeDatas.push_back( TElemTypeData(anEntity,
542 nbElemInfo.NbQuadrangles( ORDER_LINEAR ),
544 aTElemTypeDatas.push_back( TElemTypeData(anEntity,
546 nbElemInfo.NbQuadrangles( ORDER_QUADRATIC ) -
547 nbElemInfo.NbBiQuadQuadrangles(),
549 aTElemTypeDatas.push_back( TElemTypeData(anEntity,
551 nbElemInfo.NbBiQuadQuadrangles(),
553 if ( polyTypesSupported ) {
554 aTElemTypeDatas.push_back( TElemTypeData(anEntity,
556 nbElemInfo.NbPolygons(),
558 // we need one more loop on poly elements to count nb of their nodes
559 aTElemTypeDatas.push_back( TElemTypeData(anEntity,
561 nbElemInfo.NbPolygons(),
564 #ifdef _ELEMENTS_BY_DIM_
567 aTElemTypeDatas.push_back( TElemTypeData(anEntity,
569 nbElemInfo.NbTetras( ORDER_LINEAR ),
571 aTElemTypeDatas.push_back( TElemTypeData(anEntity,
573 nbElemInfo.NbTetras( ORDER_QUADRATIC ),
575 aTElemTypeDatas.push_back( TElemTypeData(anEntity,
577 nbElemInfo.NbPyramids( ORDER_LINEAR ),
579 aTElemTypeDatas.push_back( TElemTypeData(anEntity,
581 nbElemInfo.NbPyramids( ORDER_QUADRATIC ),
583 aTElemTypeDatas.push_back( TElemTypeData(anEntity,
585 nbElemInfo.NbPrisms( ORDER_LINEAR ),
587 aTElemTypeDatas.push_back( TElemTypeData(anEntity,
589 nbElemInfo.NbPrisms( ORDER_QUADRATIC ),
591 aTElemTypeDatas.push_back( TElemTypeData(anEntity,
593 nbElemInfo.NbHexas( ORDER_LINEAR ),
595 aTElemTypeDatas.push_back( TElemTypeData(anEntity,
597 nbElemInfo.NbHexas( ORDER_QUADRATIC )-
598 nbElemInfo.NbTriQuadHexas(),
600 aTElemTypeDatas.push_back( TElemTypeData(anEntity,
602 nbElemInfo.NbTriQuadHexas(),
604 aTElemTypeDatas.push_back( TElemTypeData(anEntity,
606 nbElemInfo.NbHexPrisms(),
608 if ( polyTypesSupported ) {
609 aTElemTypeDatas.push_back( TElemTypeData(anEntity,
611 nbElemInfo.NbPolyhedrons(),
613 // we need one more loop on poly elements to count nb of their nodes
614 aTElemTypeDatas.push_back( TElemTypeData(anEntity,
616 nbElemInfo.NbPolyhedrons(),
620 vector< bool > isElemFamMapBuilt( SMDSAbs_NbElementTypes, false );
622 // loop on all geom types of elements
624 list< TElemTypeData >::iterator aElemTypeData = aTElemTypeDatas.begin();
625 for ( ; aElemTypeData != aTElemTypeDatas.end(); ++aElemTypeData )
627 if ( aElemTypeData->_nbElems == 0 )
630 int defaultFamilyId = 0;
631 switch ( aElemTypeData->_smdsType ) {
632 case SMDSAbs_0DElement:
633 defaultFamilyId = my0DElementsDefaultFamilyId;
636 defaultFamilyId = myEdgesDefaultFamilyId;
639 defaultFamilyId = myFacesDefaultFamilyId;
642 defaultFamilyId = myVolumesDefaultFamilyId;
648 // iterator on elements of a current type
649 SMDS_ElemIteratorPtr elemIterator = myMesh->elementsIterator( aElemTypeData->_smdsType );
650 if ( !elemIterator->more()) continue;
655 if ( aElemTypeData->_geomType == ePOLYGONE )
657 if ( nbPolygonNodes == 0 ) {
659 while ( const SMDS_MeshElement* anElem = elemIterator->next() ) {
660 if ( anElem->IsPoly() ) {
661 nbPolygonNodes += anElem->NbNodes();
662 if ( ++iElem == aElemTypeData->_nbElems )
669 PPolygoneInfo aPolygoneInfo = myMed->CrPolygoneInfo(aMeshInfo,
670 aElemTypeData->_entity,
671 aElemTypeData->_geomType,
672 aElemTypeData->_nbElems,
674 theConnMode, theIsElemNum,
676 TElemNum & index = *(aPolygoneInfo->myIndex.get());
679 while ( const SMDS_MeshElement* anElem = elemIterator->next() )
681 if ( !anElem->IsPoly() )
685 TInt aNbNodes = anElem->NbNodes();
686 index[ iElem+1 ] = index[ iElem ] + aNbNodes;
689 TConnSlice aTConnSlice = aPolygoneInfo->GetConnSlice( iElem );
690 for(TInt iNode = 0; iNode < aNbNodes; iNode++) {
691 const SMDS_MeshElement* aNode = anElem->GetNode( iNode );
692 #ifdef _EDF_NODE_IDS_
693 aTConnSlice[ iNode ] = aNodeIdMap[aNode->GetID()];
695 aTConnSlice[ iNode ] = aNode->GetID();
699 aPolygoneInfo->SetElemNum( iElem, anElem->GetID() );
702 int famNum = getFamilyId( anElemFamMap, anElem, defaultFamilyId );
703 aPolygoneInfo->SetFamNum( iElem, famNum );
705 if ( ++iElem == aPolygoneInfo->GetNbElem() )
708 myMed->SetPolygoneInfo(aPolygoneInfo);
715 else if (aElemTypeData->_geomType == ePOLYEDRE )
717 if ( nbPolyhedronNodes == 0 ) {
719 while ( const SMDS_MeshElement* anElem = elemIterator->next() ) {
720 const SMDS_VtkVolume *aPolyedre = dynamic_cast<const SMDS_VtkVolume*>(anElem);
721 if ( aPolyedre && aPolyedre->IsPoly()) {
722 nbPolyhedronNodes += aPolyedre->NbNodes();
723 nbPolyhedronFaces += aPolyedre->NbFaces();
724 if ( ++iElem == aElemTypeData->_nbElems )
731 PPolyedreInfo aPolyhInfo = myMed->CrPolyedreInfo(aMeshInfo,
732 aElemTypeData->_entity,
733 aElemTypeData->_geomType,
734 aElemTypeData->_nbElems,
740 TElemNum & index = *(aPolyhInfo->myIndex.get());
741 TElemNum & faces = *(aPolyhInfo->myFaces.get());
742 TElemNum & conn = *(aPolyhInfo->myConn.get());
746 TInt iFace = 0, iNode = 0;
747 while ( const SMDS_MeshElement* anElem = elemIterator->next() )
749 const SMDS_VtkVolume *aPolyedre = dynamic_cast<const SMDS_VtkVolume*>(anElem);
752 if ( !aPolyedre->IsPoly() )
755 TInt aNbFaces = aPolyedre->NbFaces();
756 index[ iElem+1 ] = index[ iElem ] + aNbFaces;
759 for (TInt f = 1; f <= aNbFaces; ++f, ++iFace ) {
760 int aNbFaceNodes = aPolyedre->NbFaceNodes( f );
761 faces[ iFace+1 ] = faces[ iFace ] + aNbFaceNodes;
764 SMDS_ElemIteratorPtr nodeIt = anElem->nodesIterator();
765 while ( nodeIt->more() ) {
766 const SMDS_MeshElement* aNode = nodeIt->next();
767 #ifdef _EDF_NODE_IDS_
768 conn[ iNode ] = aNodeIdMap[aNode->GetID()];
770 conn[ iNode ] = aNode->GetID();
775 aPolyhInfo->SetElemNum( iElem, anElem->GetID() );
778 int famNum = getFamilyId( anElemFamMap, anElem, defaultFamilyId );
779 aPolyhInfo->SetFamNum( iElem, famNum );
781 if ( ++iElem == aPolyhInfo->GetNbElem() )
784 myMed->SetPolyedreInfo(aPolyhInfo);
786 } // if (aElemTypeData->_geomType == ePOLYEDRE )
790 // Treat standard types
791 // ---------------------
793 // allocate data arrays
794 PCellInfo aCellInfo = myMed->CrCellInfo( aMeshInfo,
795 aElemTypeData->_entity,
796 aElemTypeData->_geomType,
797 aElemTypeData->_nbElems,
801 // build map of family numbers for this type
802 if ( !isElemFamMapBuilt[ aElemTypeData->_smdsType ])
804 //cout << " fillElemFamilyMap()" << endl;
805 fillElemFamilyMap( anElemFamMap, aFamilies, aElemTypeData->_smdsType );
806 isElemFamMapBuilt[ aElemTypeData->_smdsType ] = true;
809 TInt aNbNodes = MED::GetNbNodes(aElemTypeData->_geomType);
810 while ( const SMDS_MeshElement* anElem = elemIterator->next() )
812 if ( anElem->NbNodes() != aNbNodes || anElem->IsPoly() )
813 continue; // other geometry
816 TConnSlice aTConnSlice = aCellInfo->GetConnSlice( iElem );
817 for (TInt iNode = 0; iNode < aNbNodes; iNode++) {
818 const SMDS_MeshElement* aNode = anElem->GetNode( iNode );
819 #ifdef _EDF_NODE_IDS_
820 aTConnSlice[ iNode ] = aNodeIdMap[aNode->GetID()];
822 aTConnSlice[ iNode ] = aNode->GetID();
826 aCellInfo->SetElemNum( iElem, anElem->GetID() );
829 int famNum = getFamilyId( anElemFamMap, anElem, defaultFamilyId );
830 aCellInfo->SetFamNum( iElem, famNum );
832 if ( ++iElem == aCellInfo->GetNbElem() )
835 // store data in a file
836 myMed->SetCellInfo(aCellInfo);
839 } // loop on geom types
843 catch(const std::exception& exc) {
844 INFOS("The following exception was caught:\n\t"<<exc.what());
848 INFOS("Unknown exception was caught !!!");