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_Mesh_i.cxx
25 // Author : Paul RASCLE, EDF
29 #include "SMESH_Mesh_i.hxx"
30 #include "SMESH_subMesh_i.hxx"
31 #include "SMESH_MEDMesh_i.hxx"
32 #include "SMESH_Group_i.hxx"
33 #include "SMESH_Filter_i.hxx"
35 #include "Utils_CorbaException.hxx"
36 #include "Utils_ExceptHandlers.hxx"
37 #include "utilities.h"
39 #include "SALOME_NamingService.hxx"
40 #include "Utils_SINGLETON.hxx"
43 #include "TCollection_AsciiString.hxx"
44 #include <TColStd_MapOfInteger.hxx>
45 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
46 #include <TColStd_SequenceOfInteger.hxx>
47 #include "SMESHDS_Command.hxx"
48 #include "SMESHDS_CommandType.hxx"
49 #include "SMESH_MeshEditor_i.hxx"
50 #include "SMESH_Gen_i.hxx"
51 #include "DriverMED_R_SMESHDS_Mesh.h"
55 // _CS_gbo_050504 Ajout explicite du sstream pour ostringstream
59 static int MYDEBUG = 0;
61 static int MYDEBUG = 0;
66 int SMESH_Mesh_i::myIdGenerator = 0;
68 //=============================================================================
72 //=============================================================================
74 SMESH_Mesh_i::SMESH_Mesh_i( PortableServer::POA_ptr thePOA,
77 : SALOME::GenericObj_i( thePOA )
79 INFOS("SMESH_Mesh_i");
81 _id = myIdGenerator++;
83 thePOA->activate_object( this );
86 //=============================================================================
90 //=============================================================================
92 SMESH_Mesh_i::~SMESH_Mesh_i()
94 INFOS("~SMESH_Mesh_i");
95 map<int, SMESH::SMESH_Group_ptr>::iterator it;
96 for ( it = _mapGroups.begin(); it != _mapGroups.end(); it++ ) {
97 SMESH_Group_i* aGroup = dynamic_cast<SMESH_Group_i*>( SMESH_Gen_i::GetServant( it->second ).in() );
100 // this method is colled from destructor of group (PAL6331)
101 //_impl->RemoveGroup( aGroup->GetLocalID() );
109 //=============================================================================
113 * Associates <this> mesh with <theShape> and puts a reference
114 * to <theShape> into the current study;
115 * the previous shape is substituted by the new one.
117 //=============================================================================
119 void SMESH_Mesh_i::SetShape( GEOM::GEOM_Object_ptr theShapeObject )
120 throw (SALOME::SALOME_Exception)
122 Unexpect aCatch(SALOME_SalomeException);
124 setShape( theShapeObject );
126 catch(SALOME_Exception & S_ex) {
127 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
130 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
131 if ( aStudy->_is_nil() )
134 // Create a reference to <theShape>
135 SALOMEDS::SObject_var aMeshSO = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( _this() ) ) ) );
136 SALOMEDS::SObject_var aShapeSO = aStudy->FindObjectIOR( SMESH_Gen_i::GetORB()->object_to_string( theShapeObject ) );
138 SALOMEDS::SObject_var anObj, aRef;
139 SALOMEDS::GenericAttribute_var anAttr;
140 SALOMEDS::AttributeIOR_var anIOR;
141 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
142 long aTag = SMESH_Gen_i::GetRefOnShapeTag();
144 if ( aMeshSO->FindSubObject( aTag, anObj ) ) {
145 if ( anObj->ReferencedObject( aRef ) ) {
146 if ( strcmp( aRef->GetID(), aShapeSO->GetID() ) == 0 ) {
147 // Setting the same shape twice forbidden
153 anObj = aBuilder->NewObjectToTag( aMeshSO, aTag );
155 aBuilder->Addreference( anObj, aShapeSO );
158 //=============================================================================
162 * Sets shape to the mesh implementation
164 //=============================================================================
166 bool SMESH_Mesh_i::setShape( GEOM::GEOM_Object_ptr theShapeObject )
168 if ( theShapeObject->_is_nil() )
171 TopoDS_Shape aLocShape = _gen_i->GetShapeReader()->GetShape( SMESH_Gen_i::GetGeomEngine(), theShapeObject );
172 _impl->ShapeToMesh( aLocShape );
176 //=============================================================================
180 //=============================================================================
182 static SMESH::DriverMED_ReadStatus ConvertDriverMEDReadStatus (int theStatus)
184 SMESH::DriverMED_ReadStatus res;
187 case DriverMED_R_SMESHDS_Mesh::DRS_OK:
188 res = SMESH::DRS_OK; break;
189 case DriverMED_R_SMESHDS_Mesh::DRS_EMPTY:
190 res = SMESH::DRS_EMPTY; break;
191 case DriverMED_R_SMESHDS_Mesh::DRS_WARN_RENUMBER:
192 res = SMESH::DRS_WARN_RENUMBER; break;
193 case DriverMED_R_SMESHDS_Mesh::DRS_WARN_SKIP_ELEM:
194 res = SMESH::DRS_WARN_SKIP_ELEM; break;
195 case DriverMED_R_SMESHDS_Mesh::DRS_FAIL:
197 res = SMESH::DRS_FAIL; break;
202 //=============================================================================
206 * Imports mesh data from MED file
208 //=============================================================================
210 SMESH::DriverMED_ReadStatus
211 SMESH_Mesh_i::ImportMEDFile( const char* theFileName, const char* theMeshName )
212 throw ( SALOME::SALOME_Exception )
214 Unexpect aCatch(SALOME_SalomeException);
217 status = importMEDFile( theFileName, theMeshName );
219 catch( SALOME_Exception& S_ex ) {
220 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
223 THROW_SALOME_CORBA_EXCEPTION("ImportMEDFile(): unknown exception", SALOME::BAD_PARAM);
226 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
227 if ( aStudy->_is_nil() )
228 return ConvertDriverMEDReadStatus(status);
230 // publishing of the groups in the study (sub-meshes are out of scope of MED import)
231 map<int, SMESH::SMESH_Group_ptr>::iterator it = _mapGroups.begin();
232 for (; it != _mapGroups.end(); it++ ) {
233 SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_duplicate( it->second );
234 if ( _gen_i->CanPublishInStudy( aGroup ) )
235 _gen_i->PublishInStudy( aStudy,
236 SALOMEDS::SObject::_nil(),
240 return ConvertDriverMEDReadStatus(status);
243 //=============================================================================
247 * Imports mesh data from MED file
249 //=============================================================================
251 int SMESH_Mesh_i::ImportUNVFile( const char* theFileName )
252 throw ( SALOME::SALOME_Exception )
254 // Read mesh with name = <theMeshName> into SMESH_Mesh
255 _impl->UNVToMesh( theFileName );
260 //=============================================================================
264 * Imports mesh data from STL file
266 //=============================================================================
267 int SMESH_Mesh_i::ImportSTLFile( const char* theFileName )
268 throw ( SALOME::SALOME_Exception )
270 // Read mesh with name = <theMeshName> into SMESH_Mesh
271 _impl->STLToMesh( theFileName );
276 //=============================================================================
280 * Imports mesh data from MED file
282 //=============================================================================
284 int SMESH_Mesh_i::importMEDFile( const char* theFileName, const char* theMeshName )
286 // Read mesh with name = <theMeshName> and all its groups into SMESH_Mesh
287 int status = _impl->MEDToMesh( theFileName, theMeshName );
289 // Create group servants, if any groups were imported
290 list<int> aGroupIds = _impl->GetGroupIds();
291 for ( list<int>::iterator it = aGroupIds.begin(); it != aGroupIds.end(); it++ ) {
292 SMESH_Group_i* aGroupImpl = new SMESH_Group_i( SMESH_Gen_i::GetPOA(), this, *it );
293 SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow( aGroupImpl->_this() );
294 _mapGroups[*it] = SMESH::SMESH_Group::_duplicate( aGroup );
296 // register CORBA object for persistence
297 StudyContext* myStudyContext = _gen_i->GetCurrentStudyContext();
298 string iorString = SMESH_Gen_i::GetORB()->object_to_string( aGroup );
299 int nextId = myStudyContext->addObject( iorString );
300 if(MYDEBUG) MESSAGE( "Add group to map with id = "<< nextId << " and IOR = " << iorString.c_str() );
306 //=============================================================================
310 //=============================================================================
312 static SMESH::Hypothesis_Status ConvertHypothesisStatus
313 (SMESH_Hypothesis::Hypothesis_Status theStatus)
315 SMESH::Hypothesis_Status res;
318 case SMESH_Hypothesis::HYP_OK:
319 res = SMESH::HYP_OK; break;
320 case SMESH_Hypothesis::HYP_MISSING:
321 res = SMESH::HYP_MISSING; break;
322 case SMESH_Hypothesis::HYP_CONCURENT:
323 res = SMESH::HYP_CONCURENT; break;
324 case SMESH_Hypothesis::HYP_BAD_PARAMETER:
325 res = SMESH::HYP_BAD_PARAMETER; break;
326 case SMESH_Hypothesis::HYP_INCOMPATIBLE:
327 res = SMESH::HYP_INCOMPATIBLE; break;
328 case SMESH_Hypothesis::HYP_NOTCONFORM:
329 res = SMESH::HYP_NOTCONFORM; break;
330 case SMESH_Hypothesis::HYP_ALREADY_EXIST:
331 res = SMESH::HYP_ALREADY_EXIST; break;
332 case SMESH_Hypothesis::HYP_BAD_DIM:
333 res = SMESH::HYP_BAD_DIM; break;
335 res = SMESH::HYP_UNKNOWN_FATAL;
340 //=============================================================================
344 * calls internal addHypothesis() and then adds a reference to <anHyp> under
345 * the SObject actually having a reference to <aSubShape>.
346 * NB: For this method to work, it is necessary to add a reference to sub-shape first.
348 //=============================================================================
350 SMESH::Hypothesis_Status SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
351 SMESH::SMESH_Hypothesis_ptr anHyp)
352 throw(SALOME::SALOME_Exception)
354 Unexpect aCatch(SALOME_SalomeException);
355 SMESH_Hypothesis::Hypothesis_Status status = addHypothesis( aSubShapeObject, anHyp );
357 if ( !SMESH_Hypothesis::IsStatusFatal(status) ) {
358 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
360 if ( !aStudy->_is_nil() ) {
361 // Detect whether <aSubShape> refers to this mesh or its sub-mesh
362 SALOMEDS::GenericAttribute_var anAttr;
363 SALOMEDS::AttributeIOR_var anIOR;
364 SALOMEDS::SObject_var aMeshSO = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( _this() ) ) ) );
365 if ( aMeshSO->_is_nil() ) {
366 SCRUTE( SMESH_Gen_i::GetORB()->object_to_string( _this() ));
367 removeHypothesis( aSubShapeObject, anHyp );
368 return SMESH::HYP_UNKNOWN_FATAL;
370 SALOMEDS::SObject_var aMorSM, aRef;
371 CORBA::String_var aShapeIOR = CORBA::string_dup( SMESH_Gen_i::GetORB()->object_to_string( aSubShapeObject ) );
372 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator( aMeshSO );
374 for ( it->InitEx( true ); it->More(); it->Next() ) {
375 SALOMEDS::SObject_var anObj = it->Value();
376 if ( anObj->ReferencedObject( aRef ) ) {
377 if ( aRef->FindAttribute( anAttr, "AttributeIOR" ) ) {
378 anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr );
379 if ( strcmp( anIOR->Value(), aShapeIOR ) == 0 ) {
380 aMorSM = anObj->GetFather();
387 bool aIsAlgo = !SMESH::SMESH_Algo::_narrow( anHyp )->_is_nil();
388 SALOMEDS::SObject_var aHypSO = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( anHyp ) ) ) );
389 if ( !aMorSM->_is_nil() && !aHypSO->_is_nil() ) {
390 //Find or Create Applied Hypothesis root
391 SALOMEDS::SObject_var AHR;
392 SALOMEDS::AttributeName_var aName;
393 SALOMEDS::AttributeSelectable_var aSelAttr;
394 SALOMEDS::AttributePixMap_var aPixmap;
395 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
396 long aTag = aIsAlgo ? SMESH_Gen_i::GetRefOnAppliedAlgorithmsTag() : SMESH_Gen_i::GetRefOnAppliedHypothesisTag();
398 if ( !aMorSM->FindSubObject( aTag, AHR ) ) {
399 AHR = aBuilder->NewObjectToTag( aMorSM, aTag );
400 anAttr = aBuilder->FindOrCreateAttribute( AHR, "AttributeName" );
401 aName = SALOMEDS::AttributeName::_narrow( anAttr );
402 aName ->SetValue( aIsAlgo ? "Applied algorithms" : "Applied hypotheses" );
403 anAttr = aBuilder->FindOrCreateAttribute( AHR, "AttributeSelectable" );
404 aSelAttr = SALOMEDS::AttributeSelectable::_narrow( anAttr );
405 aSelAttr ->SetSelectable( false );
406 anAttr = aBuilder->FindOrCreateAttribute( AHR, "AttributePixMap" );
407 aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr );
408 aPixmap ->SetPixMap( aIsAlgo ? "ICON_SMESH_TREE_ALGO" : "ICON_SMESH_TREE_HYPO" );
411 SALOMEDS::SObject_var SO = aBuilder->NewObject( AHR );
412 aBuilder->Addreference( SO, aHypSO );
416 if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status );
418 return ConvertHypothesisStatus(status);
421 //=============================================================================
425 //=============================================================================
427 SMESH_Hypothesis::Hypothesis_Status
428 SMESH_Mesh_i::addHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
429 SMESH::SMESH_Hypothesis_ptr anHyp)
431 if(MYDEBUG) MESSAGE("addHypothesis");
432 // **** proposer liste de subShape (selection multiple)
434 if (CORBA::is_nil(aSubShapeObject))
435 THROW_SALOME_CORBA_EXCEPTION("bad subShape reference",
438 SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow(anHyp);
439 if (CORBA::is_nil(myHyp))
440 THROW_SALOME_CORBA_EXCEPTION("bad hypothesis reference",
443 SMESH_Hypothesis::Hypothesis_Status status = SMESH_Hypothesis::HYP_OK;
446 TopoDS_Shape myLocSubShape =
447 _gen_i->GetShapeReader()->GetShape(SMESH_Gen_i::GetGeomEngine(), aSubShapeObject);
448 int hypId = myHyp->GetId();
449 status = _impl->AddHypothesis(myLocSubShape, hypId);
450 if ( !SMESH_Hypothesis::IsStatusFatal(status) )
451 _mapHypo[hypId] = myHyp;
453 catch(SALOME_Exception & S_ex)
455 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
460 //=============================================================================
464 //=============================================================================
466 SMESH::Hypothesis_Status SMESH_Mesh_i::RemoveHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
467 SMESH::SMESH_Hypothesis_ptr anHyp)
468 throw(SALOME::SALOME_Exception)
470 Unexpect aCatch(SALOME_SalomeException);
471 SMESH_Hypothesis::Hypothesis_Status status = removeHypothesis( aSubShapeObject, anHyp );
473 if ( !SMESH_Hypothesis::IsStatusFatal(status) ) {
474 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
476 if ( !aStudy->_is_nil() ) {
477 // Detect whether <aSubShape> refers to this mesh or its sub-mesh
478 SALOMEDS::GenericAttribute_var anAttr;
479 SALOMEDS::AttributeIOR_var anIOR;
480 SALOMEDS::SObject_var aMeshSO = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( _this() ) ) ) );
481 if ( aMeshSO->_is_nil() ) {
482 SCRUTE( SMESH_Gen_i::GetORB()->object_to_string( _this() ));
483 addHypothesis( aSubShapeObject, anHyp );
484 return SMESH::HYP_UNKNOWN_FATAL;
486 SALOMEDS::SObject_var aMorSM, aRef;
487 CORBA::String_var aShapeIOR = CORBA::string_dup( SMESH_Gen_i::GetORB()->object_to_string( aSubShapeObject ) );
488 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator( aMeshSO );
490 for ( it->InitEx( true ); it->More(); it->Next() ) {
491 SALOMEDS::SObject_var anObj = it->Value();
492 if ( anObj->ReferencedObject( aRef ) ) {
493 if ( aRef->FindAttribute( anAttr, "AttributeIOR" ) ) {
494 anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr );
495 if ( strcmp( anIOR->Value(), aShapeIOR ) == 0 ) {
496 aMorSM = anObj->GetFather();
503 bool aIsAlgo = !SMESH::SMESH_Algo::_narrow( anHyp )->_is_nil();
504 SALOMEDS::SObject_var aHypSO = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( anHyp ) ) ) );
505 if ( !aMorSM->_is_nil() && !aHypSO->_is_nil() ) {
506 // Remove a refernce to hypothesis or algorithm
507 SALOMEDS::SObject_var AHR;
508 SALOMEDS::AttributeName_var aName;
509 SALOMEDS::AttributeSelectable_var aSelAttr;
510 SALOMEDS::AttributePixMap_var aPixmap;
511 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
512 CORBA::String_var aHypIOR = CORBA::string_dup( SMESH_Gen_i::GetORB()->object_to_string( anHyp ) );
513 long aTag = aIsAlgo ? SMESH_Gen_i::GetRefOnAppliedAlgorithmsTag() : SMESH_Gen_i::GetRefOnAppliedHypothesisTag();
515 if ( aMorSM->FindSubObject( aTag, AHR ) ) {
516 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator( AHR );
517 for ( ; it->More(); it->Next() ) {
518 SALOMEDS::SObject_var anObj = it->Value();
519 if ( anObj->ReferencedObject( aRef ) ) {
520 if ( aRef->FindAttribute( anAttr, "AttributeIOR" ) ) {
521 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
522 if ( strcmp( anIOR->Value(), aHypIOR ) == 0 ) {
523 aBuilder->RemoveObject( anObj );
534 return ConvertHypothesisStatus(status);
538 //=============================================================================
542 //=============================================================================
544 SMESH_Hypothesis::Hypothesis_Status SMESH_Mesh_i::removeHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
545 SMESH::SMESH_Hypothesis_ptr anHyp)
547 if(MYDEBUG) MESSAGE("removeHypothesis()");
548 // **** proposer liste de subShape (selection multiple)
550 if (CORBA::is_nil(aSubShapeObject))
551 THROW_SALOME_CORBA_EXCEPTION("bad subShape reference",
554 SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow(anHyp);
555 if (CORBA::is_nil(myHyp))
556 THROW_SALOME_CORBA_EXCEPTION("bad hypothesis reference",
559 SMESH_Hypothesis::Hypothesis_Status status = SMESH_Hypothesis::HYP_OK;
562 TopoDS_Shape myLocSubShape =
563 _gen_i->GetShapeReader()->GetShape(SMESH_Gen_i::GetGeomEngine(), aSubShapeObject);
564 int hypId = myHyp->GetId();
565 status = _impl->RemoveHypothesis(myLocSubShape, hypId);
566 if ( !SMESH_Hypothesis::IsStatusFatal(status) )
567 _mapHypo.erase( hypId );
569 catch(SALOME_Exception & S_ex)
571 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
576 //=============================================================================
580 //=============================================================================
582 SMESH::ListOfHypothesis *
583 SMESH_Mesh_i::GetHypothesisList(GEOM::GEOM_Object_ptr aSubShapeObject)
584 throw(SALOME::SALOME_Exception)
586 Unexpect aCatch(SALOME_SalomeException);
587 MESSAGE("GetHypothesisList");
588 if (CORBA::is_nil(aSubShapeObject))
589 THROW_SALOME_CORBA_EXCEPTION("bad subShape reference",
592 SMESH::ListOfHypothesis_var aList = new SMESH::ListOfHypothesis();
595 TopoDS_Shape myLocSubShape
596 = _gen_i->GetShapeReader()->GetShape(SMESH_Gen_i::GetGeomEngine(), aSubShapeObject);
598 const list<const SMESHDS_Hypothesis*>& aLocalList = _impl->GetHypothesisList( myLocSubShape );
599 int i = 0, n = aLocalList.size();
602 for ( list<const SMESHDS_Hypothesis*>::const_iterator anIt = aLocalList.begin(); i < n && anIt != aLocalList.end(); anIt++ ) {
603 SMESHDS_Hypothesis* aHyp = (SMESHDS_Hypothesis*)(*anIt);
604 if ( _mapHypo.find( aHyp->GetID() ) != _mapHypo.end() )
605 aList[i++] = SMESH::SMESH_Hypothesis::_narrow( _mapHypo[aHyp->GetID()] );
610 catch(SALOME_Exception & S_ex) {
611 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
614 return aList._retn();
617 //=============================================================================
621 //=============================================================================
622 SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::GetSubMesh(GEOM::GEOM_Object_ptr aSubShapeObject,
623 const char* theName )
624 throw(SALOME::SALOME_Exception)
626 Unexpect aCatch(SALOME_SalomeException);
627 MESSAGE("SMESH_Mesh_i::GetSubMesh");
628 if (CORBA::is_nil(aSubShapeObject))
629 THROW_SALOME_CORBA_EXCEPTION("bad subShape reference",
634 TopoDS_Shape myLocSubShape
635 = _gen_i->GetShapeReader()->GetShape(SMESH_Gen_i::GetGeomEngine(), aSubShapeObject);
637 //Get or Create the SMESH_subMesh object implementation
639 ::SMESH_subMesh * mySubMesh = _impl->GetSubMesh(myLocSubShape);
640 subMeshId = mySubMesh->GetId();
642 // create a new subMesh object servant if there is none for the shape
644 if (_mapSubMesh.find(subMeshId) == _mapSubMesh.end()) {
645 SMESH::SMESH_subMesh_var subMesh = createSubMesh( aSubShapeObject );
646 if ( _gen_i->CanPublishInStudy( subMesh ) ) {
647 SALOMEDS::SObject_var aSubmeshSO = _gen_i->PublishInStudy( _gen_i->GetCurrentStudy(),
648 SALOMEDS::SObject::_nil(),
652 // Add reference to <aSubShape> to the study
653 SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
654 SALOMEDS::SObject_var aShapeSO = aStudy->FindObjectIOR( SMESH_Gen_i::GetORB()->object_to_string( aSubShapeObject ) );
655 if ( !aSubmeshSO->_is_nil() && !aShapeSO->_is_nil() ) {
656 if(MYDEBUG) MESSAGE( "********** SMESH_Mesh_i::GetSubMesh(): adding shape reference..." )
657 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
658 SALOMEDS::SObject_var SO = aBuilder->NewObjectToTag( aSubmeshSO, SMESH_Gen_i::GetRefOnShapeTag() );
659 aBuilder->Addreference( SO, aShapeSO );
660 if(MYDEBUG) MESSAGE( "********** SMESH_Mesh_i::GetSubMesh(): shape reference added" )
665 catch(SALOME_Exception & S_ex) {
666 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
669 ASSERT(_mapSubMeshIor.find(subMeshId) != _mapSubMeshIor.end());
670 return SMESH::SMESH_subMesh::_duplicate(_mapSubMeshIor[subMeshId]);
674 //=============================================================================
678 //=============================================================================
680 void SMESH_Mesh_i::RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh )
681 throw (SALOME::SALOME_Exception)
683 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::RemoveSubMesh");
684 if ( theSubMesh->_is_nil() )
687 GEOM::GEOM_Object_var aSubShapeObject;
688 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
689 if ( !aStudy->_is_nil() ) {
690 // Remove submesh's SObject
691 SALOMEDS::SObject_var anSO = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( theSubMesh ) ) ) );
692 if ( !anSO->_is_nil() ) {
693 long aTag = SMESH_Gen_i::GetRefOnShapeTag();
694 SALOMEDS::SObject_var anObj, aRef;
695 if ( anSO->FindSubObject( aTag, anObj ) && anObj->ReferencedObject( aRef ) )
696 aSubShapeObject = GEOM::GEOM_Object::_narrow( aRef->GetObject() );
698 aStudy->NewBuilder()->RemoveObjectWithChildren( anSO );
702 removeSubMesh( theSubMesh, aSubShapeObject.in() );
706 //=============================================================================
710 //=============================================================================
712 SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateGroup( SMESH::ElementType theElemType,
713 const char* theName )
714 throw(SALOME::SALOME_Exception)
716 Unexpect aCatch(SALOME_SalomeException);
717 SMESH::SMESH_Group_var aNewGroup = createGroup( theElemType, theName );
719 // Groups should be put under separate roots according to their type (nodes, edges, faces, volumes)
720 if ( _gen_i->CanPublishInStudy( aNewGroup ) ) {
721 SALOMEDS::SObject_var aGroupSO = _gen_i->PublishInStudy( _gen_i->GetCurrentStudy(),
722 SALOMEDS::SObject::_nil(),
727 return aNewGroup._retn();
731 //=============================================================================
735 //=============================================================================
736 SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateGroupFromGEOM( SMESH::ElementType theElemType,
738 GEOM::GEOM_Object_ptr theGEOMGroup)
739 throw(SALOME::SALOME_Exception)
741 Unexpect aCatch(SALOME_SalomeException);
743 SMESH::SMESH_Group_var aNewGroup = createGroup( theElemType, theName );
745 if ( CORBA::is_nil(theGEOMGroup) || theGEOMGroup->GetType() != 37 || CORBA::is_nil(aNewGroup))
746 return aNewGroup._retn();
748 GEOM::GEOM_IGroupOperations_var aGroupOp = SMESH_Gen_i::GetGeomEngine()->GetIGroupOperations(_studyId);
749 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
751 // Check if group constructed on the same shape as a mesh or on its child:
752 GEOM::GEOM_Object_var aGroupMainShape = aGroupOp->GetMainShape( theGEOMGroup );
753 SALOMEDS::SObject_var aGroupMainShapeSO =
754 SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( SMESH_Gen_i::GetORB()->object_to_string(aGroupMainShape) ) );
755 SALOMEDS::SObject_var aMeshSO =
756 SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( _this() ) ) ) );
758 SALOMEDS::SObject_var anObj, aRef;
759 bool isRefOrSubShape = false;
761 if ( aMeshSO->FindSubObject( 1, anObj ) && anObj->ReferencedObject( aRef )) {
762 if ( strcmp( aRef->GetID(), aGroupMainShapeSO->GetID() ) == 0 )
763 isRefOrSubShape = true;
766 SALOMEDS::SObject_var aFather = aGroupMainShapeSO->GetFather();
767 SALOMEDS::SComponent_var aComponent = aGroupMainShapeSO->GetFatherComponent();
768 while ( !isRefOrSubShape && strcmp( aFather->GetID(), aComponent->GetID() ) != 0 )
770 if (strcmp( aRef->GetID(), aFather->GetID() ) == 0)
771 isRefOrSubShape = true;
773 aFather = aFather->GetFather();
776 if ( !isRefOrSubShape )
777 return aNewGroup._retn();
780 // Detect type of the geometry group
781 SMESH::ElementType aGEOMGroupType;
783 SMESH::ElementType aGroupType = SMESH::ALL;
784 switch(aGroupOp->GetType(theGEOMGroup))
786 case 7: aGEOMGroupType = SMESH::NODE; break;
787 case 6: aGEOMGroupType = SMESH::EDGE; break;
788 case 4: aGEOMGroupType = SMESH::FACE; break;
789 case 2: aGEOMGroupType = SMESH::VOLUME; break;
792 if ( aGEOMGroupType == theElemType )
794 if ( !aStudy->_is_nil() )
796 SALOMEDS::SObject_var aGEOMGroupSO =
797 SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( SMESH_Gen_i::GetORB()->object_to_string(theGEOMGroup) ) );
799 if ( !aGEOMGroupSO->_is_nil() ) {
801 SMESH::FilterManager_var aFilterMgr = _gen_i->CreateFilterManager();
802 SMESH::Filter_var aFilter = aFilterMgr->CreateFilter();
803 SMESH::BelongToGeom_var aBelongToGeom = aFilterMgr->CreateBelongToGeom();
804 aBelongToGeom->SetGeom( theGEOMGroup );
805 aBelongToGeom->SetShapeName( aGEOMGroupSO->GetName() );
806 aBelongToGeom->SetElementType( theElemType );
807 aFilter->SetPredicate( aBelongToGeom );
808 SMESH::long_array_var anElements = aFilter->GetElementsId( _this() );
809 aNewGroup->Add( anElements );
811 // Groups should be put under separate roots according to their type (nodes, edges, faces, volumes)
812 if ( _gen_i->CanPublishInStudy( aNewGroup ) )
814 SALOMEDS::SObject_var aGroupSO = _gen_i->PublishInStudy( _gen_i->GetCurrentStudy(),
815 SALOMEDS::SObject::_nil(),
818 if ( !aGroupSO->_is_nil() )
820 //Add reference to geometry group
821 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
822 SALOMEDS::SObject_var aReference = aStudyBuilder->NewObject(aGroupSO);
823 aStudyBuilder->Addreference(aReference, aGEOMGroupSO);
830 return aNewGroup._retn();
832 //=============================================================================
836 //=============================================================================
838 void SMESH_Mesh_i::RemoveGroup( SMESH::SMESH_Group_ptr theGroup )
839 throw (SALOME::SALOME_Exception)
841 if ( theGroup->_is_nil() )
844 SMESH_Group_i* aGroup = dynamic_cast<SMESH_Group_i*>( SMESH_Gen_i::GetServant( theGroup ).in() );
848 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
849 if ( !aStudy->_is_nil() ) {
850 // Remove group's SObject
851 SALOMEDS::SObject_var aGroupSO = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( theGroup ) ) ) );
852 if ( !aGroupSO->_is_nil() )
853 aStudy->NewBuilder()->RemoveObject( aGroupSO );
856 // Remove the group from SMESH data structures
857 removeGroup( aGroup->GetLocalID() );
860 //=============================================================================
861 /*! RemoveGroupWithContents
862 * Remove group with its contents
864 //=============================================================================
865 void SMESH_Mesh_i::RemoveGroupWithContents( SMESH::SMESH_Group_ptr theGroup )
866 throw (SALOME::SALOME_Exception)
868 if ( theGroup->_is_nil() )
871 SMESH_Group_i* aGroup = dynamic_cast<SMESH_Group_i*>( SMESH_Gen_i::GetServant( theGroup ).in() );
875 SMESH::long_array_var anIds = aGroup->GetListOfID();
876 SMESH::SMESH_MeshEditor_var aMeshEditor = SMESH_Mesh_i::GetMeshEditor();
878 if ( aGroup->GetType() == SMESH::NODE )
879 aMeshEditor->RemoveNodes( anIds );
881 aMeshEditor->RemoveElements( anIds );
883 RemoveGroup( theGroup );
886 //=============================================================================
888 * New group is created. All mesh elements that are
889 * present in initial groups are added to the new one
891 //=============================================================================
892 SMESH::SMESH_Group_ptr SMESH_Mesh_i::UnionGroups( SMESH::SMESH_Group_ptr theGroup1,
893 SMESH::SMESH_Group_ptr theGroup2,
894 const char* theName )
895 throw (SALOME::SALOME_Exception)
899 SMESH::SMESH_Group_var aResGrp;
901 if ( theGroup1->_is_nil() || theGroup2->_is_nil() ||
902 theGroup1->GetType() != theGroup2->GetType() )
903 return SMESH::SMESH_Group::_nil();
905 aResGrp = CreateGroup( theGroup1->GetType(), theName );
906 if ( aResGrp->_is_nil() )
907 return SMESH::SMESH_Group::_nil();
909 SMESH::long_array_var anIds1 = theGroup1->GetListOfID();
910 SMESH::long_array_var anIds2 = theGroup2->GetListOfID();
912 TColStd_MapOfInteger aResMap;
914 for ( int i1 = 0, n1 = anIds1->length(); i1 < n1; i1++ )
915 aResMap.Add( anIds1[ i1 ] );
917 for ( int i2 = 0, n2 = anIds2->length(); i2 < n2; i2++ )
918 aResMap.Add( anIds2[ i2 ] );
920 SMESH::long_array_var aResIds = new SMESH::long_array;
921 aResIds->length( aResMap.Extent() );
924 TColStd_MapIteratorOfMapOfInteger anIter( aResMap );
925 for( ; anIter.More(); anIter.Next() )
926 aResIds[ resI++ ] = anIter.Key();
928 aResGrp->Add( aResIds );
930 return aResGrp._retn();
934 return SMESH::SMESH_Group::_nil();
938 //=============================================================================
940 * New group is created. All mesh elements that are
941 * present in both initial groups are added to the new one.
943 //=============================================================================
944 SMESH::SMESH_Group_ptr SMESH_Mesh_i::IntersectGroups( SMESH::SMESH_Group_ptr theGroup1,
945 SMESH::SMESH_Group_ptr theGroup2,
946 const char* theName )
947 throw (SALOME::SALOME_Exception)
949 SMESH::SMESH_Group_var aResGrp;
951 if ( theGroup1->_is_nil() || theGroup2->_is_nil() ||
952 theGroup1->GetType() != theGroup2->GetType() )
955 aResGrp = CreateGroup( theGroup1->GetType(), theName );
956 if ( aResGrp->_is_nil() )
959 SMESH::long_array_var anIds1 = theGroup1->GetListOfID();
960 SMESH::long_array_var anIds2 = theGroup2->GetListOfID();
962 TColStd_MapOfInteger aMap1;
964 for ( int i1 = 0, n1 = anIds1->length(); i1 < n1; i1++ )
965 aMap1.Add( anIds1[ i1 ] );
967 TColStd_SequenceOfInteger aSeq;
969 for ( int i2 = 0, n2 = anIds2->length(); i2 < n2; i2++ )
970 if ( aMap1.Contains( anIds2[ i2 ] ) )
971 aSeq.Append( anIds2[ i2 ] );
973 SMESH::long_array_var aResIds = new SMESH::long_array;
974 aResIds->length( aSeq.Length() );
976 for ( int resI = 0, resN = aSeq.Length(); resI < resN; resI++ )
977 aResIds[ resI ] = aSeq( resI + 1 );
979 aResGrp->Add( aResIds );
981 return aResGrp._retn();
984 //=============================================================================
986 * New group is created. All mesh elements that are present in
987 * main group but do not present in tool group are added to the new one
989 //=============================================================================
990 SMESH::SMESH_Group_ptr SMESH_Mesh_i::CutGroups( SMESH::SMESH_Group_ptr theGroup1,
991 SMESH::SMESH_Group_ptr theGroup2,
992 const char* theName )
993 throw (SALOME::SALOME_Exception)
995 SMESH::SMESH_Group_var aResGrp;
997 if ( theGroup1->_is_nil() || theGroup2->_is_nil() ||
998 theGroup1->GetType() != theGroup2->GetType() )
1001 aResGrp = CreateGroup( theGroup1->GetType(), theName );
1002 if ( aResGrp->_is_nil() )
1005 SMESH::long_array_var anIds1 = theGroup1->GetListOfID();
1006 SMESH::long_array_var anIds2 = theGroup2->GetListOfID();
1008 TColStd_MapOfInteger aMap2;
1010 for ( int i2 = 0, n2 = anIds2->length(); i2 < n2; i2++ )
1011 aMap2.Add( anIds2[ i2 ] );
1014 TColStd_SequenceOfInteger aSeq;
1015 for ( int i1 = 0, n1 = anIds1->length(); i1 < n1; i1++ )
1016 if ( !aMap2.Contains( anIds1[ i1 ] ) )
1017 aSeq.Append( anIds1[ i1 ] );
1019 SMESH::long_array_var aResIds = new SMESH::long_array;
1020 aResIds->length( aSeq.Length() );
1022 for ( int resI = 0, resN = aSeq.Length(); resI < resN; resI++ )
1023 aResIds[ resI ] = aSeq( resI + 1 );
1025 aResGrp->Add( aResIds );
1027 return aResGrp._retn();
1030 //=============================================================================
1034 //=============================================================================
1036 SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::createSubMesh( GEOM::GEOM_Object_ptr theSubShapeObject )
1038 TopoDS_Shape myLocSubShape = _gen_i->GetShapeReader()->GetShape(SMESH_Gen_i::GetGeomEngine(), theSubShapeObject);
1040 ::SMESH_subMesh * mySubMesh = _impl->GetSubMesh(myLocSubShape);
1041 int subMeshId = mySubMesh->GetId();
1042 SMESH_subMesh_i *subMeshServant = new SMESH_subMesh_i(myPOA, _gen_i, this, subMeshId);
1043 SMESH::SMESH_subMesh_var subMesh
1044 = SMESH::SMESH_subMesh::_narrow(subMeshServant->_this());
1046 _mapSubMesh[subMeshId] = mySubMesh;
1047 _mapSubMesh_i[subMeshId] = subMeshServant;
1048 _mapSubMeshIor[subMeshId]
1049 = SMESH::SMESH_subMesh::_duplicate(subMesh);
1051 // register CORBA object for persistence
1052 StudyContext* myStudyContext = _gen_i->GetCurrentStudyContext();
1053 string iorString = SMESH_Gen_i::GetORB()->object_to_string( subMesh );
1054 int nextId = myStudyContext->addObject( iorString );
1055 if(MYDEBUG) MESSAGE( "Add submesh to map with id = "<< nextId << " and IOR = " << iorString.c_str() );
1057 return subMesh._retn();
1061 //=============================================================================
1065 //=============================================================================
1067 void SMESH_Mesh_i::removeSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh, GEOM::GEOM_Object_ptr theSubShapeObject )
1069 MESSAGE("SMESH_Mesh_i::removeSubMesh()");
1070 if ( theSubMesh->_is_nil() || theSubShapeObject->_is_nil() )
1074 SMESH::ListOfHypothesis_var aHypList = GetHypothesisList( theSubShapeObject );
1075 for ( int i = 0, n = aHypList->length(); i < n; i++ ) {
1076 removeHypothesis( theSubShapeObject, aHypList[i] );
1079 catch( const SALOME::SALOME_Exception& ) {
1080 INFOS("SMESH_Mesh_i::removeSubMesh(): exception caught!");
1083 int subMeshId = theSubMesh->GetId();
1085 _mapSubMesh.erase(subMeshId);
1086 _mapSubMesh_i.erase(subMeshId);
1087 _mapSubMeshIor.erase(subMeshId);
1088 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::removeSubMesh() completed");
1091 //=============================================================================
1095 //=============================================================================
1097 SMESH::SMESH_Group_ptr SMESH_Mesh_i::createGroup( SMESH::ElementType theElemType, const char* theName )
1100 SMESH::SMESH_Group_var aGroup;
1101 if ( _impl->AddGroup( (SMDSAbs_ElementType)theElemType, theName, anId ) ) {
1102 SMESH_Group_i* aGroupImpl = new SMESH_Group_i( SMESH_Gen_i::GetPOA(), this, anId );
1103 aGroup = SMESH::SMESH_Group::_narrow( aGroupImpl->_this() );
1104 _mapGroups[anId] = SMESH::SMESH_Group::_duplicate( aGroup );
1106 // register CORBA object for persistence
1107 StudyContext* myStudyContext = _gen_i->GetCurrentStudyContext();
1108 string iorString = SMESH_Gen_i::GetORB()->object_to_string( aGroup );
1109 int nextId = myStudyContext->addObject( iorString );
1110 if(MYDEBUG) MESSAGE( "Add group to map with id = "<< nextId << " and IOR = " << iorString.c_str() );
1112 return aGroup._retn();
1116 //=============================================================================
1118 * SMESH_Mesh_i::removeGroup
1120 * Should be called by ~SMESH_Group_i()
1122 //=============================================================================
1124 void SMESH_Mesh_i::removeGroup( const int theId )
1126 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::removeGroup()" );
1127 if ( _mapGroups.find( theId ) != _mapGroups.end() ) {
1128 _mapGroups.erase( theId );
1129 _impl->RemoveGroup( theId );
1134 //=============================================================================
1138 //=============================================================================
1140 SMESH::log_array * SMESH_Mesh_i::GetLog(CORBA::Boolean clearAfterGet)
1141 throw(SALOME::SALOME_Exception)
1143 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::GetLog");
1145 SMESH::log_array_var aLog;
1147 list < SMESHDS_Command * >logDS = _impl->GetLog();
1148 aLog = new SMESH::log_array;
1150 int lg = logDS.size();
1153 list < SMESHDS_Command * >::iterator its = logDS.begin();
1154 while(its != logDS.end()){
1155 SMESHDS_Command *com = *its;
1156 int comType = com->GetType();
1158 int lgcom = com->GetNumber();
1160 const list < int >&intList = com->GetIndexes();
1161 int inum = intList.size();
1163 list < int >::const_iterator ii = intList.begin();
1164 const list < double >&coordList = com->GetCoords();
1165 int rnum = coordList.size();
1167 list < double >::const_iterator ir = coordList.begin();
1168 aLog[indexLog].commandType = comType;
1169 aLog[indexLog].number = lgcom;
1170 aLog[indexLog].coords.length(rnum);
1171 aLog[indexLog].indexes.length(inum);
1172 for(int i = 0; i < rnum; i++){
1173 aLog[indexLog].coords[i] = *ir;
1174 //MESSAGE(" "<<i<<" "<<ir.Value());
1177 for(int i = 0; i < inum; i++){
1178 aLog[indexLog].indexes[i] = *ii;
1179 //MESSAGE(" "<<i<<" "<<ii.Value());
1188 catch(SALOME_Exception & S_ex){
1189 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
1191 return aLog._retn();
1195 //=============================================================================
1199 //=============================================================================
1201 void SMESH_Mesh_i::ClearLog() throw(SALOME::SALOME_Exception)
1203 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::ClearLog");
1207 //=============================================================================
1211 //=============================================================================
1213 CORBA::Long SMESH_Mesh_i::GetId()throw(SALOME::SALOME_Exception)
1215 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::GetId");
1219 //=============================================================================
1223 //=============================================================================
1225 CORBA::Long SMESH_Mesh_i::GetStudyId()throw(SALOME::SALOME_Exception)
1230 //=============================================================================
1234 //=============================================================================
1236 void SMESH_Mesh_i::SetImpl(::SMESH_Mesh * impl)
1238 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::SetImpl");
1242 //=============================================================================
1246 //=============================================================================
1248 ::SMESH_Mesh & SMESH_Mesh_i::GetImpl()
1250 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::GetImpl()");
1255 //=============================================================================
1259 //=============================================================================
1261 SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditor()
1263 SMESH_MeshEditor_i *aMeshEditor = new SMESH_MeshEditor_i( _impl );
1264 SMESH::SMESH_MeshEditor_var aMesh = aMeshEditor->_this();
1265 return aMesh._retn();
1268 //=============================================================================
1272 //=============================================================================
1274 void SMESH_Mesh_i::ExportMED(const char *file, CORBA::Boolean auto_groups) throw(SALOME::SALOME_Exception)
1276 Unexpect aCatch(SALOME_SalomeException);
1277 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
1278 if ( aStudy->_is_nil() )
1281 char* aMeshName = NULL;
1282 SALOMEDS::SObject_var aMeshSO = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( _this() ) ) ) );
1283 if ( !aMeshSO->_is_nil() )
1285 aMeshName = aMeshSO->GetName();
1287 //SCRUTE(aMeshName);
1288 //SCRUTE(aMeshSO->GetID());
1289 SALOMEDS::GenericAttribute_var anAttr;
1290 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
1291 SALOMEDS::AttributeExternalFileDef_var aFileName;
1292 anAttr=aStudyBuilder->FindOrCreateAttribute(aMeshSO, "AttributeExternalFileDef");
1293 aFileName = SALOMEDS::AttributeExternalFileDef::_narrow(anAttr);
1294 ASSERT(!aFileName->_is_nil());
1295 aFileName->SetValue(file);
1296 SALOMEDS::AttributeFileType_var aFileType;
1297 anAttr=aStudyBuilder->FindOrCreateAttribute(aMeshSO, "AttributeFileType");
1298 aFileType = SALOMEDS::AttributeFileType::_narrow(anAttr);
1299 ASSERT(!aFileType->_is_nil());
1300 aFileType->SetValue("FICHIERMED");
1302 _impl->ExportMED( file, aMeshName, auto_groups );
1305 void SMESH_Mesh_i::ExportDAT(const char *file) throw(SALOME::SALOME_Exception)
1307 Unexpect aCatch(SALOME_SalomeException);
1308 _impl->ExportDAT(file);
1310 void SMESH_Mesh_i::ExportUNV(const char *file) throw(SALOME::SALOME_Exception)
1312 Unexpect aCatch(SALOME_SalomeException);
1313 _impl->ExportUNV(file);
1316 void SMESH_Mesh_i::ExportSTL(const char *file, const bool isascii) throw(SALOME::SALOME_Exception)
1318 Unexpect aCatch(SALOME_SalomeException);
1319 _impl->ExportSTL(file, isascii);
1322 //=============================================================================
1326 //=============================================================================
1328 SALOME_MED::MESH_ptr SMESH_Mesh_i::GetMEDMesh()throw(SALOME::SALOME_Exception)
1330 Unexpect aCatch(SALOME_SalomeException);
1331 SMESH_MEDMesh_i *aMedMesh = new SMESH_MEDMesh_i(this);
1332 SALOME_MED::MESH_var aMesh = aMedMesh->_this();
1333 return aMesh._retn();
1336 //=============================================================================
1340 //=============================================================================
1341 CORBA::Long SMESH_Mesh_i::NbNodes()throw(SALOME::SALOME_Exception)
1343 Unexpect aCatch(SALOME_SalomeException);
1344 return _impl->NbNodes();
1347 //=============================================================================
1351 //=============================================================================
1352 CORBA::Long SMESH_Mesh_i::NbEdges()throw(SALOME::SALOME_Exception)
1354 Unexpect aCatch(SALOME_SalomeException);
1355 return _impl->NbEdges();
1358 //=============================================================================
1362 //=============================================================================
1363 CORBA::Long SMESH_Mesh_i::NbFaces()throw(SALOME::SALOME_Exception)
1365 Unexpect aCatch(SALOME_SalomeException);
1366 return _impl->NbFaces();
1369 CORBA::Long SMESH_Mesh_i::NbTriangles()throw(SALOME::SALOME_Exception)
1371 Unexpect aCatch(SALOME_SalomeException);
1372 return _impl->NbTriangles();
1375 CORBA::Long SMESH_Mesh_i::NbQuadrangles()throw(SALOME::SALOME_Exception)
1377 Unexpect aCatch(SALOME_SalomeException);
1378 return _impl->NbQuadrangles();
1381 //=============================================================================
1385 //=============================================================================
1386 CORBA::Long SMESH_Mesh_i::NbVolumes()throw(SALOME::SALOME_Exception)
1388 Unexpect aCatch(SALOME_SalomeException);
1389 return _impl->NbVolumes();
1392 CORBA::Long SMESH_Mesh_i::NbTetras()throw(SALOME::SALOME_Exception)
1394 Unexpect aCatch(SALOME_SalomeException);
1395 return _impl->NbTetras();
1398 CORBA::Long SMESH_Mesh_i::NbHexas()throw(SALOME::SALOME_Exception)
1400 Unexpect aCatch(SALOME_SalomeException);
1401 return _impl->NbHexas();
1404 CORBA::Long SMESH_Mesh_i::NbPyramids()throw(SALOME::SALOME_Exception)
1406 Unexpect aCatch(SALOME_SalomeException);
1407 return _impl->NbPyramids();
1410 CORBA::Long SMESH_Mesh_i::NbPrisms()throw(SALOME::SALOME_Exception)
1412 Unexpect aCatch(SALOME_SalomeException);
1413 return _impl->NbPrisms();
1416 //=============================================================================
1420 //=============================================================================
1421 CORBA::Long SMESH_Mesh_i::NbSubMesh()throw(SALOME::SALOME_Exception)
1423 Unexpect aCatch(SALOME_SalomeException);
1424 return _impl->NbSubMesh();
1427 //=============================================================================
1431 //=============================================================================
1432 char* SMESH_Mesh_i::Dump()
1434 std::ostringstream os;
1436 return CORBA::string_dup( os.str().c_str() );