1 // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
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 : SMESH_MEDMesh_i.cxx
28 #include "SMESH_MEDMesh_i.hxx"
29 #include "SMESH_Mesh_i.hxx"
31 #include "SMESHDS_Mesh.hxx"
32 #include "SMESHDS_SubMesh.hxx"
35 #include <TopExp_Explorer.hxx>
37 #include <TopoDS_Iterator.hxx>
38 #include <TopoDS_Compound.hxx>
39 #include <TopoDS_CompSolid.hxx>
40 #include <TopoDS_Solid.hxx>
41 #include <TopoDS_Shell.hxx>
42 #include <TopoDS_Face.hxx>
43 #include <TopoDS_Wire.hxx>
44 #include <TopoDS_Edge.hxx>
45 #include <TopoDS_Vertex.hxx>
46 #include <TopoDS_Shape.hxx>
47 #include <TopTools_MapOfShape.hxx>
49 #include "utilities.h"
50 #include "Utils_CorbaException.hxx"
52 #include "SMESH_MEDSupport_i.hxx"
53 #include "SMESH_MEDFamily_i.hxx"
55 # include "Utils_ORB_INIT.hxx"
56 # include "Utils_SINGLETON.hxx"
62 //=============================================================================
66 //=============================================================================
67 // PN Est-ce un const ?
68 SMESH_MEDMesh_i::SMESH_MEDMesh_i()
70 BEGIN_OF("Default Constructor SMESH_MEDMesh_i");
71 END_OF("Default Constructor SMESH_MEDMesh_i");
74 //=============================================================================
78 //=============================================================================
79 SMESH_MEDMesh_i::~SMESH_MEDMesh_i()
83 //=============================================================================
87 //=============================================================================
88 SMESH_MEDMesh_i::SMESH_MEDMesh_i(::SMESH_Mesh_i * m_i):_meshId(""),
90 _creeFamily(false), _famIdent(0), _indexElts(0), _indexEnts(0)
93 _meshDS = _mesh_i->GetImpl().GetMeshDS();
95 BEGIN_OF("Constructor SMESH_MEDMesh_i");
96 END_OF("Constructor SMESH_MEDMesh_i");
99 //=============================================================================
101 * CORBA: Accessor for Name
103 //=============================================================================
104 char *SMESH_MEDMesh_i::getName() throw(SALOME::SALOME_Exception)
107 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
108 SALOME::INTERNAL_ERROR);
112 // A COMPLETER PAR LE NOM DU MAILLAGE
113 //return CORBA::string_dup(_mesh_i->getName().c_str());
114 return CORBA::string_dup("toto");
118 MESSAGE("Exception en accedant au nom");
119 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object",
120 SALOME::INTERNAL_ERROR);
124 //=============================================================================
126 * CORBA: Accessor for corbaindex cuisine interne
128 //=============================================================================
129 CORBA::Long SMESH_MEDMesh_i::getCorbaIndex()throw(SALOME::SALOME_Exception)
131 MESSAGE("Non Implemente");
132 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
135 //=============================================================================
137 * CORBA: Accessor for Space Dimension
139 //=============================================================================
140 CORBA::Long SMESH_MEDMesh_i::getSpaceDimension()throw(SALOME::SALOME_Exception)
142 // PN : Il semblerait que la dimension soit fixee a 3
144 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
145 SALOME::INTERNAL_ERROR);
149 //=============================================================================
151 * CORBA: Accessor for Mesh Dimension
153 //=============================================================================
154 CORBA::Long SMESH_MEDMesh_i::getMeshDimension()throw(SALOME::SALOME_Exception)
157 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
158 SALOME::INTERNAL_ERROR);
159 // PN : Il semblerait que la dimension soit fixee a 3
161 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
162 SALOME::INTERNAL_ERROR);
166 //=============================================================================
168 * CORBA: Accessor for Coordinates System
170 //=============================================================================
171 char *SMESH_MEDMesh_i::getCoordinateSystem() throw(SALOME::SALOME_Exception)
174 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
175 SALOME::INTERNAL_ERROR);
176 // PN : En dur. Non encore prevu
179 string systcoo = "CARTESIEN";
180 return CORBA::string_dup(systcoo.c_str());
184 MESSAGE("Exception en accedant au maillage");
185 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object",
186 SALOME::INTERNAL_ERROR);
190 //=============================================================================
192 * CORBA: Accessor for Coordinates
194 //=============================================================================
195 Engines::double_array * SMESH_MEDMesh_i::getCoordinates(
196 SALOME_MED::medModeSwitch typeSwitch) throw(SALOME::SALOME_Exception)
199 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
200 SALOME::INTERNAL_ERROR);
201 Engines::double_array_var myseq = new Engines::double_array;
205 int spaceDimension = 3;
206 int nbNodes = _meshDS->NbNodes();
208 myseq->length(nbNodes * spaceDimension);
211 SMDS_Iterator<const SMDS_MeshNode *> * itNodes=_meshDS->nodesIterator();
212 while(itNodes->more())
214 const SMDS_MeshNode* node = itNodes->next();
216 if (typeSwitch == SALOME_MED::MED_FULL_INTERLACE)
218 myseq[i * 3] = node->X();
219 myseq[i * 3 + 1] = node->Y();
220 myseq[i * 3 + 2] = node->Z();
221 SCRUTE(myseq[i * 3]);
222 SCRUTE(myseq[i * 3 + 1]);
223 SCRUTE(myseq[i * 3 + 2]);
227 ASSERT(typeSwitch == SALOME_MED::MED_NO_INTERLACE);
228 myseq[i] = node->X();
229 myseq[i + nbNodes] = node->Y();
230 myseq[i + (nbNodes * 2)] = node->Z();
232 SCRUTE(myseq[i + nbNodes]);
233 SCRUTE(myseq[i + (nbNodes * 2)]);
241 MESSAGE("Exception en accedant aux coordonnees");
242 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object",
243 SALOME::INTERNAL_ERROR);
245 return myseq._retn();
248 //=============================================================================
250 * CORBA: Accessor for Coordinates Names
252 //=============================================================================
253 Engines::string_array *
254 SMESH_MEDMesh_i::getCoordinatesNames()throw(SALOME::SALOME_Exception)
257 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
258 SALOME::INTERNAL_ERROR);
259 Engines::string_array_var myseq = new Engines::string_array;
263 int spaceDimension = 3;
264 myseq->length(spaceDimension);
265 myseq[0] = CORBA::string_dup("x");
266 myseq[1] = CORBA::string_dup("y");
267 myseq[2] = CORBA::string_dup("z");
271 MESSAGE("Exception en accedant aux noms des coordonnees");
272 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object",
273 SALOME::INTERNAL_ERROR);
275 return myseq._retn();
279 //=============================================================================
281 * CORBA: Accessor for Coordinates Units
283 //=============================================================================
284 Engines::string_array *
285 SMESH_MEDMesh_i::getCoordinatesUnits()throw(SALOME::SALOME_Exception)
288 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
289 SALOME::INTERNAL_ERROR);
290 Engines::string_array_var myseq = new Engines::string_array;
294 int spaceDimension = 3;
295 myseq->length(spaceDimension);
296 myseq[0] = CORBA::string_dup("m");
297 myseq[1] = CORBA::string_dup("m");
298 myseq[2] = CORBA::string_dup("m");
302 MESSAGE("Exception en accedant aux unites des coordonnees");
303 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object",
304 SALOME::INTERNAL_ERROR);
306 return myseq._retn();
309 //=============================================================================
311 * CORBA: Accessor for Number of Nodes
313 //=============================================================================
314 CORBA::Long SMESH_MEDMesh_i::getNumberOfNodes()throw(SALOME::SALOME_Exception)
317 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
318 SALOME::INTERNAL_ERROR);
321 return _meshDS->NbNodes();
325 MESSAGE("Exception en accedant au nombre de noeuds");
326 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object",
327 SALOME::INTERNAL_ERROR);
331 //=============================================================================
333 * CORBA: Accessor for number of Types
335 //=============================================================================
336 CORBA::Long SMESH_MEDMesh_i::getNumberOfTypes(SALOME_MED::medEntityMesh entity)
337 throw(SALOME::SALOME_Exception)
340 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
341 SALOME::INTERNAL_ERROR);
347 if (_mapNbTypes.find(entity) != _mapNbTypes.end())
348 retour = _mapNbTypes[entity];
353 MESSAGE("Exception en accedant au nombre de Types");
354 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object",
355 SALOME::INTERNAL_ERROR);
359 //=============================================================================
361 * CORBA: Accessor for existing geometry element types
362 * Not implemented for MED_ALL_ENTITIES
364 //=============================================================================
365 SALOME_MED::medGeometryElement_array *
366 SMESH_MEDMesh_i::getTypes(SALOME_MED::medEntityMesh entity) throw(SALOME::
370 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
371 SALOME::INTERNAL_ERROR);
372 if (entity == SALOME_MED::MED_ALL_ENTITIES)
373 THROW_SALOME_CORBA_EXCEPTION("Not implemented for MED_ALL_ENTITIES",
377 SALOME_MED::medGeometryElement_array_var myseq =
378 new SALOME_MED::medGeometryElement_array;
381 if (_mapNbTypes.find(entity) == _mapNbTypes.end())
382 THROW_SALOME_CORBA_EXCEPTION("No Such Entity in the mesh",
384 int nbTypes = _mapNbTypes[entity];
386 myseq->length(nbTypes);
388 if (_mapIndToVectTypes.find(entity) == _mapIndToVectTypes.end())
389 THROW_SALOME_CORBA_EXCEPTION("No Such Entity in the mesh",
390 SALOME::INTERNAL_ERROR);
392 int index = _mapIndToVectTypes[entity];
393 ASSERT(_TypesId[index].size() != 0);
395 vector < SALOME_MED::medGeometryElement >::iterator it;
396 for (it = _TypesId[index].begin(); it != _TypesId[index].end(); it++)
403 MESSAGE("Exception en accedant aux differents types");
404 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object",
405 SALOME::INTERNAL_ERROR);
407 return myseq._retn();
410 //=============================================================================
412 * CORBA: Returns number of elements of type medGeometryElement
413 * Not implemented for MED_ALL_ELEMENTS
414 * implemented for MED_ALL_ENTITIES
416 * Dans cette implementation, il n est pas prevu de tenir compte du entity
417 * qui ne doit pas pouvoir avoir deux valeurs differentes pour un geomElement
419 //=============================================================================
420 CORBA::Long SMESH_MEDMesh_i::getNumberOfElements(SALOME_MED::
421 medEntityMesh entity,
422 SALOME_MED::medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
425 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
426 SALOME::INTERNAL_ERROR);
427 if (geomElement == SALOME_MED::MED_ALL_ELEMENTS)
428 THROW_SALOME_CORBA_EXCEPTION("Not implemented for MED_ALL_ELEMENTS",
436 if (_mapIndToSeqElts.find(geomElement) != _mapIndToSeqElts.end())
438 int index = _mapIndToSeqElts[geomElement];
439 retour = _seq_elemId[index]->length();
445 MESSAGE("Exception en accedant au nombre d élements");
446 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object",
447 SALOME::INTERNAL_ERROR);
451 //=============================================================================
453 * CORBA: Accessor for connectivities
455 //=============================================================================
456 Engines::long_array *
457 SMESH_MEDMesh_i::getConnectivity(SALOME_MED::medModeSwitch typeSwitch,
458 SALOME_MED::medConnectivity mode, SALOME_MED::medEntityMesh entity,
459 SALOME_MED::medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
462 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
463 SALOME::INTERNAL_ERROR);
464 if (mode != SALOME_MED::MED_NODAL)
465 THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
466 if (typeSwitch == SALOME_MED::MED_NO_INTERLACE)
467 THROW_SALOME_CORBA_EXCEPTION("Not Yet Implemented", SALOME::BAD_PARAM);
471 // Faut-il renvoyer un pointeur vide ???
472 if (_mapIndToSeqElts.find(geomElement) != _mapIndToSeqElts.end())
473 THROW_SALOME_CORBA_EXCEPTION("No Such Element in the mesh",
476 int index = _mapIndToSeqElts[geomElement];
477 return _seq_elemId[index]._retn();
480 //=============================================================================
482 * CORBA: Accessor for connectivities
484 //=============================================================================
485 Engines::long_array *
486 SMESH_MEDMesh_i::getConnectivityIndex(SALOME_MED::medConnectivity mode,
487 SALOME_MED::medEntityMesh entity) throw(SALOME::SALOME_Exception)
489 MESSAGE("Pas Implemente dans SMESH");
490 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
494 //=============================================================================
496 * CORBA: Find an element corresponding to the given connectivity
498 //=============================================================================
499 CORBA::Long SMESH_MEDMesh_i::getElementNumber(SALOME_MED::medConnectivity mode,
500 SALOME_MED::medEntityMesh entity,
501 SALOME_MED::medGeometryElement type,
502 const Engines::long_array & connectivity)throw(SALOME::SALOME_Exception)
504 const char *LOC = "getElementNumber ";
505 MESSAGE(LOC << "Pas Implemente dans SMESH");
506 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
510 //=============================================================================
512 * CORBA: Accessor for Ascendant connectivities
513 * not implemented for MED_ALL_ENTITIES and MED_MAILLE
515 //=============================================================================
516 Engines::long_array *
517 SMESH_MEDMesh_i::getReverseConnectivity(SALOME_MED::
518 medConnectivity mode) throw(SALOME::SALOME_Exception)
520 MESSAGE("Pas Implemente dans SMESH");
521 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
525 //=============================================================================
527 * CORBA: Accessor for connectivities
529 //=============================================================================
530 Engines::long_array *
531 SMESH_MEDMesh_i::getReverseConnectivityIndex(SALOME_MED::
532 medConnectivity mode) throw(SALOME::SALOME_Exception)
534 MESSAGE("Pas Implemente dans SMESH");
535 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
539 //=============================================================================
541 * CORBA: Returns number of families within the mesh
543 //=============================================================================
544 CORBA::Long SMESH_MEDMesh_i::getNumberOfFamilies(SALOME_MED::
545 medEntityMesh entity) throw(SALOME::SALOME_Exception)
547 if (_creeFamily == false)
550 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
551 SALOME::INTERNAL_ERROR);
552 return _families.size();
555 //=============================================================================
557 * CORBA: Returns number of groups within the mesh
559 //=============================================================================
560 CORBA::Long SMESH_MEDMesh_i::getNumberOfGroups(SALOME_MED::medEntityMesh entity)
561 throw(SALOME::SALOME_Exception)
564 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
565 SALOME::INTERNAL_ERROR);
566 MESSAGE(" Pas d implementation des groupes dans SMESH");
570 //=============================================================================
572 * CORBA: Returns references for families within the mesh
574 //=============================================================================
575 SALOME_MED::Family_array *
576 SMESH_MEDMesh_i::getFamilies(SALOME_MED::
577 medEntityMesh entity) throw(SALOME::SALOME_Exception)
579 if (_creeFamily == false)
582 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
583 SALOME::INTERNAL_ERROR);
584 SALOME_MED::Family_array_var myseq = new SALOME_MED::Family_array;
585 int nbfam = _families.size();
586 myseq->length(nbfam);
588 vector < SALOME_MED::FAMILY_ptr >::iterator it;
589 for (it = _families.begin(); it != _families.end(); it++)
593 return myseq._retn();
596 //=============================================================================
598 * CORBA: Returns references for family i within the mesh
600 //=============================================================================
601 SALOME_MED::FAMILY_ptr SMESH_MEDMesh_i::getFamily(SALOME_MED::
602 medEntityMesh entity, CORBA::Long i) throw(SALOME::SALOME_Exception)
604 if (_creeFamily == false)
607 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
608 SALOME::INTERNAL_ERROR);
610 SCRUTE(_families[i]->getName());
611 MESSAGE(" SMESH_MEDMesh_i::getFamily " << i) return _families[i];
614 //=============================================================================
616 * CORBA: Returns references for groups within the mesh
618 //=============================================================================
619 SALOME_MED::Group_array *
620 SMESH_MEDMesh_i::getGroups(SALOME_MED::medEntityMesh entity) throw(SALOME::
624 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
625 SALOME::INTERNAL_ERROR);
626 MESSAGE(" Pas d implementation des groupes dans SMESH");
627 THROW_SALOME_CORBA_EXCEPTION("No group implementation", SALOME::BAD_PARAM);
630 //=============================================================================
632 * CORBA: Returns references for group i within the mesh
634 //=============================================================================
635 SALOME_MED::GROUP_ptr SMESH_MEDMesh_i::getGroup(SALOME_MED::
636 medEntityMesh entity, CORBA::Long i) throw(SALOME::SALOME_Exception)
639 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
640 SALOME::INTERNAL_ERROR);
641 MESSAGE(" Pas d implementation des groupes dans SMESH");
642 THROW_SALOME_CORBA_EXCEPTION("No group implementation", SALOME::BAD_PARAM);
645 //=============================================================================
649 //=============================================================================
650 SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getVolume(SALOME_MED::
651 SUPPORT_ptr mySupport) throw(SALOME::SALOME_Exception)
653 MESSAGE("Pas Implemente dans SMESH");
654 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
658 //=============================================================================
662 //=============================================================================
663 SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getArea(SALOME_MED::
664 SUPPORT_ptr mySupport) throw(SALOME::SALOME_Exception)
666 MESSAGE("Pas Implemente dans SMESH");
667 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
671 //=============================================================================
675 //=============================================================================
676 SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getLength(SALOME_MED::
677 SUPPORT_ptr mySupport) throw(SALOME::SALOME_Exception)
679 MESSAGE("Pas Implemente dans SMESH");
680 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
684 //=============================================================================
688 //=============================================================================
689 SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getNormal(SALOME_MED::
690 SUPPORT_ptr mySupport) throw(SALOME::SALOME_Exception)
692 MESSAGE("Pas Implemente dans SMESH");
693 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
697 //=============================================================================
701 //=============================================================================
702 SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getBarycenter(SALOME_MED::
703 SUPPORT_ptr mySupport) throw(SALOME::SALOME_Exception)
705 MESSAGE("Pas Implemente dans SMESH");
706 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
710 //=============================================================================
714 //=============================================================================
715 SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getNeighbourhood(SALOME_MED::
716 SUPPORT_ptr mySupport) throw(SALOME::SALOME_Exception)
718 MESSAGE("Non Implemente");
719 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
723 //=============================================================================
725 * CORBA: add the Mesh in the StudyManager
728 //=============================================================================
729 void SMESH_MEDMesh_i::addInStudy(SALOMEDS::Study_ptr myStudy,
730 SALOME_MED::MESH_ptr myIor) throw(SALOME::SALOME_Exception)
732 BEGIN_OF("MED_Mesh_i::addInStudy");
735 MESSAGE("Mesh already in Study");
736 THROW_SALOME_CORBA_EXCEPTION("Mesh already in Study",
741 * SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
743 * // Create SComponent labelled 'MED' if it doesn't already exit
744 * SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
745 * if ( CORBA::is_nil(medfather) )
747 * MESSAGE("Add Component MED");
748 * medfather = myBuilder->NewComponent("MED");
749 * //myBuilder->AddAttribute (medfather,SALOMEDS::Name,"MED");
750 * SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(
751 * myBuilder->FindOrCreateAttribute(medfather, "AttributeName"));
752 * aName->SetValue("MED");
754 * myBuilder->DefineComponentInstance(medfather,myIor);
758 * MESSAGE("Add a mesh Object under MED");
759 * myBuilder->NewCommand();
760 * SALOMEDS::SObject_var newObj = myBuilder->NewObject(medfather);
762 * ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
763 * ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
764 * CORBA::ORB_var &orb = init(0,0);
765 * string iorStr = orb->object_to_string(myIor);
766 * //myBuilder->AddAttribute(newObj,SALOMEDS::IOR,iorStr.c_str());
767 * SALOMEDS::AttributeIOR_var aIOR = SALOMEDS::AttributeIOR::_narrow(
768 * myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR"));
769 * aIOR->SetValue(iorStr.c_str());
771 * //myBuilder->AddAttribute(newObj,SALOMEDS::Name,_mesh_i->getName().c_str());
772 * SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(
773 * myBuilder->FindOrCreateAttribute(newObj, "AttributeName"));
774 * aName->SetValue(_mesh_i->getName().c_str());
776 * _meshId = newObj->GetID();
777 * myBuilder->CommitCommand();
780 END_OF("Mesh_i::addInStudy(SALOMEDS::Study_ptr myStudy)");
783 //=============================================================================
785 * CORBA: write mesh in a med file
787 //=============================================================================
788 void SMESH_MEDMesh_i::write(CORBA::Long i, const char *driverMeshName)
789 throw(SALOME::SALOME_Exception)
791 MESSAGE("Non Implemente");
792 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
795 //=============================================================================
797 * CORBA: read mesh in a med file
799 //=============================================================================
800 void SMESH_MEDMesh_i::read(CORBA::Long i) throw(SALOME::SALOME_Exception)
802 MESSAGE("Non Implemente");
803 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
806 //=============================================================================
808 * CORBA : release driver
810 //=============================================================================
811 void SMESH_MEDMesh_i::rmDriver(CORBA::Long i) throw(SALOME::SALOME_Exception)
813 MESSAGE("Non Implemente");
814 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
817 //=============================================================================
819 * CORBA : attach driver
821 //=============================================================================
822 CORBA::Long SMESH_MEDMesh_i::addDriver(SALOME_MED::medDriverTypes driverType,
823 const char *fileName, const char *meshName) throw(SALOME::SALOME_Exception)
825 MESSAGE("Non Implemente");
826 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
830 //=============================================================================
832 * Calcule le Nb d'elements par entite geometrique
834 //=============================================================================
835 void SMESH_MEDMesh_i::calculeNbElts() throw(SALOME::SALOME_Exception)
841 _mapNbTypes[SALOME_MED::MED_NODE] = 1;
842 // On compte les aretes MED_SEG2 ou MED_SEG3
843 // On range les elements dans les vecteurs correspondants
845 _mapIndToSeqElts[SALOME_MED::MED_SEG2] = _indexElts++;
846 _mapIndToSeqElts[SALOME_MED::MED_SEG3] = _indexElts++;
847 _mapIndToVectTypes[SALOME_MED::MED_EDGE] = _indexEnts++;
851 SALOME_MED::medGeometryElement medElement;
853 SMDS_Iterator<const SMDS_MeshEdge*> * itEdges=_meshDS->edgesIterator();
854 while(itEdges->more())
856 const SMDS_MeshEdge* elem = itEdges->next();
857 int nb_of_nodes = elem->NbNodes();
863 medElement = SALOME_MED::MED_SEG2;
867 _TypesId[SALOME_MED::MED_EDGE].
868 push_back(SALOME_MED::MED_SEG2);
874 medElement = SALOME_MED::MED_SEG3;
878 _TypesId[SALOME_MED::MED_EDGE].
879 push_back(SALOME_MED::MED_SEG3);
884 int index = _mapIndToSeqElts[medElement];
886 // Traitement de l arete
887 int longueur = _seq_elemId[index]->length();
888 _seq_elemId[index]->length(longueur + nb_of_nodes);
890 SMDS_Iterator<const SMDS_MeshNode*> * itn=_meshDS->nodesIterator();
892 for(int k=0; itn->more(); k++)
893 _seq_elemId[index][longueur + k] = itn->next()->GetID()+1;
898 _mapNbTypes[SALOME_MED::MED_EDGE] = trouveSeg2 + trouveSeg3;
900 // On compte les faces MED_TRIA3, MED_HEXA8, MED_TRIA6
901 // On range les elements dans les vecteurs correspondants
906 _mapIndToSeqElts[SALOME_MED::MED_TRIA3] = _indexElts++;
907 _mapIndToSeqElts[SALOME_MED::MED_TRIA6] = _indexElts++;
908 _mapIndToSeqElts[SALOME_MED::MED_QUAD4] = _indexElts++;
909 _mapIndToVectTypes[SALOME_MED::MED_FACE] = _indexEnts++;
911 SMDS_Iterator<const SMDS_MeshFace*> * itFaces=_meshDS->facesIterator();
912 while(itFaces->more())
914 const SMDS_MeshFace * elem = itFaces->next();
915 int nb_of_nodes = elem->NbNodes();
921 medElement = SALOME_MED::MED_TRIA3;
922 if (trouveTria3 == 0)
925 _TypesId[SALOME_MED::MED_FACE].
926 push_back(SALOME_MED::MED_TRIA3);
932 medElement = SALOME_MED::MED_QUAD4;
933 if (trouveQuad4 == 0)
936 _TypesId[SALOME_MED::MED_FACE].
937 push_back(SALOME_MED::MED_QUAD4);
943 medElement = SALOME_MED::MED_TRIA6;
944 if (trouveTria6 == 0)
947 _TypesId[SALOME_MED::MED_FACE].
948 push_back(SALOME_MED::MED_TRIA6);
953 int index = _mapIndToSeqElts[medElement];
956 // Traitement de la face
957 // Attention La numérotation des noeuds Med commence a 1
959 int longueur = _seq_elemId[index]->length();
960 _seq_elemId[index]->length(longueur + nb_of_nodes);
962 SMDS_Iterator<const SMDS_MeshNode*> * itn=_meshDS->nodesIterator();
964 for(int k=0; itn->more(); k++)
965 _seq_elemId[index][longueur + k] = itn->next()->GetID()+1;
970 _mapNbTypes[SALOME_MED::MED_FACE] =
971 trouveTria3 + trouveTria6 + trouveQuad4;
973 _mapIndToSeqElts[SALOME_MED::MED_HEXA8] = _indexElts++;
974 _mapIndToVectTypes[SALOME_MED::MED_CELL] = _indexEnts++;
975 int index = _mapIndToSeqElts[medElement];
979 SMDS_Iterator<const SMDS_MeshVolume*> * itVolumes=_meshDS->volumesIterator();
980 while(itVolumes->more())
982 const SMDS_MeshVolume * elem = itVolumes->next();
984 int nb_of_nodes = elem->NbNodes();
985 medElement = SALOME_MED::MED_HEXA8;
986 ASSERT(nb_of_nodes = 8);
988 if (trouveHexa8 == 0)
991 _TypesId[SALOME_MED::MED_CELL].push_back(SALOME_MED::MED_HEXA8);
993 // Traitement de la maille
994 int longueur = _seq_elemId[index]->length();
995 _seq_elemId[index]->length(longueur + nb_of_nodes);
997 SMDS_Iterator<const SMDS_MeshNode*> * itn=_meshDS->nodesIterator();
998 for(int k=0; itn->more(); k++)
999 _seq_elemId[index][longueur + k] = itn->next()->GetID()+1;
1004 _mapNbTypes[SALOME_MED::MED_CELL] = trouveHexa8;
1005 _mapNbTypes[SALOME_MED::MED_ALL_ENTITIES]
1007 trouveHexa8 + trouveTria3 + trouveTria6 + trouveQuad4 + trouveSeg2 +
1012 //=============================================================================
1014 * Creation des familles
1016 //=============================================================================
1017 void SMESH_MEDMesh_i::createFamilies() throw(SALOME::SALOME_Exception)
1019 string famDes = ("Je ne sais pas");
1020 string famName0 = "Famille_";
1024 if (_creeFamily == false)
1027 SMESH_subMesh_i *subMeshServant;
1029 map < int, SMESH_subMesh_i * >::iterator it;
1030 for (it = _mesh_i->_mapSubMesh_i.begin();
1031 it != _mesh_i->_mapSubMesh_i.end(); it++)
1033 SMESH_subMesh_i *submesh_i = (*it).second;
1034 int famIdent = (*it).first;
1036 ASSERT(famIdent < 999999999);
1037 sprintf(numero, "%d\n", famIdent);
1038 famName = famName0 + numero;
1040 SMESH_MEDFamily_i *famservant =
1041 new SMESH_MEDFamily_i(famIdent, submesh_i,
1042 famName, famDes, SALOME_MED::MED_NODE);
1043 SALOME_MED::FAMILY_ptr famille =
1044 SALOME_MED::FAMILY::_narrow(famservant->
1045 POA_SALOME_MED::FAMILY::_this());
1046 _families.push_back(famille);