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"
34 #include "SMDS_MapIteratorOfExtendedMap.hxx"
35 #include "SMDS_MapOfMeshElement.hxx"
38 #include <TopExp_Explorer.hxx>
40 #include <TopoDS_Iterator.hxx>
41 #include <TopoDS_Compound.hxx>
42 #include <TopoDS_CompSolid.hxx>
43 #include <TopoDS_Solid.hxx>
44 #include <TopoDS_Shell.hxx>
45 #include <TopoDS_Face.hxx>
46 #include <TopoDS_Wire.hxx>
47 #include <TopoDS_Edge.hxx>
48 #include <TopoDS_Vertex.hxx>
49 #include <TopoDS_Shape.hxx>
50 #include <TopTools_MapOfShape.hxx>
52 #include "utilities.h"
53 #include "Utils_CorbaException.hxx"
55 #include "SMESH_MEDSupport_i.hxx"
56 #include "SMESH_MEDFamily_i.hxx"
58 # include "Utils_ORB_INIT.hxx"
59 # include "Utils_SINGLETON.hxx"
66 //=============================================================================
70 //=============================================================================
71 // PN Est-ce un const ?
72 SMESH_MEDMesh_i::SMESH_MEDMesh_i()
74 BEGIN_OF("Default Constructor SMESH_MEDMesh_i");
75 END_OF("Default Constructor SMESH_MEDMesh_i");
77 //=============================================================================
81 //=============================================================================
82 SMESH_MEDMesh_i::~SMESH_MEDMesh_i()
85 //=============================================================================
89 //=============================================================================
90 SMESH_MEDMesh_i::SMESH_MEDMesh_i( ::SMESH_Mesh_i* m_i ) :_meshId(""),
98 _meshDS = _mesh_i->GetImpl().GetMeshDS();
100 BEGIN_OF("Constructor SMESH_MEDMesh_i");
101 END_OF("Constructor SMESH_MEDMesh_i");
104 //=============================================================================
106 * CORBA: Accessor for Name
108 //=============================================================================
109 char * SMESH_MEDMesh_i::getName()
110 throw (SALOME::SALOME_Exception)
113 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
114 SALOME::INTERNAL_ERROR);
118 // A COMPLETER PAR LE NOM DU MAILLAGE
119 //return CORBA::string_dup(_mesh_i->getName().c_str());
120 return CORBA::string_dup("toto");
124 MESSAGE("Exception en accedant au nom");
125 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
126 ,SALOME::INTERNAL_ERROR);
129 //=============================================================================
131 * CORBA: Accessor for corbaindex cuisine interne
133 //=============================================================================
134 CORBA::Long SMESH_MEDMesh_i::getCorbaIndex()
135 throw (SALOME::SALOME_Exception)
137 MESSAGE("Non Implemente");
138 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
141 //=============================================================================
143 * CORBA: Accessor for Space Dimension
145 //=============================================================================
146 CORBA::Long SMESH_MEDMesh_i::getSpaceDimension()
147 throw (SALOME::SALOME_Exception)
149 // PN : Il semblerait que la dimension soit fixee a 3
151 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
152 SALOME::INTERNAL_ERROR);
155 //=============================================================================
157 * CORBA: Accessor for Mesh Dimension
159 //=============================================================================
160 CORBA::Long SMESH_MEDMesh_i::getMeshDimension()
161 throw (SALOME::SALOME_Exception)
164 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
165 SALOME::INTERNAL_ERROR);
166 // PN : Il semblerait que la dimension soit fixee a 3
168 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
169 SALOME::INTERNAL_ERROR);
172 //=============================================================================
174 * CORBA: Accessor for Coordinates System
176 //=============================================================================
177 char * SMESH_MEDMesh_i::getCoordinateSystem()
178 throw (SALOME::SALOME_Exception)
181 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
182 SALOME::INTERNAL_ERROR);
183 // PN : En dur. Non encore prevu
186 string systcoo="CARTESIEN";
187 return CORBA::string_dup(systcoo.c_str());
191 MESSAGE("Exception en accedant au maillage");
192 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
193 ,SALOME::INTERNAL_ERROR);
196 //=============================================================================
198 * CORBA: Accessor for Coordinates
200 //=============================================================================
201 Engines::double_array * SMESH_MEDMesh_i::getCoordinates(SALOME_MED::medModeSwitch typeSwitch)
202 throw (SALOME::SALOME_Exception)
205 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
206 SALOME::INTERNAL_ERROR);
207 Engines::double_array_var myseq = new Engines::double_array;
211 int spaceDimension=3;
212 int nbNodes=_meshDS->NbNodes();
214 myseq->length(nbNodes*spaceDimension);
216 SMDS_MeshNodesIterator itNodes(_meshDS);
217 for (;itNodes.More();itNodes.Next())
220 const Handle(SMDS_MeshElement)& elem = itNodes.Value();
221 const Handle(SMDS_MeshNode)& node =_meshDS->GetNode(1,elem);
223 if (typeSwitch == SALOME_MED::MED_FULL_INTERLACE)
225 myseq[i*3]=node->X();
226 myseq[i*3+1]=node->Y();
227 myseq[i*3+2]=node->Z();
229 SCRUTE(myseq[i*3+1]);
230 SCRUTE(myseq[i*3+2]);
234 ASSERT(typeSwitch == SALOME_MED::MED_NO_INTERLACE);
236 myseq[i+nbNodes]=node->Y();
237 myseq[i+(nbNodes*2)]=node->Z();
239 SCRUTE(myseq[i+nbNodes]);
240 SCRUTE(myseq[i+(nbNodes*2)]);
247 MESSAGE("Exception en accedant aux coordonnees");
248 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
249 ,SALOME::INTERNAL_ERROR);
251 return myseq._retn();
253 //=============================================================================
255 * CORBA: Accessor for Coordinates Names
257 //=============================================================================
258 Engines::string_array * SMESH_MEDMesh_i::getCoordinatesNames()
259 throw (SALOME::SALOME_Exception)
262 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
263 SALOME::INTERNAL_ERROR);
264 Engines::string_array_var myseq = new Engines::string_array;
268 int spaceDimension=3;
269 myseq->length(spaceDimension);
270 myseq[0]=CORBA::string_dup("x");
271 myseq[1]=CORBA::string_dup("y");
272 myseq[2]=CORBA::string_dup("z");
276 MESSAGE("Exception en accedant aux noms des coordonnees");
277 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
278 ,SALOME::INTERNAL_ERROR);
280 return myseq._retn();
283 //=============================================================================
285 * CORBA: Accessor for Coordinates Units
287 //=============================================================================
288 Engines::string_array * SMESH_MEDMesh_i::getCoordinatesUnits()
289 throw (SALOME::SALOME_Exception)
292 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
293 SALOME::INTERNAL_ERROR);
294 Engines::string_array_var myseq = new Engines::string_array;
298 int spaceDimension=3;
299 myseq->length(spaceDimension);
300 myseq[0]=CORBA::string_dup("m");
301 myseq[1]=CORBA::string_dup("m");
302 myseq[2]=CORBA::string_dup("m");
306 MESSAGE("Exception en accedant aux unites des coordonnees");
307 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
308 ,SALOME::INTERNAL_ERROR);
310 return myseq._retn();
312 //=============================================================================
314 * CORBA: Accessor for Number of Nodes
316 //=============================================================================
317 CORBA::Long SMESH_MEDMesh_i::getNumberOfNodes()
318 throw (SALOME::SALOME_Exception)
321 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
322 SALOME::INTERNAL_ERROR);
325 return _meshDS->NbNodes();
329 MESSAGE("Exception en accedant au nombre de noeuds");
330 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
331 ,SALOME::INTERNAL_ERROR);
334 //=============================================================================
336 * CORBA: Accessor for number of Types
338 //=============================================================================
339 CORBA::Long SMESH_MEDMesh_i::getNumberOfTypes(SALOME_MED::medEntityMesh entity)
340 throw (SALOME::SALOME_Exception)
343 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
344 SALOME::INTERNAL_ERROR);
350 if ( _mapNbTypes.find(entity)!=_mapNbTypes.end())
351 retour=_mapNbTypes[entity];
356 MESSAGE("Exception en accedant au nombre de Types");
357 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
358 ,SALOME::INTERNAL_ERROR);
362 //=============================================================================
364 * CORBA: Accessor for existing geometry element types
365 * Not implemented for MED_ALL_ENTITIES
367 //=============================================================================
368 SALOME_MED::medGeometryElement_array * SMESH_MEDMesh_i::getTypes (SALOME_MED::medEntityMesh entity)
369 throw (SALOME::SALOME_Exception)
372 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
373 SALOME::INTERNAL_ERROR);
374 if (entity ==SALOME_MED::MED_ALL_ENTITIES)
375 THROW_SALOME_CORBA_EXCEPTION("Not implemented for MED_ALL_ENTITIES",\
379 SALOME_MED::medGeometryElement_array_var myseq =
380 new SALOME_MED::medGeometryElement_array;
383 if ( _mapNbTypes.find(entity) ==_mapNbTypes.end())
384 THROW_SALOME_CORBA_EXCEPTION("No Such Entity in the mesh"\
386 int nbTypes=_mapNbTypes[entity];
388 myseq->length(nbTypes);
390 if ( _mapIndToVectTypes.find(entity) ==_mapIndToVectTypes.end())
391 THROW_SALOME_CORBA_EXCEPTION("No Such Entity in the mesh"\
392 ,SALOME::INTERNAL_ERROR);
394 int index=_mapIndToVectTypes[entity];
395 ASSERT( _TypesId[index].size()!=0);
397 vector<SALOME_MED::medGeometryElement>::iterator it;
398 for (it=_TypesId[index].begin();it!=_TypesId[index].end();it++)
405 MESSAGE("Exception en accedant aux differents types");
406 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
407 ,SALOME::INTERNAL_ERROR);
409 return myseq._retn();
411 //=============================================================================
413 * CORBA: Returns number of elements of type medGeometryElement
414 * Not implemented for MED_ALL_ELEMENTS
415 * implemented for MED_ALL_ENTITIES
417 * Dans cette implementation, il n est pas prevu de tenir compte du entity
418 * qui ne doit pas pouvoir avoir deux valeurs differentes pour un geomElement
420 //=============================================================================
421 CORBA::Long SMESH_MEDMesh_i::getNumberOfElements(SALOME_MED::medEntityMesh entity,
422 SALOME_MED::medGeometryElement geomElement)
423 throw (SALOME::SALOME_Exception)
426 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
427 SALOME::INTERNAL_ERROR);
428 if (geomElement == SALOME_MED::MED_ALL_ELEMENTS)
429 THROW_SALOME_CORBA_EXCEPTION("Not implemented for MED_ALL_ELEMENTS", \
437 if ( _mapIndToSeqElts.find(geomElement)!=_mapIndToSeqElts.end())
439 int index = _mapIndToSeqElts[geomElement];
440 retour=_seq_elemId[index]->length();
446 MESSAGE("Exception en accedant au nombre d élements");
447 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object"\
448 ,SALOME::INTERNAL_ERROR);
451 //=============================================================================
453 * CORBA: Accessor for connectivities
455 //=============================================================================
456 Engines::long_array * SMESH_MEDMesh_i::getConnectivity(SALOME_MED::medModeSwitch typeSwitch,
457 SALOME_MED::medConnectivity mode,
458 SALOME_MED::medEntityMesh entity,
459 SALOME_MED::medGeometryElement geomElement)
460 throw (SALOME::SALOME_Exception)
463 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
464 SALOME::INTERNAL_ERROR);
465 if (mode != SALOME_MED::MED_NODAL)
466 THROW_SALOME_CORBA_EXCEPTION("Not Implemented",\
468 if (typeSwitch == SALOME_MED::MED_NO_INTERLACE)
469 THROW_SALOME_CORBA_EXCEPTION("Not Yet Implemented",\
474 // Faut-il renvoyer un pointeur vide ???
475 if ( _mapIndToSeqElts.find(geomElement)!=_mapIndToSeqElts.end())
476 THROW_SALOME_CORBA_EXCEPTION("No Such Element in the mesh"\
479 int index=_mapIndToSeqElts[geomElement];
480 return _seq_elemId[index]._retn();
482 //=============================================================================
484 * CORBA: Accessor for connectivities
486 //=============================================================================
487 Engines::long_array* SMESH_MEDMesh_i::getConnectivityIndex(SALOME_MED::medConnectivity mode,
488 SALOME_MED::medEntityMesh entity)
489 throw (SALOME::SALOME_Exception)
491 MESSAGE("Pas Implemente dans SMESH");
492 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
496 //=============================================================================
498 * CORBA: Find an element corresponding to the given connectivity
500 //=============================================================================
501 CORBA::Long SMESH_MEDMesh_i::getElementNumber(SALOME_MED::medConnectivity mode,
502 SALOME_MED::medEntityMesh entity,
503 SALOME_MED::medGeometryElement type,
504 const Engines::long_array & connectivity
506 throw (SALOME::SALOME_Exception)
508 const char * LOC = "getElementNumber ";
509 MESSAGE(LOC<<"Pas Implemente dans SMESH");
510 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
514 //=============================================================================
516 * CORBA: Accessor for Ascendant connectivities
517 * not implemented for MED_ALL_ENTITIES and MED_MAILLE
519 //=============================================================================
520 Engines::long_array* SMESH_MEDMesh_i::getReverseConnectivity(SALOME_MED::medConnectivity mode)
521 throw (SALOME::SALOME_Exception)
523 MESSAGE("Pas Implemente dans SMESH");
524 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
528 //=============================================================================
530 * CORBA: Accessor for connectivities
532 //=============================================================================
533 Engines::long_array* SMESH_MEDMesh_i::getReverseConnectivityIndex(SALOME_MED::medConnectivity mode)
534 throw (SALOME::SALOME_Exception)
536 MESSAGE("Pas Implemente dans SMESH");
537 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
541 //=============================================================================
543 * CORBA: Returns number of families within the mesh
545 //=============================================================================
546 CORBA::Long SMESH_MEDMesh_i::getNumberOfFamilies(SALOME_MED::medEntityMesh entity)
547 throw (SALOME::SALOME_Exception)
549 if (_creeFamily == false)
552 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
553 SALOME::INTERNAL_ERROR);
554 return _families.size();
556 //=============================================================================
558 * CORBA: Returns number of groups within the mesh
560 //=============================================================================
561 CORBA::Long SMESH_MEDMesh_i::getNumberOfGroups(SALOME_MED::medEntityMesh entity)
562 throw (SALOME::SALOME_Exception)
565 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
566 SALOME::INTERNAL_ERROR);
567 MESSAGE(" Pas d implementation des groupes dans SMESH");
570 //=============================================================================
572 * CORBA: Returns references for families within the mesh
574 //=============================================================================
575 SALOME_MED::Family_array * SMESH_MEDMesh_i::getFamilies(SALOME_MED::medEntityMesh entity)
576 throw (SALOME::SALOME_Exception)
578 if (_creeFamily == false)
581 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
582 SALOME::INTERNAL_ERROR);
583 SALOME_MED::Family_array_var myseq = new SALOME_MED::Family_array;
584 int nbfam= _families.size();
585 myseq->length(nbfam);
587 vector<SALOME_MED::FAMILY_ptr>::iterator it;
588 for (it=_families.begin();it!=_families.end();it++)
592 return myseq._retn();
594 //=============================================================================
596 * CORBA: Returns references for family i within the mesh
598 //=============================================================================
599 SALOME_MED::FAMILY_ptr SMESH_MEDMesh_i::getFamily(SALOME_MED::medEntityMesh entity,
601 throw (SALOME::SALOME_Exception)
603 if (_creeFamily == false)
606 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
607 SALOME::INTERNAL_ERROR);
609 SCRUTE(_families[i]->getName());
610 MESSAGE ( " SMESH_MEDMesh_i::getFamily " << i )
613 //=============================================================================
615 * CORBA: Returns references for groups within the mesh
617 //=============================================================================
618 SALOME_MED::Group_array * SMESH_MEDMesh_i::getGroups(SALOME_MED::medEntityMesh entity)
619 throw (SALOME::SALOME_Exception)
622 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
623 SALOME::INTERNAL_ERROR);
624 MESSAGE(" Pas d implementation des groupes dans SMESH");
625 THROW_SALOME_CORBA_EXCEPTION("No group implementation"\
628 //=============================================================================
630 * CORBA: Returns references for group i within the mesh
632 //=============================================================================
633 SALOME_MED::GROUP_ptr SMESH_MEDMesh_i::getGroup(SALOME_MED::medEntityMesh entity,
635 throw (SALOME::SALOME_Exception)
638 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
639 SALOME::INTERNAL_ERROR);
640 MESSAGE(" Pas d implementation des groupes dans SMESH");
641 THROW_SALOME_CORBA_EXCEPTION("No group implementation"\
644 //=============================================================================
648 //=============================================================================
649 SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getVolume(SALOME_MED::SUPPORT_ptr mySupport)
650 throw (SALOME::SALOME_Exception)
652 MESSAGE("Pas Implemente dans SMESH");
653 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
657 //=============================================================================
661 //=============================================================================
662 SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getArea(SALOME_MED::SUPPORT_ptr mySupport)
663 throw (SALOME::SALOME_Exception)
665 MESSAGE("Pas Implemente dans SMESH");
666 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
670 //=============================================================================
674 //=============================================================================
675 SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getLength(SALOME_MED::SUPPORT_ptr mySupport)
676 throw (SALOME::SALOME_Exception)
678 MESSAGE("Pas Implemente dans SMESH");
679 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
683 //=============================================================================
687 //=============================================================================
688 SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getNormal(SALOME_MED::SUPPORT_ptr mySupport)
689 throw (SALOME::SALOME_Exception)
691 MESSAGE("Pas Implemente dans SMESH");
692 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
696 //=============================================================================
700 //=============================================================================
701 SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getBarycenter(SALOME_MED::SUPPORT_ptr mySupport)
702 throw (SALOME::SALOME_Exception)
704 MESSAGE("Pas Implemente dans SMESH");
705 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
709 //=============================================================================
713 //=============================================================================
714 SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getNeighbourhood(SALOME_MED::SUPPORT_ptr mySupport)
715 throw (SALOME::SALOME_Exception)
717 MESSAGE("Non Implemente");
718 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
722 //=============================================================================
724 * CORBA: add the Mesh in the StudyManager
727 //=============================================================================
728 void SMESH_MEDMesh_i::addInStudy(SALOMEDS::Study_ptr myStudy,
729 SALOME_MED::MESH_ptr myIor)
730 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)");
782 //=============================================================================
784 * CORBA: write mesh in a med file
786 //=============================================================================
787 void SMESH_MEDMesh_i::write(CORBA::Long i, const char* driverMeshName)
788 throw (SALOME::SALOME_Exception)
790 MESSAGE("Non Implemente");
791 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
794 //=============================================================================
796 * CORBA: read mesh in a med file
798 //=============================================================================
799 void SMESH_MEDMesh_i::read(CORBA::Long i)
800 throw (SALOME::SALOME_Exception)
802 MESSAGE("Non Implemente");
803 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
806 //=============================================================================
808 * CORBA : release driver
810 //=============================================================================
811 void SMESH_MEDMesh_i::rmDriver(CORBA::Long i)
812 throw (SALOME::SALOME_Exception)
814 MESSAGE("Non Implemente");
815 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
818 //=============================================================================
820 * CORBA : attach driver
822 //=============================================================================
823 CORBA::Long SMESH_MEDMesh_i::addDriver(SALOME_MED::medDriverTypes driverType,
824 const char* fileName, const char* meshName)
825 throw (SALOME::SALOME_Exception)
827 MESSAGE("Non Implemente");
828 THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method"\
832 //=============================================================================
834 * Calcule le Nb d'elements par entite geometrique
836 //=============================================================================
837 void SMESH_MEDMesh_i::calculeNbElts()
838 throw (SALOME::SALOME_Exception)
844 _mapNbTypes[SALOME_MED::MED_NODE]=1;
845 // On compte les aretes MED_SEG2 ou MED_SEG3
846 // On range les elements dans les vecteurs correspondants
848 _mapIndToSeqElts[SALOME_MED::MED_SEG2]=_indexElts++;
849 _mapIndToSeqElts[SALOME_MED::MED_SEG3]=_indexElts++;
850 _mapIndToVectTypes[SALOME_MED::MED_EDGE]=_indexEnts++;
854 SALOME_MED::medGeometryElement medElement;
855 SMDS_MeshEdgesIterator itEdges(_meshDS);
856 for (;itEdges.More();itEdges.Next())
858 const Handle(SMDS_MeshElement)& elem = itEdges.Value();
859 int nb_of_nodes = elem->NbNodes();
865 medElement=SALOME_MED::MED_SEG2;
869 _TypesId[SALOME_MED::MED_EDGE].push_back(SALOME_MED::MED_SEG2);
876 medElement=SALOME_MED::MED_SEG3;
880 _TypesId[SALOME_MED::MED_EDGE].push_back(SALOME_MED::MED_SEG3);
885 int index=_mapIndToSeqElts[medElement];
887 // Traitement de l arete
888 int longueur=_seq_elemId[index]->length();
889 _seq_elemId[index]->length(longueur + nb_of_nodes);
891 for (int k=0; k<nb_of_nodes; k++)
893 _seq_elemId[index][longueur+k]=elem->GetConnection(k+1) +1;
897 _mapNbTypes[SALOME_MED::MED_EDGE]=trouveSeg2 + trouveSeg3;
899 // On compte les faces MED_TRIA3, MED_HEXA8, MED_TRIA6
900 // On range les elements dans les vecteurs correspondants
905 _mapIndToSeqElts[SALOME_MED::MED_TRIA3]=_indexElts++;
906 _mapIndToSeqElts[SALOME_MED::MED_TRIA6]=_indexElts++;
907 _mapIndToSeqElts[SALOME_MED::MED_QUAD4]=_indexElts++;
908 _mapIndToVectTypes[SALOME_MED::MED_FACE]=_indexEnts++;
910 SMDS_MeshFacesIterator itFaces(_meshDS);
911 for (;itFaces.More();itFaces.Next())
914 const Handle(SMDS_MeshElement)& elem = itFaces.Value();
915 int nb_of_nodes = elem->NbNodes();
921 medElement=SALOME_MED::MED_TRIA3;
925 _TypesId[SALOME_MED::MED_FACE].push_back(SALOME_MED::MED_TRIA3);
931 medElement=SALOME_MED::MED_QUAD4;
935 _TypesId[SALOME_MED::MED_FACE].push_back(SALOME_MED::MED_QUAD4);
941 medElement=SALOME_MED::MED_TRIA6;
945 _TypesId[SALOME_MED::MED_FACE].push_back(SALOME_MED::MED_TRIA6);
950 int index=_mapIndToSeqElts[medElement];
953 // Traitement de la face
954 // Attention La numérotation des noeuds Med commence a 1
957 int longueur = _seq_elemId[index]->length();
958 _seq_elemId[index]->length(longueur+nb_of_nodes);
960 for (int k=0; k<nb_of_nodes; k++)
962 _seq_elemId[index][longueur+k]=elem->GetConnection(k+1) +1;
966 _mapNbTypes[SALOME_MED::MED_FACE]=trouveTria3 + trouveTria6 + trouveQuad4;
968 _mapIndToSeqElts[SALOME_MED::MED_HEXA8]=_indexElts++;
969 _mapIndToVectTypes[SALOME_MED::MED_CELL]=_indexEnts++;
970 int index=_mapIndToSeqElts[medElement];
973 SMDS_MeshVolumesIterator itVolumes(_meshDS);
974 for (;itVolumes.More();itVolumes.Next())
976 const Handle(SMDS_MeshElement)& elem = itVolumes.Value();
978 int nb_of_nodes = elem->NbNodes();
979 medElement=SALOME_MED::MED_HEXA8;
980 ASSERT(nb_of_nodes=8);
982 if (trouveHexa8 == 0)
985 _TypesId[SALOME_MED::MED_CELL].push_back(SALOME_MED::MED_HEXA8);
987 // Traitement de la maille
988 int longueur=_seq_elemId[index]->length();
989 _seq_elemId[index]->length(longueur+nb_of_nodes);
991 for (int k=0; k<nb_of_nodes; k++)
993 _seq_elemId[index][longueur+k]=elem->GetConnection(k+1) +1;
998 _mapNbTypes[SALOME_MED::MED_CELL]=trouveHexa8;
999 _mapNbTypes[SALOME_MED::MED_ALL_ENTITIES]
1000 =trouveHexa8 + trouveTria3 + trouveTria6 + trouveQuad4 + trouveSeg2 + trouveSeg3 ;
1001 } /* fin du _compte */
1003 //=============================================================================
1005 * Creation des familles
1007 //=============================================================================
1008 void SMESH_MEDMesh_i::createFamilies()
1009 throw (SALOME::SALOME_Exception)
1011 string famDes=("Je ne sais pas");
1012 string famName0="Famille_";
1016 if ( _creeFamily == false)
1019 SMESH_subMesh_i* subMeshServant;
1021 map<int, SMESH_subMesh_i*>::iterator it;
1022 for (it = _mesh_i->_mapSubMesh_i.begin(); it != _mesh_i->_mapSubMesh_i.end(); it++) {
1023 SMESH_subMesh_i* submesh_i = (*it).second;
1024 int famIdent = (*it).first;
1026 ASSERT (famIdent<999999999);
1027 sprintf(numero,"%d\n",famIdent);
1028 famName=famName0 + numero;
1030 SMESH_MEDFamily_i * famservant= new SMESH_MEDFamily_i(famIdent, submesh_i,
1031 famName, famDes, SALOME_MED::MED_NODE);
1032 SALOME_MED::FAMILY_ptr famille =
1033 SALOME_MED::FAMILY::_narrow(famservant->POA_SALOME_MED::FAMILY::_this());
1034 _families.push_back(famille);
1036 } /* fin du _compte */