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() && strcmp(aSupportName.in(),"SupportOnAll_MED_") > 0){
547 MESSAGE("VISU_MEDConvertor::Build - Support isOnAllElements = '"<<aSupportName<<
548 "' aVEntity = "<<aVEntity);
549 int aNbCells, aCellsSize;
550 //Check, if there is any data on the support?
551 if(aVEntity == NODE_ENTITY){
552 aMesh->myNbPoints = aMeshOnSupport->getNumberOfNodes();
553 aNbCells = aMesh->myNbPoints;
554 aCellsSize = 2*aMesh->myNbPoints;
556 GetCellsSize(aNbCells,aCellsSize,aMeshOnSupport,aVEntity);
559 PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TCMeshOnEntity());
560 aMeshOnEntity->myMeshName = aMeshName.in();
561 aMeshOnEntity->myEntity = aVEntity;
562 aMeshOnEntity->myNbCells = aNbCells;
563 aMeshOnEntity->myCellsSize = aCellsSize;
564 aMeshOnEntity->mySupport = aMEDSupport;
570 aSupportIterator->InitEx(true);
571 for(; aSupportIterator->More(); aSupportIterator->Next()){
572 SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value();
574 CORBA::Object_var aMedSupport = VISU::SObjectToObject(aSupportSObj);
575 if(CORBA::is_nil(aMedSupport))
578 SALOME_MED::SUPPORT_var aMEDSupport = SALOME_MED::SUPPORT::_narrow(aMedSupport);
579 if(aMEDSupport->_is_nil())
582 SALOME_MED::MESH_var aMeshOnSupport = aMEDSupport->getMesh();
583 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
584 VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
585 CORBA::String_var aSupportName = aMEDSupport->getName();
587 SALOME_MED::FAMILY_var aMEDFamily = SALOME_MED::FAMILY::_narrow(aMedSupport);
588 if(!aMEDFamily->_is_nil()) {
589 TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);
590 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
592 PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
594 int aNbCells = aMeshOnEntity->myNbCells, aCellsSize = aMeshOnEntity->myCellsSize;
595 CORBA::Boolean anIsOnAllElements = aMEDSupport->isOnAllElements();
596 if(!anIsOnAllElements)
597 GetCellsSize(aNbCells,aCellsSize,aMEDFamily);
600 MESSAGE("VISU_MEDConvertor::Build - aFamily = '"<<aSupportName<<
601 "'; anIsOnAllElements = "<<anIsOnAllElements<<
602 "; aVEntity = "<<aVEntity<<
603 "; aNbCells = "<<aNbCells);
606 TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
607 PCFamily aFamily = aFamilyMap[aSupportName.in()](new TCFamily());
608 aFamily->myName = aSupportName.in();
609 aFamily->myEntity = aVEntity;
610 aFamily->myNbCells = aNbCells;
611 aFamily->myCellsSize = aCellsSize;
612 aFamily->myId = aMEDFamily->getIdentifier();
613 aFamily->myFamily = aMEDFamily;
619 aSupportIterator->InitEx(true);
620 for(; aSupportIterator->More(); aSupportIterator->Next()){
621 SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value();
623 CORBA::Object_var aMedSupport = VISU::SObjectToObject(aSupportSObj);
624 if(CORBA::is_nil(aMedSupport))
627 SALOME_MED::SUPPORT_var aMEDSupport = SALOME_MED::SUPPORT::_narrow(aMedSupport);
628 if(aMEDSupport->_is_nil())
631 SALOME_MED::MESH_var aMeshOnSupport = aMEDSupport->getMesh();
632 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
633 VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
634 CORBA::String_var aSupportName = aMEDSupport->getName();
636 SALOME_MED::GROUP_var aMEDGroup = SALOME_MED::GROUP::_narrow(aMedSupport);
637 if(!aMEDGroup->_is_nil()){
638 CORBA::Boolean anIsOnAllElements = aMEDSupport->isOnAllElements();
641 MESSAGE("VISU_MEDConvertor::Build - aGroup = '"<<aSupportName<<
642 "'; anIsOnAllElements = "<<anIsOnAllElements<<
643 "; aVEntity = "<<aVEntity);
645 PCGroup aGroup(new TCGroup());
646 aGroup->myGroup = aMEDGroup;
647 aGroup->myName = aSupportName.in();
648 aGroup->myMeshName = aMeshName.in();
649 VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup->myFamilyAndEntitySet;
651 SALOME_MED::Family_array_var aFamilies = aMEDGroup->getFamilies();
652 int iFamilyEnd = aFamilies->length();
653 for(int iFamaily = 0; iFamaily < iFamilyEnd; iFamaily++){
654 SALOME_MED::FAMILY_var aMEDFamily = aFamilies[iFamaily];
655 CORBA::String_var aFamilyName = aMEDFamily->getName();
656 PFamily aFamily = FindFamily(aMesh,aFamilyName.in());
657 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aGroup - aFamilyName = '"<<aFamilyName.in()<<"' = "<<bool(aFamily));
659 TFamilyAndEntity aFamilyAndEntity(aFamilyName.in(),aFamily->myEntity);
660 aFamilyAndEntitySet.insert(aFamilyAndEntity);
662 aGroup->myNbCells += aFamily->myNbCells;
663 aGroup->myCellsSize += aFamily->myCellsSize;
665 VISU::TBindGroups& aBindGroups = aFamily->myGroups;
666 aBindGroups.insert(aSupportName.in());
670 if(!aGroup->myFamilyAndEntitySet.empty()){
671 TGroupMap& aGroupMap = aMesh->myGroupMap;
672 aGroupMap[aSupportName.in()] = aGroup;
681 aSObjectByNameRet = Find(aMedCompSObj,aStudy,TSObjectByName("MEDFIELD"),anIsSuccess);
683 SALOMEDS::SObject_var aFieldsSObj = boost::get<0>(aSObjectByNameRet);
684 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - MEDFIELD found.");
685 SALOMEDS::ChildIterator_var aFieldIterator = aStudy->NewChildIterator(aFieldsSObj);
686 for(int iField = 0; aFieldIterator->More(); aFieldIterator->Next(), iField++){
687 SALOMEDS::SObject_var aFieldSObj = aFieldIterator->Value();
688 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFieldName = '"<<GetSObjectName(aFieldSObj)<<"'");
689 SALOMEDS::ChildIterator_var aTimeStampIterator = aStudy->NewChildIterator(aFieldSObj);
690 for(; aTimeStampIterator->More(); aTimeStampIterator->Next()){
691 SALOMEDS::SObject_var aTimeStampSObj = aTimeStampIterator->Value();
692 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<<GetSObjectName(aTimeStampSObj)<<"'");
693 CORBA::Object_var aMedField = VISU::SObjectToObject(aTimeStampSObj);
694 if(CORBA::is_nil(aMedField))
697 SALOME_MED::FIELD_var aMEDField = SALOME_MED::FIELD::_narrow(aMedField);
698 if(aMEDField->_is_nil())
701 SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport();
702 if(aMEDSupport->_is_nil())
705 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
706 VISU::TEntity anEntity = MEDEntityToVTK(aMEntity);
707 SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh();
708 if(aMEDMesh->_is_nil())
711 CORBA::String_var aMeshName = aMEDMesh->getName();
712 CORBA::String_var aFieldName = aMEDField->getName();
714 TMeshMap::iterator aMeshMapIter = myMeshMap.find(aMeshName.in());
715 if(aMeshMapIter == myMeshMap.end())
718 PCMesh aMesh = aMeshMapIter->second;
719 TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
720 TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(anEntity);
721 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
724 PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
725 TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
726 TFieldMap::iterator aFieldMapIter = aFieldMap.find(aFieldName.in());
728 if(aFieldMapIter == aFieldMap.end()){
729 aField = aFieldMap[aFieldName.in()](new TCField());
730 aField->myId = iField;
731 aField->myName = aFieldName.in();
732 aField->myEntity = anEntity;
733 aField->myMeshName = aMeshName.in();
734 aField->myNbComp = aMEDField->getNumberOfComponents();
735 aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
737 MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity->myNbCells = "<<aMeshOnEntity->myNbCells);
738 aField->myCompNames.resize(aField->myNbComp);
739 aField->myUnitNames.resize(aField->myNbComp);
741 aField = aFieldMapIter->second;
743 TValField& aValField = aField->myValField;
744 int anId = aMEDField->getIterationNumber();
745 PCValForTime aValForTime = aValField[anId](new TCValForTime());
746 aValForTime->myId = anId;
747 CORBA::Double aDT = aMEDField->getTime();
748 aValForTime->myTime = TTime(aDT,"");
749 aValForTime->myField = aMEDField;
751 MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<<aMeshName<<
752 "'; myEntity = "<<anEntity<<"; myTime = "<<aDT);
761 VISU_MEDConvertor::Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator)
763 if(theTimeStampIterator->_is_nil()) return NULL;
764 for(; theTimeStampIterator->More(); theTimeStampIterator->Next()){
765 SALOMEDS::SObject_var aTimeStampSObj = theTimeStampIterator->Value();
766 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<<GetSObjectName(aTimeStampSObj)<<"'");
768 CORBA::Object_var aMedField = VISU::SObjectToObject(aTimeStampSObj);
769 if(CORBA::is_nil(aMedField))
772 SALOME_MED::FIELD_var aMEDField = SALOME_MED::FIELD::_narrow(aMedField);
773 if(aMEDField->_is_nil())
776 SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport();
777 if(aMEDSupport->_is_nil())
780 SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
781 TEntity aVEntity = MEDEntityToVTK(aMEntity);
782 SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh();
783 if(aMEDMesh->_is_nil()) continue;
784 CORBA::String_var aMeshName = aMEDMesh->getName();
785 CORBA::String_var aFieldName = aMEDField->getName();
787 PCMesh aMesh = myMeshMap[aMeshName.in()](new TCMesh());
788 aMesh->myDim = aMEDMesh->getSpaceDimension();
789 aMesh->myPointsDim.resize(aMesh->myDim);
790 aMesh->myName = aMeshName.in();
791 aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
792 aMesh->myMesh = aMEDMesh;
793 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<<aMeshName<<"'; myDim = "<<aMesh->myDim);
795 TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
796 PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TCMeshOnEntity());
797 aMeshOnEntity->myEntity = aVEntity;
798 aMeshOnEntity->myMeshName = aMeshName.in();
799 aMeshOnEntity->mySupport = aMEDSupport;
800 if(aVEntity == NODE_ENTITY){
801 PCMeshOnEntity aMeshOnEntity2 = aMeshOnEntityMap[CELL_ENTITY](new TCMeshOnEntity());
802 *aMeshOnEntity2 = *aMeshOnEntity;
803 aMeshOnEntity->myEntity = CELL_ENTITY;
804 GetCellsSize(aMesh,aMEDMesh,CELL_ENTITY);
806 PCMeshOnEntity aMeshOnEntity2 = aMeshOnEntityMap[NODE_ENTITY](new TCMeshOnEntity());
807 *aMeshOnEntity2 = *aMeshOnEntity;
808 aMeshOnEntity->myEntity = NODE_ENTITY;
809 GetCellsSize(aMesh,aMEDMesh,NODE_ENTITY);
811 GetCellsSize(aMesh,aMEDMesh,aVEntity);
812 TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
813 TFieldMap::iterator aFieldMapIter = aFieldMap.find(aFieldName.in());
815 if(aFieldMapIter == aFieldMap.end()){
816 aField = aFieldMap[aFieldName.in()](new TCField());
817 CORBA::Short iField = mySObject->Tag();
818 aField->myId = iField;
819 aField->myName = aFieldName.in();
820 aField->myEntity = aVEntity;
821 aField->myMeshName = aMeshName.in();
822 aField->myNbComp = aMEDField->getNumberOfComponents();
823 aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
825 MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity->myNbCells = "<<aMeshOnEntity->myNbCells);
826 aField->myCompNames.resize(aField->myNbComp);
827 aField->myUnitNames.resize(aField->myNbComp);
829 TValField& aValField = aField->myValField;
830 int anId = aMEDField->getIterationNumber();
831 PCValForTime aValForTime = aValField[anId](new TCValForTime());
832 aValForTime->myId = anId;
833 CORBA::Double aDT = aMEDField->getTime();
834 aValForTime->myTime = TTime(aDT,"");
835 aValForTime->myField = aMEDField;
837 MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<<aMeshName<<
838 "'; myEntity = "<<aVEntity<<"; myTime = "<<aDT);
845 VISU_MEDConvertor::LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity,
846 const string& theFamilyName)
849 const string& aMeshName = theMeshOnEntity->myMeshName;
850 const TEntity& aVEntity = theMeshOnEntity->myEntity;
851 PCMesh aMesh = myMeshMap[aMeshName];
853 if(aVEntity == NODE_ENTITY)
854 isPointsUpdated = LoadPoints(aMesh,theFamilyName);
856 isPointsUpdated = LoadPoints(aMesh);
857 int isCellsOnEntityUpdated = LoadCellsOnEntity(aMesh,theMeshOnEntity,theFamilyName);
859 return (isPointsUpdated || isCellsOnEntityUpdated);
864 VISU_MEDConvertor::LoadMeshOnGroup(VISU::PMeshImpl theMesh,
865 const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet)
868 int isPointsUpdated = 0;
869 int isCellsOnEntityUpdated = 0;
870 VISU::TFamilyAndEntitySet::const_iterator aFamilyAndEntitySetIter = theFamilyAndEntitySet.begin();
871 for(; aFamilyAndEntitySetIter != theFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){
872 const string& aFamilyName = aFamilyAndEntitySetIter->first;
873 const VISU::TEntity& aVEntity = aFamilyAndEntitySetIter->second;
874 PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
875 if(aVEntity == VISU::NODE_ENTITY){
876 isPointsUpdated += LoadPoints(theMesh,aFamilyName);
877 isCellsOnEntityUpdated += LoadCellsOnEntity(theMesh,aMeshOnEntity);
879 isPointsUpdated += LoadPoints(theMesh);
880 isCellsOnEntityUpdated += LoadCellsOnEntity(theMesh,aMeshOnEntity,aFamilyName);
884 return (isPointsUpdated || isCellsOnEntityUpdated);
889 VISU_MEDConvertor::LoadFieldOnMesh(VISU::PMeshImpl theMesh,
890 VISU::PMeshOnEntityImpl theMeshOnEntity,
891 VISU::PFieldImpl theField,
892 VISU::PValForTimeImpl theValForTime)
895 int isPointsUpdated = LoadPoints(theMesh);
896 int isCellsOnEntityUpdated = LoadCellsOnEntity(theMesh,theMeshOnEntity);
897 int isFieldUpdated = LoadField(theMesh,theMeshOnEntity,theField,theValForTime);
899 return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated);
903 VISU_MEDConvertor::LoadPoints(VISU::PCMesh theMesh,
904 const string& theFamilyName)
906 //Check on existing family
907 PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
908 PCFamily aFamily = GetFamily(aMeshOnEntity,theFamilyName);
909 //Check on loading already done
910 bool isPointsLoaded = !theMesh->myPointsCoord.empty();
914 else if(!aFamily->mySubMesh.empty())
918 MESSAGE("LoadPoints - isPointsLoaded = "<<isPointsLoaded<<"; theFamilyName = '"<<theFamilyName<<"'");
920 SALOME_MED::MESH_var& aMedMesh = theMesh->myMesh;
921 int iNumElemEnd = aMedMesh->getNumberOfNodes();
922 TMeshImpl::TPointsCoord& aPointsCoord = theMesh->myPointsCoord;
924 if(MYDEBUG) MESSAGE("LoadPoints - iNumElemEnd = "<<iNumElemEnd);
926 if (iNumElemEnd <= 0)
927 throw std::runtime_error("LoadPoints >> There is no points in the mesh !!!");
929 aPointsCoord.resize(theMesh->myDim*iNumElemEnd,0.0);
930 SALOME_MED::double_array_var coord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE);
932 for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
933 for(int iDim = 0, iNumElem2Dim = iNumElem*theMesh->myDim; iDim < theMesh->myDim; iDim++, iNumElem2Dim++)
934 aPointsCoord[iNumElem2Dim] = coord[iNumElem2Dim];
936 if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY");
938 TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aMeshOnEntity->myCellsConn[VTK_VERTEX];
939 aConnForCellType.resize(iNumElemEnd);
940 for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
941 aConnForCellType[iNumElem] = TMeshOnEntityImpl::TConnect(1,iNumElem);
944 if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily SubMesh");
946 SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily;
947 CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements();
948 TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[VTK_VERTEX];
950 if(!anIsOnAllElements){
951 SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes();
952 SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom[0]);
953 int iNumElemEndTmp = iNumElemEnd;
954 iNumElemEnd = aCellNumForType->length();
955 for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
956 int tmp = aCellNumForType[iNumElem]-1;
957 if(0 > tmp || tmp >= iNumElemEndTmp) {
958 static QString aString;
959 aString.sprintf("LoadPoints >> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEnd,iNumElem,tmp);
960 throw std::runtime_error(aString.latin1());
962 aSubMeshOnCellType.insert(tmp);
965 for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++){
966 aSubMeshOnCellType.insert(iNumElem);
975 VISU_MEDConvertor::LoadCellsOnEntity(VISU::PCMesh theMesh,
976 VISU::PCMeshOnEntity theMeshOnEntity,
977 const string& theFamilyName)
979 //Check on existing family
980 PCFamily aFamily = GetFamily(theMeshOnEntity,theFamilyName);
981 //Check on loading already done
982 bool isCellsLoaded = !theMeshOnEntity->myCellsConn.empty();
986 else if(!aFamily->mySubMesh.empty())
989 SALOME_MED::SUPPORT_var& aMedSupport = theMeshOnEntity->mySupport;
990 SALOME_MED::MESH_var aMedMesh = aMedSupport->getMesh();
992 MESSAGE("LoadCellsOnEntity - theFamilyName = '"<<theFamilyName<<"'");
993 MESSAGE("LoadCellsOnEntity - isCellsLoaded = "<<isCellsLoaded<<"; isFamilyPresent = "<<bool(aFamily));
997 SALOME_MED::medGeometryElement* aGeomElems;
998 const TEntity& aVEntity = theMeshOnEntity->myEntity;
999 int iGeomEnd = GetEntity2Geom(aVEntity,aGeomElems);
1000 const SALOME_MED::medEntityMesh& aMEntity = VTKEntityToMED(aVEntity);
1001 int aNbPoints = theMesh->myPointsCoord.size()/theMesh->myDim;
1003 for(int iGeom = 0, aCounter = 0; iGeom < iGeomEnd; iGeom++){
1004 SALOME_MED::medGeometryElement aGeom = aGeomElems[iGeom];
1005 int aMNbNodes = MEDGeom2NbNodes(aGeom);
1006 int aVGeom = MEDGeomToVTK(aGeom);
1007 int aVNbNodes = VTKGeom2NbNodes(aVGeom);
1008 int iNumElemEnd = aMedMesh->getNumberOfElements(aMEntity,aGeom);
1009 if (iNumElemEnd > 0) {
1010 SALOME_MED::long_array_var conn =
1011 aMedMesh->getConnectivity(SALOME_MED::MED_FULL_INTERLACE,SALOME_MED::MED_NODAL,aMEntity,aGeom);
1012 TMeshOnEntityImpl::TConnForCellType& aConnForCellType = theMeshOnEntity->myCellsConn[aVGeom];
1013 //APO - aConnForCellType.resize(iNumElemEnd);
1014 vector<int> aConnect(aMNbNodes);
1015 int aNbConnForElem = conn->length()/iNumElemEnd;
1016 if(MYDEBUG) MESSAGE("LoadCellsOnEntity - aGeom = "<<aGeom<<
1017 "; iNumElemEnd = "<<iNumElemEnd<<
1018 "; aNbConnForElem = "<<aNbConnForElem);
1019 for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
1020 VISU::TMeshOnEntityImpl::TConnect anArray(aVNbNodes);
1021 for (int k = 0, kj = iNumElem*aNbConnForElem; k < aMNbNodes; k++) {
1022 aConnect[k] = conn[kj+k] - 1;
1025 case SALOME_MED::MED_TETRA4 :
1026 case SALOME_MED::MED_TETRA10 :
1027 anArray[0] = aConnect[0];
1028 anArray[1] = aConnect[1];
1029 anArray[2] = aConnect[3];
1030 anArray[3] = aConnect[2];
1032 case SALOME_MED::MED_PYRA5 :
1033 case SALOME_MED::MED_PYRA13 :
1034 anArray[0] = aConnect[0];
1035 anArray[1] = aConnect[3];
1036 anArray[2] = aConnect[2];
1037 anArray[3] = aConnect[1];
1038 anArray[4] = aConnect[4];
1041 for (int k = 0; k < aVNbNodes; k++)
1042 anArray[k] = aConnect[k];
1044 for (int k = 0; k < aVNbNodes; k++)
1045 if(anArray[k] < 0 || aNbPoints <= anArray[k]){
1046 static QString aString;
1047 aString.sprintf("ImportCells >> aNbPoints(%d) <= anArray[%d][%d]=%d < 0 !!!",aNbPoints,iNumElem,k,anArray[k]);
1048 throw std::runtime_error(aString.latin1());
1050 aConnForCellType.push_back(anArray);
1052 //Workaround for MED Component data structure
1053 int aSize = aConnForCellType.size();
1054 theMeshOnEntity->myCellsFirstIndex[aGeom] = TCMeshOnEntity::TIndexAndSize(aCounter,aSize);
1059 //Filling aFamily SubMesh
1061 SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily;
1062 CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements();
1063 if(!anIsOnAllElements){
1064 SALOME_MED::medGeometryElement_array_var aGeoms = aMedFamily->getTypes();
1065 iGeomEnd = aGeoms->length();
1066 if(MYDEBUG) MESSAGE("LoadCellsOnEntity - iGeomEnd = "<<iGeomEnd);
1067 for (int iGeom = 0; iGeom < iGeomEnd; iGeom++) {
1068 SALOME_MED::medGeometryElement aGeom = aGeoms[iGeom];
1069 SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom);
1070 int aVGeom = MEDGeomToVTK(aGeom);
1071 TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVGeom];
1072 int iNumElemEndTmp = theMeshOnEntity->myCellsConn[aVGeom].size();
1073 int iNumElemEnd = aCellNumForType->length();
1074 int aCounter = theMeshOnEntity->myCellsFirstIndex[aGeom].first;
1076 MESSAGE("LoadCellsOnEntity - aGeom = "<<aGeom<<
1077 "; iNumElemEnd = "<<iNumElemEnd<<
1078 "; aCounter = "<<aCounter);
1079 for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
1080 int tmp = aCellNumForType[iNumElem]-aCounter-1;
1081 if(0 > tmp || tmp >= iNumElemEndTmp) {
1082 static QString aString;
1083 aString.sprintf("LoadCellsOnEntity >> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEndTmp,iNumElem,tmp);
1084 throw std::runtime_error(aString.latin1());
1086 aSubMeshOnCellType.insert(tmp);
1090 const TMeshOnEntityImpl::TCellsConn& aCellsConn = theMeshOnEntity->myCellsConn;
1091 TMeshOnEntityImpl::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin();
1092 for(; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){
1093 int aVGeom = aCellsConnIter->first;
1094 const TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aCellsConnIter->second;
1095 TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVGeom];
1096 int iNumElemEnd = aConnForCellType.size();
1097 for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
1098 aSubMeshOnCellType.insert(iNumElem);
1105 template<class TArray>
1107 ImportField(TArray& theArray,
1108 VISU::PCMesh theMesh,
1109 VISU::PCField theField,
1110 VISU::PCValForTime theValForTime,
1111 VISU::PCMeshOnEntity theMeshOnEntity)
1113 if(theField->myEntity == NODE_ENTITY){
1114 TValForTimeImpl::TValForCellsWithType& aValForCellsWithType =
1115 theValForTime->myValForCells[VTK_VERTEX];
1116 int iNumElemEnd = theMesh->myPointsCoord.size()/theMesh->myDim*theField->myNbComp;
1117 if(MYDEBUG) MESSAGE("ImportField - iNumElemEnd = "<<iNumElemEnd);
1118 aValForCellsWithType.resize(iNumElemEnd);
1119 for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
1120 aValForCellsWithType[iNumElem] = theArray[iNumElem];
1122 SALOME_MED::medGeometryElement* aGeomElems;
1123 const TEntity& aVEntity = theField->myEntity;
1124 int iGeomEnd = GetEntity2Geom(aVEntity,aGeomElems);
1125 for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
1126 SALOME_MED::medGeometryElement aGeom = aGeomElems[iGeom];
1127 int aVGeom = MEDGeomToVTK(aGeom);
1128 const TCMeshOnEntity::TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity->myCellsFirstIndex;
1129 TCMeshOnEntity::TCellsFirstIndex::const_iterator aCellsFirstIndexIter = aCellsFirstIndex.find(aGeom);
1130 if(aCellsFirstIndexIter != aCellsFirstIndex.end()){
1131 const TCMeshOnEntity::TIndexAndSize& aIndexAndSize = aCellsFirstIndexIter->second;
1132 int iNumElemEnd = aIndexAndSize.second;
1134 MESSAGE("ImportField - aGeom = "<<aGeom<<
1135 "; aIndexAndSize = {"<<aIndexAndSize.first<<
1136 ","<<aIndexAndSize.second<<"}");
1137 TValForTimeImpl::TValForCellsWithType& aValForCellsWithType = theValForTime->myValForCells[aVGeom];
1138 aValForCellsWithType.resize(iNumElemEnd*theField->myNbComp);
1139 for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
1140 for(int k = 0, kj = iNumElem*theField->myNbComp; k < theField->myNbComp; k++)
1141 aValForCellsWithType[kj+k] = theArray[aIndexAndSize.first*theField->myNbComp+kj+k];
1149 VISU_MEDConvertor::LoadField(VISU::PCMesh theMesh,
1150 VISU::PCMeshOnEntity theMeshOnEntity,
1151 VISU::PField theField,
1152 VISU::PCValForTime theValForTime)
1154 //Check on loading already done
1155 if(!theValForTime->myValForCells.empty())
1158 SALOME_MED::FIELD_var aMEDField = theValForTime->myField;
1159 SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField);
1160 if(!aFieldDouble->_is_nil()){
1161 SALOME_MED::double_array_var anArray = aFieldDouble->getValue(SALOME_MED::MED_FULL_INTERLACE);
1162 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDDOUBLE = "<<anArray->length());
1163 ::ImportField(anArray,theMesh,theField,theValForTime,theMeshOnEntity);
1165 SALOME_MED::FIELDINT_ptr aFieldInt = SALOME_MED::FIELDINT::_narrow(aMEDField);
1166 if(!aFieldInt->_is_nil()){
1167 SALOME_MED::long_array_var anArray = aFieldInt->getValue(SALOME_MED::MED_FULL_INTERLACE);
1168 if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDINT = "<<anArray->length());
1169 ::ImportField(anArray,theMesh,theField,theValForTime,theMeshOnEntity);