1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : VISU_CorbaMedConvertor.cxx
25 // Author : Alexey PETROV
28 // Copyright (C) 2003 CEA/DEN, EDF R&D
30 #include "VISU_CorbaMedConvertor.hxx"
32 #include <vtkCellType.h>
34 #include <boost/tuple/tuple.hpp>
39 #define USER_INTERLACE MED_FULL_INTERLACE
42 static int MYDEBUG = 0;
44 static int MYDEBUG = 0;
49 CreateMEDConvertor(SALOMEDS::SObject_ptr theMedSObject)
51 return new VISU_MEDConvertor(theMedSObject);
55 CreateMEDFieldConvertor(SALOME_MED::FIELD_ptr theField)
57 return new VISU_MEDFieldConvertor(theField);
62 using namespace SALOME_MED;
64 const int MED_NBR_GEOMETRIE_MAILLE = 15;
67 CELLGEOM[MED_NBR_GEOMETRIE_MAILLE] = {
85 const int MED_NBR_GEOMETRIE_FACE = 4;
88 FACEGEOM[MED_NBR_GEOMETRIE_FACE] = {
95 const int MED_NBR_GEOMETRIE_ARETE = 2;
98 EDGEGEOM[MED_NBR_GEOMETRIE_ARETE] = {
103 const int MED_NBR_GEOMETRIE_NODE = 1;
106 NODEGEOM[MED_NBR_GEOMETRIE_NODE] = {
110 int GetEntity2Geom(const VISU::TEntity& theEntity, medGeometryElement*& theVector)
113 case CELL_ENTITY: theVector = CELLGEOM; return MED_NBR_GEOMETRIE_MAILLE; break;
114 case FACE_ENTITY: theVector = FACEGEOM; return MED_NBR_GEOMETRIE_FACE; break;
115 case EDGE_ENTITY: theVector = EDGEGEOM; return MED_NBR_GEOMETRIE_ARETE; break;
116 case NODE_ENTITY: theVector = NODEGEOM; return MED_NBR_GEOMETRIE_NODE; break;
121 int MEDGeom2NbNodes(int theMEDGeomType)
123 switch(theMEDGeomType){
124 case MED_NONE: return 0;
125 case MED_POINT1: return 1;
126 case MED_SEG2: return 2;
127 case MED_SEG3: return 3;
128 case MED_TRIA3: return 3;
129 case MED_TRIA6: return 6;
130 case MED_QUAD4: return 4;
131 case MED_QUAD8: return 8;
132 case MED_TETRA4: return 4;
133 case MED_TETRA10: return 10;
134 case MED_HEXA8: return 8;
135 case MED_HEXA20: return 20;
136 case MED_PENTA6: return 6;
137 case MED_PENTA15: return 15;
138 case MED_PYRA5: return 5;
139 case MED_PYRA13: return 13;
144 int MEDGeomToVTK(medGeometryElement theMEDGeomType)
146 switch(theMEDGeomType){
147 case MED_NONE: return VTK_EMPTY_CELL;
148 case MED_POINT1: return VTK_VERTEX;
149 case MED_SEG2: return VTK_LINE;
150 case MED_SEG3: return VTK_LINE;
151 case MED_TRIA3: return VTK_TRIANGLE;
152 case MED_TRIA6: return VTK_TRIANGLE;
153 case MED_QUAD4: return VTK_QUAD;
154 case MED_QUAD8: return VTK_QUAD;
155 case MED_TETRA4: return VTK_TETRA;
156 case MED_TETRA10: return VTK_TETRA;
157 case MED_HEXA8: return VTK_HEXAHEDRON;
158 case MED_HEXA20: return VTK_HEXAHEDRON;
159 case MED_PENTA6: return VTK_WEDGE;
160 case MED_PENTA15: return VTK_WEDGE;
161 case MED_PYRA5: return VTK_PYRAMID;
162 case MED_PYRA13: return VTK_PYRAMID;
167 int VTKGeom2NbNodes(int theVTKGeomType)
169 switch(theVTKGeomType){
170 case VTK_VERTEX: return 1;
171 case VTK_LINE: return 2;
172 case VTK_TRIANGLE: return 3;
173 case VTK_QUAD: return 4;
174 case VTK_TETRA: return 4;
175 case VTK_HEXAHEDRON: return 8;
176 case VTK_WEDGE: return 6;
177 case VTK_PYRAMID: return 5;
182 medGeometryElement VTKGeomToMED(int theVTKGeomType)
184 switch(theVTKGeomType){
185 case VTK_VERTEX: return MED_POINT1;
186 case VTK_LINE: return MED_SEG2;
187 case VTK_TRIANGLE: return MED_TRIA3;
188 case VTK_QUAD: return MED_QUAD4;
189 case VTK_TETRA: return MED_TETRA4;
190 case VTK_HEXAHEDRON: return MED_HEXA8;
191 case VTK_WEDGE: return MED_PENTA6;
192 case VTK_PYRAMID: return MED_PYRA5;
194 return medGeometryElement(-1);
197 VISU::TEntity MEDEntityToVTK(medEntityMesh theMEDEntity)
199 switch(theMEDEntity){
200 case MED_NODE: return NODE_ENTITY;
201 case MED_EDGE: return EDGE_ENTITY;
202 case MED_FACE: return FACE_ENTITY;
203 case MED_CELL: return CELL_ENTITY;
205 return VISU::TEntity(-1);
208 medEntityMesh VTKEntityToMED(VISU::TEntity theVTKEntity)
210 switch(theVTKEntity){
211 case NODE_ENTITY: return MED_NODE;
212 case EDGE_ENTITY: return MED_EDGE;
213 case FACE_ENTITY: return MED_FACE;
214 case CELL_ENTITY: return MED_CELL;
216 return medEntityMesh(-1);
219 string GetSObjectName(SALOMEDS::SObject_ptr aSObject){
220 SALOMEDS::GenericAttribute_var anAttr;
221 if (aSObject->FindAttribute(anAttr,"AttributeName")) {
222 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
223 CORBA::String_var aString = aName->Value();
230 GetCellsSize(vtkIdType& theNbCells, vtkIdType& theCellsSize,
231 SALOME_MED::MESH_ptr theMEDMesh,
232 const VISU::TEntity& theVEntity)
234 medGeometryElement* aGeomElems;
235 theNbCells = theCellsSize = 0;
236 int iGeomEnd = GetEntity2Geom(theVEntity,aGeomElems);
237 const medEntityMesh& aMEntity = VTKEntityToMED(theVEntity);
238 if(MYDEBUG) MESSAGE("GetCellsSize - theVEntity = "<<theVEntity);
239 for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
240 medGeometryElement aMEDGeom = aGeomElems[iGeom];
241 int iNumElemEnd = theMEDMesh->getNumberOfElements(aMEntity,aMEDGeom);
243 if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<<iNumElemEnd);
244 theCellsSize += iNumElemEnd*(MEDGeom2NbNodes(aMEDGeom) + 1);
245 theNbCells += iNumElemEnd;
252 GetCellsSize(vtkIdType& theNbCells, vtkIdType& theCellsSize,
253 SALOME_MED::FAMILY_ptr theMEDFamily)
255 medGeometryElement_array_var aGeom = theMEDFamily->getTypes();
256 int iGeomEnd = aGeom->length();
257 theNbCells = theCellsSize = 0;
258 if(MYDEBUG) MESSAGE("GetCellsSize - iGeomEnd = "<<iGeomEnd);
259 for(int iGeom = 0; iGeom < iGeomEnd; iGeom++) {
260 medGeometryElement aMEDGeom = aGeom[iGeom];
261 long_array_var aCellNumForType = theMEDFamily->getNumber(aMEDGeom);
262 int iNumElemEnd = aCellNumForType->length();
264 if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<<iNumElemEnd);
265 theNbCells += iNumElemEnd;
266 theCellsSize += iNumElemEnd*(MEDGeom2NbNodes(aMEDGeom) + 1);
273 GetCellsSize(VISU::PCMesh theMesh,
274 SALOME_MED::MESH_ptr theMEDMesh,
275 const VISU::TEntity& theEntity)
277 TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
278 VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[theEntity];
279 if(theEntity == NODE_ENTITY){
280 theMesh->myNbPoints = theMEDMesh->getNumberOfNodes();
281 aMeshOnEntity->myNbCells = theMesh->myNbPoints;
282 aMeshOnEntity->myCellsSize = 2*theMesh->myNbPoints;
283 vtkIdType aNbCells, aCellsSize;
284 GetCellsSize(aNbCells,aCellsSize,theMEDMesh,CELL_ENTITY);
287 TMeshOnEntityMap::iterator aIter = aMeshOnEntityMap.find(CELL_ENTITY);
288 if (aIter != aMeshOnEntityMap.end()){
289 VISU::PCMeshOnEntity aMeshOnCells = aIter->second;
291 aMeshOnCells->myEntity = VISU::CELL_ENTITY;
292 aMeshOnCells->myMeshName = theMesh->myName;
293 aMeshOnCells->myNbCells = aNbCells;
294 aMeshOnCells->myCellsSize = aCellsSize;
298 GetCellsSize(aMeshOnEntity->myNbCells,aMeshOnEntity->myCellsSize,theMEDMesh,theEntity);
306 VISU_MEDFieldConvertor::Build()
308 if(myField->_is_nil())
309 throw std::runtime_error("VISU_MEDFieldConvertor::Build >> myField->_is_nil() !!!");
311 SALOME_MED::SUPPORT_var aMEDSupport = myField->getSupport();
312 if(aMEDSupport->_is_nil())
313 throw std::runtime_error("VISU_MEDFieldConvertor::Build >> aMEDSupport->_is_nil() !!!");
315 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
316 TEntity aVEntity = MEDEntityToVTK(aMEntity);
317 SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh();
318 if(aMEDMesh->_is_nil())
319 throw std::runtime_error("VISU_MEDFieldConvertor::Build >> aMEDMesh->_is_nil() !!!");
321 CORBA::String_var aMeshName = aMEDMesh->getName();
322 CORBA::String_var aFieldName = myField->getName();
324 PCMesh aMesh = myMeshMap[aMeshName.in()](new TCMesh());
325 aMesh->myDim = aMEDMesh->getSpaceDimension();
326 aMesh->myPointsDim.resize(aMesh->myDim);
327 aMesh->myName = aMeshName.in();
328 aMesh->myMesh = aMEDMesh;
330 if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
332 TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
333 PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TCMeshOnEntity());
334 aMeshOnEntity->myEntity = aVEntity;
335 aMeshOnEntity->myMeshName = aMeshName.in();
336 aMeshOnEntity->mySupport = aMEDSupport;
338 if(aVEntity == NODE_ENTITY){
339 PCMeshOnEntity aMeshOnEntity2 = aMeshOnEntityMap[CELL_ENTITY](new TCMeshOnEntity());
340 *aMeshOnEntity2 = *aMeshOnEntity;
341 aMeshOnEntity->myEntity = CELL_ENTITY;
342 GetCellsSize(aMesh,aMEDMesh,CELL_ENTITY);
344 PCMeshOnEntity aMeshOnEntity2 = aMeshOnEntityMap[NODE_ENTITY](new TCMeshOnEntity());
345 *aMeshOnEntity2 = *aMeshOnEntity;
346 aMeshOnEntity->myEntity = NODE_ENTITY;
347 GetCellsSize(aMesh,aMEDMesh,NODE_ENTITY);
349 GetCellsSize(aMesh,aMEDMesh,aVEntity);
351 TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
352 PCField aField = aFieldMap[aFieldName.in()](new TCField());
353 aField->myId = myField->getOrderNumber();
354 aField->myName = aFieldName.in();
355 aField->myEntity = aVEntity;
356 aField->myMeshName = aMeshName.in();
357 aField->myNbComp = myField->getNumberOfComponents();
358 aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
359 aField->myCompNames.resize(aField->myNbComp);
360 aField->myUnitNames.resize(aField->myNbComp);
362 if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
364 TValField& aValField = aField->myValField;
365 int anId = myField->getIterationNumber();
366 PCValForTime aValForTime = aValField[anId](new TCValForTime());
367 aValForTime->myId = anId;
368 CORBA::Double aDT = myField->getTime();
369 aValForTime->myTime = TTime(aDT,"");
370 aValForTime->myField = myField;
373 MESSAGE("VISU_MEDFieldConvertor::Build - aFieldName = '"<<aFieldName<<
374 "'; myId = "<<anId<<"; myTime = "<<aDT);
381 VISU_MEDConvertor::Build()
383 if(mySObject->_is_nil())
384 throw std::runtime_error("VISU_MEDConvertor::Build >> mySObject->_is_nil() !!!");
385 SALOMEDS::Study_var aStudy = mySObject->GetStudy();
387 CORBA::Object_var aMedObject = VISU::SObjectToObject(mySObject);
388 if(!CORBA::is_nil(aMedObject)){
389 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(aMedObject);
393 SALOMEDS::ChildIterator_var aTimeStampIterator = aStudy->NewChildIterator(mySObject);
394 return Build(aTimeStampIterator);
399 using namespace boost;
401 struct TSObjectByName{
403 typedef tuple<SALOMEDS::SObject_var> TRet;
405 TSObjectByName(const std::string& theName):
409 TRet operator()(SALOMEDS::SObject_ptr theSObj, bool& theIsSuccess)
411 SALOMEDS::GenericAttribute_var anAttr;
412 if(theSObj->FindAttribute(anAttr,"AttributeName")){
413 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
414 CORBA::String_var aValue = aName->Value();
415 theIsSuccess = (myName == aValue.in());
417 return TRet(SALOMEDS::SObject::_duplicate(theSObj));
426 typedef tuple<SALOME_MED::MESH_var,SALOMEDS::SObject_var> TRet;
428 TMeshByName(const std::string& theName):
432 TRet operator()(SALOMEDS::SObject_ptr theSObj, bool& theIsSuccess)
434 CORBA::Object_var anObj = VISU::SObjectToObject(theSObj);
435 if(!CORBA::is_nil(anObj)){
436 SALOME_MED::MESH_var aMesh = SALOME_MED::MESH::_narrow(anObj);
437 if(!CORBA::is_nil(aMesh)){
438 CORBA::String_var aName = aMesh->getName();
439 theIsSuccess = (myName == aName.in());
441 return TRet(aMesh,SALOMEDS::SObject::_duplicate(theSObj));
448 template<typename TFun>
450 Find(SALOMEDS::SObject_ptr theStartSObj,
451 SALOMEDS::Study_ptr theStudy,
454 bool theIsAllLevels = true)
456 SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator(theStartSObj);
457 anIter->InitEx(theIsAllLevels);
458 for(; anIter->More(); anIter->Next()){
459 SALOMEDS::SObject_var aSObj = anIter->Value();
460 typename TFun::TRet aRet = theFun(aSObj,theIsSuccess);
464 return typename TFun::TRet();
470 VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED)
472 if(CORBA::is_nil(theMED))
475 CORBA::Long aNbMeshes = theMED->getNumberOfMeshes();
476 SALOME_MED::string_array_var aMeshNames = theMED->getMeshNames();
477 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aNbMeshes = "<<aNbMeshes);
479 SALOMEDS::Study_var aStudy = mySObject->GetStudy();
480 SALOMEDS::SObject_var aMedCompSObj = mySObject->GetFather();
482 bool anIsSuccess = false;
483 TSObjectByName::TRet aSObjectByNameRet =
484 Find(aMedCompSObj,aStudy,TSObjectByName("MEDMESH"),anIsSuccess);
486 MESSAGE("VISU_MEDConvertor::Build - Find ('"<<"MEDMESH"<<"') = "<<anIsSuccess);
488 SALOMEDS::SObject_var aMeshesSObj = boost::get<0>(aSObjectByNameRet);
489 for(int iMesh = 0; iMesh < aNbMeshes; iMesh++){
491 CORBA::String_var aMeshName = aMeshNames[iMesh];
492 TMeshByName::TRet aMeshByNameRet =
493 Find(aMeshesSObj,aStudy,TMeshByName(aMeshName.in()),anIsSuccess);
495 MESSAGE("VISU_MEDConvertor::Build - Find aMeshName('"<<aMeshName.in()<<"') = "<<anIsSuccess);
499 PCMesh aMesh = myMeshMap[aMeshName.in()](new TCMesh());
500 SALOME_MED::MESH_var aMEDMesh = boost::get<0>(aMeshByNameRet);
501 aMesh->myDim = aMEDMesh->getSpaceDimension();
502 aMesh->myName = aMeshName.in();
503 aMesh->myPointsDim.resize(aMesh->myDim);
504 aMesh->myMesh = aMEDMesh;
507 MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
509 std::string aName = aMeshName.in();
510 std::replace(aName.begin(),aName.end(),' ','_');
513 std::ostringstream aStream;
514 aStream<<"MEDSUPPORTS_OF_"<<aName;
515 std::string aSupportsName(aStream.str());
516 TSObjectByName::TRet aSObjectByNameRet =
517 Find(aMeshesSObj,aStudy,TSObjectByName(aSupportsName.c_str()),anIsSuccess);
519 MESSAGE("VISU_MEDConvertor::Build - Find aSupportsName('"<<aSupportsName<<"') = "<<anIsSuccess);
523 TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
524 SALOMEDS::SObject_var aSupportsSObj = boost::get<0>(aSObjectByNameRet);
525 SALOMEDS::ChildIterator_var aSupportIterator = aStudy->NewChildIterator(aSupportsSObj);
527 // Fill all MeshOnEntity
528 aSupportIterator->InitEx(true);
529 for(; aSupportIterator->More(); aSupportIterator->Next()){
530 SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value();
532 CORBA::Object_var aMedSupport = VISU::SObjectToObject(aSupportSObj);
533 if(CORBA::is_nil(aMedSupport))
536 SALOME_MED::SUPPORT_var aMEDSupport = SALOME_MED::SUPPORT::_narrow(aMedSupport);
537 if(aMEDSupport->_is_nil())
540 SALOME_MED::MESH_var aMeshOnSupport = aMEDSupport->getMesh();
541 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
542 VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
543 CORBA::String_var aSupportName = aMEDSupport->getName();
545 if(aMEDSupport->isOnAllElements()){
546 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - Support isOnAllElements = '"<<aSupportName<<"' aVEntity = "<<aVEntity);
547 int aNbCells, aCellsSize;
548 //Check, if there is any data on the support?
549 if(aVEntity == NODE_ENTITY){
550 aMesh->myNbPoints = aMeshOnSupport->getNumberOfNodes();
551 aNbCells = aMesh->myNbPoints;
552 aCellsSize = 2*aMesh->myNbPoints;
554 GetCellsSize(aNbCells,aCellsSize,aMeshOnSupport,aVEntity);
557 PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TCMeshOnEntity());
558 aMeshOnEntity->myMeshName = aMeshName.in();
559 aMeshOnEntity->myEntity = aVEntity;
560 aMeshOnEntity->myNbCells = aNbCells;
561 aMeshOnEntity->myCellsSize = aCellsSize;
562 aMeshOnEntity->mySupport = aMEDSupport;
568 aSupportIterator->InitEx(true);
569 for(; aSupportIterator->More(); aSupportIterator->Next()){
570 SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value();
572 CORBA::Object_var aMedSupport = VISU::SObjectToObject(aSupportSObj);
573 if(CORBA::is_nil(aMedSupport))
576 SALOME_MED::SUPPORT_var aMEDSupport = SALOME_MED::SUPPORT::_narrow(aMedSupport);
577 if(aMEDSupport->_is_nil())
580 SALOME_MED::MESH_var aMeshOnSupport = aMEDSupport->getMesh();
581 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
582 VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
583 CORBA::String_var aSupportName = aMEDSupport->getName();
585 SALOME_MED::FAMILY_var aMEDFamily = SALOME_MED::FAMILY::_narrow(aMedSupport);
586 if(!aMEDFamily->_is_nil()) {
587 int aNbCells, aCellsSize;
588 GetCellsSize(aNbCells,aCellsSize,aMEDFamily);
590 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFamily = '"<<aSupportName<<"' aVEntity = "<<aVEntity);
591 TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);
592 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
595 PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
596 TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
597 PCFamily aFamily = aFamilyMap[aSupportName.in()](new TCFamily());
598 aFamily->myName = aSupportName.in();
599 aFamily->myEntity = aVEntity;
600 aFamily->myNbCells = aNbCells;
601 aFamily->myCellsSize = aCellsSize;
602 aFamily->myId = aMEDFamily->getIdentifier();
603 aFamily->myFamily = aMEDFamily;
609 aSupportIterator->InitEx(true);
610 for(; aSupportIterator->More(); aSupportIterator->Next()){
611 SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value();
613 CORBA::Object_var aMedSupport = VISU::SObjectToObject(aSupportSObj);
614 if(CORBA::is_nil(aMedSupport))
617 SALOME_MED::SUPPORT_var aMEDSupport = SALOME_MED::SUPPORT::_narrow(aMedSupport);
618 if(aMEDSupport->_is_nil())
621 SALOME_MED::MESH_var aMeshOnSupport = aMEDSupport->getMesh();
622 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
623 VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
624 CORBA::String_var aSupportName = aMEDSupport->getName();
626 SALOME_MED::GROUP_var aMEDGroup = SALOME_MED::GROUP::_narrow(aMedSupport);
627 if(!aMEDGroup->_is_nil()){
628 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aGroup = '"<<aSupportName<<"' aVEntity = "<<aVEntity);
629 TGroupMap& aGroupMap = aMesh->myGroupMap;
630 PCGroup aGroup = aGroupMap[aSupportName.in()](new TCGroup());
631 aGroup->myGroup = aMEDGroup;
632 aGroup->myName = aSupportName.in();
633 aGroup->myMeshName = aMeshName.in();
634 VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup->myFamilyAndEntitySet;
636 SALOME_MED::Family_array_var aFamilies = aMEDGroup->getFamilies();
637 int iFamilyEnd = aFamilies->length();
638 for(int iFamaily = 0; iFamaily < iFamilyEnd; iFamaily++){
639 SALOME_MED::FAMILY_var aMEDFamily = aFamilies[iFamaily];
640 CORBA::String_var aFamilyName = aMEDFamily->getName();
641 PFamily aFamily = FindFamily(aMesh,aFamilyName.in());
642 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aGroup - aFamilyName = '"<<aFamilyName.in()<<"' = "<<bool(aFamily));
644 TFamilyAndEntity aFamilyAndEntity(aFamilyName.in(),aFamily->myEntity);
645 aFamilyAndEntitySet.insert(aFamilyAndEntity);
647 aGroup->myNbCells += aFamily->myNbCells;
648 aGroup->myCellsSize += aFamily->myCellsSize;
650 VISU::TBindGroups& aBindGroups = aFamily->myGroups;
651 aBindGroups.insert(aSupportName.in());
660 aSObjectByNameRet = Find(aMedCompSObj,aStudy,TSObjectByName("MEDFIELD"),anIsSuccess);
662 SALOMEDS::SObject_var aFieldsSObj = boost::get<0>(aSObjectByNameRet);
663 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - MEDFIELD found.");
664 SALOMEDS::ChildIterator_var aFieldIterator = aStudy->NewChildIterator(aFieldsSObj);
665 for(int iField = 0; aFieldIterator->More(); aFieldIterator->Next(), iField++){
666 SALOMEDS::SObject_var aFieldSObj = aFieldIterator->Value();
667 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFieldName = '"<<GetSObjectName(aFieldSObj)<<"'");
668 SALOMEDS::ChildIterator_var aTimeStampIterator = aStudy->NewChildIterator(aFieldSObj);
669 for(; aTimeStampIterator->More(); aTimeStampIterator->Next()){
670 SALOMEDS::SObject_var aTimeStampSObj = aTimeStampIterator->Value();
671 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<<GetSObjectName(aTimeStampSObj)<<"'");
672 CORBA::Object_var aMedField = VISU::SObjectToObject(aTimeStampSObj);
673 if(CORBA::is_nil(aMedField))
676 SALOME_MED::FIELD_var aMEDField = SALOME_MED::FIELD::_narrow(aMedField);
677 if(aMEDField->_is_nil())
680 SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport();
681 if(aMEDSupport->_is_nil())
684 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
685 VISU::TEntity anEntity = MEDEntityToVTK(aMEntity);
686 SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh();
687 if(aMEDMesh->_is_nil())
690 CORBA::String_var aMeshName = aMEDMesh->getName();
691 CORBA::String_var aFieldName = aMEDField->getName();
693 TMeshMap::iterator aMeshMapIter = myMeshMap.find(aMeshName.in());
694 if(aMeshMapIter == myMeshMap.end())
697 PCMesh aMesh = aMeshMapIter->second;
698 TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
699 TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(anEntity);
700 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
703 PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
704 TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
705 TFieldMap::iterator aFieldMapIter = aFieldMap.find(aFieldName.in());
707 if(aFieldMapIter == aFieldMap.end()){
708 aField = aFieldMap[aFieldName.in()](new TCField());
709 aField->myId = iField;
710 aField->myName = aFieldName.in();
711 aField->myEntity = anEntity;
712 aField->myMeshName = aMeshName.in();
713 aField->myNbComp = aMEDField->getNumberOfComponents();
714 aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
716 MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity->myNbCells = "<<aMeshOnEntity->myNbCells);
717 aField->myCompNames.resize(aField->myNbComp);
718 aField->myUnitNames.resize(aField->myNbComp);
720 aField = aFieldMapIter->second;
722 TValField& aValField = aField->myValField;
723 int anId = aMEDField->getIterationNumber();
724 PCValForTime aValForTime = aValField[anId](new TCValForTime());
725 aValForTime->myId = anId;
726 CORBA::Double aDT = aMEDField->getTime();
727 aValForTime->myTime = TTime(aDT,"");
728 aValForTime->myField = aMEDField;
730 MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<<aMeshName<<
731 "'; myEntity = "<<anEntity<<"; myTime = "<<aDT);
740 VISU_MEDConvertor::Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator)
742 if(theTimeStampIterator->_is_nil()) return NULL;
743 for(; theTimeStampIterator->More(); theTimeStampIterator->Next()){
744 SALOMEDS::SObject_var aTimeStampSObj = theTimeStampIterator->Value();
745 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<<GetSObjectName(aTimeStampSObj)<<"'");
747 CORBA::Object_var aMedField = VISU::SObjectToObject(aTimeStampSObj);
748 if(CORBA::is_nil(aMedField))
751 SALOME_MED::FIELD_var aMEDField = SALOME_MED::FIELD::_narrow(aMedField);
752 if(aMEDField->_is_nil())
755 SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport();
756 if(aMEDSupport->_is_nil())
759 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
760 TEntity aVEntity = MEDEntityToVTK(aMEntity);
761 SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh();
762 if(aMEDMesh->_is_nil()) continue;
763 CORBA::String_var aMeshName = aMEDMesh->getName();
764 CORBA::String_var aFieldName = aMEDField->getName();
766 PCMesh aMesh = myMeshMap[aMeshName.in()](new TCMesh());
767 aMesh->myDim = aMEDMesh->getSpaceDimension();
768 aMesh->myPointsDim.resize(aMesh->myDim);
769 aMesh->myName = aMeshName.in();
770 aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
771 aMesh->myMesh = aMEDMesh;
772 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<<aMeshName<<"'; myDim = "<<aMesh->myDim);
774 TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
775 PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TCMeshOnEntity());
776 aMeshOnEntity->myEntity = aVEntity;
777 aMeshOnEntity->myMeshName = aMeshName.in();
778 aMeshOnEntity->mySupport = aMEDSupport;
779 if(aVEntity == NODE_ENTITY){
780 PCMeshOnEntity aMeshOnEntity2 = aMeshOnEntityMap[CELL_ENTITY](new TCMeshOnEntity());
781 *aMeshOnEntity2 = *aMeshOnEntity;
782 aMeshOnEntity->myEntity = CELL_ENTITY;
783 GetCellsSize(aMesh,aMEDMesh,CELL_ENTITY);
785 PCMeshOnEntity aMeshOnEntity2 = aMeshOnEntityMap[NODE_ENTITY](new TCMeshOnEntity());
786 *aMeshOnEntity2 = *aMeshOnEntity;
787 aMeshOnEntity->myEntity = NODE_ENTITY;
788 GetCellsSize(aMesh,aMEDMesh,NODE_ENTITY);
790 GetCellsSize(aMesh,aMEDMesh,aVEntity);
791 TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
792 TFieldMap::iterator aFieldMapIter = aFieldMap.find(aFieldName.in());
794 if(aFieldMapIter == aFieldMap.end()){
795 aField = aFieldMap[aFieldName.in()](new TCField());
796 CORBA::Short iField = mySObject->Tag();
797 aField->myId = iField;
798 aField->myName = aFieldName.in();
799 aField->myEntity = aVEntity;
800 aField->myMeshName = aMeshName.in();
801 aField->myNbComp = aMEDField->getNumberOfComponents();
802 aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
804 MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity->myNbCells = "<<aMeshOnEntity->myNbCells);
805 aField->myCompNames.resize(aField->myNbComp);
806 aField->myUnitNames.resize(aField->myNbComp);
808 TValField& aValField = aField->myValField;
809 int anId = aMEDField->getIterationNumber();
810 PCValForTime aValForTime = aValField[anId](new TCValForTime());
811 aValForTime->myId = anId;
812 CORBA::Double aDT = aMEDField->getTime();
813 aValForTime->myTime = TTime(aDT,"");
814 aValForTime->myField = aMEDField;
816 MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<<aMeshName<<
817 "'; myEntity = "<<aVEntity<<"; myTime = "<<aDT);
824 VISU_MEDConvertor::LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity,
825 const string& theFamilyName)
828 const string& aMeshName = theMeshOnEntity->myMeshName;
829 const TEntity& aVEntity = theMeshOnEntity->myEntity;
830 PCMesh aMesh = myMeshMap[aMeshName];
832 if(aVEntity == NODE_ENTITY)
833 isPointsUpdated = LoadPoints(aMesh,theFamilyName);
835 isPointsUpdated = LoadPoints(aMesh);
836 int isCellsOnEntityUpdated = LoadCellsOnEntity(aMesh,theMeshOnEntity,theFamilyName);
838 return (isPointsUpdated || isCellsOnEntityUpdated);
843 VISU_MEDConvertor::LoadMeshOnGroup(VISU::PMeshImpl theMesh,
844 const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet)
847 int isPointsUpdated = 0;
848 int isCellsOnEntityUpdated = 0;
849 VISU::TFamilyAndEntitySet::const_iterator aFamilyAndEntitySetIter = theFamilyAndEntitySet.begin();
850 for(; aFamilyAndEntitySetIter != theFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){
851 const string& aFamilyName = aFamilyAndEntitySetIter->first;
852 const VISU::TEntity& aVEntity = aFamilyAndEntitySetIter->second;
853 PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
854 if(aVEntity == VISU::NODE_ENTITY){
855 isPointsUpdated += LoadPoints(theMesh,aFamilyName);
856 isCellsOnEntityUpdated += LoadCellsOnEntity(theMesh,aMeshOnEntity);
858 isPointsUpdated += LoadPoints(theMesh);
859 isCellsOnEntityUpdated += LoadCellsOnEntity(theMesh,aMeshOnEntity,aFamilyName);
863 return (isPointsUpdated || isCellsOnEntityUpdated);
868 VISU_MEDConvertor::LoadFieldOnMesh(VISU::PMeshImpl theMesh,
869 VISU::PMeshOnEntityImpl theMeshOnEntity,
870 VISU::PFieldImpl theField,
871 VISU::PValForTimeImpl theValForTime)
874 int isPointsUpdated = LoadPoints(theMesh);
875 int isCellsOnEntityUpdated = LoadCellsOnEntity(theMesh,theMeshOnEntity);
876 int isFieldUpdated = LoadField(theMesh,theMeshOnEntity,theField,theValForTime);
878 return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated);
882 VISU_MEDConvertor::LoadPoints(VISU::PCMesh theMesh,
883 const string& theFamilyName)
885 //Check on existing family
886 PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
887 PCFamily aFamily = GetFamily(aMeshOnEntity,theFamilyName);
888 //Check on loading already done
889 bool isPointsLoaded = !theMesh->myPointsCoord.empty();
893 else if(!aFamily->mySubMesh.empty())
897 MESSAGE("LoadPoints - isPointsLoaded = "<<isPointsLoaded<<"; theFamilyName = '"<<theFamilyName<<"'");
899 SALOME_MED::MESH_var& aMedMesh = theMesh->myMesh;
900 int iNumElemEnd = aMedMesh->getNumberOfNodes();
901 TMeshImpl::TPointsCoord& aPointsCoord = theMesh->myPointsCoord;
902 if(MYDEBUG) MESSAGE("LoadPoints - iNumElemEnd = "<<iNumElemEnd);
903 if (iNumElemEnd <= 0) throw std::runtime_error("LoadPoints >> There is no points in the mesh !!!");
904 aPointsCoord.resize(theMesh->myDim*iNumElemEnd,0.0);
905 SALOME_MED::double_array_var coord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE);
907 for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
908 for(int iDim = 0, iNumElem2Dim = iNumElem*theMesh->myDim; iDim < theMesh->myDim; iDim++, iNumElem2Dim++)
909 aPointsCoord[iNumElem2Dim] = coord[iNumElem2Dim];
910 if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY");
911 TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aMeshOnEntity->myCellsConn[VTK_VERTEX];
912 aConnForCellType.resize(iNumElemEnd);
913 for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
914 aConnForCellType[iNumElem] = TMeshOnEntityImpl::TConnect(1,iNumElem);
917 if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily SubMesh");
918 SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily;
919 TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[VTK_VERTEX];
920 SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes();
921 SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom[0]);
922 int iNumElemEndTmp = iNumElemEnd;
923 iNumElemEnd = aCellNumForType->length();
924 for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
925 int tmp = aCellNumForType[iNumElem]-1;
926 if(0 > tmp || tmp >= iNumElemEndTmp) {
927 static QString aString;
928 aString.sprintf("LoadPoints >> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEnd,iNumElem,tmp);
929 throw std::runtime_error(aString.latin1());
931 aSubMeshOnCellType.insert(tmp);
939 VISU_MEDConvertor::LoadCellsOnEntity(VISU::PCMesh theMesh,
940 VISU::PCMeshOnEntity theMeshOnEntity,
941 const string& theFamilyName)
943 //Check on existing family
944 PCFamily aFamily = GetFamily(theMeshOnEntity,theFamilyName);
945 //Check on loading already done
946 bool isCellsLoaded = !theMeshOnEntity->myCellsConn.empty();
950 else if(!aFamily->mySubMesh.empty())
953 SALOME_MED::SUPPORT_var& aMedSupport = theMeshOnEntity->mySupport;
954 SALOME_MED::MESH_var aMedMesh = aMedSupport->getMesh();
956 MESSAGE("LoadCellsOnEntity - theFamilyName = '"<<theFamilyName<<"'");
957 MESSAGE("LoadCellsOnEntity - isCellsLoaded = "<<isCellsLoaded<<"; isFamilyPresent = "<<bool(aFamily));
961 SALOME_MED::medGeometryElement* aGeomElems;
962 const TEntity& aVEntity = theMeshOnEntity->myEntity;
963 int iGeomEnd = GetEntity2Geom(aVEntity,aGeomElems);
964 const SALOME_MED::medEntityMesh& aMEntity = VTKEntityToMED(aVEntity);
965 int aNbPoints = theMesh->myPointsCoord.size()/theMesh->myDim;
967 for(int iGeom = 0, aCounter = 0; iGeom < iGeomEnd; iGeom++){
968 SALOME_MED::medGeometryElement aGeom = aGeomElems[iGeom];
969 int aMNbNodes = MEDGeom2NbNodes(aGeom);
970 int aVGeom = MEDGeomToVTK(aGeom);
971 int aVNbNodes = VTKGeom2NbNodes(aVGeom);
972 int iNumElemEnd = aMedMesh->getNumberOfElements(aMEntity,aGeom);
973 if (iNumElemEnd > 0) {
974 SALOME_MED::long_array_var conn =
975 aMedMesh->getConnectivity(SALOME_MED::MED_FULL_INTERLACE,SALOME_MED::MED_NODAL,aMEntity,aGeom);
976 TMeshOnEntityImpl::TConnForCellType& aConnForCellType = theMeshOnEntity->myCellsConn[aVGeom];
977 //APO - aConnForCellType.resize(iNumElemEnd);
978 vector<int> aConnect(aMNbNodes);
979 int aNbConnForElem = conn->length()/iNumElemEnd;
980 if(MYDEBUG) MESSAGE("LoadCellsOnEntity - aGeom = "<<aGeom<<
981 "; iNumElemEnd = "<<iNumElemEnd<<
982 "; aNbConnForElem = "<<aNbConnForElem);
983 for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
984 VISU::TMeshOnEntityImpl::TConnect anArray(aVNbNodes);
985 for (int k = 0, kj = iNumElem*aNbConnForElem; k < aMNbNodes; k++) {
986 aConnect[k] = conn[kj+k] - 1;
989 case SALOME_MED::MED_TETRA4 :
990 case SALOME_MED::MED_TETRA10 :
991 anArray[0] = aConnect[0];
992 anArray[1] = aConnect[1];
993 anArray[2] = aConnect[3];
994 anArray[3] = aConnect[2];
996 case SALOME_MED::MED_PYRA5 :
997 case SALOME_MED::MED_PYRA13 :
998 anArray[0] = aConnect[0];
999 anArray[1] = aConnect[3];
1000 anArray[2] = aConnect[2];
1001 anArray[3] = aConnect[1];
1002 anArray[4] = aConnect[4];
1005 for (int k = 0; k < aVNbNodes; k++)
1006 anArray[k] = aConnect[k];
1008 for (int k = 0; k < aVNbNodes; k++)
1009 if(anArray[k] < 0 || aNbPoints <= anArray[k]){
1010 static QString aString;
1011 aString.sprintf("ImportCells >> aNbPoints(%d) <= anArray[%d][%d]=%d < 0 !!!",aNbPoints,iNumElem,k,anArray[k]);
1012 throw std::runtime_error(aString.latin1());
1014 aConnForCellType.push_back(anArray);
1016 //Workaround for MED Component data structure
1017 int aSize = aConnForCellType.size();
1018 theMeshOnEntity->myCellsFirstIndex[aGeom] = TCMeshOnEntity::TIndexAndSize(aCounter,aSize);
1023 //Filling aFamily SubMesh
1025 SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily;
1026 SALOME_MED::medGeometryElement_array_var aGeoms = aMedFamily->getTypes();
1027 iGeomEnd = aGeoms->length();
1028 if(MYDEBUG) MESSAGE("LoadCellsOnEntity - iGeomEnd = "<<iGeomEnd);
1029 for (int iGeom = 0; iGeom < iGeomEnd; iGeom++) {
1030 SALOME_MED::medGeometryElement aGeom = aGeoms[iGeom];
1031 SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom);
1032 int aVGeom = MEDGeomToVTK(aGeom);
1033 TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVGeom];
1034 int iNumElemEndTmp = theMeshOnEntity->myCellsConn[aVGeom].size();
1035 int iNumElemEnd = aCellNumForType->length();
1036 int aCounter = theMeshOnEntity->myCellsFirstIndex[aGeom].first;
1038 MESSAGE("LoadCellsOnEntity - aGeom = "<<aGeom<<
1039 "; iNumElemEnd = "<<iNumElemEnd<<
1040 "; aCounter = "<<aCounter);
1041 for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
1042 int tmp = aCellNumForType[iNumElem]-aCounter-1;
1043 if(0 > tmp || tmp >= iNumElemEndTmp) {
1044 static QString aString;
1045 aString.sprintf("LoadCellsOnEntity >> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEndTmp,iNumElem,tmp);
1046 throw std::runtime_error(aString.latin1());
1048 aSubMeshOnCellType.insert(tmp);
1055 template<class TArray>
1057 ImportField(TArray& theArray,
1058 VISU::PCMesh theMesh,
1059 VISU::PCField theField,
1060 VISU::PCValForTime theValForTime,
1061 VISU::PCMeshOnEntity theMeshOnEntity)
1063 if(theField->myEntity == NODE_ENTITY){
1064 TValForTimeImpl::TValForCellsWithType& aValForCellsWithType =
1065 theValForTime->myValForCells[VTK_VERTEX];
1066 int iNumElemEnd = theMesh->myPointsCoord.size()/theMesh->myDim*theField->myNbComp;
1067 if(MYDEBUG) MESSAGE("ImportField - iNumElemEnd = "<<iNumElemEnd);
1068 aValForCellsWithType.resize(iNumElemEnd);
1069 for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
1070 aValForCellsWithType[iNumElem] = theArray[iNumElem];
1072 SALOME_MED::medGeometryElement* aGeomElems;
1073 const TEntity& aVEntity = theField->myEntity;
1074 int iGeomEnd = GetEntity2Geom(aVEntity,aGeomElems);
1075 for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
1076 SALOME_MED::medGeometryElement aGeom = aGeomElems[iGeom];
1077 int aVGeom = MEDGeomToVTK(aGeom);
1078 const TCMeshOnEntity::TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity->myCellsFirstIndex;
1079 TCMeshOnEntity::TCellsFirstIndex::const_iterator aCellsFirstIndexIter = aCellsFirstIndex.find(aGeom);
1080 if(aCellsFirstIndexIter != aCellsFirstIndex.end()){
1081 const TCMeshOnEntity::TIndexAndSize& aIndexAndSize = aCellsFirstIndexIter->second;
1082 int iNumElemEnd = aIndexAndSize.second;
1084 MESSAGE("ImportField - aGeom = "<<aGeom<<
1085 "; aIndexAndSize = {"<<aIndexAndSize.first<<
1086 ","<<aIndexAndSize.second<<"}");
1087 TValForTimeImpl::TValForCellsWithType& aValForCellsWithType = theValForTime->myValForCells[aVGeom];
1088 aValForCellsWithType.resize(iNumElemEnd*theField->myNbComp);
1089 for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
1090 for(int k = 0, kj = iNumElem*theField->myNbComp; k < theField->myNbComp; k++)
1091 aValForCellsWithType[kj+k] = theArray[aIndexAndSize.first*theField->myNbComp+kj+k];
1099 VISU_MEDConvertor::LoadField(VISU::PCMesh theMesh,
1100 VISU::PCMeshOnEntity theMeshOnEntity,
1101 VISU::PField theField,
1102 VISU::PCValForTime theValForTime)
1104 //Check on loading already done
1105 if(!theValForTime->myValForCells.empty())
1108 SALOME_MED::FIELD_var aMEDField = theValForTime->myField;
1109 SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField);
1110 if(!aFieldDouble->_is_nil()){
1111 SALOME_MED::double_array_var anArray = aFieldDouble->getValue(SALOME_MED::MED_FULL_INTERLACE);
1112 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDDOUBLE = "<<anArray->length());
1113 ::ImportField(anArray,theMesh,theField,theValForTime,theMeshOnEntity);
1115 SALOME_MED::FIELDINT_ptr aFieldInt = SALOME_MED::FIELDINT::_narrow(aMEDField);
1116 if(!aFieldInt->_is_nil()){
1117 SALOME_MED::long_array_var anArray = aFieldInt->getValue(SALOME_MED::MED_FULL_INTERLACE);
1118 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDINT = "<<anArray->length());
1119 ::ImportField(anArray,theMesh,theField,theValForTime,theMeshOnEntity);