1 // Copyright (C) 2007-2008 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
22 // VISU OBJECT : interactive object for VISU entities implementation
23 // File : VISU_CorbaMedConvertor.cxx
24 // Author : Alexey PETROV
28 #include "VISU_CorbaMedConvertor.hxx"
29 #include "VISU_ConvertorUtils.hxx"
31 #include <vtkCellType.h>
33 #include <boost/tuple/tuple.hpp>
35 #include "ReceiverFactory.hxx"
36 #include "MED_SliceArray.hxx"
38 #include "utilities.h"
40 #define USER_INTERLACE MED_FULL_INTERLACE
43 static int MYDEBUG = 0;
45 static int MYDEBUG = 0;
50 CreateMEDConvertor(SALOMEDS::SObject_ptr theMedSObject)
52 return new VISU_MEDConvertor(theMedSObject);
56 CreateMEDFieldConvertor(SALOME_MED::FIELD_ptr theField)
58 return new VISU_MEDFieldConvertor(theField);
64 const int MED_NBR_GEOMETRIE_MAILLE = 17;
66 SALOME_MED::medGeometryElement
67 CELLGEOM[MED_NBR_GEOMETRIE_MAILLE] = {
68 SALOME_MED::MED_POINT1,
71 SALOME_MED::MED_TRIA3,
72 SALOME_MED::MED_QUAD4,
73 SALOME_MED::MED_TRIA6,
74 SALOME_MED::MED_QUAD8,
75 SALOME_MED::MED_TETRA4,
76 SALOME_MED::MED_PYRA5,
77 SALOME_MED::MED_PENTA6,
78 SALOME_MED::MED_HEXA8,
79 SALOME_MED::MED_TETRA10,
80 SALOME_MED::MED_PYRA13,
81 SALOME_MED::MED_PENTA15,
82 SALOME_MED::MED_HEXA20,
83 SALOME_MED::MED_POLYGON,
84 SALOME_MED::MED_POLYHEDRA
87 const int MED_NBR_GEOMETRIE_FACE = 5;
89 SALOME_MED::medGeometryElement
90 FACEGEOM[MED_NBR_GEOMETRIE_FACE] = {
91 SALOME_MED::MED_TRIA3,
92 SALOME_MED::MED_QUAD4,
93 SALOME_MED::MED_TRIA6,
94 SALOME_MED::MED_QUAD8,
95 SALOME_MED::MED_POLYGON
98 const int MED_NBR_GEOMETRIE_ARETE = 2;
100 SALOME_MED::medGeometryElement
101 EDGEGEOM[MED_NBR_GEOMETRIE_ARETE] = {
102 SALOME_MED::MED_SEG2,
106 const int MED_NBR_GEOMETRIE_NODE = 1;
108 SALOME_MED::medGeometryElement
109 NODEGEOM[MED_NBR_GEOMETRIE_NODE] = {
110 SALOME_MED::MED_POINT1,
114 //---------------------------------------------------------------
116 GetEntity2Geom(const VISU::TEntity& theEntity,
117 SALOME_MED::medGeometryElement*& theVector)
120 case VISU::CELL_ENTITY:
121 theVector = CELLGEOM;
122 return MED_NBR_GEOMETRIE_MAILLE;
123 case VISU::FACE_ENTITY:
124 theVector = FACEGEOM;
125 return MED_NBR_GEOMETRIE_FACE;
126 case VISU::EDGE_ENTITY:
127 theVector = EDGEGEOM;
128 return MED_NBR_GEOMETRIE_ARETE;
129 case VISU::NODE_ENTITY:
130 theVector = NODEGEOM;
131 return MED_NBR_GEOMETRIE_NODE;
137 //---------------------------------------------------------------
139 MEDGeom2NbNodes(int theMEDGeomType)
141 switch(theMEDGeomType){
142 case SALOME_MED::MED_NONE:
144 case SALOME_MED::MED_POINT1:
146 case SALOME_MED::MED_SEG2:
148 case SALOME_MED::MED_SEG3:
150 case SALOME_MED::MED_TRIA3:
152 case SALOME_MED::MED_TRIA6:
154 case SALOME_MED::MED_QUAD4:
156 case SALOME_MED::MED_QUAD8:
158 case SALOME_MED::MED_TETRA4:
160 case SALOME_MED::MED_TETRA10:
162 case SALOME_MED::MED_HEXA8:
164 case SALOME_MED::MED_HEXA20:
166 case SALOME_MED::MED_PENTA6:
168 case SALOME_MED::MED_PENTA15:
170 case SALOME_MED::MED_PYRA5:
172 case SALOME_MED::MED_PYRA13:
179 //---------------------------------------------------------------
181 MEDGeom2VISU(SALOME_MED::medGeometryElement theGeom)
184 case SALOME_MED::MED_POINT1:
185 return VISU::ePOINT1;
186 case SALOME_MED::MED_SEG2:
188 case SALOME_MED::MED_SEG3:
190 case SALOME_MED::MED_TRIA3:
192 case SALOME_MED::MED_TRIA6:
194 case SALOME_MED::MED_QUAD4:
196 case SALOME_MED::MED_QUAD8:
198 case SALOME_MED::MED_TETRA4:
199 return VISU::eTETRA4;
200 case SALOME_MED::MED_TETRA10:
201 return VISU::eTETRA10;
202 case SALOME_MED::MED_HEXA8:
204 case SALOME_MED::MED_HEXA20:
205 return VISU::eHEXA20;
206 case SALOME_MED::MED_PENTA6:
207 return VISU::ePENTA6;
208 case SALOME_MED::MED_PENTA15:
209 return VISU::ePENTA15;
210 case SALOME_MED::MED_PYRA5:
212 case SALOME_MED::MED_PYRA13:
213 return VISU::ePYRA13;
214 case SALOME_MED::MED_POLYGON:
215 return VISU::ePOLYGONE;
216 case SALOME_MED::MED_POLYHEDRA:
217 return VISU::ePOLYEDRE;
222 //---------------------------------------------------------------
223 SALOME_MED::medGeometryElement
224 VISUGeomToMED(int theGeom)
228 return SALOME_MED::MED_POINT1;
230 return SALOME_MED::MED_SEG2;
232 return SALOME_MED::MED_TRIA3;
234 return SALOME_MED::MED_QUAD4;
236 return SALOME_MED::MED_TETRA4;
238 return SALOME_MED::MED_HEXA8;
240 return SALOME_MED::MED_PENTA6;
242 return SALOME_MED::MED_PYRA5;
245 return SALOME_MED::MED_SEG3;
247 return SALOME_MED::MED_TRIA6;
249 return SALOME_MED::MED_QUAD8;
251 return SALOME_MED::MED_TETRA10;
253 return SALOME_MED::MED_HEXA20;
255 return SALOME_MED::MED_PENTA15;
257 return SALOME_MED::MED_PYRA13;
258 case VISU::ePOLYGONE:
259 return SALOME_MED::MED_POLYGON;
260 case VISU::ePOLYEDRE:
261 return SALOME_MED::MED_POLYHEDRA;
263 return SALOME_MED::medGeometryElement(-1);
266 //---------------------------------------------------------------
267 SALOME_MED::medGeometryElement
268 VTKGeomToMED(int theVTKGeomType)
270 switch(theVTKGeomType){
272 return SALOME_MED::MED_POINT1;
274 return SALOME_MED::MED_SEG2;
276 return SALOME_MED::MED_TRIA3;
278 return SALOME_MED::MED_QUAD4;
280 return SALOME_MED::MED_TETRA4;
282 return SALOME_MED::MED_HEXA8;
284 return SALOME_MED::MED_PENTA6;
286 return SALOME_MED::MED_PYRA5;
288 return SALOME_MED::MED_POLYGON;
290 return SALOME_MED::medGeometryElement(-1);
293 //---------------------------------------------------------------
295 MEDEntityToVTK(SALOME_MED::medEntityMesh theMEDEntity)
297 switch(theMEDEntity){
298 case SALOME_MED::MED_NODE:
299 return VISU::NODE_ENTITY;
300 case SALOME_MED::MED_EDGE:
301 return VISU::EDGE_ENTITY;
302 case SALOME_MED::MED_FACE:
303 return VISU::FACE_ENTITY;
304 case SALOME_MED::MED_CELL:
305 return VISU::CELL_ENTITY;
307 return VISU::TEntity(-1);
310 //---------------------------------------------------------------
311 SALOME_MED::medEntityMesh
312 VTKEntityToMED(VISU::TEntity theVTKEntity)
314 switch(theVTKEntity){
315 case VISU::NODE_ENTITY:
316 return SALOME_MED::MED_NODE;
317 case VISU::EDGE_ENTITY:
318 return SALOME_MED::MED_EDGE;
319 case VISU::FACE_ENTITY:
320 return SALOME_MED::MED_FACE;
321 case VISU::CELL_ENTITY:
322 return SALOME_MED::MED_CELL;
324 return SALOME_MED::medEntityMesh(-1);
328 //---------------------------------------------------------------
330 GetSObjectName(SALOMEDS::SObject_ptr aSObject)
332 SALOMEDS::GenericAttribute_var anAttr;
333 if (aSObject->FindAttribute(anAttr,"AttributeName")) {
334 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
335 CORBA::String_var aString = aName->Value();
342 //---------------------------------------------------------------
344 GetCellsSize(vtkIdType& theNbCells,
345 vtkIdType& theCellsSize,
346 SALOME_MED::MESH_ptr theMEDMesh,
347 const VISU::TEntity& theVEntity)
349 theNbCells = theCellsSize = 0;
350 if(MYDEBUG) MESSAGE("GetCellsSize - theVEntity = "<<theVEntity);
351 const SALOME_MED::medEntityMesh& aMEntity = VTKEntityToMED(theVEntity);
352 SALOME_MED::MESH::connectivityInfos_var connInfo=theMEDMesh->getConnectGlobal(aMEntity);
353 int iGeomEnd = connInfo->meshTypes.length();
354 for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
355 int iNumElemEnd = connInfo->numberOfElements[iGeom];
357 if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<<iNumElemEnd);
358 theCellsSize += iNumElemEnd + connInfo->nodalConnectivityLength[iGeom];
359 theNbCells += iNumElemEnd;
365 //---------------------------------------------------------------
367 GetCellsSize(vtkIdType& theNbCells,
368 vtkIdType& theCellsSize,
369 SALOME_MED::FAMILY_ptr theMEDFamily)
371 theNbCells = theCellsSize = 0;
372 SALOME_MED::SUPPORT::supportInfos_var suppInfo=theMEDFamily->getSupportGlobal();
373 int iGeomEnd = suppInfo->types.length();
374 if(MYDEBUG) MESSAGE("GetCellsSize - iGeomEnd = "<<iGeomEnd);
375 for(int iGeom = 0; iGeom < iGeomEnd; iGeom++) {
376 int iNumElemEnd = suppInfo->nbEltTypes[iGeom];
378 if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<<iNumElemEnd);
379 theNbCells += iNumElemEnd;
380 theCellsSize += iNumElemEnd + suppInfo->nodalConnectivityLength[iGeom];
386 //---------------------------------------------------------------
388 GetCellsSize(VISU::PCMesh theMesh,
389 SALOME_MED::MESH_ptr theMEDMesh,
390 const VISU::TEntity& theEntity)
392 VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
393 VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[theEntity];
394 if(theEntity == VISU::NODE_ENTITY){
395 aMeshOnEntity->myNbCells = theMesh->myNbPoints;
396 aMeshOnEntity->myCellsSize = 2*theMesh->myNbPoints;
398 GetCellsSize(aMeshOnEntity->myNbCells,aMeshOnEntity->myCellsSize,theMEDMesh,theEntity);
403 //---------------------------------------------------------------
405 InitMeshOnEntity(const VISU::PCMesh& theMesh,
406 const VISU::TEntity& theEntity,
407 const VISU::PCMeshOnEntity& theMeshOnEntity)
409 VISU::PCMeshOnEntity aMeshOnEntity;
410 VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
411 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(theEntity);
412 if(anIter == aMeshOnEntityMap.end()){
413 aMeshOnEntity.reset(new VISU::TCMeshOnEntity());
414 *aMeshOnEntity = *theMeshOnEntity;
415 aMeshOnEntity->myEntity = theEntity;
416 aMeshOnEntityMap[theEntity] = aMeshOnEntity;
418 aMeshOnEntity = anIter->second;
420 GetCellsSize(theMesh,theMesh->myMesh,theEntity);
422 return aMeshOnEntity;
427 CrSubProfile(const VISU::PCMesh theMesh,
428 const VISU::PCField theField,
429 const VISU::TCMeshOnEntity& theMeshOnEntity,
430 SALOME_MED::medGeometryElement theMGeom,
433 if (MYDEBUG) MESSAGE("CrSubProfile");
434 VISU::EGeometry aEGeom = MEDGeom2VISU(theMGeom);
435 vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
437 VISU::PCSubProfile aSubProfile(new VISU::TCSubProfile());
438 aSubProfile->myGeom = aEGeom;
439 aSubProfile->myMGeom = theMGeom;
440 aSubProfile->myStatus = VISU::eAddAll;
441 if(MYDEBUG) MESSAGE("theMGeom = "<<theMGeom);
442 const VISU::TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity.myCellsFirstIndex;
443 VISU::TCellsFirstIndex::const_iterator aTimeStampIter = aCellsFirstIndex.find(theMGeom);
444 if(aTimeStampIter == (theMeshOnEntity.myCellsFirstIndex).end() &&
445 theMGeom != SALOME_MED::MED_POINT1)
446 aSubProfile->myStatus = VISU::eRemoveAll;
447 else if(aTimeStampIter == aCellsFirstIndex.end() && theMGeom == SALOME_MED::MED_POINT1){
449 aSubProfile->myName = "";
450 aSubProfile->myStatus = VISU::eAddPart;
452 aSubProfile->myNbCells = theNbElems;
453 aSubProfile->myCellsSize = aSubProfile->myNbCells;
457 aSubProfile->myName = "";
458 aSubProfile->myStatus = VISU::eAddPart;
460 aSubProfile->myNbCells = theNbElems;
461 aSubProfile->myCellsSize = aSubProfile->myNbCells*aVNbNodes;
465 if (MYDEBUG) MESSAGE("CrSubProfile done");
470 GetProfileKey(const VISU::PCMesh theMesh,
471 const VISU::PCField theField,
472 const VISU::PCValForTime theValForTime,
473 const VISU::TCMeshOnEntity& theMeshOnEntity)
475 if (MYDEBUG) MESSAGE("GetProfileKey");
477 VISU::TProfileKey aProfileKey;
479 const VISU::TCellsFirstIndex& aFirstIndex = theMeshOnEntity.myCellsFirstIndex;
480 VISU::TCellsFirstIndex::const_iterator anIter = aFirstIndex.begin();
481 SALOME_MED::SUPPORT_var aSupport = theValForTime->myField->getSupport();
483 if(anIter == aFirstIndex.end() && aSupport->getEntity() == SALOME_MED::MED_NODE){
484 SALOME_MED::medGeometryElement aMGeom = SALOME_MED::MED_POINT1;
486 aNbElems = aSupport->getNumberOfElements(SALOME_MED::MED_NONE);
487 if(MYDEBUG)MESSAGE("aMGeom="<<aMGeom<<" aNbElems="<<aNbElems);
489 MESSAGE("Error in theValForTime->myField->getSupport()->getNumberOfElements(aMGeom);");
492 VISU::PCSubProfile aSubProfile = CrSubProfile(theMesh,
497 aProfileKey.insert(aSubProfile);
500 for(; anIter != aFirstIndex.end(); anIter++){
501 SALOME_MED::medGeometryElement aMGeom = anIter->first;
503 aNbElems = aSupport->getNumberOfElements(aMGeom);
504 if(MYDEBUG)MESSAGE("aMGeom="<<aMGeom<<" aNbElems="<<aNbElems);
506 MESSAGE("Error in theValForTime->myField->getSupport()->getNumberOfElements(aMGeom);");
509 VISU::PCSubProfile aSubProfile = CrSubProfile(theMesh,
514 aProfileKey.insert(aSubProfile);
517 if (MYDEBUG) MESSAGE("GetProfileKey done");
522 InitProfile(VISU::PCMesh theMesh,
523 VISU::PCField theField,
524 VISU::PCValForTime theValForTime,
525 VISU::TCMeshOnEntity& theMeshOnEntity)
527 if (MYDEBUG) MESSAGE("InitProfile");
529 VISU::TProfileMap& aProfileMap = theMeshOnEntity.myProfileMap;
531 VISU::TProfileKey aProfileKey = GetProfileKey(theMesh,
536 VISU::TProfileMap::const_iterator anIter = aProfileMap.find(aProfileKey);
537 if(anIter != aProfileMap.end()){
538 theValForTime->myProfile = anIter->second;
539 if(MYDEBUG) MESSAGE("aProfileMap.find(aProfileKey) aProfile->myGeom=");
541 VISU::PCProfile aProfile(new VISU::TCProfile());
542 VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
544 VISU::TProfileKey::const_iterator anIter = aProfileKey.begin();
545 for(; anIter != aProfileKey.end(); anIter++){
546 VISU::PCSubProfile aSubProfile(*anIter);
548 if(aProfile->myIsAll && aSubProfile->myStatus != VISU::eAddAll)
549 aProfile->myIsAll = false;
551 VISU::EGeometry aEGeom = aSubProfile->myGeom;
552 aGeom2SubProfile[aEGeom] = aSubProfile;
555 aProfileMap[aProfileKey] = aProfile;
556 theValForTime->myProfile = aProfile;
558 if (MYDEBUG) MESSAGE("InitProfile done");
562 LoadProfile(VISU::PCMesh theMesh,
563 VISU::PCField theField,
564 VISU::PCValForTime theValForTime,
565 VISU::PCMeshOnEntity theMeshOnEntity)
567 VISU::PCProfile aProfile = theValForTime->myProfile;
568 if (MYDEBUG) MESSAGE("LoadProfile aProfile->myIsDone="<<aProfile->myIsDone);
569 if(aProfile->myIsDone)
572 const VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
573 VISU::TGeom2SubProfile::const_iterator aGeom2SubProfileIter = aGeom2SubProfile.begin();
574 if(aGeom2SubProfileIter == aGeom2SubProfile.end()){
575 MESSAGE("Warning! No geom 2 sub profile");
577 SALOME_MED::SUPPORT_var aSupport = theValForTime->myField->getSupport();
578 for(; aGeom2SubProfileIter != aGeom2SubProfile.end(); aGeom2SubProfileIter++){
579 VISU::EGeometry aEGeom = aGeom2SubProfileIter->first;
580 SALOME_MED::medGeometryElement aMGeom = VISUGeomToMED(aEGeom);
581 VISU::PCSubProfile aSubProfile = aGeom2SubProfileIter->second;
582 SALOME_MED::long_array_var aGeom2ProfileIds;
583 std::vector<int> aGeom2Profile;
584 if(!aSupport->isOnAllElements()){
586 if(aMGeom == SALOME_MED::MED_POINT1)
587 aGeom2ProfileIds = aSupport->getNumberFromFile(SALOME_MED::MED_NONE);
589 aGeom2ProfileIds = aSupport->getNumberFromFile(aMGeom);
590 int aLen = aGeom2ProfileIds->length();
591 if(MYDEBUG) MESSAGE_BEGIN(" - aMGeom="<<aMGeom<<"; aNbCells="<<aLen);
592 for(int i = 0; i < aLen; i++){
593 int anId = aGeom2ProfileIds[i];
594 aGeom2Profile.push_back(anId);
595 if(MYDEBUG) MESSAGE_ADD(std::endl << "------------------------------->" << anId);
597 if(MYDEBUG) MESSAGE_END(" ");
602 SALOME_MED::medEntityMesh aMEntity = aSupport->getEntity();
603 int aNbElems = theMesh->myMesh->getNumberOfElements(aMEntity,aMGeom);
604 for(int i = 0; i < aNbElems; i++)
605 aGeom2Profile.push_back(i+1);
607 if(aGeom2Profile.size()>0){
608 VISU::TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID;
609 int aSize = aGeom2Profile.size();
610 aSubMeshID.resize(aSize);
611 for(int anId = 0; anId < aSize; anId++){
612 aSubMeshID[anId] = aGeom2Profile[anId] - 1;
617 aProfile->myIsDone = true;
618 if (MYDEBUG) MESSAGE("LoadProfile done");
623 //---------------------------------------------------------------
625 VISU_MEDFieldConvertor
628 if(myField->_is_nil())
629 throw std::runtime_error("VISU_MEDFieldConvertor::Build >> myField->_is_nil() !!!");
631 SALOME_MED::SUPPORT_var aMEDSupport = myField->getSupport();
632 if(aMEDSupport->_is_nil())
633 throw std::runtime_error("VISU_MEDFieldConvertor::Build >> aMEDSupport->_is_nil() !!!");
635 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
636 VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
637 SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh();
638 if(aMEDMesh->_is_nil())
639 throw std::runtime_error("VISU_MEDFieldConvertor::Build >> aMEDMesh->_is_nil() !!!");
641 CORBA::String_var aMeshName = aMEDMesh->getName();
642 CORBA::String_var aFieldName = myField->getName();
644 VISU::PCMesh aMesh = myMeshMap[aMeshName.in()](new VISU::TCMesh());
645 aMesh->myNamedPointCoords(new VISU::TNamedPointCoords());
646 aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
647 aMesh->myDim = aMEDMesh->getSpaceDimension();
648 aMesh->myName = aMeshName.in();
649 aMesh->myMesh = aMEDMesh;
651 if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
653 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
654 VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new VISU::TCMeshOnEntity());
655 aMeshOnEntity->myEntity = aVEntity;
656 aMeshOnEntity->myMeshName = aMeshName.in();
657 aMeshOnEntity->mySupport = aMEDSupport;
659 if(aVEntity == VISU::NODE_ENTITY)
660 ::InitMeshOnEntity(aMesh, VISU::CELL_ENTITY, aMeshOnEntity);
662 ::InitMeshOnEntity(aMesh, VISU::NODE_ENTITY, aMeshOnEntity);
664 ::GetCellsSize(aMesh, aMEDMesh, aVEntity);
666 VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
667 VISU::PCField aField = aFieldMap[aFieldName.in()](new VISU::TCField());
668 aField->myId = myField->getOrderNumber();
669 aField->myName = aFieldName.in();
670 aField->myEntity = aVEntity;
671 aField->myMeshName = aMeshName.in();
672 aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
674 vtkIdType aDataType = VTK_DOUBLE;
675 SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(myField);
676 if(aFieldDouble->_is_nil()) {
677 // PAL18313: Mandriva 64 porting: CRASH at creating presentation on "Import Structure".
678 if (sizeof(long) == 4 ) // Size of CORBA::Long is always 4 (see CORBA_basetypes.h)
679 aDataType = VTK_LONG;
680 else if (sizeof(int) == 4)
683 throw std::runtime_error("Can't map CORBA::Long to a VTK type");
686 aField->Init(myField->getNumberOfComponents(), aDataType);
688 if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
690 VISU::TValField& aValField = aField->myValField;
691 int anId = myField->getIterationNumber();
692 VISU::PCValForTime aValForTime = aValField[anId](new VISU::TCValForTime());
693 aValForTime->myId = anId;
694 CORBA::Double aDT = myField->getTime();
695 aValForTime->myTime = VISU::TTime(aDT,"");
696 aValForTime->myField = myField;
699 MESSAGE("VISU_MEDFieldConvertor::Build - aFieldName = '"<<aFieldName<<
700 "'; myId = "<<anId<<"; myTime = "<<aDT);
706 //---------------------------------------------------------------
711 if(mySObject->_is_nil())
712 throw std::runtime_error("VISU_MEDConvertor::Build >> mySObject->_is_nil() !!!");
713 SALOMEDS::Study_var aStudy = mySObject->GetStudy();
715 CORBA::Object_var aMedObject = VISU::SObjectToObject(mySObject);
716 if(!CORBA::is_nil(aMedObject)){
717 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(aMedObject);
721 SALOMEDS::ChildIterator_var aTimeStampIterator = aStudy->NewChildIterator(mySObject);
722 return Build(aTimeStampIterator);
728 using namespace boost;
730 //---------------------------------------------------------------
731 struct TSObjectByName
734 typedef tuple<SALOMEDS::SObject_var> TRet;
736 TSObjectByName(const std::string& theName):
740 TRet operator()(SALOMEDS::SObject_ptr theSObj, bool& theIsSuccess)
742 SALOMEDS::GenericAttribute_var anAttr;
743 if(theSObj->FindAttribute(anAttr,"AttributeName")){
744 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
745 CORBA::String_var aValue = aName->Value();
746 theIsSuccess = (myName == aValue.in());
748 return TRet(SALOMEDS::SObject::_duplicate(theSObj));
756 //---------------------------------------------------------------
760 typedef tuple<SALOME_MED::MESH_var,SALOMEDS::SObject_var> TRet;
762 TMeshByName(const std::string& theName):
766 TRet operator()(SALOMEDS::SObject_ptr theSObj, bool& theIsSuccess)
768 CORBA::Object_var anObj = VISU::SObjectToObject(theSObj);
769 if(!CORBA::is_nil(anObj)){
770 SALOME_MED::MESH_var aMesh = SALOME_MED::MESH::_narrow(anObj);
771 if(!CORBA::is_nil(aMesh)){
772 CORBA::String_var aName = aMesh->getName();
773 theIsSuccess = (myName == aName.in());
775 return TRet(aMesh,SALOMEDS::SObject::_duplicate(theSObj));
783 //---------------------------------------------------------------
784 template<typename TFun>
786 Find(SALOMEDS::SObject_ptr theStartSObj,
787 SALOMEDS::Study_ptr theStudy,
790 bool theIsAllLevels = true)
792 SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator(theStartSObj);
793 anIter->InitEx(theIsAllLevels);
794 for(; anIter->More(); anIter->Next()){
795 SALOMEDS::SObject_var aSObj = anIter->Value();
796 typename TFun::TRet aRet = theFun(aSObj,theIsSuccess);
800 return typename TFun::TRet();
806 //---------------------------------------------------------------
809 ::Build(SALOME_MED::MED_ptr theMED)
811 if(CORBA::is_nil(theMED))
814 CORBA::Long aNbMeshes = theMED->getNumberOfMeshes();
815 SALOME_MED::string_array_var aMeshNames = theMED->getMeshNames();
816 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aNbMeshes = "<<aNbMeshes);
818 SALOMEDS::Study_var aStudy = mySObject->GetStudy();
819 SALOMEDS::SObject_var aMedCompSObj = mySObject->GetFather();
821 bool anIsSuccess = false;
822 TSObjectByName::TRet aSObjectByNameRet =
823 Find(aMedCompSObj,aStudy,TSObjectByName("MEDMESH"),anIsSuccess);
825 MESSAGE("VISU_MEDConvertor::Build - Find ('"<<"MEDMESH"<<"') = "<<anIsSuccess);
827 SALOMEDS::SObject_var aMeshesSObj = boost::get<0>(aSObjectByNameRet);
828 for(int iMesh = 0; iMesh < aNbMeshes; iMesh++){
830 CORBA::String_var aMeshName = aMeshNames[iMesh];
831 TMeshByName::TRet aMeshByNameRet =
832 Find(aMeshesSObj,aStudy,TMeshByName(aMeshName.in()),anIsSuccess);
834 MESSAGE("VISU_MEDConvertor::Build - Find aMeshName('"<<aMeshName.in()<<"') = "<<anIsSuccess);
838 VISU::PCMesh aMesh = myMeshMap[aMeshName.in()](new VISU::TCMesh());
839 SALOME_MED::MESH_var aMEDMesh = boost::get<0>(aMeshByNameRet);
840 aMesh->myNamedPointCoords(new VISU::TNamedPointCoords());
841 aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
842 aMesh->myDim = aMEDMesh->getSpaceDimension();
843 aMesh->myName = aMeshName.in();
844 aMesh->myMesh = aMEDMesh;
847 MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
849 std::string aName = aMeshName.in();
850 std::replace(aName.begin(),aName.end(),' ','_');
853 std::ostringstream aStream;
854 aStream<<"MEDSUPPORTS_OF_"<<aName;
855 std::string aSupportsName(aStream.str());
856 TSObjectByName::TRet aSObjectByNameRet =
857 Find(aMeshesSObj,aStudy,TSObjectByName(aSupportsName.c_str()),anIsSuccess);
859 MESSAGE("VISU_MEDConvertor::Build - Find aSupportsName('"<<aSupportsName<<"') = "<<anIsSuccess);
863 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
864 SALOMEDS::SObject_var aSupportsSObj = boost::get<0>(aSObjectByNameRet);
865 SALOMEDS::ChildIterator_var aSupportIterator = aStudy->NewChildIterator(aSupportsSObj);
867 // Fill all MeshOnEntity
868 aSupportIterator->InitEx(true);
869 for(; aSupportIterator->More(); aSupportIterator->Next()){
870 SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value();
872 CORBA::Object_var aMedSupport = VISU::SObjectToObject(aSupportSObj);
873 if(CORBA::is_nil(aMedSupport))
876 SALOME_MED::SUPPORT_var aMEDSupport = SALOME_MED::SUPPORT::_narrow(aMedSupport);
877 if(aMEDSupport->_is_nil())
880 SALOME_MED::MESH_var aMeshOnSupport = aMEDSupport->getMesh();
881 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
882 VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
883 CORBA::String_var aSupportName = aMEDSupport->getName();
885 if(aMEDSupport->isOnAllElements() && strcmp(aSupportName.in(),"SupportOnAll_MED_") > 0){
887 MESSAGE("VISU_MEDConvertor::Build - Support isOnAllElements = '"<<aSupportName<<
888 "' aVEntity = "<<aVEntity);
889 vtkIdType aNbCells, aCellsSize;
890 //Check, if there is any data on the support?
891 if(aVEntity == VISU::NODE_ENTITY){
892 aMesh->myNbPoints = aMeshOnSupport->getNumberOfNodes();
893 aNbCells = aMesh->myNbPoints;
894 aCellsSize = 2*aMesh->myNbPoints;
896 ::GetCellsSize(aNbCells,aCellsSize,aMeshOnSupport,aVEntity);
899 if(aMeshOnEntityMap.find(aVEntity) == aMeshOnEntityMap.end()){
900 VISU::PCMeshOnEntity aMeshOnEntity(new VISU::TCMeshOnEntity());
901 aMeshOnEntity->myMeshName = aMeshName.in();
902 aMeshOnEntity->myEntity = aVEntity;
903 aMeshOnEntity->myNbCells = aNbCells;
904 aMeshOnEntity->myCellsSize = aCellsSize;
905 aMeshOnEntity->mySupport = aMEDSupport;
906 aMeshOnEntityMap[aVEntity] = aMeshOnEntity;
913 aSupportIterator->InitEx(true);
914 for(; aSupportIterator->More(); aSupportIterator->Next()){
915 SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value();
917 CORBA::Object_var aMedSupport = VISU::SObjectToObject(aSupportSObj);
918 if(CORBA::is_nil(aMedSupport))
921 SALOME_MED::SUPPORT_var aMEDSupport = SALOME_MED::SUPPORT::_narrow(aMedSupport);
922 if(aMEDSupport->_is_nil())
925 SALOME_MED::MESH_var aMeshOnSupport = aMEDSupport->getMesh();
926 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
927 VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
928 CORBA::String_var aSupportName = aMEDSupport->getName();
930 SALOME_MED::FAMILY_var aMEDFamily = SALOME_MED::FAMILY::_narrow(aMedSupport);
931 if(!aMEDFamily->_is_nil()) {
932 VISU::TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);
933 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
935 VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
937 vtkIdType aNbCells = aMeshOnEntity->myNbCells, aCellsSize = aMeshOnEntity->myCellsSize;
938 CORBA::Boolean anIsOnAllElements = aMEDSupport->isOnAllElements();
939 if(!anIsOnAllElements)
940 ::GetCellsSize(aNbCells,aCellsSize,aMEDFamily);
943 MESSAGE("VISU_MEDConvertor::Build "<<
944 "- aFamily = '"<<aSupportName<<"'"<<
945 "; anIsOnAllElements = "<<anIsOnAllElements<<
946 "; aVEntity = "<<aVEntity<<
947 "; aNbCells = "<<aNbCells);
950 VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
951 VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.find(aSupportName.in());
952 if(aFamilyMapIter == aFamilyMap.end()){
953 VISU::PCFamily aFamily(new VISU::TCFamily());
954 aFamily->myEntity = aVEntity;
955 aFamily->myNbCells = aNbCells;
956 aFamily->myCellsSize = aCellsSize;
957 aFamily->myId = aMEDFamily->getIdentifier();
958 aFamily->myName = aSupportName.in();
959 aFamily->myFamily = aMEDFamily;
960 aFamilyMap[aSupportName.in()] = aFamily;
967 aSupportIterator->InitEx(true);
968 for(; aSupportIterator->More(); aSupportIterator->Next()){
969 SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value();
971 CORBA::Object_var aMedSupport = VISU::SObjectToObject(aSupportSObj);
972 if(CORBA::is_nil(aMedSupport))
975 SALOME_MED::SUPPORT_var aMEDSupport = SALOME_MED::SUPPORT::_narrow(aMedSupport);
976 if(aMEDSupport->_is_nil())
979 SALOME_MED::MESH_var aMeshOnSupport = aMEDSupport->getMesh();
980 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
981 VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
982 CORBA::String_var aSupportName = aMEDSupport->getName();
984 SALOME_MED::GROUP_var aMEDGroup = SALOME_MED::GROUP::_narrow(aMedSupport);
985 if(!aMEDGroup->_is_nil()){
986 CORBA::Boolean anIsOnAllElements = aMEDSupport->isOnAllElements();
989 MESSAGE("VISU_MEDConvertor::Build "<<
990 "- aGroup = '"<<aSupportName<<"'"<<
991 "; anIsOnAllElements = "<<anIsOnAllElements<<
992 "; aVEntity = "<<aVEntity);
994 VISU::PCGroup aGroup(new VISU::TCGroup());
995 aGroup->myGroup = aMEDGroup;
996 VISU::TFamilySet& aFamilySet = aGroup->myFamilySet;
998 SALOME_MED::Family_array_var aFamilies = aMEDGroup->getFamilies();
999 int iFamilyEnd = aFamilies->length();
1000 for(int iFamaily = 0; iFamaily < iFamilyEnd; iFamaily++){
1001 SALOME_MED::FAMILY_var aMEDFamily = aFamilies[iFamaily];
1002 CORBA::String_var aFamilyName = aMEDFamily->getName();
1003 TFindFamilyOnEntity aFindFamilyOnEntity =
1004 FindFamilyOnEntity(aMeshName.in(), aVEntity, aFamilyName.in());
1005 VISU::PCFamily aFamily = boost::get<2>(aFindFamilyOnEntity);
1006 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aGroup - aFamilyName = '"<<aFamilyName.in()<<"' = "<<bool(aFamily));
1008 aFamilySet.insert(aFamily);
1012 if(!aFamilySet.empty()){
1013 VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
1014 aGroupMap[aSupportName.in()] = aGroup;
1022 anIsSuccess = false;
1023 aSObjectByNameRet = Find(aMedCompSObj,aStudy,TSObjectByName("MEDFIELD"),anIsSuccess);
1025 SALOMEDS::SObject_var aFieldsSObj = boost::get<0>(aSObjectByNameRet);
1026 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - MEDFIELD found.");
1027 SALOMEDS::ChildIterator_var aFieldIterator = aStudy->NewChildIterator(aFieldsSObj);
1028 for(int iField = 0; aFieldIterator->More(); aFieldIterator->Next(), iField++){
1029 SALOMEDS::SObject_var aFieldSObj = aFieldIterator->Value();
1030 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFieldName = '"<<GetSObjectName(aFieldSObj)<<"'");
1031 SALOMEDS::ChildIterator_var aTimeStampIterator = aStudy->NewChildIterator(aFieldSObj);
1032 for(; aTimeStampIterator->More(); aTimeStampIterator->Next()){
1033 SALOMEDS::SObject_var aTimeStampSObj = aTimeStampIterator->Value();
1034 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<<GetSObjectName(aTimeStampSObj)<<"'");
1035 CORBA::Object_var aMedField = VISU::SObjectToObject(aTimeStampSObj);
1036 if(CORBA::is_nil(aMedField))
1039 SALOME_MED::FIELD_var aMEDField = SALOME_MED::FIELD::_narrow(aMedField);
1040 if(aMEDField->_is_nil())
1043 SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport();
1044 if(aMEDSupport->_is_nil())
1047 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
1048 VISU::TEntity anEntity = MEDEntityToVTK(aMEntity);
1049 SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh();
1050 if(aMEDMesh->_is_nil())
1053 CORBA::String_var aMeshName = aMEDMesh->getName();
1054 CORBA::String_var aFieldName = aMEDField->getName();
1056 VISU::TMeshMap::iterator aMeshMapIter = myMeshMap.find(aMeshName.in());
1057 if(aMeshMapIter == myMeshMap.end())
1060 VISU::PCMesh aMesh = aMeshMapIter->second;
1061 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1062 VISU::TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(anEntity);
1063 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
1066 VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
1067 VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1068 VISU::TFieldMap::iterator aFieldMapIter = aFieldMap.find(aFieldName.in());
1069 VISU::PCField aField;
1070 if(aFieldMapIter == aFieldMap.end()){
1071 aField = aFieldMap[aFieldName.in()](new VISU::TCField());
1072 aField->myId = iField;
1073 aField->myName = aFieldName.in();
1074 aField->myEntity = anEntity;
1075 aField->myMeshName = aMeshName.in();
1076 aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
1078 vtkIdType aDataType = VTK_DOUBLE;
1079 SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField);
1080 if(aFieldDouble->_is_nil()) {
1081 // PAL18313: Mandriva 64 porting: CRASH at creating presentation on "Import Structure".
1082 if (sizeof(long) == 4 ) // Size of CORBA::Long is always 4 (see CORBA_basetypes.h)
1083 aDataType = VTK_LONG;
1084 else if (sizeof(int) == 4)
1085 aDataType = VTK_INT;
1087 MESSAGE("Can't map CORBA::Long to a VTK type, for Field " << aFieldName);
1091 aField->Init(aMEDField->getNumberOfComponents(), aDataType);
1094 MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity->myNbCells = "<<aMeshOnEntity->myNbCells);
1096 aField = aFieldMapIter->second;
1098 VISU::TValField& aValField = aField->myValField;
1099 int anId = aMEDField->getIterationNumber();
1100 VISU::PCValForTime aValForTime = aValField[anId](new VISU::TCValForTime());
1101 aValForTime->myId = anId;
1102 CORBA::Double aDT = aMEDField->getTime();
1103 aValForTime->myTime = VISU::TTime(aDT,"");
1104 aValForTime->myField = aMEDField;
1106 MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<<aMeshName<<
1107 "'; myEntity = "<<anEntity<<"; myTime = "<<aDT);
1115 //---------------------------------------------------------------
1118 ::Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator)
1120 if(theTimeStampIterator->_is_nil()) return NULL;
1121 for(; theTimeStampIterator->More(); theTimeStampIterator->Next()){
1122 SALOMEDS::SObject_var aTimeStampSObj = theTimeStampIterator->Value();
1123 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<<GetSObjectName(aTimeStampSObj)<<"'");
1125 CORBA::Object_var aMedField = VISU::SObjectToObject(aTimeStampSObj);
1126 if(CORBA::is_nil(aMedField))
1129 SALOME_MED::FIELD_var aMEDField = SALOME_MED::FIELD::_narrow(aMedField);
1130 if(aMEDField->_is_nil())
1133 SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport();
1134 if(aMEDSupport->_is_nil())
1137 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
1138 VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
1139 SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh();
1140 if(aMEDMesh->_is_nil()) continue;
1141 CORBA::String_var aMeshName = aMEDMesh->getName();
1142 CORBA::String_var aFieldName = aMEDField->getName();
1145 VISU::TMeshMap::const_iterator aMeshMapIter = myMeshMap.find(aMeshName.in());
1146 if(aMeshMapIter == myMeshMap.end()){
1147 aMesh.reset(new VISU::TCMesh());
1148 aMesh->myNamedPointCoords(new VISU::TNamedPointCoords());
1149 aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
1150 aMesh->myDim = aMEDMesh->getSpaceDimension();
1151 aMesh->myName = aMeshName.in();
1152 aMesh->myMesh = aMEDMesh;
1154 myMeshMap[aMeshName.in()] = aMesh;
1157 MESSAGE("VISU_MEDConvertor::Build "<<
1158 "- aMeshName = '"<<aMeshName<<"'"<<
1159 "; aDim = "<<aMesh->myDim);
1161 aMesh = aMeshMapIter->second;
1163 VISU::PCMeshOnEntity aMeshOnEntity;
1164 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1165 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);
1166 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end()){
1167 aMeshOnEntity.reset(new VISU::TCMeshOnEntity());
1168 aMeshOnEntity->myEntity = aVEntity;
1169 aMeshOnEntity->myMeshName = aMeshName.in();
1170 aMeshOnEntity->mySupport = aMEDSupport;
1171 aMeshOnEntityMap[aVEntity] = aMeshOnEntity;
1173 aMeshOnEntity = aMeshOnEntityMapIter->second;
1175 if(aVEntity == VISU::NODE_ENTITY)
1176 ::InitMeshOnEntity(aMesh,VISU::CELL_ENTITY,aMeshOnEntity);
1178 ::InitMeshOnEntity(aMesh,VISU::NODE_ENTITY,aMeshOnEntity);
1180 ::GetCellsSize(aMesh,aMEDMesh,aVEntity);
1182 VISU::PCField aField;
1183 VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1184 VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.find(aFieldName.in());
1185 if(aFieldMapIter == aFieldMap.end()){
1186 aField.reset(new VISU::TCField());
1187 aField->myId = mySObject->Tag();
1188 aField->myName = aFieldName.in();
1189 aField->myEntity = aVEntity;
1190 aField->myMeshName = aMeshName.in();
1191 aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
1193 vtkIdType aDataType = VTK_DOUBLE;
1194 SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField);
1195 if(aFieldDouble->_is_nil()){
1196 if (sizeof(long) == 4 ) // Size of CORBA::Long is always 4 (see CORBA_basetypes.h)
1197 //Fix for IPAL20325 Crash on create presentation for imported field
1198 aDataType = VTK_LONG;
1199 else if (sizeof(int) == 4)
1200 aDataType = VTK_INT;
1202 throw std::runtime_error("Can't map CORBA::Long to a VTK type");
1205 aField->Init(aMEDField->getNumberOfComponents(), aDataType);
1207 aFieldMap[aFieldName.in()] = aField;
1210 MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity->myNbCells = "<<aMeshOnEntity->myNbCells);
1212 aField = aFieldMapIter->second;
1214 VISU::TValField& aValField = aField->myValField;
1215 int anId = aMEDField->getIterationNumber();
1216 VISU::PCValForTime aValForTime = aValField[anId](new VISU::TCValForTime());
1217 aValForTime->myId = anId;
1218 CORBA::Double aDT = aMEDField->getTime();
1219 aValForTime->myTime = VISU::TTime(aDT,"");
1220 aValForTime->myField = aMEDField;
1222 MESSAGE("VISU_MEDConvertor::Build "<<
1223 "- aMeshName = '"<<aMeshName<<"'"<<
1224 "; myEntity = "<<aVEntity<<
1225 "; myTime = "<<aDT<<
1232 //---------------------------------------------------------------
1235 ::LoadMeshOnEntity(VISU::PMeshImpl theMesh,
1236 VISU::PMeshOnEntityImpl theMeshOnEntity)
1238 int anIsUpdated = LoadPoints(theMesh);
1239 const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;
1240 if(aVEntity != VISU::NODE_ENTITY)
1241 anIsUpdated |= LoadCellsOnEntity(theMesh,theMeshOnEntity);
1247 //---------------------------------------------------------------
1250 ::LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
1251 VISU::PMeshOnEntityImpl theMeshOnEntity,
1252 VISU::PFamilyImpl theFamily)
1254 int anIsUpdated = LoadPoints(theMesh);
1255 const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;
1256 if(anEntity == VISU::NODE_ENTITY){
1257 anIsUpdated |= LoadPointsOnFamily(theMesh,theFamily);
1259 anIsUpdated |= LoadCellsOnEntity(theMesh,theMeshOnEntity);
1260 anIsUpdated |= LoadCellsOnFamily(theMesh,theMeshOnEntity,theFamily);
1267 //---------------------------------------------------------------
1270 ::LoadMeshOnGroup(VISU::PMeshImpl theMesh,
1271 const VISU::TFamilySet& theFamilySet)
1274 int anIsUpdated = LoadPoints(theMesh);
1275 VISU::TFamilySet::const_iterator aFamilyIter = theFamilySet.begin();
1276 for(; aFamilyIter != theFamilySet.end(); aFamilyIter++){
1277 VISU::PCFamily aFamily = *aFamilyIter;
1278 const VISU::TEntity& aVEntity = aFamily->myEntity;
1279 VISU::PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
1280 if(aVEntity == VISU::NODE_ENTITY){
1281 anIsUpdated |= LoadPointsOnFamily(theMesh,aFamily);
1283 anIsUpdated |= LoadCellsOnEntity(theMesh,aMeshOnEntity);
1284 anIsUpdated |= LoadCellsOnFamily(theMesh,aMeshOnEntity,aFamily);
1292 //---------------------------------------------------------------
1295 ::LoadValForTimeOnMesh(VISU::PMeshImpl theMesh,
1296 VISU::PMeshOnEntityImpl theMeshOnEntity,
1297 VISU::PFieldImpl theField,
1298 VISU::PValForTimeImpl theValForTime)
1301 int anIsUpdated = LoadPoints(theMesh);
1302 const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;
1303 if(aVEntity != VISU::NODE_ENTITY)
1304 anIsUpdated |= LoadCellsOnEntity(theMesh,theMeshOnEntity);
1306 anIsUpdated |= LoadField(theMesh,theMeshOnEntity,theField,theValForTime);
1312 //---------------------------------------------------------------
1315 ::LoadPoints(VISU::PCMesh theMesh)
1317 //Check on existing family
1318 VISU::PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
1320 //Check on loading already done
1321 if(theMesh->myIsDone)
1324 SALOME_MED::MESH_var& aMedMesh = theMesh->myMesh;
1325 vtkIdType aDim = theMesh->GetDim();
1326 vtkIdType aNbElem = theMesh->GetNbPoints();
1328 if(MYDEBUG) MESSAGE("LoadPoints - aNbElem = "<<aNbElem);
1331 throw std::runtime_error("LoadPoints >> There is no points in the mesh !!!");
1333 SALOME_MED::double_array_var aCCoord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE);
1334 VISU::TCMEDCoordHolder* aCoordHolder = new VISU::TCMEDCoordHolder();
1335 aCoordHolder->Init(aNbElem, aDim, aCCoord);
1337 VISU::TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
1338 aCoords.Init(VISU::PCoordHolder(aCoordHolder));
1340 if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY");
1342 VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
1343 VISU::PSubMeshImpl aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new VISU::TCSubMesh());
1345 aSubMesh->myNbCells = theMesh->myNbPoints;
1346 aSubMesh->myCellsSize = 2*theMesh->myNbPoints;
1348 VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
1349 aCell2Connect.resize(aNbElem);
1350 if(MYDEBUG) MESSAGE("LoadPoints - aNbElem="<<aNbElem);
1351 for(int iElem = 0; iElem < aNbElem; iElem++)
1352 aCell2Connect[iElem] = VISU::TConnect(1,iElem);
1354 theMesh->myIsDone = true;
1360 //---------------------------------------------------------------
1363 ::LoadPointsOnFamily(VISU::PCMesh theMesh,
1364 VISU::PCFamily theFamily)
1366 VISU::PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
1368 if(theFamily->myIsDone)
1371 vtkIdType aNbElem = theMesh->GetNbPoints();
1372 SALOME_MED::FAMILY_var aMedFamily = theFamily->myFamily;
1373 CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements();
1374 VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1];
1376 if(!anIsOnAllElements){
1377 SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes();
1378 SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom[0]);
1379 int aSize = aNbElem;
1380 aNbElem = aCellNumForType->length();
1381 for(int iElem = 0; iElem < aNbElem; iElem++){
1382 int anID = aCellNumForType[iElem] - 1;
1383 if(0 > anID || anID >= aSize){
1384 static QString aString;
1385 aString.sprintf("LoadPointsOnFamily - aSize(%d) <= aCellNumForType[%d] = %d < 0",aSize,iElem,anID);
1386 throw std::runtime_error((const char*)aString.toLatin1());
1388 aSubMeshID.push_back(anID);
1391 for(int iElem = 0; iElem < aNbElem; iElem++){
1392 aSubMeshID.push_back(iElem);
1396 theFamily->myIsDone = true;
1401 //---------------------------------------------------------------
1404 typedef MED::TCSlice<int> TA;
1405 //---------------------------------------------------------------
1406 typedef std::set<int> TConnSet;
1407 typedef std::vector<int> TIntArray;
1408 typedef MED::TCSlice<int> TConnSlice;
1410 //---------------------------------------------------------------
1411 class MEDPolygonConnectivity //! retriver of polygon connectivity
1414 TIntArray myConnIndex;
1417 MEDPolygonConnectivity(SALOME_MED::MESH_var theMesh,
1418 SALOME_MED::medEntityMesh theEntity)
1421 SALOME::SenderInt_var aSender =
1422 theMesh->getSenderForPolygonsConnectivity(SALOME_MED::MED_NODAL, theEntity);
1424 int* aValuePtr = ReceiverFactory::getValue(aSender.in(), aSize);
1425 myConn.assign(aValuePtr, aValuePtr + aSize);
1428 SALOME::SenderInt_var aSender =
1429 theMesh->getSenderForPolygonsConnectivityIndex(SALOME_MED::MED_NODAL, theEntity);
1431 int* aValuePtr = ReceiverFactory::getValue(aSender, aSize);
1432 myConnIndex.assign(aValuePtr, aValuePtr + aSize);
1437 GetConn(int theId) const
1439 int anOffSet = myConnIndex[theId] - 1;
1440 int aSize = myConnIndex[theId + 1] - myConnIndex[ theId ];
1441 return TConnSlice(&myConn[0], myConn.size(), std::slice(anOffSet, aSize, 1));
1447 return myConnIndex.size() - 1;
1453 return myConn.size() + GetNbElem();
1458 //---------------------------------------------------------------
1459 class MEDPolyhedraConnectivity //! retriver of polyhedron connectivity
1462 TIntArray myConnIndex;
1463 TIntArray myFaceIndex;
1466 MEDPolyhedraConnectivity(SALOME_MED::MESH_var theMesh)
1469 SALOME::SenderInt_var aSender =
1470 theMesh->getSenderForPolyhedronConnectivity(SALOME_MED::MED_NODAL);
1472 int* aValuePtr = ReceiverFactory::getValue(aSender, aSize);
1473 myConn.assign(aValuePtr, aValuePtr + aSize);
1476 SALOME::SenderInt_var aSender =
1477 theMesh->getSenderForPolyhedronIndex(SALOME_MED::MED_NODAL);
1479 int* aValuePtr = ReceiverFactory::getValue(aSender, aSize);
1480 myConnIndex.assign(aValuePtr, aValuePtr + aSize);
1483 SALOME::SenderInt_var aSender =
1484 theMesh->getSenderForPolyhedronFacesIndex();
1486 int* aValuePtr = ReceiverFactory::getValue(aSender, aSize);
1487 myFaceIndex.assign(aValuePtr, aValuePtr + aSize);
1492 GetUniqueConn(int theId,
1493 TConnSet& theConnSet) const
1496 int aStartFaceId = myConnIndex[theId] - 1;
1497 int anEndFaceId = myConnIndex[theId + 1] - 2;
1498 int aStartConnId = myFaceIndex[aStartFaceId] - 1;
1499 int anEndConnId = myFaceIndex[anEndFaceId + 1] - 1;
1500 for(int aConnId = aStartConnId; aConnId < anEndConnId; aConnId++)
1501 theConnSet.insert(myConn[aConnId]);
1502 return theConnSet.size();
1508 return myConnIndex.size() - 1;
1516 for(int anElemId = 0; anElemId < GetNbElem(); anElemId++)
1517 aCellSize += GetUniqueConn(anElemId, aConnSet);
1523 //---------------------------------------------------------------
1526 ::LoadCellsOnEntity(VISU::PCMesh theMesh,
1527 VISU::PCMeshOnEntity theMeshOnEntity)
1529 if(theMeshOnEntity->myIsDone)
1532 SALOME_MED::SUPPORT_var& aMedSupport = theMeshOnEntity->mySupport;
1533 SALOME_MED::MESH_var aMedMesh = aMedSupport->getMesh();
1536 const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;
1537 const SALOME_MED::medEntityMesh& aMEntity = VTKEntityToMED(aVEntity);
1538 VISU::TCellsFirstIndex& aFirstIndex = theMeshOnEntity->myCellsFirstIndex;
1540 SALOME_MED::MESH::connectivityInfos_var anInfo = aMedMesh->getConnectGlobal(aMEntity);
1541 int iGeomEnd = anInfo->meshTypes.length();
1543 VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
1544 vtkIdType aNbPoints = theMesh->GetNbPoints();
1546 for(int iGeom = 0, aCounter = 0; iGeom < iGeomEnd; iGeom++) {
1547 SALOME_MED::medGeometryElement aMGeom = anInfo->meshTypes[iGeom];
1548 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
1550 case SALOME_MED::MED_POLYGON:
1552 MEDPolygonConnectivity aConn(aMedMesh, aMEntity);
1553 int aNbElem = aConn.GetNbElem();
1555 VISU::PSubMeshImpl aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TCSubMesh());
1556 aSubMesh->myNbCells = aNbElem;
1557 aSubMesh->myCellsSize = aConn.GetCellSize();
1559 VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
1560 aCell2Connect.resize(aNbElem);
1562 for(int iElem = 0; iElem < aNbElem; iElem++) {
1563 TConnSlice aConnSlice = aConn.GetConn(iElem);
1564 VISU::TConnect& anArray = aCell2Connect[iElem];
1565 anArray.resize(aConnSlice.size());
1566 for(int iConn = 0; iConn < aConnSlice.size(); iConn++)
1567 anArray[iConn] = aConnSlice[iConn] - 1;
1572 case SALOME_MED::MED_POLYHEDRA:
1574 MEDPolyhedraConnectivity aConn( aMedMesh );
1575 int aNbElem = aConn.GetNbElem();
1577 VISU::PSubMeshImpl aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TCSubMesh());
1578 aSubMesh->myNbCells = aNbElem;
1579 aSubMesh->myCellsSize = aConn.GetCellSize();
1581 VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
1582 aCell2Connect.resize(aNbElem);
1584 TConnSet aConnectSet;
1585 for(int iElem = 0; iElem < aNbElem; iElem++){
1586 if(aConn.GetUniqueConn(iElem, aConnectSet)){
1587 int aNbConn = aConnectSet.size();
1588 VISU::TConnect& anArray = aCell2Connect[iElem];
1589 anArray.resize(aNbConn);
1590 std::set<int>::iterator anIter = aConnectSet.begin();
1591 for(int i = 0; anIter != aConnectSet.end(); anIter++, i++)
1592 anArray[i] = *anIter - 1;
1600 int aMNbNodes = MEDGeom2NbNodes(aMGeom);
1601 int aVNbNodes = VISUGeom2NbNodes(aEGeom);
1602 int aNbElem = anInfo->numberOfElements[iGeom];
1604 SALOME_MED::long_array_var aConn =
1605 aMedMesh->getConnectivity(SALOME_MED::MED_FULL_INTERLACE,
1606 SALOME_MED::MED_NODAL,
1609 VISU::PSubMeshImpl aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TCSubMesh());
1611 aSubMesh->myNbCells = aNbElem;
1612 aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1);
1614 VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
1615 std::vector<int> aConnect(aMNbNodes);
1616 int aNbConnForElem = aConn->length() / aNbElem;
1618 if(MYDEBUG) MESSAGE("LoadCellsOnEntity - aMGeom = "<<aMGeom<<
1619 "; aNbElem = "<<aNbElem<<
1620 "; aMNbNodes = "<<aMNbNodes<<
1621 "; aVNbNodes = "<<aVNbNodes<<
1622 "; aNbConnForElem = "<<aNbConnForElem);
1624 for(int iElem = 0; iElem < aNbElem; iElem++) {
1625 VISU::TConnect anArray(aVNbNodes);
1626 for(int k = 0, kj = iElem*aNbConnForElem; k < aMNbNodes; k++)
1627 aConnect[k] = aConn[kj+k] - 1;
1630 #if !(defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
1631 case SALOME_MED::MED_SEG3:
1632 anArray[0] = aConnect[0];
1633 anArray[2] = aConnect[1];
1635 anArray[1] = aConnect[2];
1638 #if !(defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
1639 case SALOME_MED::MED_TRIA6:
1640 anArray[0] = aConnect[0];
1641 anArray[2] = aConnect[1];
1642 anArray[4] = aConnect[2];
1644 anArray[1] = aConnect[3];
1645 anArray[3] = aConnect[4];
1646 anArray[5] = aConnect[5];
1649 #if !(defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
1650 case SALOME_MED::MED_QUAD8:
1651 anArray[0] = aConnect[0];
1652 anArray[2] = aConnect[1];
1653 anArray[4] = aConnect[2];
1654 anArray[6] = aConnect[3];
1656 anArray[1] = aConnect[4];
1657 anArray[3] = aConnect[5];
1658 anArray[5] = aConnect[6];
1659 anArray[7] = aConnect[7];
1662 #if (defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
1663 case SALOME_MED::MED_TETRA10 :
1665 case SALOME_MED::MED_TETRA4 :
1666 anArray[0] = aConnect[0];
1667 anArray[1] = aConnect[1];
1668 anArray[2] = aConnect[3];
1669 anArray[3] = aConnect[2];
1671 #if (defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
1672 case SALOME_MED::MED_PYRA13:
1674 case SALOME_MED::MED_PYRA5 :
1675 anArray[0] = aConnect[0];
1676 anArray[1] = aConnect[3];
1677 anArray[2] = aConnect[2];
1678 anArray[3] = aConnect[1];
1679 anArray[4] = aConnect[4];
1682 for (int k = 0; k < aVNbNodes; k++)
1683 anArray[k] = aConnect[k];
1685 for (int k = 0; k < aVNbNodes; k++)
1686 if(anArray[k] < 0 || aNbPoints <= anArray[k]){
1687 static QString aString;
1688 aString.sprintf("LoadCellsOnEntity >> aNbPoints(%d) <= anArray[%d][%d]=%d < 0 !!!",int(aNbPoints),iElem,k,anArray[k]);
1689 throw std::runtime_error((const char*)aString.toLatin1());
1691 aCell2Connect.push_back(anArray);
1692 } // loop on elements
1694 }} // switch( aMGeom )
1695 VISU::TGeom2SubMesh::iterator anIter = aGeom2SubMesh.find(aEGeom);
1696 if(anIter != aGeom2SubMesh.end()){
1697 const VISU::PSubMeshImpl& aSubMesh = anIter->second;
1698 const VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
1699 int aSize = aCell2Connect.size();
1700 if(MYDEBUG) MESSAGE("LoadCellsOnEntity - aCounter = "<<aCounter<<"; aSize = "<<aSize<<"; aMGeom = "<<aMGeom);
1701 aFirstIndex[aMGeom] = VISU::TIndexAndSize(aCounter, aSize);
1706 // Dump result connectivity
1708 // TGeom2SubMesh::iterator geom_sm = aGeom2SubMesh.begin();
1709 // for ( ; geom_sm!=aGeom2SubMesh.end(); ++geom_sm ) {
1710 // cout << "TYPE: " << geom_sm->first << endl;
1711 // PSubMeshImpl aSubMesh = geom_sm->second;
1712 // TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
1713 // TCell2Connect::iterator id_conn = aCell2Connect.begin();
1714 // for ( int i = 0; id_conn !=aCell2Connect.end(); ++id_conn ) {
1715 // cout << "\t" << i++ << ": [";
1716 // TConnect& anArray = *id_conn;
1717 // TConnect::iterator n = anArray.begin();
1718 // for ( ; n != anArray.end(); ++n )
1719 // cout << " " << *n + 1;
1720 // cout << " ]"<< endl;
1725 theMeshOnEntity->myIsDone = true;
1731 //---------------------------------------------------------------
1734 ::LoadCellsOnFamily(VISU::PCMesh theMesh,
1735 VISU::PCMeshOnEntity theMeshOnEntity,
1736 VISU::PCFamily theFamily)
1738 if(theFamily->myIsDone)
1741 SALOME_MED::FAMILY_var aMedFamily = theFamily->myFamily;
1742 CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements();
1743 if(!anIsOnAllElements){
1744 SALOME_MED::medGeometryElement_array_var aGeoms = aMedFamily->getTypes();
1745 int iGeomEnd = aGeoms->length();
1746 if(MYDEBUG) MESSAGE("LoadCellsOnFamily - iGeomEnd = "<<iGeomEnd);
1747 for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
1748 SALOME_MED::medGeometryElement aMGeom = aGeoms[iGeom];
1749 SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aMGeom);
1750 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
1752 int aNbElem = aCellNumForType->length();
1753 int aCounter = theMeshOnEntity->myCellsFirstIndex[aMGeom].first;
1754 int aSize = theMeshOnEntity->myCellsFirstIndex[aMGeom].second;
1755 VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aEGeom];
1758 MESSAGE("LoadCellsOnFamily "<<
1759 "- aMGeom = "<<aMGeom<<
1760 "; aNbElem = "<<aNbElem<<
1761 "; aSize = "<<aSize<<
1762 "; aCounter = "<<aCounter);
1764 for(int iElem = 0; iElem < aNbElem; iElem++){
1765 int anID = aCellNumForType[iElem] - aCounter - 1;
1766 if(0 > anID || anID >= aSize){
1767 static QString aString;
1768 aString.sprintf("LoadCellsOnFamily - aNbElem(%d) <= aCellNumForType[%d] = %d < 0 !!!",aNbElem,iElem,anID);
1769 throw std::runtime_error((const char*)aString.toLatin1());
1771 aSubMeshID.push_back(anID);
1775 const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
1776 VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
1777 for(; anIter != aGeom2SubMesh.end(); anIter++){
1778 VISU::EGeometry aEGeom = anIter->first;
1779 const VISU::TSubMeshImpl& aSubMesh = anIter->second;
1780 const VISU::TCell2Connect& aCell2Connect = aSubMesh.myCell2Connect;
1781 VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aEGeom];
1782 int iNumElemEnd = aCell2Connect.size();
1783 for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
1784 aSubMeshID.push_back(iNumElem);
1788 theFamily->myIsDone = true;
1794 template<class TValueType,
1795 class TContainerType>
1797 ImportField(TContainerType& theContainer,
1798 VISU::PCMesh theMesh,
1799 VISU::PCField theField,
1800 VISU::PCValForTime theValForTime,
1801 VISU::PCMeshOnEntity theMeshOnEntity)
1803 typedef VISU::TTCMEDMeshValue<TValueType, TContainerType> TVMeshValue;
1804 vtkIdType aNbComp = theField->myNbComp;
1805 if(theField->myEntity == VISU::NODE_ENTITY){
1806 VISU::EGeometry aEGeom = VISU::ePOINT1;
1807 vtkIdType aNbGauss = theValForTime->GetNbGauss(aEGeom);
1808 vtkIdType aNbElem = theMesh->GetNbPoints();
1810 if(MYDEBUG) MESSAGE("ImportField - aNbElem = "<<aNbElem);
1812 VISU::PMeshValue& aVMeshValue = theValForTime->GetMeshValue(VISU::ePOINT1);
1813 TVMeshValue* aMeshValue = new TVMeshValue();
1814 aMeshValue->Init(aNbElem, aNbGauss, aNbComp, theContainer, 0);
1815 aVMeshValue.reset(aMeshValue);
1817 SALOME_MED::medGeometryElement* aGeomElems;
1818 const VISU::TEntity& aVEntity = theField->myEntity;
1819 int iGeomEnd = GetEntity2Geom(aVEntity,aGeomElems);
1820 for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
1821 SALOME_MED::medGeometryElement aMGeom = aGeomElems[iGeom];
1822 VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
1823 vtkIdType aNbGauss = theValForTime->GetNbGauss(aEGeom);
1824 const VISU::TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity->myCellsFirstIndex;
1825 VISU::TCellsFirstIndex::const_iterator aCellsFirstIndexIter = aCellsFirstIndex.find(aMGeom);
1826 if(aCellsFirstIndexIter != aCellsFirstIndex.end()){
1827 const VISU::TIndexAndSize& aIndexAndSize = aCellsFirstIndexIter->second;
1829 MESSAGE("ImportField - aMGeom = "<<aMGeom<<
1830 "; aIndexAndSize = {"<<aIndexAndSize.first<<
1831 ","<<aIndexAndSize.second<<"}");
1833 vtkIdType aNbElem = aIndexAndSize.second;
1834 vtkIdType aStart = aIndexAndSize.first * aNbComp;
1835 VISU::PMeshValue& aVMeshValue = theValForTime->GetMeshValue(aEGeom);
1836 TVMeshValue* aMeshValue = new TVMeshValue();
1837 aMeshValue->Init(aNbElem, aNbGauss, aNbComp, theContainer, aStart);
1838 aVMeshValue.reset(aMeshValue);
1846 ::LoadField(VISU::PCMesh theMesh,
1847 VISU::PCMeshOnEntity theMeshOnEntity,
1848 VISU::PField theField,
1849 VISU::PCValForTime theValForTime)
1851 MESSAGE("VISU_MEDConvertor::LoadField");
1852 //Check on loading already done
1853 VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = theValForTime->myUnstructuredGridIDMapper;
1854 if(anUnstructuredGridIDMapper->myIsVTKDone)
1857 VISU::PCProfile aProfile(new VISU::TCProfile());
1858 aProfile->myIsAll = true;
1859 theValForTime->myProfile = aProfile;
1861 SALOME_MED::FIELD_var aMEDField = theValForTime->myField;
1863 SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport();
1865 if(aMEDSupport->isOnAllElements()) aProfile->myIsDone = true;
1867 SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField);
1868 if(!aFieldDouble->_is_nil()){
1869 SALOME_MED::double_array_var anArray = aFieldDouble->getValue(SALOME_MED::MED_FULL_INTERLACE);
1870 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDDOUBLE = "<<anArray->length());
1871 ImportField<CORBA::Double>(anArray,
1878 SALOME_MED::FIELDINT_ptr aFieldInt = SALOME_MED::FIELDINT::_narrow(aMEDField);
1879 if(!aFieldInt->_is_nil()){
1880 SALOME_MED::long_array_var anArray = aFieldInt->getValue(SALOME_MED::MED_FULL_INTERLACE);
1881 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDINT = "<<anArray->length());
1882 ImportField<CORBA::Long>(anArray,
1889 anUnstructuredGridIDMapper->myIsVTKDone = true;
1891 MESSAGE("VISU_MEDConvertor::LoadField done");