1 // SMESH DriverMED : driver to read and write 'med' files
3 // Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : DriverMED_W_SMESHDS_Mesh.cxx
29 #include "DriverMED_W_SMESHDS_Mesh.h"
30 #include "DriverMED_W_SMDS_Mesh.h"
31 #include "DriverMED_Family.h"
33 #include "SMESHDS_Mesh.hxx"
34 #include "SMDS_MeshElement.hxx"
35 #include "SMDS_MeshNode.hxx"
36 #include "SMDS_PolyhedralVolumeOfNodes.hxx"
38 #include "utilities.h"
40 #include "MED_Utilities.hxx"
42 #define _EDF_NODE_IDS_
43 //#define _ELEMENTS_BY_DIM_
49 DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh():
50 myAllSubMeshes (false),
51 myDoGroupOfNodes (false),
52 myDoGroupOfEdges (false),
53 myDoGroupOfFaces (false),
54 myDoGroupOfVolumes (false)
57 void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName,
60 myMed = CrWrapper(theFileName,theId);
61 Driver_SMESHDS_Mesh::SetFile(theFileName);
64 void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName)
66 return SetFile(theFileName,MED::eV2_2);
69 void DriverMED_W_SMESHDS_Mesh::SetMeshName(const std::string& theMeshName)
71 myMeshName = theMeshName;
74 void DriverMED_W_SMESHDS_Mesh::AddGroup(SMESHDS_GroupBase* theGroup)
76 myGroups.push_back(theGroup);
79 void DriverMED_W_SMESHDS_Mesh::AddAllSubMeshes()
81 myAllSubMeshes = true;
84 void DriverMED_W_SMESHDS_Mesh::AddSubMesh(SMESHDS_SubMesh* theSubMesh, int theID)
86 mySubMeshes[theID] = theSubMesh;
89 void DriverMED_W_SMESHDS_Mesh::AddGroupOfNodes()
91 myDoGroupOfNodes = true;
94 void DriverMED_W_SMESHDS_Mesh::AddGroupOfEdges()
96 myDoGroupOfEdges = true;
99 void DriverMED_W_SMESHDS_Mesh::AddGroupOfFaces()
101 myDoGroupOfFaces = true;
104 void DriverMED_W_SMESHDS_Mesh::AddGroupOfVolumes()
106 myDoGroupOfVolumes = true;
110 typedef double (SMDS_MeshNode::* TGetCoord)() const;
111 typedef const char* TName;
112 typedef const char* TUnit;
114 TUnit aUnit[3] = {"m","m","m"};
116 TGetCoord aXYZGetCoord[3] = {
121 TName aXYZName[3] = {"x","y","z"};
124 TGetCoord aXYGetCoord[2] = {
128 TName aXYName[2] = {"x","y"};
130 TGetCoord aYZGetCoord[2] = {
134 TName aYZName[2] = {"y","z"};
136 TGetCoord aXZGetCoord[2] = {
140 TName aXZName[2] = {"x","z"};
143 TGetCoord aXGetCoord[1] = {
146 TName aXName[1] = {"x"};
148 TGetCoord aYGetCoord[1] = {
151 TName aYName[1] = {"y"};
153 TGetCoord aZGetCoord[1] = {
156 TName aZName[1] = {"z"};
160 SMDS_NodeIteratorPtr myNodeIter;
161 const SMDS_MeshNode* myCurrentNode;
162 TGetCoord* myGetCoord;
166 TCoordHelper(const SMDS_NodeIteratorPtr& theNodeIter,
167 TGetCoord* theGetCoord,
169 TUnit* theUnit = aUnit):
170 myNodeIter(theNodeIter),
171 myGetCoord(theGetCoord),
175 virtual ~TCoordHelper(){}
177 return myNodeIter->more() &&
178 (myCurrentNode = myNodeIter->next());
180 const SMDS_MeshNode* GetNode(){
181 return myCurrentNode;
183 MED::TIntVector::value_type GetID(){
184 return myCurrentNode->GetID();
186 MED::TFloatVector::value_type GetCoord(TInt theCoodId){
187 return (myCurrentNode->*myGetCoord[theCoodId])();
189 MED::TStringVector::value_type GetName(TInt theDimId){
190 return myName[theDimId];
192 MED::TStringVector::value_type GetUnit(TInt theDimId){
193 return myUnit[theDimId];
196 typedef boost::shared_ptr<TCoordHelper> TCoordHelperPtr;
201 Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
203 Status aResult = DRS_OK;
204 if (myMesh->hasConstructionEdges() || myMesh->hasConstructionFaces()) {
205 INFOS("SMDS_MESH with hasConstructionEdges() or hasConstructionFaces() do not supports!!!");
209 MESSAGE("Perform - myFile : "<<myFile);
211 // Creating the MED mesh for corresponding SMDS structure
212 //-------------------------------------------------------
214 if (myMeshId != -1) {
215 ostringstream aMeshNameStr;
216 aMeshNameStr<<myMeshId;
217 aMeshName = aMeshNameStr.str();
219 aMeshName = myMeshName;
222 // Mesh dimension definition
224 TCoordHelperPtr aCoordHelperPtr;
226 bool anIsXDimension = false;
227 bool anIsYDimension = false;
228 bool anIsZDimension = false;
230 SMDS_NodeIteratorPtr aNodesIter = myMesh->nodesIterator();
232 if(aNodesIter->more()){
233 const SMDS_MeshNode* aNode = aNodesIter->next();
234 aBounds[0] = aBounds[1] = aNode->X();
235 aBounds[2] = aBounds[3] = aNode->Y();
236 aBounds[4] = aBounds[5] = aNode->Z();
238 while(aNodesIter->more()){
239 const SMDS_MeshNode* aNode = aNodesIter->next();
240 aBounds[0] = min(aBounds[0],aNode->X());
241 aBounds[1] = max(aBounds[1],aNode->X());
243 aBounds[2] = min(aBounds[2],aNode->Y());
244 aBounds[3] = max(aBounds[3],aNode->Y());
246 aBounds[4] = min(aBounds[4],aNode->Z());
247 aBounds[5] = max(aBounds[5],aNode->Z());
251 anIsXDimension = (aBounds[1] - aBounds[0]) + abs(aBounds[1]) + abs(aBounds[0]) > EPS;
252 anIsYDimension = (aBounds[3] - aBounds[2]) + abs(aBounds[3]) + abs(aBounds[2]) > EPS;
253 anIsZDimension = (aBounds[5] - aBounds[4]) + abs(aBounds[5]) + abs(aBounds[4]) > EPS;
254 aMeshDimension = anIsXDimension + anIsYDimension + anIsZDimension;
259 SMDS_NodeIteratorPtr aNodesIter = myMesh->nodesIterator();
260 switch(aMeshDimension){
262 aCoordHelperPtr.reset(new TCoordHelper(aNodesIter,aXYZGetCoord,aXYZName));
265 if(anIsXDimension && anIsYDimension)
266 aCoordHelperPtr.reset(new TCoordHelper(aNodesIter,aXYGetCoord,aXYName));
267 if(anIsYDimension && anIsZDimension)
268 aCoordHelperPtr.reset(new TCoordHelper(aNodesIter,aYZGetCoord,aYZName));
269 if(anIsXDimension && anIsZDimension)
270 aCoordHelperPtr.reset(new TCoordHelper(aNodesIter,aXZGetCoord,aXZName));
274 aCoordHelperPtr.reset(new TCoordHelper(aNodesIter,aXGetCoord,aXName));
276 aCoordHelperPtr.reset(new TCoordHelper(aNodesIter,aYGetCoord,aYName));
278 aCoordHelperPtr.reset(new TCoordHelper(aNodesIter,aZGetCoord,aZName));
284 PMeshInfo aMeshInfo = myMed->CrMeshInfo(aMeshDimension,aMeshName);
285 MESSAGE("Add - aMeshName : "<<aMeshName<<"; "<<aMeshInfo->GetName());
286 myMed->SetMeshInfo(aMeshInfo);
288 // Storing SMDS groups and sub-meshes
289 //-----------------------------------
290 int myNodesDefaultFamilyId = 0;
291 int myEdgesDefaultFamilyId = 0;
292 int myFacesDefaultFamilyId = 0;
293 int myVolumesDefaultFamilyId = 0;
294 if (myDoGroupOfNodes)
295 myNodesDefaultFamilyId = REST_NODES_FAMILY;
296 if (myDoGroupOfEdges)
297 myEdgesDefaultFamilyId = REST_EDGES_FAMILY;
298 if (myDoGroupOfFaces)
299 myFacesDefaultFamilyId = REST_FACES_FAMILY;
300 if (myDoGroupOfVolumes)
301 myVolumesDefaultFamilyId = REST_VOLUMES_FAMILY;
303 MESSAGE("Perform - aFamilyInfo");
304 map<const SMDS_MeshElement *, int> anElemFamMap;
305 list<DriverMED_FamilyPtr> aFamilies;
306 if (myAllSubMeshes) {
307 aFamilies = DriverMED_Family::MakeFamilies
308 (myMesh->SubMeshes(), myGroups,
309 myDoGroupOfNodes, myDoGroupOfEdges, myDoGroupOfFaces, myDoGroupOfVolumes);
311 aFamilies = DriverMED_Family::MakeFamilies
312 (mySubMeshes, myGroups,
313 myDoGroupOfNodes, myDoGroupOfEdges, myDoGroupOfFaces, myDoGroupOfVolumes);
315 list<DriverMED_FamilyPtr>::iterator aFamsIter = aFamilies.begin();
317 for (; aFamsIter != aFamilies.end(); aFamsIter++)
319 PFamilyInfo aFamilyInfo = (*aFamsIter)->GetFamilyInfo(myMed,aMeshInfo);
320 myMed->SetFamilyInfo(aFamilyInfo);
321 int aFamId = (*aFamsIter)->GetId();
323 const set<const SMDS_MeshElement *>& anElems = (*aFamsIter)->GetElements();
324 set<const SMDS_MeshElement *>::iterator anElemsIter = anElems.begin();
325 for (; anElemsIter != anElems.end(); anElemsIter++)
327 anElemFamMap[*anElemsIter] = aFamId;
329 // delete (*aFamsIter);
332 // Storing SMDS nodes to the MED file for the MED mesh
333 //----------------------------------------------------
334 #ifdef _EDF_NODE_IDS_
335 typedef map<TInt,TInt> TNodeIdMap;
336 TNodeIdMap aNodeIdMap;
338 TInt aNbElems = myMesh->NbNodes();
339 MED::TIntVector anElemNums(aNbElems);
340 MED::TIntVector aFamilyNums(aNbElems);
341 MED::TFloatVector aCoordinates(aNbElems*aMeshDimension);
342 for(TInt iNode = 0, aStartId = 0; aCoordHelperPtr->Next(); iNode++, aStartId += aMeshDimension){
343 for(TInt iCoord = 0; iCoord < aMeshDimension; iCoord++){
344 aCoordinates[aStartId+iCoord] = aCoordHelperPtr->GetCoord(iCoord);
346 int aNodeID = aCoordHelperPtr->GetID();
347 anElemNums[iNode] = aNodeID;
348 #ifdef _EDF_NODE_IDS_
349 aNodeIdMap[aNodeID] = iNode+1;
351 const SMDS_MeshNode* aNode = aCoordHelperPtr->GetNode();
352 if (anElemFamMap.find(aNode) != anElemFamMap.end())
353 aFamilyNums[iNode] = anElemFamMap[aNode];
355 aFamilyNums[iNode] = myNodesDefaultFamilyId;
358 MED::TStringVector aCoordNames(aMeshDimension);
359 MED::TStringVector aCoordUnits(aMeshDimension);
360 for(TInt iCoord = 0; iCoord < aMeshDimension; iCoord++){
361 aCoordNames[iCoord] = aCoordHelperPtr->GetName(iCoord);
362 aCoordUnits[iCoord] = aCoordHelperPtr->GetUnit(iCoord);
365 const ERepere SMDS_COORDINATE_SYSTEM = eCART;
367 PNodeInfo aNodeInfo = myMed->CrNodeInfo(aMeshInfo,
368 SMDS_COORDINATE_SYSTEM,
374 MESSAGE("Perform - aNodeInfo->GetNbElem() = "<<aNbElems);
375 myMed->SetNodeInfo(aNodeInfo);
378 // Storing others SMDS elements to the MED file for the MED mesh
379 //--------------------------------------------------------------
380 EEntiteMaillage SMDS_MED_ENTITY = eMAILLE;
381 const EConnectivite SMDS_MED_CONNECTIVITY = eNOD;
383 // Storing SMDS Edges
384 if(TInt aNbElems = myMesh->NbEdges()){
385 #ifdef _ELEMENTS_BY_DIM_
386 SMDS_MED_ENTITY = eARETE;
388 SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator();
389 TInt aNbConnectivity = MED::GetNbNodes(eSEG2);
390 MED::TIntVector anElemNums(aNbElems);
391 MED::TIntVector aFamilyNums(aNbElems);
392 MED::TIntVector aConnectivity(aNbElems*aNbConnectivity);
394 for(TInt iElem = 0, iConn = 0; anIter->more(); iElem++, iConn+=aNbConnectivity){
395 const SMDS_MeshEdge* anElem = anIter->next();
396 SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
397 for(TInt iNode = 0; iNode < aNbConnectivity && aNodesIter->more(); iNode++){
398 const SMDS_MeshElement* aNode = aNodesIter->next();
399 #ifdef _EDF_NODE_IDS_
400 aConnectivity[iConn+iNode] = aNodeIdMap[aNode->GetID()];
402 aConnectivity[iConn+iNode] = aNode->GetID();
405 anElemNums[iElem] = anElem->GetID();
407 if (anElemFamMap.find(anElem) != anElemFamMap.end())
408 aFamilyNums[iElem] = anElemFamMap[anElem];
410 aFamilyNums[iElem] = myEdgesDefaultFamilyId;
413 PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
416 SMDS_MED_CONNECTIVITY,
420 myMed->SetCellInfo(aCellInfo);
423 // Storing SMDS Faces
424 if(TInt aNbElems = myMesh->NbFaces()){
425 SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
426 #ifdef _ELEMENTS_BY_DIM_
427 SMDS_MED_ENTITY = eFACE;
429 TInt aNbTriaConn = MED::GetNbNodes(eTRIA3);
430 MED::TIntVector anTriaElemNums;
431 anTriaElemNums.reserve(aNbElems);
432 MED::TIntVector aTriaFamilyNums;
433 aTriaFamilyNums.reserve(aNbElems);
434 MED::TIntVector aTriaConn;
435 aTriaConn.reserve(aNbElems*aNbTriaConn);
437 TInt aNbQuadConn = MED::GetNbNodes(eQUAD4);
438 MED::TIntVector aQuadElemNums;
439 aQuadElemNums.reserve(aNbElems);
440 MED::TIntVector aQuadFamilyNums;
441 aQuadFamilyNums.reserve(aNbElems);
442 MED::TIntVector aQuadConn;
443 aQuadConn.reserve(aNbElems*aNbQuadConn);
445 MED::TIntVector aPolygoneElemNums;
446 aPolygoneElemNums.reserve(aNbElems);
447 MED::TIntVector aPolygoneInds;
448 aPolygoneInds.reserve(aNbElems + 1);
449 aPolygoneInds.push_back(1); // reference on the first element in the connectivities
450 MED::TIntVector aPolygoneFamilyNums;
451 aPolygoneFamilyNums.reserve(aNbElems);
452 MED::TIntVector aPolygoneConn;
453 aPolygoneConn.reserve(aNbElems*aNbQuadConn);
455 for(TInt iElem = 0; iElem < aNbElems && anIter->more(); iElem++){
456 const SMDS_MeshFace* anElem = anIter->next();
457 TInt aNbNodes = anElem->NbNodes();
458 SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
459 TInt aNbConnectivity;
460 MED::TIntVector* anElemNums;
461 MED::TIntVector* aFamilyNums;
462 MED::TIntVector* aConnectivity;
463 if (anElem->IsPoly()) {
464 aNbConnectivity = aNbNodes;
465 anElemNums = &aPolygoneElemNums;
466 aFamilyNums = &aPolygoneFamilyNums;
467 aConnectivity = &aPolygoneConn;
471 aNbConnectivity = aNbTriaConn;
472 anElemNums = &anTriaElemNums;
473 aFamilyNums = &aTriaFamilyNums;
474 aConnectivity = &aTriaConn;
477 aNbConnectivity = aNbQuadConn;
478 anElemNums = &aQuadElemNums;
479 aFamilyNums = &aQuadFamilyNums;
480 aConnectivity = &aQuadConn;
486 MED::TIntVector aVector(aNbNodes);
487 for(TInt iNode = 0; aNodesIter->more(); iNode++){
488 const SMDS_MeshElement* aNode = aNodesIter->next();
489 #ifdef _EDF_NODE_IDS_
490 aVector[iNode] = aNodeIdMap[aNode->GetID()];
492 aVector[iNode] = aNode->GetID();
496 TInt aSize = aConnectivity->size();
497 aConnectivity->resize(aSize+aNbConnectivity);
498 // There is some differences between SMDS and MED in cells mapping
501 (*aConnectivity)[aSize+0] = aVector[0];
502 (*aConnectivity)[aSize+1] = aVector[1];
503 (*aConnectivity)[aSize+2] = aVector[3];
504 (*aConnectivity)[aSize+3] = aVector[2];
506 for(TInt iNode = 0; iNode < aNbNodes; iNode++)
507 (*aConnectivity)[aSize+iNode] = aVector[iNode];
510 if (anElem->IsPoly()) {
511 // fill indices for polygonal element
512 TInt aPrevPos = aPolygoneInds.back();
513 aPolygoneInds.push_back(aPrevPos + aNbNodes);
516 anElemNums->push_back(anElem->GetID());
518 if (anElemFamMap.find(anElem) != anElemFamMap.end())
519 aFamilyNums->push_back(anElemFamMap[anElem]);
521 aFamilyNums->push_back(myFacesDefaultFamilyId);
523 if(TInt aNbElems = anTriaElemNums.size()){
524 PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
527 SMDS_MED_CONNECTIVITY,
531 MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eTRIA3<<"; aNbElems = "<<aNbElems);
532 myMed->SetCellInfo(aCellInfo);
534 if(TInt aNbElems = aQuadElemNums.size()){
535 PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
538 SMDS_MED_CONNECTIVITY,
542 MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eQUAD4<<"; aNbElems = "<<aNbElems);
543 myMed->SetCellInfo(aCellInfo);
545 if(TInt aNbElems = aPolygoneElemNums.size()){
546 // add one element in connectivities,
547 // referenced by the last element in indices
548 aPolygoneConn.push_back(0);
550 PPolygoneInfo aCellInfo = myMed->CrPolygoneInfo(aMeshInfo,
553 SMDS_MED_CONNECTIVITY,
558 MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePOLYGONE<<"; aNbElems = "<<aNbElems);
559 myMed->SetPolygoneInfo(aCellInfo);
563 // Storing SMDS Volumes
564 if(TInt aNbElems = myMesh->NbVolumes()){
565 SMDS_VolumeIteratorPtr anIter = myMesh->volumesIterator();
566 #ifdef _ELEMENTS_BY_DIM_
567 SMDS_MED_ENTITY = eMAILLE;
569 TInt aNbTetraConn = MED::GetNbNodes(eTETRA4);
570 MED::TIntVector anTetraElemNums;
571 anTetraElemNums.reserve(aNbElems);
572 MED::TIntVector aTetraFamilyNums;
573 aTetraFamilyNums.reserve(aNbElems);
574 MED::TIntVector aTetraConn;
575 aTetraConn.reserve(aNbElems*aNbTetraConn);
577 TInt aNbPyraConn = MED::GetNbNodes(ePYRA5);
578 MED::TIntVector anPyraElemNums;
579 anPyraElemNums.reserve(aNbElems);
580 MED::TIntVector aPyraFamilyNums;
581 aPyraFamilyNums.reserve(aNbElems);
582 MED::TIntVector aPyraConn;
583 aPyraConn.reserve(aNbElems*aNbPyraConn);
585 TInt aNbPentaConn = MED::GetNbNodes(ePENTA6);
586 MED::TIntVector anPentaElemNums;
587 anPentaElemNums.reserve(aNbElems);
588 MED::TIntVector aPentaFamilyNums;
589 aPentaFamilyNums.reserve(aNbElems);
590 MED::TIntVector aPentaConn;
591 aPentaConn.reserve(aNbElems*aNbPentaConn);
593 TInt aNbHexaConn = MED::GetNbNodes(eHEXA8);
594 MED::TIntVector aHexaElemNums;
595 aHexaElemNums.reserve(aNbElems);
596 MED::TIntVector aHexaFamilyNums;
597 aHexaFamilyNums.reserve(aNbElems);
598 MED::TIntVector aHexaConn;
599 aHexaConn.reserve(aNbElems*aNbHexaConn);
601 MED::TIntVector aPolyedreElemNums;
602 aPolyedreElemNums.reserve(aNbElems);
603 MED::TIntVector aPolyedreInds;
604 aPolyedreInds.reserve(aNbElems + 1);
605 aPolyedreInds.push_back(1); // reference on the first element in the faces
606 MED::TIntVector aPolyedreFaces;
607 aPolyedreFaces.reserve(aNbElems + 1);
608 aPolyedreFaces.push_back(1); // reference on the first element in the connectivities
609 MED::TIntVector aPolyedreFamilyNums;
610 aPolyedreFamilyNums.reserve(aNbElems);
611 MED::TIntVector aPolyedreConn;
612 aPolyedreConn.reserve(aNbElems*aNbHexaConn);
614 for(TInt iElem = 0; iElem < aNbElems && anIter->more(); iElem++){
615 const SMDS_MeshVolume* anElem = anIter->next();
617 MED::TIntVector* anElemNums;
618 MED::TIntVector* aFamilyNums;
620 if (anElem->IsPoly()) {
621 const SMDS_PolyhedralVolumeOfNodes* aPolyedre =
622 (const SMDS_PolyhedralVolumeOfNodes*) anElem;
624 MESSAGE("Warning: bad volumic element");
628 anElemNums = &aPolyedreElemNums;
629 aFamilyNums = &aPolyedreFamilyNums;
631 TInt aNodeId, aNbFaces = aPolyedre->NbFaces();
632 for (int iface = 1; iface <= aNbFaces; iface++) {
633 int aNbFaceNodes = aPolyedre->NbFaceNodes(iface);
634 for (int inode = 1; inode <= aNbFaceNodes; inode++) {
635 aNodeId = aPolyedre->GetFaceNode(iface, inode)->GetID();
636 #ifdef _EDF_NODE_IDS_
637 aPolyedreConn.push_back(aNodeIdMap[aNodeId]);
639 aPolyedreConn.push_back(aNodeId);
642 TInt aPrevPos = aPolyedreFaces.back();
643 aPolyedreFaces.push_back(aPrevPos + aNbFaceNodes);
645 TInt aPrevPos = aPolyedreInds.back();
646 aPolyedreInds.push_back(aPrevPos + aNbFaces);
649 TInt aNbNodes = anElem->NbNodes();
650 SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
651 TInt aNbConnectivity;
652 MED::TIntVector* aConnectivity;
655 aNbConnectivity = aNbTetraConn;
656 anElemNums = &anTetraElemNums;
657 aFamilyNums = &aTetraFamilyNums;
658 aConnectivity = &aTetraConn;
661 aNbConnectivity = aNbPyraConn;
662 anElemNums = &anPyraElemNums;
663 aFamilyNums = &aPyraFamilyNums;
664 aConnectivity = &aPyraConn;
667 aNbConnectivity = aNbPentaConn;
668 anElemNums = &anPentaElemNums;
669 aFamilyNums = &aPentaFamilyNums;
670 aConnectivity = &aPentaConn;
673 aNbConnectivity = aNbHexaConn;
674 anElemNums = &aHexaElemNums;
675 aFamilyNums = &aHexaFamilyNums;
676 aConnectivity = &aHexaConn;
679 TInt aSize = aConnectivity->size();
680 aConnectivity->resize(aSize + aNbConnectivity);
682 MED::TIntVector aVector(aNbNodes);
683 for(TInt iNode = 0; aNodesIter->more(); iNode++){
684 const SMDS_MeshElement* aNode = aNodesIter->next();
685 #ifdef _EDF_NODE_IDS_
686 aVector[iNode] = aNodeIdMap[aNode->GetID()];
688 aVector[iNode] = aNode->GetID();
691 // There is some difference between SMDS and MED in cells mapping
694 (*aConnectivity)[aSize+0] = aVector[0];
695 (*aConnectivity)[aSize+1] = aVector[3];
696 (*aConnectivity)[aSize+2] = aVector[2];
697 (*aConnectivity)[aSize+3] = aVector[1];
698 (*aConnectivity)[aSize+4] = aVector[4];
700 for(TInt iNode = 0; iNode < aNbNodes; iNode++)
701 (*aConnectivity)[aSize+iNode] = aVector[iNode];
705 anElemNums->push_back(anElem->GetID());
707 if (anElemFamMap.find(anElem) != anElemFamMap.end())
708 aFamilyNums->push_back(anElemFamMap[anElem]);
710 aFamilyNums->push_back(myVolumesDefaultFamilyId);
713 if(TInt aNbElems = anTetraElemNums.size()){
714 PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
717 SMDS_MED_CONNECTIVITY,
721 MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eTETRA4<<"; aNbElems = "<<aNbElems);
722 myMed->SetCellInfo(aCellInfo);
724 if(TInt aNbElems = anPyraElemNums.size()){
725 PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
728 SMDS_MED_CONNECTIVITY,
732 MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePYRA5<<"; aNbElems = "<<aNbElems);
733 myMed->SetCellInfo(aCellInfo);
735 if(TInt aNbElems = anPentaElemNums.size()){
736 PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
739 SMDS_MED_CONNECTIVITY,
743 MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePENTA6<<"; aNbElems = "<<aNbElems);
744 myMed->SetCellInfo(aCellInfo);
746 if(TInt aNbElems = aHexaElemNums.size()){
747 PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
750 SMDS_MED_CONNECTIVITY,
754 MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eHEXA8<<"; aNbElems = "<<aNbElems);
755 myMed->SetCellInfo(aCellInfo);
757 if(TInt aNbElems = aPolyedreElemNums.size()){
758 // add one element in connectivities,
759 // referenced by the last element in faces
760 aPolyedreConn.push_back(0);
762 PPolyedreInfo aCellInfo = myMed->CrPolyedreInfo(aMeshInfo,
765 SMDS_MED_CONNECTIVITY,
771 MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePOLYEDRE<<"; aNbElems = "<<aNbElems);
772 myMed->SetPolyedreInfo(aCellInfo);
775 }catch(const std::exception& exc){
776 INFOS("Follow exception was cought:\n\t"<<exc.what());
778 INFOS("Unknown exception was cought !!!");