1 // Copyright (C) 2007-2011 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 // VISU OBJECT : interactive object for VISU entities implementation
24 // File : VISU_CorbaMedConvertor.cxx
25 // Author : Alexey PETROV
29 #include "VISU_CorbaMedConvertor.hxx"
30 #include "VISU_ConvertorUtils.hxx"
32 #include <vtkCellType.h>
34 #include <boost/tuple/tuple.hpp>
36 #include "ReceiverFactory.hxx"
37 #include "MED_SliceArray.hxx"
39 #include "utilities.h"
41 #define USER_INTERLACE MED_FULL_INTERLACE
44 static int MYDEBUG = 0;
46 static int MYDEBUG = 0;
51 CreateMEDConvertor(SALOMEDS::SObject_ptr theMedSObject)
53 return new VISU_MEDConvertor(theMedSObject);
57 CreateMEDFieldConvertor(SALOME_MED::FIELD_ptr theField)
59 return new VISU_MEDFieldConvertor(theField);
65 const int MED_NBR_GEOMETRIE_MAILLE = 17;
67 SALOME_MED::medGeometryElement
68 CELLGEOM[MED_NBR_GEOMETRIE_MAILLE] = {
69 SALOME_MED::MED_POINT1,
72 SALOME_MED::MED_TRIA3,
73 SALOME_MED::MED_QUAD4,
74 SALOME_MED::MED_TRIA6,
75 SALOME_MED::MED_QUAD8,
76 SALOME_MED::MED_TETRA4,
77 SALOME_MED::MED_PYRA5,
78 SALOME_MED::MED_PENTA6,
79 SALOME_MED::MED_HEXA8,
80 SALOME_MED::MED_TETRA10,
81 SALOME_MED::MED_PYRA13,
82 SALOME_MED::MED_PENTA15,
83 SALOME_MED::MED_HEXA20,
84 SALOME_MED::MED_POLYGON,
85 SALOME_MED::MED_POLYHEDRA
88 const int MED_NBR_GEOMETRIE_FACE = 5;
90 SALOME_MED::medGeometryElement
91 FACEGEOM[MED_NBR_GEOMETRIE_FACE] = {
92 SALOME_MED::MED_TRIA3,
93 SALOME_MED::MED_QUAD4,
94 SALOME_MED::MED_TRIA6,
95 SALOME_MED::MED_QUAD8,
96 SALOME_MED::MED_POLYGON
99 const int MED_NBR_GEOMETRIE_ARETE = 2;
101 SALOME_MED::medGeometryElement
102 EDGEGEOM[MED_NBR_GEOMETRIE_ARETE] = {
103 SALOME_MED::MED_SEG2,
107 const int MED_NBR_GEOMETRIE_NODE = 1;
109 SALOME_MED::medGeometryElement
110 NODEGEOM[MED_NBR_GEOMETRIE_NODE] = {
111 SALOME_MED::MED_POINT1,
115 //---------------------------------------------------------------
117 GetEntity2Geom(const VISU::TEntity& theEntity,
118 SALOME_MED::medGeometryElement*& theVector)
121 case VISU::CELL_ENTITY:
122 theVector = CELLGEOM;
123 return MED_NBR_GEOMETRIE_MAILLE;
124 case VISU::FACE_ENTITY:
125 theVector = FACEGEOM;
126 return MED_NBR_GEOMETRIE_FACE;
127 case VISU::EDGE_ENTITY:
128 theVector = EDGEGEOM;
129 return MED_NBR_GEOMETRIE_ARETE;
130 case VISU::NODE_ENTITY:
131 theVector = NODEGEOM;
132 return MED_NBR_GEOMETRIE_NODE;
138 //---------------------------------------------------------------
140 MEDGeom2NbNodes(int theMEDGeomType)
142 switch(theMEDGeomType){
143 case SALOME_MED::MED_NONE:
145 case SALOME_MED::MED_POINT1:
147 case SALOME_MED::MED_SEG2:
149 case SALOME_MED::MED_SEG3:
151 case SALOME_MED::MED_TRIA3:
153 case SALOME_MED::MED_TRIA6:
155 case SALOME_MED::MED_QUAD4:
157 case SALOME_MED::MED_QUAD8:
159 case SALOME_MED::MED_TETRA4:
161 case SALOME_MED::MED_TETRA10:
163 case SALOME_MED::MED_HEXA8:
165 case SALOME_MED::MED_HEXA20:
167 case SALOME_MED::MED_PENTA6:
169 case SALOME_MED::MED_PENTA15:
171 case SALOME_MED::MED_PYRA5:
173 case SALOME_MED::MED_PYRA13:
180 //---------------------------------------------------------------
182 MEDGeom2VISU(SALOME_MED::medGeometryElement theGeom)
185 case SALOME_MED::MED_POINT1:
186 return VISU::ePOINT1;
187 case SALOME_MED::MED_SEG2:
189 case SALOME_MED::MED_SEG3:
191 case SALOME_MED::MED_TRIA3:
193 case SALOME_MED::MED_TRIA6:
195 case SALOME_MED::MED_QUAD4:
197 case SALOME_MED::MED_QUAD8:
199 case SALOME_MED::MED_TETRA4:
200 return VISU::eTETRA4;
201 case SALOME_MED::MED_TETRA10:
202 return VISU::eTETRA10;
203 case SALOME_MED::MED_HEXA8:
205 case SALOME_MED::MED_HEXA20:
206 return VISU::eHEXA20;
207 case SALOME_MED::MED_PENTA6:
208 return VISU::ePENTA6;
209 case SALOME_MED::MED_PENTA15:
210 return VISU::ePENTA15;
211 case SALOME_MED::MED_PYRA5:
213 case SALOME_MED::MED_PYRA13:
214 return VISU::ePYRA13;
215 case SALOME_MED::MED_POLYGON:
216 return VISU::ePOLYGONE;
217 case SALOME_MED::MED_POLYHEDRA:
218 return VISU::ePOLYEDRE;
223 //---------------------------------------------------------------
224 SALOME_MED::medGeometryElement
225 VISUGeomToMED(int theGeom)
229 return SALOME_MED::MED_POINT1;
231 return SALOME_MED::MED_SEG2;
233 return SALOME_MED::MED_TRIA3;
235 return SALOME_MED::MED_QUAD4;
237 return SALOME_MED::MED_TETRA4;
239 return SALOME_MED::MED_HEXA8;
241 return SALOME_MED::MED_PENTA6;
243 return SALOME_MED::MED_PYRA5;
246 return SALOME_MED::MED_SEG3;
248 return SALOME_MED::MED_TRIA6;
250 return SALOME_MED::MED_QUAD8;
252 return SALOME_MED::MED_TETRA10;
254 return SALOME_MED::MED_HEXA20;
256 return SALOME_MED::MED_PENTA15;
258 return SALOME_MED::MED_PYRA13;
259 case VISU::ePOLYGONE:
260 return SALOME_MED::MED_POLYGON;
261 case VISU::ePOLYEDRE:
262 return SALOME_MED::MED_POLYHEDRA;
264 return SALOME_MED::medGeometryElement(-1);
267 //---------------------------------------------------------------
268 SALOME_MED::medGeometryElement
269 VTKGeomToMED(int theVTKGeomType)
271 switch(theVTKGeomType){
273 return SALOME_MED::MED_POINT1;
275 return SALOME_MED::MED_SEG2;
277 return SALOME_MED::MED_TRIA3;
279 return SALOME_MED::MED_QUAD4;
281 return SALOME_MED::MED_TETRA4;
283 return SALOME_MED::MED_HEXA8;
285 return SALOME_MED::MED_PENTA6;
287 return SALOME_MED::MED_PYRA5;
289 return SALOME_MED::MED_POLYGON;
291 return SALOME_MED::medGeometryElement(-1);
294 //---------------------------------------------------------------
296 MEDEntityToVTK(SALOME_MED::medEntityMesh theMEDEntity)
298 switch(theMEDEntity){
299 case SALOME_MED::MED_NODE:
300 return VISU::NODE_ENTITY;
301 case SALOME_MED::MED_EDGE:
302 return VISU::EDGE_ENTITY;
303 case SALOME_MED::MED_FACE:
304 return VISU::FACE_ENTITY;
305 case SALOME_MED::MED_CELL:
306 return VISU::CELL_ENTITY;
308 return VISU::TEntity(-1);
311 //---------------------------------------------------------------
312 SALOME_MED::medEntityMesh
313 VTKEntityToMED(VISU::TEntity theVTKEntity)
315 switch(theVTKEntity){
316 case VISU::NODE_ENTITY:
317 return SALOME_MED::MED_NODE;
318 case VISU::EDGE_ENTITY:
319 return SALOME_MED::MED_EDGE;
320 case VISU::FACE_ENTITY:
321 return SALOME_MED::MED_FACE;
322 case VISU::CELL_ENTITY:
323 return SALOME_MED::MED_CELL;
325 return SALOME_MED::medEntityMesh(-1);
329 //---------------------------------------------------------------
331 GetSObjectName(SALOMEDS::SObject_ptr aSObject)
333 SALOMEDS::GenericAttribute_var anAttr;
334 if (aSObject->FindAttribute(anAttr,"AttributeName")) {
335 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
336 CORBA::String_var aString = aName->Value();
343 //---------------------------------------------------------------
345 GetCellsSize(vtkIdType& theNbCells,
346 vtkIdType& theCellsSize,
347 SALOME_MED::MESH_ptr theMEDMesh,
348 const VISU::TEntity& theVEntity)
350 theNbCells = theCellsSize = 0;
351 if(MYDEBUG) MESSAGE("GetCellsSize - theVEntity = "<<theVEntity);
352 const SALOME_MED::medEntityMesh& aMEntity = VTKEntityToMED(theVEntity);
353 SALOME_MED::MESH::connectivityInfos_var connInfo=theMEDMesh->getConnectGlobal(aMEntity);
354 int iGeomEnd = connInfo->meshTypes.length();
355 for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
356 int iNumElemEnd = connInfo->numberOfElements[iGeom];
358 if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<<iNumElemEnd);
359 theCellsSize += iNumElemEnd + connInfo->nodalConnectivityLength[iGeom];
360 theNbCells += iNumElemEnd;
366 //---------------------------------------------------------------
368 GetCellsSize(vtkIdType& theNbCells,
369 vtkIdType& theCellsSize,
370 SALOME_MED::FAMILY_ptr theMEDFamily)
372 theNbCells = theCellsSize = 0;
373 SALOME_MED::SUPPORT::supportInfos_var suppInfo=theMEDFamily->getSupportGlobal();
374 int iGeomEnd = suppInfo->types.length();
375 if(MYDEBUG) MESSAGE("GetCellsSize - iGeomEnd = "<<iGeomEnd);
376 for(int iGeom = 0; iGeom < iGeomEnd; iGeom++) {
377 int iNumElemEnd = suppInfo->nbEltTypes[iGeom];
379 if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<<iNumElemEnd);
380 theNbCells += iNumElemEnd;
381 theCellsSize += iNumElemEnd + suppInfo->nodalConnectivityLength[iGeom];
387 //---------------------------------------------------------------
389 GetCellsSize(VISU::PCMesh theMesh,
390 SALOME_MED::MESH_ptr theMEDMesh,
391 const VISU::TEntity& theEntity)
393 VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
394 VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[theEntity];
395 if(theEntity == VISU::NODE_ENTITY){
396 aMeshOnEntity->myNbCells = theMesh->myNbPoints;
397 aMeshOnEntity->myCellsSize = 2*theMesh->myNbPoints;
399 GetCellsSize(aMeshOnEntity->myNbCells,aMeshOnEntity->myCellsSize,theMEDMesh,theEntity);
404 //---------------------------------------------------------------
406 InitMeshOnEntity(const VISU::PCMesh& theMesh,
407 const VISU::TEntity& theEntity,
408 const VISU::PCMeshOnEntity& theMeshOnEntity)
410 VISU::PCMeshOnEntity aMeshOnEntity;
411 VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
412 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(theEntity);
413 if(anIter == aMeshOnEntityMap.end()){
414 aMeshOnEntity.reset(new VISU::TCMeshOnEntity());
415 *aMeshOnEntity = *theMeshOnEntity;
416 aMeshOnEntity->myEntity = theEntity;
417 aMeshOnEntityMap[theEntity] = aMeshOnEntity;
419 aMeshOnEntity = anIter->second;
421 GetCellsSize(theMesh,theMesh->myMesh,theEntity);
423 return aMeshOnEntity;
428 CrSubProfile(const VISU::PCMesh theMesh,
429 const VISU::PCField theField,
430 const VISU::TCMeshOnEntity& theMeshOnEntity,
431 SALOME_MED::medGeometryElement theMGeom,
434 if (MYDEBUG) MESSAGE("CrSubProfile");
435 VISU::EGeometry aEGeom = MEDGeom2VISU(theMGeom);
436 vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
438 VISU::PCSubProfile aSubProfile(new VISU::TCSubProfile());
439 aSubProfile->myGeom = aEGeom;
440 aSubProfile->myMGeom = theMGeom;
441 aSubProfile->myStatus = VISU::eAddAll;
442 if(MYDEBUG) MESSAGE("theMGeom = "<<theMGeom);
443 const VISU::TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity.myCellsFirstIndex;
444 VISU::TCellsFirstIndex::const_iterator aTimeStampIter = aCellsFirstIndex.find(theMGeom);
445 if(aTimeStampIter == (theMeshOnEntity.myCellsFirstIndex).end() &&
446 theMGeom != SALOME_MED::MED_POINT1)
447 aSubProfile->myStatus = VISU::eRemoveAll;
448 else if(aTimeStampIter == aCellsFirstIndex.end() && theMGeom == SALOME_MED::MED_POINT1){
450 aSubProfile->myName = "";
451 aSubProfile->myStatus = VISU::eAddPart;
453 aSubProfile->myNbCells = theNbElems;
454 aSubProfile->myCellsSize = aSubProfile->myNbCells;
458 aSubProfile->myName = "";
459 aSubProfile->myStatus = VISU::eAddPart;
461 aSubProfile->myNbCells = theNbElems;
462 aSubProfile->myCellsSize = aSubProfile->myNbCells*aVNbNodes;
466 if (MYDEBUG) MESSAGE("CrSubProfile done");
471 GetProfileKey(const VISU::PCMesh theMesh,
472 const VISU::PCField theField,
473 const VISU::PCValForTime theValForTime,
474 const VISU::TCMeshOnEntity& theMeshOnEntity)
476 if (MYDEBUG) MESSAGE("GetProfileKey");
478 VISU::TProfileKey aProfileKey;
480 const VISU::TCellsFirstIndex& aFirstIndex = theMeshOnEntity.myCellsFirstIndex;
481 VISU::TCellsFirstIndex::const_iterator anIter = aFirstIndex.begin();
482 SALOME_MED::SUPPORT_var aSupport = theValForTime->myField->getSupport();
484 if(anIter == aFirstIndex.end() && aSupport->getEntity() == SALOME_MED::MED_NODE){
485 SALOME_MED::medGeometryElement aMGeom = SALOME_MED::MED_POINT1;
487 aNbElems = aSupport->getNumberOfElements(SALOME_MED::MED_NONE);
488 if(MYDEBUG)MESSAGE("aMGeom="<<aMGeom<<" aNbElems="<<aNbElems);
490 MESSAGE("Error in theValForTime->myField->getSupport()->getNumberOfElements(aMGeom);");
493 VISU::PCSubProfile aSubProfile = CrSubProfile(theMesh,
498 aProfileKey.insert(aSubProfile);
501 for(; anIter != aFirstIndex.end(); anIter++){
502 SALOME_MED::medGeometryElement aMGeom = anIter->first;
504 aNbElems = aSupport->getNumberOfElements(aMGeom);
505 if(MYDEBUG)MESSAGE("aMGeom="<<aMGeom<<" aNbElems="<<aNbElems);
507 MESSAGE("Error in theValForTime->myField->getSupport()->getNumberOfElements(aMGeom);");
510 VISU::PCSubProfile aSubProfile = CrSubProfile(theMesh,
515 aProfileKey.insert(aSubProfile);
518 if (MYDEBUG) MESSAGE("GetProfileKey done");
523 InitProfile(VISU::PCMesh theMesh,
524 VISU::PCField theField,
525 VISU::PCValForTime theValForTime,
526 VISU::TCMeshOnEntity& theMeshOnEntity)
528 if (MYDEBUG) MESSAGE("InitProfile");
530 VISU::TProfileMap& aProfileMap = theMeshOnEntity.myProfileMap;
532 VISU::TProfileKey aProfileKey = GetProfileKey(theMesh,
537 VISU::TProfileMap::const_iterator anIter = aProfileMap.find(aProfileKey);
538 if(anIter != aProfileMap.end()){
539 theValForTime->myProfile = anIter->second;
540 if(MYDEBUG) MESSAGE("aProfileMap.find(aProfileKey) aProfile->myGeom=");
542 VISU::PCProfile aProfile(new VISU::TCProfile());
543 VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
545 VISU::TProfileKey::const_iterator anIter = aProfileKey.begin();
546 for(; anIter != aProfileKey.end(); anIter++){
547 VISU::PCSubProfile aSubProfile(*anIter);
549 if(aProfile->myIsAll && aSubProfile->myStatus != VISU::eAddAll)
550 aProfile->myIsAll = false;
552 VISU::EGeometry aEGeom = aSubProfile->myGeom;
553 aGeom2SubProfile[aEGeom] = aSubProfile;
556 aProfileMap[aProfileKey] = aProfile;
557 theValForTime->myProfile = aProfile;
559 if (MYDEBUG) MESSAGE("InitProfile done");
563 LoadProfile(VISU::PCMesh theMesh,
564 VISU::PCField theField,
565 VISU::PCValForTime theValForTime,
566 VISU::PCMeshOnEntity theMeshOnEntity)
568 VISU::PCProfile aProfile = theValForTime->myProfile;
569 if (MYDEBUG) MESSAGE("LoadProfile aProfile->myIsDone="<<aProfile->myIsDone);
570 if(aProfile->myIsDone)
573 const VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
574 VISU::TGeom2SubProfile::const_iterator aGeom2SubProfileIter = aGeom2SubProfile.begin();
575 if(aGeom2SubProfileIter == aGeom2SubProfile.end()){
576 MESSAGE("Warning! No geom 2 sub profile");
578 SALOME_MED::SUPPORT_var aSupport = theValForTime->myField->getSupport();
579 for(; aGeom2SubProfileIter != aGeom2SubProfile.end(); aGeom2SubProfileIter++){
580 VISU::EGeometry aEGeom = aGeom2SubProfileIter->first;
581 SALOME_MED::medGeometryElement aMGeom = VISUGeomToMED(aEGeom);
582 VISU::PCSubProfile aSubProfile = aGeom2SubProfileIter->second;
583 SALOME_TYPES::ListOfLong_var aGeom2ProfileIds;
584 std::vector<int> aGeom2Profile;
585 if(!aSupport->isOnAllElements()){
587 if(aMGeom == SALOME_MED::MED_POINT1)
588 aGeom2ProfileIds = aSupport->getNumberFromFile(SALOME_MED::MED_NONE);
590 aGeom2ProfileIds = aSupport->getNumberFromFile(aMGeom);
591 int aLen = aGeom2ProfileIds->length();
592 if(MYDEBUG) MESSAGE_BEGIN(" - aMGeom="<<aMGeom<<"; aNbCells="<<aLen);
593 for(int i = 0; i < aLen; i++){
594 int anId = aGeom2ProfileIds[i];
595 aGeom2Profile.push_back(anId);
596 if(MYDEBUG) MESSAGE_ADD(std::endl << "------------------------------->" << anId);
598 if(MYDEBUG) MESSAGE_END(" ");
603 SALOME_MED::medEntityMesh aMEntity = aSupport->getEntity();
604 int aNbElems = theMesh->myMesh->getNumberOfElements(aMEntity,aMGeom);
605 for(int i = 0; i < aNbElems; i++)
606 aGeom2Profile.push_back(i+1);
608 if(aGeom2Profile.size()>0){
609 VISU::TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID;
610 int aSize = aGeom2Profile.size();
611 aSubMeshID.resize(aSize);
612 for(int anId = 0; anId < aSize; anId++){
613 aSubMeshID[anId] = aGeom2Profile[anId] - 1;
618 aProfile->myIsDone = true;
619 if (MYDEBUG) MESSAGE("LoadProfile done");
624 //---------------------------------------------------------------
626 VISU_MEDFieldConvertor
629 if(myField->_is_nil())
630 throw std::runtime_error("VISU_MEDFieldConvertor::Build >> myField->_is_nil() !!!");
632 SALOME_MED::SUPPORT_var aMEDSupport = myField->getSupport();
633 if(aMEDSupport->_is_nil())
634 throw std::runtime_error("VISU_MEDFieldConvertor::Build >> aMEDSupport->_is_nil() !!!");
636 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
637 VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
638 SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh()->convertInMESH();
639 if(aMEDMesh->_is_nil())
640 throw std::runtime_error("VISU_MEDFieldConvertor::Build >> aMEDMesh->_is_nil() !!!");
642 CORBA::String_var aMeshName = aMEDMesh->getName();
643 CORBA::String_var aFieldName = myField->getName();
645 VISU::PCMesh aMesh = myMeshMap[aMeshName.in()](new VISU::TCMesh());
646 aMesh->myNamedPointCoords(new VISU::TNamedPointCoords());
647 aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
648 aMesh->myDim = aMEDMesh->getSpaceDimension();
649 aMesh->myName = aMeshName.in();
650 aMesh->myMesh = aMEDMesh;
652 if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
654 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
655 VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new VISU::TCMeshOnEntity());
656 aMeshOnEntity->myEntity = aVEntity;
657 aMeshOnEntity->myMeshName = aMeshName.in();
658 aMeshOnEntity->mySupport = aMEDSupport;
660 if(aVEntity == VISU::NODE_ENTITY)
661 ::InitMeshOnEntity(aMesh, VISU::CELL_ENTITY, aMeshOnEntity);
663 ::InitMeshOnEntity(aMesh, VISU::NODE_ENTITY, aMeshOnEntity);
665 ::GetCellsSize(aMesh, aMEDMesh, aVEntity);
667 VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
668 VISU::PCField aField = aFieldMap[aFieldName.in()](new VISU::TCField());
669 aField->myId = myField->getOrderNumber();
670 aField->myName = aFieldName.in();
671 aField->myEntity = aVEntity;
672 aField->myMeshName = aMeshName.in();
673 aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
675 vtkIdType aDataType = VTK_DOUBLE;
676 SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(myField);
677 if(aFieldDouble->_is_nil()) {
678 // PAL18313: Mandriva 64 porting: CRASH at creating presentation on "Import Structure".
679 if (sizeof(long) == 4 ) // Size of CORBA::Long is always 4 (see CORBA_basetypes.h)
680 aDataType = VTK_LONG;
681 else if (sizeof(int) == 4)
684 throw std::runtime_error("Can't map CORBA::Long to a VTK type");
687 aField->Init(myField->getNumberOfComponents(), aDataType);
689 if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
691 VISU::TValField& aValField = aField->myValField;
692 int anId = myField->getIterationNumber();
693 VISU::PCValForTime aValForTime = aValField[anId](new VISU::TCValForTime());
694 aValForTime->myId = anId;
695 CORBA::Double aDT = myField->getTime();
696 aValForTime->myTime = VISU::TTime(aDT,"");
697 aValForTime->myField = myField;
700 MESSAGE("VISU_MEDFieldConvertor::Build - aFieldName = '"<<aFieldName<<
701 "'; myId = "<<anId<<"; myTime = "<<aDT);
707 //---------------------------------------------------------------
712 if(mySObject->_is_nil())
713 throw std::runtime_error("VISU_MEDConvertor::Build >> mySObject->_is_nil() !!!");
714 SALOMEDS::Study_var aStudy = mySObject->GetStudy();
716 CORBA::Object_var aMedObject = VISU::SObjectToObject(mySObject);
717 if(!CORBA::is_nil(aMedObject)){
718 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(aMedObject);
722 SALOMEDS::ChildIterator_var aTimeStampIterator = aStudy->NewChildIterator(mySObject);
723 return Build(aTimeStampIterator);
729 using namespace boost;
731 //---------------------------------------------------------------
732 struct TSObjectByName
735 typedef tuple<SALOMEDS::SObject_var> TRet;
737 TSObjectByName(const std::string& theName):
741 TRet operator()(SALOMEDS::SObject_ptr theSObj, bool& theIsSuccess)
743 SALOMEDS::GenericAttribute_var anAttr;
744 if(theSObj->FindAttribute(anAttr,"AttributeName")){
745 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
746 CORBA::String_var aValue = aName->Value();
747 theIsSuccess = (myName == aValue.in());
749 return TRet(SALOMEDS::SObject::_duplicate(theSObj));
757 //---------------------------------------------------------------
761 typedef tuple<SALOME_MED::MESH_var,SALOMEDS::SObject_var> TRet;
763 TMeshByName(const std::string& theName):
767 TRet operator()(SALOMEDS::SObject_ptr theSObj, bool& theIsSuccess)
769 CORBA::Object_var anObj = VISU::SObjectToObject(theSObj);
770 if(!CORBA::is_nil(anObj)){
771 SALOME_MED::MESH_var aMesh = SALOME_MED::MESH::_narrow(anObj);
772 if(!CORBA::is_nil(aMesh)){
773 CORBA::String_var aName = aMesh->getName();
774 theIsSuccess = (myName == aName.in());
776 return TRet(aMesh,SALOMEDS::SObject::_duplicate(theSObj));
784 //---------------------------------------------------------------
785 template<typename TFun>
787 Find(SALOMEDS::SObject_ptr theStartSObj,
788 SALOMEDS::Study_ptr theStudy,
791 bool theIsAllLevels = true)
793 SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator(theStartSObj);
794 anIter->InitEx(theIsAllLevels);
795 for(; anIter->More(); anIter->Next()){
796 SALOMEDS::SObject_var aSObj = anIter->Value();
797 typename TFun::TRet aRet = theFun(aSObj,theIsSuccess);
801 return typename TFun::TRet();
807 //---------------------------------------------------------------
810 ::Build(SALOME_MED::MED_ptr theMED)
812 if(CORBA::is_nil(theMED))
815 CORBA::Long aNbMeshes = theMED->getNumberOfMeshes();
816 SALOME_TYPES::ListOfString_var aMeshNames = theMED->getMeshNames();
817 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aNbMeshes = "<<aNbMeshes);
819 SALOMEDS::Study_var aStudy = mySObject->GetStudy();
820 SALOMEDS::SObject_var aMedCompSObj = mySObject->GetFather();
822 bool anIsSuccess = false;
823 TSObjectByName::TRet aSObjectByNameRet =
824 Find(aMedCompSObj,aStudy,TSObjectByName("MEDMESH"),anIsSuccess);
826 MESSAGE("VISU_MEDConvertor::Build - Find ('"<<"MEDMESH"<<"') = "<<anIsSuccess);
828 SALOMEDS::SObject_var aMeshesSObj = boost::get<0>(aSObjectByNameRet);
829 for(int iMesh = 0; iMesh < aNbMeshes; iMesh++){
831 CORBA::String_var aMeshName = aMeshNames[iMesh];
832 TMeshByName::TRet aMeshByNameRet =
833 Find(aMeshesSObj,aStudy,TMeshByName(aMeshName.in()),anIsSuccess);
835 MESSAGE("VISU_MEDConvertor::Build - Find aMeshName('"<<aMeshName.in()<<"') = "<<anIsSuccess);
839 VISU::PCMesh aMesh = myMeshMap[aMeshName.in()](new VISU::TCMesh());
840 SALOME_MED::MESH_var aMEDMesh = boost::get<0>(aMeshByNameRet);
841 aMesh->myNamedPointCoords(new VISU::TNamedPointCoords());
842 aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
843 aMesh->myDim = aMEDMesh->getSpaceDimension();
844 aMesh->myName = aMeshName.in();
845 aMesh->myMesh = aMEDMesh;
848 MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
850 std::string aName = aMeshName.in();
851 std::replace(aName.begin(),aName.end(),' ','_');
854 std::ostringstream aStream;
855 aStream<<"MEDSUPPORTS_OF_"<<aName;
856 std::string aSupportsName(aStream.str());
857 TSObjectByName::TRet aSObjectByNameRet =
858 Find(aMeshesSObj,aStudy,TSObjectByName(aSupportsName.c_str()),anIsSuccess);
860 MESSAGE("VISU_MEDConvertor::Build - Find aSupportsName('"<<aSupportsName<<"') = "<<anIsSuccess);
864 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
865 SALOMEDS::SObject_var aSupportsSObj = boost::get<0>(aSObjectByNameRet);
866 SALOMEDS::ChildIterator_var aSupportIterator = aStudy->NewChildIterator(aSupportsSObj);
868 // Fill all MeshOnEntity
869 aSupportIterator->InitEx(true);
870 for(; aSupportIterator->More(); aSupportIterator->Next()){
871 SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value();
873 CORBA::Object_var aMedSupport = VISU::SObjectToObject(aSupportSObj);
874 if(CORBA::is_nil(aMedSupport))
877 SALOME_MED::SUPPORT_var aMEDSupport = SALOME_MED::SUPPORT::_narrow(aMedSupport);
878 if(aMEDSupport->_is_nil())
881 SALOME_MED::MESH_var aMeshOnSupport = aMEDSupport->getMesh()->convertInMESH();
882 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
883 VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
884 CORBA::String_var aSupportName = aMEDSupport->getName();
886 if(aMEDSupport->isOnAllElements() && strcmp(aSupportName.in(),"SupportOnAll_MED_") > 0){
888 MESSAGE("VISU_MEDConvertor::Build - Support isOnAllElements = '"<<aSupportName<<
889 "' aVEntity = "<<aVEntity);
890 vtkIdType aNbCells, aCellsSize;
891 //Check, if there is any data on the support?
892 if(aVEntity == VISU::NODE_ENTITY){
893 aMesh->myNbPoints = aMeshOnSupport->getNumberOfNodes();
894 aNbCells = aMesh->myNbPoints;
895 aCellsSize = 2*aMesh->myNbPoints;
897 ::GetCellsSize(aNbCells,aCellsSize,aMeshOnSupport,aVEntity);
900 if(aMeshOnEntityMap.find(aVEntity) == aMeshOnEntityMap.end()){
901 VISU::PCMeshOnEntity aMeshOnEntity(new VISU::TCMeshOnEntity());
902 aMeshOnEntity->myMeshName = aMeshName.in();
903 aMeshOnEntity->myEntity = aVEntity;
904 aMeshOnEntity->myNbCells = aNbCells;
905 aMeshOnEntity->myCellsSize = aCellsSize;
906 aMeshOnEntity->mySupport = aMEDSupport;
907 aMeshOnEntityMap[aVEntity] = aMeshOnEntity;
914 aSupportIterator->InitEx(true);
915 for(; aSupportIterator->More(); aSupportIterator->Next()){
916 SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value();
918 CORBA::Object_var aMedSupport = VISU::SObjectToObject(aSupportSObj);
919 if(CORBA::is_nil(aMedSupport))
922 SALOME_MED::SUPPORT_var aMEDSupport = SALOME_MED::SUPPORT::_narrow(aMedSupport);
923 if(aMEDSupport->_is_nil())
926 SALOME_MED::MESH_var aMeshOnSupport = aMEDSupport->getMesh()->convertInMESH();
927 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
928 VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
929 CORBA::String_var aSupportName = aMEDSupport->getName();
931 SALOME_MED::FAMILY_var aMEDFamily = SALOME_MED::FAMILY::_narrow(aMedSupport);
932 if(!aMEDFamily->_is_nil()) {
933 VISU::TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);
934 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
936 VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
938 vtkIdType aNbCells = aMeshOnEntity->myNbCells, aCellsSize = aMeshOnEntity->myCellsSize;
939 CORBA::Boolean anIsOnAllElements = aMEDSupport->isOnAllElements();
940 if(!anIsOnAllElements)
941 ::GetCellsSize(aNbCells,aCellsSize,aMEDFamily);
944 MESSAGE("VISU_MEDConvertor::Build "<<
945 "- aFamily = '"<<aSupportName<<"'"<<
946 "; anIsOnAllElements = "<<anIsOnAllElements<<
947 "; aVEntity = "<<aVEntity<<
948 "; aNbCells = "<<aNbCells);
951 VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
952 VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.find(aSupportName.in());
953 if(aFamilyMapIter == aFamilyMap.end()){
954 VISU::PCFamily aFamily(new VISU::TCFamily());
955 aFamily->myEntity = aVEntity;
956 aFamily->myNbCells = aNbCells;
957 aFamily->myCellsSize = aCellsSize;
958 aFamily->myId = aMEDFamily->getIdentifier();
959 aFamily->myName = aSupportName.in();
960 aFamily->myFamily = aMEDFamily;
961 aFamilyMap[aSupportName.in()] = aFamily;
968 aSupportIterator->InitEx(true);
969 for(; aSupportIterator->More(); aSupportIterator->Next()){
970 SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value();
972 CORBA::Object_var aMedSupport = VISU::SObjectToObject(aSupportSObj);
973 if(CORBA::is_nil(aMedSupport))
976 SALOME_MED::SUPPORT_var aMEDSupport = SALOME_MED::SUPPORT::_narrow(aMedSupport);
977 if(aMEDSupport->_is_nil())
980 SALOME_MED::MESH_var aMeshOnSupport = aMEDSupport->getMesh()->convertInMESH();
981 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
982 VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
983 CORBA::String_var aSupportName = aMEDSupport->getName();
985 SALOME_MED::GROUP_var aMEDGroup = SALOME_MED::GROUP::_narrow(aMedSupport);
986 if(!aMEDGroup->_is_nil()){
987 CORBA::Boolean anIsOnAllElements = aMEDSupport->isOnAllElements();
990 MESSAGE("VISU_MEDConvertor::Build "<<
991 "- aGroup = '"<<aSupportName<<"'"<<
992 "; anIsOnAllElements = "<<anIsOnAllElements<<
993 "; aVEntity = "<<aVEntity);
995 VISU::PCGroup aGroup(new VISU::TCGroup());
996 aGroup->myGroup = aMEDGroup;
997 VISU::TFamilySet& aFamilySet = aGroup->myFamilySet;
999 SALOME_MED::Family_array_var aFamilies = aMEDGroup->getFamilies();
1000 int iFamilyEnd = aFamilies->length();
1001 for(int iFamaily = 0; iFamaily < iFamilyEnd; iFamaily++){
1002 SALOME_MED::FAMILY_var aMEDFamily = aFamilies[iFamaily];
1003 CORBA::String_var aFamilyName = aMEDFamily->getName();
1004 TFindFamilyOnEntity aFindFamilyOnEntity =
1005 FindFamilyOnEntity(aMeshName.in(), aVEntity, aFamilyName.in());
1006 VISU::PCFamily aFamily = boost::get<2>(aFindFamilyOnEntity);
1007 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aGroup - aFamilyName = '"<<aFamilyName.in()<<"' = "<<bool(aFamily));
1009 aFamilySet.insert(VISU::TEnity2Family(aVEntity, aFamily));
1013 if(!aFamilySet.empty()){
1014 VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
1015 aGroupMap[aSupportName.in()] = aGroup;
1023 anIsSuccess = false;
1024 aSObjectByNameRet = Find(aMedCompSObj,aStudy,TSObjectByName("MEDFIELD"),anIsSuccess);
1026 SALOMEDS::SObject_var aFieldsSObj = boost::get<0>(aSObjectByNameRet);
1027 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - MEDFIELD found.");
1028 SALOMEDS::ChildIterator_var aFieldIterator = aStudy->NewChildIterator(aFieldsSObj);
1029 for(int iField = 0; aFieldIterator->More(); aFieldIterator->Next(), iField++){
1030 SALOMEDS::SObject_var aFieldSObj = aFieldIterator->Value();
1031 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFieldName = '"<<GetSObjectName(aFieldSObj)<<"'");
1032 SALOMEDS::ChildIterator_var aTimeStampIterator = aStudy->NewChildIterator(aFieldSObj);
1033 for(; aTimeStampIterator->More(); aTimeStampIterator->Next()){
1034 SALOMEDS::SObject_var aTimeStampSObj = aTimeStampIterator->Value();
1035 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<<GetSObjectName(aTimeStampSObj)<<"'");
1036 CORBA::Object_var aMedField = VISU::SObjectToObject(aTimeStampSObj);
1037 if(CORBA::is_nil(aMedField))
1040 SALOME_MED::FIELD_var aMEDField = SALOME_MED::FIELD::_narrow(aMedField);
1041 if(aMEDField->_is_nil())
1044 SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport();
1045 if(aMEDSupport->_is_nil())
1048 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
1049 VISU::TEntity anEntity = MEDEntityToVTK(aMEntity);
1050 SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh()->convertInMESH();
1051 if(aMEDMesh->_is_nil())
1054 CORBA::String_var aMeshName = aMEDMesh->getName();
1055 CORBA::String_var aFieldName = aMEDField->getName();
1057 VISU::TMeshMap::iterator aMeshMapIter = myMeshMap.find(aMeshName.in());
1058 if(aMeshMapIter == myMeshMap.end())
1061 VISU::PCMesh aMesh = aMeshMapIter->second;
1062 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1063 VISU::TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(anEntity);
1064 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
1067 VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
1068 VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1069 VISU::TFieldMap::iterator aFieldMapIter = aFieldMap.find(aFieldName.in());
1070 VISU::PCField aField;
1071 if(aFieldMapIter == aFieldMap.end()){
1072 aField = aFieldMap[aFieldName.in()](new VISU::TCField());
1073 aField->myId = iField;
1074 aField->myName = aFieldName.in();
1075 aField->myEntity = anEntity;
1076 aField->myMeshName = aMeshName.in();
1077 aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
1079 vtkIdType aDataType = VTK_DOUBLE;
1080 SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField);
1081 if(aFieldDouble->_is_nil()) {
1082 // PAL18313: Mandriva 64 porting: CRASH at creating presentation on "Import Structure".
1083 if (sizeof(long) == 4 ) // Size of CORBA::Long is always 4 (see CORBA_basetypes.h)
1084 aDataType = VTK_LONG;
1085 else if (sizeof(int) == 4)
1086 aDataType = VTK_INT;
1088 MESSAGE("Can't map CORBA::Long to a VTK type, for Field " << aFieldName);
1092 aField->Init(aMEDField->getNumberOfComponents(), aDataType);
1095 MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity->myNbCells = "<<aMeshOnEntity->myNbCells);
1097 aField = aFieldMapIter->second;
1099 VISU::TValField& aValField = aField->myValField;
1100 int anId = aMEDField->getIterationNumber();
1101 VISU::PCValForTime aValForTime = aValField[anId](new VISU::TCValForTime());
1102 aValForTime->myId = anId;
1103 CORBA::Double aDT = aMEDField->getTime();
1104 aValForTime->myTime = VISU::TTime(aDT,"");
1105 aValForTime->myField = aMEDField;
1107 MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<<aMeshName<<
1108 "'; myEntity = "<<anEntity<<"; myTime = "<<aDT);
1116 //---------------------------------------------------------------
1119 ::Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator)
1121 if(theTimeStampIterator->_is_nil()) return NULL;
1122 for(; theTimeStampIterator->More(); theTimeStampIterator->Next()){
1123 SALOMEDS::SObject_var aTimeStampSObj = theTimeStampIterator->Value();
1124 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<<GetSObjectName(aTimeStampSObj)<<"'");
1126 CORBA::Object_var aMedField = VISU::SObjectToObject(aTimeStampSObj);
1127 if(CORBA::is_nil(aMedField))
1130 SALOME_MED::FIELD_var aMEDField = SALOME_MED::FIELD::_narrow(aMedField);
1131 if(aMEDField->_is_nil())
1134 SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport();
1135 if(aMEDSupport->_is_nil())
1138 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
1139 VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
1140 SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh()->convertInMESH();
1141 if(aMEDMesh->_is_nil()) continue;
1142 CORBA::String_var aMeshName = aMEDMesh->getName();
1143 CORBA::String_var aFieldName = aMEDField->getName();
1146 VISU::TMeshMap::const_iterator aMeshMapIter = myMeshMap.find(aMeshName.in());
1147 if(aMeshMapIter == myMeshMap.end()){
1148 aMesh.reset(new VISU::TCMesh());
1149 aMesh->myNamedPointCoords(new VISU::TNamedPointCoords());
1150 aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
1151 aMesh->myDim = aMEDMesh->getSpaceDimension();
1152 aMesh->myName = aMeshName.in();
1153 aMesh->myMesh = aMEDMesh;
1155 myMeshMap[aMeshName.in()] = aMesh;
1158 MESSAGE("VISU_MEDConvertor::Build "<<
1159 "- aMeshName = '"<<aMeshName<<"'"<<
1160 "; aDim = "<<aMesh->myDim);
1162 aMesh = aMeshMapIter->second;
1164 VISU::PCMeshOnEntity aMeshOnEntity;
1165 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1166 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);
1167 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end()){
1168 aMeshOnEntity.reset(new VISU::TCMeshOnEntity());
1169 aMeshOnEntity->myEntity = aVEntity;
1170 aMeshOnEntity->myMeshName = aMeshName.in();
1171 aMeshOnEntity->mySupport = aMEDSupport;
1172 aMeshOnEntityMap[aVEntity] = aMeshOnEntity;
1174 aMeshOnEntity = aMeshOnEntityMapIter->second;
1176 if(aVEntity == VISU::NODE_ENTITY)
1177 ::InitMeshOnEntity(aMesh,VISU::CELL_ENTITY,aMeshOnEntity);
1179 ::InitMeshOnEntity(aMesh,VISU::NODE_ENTITY,aMeshOnEntity);
1181 ::GetCellsSize(aMesh,aMEDMesh,aVEntity);
1183 VISU::PCField aField;
1184 VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1185 VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.find(aFieldName.in());
1186 if(aFieldMapIter == aFieldMap.end()){
1187 aField.reset(new VISU::TCField());
1188 aField->myId = mySObject->Tag();
1189 aField->myName = aFieldName.in();
1190 aField->myEntity = aVEntity;
1191 aField->myMeshName = aMeshName.in();
1192 aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
1194 vtkIdType aDataType = VTK_DOUBLE;
1195 SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField);
1196 if(aFieldDouble->_is_nil()){
1197 if (sizeof(long) == 4 ) // Size of CORBA::Long is always 4 (see CORBA_basetypes.h)
1198 //Fix for IPAL20325 Crash on create presentation for imported field
1199 aDataType = VTK_LONG;
1200 else if (sizeof(int) == 4)
1201 aDataType = VTK_INT;
1203 throw std::runtime_error("Can't map CORBA::Long to a VTK type");
1206 aField->Init(aMEDField->getNumberOfComponents(), aDataType);
1208 aFieldMap[aFieldName.in()] = aField;
1211 MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity->myNbCells = "<<aMeshOnEntity->myNbCells);
1213 aField = aFieldMapIter->second;
1215 VISU::TValField& aValField = aField->myValField;
1216 int anId = aMEDField->getIterationNumber();
1217 VISU::PCValForTime aValForTime = aValField[anId](new VISU::TCValForTime());
1218 aValForTime->myId = anId;
1219 CORBA::Double aDT = aMEDField->getTime();
1220 aValForTime->myTime = VISU::TTime(aDT,"");
1221 aValForTime->myField = aMEDField;
1223 MESSAGE("VISU_MEDConvertor::Build "<<
1224 "- aMeshName = '"<<aMeshName<<"'"<<
1225 "; myEntity = "<<aVEntity<<
1226 "; myTime = "<<aDT<<
1233 //---------------------------------------------------------------
1236 ::LoadMeshOnEntity(VISU::PMeshImpl theMesh,
1237 VISU::PMeshOnEntityImpl theMeshOnEntity)
1239 int anIsUpdated = LoadPoints(theMesh);
1240 const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;
1241 if(aVEntity != VISU::NODE_ENTITY)
1242 anIsUpdated |= LoadCellsOnEntity(theMesh,theMeshOnEntity);
1248 //---------------------------------------------------------------
1251 ::LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
1252 VISU::PMeshOnEntityImpl theMeshOnEntity,
1253 VISU::PFamilyImpl theFamily)
1255 int anIsUpdated = LoadPoints(theMesh);
1256 const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;
1257 if(anEntity == VISU::NODE_ENTITY){
1258 anIsUpdated |= LoadPointsOnFamily(theMesh,theFamily);
1260 anIsUpdated |= LoadCellsOnEntity(theMesh,theMeshOnEntity);
1261 anIsUpdated |= LoadCellsOnFamily(theMesh,theMeshOnEntity,theFamily);
1268 //---------------------------------------------------------------
1271 ::LoadMeshOnGroup(VISU::PMeshImpl theMesh,
1272 const VISU::TFamilySet& theFamilySet)
1275 int anIsUpdated = LoadPoints(theMesh);
1276 VISU::TFamilySet::const_iterator aFamilyIter = theFamilySet.begin();
1277 for(; aFamilyIter != theFamilySet.end(); aFamilyIter++){
1278 VISU::PCFamily aFamily = (*aFamilyIter).second;
1279 const VISU::TEntity& aVEntity = aFamily->myEntity;
1280 VISU::PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
1281 if(aVEntity == VISU::NODE_ENTITY){
1282 anIsUpdated |= LoadPointsOnFamily(theMesh,aFamily);
1284 anIsUpdated |= LoadCellsOnEntity(theMesh,aMeshOnEntity);
1285 anIsUpdated |= LoadCellsOnFamily(theMesh,aMeshOnEntity,aFamily);
1293 //---------------------------------------------------------------
1296 ::LoadValForTimeOnMesh(VISU::PMeshImpl theMesh,
1297 VISU::PMeshOnEntityImpl theMeshOnEntity,
1298 VISU::PFieldImpl theField,
1299 VISU::PValForTimeImpl theValForTime)
1302 int anIsUpdated = LoadPoints(theMesh);
1303 const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;
1304 if(aVEntity != VISU::NODE_ENTITY)
1305 anIsUpdated |= LoadCellsOnEntity(theMesh,theMeshOnEntity);
1307 anIsUpdated |= LoadField(theMesh,theMeshOnEntity,theField,theValForTime);
1313 //---------------------------------------------------------------
1316 ::LoadPoints(VISU::PCMesh theMesh)
1318 //Check on existing family
1319 VISU::PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
1321 //Check on loading already done
1322 if(theMesh->myIsDone)
1325 SALOME_MED::MESH_var& aMedMesh = theMesh->myMesh;
1326 vtkIdType aDim = theMesh->GetDim();
1327 vtkIdType aNbElem = theMesh->GetNbPoints();
1329 if(MYDEBUG) MESSAGE("LoadPoints - aNbElem = "<<aNbElem);
1332 throw std::runtime_error("LoadPoints >> There is no points in the mesh !!!");
1334 SALOME_TYPES::ListOfDouble_var aCCoord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE);
1335 VISU::TCMEDCoordHolder* aCoordHolder = new VISU::TCMEDCoordHolder();
1336 aCoordHolder->Init(aNbElem, aDim, aCCoord);
1338 VISU::TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
1339 aCoords.Init(VISU::PCoordHolder(aCoordHolder));
1341 if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY");
1343 VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
1344 VISU::PSubMeshImpl aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new VISU::TCSubMesh());
1346 aSubMesh->myNbCells = theMesh->myNbPoints;
1347 aSubMesh->myCellsSize = 2*theMesh->myNbPoints;
1349 VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
1350 aCell2Connect.resize(aNbElem);
1351 if(MYDEBUG) MESSAGE("LoadPoints - aNbElem="<<aNbElem);
1352 for(int iElem = 0; iElem < aNbElem; iElem++)
1353 aCell2Connect[iElem] = VISU::TConnect(1,iElem);
1355 theMesh->myIsDone = true;
1361 //---------------------------------------------------------------
1364 ::LoadPointsOnFamily(VISU::PCMesh theMesh,
1365 VISU::PCFamily theFamily)
1367 VISU::PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
1369 if(theFamily->myIsDone)
1372 vtkIdType aNbElem = theMesh->GetNbPoints();
1373 SALOME_MED::FAMILY_var aMedFamily = theFamily->myFamily;
1374 CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements();
1375 VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1];
1377 if(!anIsOnAllElements){
1378 SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes();
1379 SALOME_TYPES::ListOfLong_var aCellNumForType = aMedFamily->getNumber(aGeom[0]);
1380 int aSize = aNbElem;
1381 aNbElem = aCellNumForType->length();
1382 for(int iElem = 0; iElem < aNbElem; iElem++){
1383 int anID = aCellNumForType[iElem] - 1;
1384 if(0 > anID || anID >= aSize){
1385 static QString aString;
1386 aString.sprintf("LoadPointsOnFamily - aSize(%d) <= aCellNumForType[%d] = %d < 0",aSize,iElem,anID);
1387 throw std::runtime_error((const char*)aString.toLatin1());
1389 aSubMeshID.push_back(anID);
1392 for(int iElem = 0; iElem < aNbElem; iElem++){
1393 aSubMeshID.push_back(iElem);
1397 theFamily->myIsDone = true;
1402 //---------------------------------------------------------------
1405 typedef MED::TCSlice<int> TA;
1406 //---------------------------------------------------------------
1407 typedef std::set<int> TConnSet;
1408 typedef std::vector<int> TIntArray;
1409 typedef MED::TCSlice<int> TConnSlice;
1411 //---------------------------------------------------------------
1412 class MEDPolygonConnectivity //! retriver of polygon connectivity
1415 TIntArray myConnIndex;
1418 MEDPolygonConnectivity(SALOME_MED::MESH_var theMesh,
1419 SALOME_MED::medEntityMesh theEntity)
1422 SALOME::SenderInt_var aSender =
1423 theMesh->getSenderForConnectivity(SALOME_MED::MED_NODAL, theEntity, SALOME_MED::MED_POLYGON);
1425 int* aValuePtr = ReceiverFactory::getValue(aSender.in(), aSize);
1426 myConn.assign(aValuePtr, aValuePtr + aSize);
1429 SALOME::SenderInt_var aSender =
1430 theMesh->getSenderForConnectivityIndex(SALOME_MED::MED_NODAL, theEntity, SALOME_MED::MED_POLYGON);
1432 int* aValuePtr = ReceiverFactory::getValue(aSender, aSize);
1433 myConnIndex.assign(aValuePtr, aValuePtr + aSize);
1435 // since the connectivity indices for polygones are stored together with other elements
1436 // we should cut the indices by a value of the first one
1439 int anOffset = myConnIndex.front() - 1;
1440 for( int anIndex = 0; anIndex < aSize; anIndex++ )
1441 myConnIndex[ anIndex ] -= anOffset;
1447 GetConn(int theId) const
1449 int anOffSet = myConnIndex[theId] - 1;
1450 int aSize = myConnIndex[theId + 1] - myConnIndex[ theId ];
1451 return TConnSlice(&myConn[0], myConn.size(), std::slice(anOffSet, aSize, 1));
1457 return myConnIndex.size() - 1;
1463 return myConn.size() + GetNbElem();
1468 //---------------------------------------------------------------
1469 class MEDPolyhedraConnectivity //! retriver of polyhedron connectivity
1472 TIntArray myConnIndex;
1473 TIntArray myFaceIndex;
1476 MEDPolyhedraConnectivity(SALOME_MED::MESH_var theMesh,
1477 SALOME_MED::medEntityMesh theEntity)
1480 SALOME::SenderInt_var aSender =
1481 theMesh->getSenderForConnectivity(SALOME_MED::MED_NODAL, theEntity, SALOME_MED::MED_POLYHEDRA);
1483 int* pt = ReceiverFactory::getValue(aSender, aSize);
1485 SALOME::SenderInt_var aSender2 =
1486 theMesh->getSenderForConnectivityIndex(SALOME_MED::MED_NODAL, theEntity, SALOME_MED::MED_POLYHEDRA);
1488 int* ptI = ReceiverFactory::getValue(aSender, aSize);
1490 int nbOfPolyHCells=aSizeI-1;
1491 std::vector<int> polh1v(aSizeI);
1493 std::vector<int> polh2v,polh3v;
1494 for(int i=0;i<nbOfPolyHCells;i++)
1496 int nbOfFaces=std::count(pt+ptI[i]-1,pt+ptI[i+1]-1,-1)+1;
1497 polh1v[i+1]=polh1v[i]+nbOfFaces;
1498 int *work=pt+ptI[i]-1;
1499 for(int j=0;j<nbOfFaces;j++)
1501 int *work2=std::find(work,pt+ptI[i+1]-1,-1);
1502 int connLgthOfFace=std::distance(work,work2);
1503 polh2v.push_back(connLgthOfFace);
1504 polh3v.insert(polh3v.end(),work,work2);
1509 myConn.assign(polh3v.begin(),polh3v.end());
1510 myFaceIndex.assign(polh2v.begin(),polh2v.end());
1511 myConnIndex.assign(polh1v.begin(),polh1v.end());
1516 GetUniqueConn(int theId,
1517 TConnSet& theConnSet) const
1520 int aStartFaceId = myConnIndex[theId] - 1;
1521 int anEndFaceId = myConnIndex[theId + 1] - 2;
1522 int aStartConnId = myFaceIndex[aStartFaceId] - 1;
1523 int anEndConnId = myFaceIndex[anEndFaceId + 1] - 1;
1524 for(int aConnId = aStartConnId; aConnId < anEndConnId; aConnId++)
1525 theConnSet.insert(myConn[aConnId]);
1526 return theConnSet.size();
1532 return myConnIndex.size() - 1;
1540 for(int anElemId = 0; anElemId < GetNbElem(); anElemId++)
1541 aCellSize += GetUniqueConn(anElemId, aConnSet);
1547 //---------------------------------------------------------------
1550 ::LoadCellsOnEntity(VISU::PCMesh theMesh,
1551 VISU::PCMeshOnEntity theMeshOnEntity)
1553 if(theMeshOnEntity->myIsDone)
1556 SALOME_MED::SUPPORT_var& aMedSupport = theMeshOnEntity->mySupport;
1557 SALOME_MED::MESH_var aMedMesh = aMedSupport->getMesh()->convertInMESH();
1560 const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;
1561 const SALOME_MED::medEntityMesh& aMEntity = VTKEntityToMED(aVEntity);
1562 VISU::TCellsFirstIndex& aFirstIndex = theMeshOnEntity->myCellsFirstIndex;
1564 SALOME_MED::MESH::connectivityInfos_var anInfo = aMedMesh->getConnectGlobal(aMEntity);
1565 int iGeomEnd = anInfo->meshTypes.length();
1567 VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
1568 vtkIdType aNbPoints = theMesh->GetNbPoints();
1570 for(int iGeom = 0, aCounter = 0; iGeom < iGeomEnd; iGeom++) {
1571 SALOME_MED::medGeometryElement aMGeom = anInfo->meshTypes[iGeom];
1572 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
1574 case SALOME_MED::MED_POLYGON:
1576 MEDPolygonConnectivity aConn(aMedMesh, aMEntity);
1577 int aNbElem = aConn.GetNbElem();
1579 VISU::PSubMeshImpl aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TCSubMesh());
1580 aSubMesh->myNbCells = aNbElem;
1581 aSubMesh->myCellsSize = aConn.GetCellSize();
1583 VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
1584 aCell2Connect.resize(aNbElem);
1586 for(int iElem = 0; iElem < aNbElem; iElem++) {
1587 TConnSlice aConnSlice = aConn.GetConn(iElem);
1588 VISU::TConnect& anArray = aCell2Connect[iElem];
1589 anArray.resize(aConnSlice.size());
1590 for(int iConn = 0; iConn < aConnSlice.size(); iConn++)
1591 anArray[iConn] = aConnSlice[iConn] - 1;
1596 case SALOME_MED::MED_POLYHEDRA:
1598 MEDPolyhedraConnectivity aConn( aMedMesh, aMEntity );
1599 int aNbElem = aConn.GetNbElem();
1601 VISU::PSubMeshImpl aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TCSubMesh());
1602 aSubMesh->myNbCells = aNbElem;
1603 aSubMesh->myCellsSize = aConn.GetCellSize();
1605 VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
1606 aCell2Connect.resize(aNbElem);
1608 TConnSet aConnectSet;
1609 for(int iElem = 0; iElem < aNbElem; iElem++){
1610 if(aConn.GetUniqueConn(iElem, aConnectSet)){
1611 int aNbConn = aConnectSet.size();
1612 VISU::TConnect& anArray = aCell2Connect[iElem];
1613 anArray.resize(aNbConn);
1614 std::set<int>::iterator anIter = aConnectSet.begin();
1615 for(int i = 0; anIter != aConnectSet.end(); anIter++, i++)
1616 anArray[i] = *anIter - 1;
1624 int aMNbNodes = MEDGeom2NbNodes(aMGeom);
1625 int aVNbNodes = VISUGeom2NbNodes(aEGeom);
1626 int aNbElem = anInfo->numberOfElements[iGeom];
1628 SALOME_TYPES::ListOfLong_var aConn =
1629 aMedMesh->getConnectivity(SALOME_MED::MED_NODAL,
1632 VISU::PSubMeshImpl aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TCSubMesh());
1634 aSubMesh->myNbCells = aNbElem;
1635 aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1);
1637 VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
1638 std::vector<int> aConnect(aMNbNodes);
1639 int aNbConnForElem = aConn->length() / aNbElem;
1641 if(MYDEBUG) MESSAGE("LoadCellsOnEntity - aMGeom = "<<aMGeom<<
1642 "; aNbElem = "<<aNbElem<<
1643 "; aMNbNodes = "<<aMNbNodes<<
1644 "; aVNbNodes = "<<aVNbNodes<<
1645 "; aNbConnForElem = "<<aNbConnForElem);
1647 for(int iElem = 0; iElem < aNbElem; iElem++) {
1648 VISU::TConnect anArray(aVNbNodes);
1649 for(int k = 0, kj = iElem*aNbConnForElem; k < aMNbNodes; k++)
1650 aConnect[k] = aConn[kj+k] - 1;
1653 #if !(defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
1654 case SALOME_MED::MED_SEG3:
1655 anArray[0] = aConnect[0];
1656 anArray[2] = aConnect[1];
1658 anArray[1] = aConnect[2];
1661 #if !(defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
1662 case SALOME_MED::MED_TRIA6:
1663 anArray[0] = aConnect[0];
1664 anArray[2] = aConnect[1];
1665 anArray[4] = aConnect[2];
1667 anArray[1] = aConnect[3];
1668 anArray[3] = aConnect[4];
1669 anArray[5] = aConnect[5];
1672 #if !(defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
1673 case SALOME_MED::MED_QUAD8:
1674 anArray[0] = aConnect[0];
1675 anArray[2] = aConnect[1];
1676 anArray[4] = aConnect[2];
1677 anArray[6] = aConnect[3];
1679 anArray[1] = aConnect[4];
1680 anArray[3] = aConnect[5];
1681 anArray[5] = aConnect[6];
1682 anArray[7] = aConnect[7];
1685 #if (defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
1686 case SALOME_MED::MED_TETRA10 :
1688 case SALOME_MED::MED_TETRA4 :
1689 anArray[0] = aConnect[0];
1690 anArray[1] = aConnect[1];
1691 anArray[2] = aConnect[3];
1692 anArray[3] = aConnect[2];
1694 #if (defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
1695 case SALOME_MED::MED_PYRA13:
1697 case SALOME_MED::MED_PYRA5 :
1698 anArray[0] = aConnect[0];
1699 anArray[1] = aConnect[3];
1700 anArray[2] = aConnect[2];
1701 anArray[3] = aConnect[1];
1702 anArray[4] = aConnect[4];
1705 for (int k = 0; k < aVNbNodes; k++)
1706 anArray[k] = aConnect[k];
1708 for (int k = 0; k < aVNbNodes; k++)
1709 if(anArray[k] < 0 || aNbPoints <= anArray[k]){
1710 static QString aString;
1711 aString.sprintf("LoadCellsOnEntity >> aNbPoints(%d) <= anArray[%d][%d]=%d < 0 !!!",int(aNbPoints),iElem,k,anArray[k]);
1712 throw std::runtime_error((const char*)aString.toLatin1());
1714 aCell2Connect.push_back(anArray);
1715 } // loop on elements
1717 }} // switch( aMGeom )
1718 VISU::TGeom2SubMesh::iterator anIter = aGeom2SubMesh.find(aEGeom);
1719 if(anIter != aGeom2SubMesh.end()){
1720 const VISU::PSubMeshImpl& aSubMesh = anIter->second;
1721 const VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
1722 int aSize = aCell2Connect.size();
1723 if(MYDEBUG) MESSAGE("LoadCellsOnEntity - aCounter = "<<aCounter<<"; aSize = "<<aSize<<"; aMGeom = "<<aMGeom);
1724 aFirstIndex[aMGeom] = VISU::TIndexAndSize(aCounter, aSize);
1729 // Dump result connectivity
1731 // TGeom2SubMesh::iterator geom_sm = aGeom2SubMesh.begin();
1732 // for ( ; geom_sm!=aGeom2SubMesh.end(); ++geom_sm ) {
1733 // cout << "TYPE: " << geom_sm->first << endl;
1734 // PSubMeshImpl aSubMesh = geom_sm->second;
1735 // TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
1736 // TCell2Connect::iterator id_conn = aCell2Connect.begin();
1737 // for ( int i = 0; id_conn !=aCell2Connect.end(); ++id_conn ) {
1738 // cout << "\t" << i++ << ": [";
1739 // TConnect& anArray = *id_conn;
1740 // TConnect::iterator n = anArray.begin();
1741 // for ( ; n != anArray.end(); ++n )
1742 // cout << " " << *n + 1;
1743 // cout << " ]"<< endl;
1748 theMeshOnEntity->myIsDone = true;
1754 //---------------------------------------------------------------
1757 ::LoadCellsOnFamily(VISU::PCMesh theMesh,
1758 VISU::PCMeshOnEntity theMeshOnEntity,
1759 VISU::PCFamily theFamily)
1761 if(theFamily->myIsDone)
1764 SALOME_MED::FAMILY_var aMedFamily = theFamily->myFamily;
1765 CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements();
1766 if(!anIsOnAllElements){
1767 SALOME_MED::medGeometryElement_array_var aGeoms = aMedFamily->getTypes();
1768 int iGeomEnd = aGeoms->length();
1769 if(MYDEBUG) MESSAGE("LoadCellsOnFamily - iGeomEnd = "<<iGeomEnd);
1770 for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
1771 SALOME_MED::medGeometryElement aMGeom = aGeoms[iGeom];
1772 SALOME_TYPES::ListOfLong_var aCellNumForType = aMedFamily->getNumber(aMGeom);
1773 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
1775 int aNbElem = aCellNumForType->length();
1776 int aCounter = theMeshOnEntity->myCellsFirstIndex[aMGeom].first;
1777 int aSize = theMeshOnEntity->myCellsFirstIndex[aMGeom].second;
1778 VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aEGeom];
1781 MESSAGE("LoadCellsOnFamily "<<
1782 "- aMGeom = "<<aMGeom<<
1783 "; aNbElem = "<<aNbElem<<
1784 "; aSize = "<<aSize<<
1785 "; aCounter = "<<aCounter);
1787 for(int iElem = 0; iElem < aNbElem; iElem++){
1788 int anID = aCellNumForType[iElem] - aCounter - 1;
1789 if(0 > anID || anID >= aSize){
1790 static QString aString;
1791 aString.sprintf("LoadCellsOnFamily - aNbElem(%d) <= aCellNumForType[%d] = %d < 0 !!!",aNbElem,iElem,anID);
1792 throw std::runtime_error((const char*)aString.toLatin1());
1794 aSubMeshID.push_back(anID);
1798 const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
1799 VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
1800 for(; anIter != aGeom2SubMesh.end(); anIter++){
1801 VISU::EGeometry aEGeom = anIter->first;
1802 const VISU::TSubMeshImpl& aSubMesh = anIter->second;
1803 const VISU::TCell2Connect& aCell2Connect = aSubMesh.myCell2Connect;
1804 VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aEGeom];
1805 int iNumElemEnd = aCell2Connect.size();
1806 for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
1807 aSubMeshID.push_back(iNumElem);
1811 theFamily->myIsDone = true;
1817 template<class TValueType,
1818 class TContainerType>
1820 ImportField(TContainerType& theContainer,
1821 VISU::PCMesh theMesh,
1822 VISU::PCField theField,
1823 VISU::PCValForTime theValForTime,
1824 VISU::PCMeshOnEntity theMeshOnEntity)
1826 typedef VISU::TTCMEDMeshValue<TValueType, TContainerType> TVMeshValue;
1827 vtkIdType aNbComp = theField->myNbComp;
1828 if(theField->myEntity == VISU::NODE_ENTITY){
1829 VISU::EGeometry aEGeom = VISU::ePOINT1;
1830 vtkIdType aNbGauss = theValForTime->GetNbGauss(aEGeom);
1831 vtkIdType aNbElem = theMesh->GetNbPoints();
1833 if(MYDEBUG) MESSAGE("ImportField - aNbElem = "<<aNbElem);
1835 VISU::PMeshValue& aVMeshValue = theValForTime->GetMeshValue(VISU::ePOINT1);
1836 TVMeshValue* aMeshValue = new TVMeshValue();
1837 aMeshValue->Init(aNbElem, aNbGauss, aNbComp, theContainer, 0);
1838 aVMeshValue.reset(aMeshValue);
1840 SALOME_MED::medGeometryElement* aGeomElems;
1841 const VISU::TEntity& aVEntity = theField->myEntity;
1842 int iGeomEnd = GetEntity2Geom(aVEntity,aGeomElems);
1843 for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
1844 SALOME_MED::medGeometryElement aMGeom = aGeomElems[iGeom];
1845 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
1846 vtkIdType aNbGauss = theValForTime->GetNbGauss(aEGeom);
1847 const VISU::TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity->myCellsFirstIndex;
1848 VISU::TCellsFirstIndex::const_iterator aCellsFirstIndexIter = aCellsFirstIndex.find(aMGeom);
1849 if(aCellsFirstIndexIter != aCellsFirstIndex.end()){
1850 const VISU::TIndexAndSize& aIndexAndSize = aCellsFirstIndexIter->second;
1852 MESSAGE("ImportField - aMGeom = "<<aMGeom<<
1853 "; aIndexAndSize = {"<<aIndexAndSize.first<<
1854 ","<<aIndexAndSize.second<<"}");
1856 vtkIdType aNbElem = aIndexAndSize.second;
1857 vtkIdType aStart = aIndexAndSize.first * aNbComp;
1858 VISU::PMeshValue& aVMeshValue = theValForTime->GetMeshValue(aEGeom);
1859 TVMeshValue* aMeshValue = new TVMeshValue();
1860 aMeshValue->Init(aNbElem, aNbGauss, aNbComp, theContainer, aStart);
1861 aVMeshValue.reset(aMeshValue);
1869 ::LoadField(VISU::PCMesh theMesh,
1870 VISU::PCMeshOnEntity theMeshOnEntity,
1871 VISU::PField theField,
1872 VISU::PCValForTime theValForTime)
1874 MESSAGE("VISU_MEDConvertor::LoadField");
1875 //Check on loading already done
1876 VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = theValForTime->myUnstructuredGridIDMapper;
1877 if(anUnstructuredGridIDMapper->myIsVTKDone)
1880 VISU::PCProfile aProfile(new VISU::TCProfile());
1881 aProfile->myIsAll = true;
1882 theValForTime->myProfile = aProfile;
1884 SALOME_MED::FIELD_var aMEDField = theValForTime->myField;
1886 SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport();
1888 if(aMEDSupport->isOnAllElements()) aProfile->myIsDone = true;
1890 SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField);
1891 if(!aFieldDouble->_is_nil()){
1892 SALOME_TYPES::ListOfDouble_var anArray = aFieldDouble->getValue(SALOME_MED::MED_FULL_INTERLACE);
1893 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDDOUBLE = "<<anArray->length());
1894 ImportField<CORBA::Double>(anArray,
1901 SALOME_MED::FIELDINT_ptr aFieldInt = SALOME_MED::FIELDINT::_narrow(aMEDField);
1902 if(!aFieldInt->_is_nil()){
1903 SALOME_TYPES::ListOfLong_var anArray = aFieldInt->getValue(SALOME_MED::MED_FULL_INTERLACE);
1904 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDINT = "<<anArray->length());
1905 ImportField<CORBA::Long>(anArray,
1912 anUnstructuredGridIDMapper->myIsVTKDone = true;
1914 MESSAGE("VISU_MEDConvertor::LoadField done");