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.salome-platform.org/ or email : webmaster.salome@opencascade.com
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"
34 #include "SMESH_PythonDump.hxx"
36 #include "Utils_CorbaException.hxx"
37 #include "Utils_ExceptHandlers.hxx"
38 #include "utilities.h"
40 #include "SALOME_NamingService.hxx"
41 #include "Utils_SINGLETON.hxx"
44 #include "SMESHDS_Command.hxx"
45 #include "SMESHDS_CommandType.hxx"
46 #include "SMESH_MeshEditor_i.hxx"
47 #include "SMESH_Gen_i.hxx"
48 #include "DriverMED_R_SMESHDS_Mesh.h"
49 //#include "SMDS_ElemIterator.hxx"
50 #include "SMDS_VolumeTool.hxx"
51 #include "SMESH_MesherHelper.hxx"
52 #include "SMESH_MeshEditor.hxx"
55 #include <OSD_Path.hxx>
56 #include <OSD_File.hxx>
57 #include <OSD_Directory.hxx>
58 #include <OSD_Protection.hxx>
59 #include <TColStd_MapOfInteger.hxx>
60 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
61 #include <TColStd_SequenceOfInteger.hxx>
62 #include "TCollection_AsciiString.hxx"
70 static int MYDEBUG = 0;
72 static int MYDEBUG = 0;
76 using SMESH::TPythonDump;
78 int SMESH_Mesh_i::myIdGenerator = 0;
82 //=============================================================================
86 //=============================================================================
88 SMESH_Mesh_i::SMESH_Mesh_i( PortableServer::POA_ptr thePOA,
91 : SALOME::GenericObj_i( thePOA )
93 MESSAGE("SMESH_Mesh_i");
96 _id = myIdGenerator++;
100 //=============================================================================
104 //=============================================================================
106 SMESH_Mesh_i::~SMESH_Mesh_i()
108 INFOS("~SMESH_Mesh_i");
109 map<int, SMESH::SMESH_GroupBase_ptr>::iterator it;
110 for ( it = _mapGroups.begin(); it != _mapGroups.end(); it++ ) {
111 SMESH_GroupBase_i* aGroup = dynamic_cast<SMESH_GroupBase_i*>( SMESH_Gen_i::GetServant( it->second ).in() );
114 // this method is colled from destructor of group (PAL6331)
115 //_impl->RemoveGroup( aGroup->GetLocalID() );
123 //=============================================================================
127 * Associates <this> mesh with <theShape> and puts a reference
128 * to <theShape> into the current study;
129 * the previous shape is substituted by the new one.
131 //=============================================================================
133 void SMESH_Mesh_i::SetShape( GEOM::GEOM_Object_ptr theShapeObject )
134 throw (SALOME::SALOME_Exception)
136 Unexpect aCatch(SALOME_SalomeException);
138 _impl->ShapeToMesh( _gen_i->GeomObjectToShape( theShapeObject ));
140 catch(SALOME_Exception & S_ex) {
141 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
145 //================================================================================
147 * \brief return true if mesh has a shape to build a shape on
149 //================================================================================
151 CORBA::Boolean SMESH_Mesh_i::HasShapeToMesh()
152 throw (SALOME::SALOME_Exception)
154 Unexpect aCatch(SALOME_SalomeException);
157 res = _impl->HasShapeToMesh();
159 catch(SALOME_Exception & S_ex) {
160 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
165 //=======================================================================
166 //function : GetShapeToMesh
168 //=======================================================================
170 GEOM::GEOM_Object_ptr SMESH_Mesh_i::GetShapeToMesh()
171 throw (SALOME::SALOME_Exception)
173 Unexpect aCatch(SALOME_SalomeException);
174 GEOM::GEOM_Object_var aShapeObj;
176 TopoDS_Shape S = _impl->GetMeshDS()->ShapeToMesh();
178 aShapeObj = _gen_i->ShapeToGeomObject( S );
180 catch(SALOME_Exception & S_ex) {
181 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
183 return aShapeObj._retn();
186 //=============================================================================
190 //=============================================================================
192 static SMESH::DriverMED_ReadStatus ConvertDriverMEDReadStatus (int theStatus)
194 SMESH::DriverMED_ReadStatus res;
197 case DriverMED_R_SMESHDS_Mesh::DRS_OK:
198 res = SMESH::DRS_OK; break;
199 case DriverMED_R_SMESHDS_Mesh::DRS_EMPTY:
200 res = SMESH::DRS_EMPTY; break;
201 case DriverMED_R_SMESHDS_Mesh::DRS_WARN_RENUMBER:
202 res = SMESH::DRS_WARN_RENUMBER; break;
203 case DriverMED_R_SMESHDS_Mesh::DRS_WARN_SKIP_ELEM:
204 res = SMESH::DRS_WARN_SKIP_ELEM; break;
205 case DriverMED_R_SMESHDS_Mesh::DRS_FAIL:
207 res = SMESH::DRS_FAIL; break;
212 //=============================================================================
216 * Imports mesh data from MED file
218 //=============================================================================
220 SMESH::DriverMED_ReadStatus
221 SMESH_Mesh_i::ImportMEDFile( const char* theFileName, const char* theMeshName )
222 throw ( SALOME::SALOME_Exception )
224 Unexpect aCatch(SALOME_SalomeException);
227 status = importMEDFile( theFileName, theMeshName );
229 catch( SALOME_Exception& S_ex ) {
230 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
233 THROW_SALOME_CORBA_EXCEPTION("ImportMEDFile(): unknown exception", SALOME::BAD_PARAM);
236 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
237 if ( !aStudy->_is_nil() ) {
238 // publishing of the groups in the study (sub-meshes are out of scope of MED import)
239 map<int, SMESH::SMESH_GroupBase_ptr>::iterator it = _mapGroups.begin();
240 for (; it != _mapGroups.end(); it++ ) {
241 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_duplicate( it->second );
242 _gen_i->PublishGroup( aStudy, _this(), aGroup,
243 GEOM::GEOM_Object::_nil(), aGroup->GetName());
246 return ConvertDriverMEDReadStatus(status);
249 //=============================================================================
253 * Imports mesh data from MED file
255 //=============================================================================
257 int SMESH_Mesh_i::ImportUNVFile( const char* theFileName )
258 throw ( SALOME::SALOME_Exception )
260 // Read mesh with name = <theMeshName> into SMESH_Mesh
261 _impl->UNVToMesh( theFileName );
263 CreateGroupServants();
265 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
266 if ( !aStudy->_is_nil() ) {
267 // publishing of the groups in the study (sub-meshes are out of scope of UNV import)
268 map<int, SMESH::SMESH_GroupBase_ptr>::iterator it = _mapGroups.begin();
269 for (; it != _mapGroups.end(); it++ ) {
270 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_duplicate( it->second );
271 _gen_i->PublishGroup( aStudy, _this(), aGroup,
272 GEOM::GEOM_Object::_nil(), aGroup->GetName());
278 //=============================================================================
282 * Imports mesh data from STL file
284 //=============================================================================
285 int SMESH_Mesh_i::ImportSTLFile( const char* theFileName )
286 throw ( SALOME::SALOME_Exception )
288 // Read mesh with name = <theMeshName> into SMESH_Mesh
289 _impl->STLToMesh( theFileName );
294 //=============================================================================
298 * Imports mesh data from MED file
300 //=============================================================================
302 int SMESH_Mesh_i::importMEDFile( const char* theFileName, const char* theMeshName )
304 // Read mesh with name = <theMeshName> and all its groups into SMESH_Mesh
305 int status = _impl->MEDToMesh( theFileName, theMeshName );
306 CreateGroupServants();
311 //=============================================================================
315 //=============================================================================
317 #define RETURNCASE(hyp_stat) case SMESH_Hypothesis::hyp_stat: return SMESH::hyp_stat;
319 SMESH::Hypothesis_Status SMESH_Mesh_i::ConvertHypothesisStatus
320 (SMESH_Hypothesis::Hypothesis_Status theStatus)
323 RETURNCASE( HYP_OK );
324 RETURNCASE( HYP_MISSING );
325 RETURNCASE( HYP_CONCURENT );
326 RETURNCASE( HYP_BAD_PARAMETER );
327 RETURNCASE( HYP_HIDDEN_ALGO );
328 RETURNCASE( HYP_HIDING_ALGO );
329 RETURNCASE( HYP_UNKNOWN_FATAL );
330 RETURNCASE( HYP_INCOMPATIBLE );
331 RETURNCASE( HYP_NOTCONFORM );
332 RETURNCASE( HYP_ALREADY_EXIST );
333 RETURNCASE( HYP_BAD_DIM );
334 RETURNCASE( HYP_BAD_SUBSHAPE );
335 RETURNCASE( HYP_BAD_GEOMETRY );
338 return SMESH::HYP_UNKNOWN_FATAL;
341 //=============================================================================
345 * calls internal addHypothesis() and then adds a reference to <anHyp> under
346 * the SObject actually having a reference to <aSubShape>.
347 * NB: For this method to work, it is necessary to add a reference to sub-shape first.
349 //=============================================================================
351 SMESH::Hypothesis_Status SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
352 SMESH::SMESH_Hypothesis_ptr anHyp)
353 throw(SALOME::SALOME_Exception)
355 Unexpect aCatch(SALOME_SalomeException);
356 SMESH_Hypothesis::Hypothesis_Status status = addHypothesis( aSubShapeObject, anHyp );
358 if ( !SMESH_Hypothesis::IsStatusFatal(status) )
359 _gen_i->AddHypothesisToShape(_gen_i->GetCurrentStudy(), _this(),
360 aSubShapeObject, anHyp );
362 if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status );
364 // Update Python script
365 TPythonDump() << "status = " << _this() << ".AddHypothesis( "
366 << aSubShapeObject << ", " << anHyp << " )";
368 return ConvertHypothesisStatus(status);
371 //=============================================================================
375 //=============================================================================
377 SMESH_Hypothesis::Hypothesis_Status
378 SMESH_Mesh_i::addHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
379 SMESH::SMESH_Hypothesis_ptr anHyp)
381 if(MYDEBUG) MESSAGE("addHypothesis");
383 if (CORBA::is_nil(aSubShapeObject))
384 THROW_SALOME_CORBA_EXCEPTION("bad subShape reference",
387 SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow(anHyp);
388 if (CORBA::is_nil(myHyp))
389 THROW_SALOME_CORBA_EXCEPTION("bad hypothesis reference",
392 SMESH_Hypothesis::Hypothesis_Status status = SMESH_Hypothesis::HYP_OK;
395 TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape( aSubShapeObject);
396 int hypId = myHyp->GetId();
397 status = _impl->AddHypothesis(myLocSubShape, hypId);
398 if ( !SMESH_Hypothesis::IsStatusFatal(status) ) {
399 _mapHypo[hypId] = SMESH::SMESH_Hypothesis::_duplicate( myHyp );
400 // assure there is a corresponding submesh
401 if ( !_impl->IsMainShape( myLocSubShape )) {
402 int shapeId = _impl->GetMeshDS()->ShapeToIndex( myLocSubShape );
403 if ( _mapSubMesh_i.find( shapeId ) == _mapSubMesh_i.end() )
404 createSubMesh( aSubShapeObject );
408 catch(SALOME_Exception & S_ex)
410 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
415 //=============================================================================
419 //=============================================================================
421 SMESH::Hypothesis_Status SMESH_Mesh_i::RemoveHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
422 SMESH::SMESH_Hypothesis_ptr anHyp)
423 throw(SALOME::SALOME_Exception)
425 Unexpect aCatch(SALOME_SalomeException);
426 SMESH_Hypothesis::Hypothesis_Status status = removeHypothesis( aSubShapeObject, anHyp );
428 if ( !SMESH_Hypothesis::IsStatusFatal(status) )
429 _gen_i->RemoveHypothesisFromShape(_gen_i->GetCurrentStudy(), _this(),
430 aSubShapeObject, anHyp );
432 // Update Python script
433 TPythonDump() << "status = " << _this() << ".RemoveHypothesis( "
434 << aSubShapeObject << ", " << anHyp << " )";
436 return ConvertHypothesisStatus(status);
439 //=============================================================================
443 //=============================================================================
445 SMESH_Hypothesis::Hypothesis_Status SMESH_Mesh_i::removeHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
446 SMESH::SMESH_Hypothesis_ptr anHyp)
448 if(MYDEBUG) MESSAGE("removeHypothesis()");
449 // **** proposer liste de subShape (selection multiple)
451 if (CORBA::is_nil(aSubShapeObject))
452 THROW_SALOME_CORBA_EXCEPTION("bad subShape reference",
455 SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow(anHyp);
456 if (CORBA::is_nil(myHyp))
457 THROW_SALOME_CORBA_EXCEPTION("bad hypothesis reference",
460 SMESH_Hypothesis::Hypothesis_Status status = SMESH_Hypothesis::HYP_OK;
463 TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape(aSubShapeObject);
464 int hypId = myHyp->GetId();
465 status = _impl->RemoveHypothesis(myLocSubShape, hypId);
466 if ( !SMESH_Hypothesis::IsStatusFatal(status) )
467 _mapHypo.erase( hypId );
469 catch(SALOME_Exception & S_ex)
471 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
476 //=============================================================================
480 //=============================================================================
482 SMESH::ListOfHypothesis *
483 SMESH_Mesh_i::GetHypothesisList(GEOM::GEOM_Object_ptr aSubShapeObject)
484 throw(SALOME::SALOME_Exception)
486 Unexpect aCatch(SALOME_SalomeException);
487 if (MYDEBUG) MESSAGE("GetHypothesisList");
488 if (CORBA::is_nil(aSubShapeObject))
489 THROW_SALOME_CORBA_EXCEPTION("bad subShape reference",
492 SMESH::ListOfHypothesis_var aList = new SMESH::ListOfHypothesis();
495 TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape(aSubShapeObject);
496 const list<const SMESHDS_Hypothesis*>& aLocalList = _impl->GetHypothesisList( myLocSubShape );
497 int i = 0, n = aLocalList.size();
500 for ( list<const SMESHDS_Hypothesis*>::const_iterator anIt = aLocalList.begin(); i < n && anIt != aLocalList.end(); anIt++ ) {
501 SMESHDS_Hypothesis* aHyp = (SMESHDS_Hypothesis*)(*anIt);
502 if ( _mapHypo.find( aHyp->GetID() ) != _mapHypo.end() )
503 aList[i++] = SMESH::SMESH_Hypothesis::_narrow( _mapHypo[aHyp->GetID()] );
508 catch(SALOME_Exception & S_ex) {
509 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
512 return aList._retn();
515 //=============================================================================
519 //=============================================================================
520 SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::GetSubMesh(GEOM::GEOM_Object_ptr aSubShapeObject,
521 const char* theName )
522 throw(SALOME::SALOME_Exception)
524 Unexpect aCatch(SALOME_SalomeException);
525 MESSAGE("SMESH_Mesh_i::GetSubMesh");
526 if (CORBA::is_nil(aSubShapeObject))
527 THROW_SALOME_CORBA_EXCEPTION("bad subShape reference",
530 SMESH::SMESH_subMesh_var subMesh;
531 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(_this());
533 TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape(aSubShapeObject);
535 //Get or Create the SMESH_subMesh object implementation
537 int subMeshId = _impl->GetMeshDS()->ShapeToIndex( myLocSubShape );
538 subMesh = getSubMesh( subMeshId );
540 // create a new subMesh object servant if there is none for the shape
541 if ( subMesh->_is_nil() )
542 subMesh = createSubMesh( aSubShapeObject );
544 if ( _gen_i->CanPublishInStudy( subMesh )) {
545 SALOMEDS::SObject_var aSO =
546 _gen_i->PublishSubMesh(_gen_i->GetCurrentStudy(), aMesh,
547 subMesh, aSubShapeObject, theName );
548 if ( !aSO->_is_nil()) {
549 // Update Python script
550 TPythonDump() << aSO << " = " << _this() << ".GetSubMesh( "
551 << aSubShapeObject << ", '" << theName << "' )";
555 catch(SALOME_Exception & S_ex) {
556 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
558 return subMesh._retn();
561 //=============================================================================
565 //=============================================================================
567 void SMESH_Mesh_i::RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh )
568 throw (SALOME::SALOME_Exception)
570 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::RemoveSubMesh");
571 if ( theSubMesh->_is_nil() )
574 GEOM::GEOM_Object_var aSubShapeObject;
575 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
576 if ( !aStudy->_is_nil() ) {
577 // Remove submesh's SObject
578 SALOMEDS::SObject_var anSO = _gen_i->ObjectToSObject( aStudy, theSubMesh );
579 if ( !anSO->_is_nil() ) {
580 long aTag = SMESH_Gen_i::GetRefOnShapeTag();
581 SALOMEDS::SObject_var anObj, aRef;
582 if ( anSO->FindSubObject( aTag, anObj ) && anObj->ReferencedObject( aRef ) )
583 aSubShapeObject = GEOM::GEOM_Object::_narrow( aRef->GetObject() );
585 aStudy->NewBuilder()->RemoveObjectWithChildren( anSO );
587 // Update Python script
588 TPythonDump() << _this() << ".RemoveSubMesh( " << anSO << " )";
592 removeSubMesh( theSubMesh, aSubShapeObject.in() );
595 //=============================================================================
599 //=============================================================================
600 #define CASE2STRING(enum) case SMESH::enum: return "SMESH."#enum;
601 inline TCollection_AsciiString ElementTypeString (SMESH::ElementType theElemType)
603 switch (theElemType) {
608 CASE2STRING( VOLUME );
614 //=============================================================================
618 //=============================================================================
620 SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateGroup( SMESH::ElementType theElemType,
621 const char* theName )
622 throw(SALOME::SALOME_Exception)
624 Unexpect aCatch(SALOME_SalomeException);
625 SMESH::SMESH_Group_var aNewGroup =
626 SMESH::SMESH_Group::_narrow( createGroup( theElemType, theName ));
628 if ( _gen_i->CanPublishInStudy( aNewGroup ) ) {
629 SALOMEDS::SObject_var aSO =
630 _gen_i->PublishGroup(_gen_i->GetCurrentStudy(), _this(),
631 aNewGroup, GEOM::GEOM_Object::_nil(), theName);
632 if ( !aSO->_is_nil()) {
633 // Update Python script
634 TPythonDump() << aSO << " = " << _this() << ".CreateGroup( "
635 << ElementTypeString(theElemType) << ", '" << theName << "' )";
638 return aNewGroup._retn();
642 //=============================================================================
646 //=============================================================================
647 SMESH::SMESH_GroupOnGeom_ptr SMESH_Mesh_i::CreateGroupFromGEOM (SMESH::ElementType theElemType,
649 GEOM::GEOM_Object_ptr theGeomObj)
650 throw(SALOME::SALOME_Exception)
652 Unexpect aCatch(SALOME_SalomeException);
653 SMESH::SMESH_GroupOnGeom_var aNewGroup;
655 TopoDS_Shape aShape = _gen_i->GeomObjectToShape( theGeomObj );
656 if ( !aShape.IsNull() ) {
657 aNewGroup = SMESH::SMESH_GroupOnGeom::_narrow
658 ( createGroup( theElemType, theName, aShape ));
659 if ( _gen_i->CanPublishInStudy( aNewGroup ) ) {
660 SALOMEDS::SObject_var aSO =
661 _gen_i->PublishGroup(_gen_i->GetCurrentStudy(), _this(),
662 aNewGroup, theGeomObj, theName);
663 if ( !aSO->_is_nil()) {
664 // Update Python script
665 TPythonDump() << aSO << " = " << _this() << ".CreateGroupFromGEOM("
666 << ElementTypeString(theElemType) << ", '" << theName << "', "
667 << theGeomObj << " )";
672 return aNewGroup._retn();
675 //=============================================================================
679 //=============================================================================
681 void SMESH_Mesh_i::RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup )
682 throw (SALOME::SALOME_Exception)
684 if ( theGroup->_is_nil() )
687 SMESH_GroupBase_i* aGroup =
688 dynamic_cast<SMESH_GroupBase_i*>( SMESH_Gen_i::GetServant( theGroup ).in() );
692 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
693 if ( !aStudy->_is_nil() ) {
694 SALOMEDS::SObject_var aGroupSO = _gen_i->ObjectToSObject( aStudy, theGroup );
696 if ( !aGroupSO->_is_nil() ) {
697 // Update Python script
698 TPythonDump() << _this() << ".RemoveGroup( " << aGroupSO << " )";
700 // Remove group's SObject
701 aStudy->NewBuilder()->RemoveObject( aGroupSO );
705 // Remove the group from SMESH data structures
706 removeGroup( aGroup->GetLocalID() );
709 //=============================================================================
710 /*! RemoveGroupWithContents
711 * Remove group with its contents
713 //=============================================================================
714 void SMESH_Mesh_i::RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup )
715 throw (SALOME::SALOME_Exception)
717 if ( theGroup->_is_nil() )
720 SMESH_GroupBase_i* aGroup =
721 dynamic_cast<SMESH_GroupBase_i*>( SMESH_Gen_i::GetServant( theGroup ).in() );
725 SMESH::long_array_var anIds = aGroup->GetListOfID();
726 SMESH::SMESH_MeshEditor_var aMeshEditor = SMESH_Mesh_i::GetMeshEditor();
728 // Update Python script
729 TPythonDump() << _this() << ".RemoveGroupWithContents( " << theGroup << " )";
732 if ( aGroup->GetType() == SMESH::NODE )
733 aMeshEditor->RemoveNodes( anIds );
735 aMeshEditor->RemoveElements( anIds );
738 RemoveGroup( theGroup );
740 // Clear python lines, created by RemoveNodes/Elements() and RemoveGroup()
741 _gen_i->RemoveLastFromPythonScript(_gen_i->GetCurrentStudy()->StudyId());
742 _gen_i->RemoveLastFromPythonScript(_gen_i->GetCurrentStudy()->StudyId());
746 //================================================================================
748 * \brief Get the list of groups existing in the mesh
749 * \retval SMESH::ListOfGroups * - list of groups
751 //================================================================================
753 SMESH::ListOfGroups * SMESH_Mesh_i::GetGroups() throw(SALOME::SALOME_Exception)
755 Unexpect aCatch(SALOME_SalomeException);
756 if (MYDEBUG) MESSAGE("GetGroups");
758 SMESH::ListOfGroups_var aList = new SMESH::ListOfGroups();
761 TPythonDump aPythonDump;
762 if ( !_mapGroups.empty() ) // (IMP13463) avoid "SyntaxError: can't assign to []"
766 aList->length( _mapGroups.size() );
768 map<int, SMESH::SMESH_GroupBase_ptr>::iterator it = _mapGroups.begin();
769 for ( ; it != _mapGroups.end(); it++ ) {
770 if ( CORBA::is_nil( it->second )) continue;
771 aList[i++] = SMESH::SMESH_GroupBase::_duplicate( it->second );
773 if (i > 1) aPythonDump << ", ";
774 aPythonDump << it->second;
778 catch(SALOME_Exception & S_ex) {
779 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
782 // Update Python script
783 if ( !_mapGroups.empty() ) // (IMP13463) avoid "SyntaxError: can't assign to []"
784 aPythonDump << " ] = " << _this() << ".GetGroups()";
786 return aList._retn();
789 //=============================================================================
791 * New group is created. All mesh elements that are
792 * present in initial groups are added to the new one
794 //=============================================================================
795 SMESH::SMESH_Group_ptr SMESH_Mesh_i::UnionGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
796 SMESH::SMESH_GroupBase_ptr theGroup2,
797 const char* theName )
798 throw (SALOME::SALOME_Exception)
802 if ( theGroup1->_is_nil() || theGroup2->_is_nil() ||
803 theGroup1->GetType() != theGroup2->GetType() )
804 return SMESH::SMESH_Group::_nil();
807 SMESH::SMESH_Group_var aResGrp = CreateGroup( theGroup1->GetType(), theName );
808 if ( aResGrp->_is_nil() )
809 return SMESH::SMESH_Group::_nil();
811 SMESH::long_array_var anIds1 = theGroup1->GetListOfID();
812 SMESH::long_array_var anIds2 = theGroup2->GetListOfID();
814 TColStd_MapOfInteger aResMap;
816 for ( int i1 = 0, n1 = anIds1->length(); i1 < n1; i1++ )
817 aResMap.Add( anIds1[ i1 ] );
819 for ( int i2 = 0, n2 = anIds2->length(); i2 < n2; i2++ )
820 aResMap.Add( anIds2[ i2 ] );
822 SMESH::long_array_var aResIds = new SMESH::long_array;
823 aResIds->length( aResMap.Extent() );
826 TColStd_MapIteratorOfMapOfInteger anIter( aResMap );
827 for( ; anIter.More(); anIter.Next() )
828 aResIds[ resI++ ] = anIter.Key();
830 aResGrp->Add( aResIds );
832 // Clear python lines, created by CreateGroup() and Add()
833 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
834 _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
835 _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
837 // Update Python script
838 TPythonDump() << aResGrp << " = " << _this() << ".UnionGroups( "
839 << theGroup1 << ", " << theGroup2 << ", '"
842 return aResGrp._retn();
846 return SMESH::SMESH_Group::_nil();
850 //=============================================================================
852 * New group is created. All mesh elements that are
853 * present in both initial groups are added to the new one.
855 //=============================================================================
856 SMESH::SMESH_Group_ptr SMESH_Mesh_i::IntersectGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
857 SMESH::SMESH_GroupBase_ptr theGroup2,
858 const char* theName )
859 throw (SALOME::SALOME_Exception)
861 if ( theGroup1->_is_nil() || theGroup2->_is_nil() ||
862 theGroup1->GetType() != theGroup2->GetType() )
863 return SMESH::SMESH_Group::_nil();
865 // Create Intersection
866 SMESH::SMESH_Group_var aResGrp = CreateGroup( theGroup1->GetType(), theName );
867 if ( aResGrp->_is_nil() )
870 SMESH::long_array_var anIds1 = theGroup1->GetListOfID();
871 SMESH::long_array_var anIds2 = theGroup2->GetListOfID();
873 TColStd_MapOfInteger aMap1;
875 for ( int i1 = 0, n1 = anIds1->length(); i1 < n1; i1++ )
876 aMap1.Add( anIds1[ i1 ] );
878 TColStd_SequenceOfInteger aSeq;
880 for ( int i2 = 0, n2 = anIds2->length(); i2 < n2; i2++ )
881 if ( aMap1.Contains( anIds2[ i2 ] ) )
882 aSeq.Append( anIds2[ i2 ] );
884 SMESH::long_array_var aResIds = new SMESH::long_array;
885 aResIds->length( aSeq.Length() );
887 for ( int resI = 0, resN = aSeq.Length(); resI < resN; resI++ )
888 aResIds[ resI ] = aSeq( resI + 1 );
890 aResGrp->Add( aResIds );
892 // Clear python lines, created by CreateGroup() and Add()
893 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
894 _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
895 _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
897 // Update Python script
898 TPythonDump() << aResGrp << " = " << _this() << ".IntersectGroups( "
899 << theGroup1 << ", " << theGroup2 << ", '" << theName << "')";
901 return aResGrp._retn();
904 //=============================================================================
906 * New group is created. All mesh elements that are present in
907 * main group but do not present in tool group are added to the new one
909 //=============================================================================
910 SMESH::SMESH_Group_ptr SMESH_Mesh_i::CutGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
911 SMESH::SMESH_GroupBase_ptr theGroup2,
912 const char* theName )
913 throw (SALOME::SALOME_Exception)
915 if ( theGroup1->_is_nil() || theGroup2->_is_nil() ||
916 theGroup1->GetType() != theGroup2->GetType() )
917 return SMESH::SMESH_Group::_nil();
920 SMESH::SMESH_Group_var aResGrp = CreateGroup( theGroup1->GetType(), theName );
921 if ( aResGrp->_is_nil() )
924 SMESH::long_array_var anIds1 = theGroup1->GetListOfID();
925 SMESH::long_array_var anIds2 = theGroup2->GetListOfID();
927 TColStd_MapOfInteger aMap2;
929 for ( int i2 = 0, n2 = anIds2->length(); i2 < n2; i2++ )
930 aMap2.Add( anIds2[ i2 ] );
933 TColStd_SequenceOfInteger aSeq;
934 for ( int i1 = 0, n1 = anIds1->length(); i1 < n1; i1++ )
935 if ( !aMap2.Contains( anIds1[ i1 ] ) )
936 aSeq.Append( anIds1[ i1 ] );
938 SMESH::long_array_var aResIds = new SMESH::long_array;
939 aResIds->length( aSeq.Length() );
941 for ( int resI = 0, resN = aSeq.Length(); resI < resN; resI++ )
942 aResIds[ resI ] = aSeq( resI + 1 );
944 aResGrp->Add( aResIds );
946 // Clear python lines, created by CreateGroup() and Add()
947 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
948 _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
949 _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
951 // Update Python script
952 TPythonDump() << aResGrp << " = " << _this() << ".CutGroups( "
953 << theGroup1 << ", " << theGroup2 << ", '"
956 return aResGrp._retn();
959 //=============================================================================
963 //=============================================================================
965 SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::createSubMesh( GEOM::GEOM_Object_ptr theSubShapeObject )
967 if(MYDEBUG) MESSAGE( "createSubMesh" );
968 TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape(theSubShapeObject);
970 ::SMESH_subMesh * mySubMesh = _impl->GetSubMesh(myLocSubShape);
971 int subMeshId = _impl->GetMeshDS()->ShapeToIndex( myLocSubShape );
972 SMESH_subMesh_i *subMeshServant = new SMESH_subMesh_i(myPOA, _gen_i, this, subMeshId);
973 SMESH::SMESH_subMesh_var subMesh
974 = SMESH::SMESH_subMesh::_narrow(subMeshServant->_this());
976 _mapSubMesh[subMeshId] = mySubMesh;
977 _mapSubMesh_i[subMeshId] = subMeshServant;
978 _mapSubMeshIor[subMeshId] = SMESH::SMESH_subMesh::_duplicate(subMesh);
980 // register CORBA object for persistence
981 int nextId = _gen_i->RegisterObject( subMesh );
982 if(MYDEBUG) MESSAGE( "Add submesh to map with id = "<< nextId);
984 return subMesh._retn();
987 //=======================================================================
988 //function : getSubMesh
990 //=======================================================================
992 SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::getSubMesh(int shapeID)
994 map<int, SMESH::SMESH_subMesh_ptr>::iterator it = _mapSubMeshIor.find( shapeID );
995 if ( it == _mapSubMeshIor.end() )
996 return SMESH::SMESH_subMesh::_nil();
998 return SMESH::SMESH_subMesh::_duplicate( (*it).second );
1002 //=============================================================================
1006 //=============================================================================
1008 void SMESH_Mesh_i::removeSubMesh (SMESH::SMESH_subMesh_ptr theSubMesh,
1009 GEOM::GEOM_Object_ptr theSubShapeObject )
1011 MESSAGE("SMESH_Mesh_i::removeSubMesh()");
1012 if ( theSubMesh->_is_nil() || theSubShapeObject->_is_nil() )
1016 SMESH::ListOfHypothesis_var aHypList = GetHypothesisList( theSubShapeObject );
1017 for ( int i = 0, n = aHypList->length(); i < n; i++ ) {
1018 removeHypothesis( theSubShapeObject, aHypList[i] );
1021 catch( const SALOME::SALOME_Exception& ) {
1022 INFOS("SMESH_Mesh_i::removeSubMesh(): exception caught!");
1025 int subMeshId = theSubMesh->GetId();
1027 _mapSubMesh.erase(subMeshId);
1028 _mapSubMesh_i.erase(subMeshId);
1029 _mapSubMeshIor.erase(subMeshId);
1030 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::removeSubMesh() completed");
1033 //=============================================================================
1037 //=============================================================================
1039 SMESH::SMESH_GroupBase_ptr SMESH_Mesh_i::createGroup (SMESH::ElementType theElemType,
1040 const char* theName,
1041 const TopoDS_Shape& theShape )
1044 SMESH::SMESH_GroupBase_var aGroup;
1045 if ( _impl->AddGroup( (SMDSAbs_ElementType)theElemType, theName, anId, theShape )) {
1046 SMESH_GroupBase_i* aGroupImpl;
1047 if ( !theShape.IsNull() )
1048 aGroupImpl = new SMESH_GroupOnGeom_i( SMESH_Gen_i::GetPOA(), this, anId );
1050 aGroupImpl = new SMESH_Group_i( SMESH_Gen_i::GetPOA(), this, anId );
1052 // PAL7962: san -- To ensure correct mapping of servant and correct reference counting in GenericObj_i
1053 SMESH_Gen_i::GetPOA()->activate_object( aGroupImpl );
1054 aGroupImpl->Register();
1055 // PAL7962: san -- To ensure correct mapping of servant and correct reference counting in GenericObj_i
1057 aGroup = SMESH::SMESH_GroupBase::_narrow( aGroupImpl->_this() );
1058 _mapGroups[anId] = SMESH::SMESH_GroupBase::_duplicate( aGroup );
1060 // register CORBA object for persistence
1061 int nextId = _gen_i->RegisterObject( aGroup );
1062 if(MYDEBUG) MESSAGE( "Add group to map with id = "<< nextId);
1064 return aGroup._retn();
1067 //=============================================================================
1069 * SMESH_Mesh_i::removeGroup
1071 * Should be called by ~SMESH_Group_i()
1073 //=============================================================================
1075 void SMESH_Mesh_i::removeGroup( const int theId )
1077 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::removeGroup()" );
1078 if ( _mapGroups.find( theId ) != _mapGroups.end() ) {
1079 _mapGroups.erase( theId );
1080 _impl->RemoveGroup( theId );
1085 //=============================================================================
1089 //=============================================================================
1091 SMESH::log_array * SMESH_Mesh_i::GetLog(CORBA::Boolean clearAfterGet)
1092 throw(SALOME::SALOME_Exception)
1094 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::GetLog");
1096 SMESH::log_array_var aLog;
1098 list < SMESHDS_Command * >logDS = _impl->GetLog();
1099 aLog = new SMESH::log_array;
1101 int lg = logDS.size();
1104 list < SMESHDS_Command * >::iterator its = logDS.begin();
1105 while(its != logDS.end()){
1106 SMESHDS_Command *com = *its;
1107 int comType = com->GetType();
1109 int lgcom = com->GetNumber();
1111 const list < int >&intList = com->GetIndexes();
1112 int inum = intList.size();
1114 list < int >::const_iterator ii = intList.begin();
1115 const list < double >&coordList = com->GetCoords();
1116 int rnum = coordList.size();
1118 list < double >::const_iterator ir = coordList.begin();
1119 aLog[indexLog].commandType = comType;
1120 aLog[indexLog].number = lgcom;
1121 aLog[indexLog].coords.length(rnum);
1122 aLog[indexLog].indexes.length(inum);
1123 for(int i = 0; i < rnum; i++){
1124 aLog[indexLog].coords[i] = *ir;
1125 //MESSAGE(" "<<i<<" "<<ir.Value());
1128 for(int i = 0; i < inum; i++){
1129 aLog[indexLog].indexes[i] = *ii;
1130 //MESSAGE(" "<<i<<" "<<ii.Value());
1139 catch(SALOME_Exception & S_ex){
1140 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
1142 return aLog._retn();
1146 //=============================================================================
1150 //=============================================================================
1152 void SMESH_Mesh_i::ClearLog() throw(SALOME::SALOME_Exception)
1154 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::ClearLog");
1158 //=============================================================================
1162 //=============================================================================
1164 CORBA::Long SMESH_Mesh_i::GetId()throw(SALOME::SALOME_Exception)
1166 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::GetId");
1170 //=============================================================================
1174 //=============================================================================
1176 CORBA::Long SMESH_Mesh_i::GetStudyId()throw(SALOME::SALOME_Exception)
1181 //=============================================================================
1185 //=============================================================================
1187 void SMESH_Mesh_i::SetImpl(::SMESH_Mesh * impl)
1189 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::SetImpl");
1193 //=============================================================================
1197 //=============================================================================
1199 ::SMESH_Mesh & SMESH_Mesh_i::GetImpl()
1201 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::GetImpl()");
1205 //=============================================================================
1207 * Return mesh editor
1209 //=============================================================================
1211 SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditor()
1213 // Create MeshEditor
1214 SMESH_MeshEditor_i *aMeshEditor = new SMESH_MeshEditor_i( _impl, false );
1215 SMESH::SMESH_MeshEditor_var aMesh = aMeshEditor->_this();
1217 // Update Python script
1218 TPythonDump() << aMeshEditor << " = " << _this() << ".GetMeshEditor()";
1220 return aMesh._retn();
1223 //=============================================================================
1225 * Return mesh edition previewer
1227 //=============================================================================
1229 SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditPreviewer()
1231 SMESH_MeshEditor_i *aMeshEditor = new SMESH_MeshEditor_i( _impl, true );
1232 SMESH::SMESH_MeshEditor_var aMesh = aMeshEditor->_this();
1233 return aMesh._retn();
1236 //=============================================================================
1238 * Export in different formats
1240 //=============================================================================
1242 CORBA::Boolean SMESH_Mesh_i::HasDuplicatedGroupNamesMED()
1244 return _impl->HasDuplicatedGroupNamesMED();
1247 static void PrepareForWriting (const char* file)
1249 TCollection_AsciiString aFullName ((char*)file);
1250 OSD_Path aPath (aFullName);
1251 OSD_File aFile (aPath);
1252 if (aFile.Exists()) {
1253 // existing filesystem node
1254 if (aFile.KindOfFile() == OSD_FILE) {
1255 if (aFile.IsWriteable()) {
1258 if (aFile.Failed()) {
1259 TCollection_AsciiString msg ("File ");
1260 msg += aFullName + " cannot be replaced.";
1261 THROW_SALOME_CORBA_EXCEPTION(msg.ToCString(), SALOME::BAD_PARAM);
1264 TCollection_AsciiString msg ("File ");
1265 msg += aFullName + " cannot be overwritten.";
1266 THROW_SALOME_CORBA_EXCEPTION(msg.ToCString(), SALOME::BAD_PARAM);
1269 TCollection_AsciiString msg ("Location ");
1270 msg += aFullName + " is not a file.";
1271 THROW_SALOME_CORBA_EXCEPTION(msg.ToCString(), SALOME::BAD_PARAM);
1274 // nonexisting file; check if it can be created
1276 aFile.Build(OSD_WriteOnly, OSD_Protection());
1277 if (aFile.Failed()) {
1278 TCollection_AsciiString msg ("You cannot create the file ");
1279 msg += aFullName + ". Check the directory existance and access rights.";
1280 THROW_SALOME_CORBA_EXCEPTION(msg.ToCString(), SALOME::BAD_PARAM);
1288 void SMESH_Mesh_i::ExportToMED (const char* file,
1289 CORBA::Boolean auto_groups,
1290 SMESH::MED_VERSION theVersion)
1291 throw(SALOME::SALOME_Exception)
1293 Unexpect aCatch(SALOME_SalomeException);
1295 // Update Python script
1296 TPythonDump() << _this() << ".ExportToMED( '"
1297 << file << "', " << auto_groups << ", " << theVersion << " )";
1300 PrepareForWriting(file);
1301 char* aMeshName = "Mesh";
1302 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
1303 if ( !aStudy->_is_nil() ) {
1304 SALOMEDS::SObject_var aMeshSO = _gen_i->ObjectToSObject( aStudy, _this() );
1305 if ( !aMeshSO->_is_nil() ) {
1306 aMeshName = aMeshSO->GetName();
1308 //SCRUTE(aMeshName);
1309 //SCRUTE(aMeshSO->GetID());
1311 // asv : 27.10.04 : fix of 6903: check for StudyLocked before adding attributes
1312 if ( !aStudy->GetProperties()->IsLocked() )
1314 SALOMEDS::GenericAttribute_var anAttr;
1315 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
1316 SALOMEDS::AttributeExternalFileDef_var aFileName;
1317 anAttr=aStudyBuilder->FindOrCreateAttribute(aMeshSO, "AttributeExternalFileDef");
1318 aFileName = SALOMEDS::AttributeExternalFileDef::_narrow(anAttr);
1319 ASSERT(!aFileName->_is_nil());
1320 aFileName->SetValue(file);
1321 SALOMEDS::AttributeFileType_var aFileType;
1322 anAttr=aStudyBuilder->FindOrCreateAttribute(aMeshSO, "AttributeFileType");
1323 aFileType = SALOMEDS::AttributeFileType::_narrow(anAttr);
1324 ASSERT(!aFileType->_is_nil());
1325 aFileType->SetValue("FICHIERMED");
1329 _impl->ExportMED( file, aMeshName, auto_groups, theVersion );
1332 void SMESH_Mesh_i::ExportMED (const char* file,
1333 CORBA::Boolean auto_groups)
1334 throw(SALOME::SALOME_Exception)
1336 ExportToMED(file,auto_groups,SMESH::MED_V2_1);
1339 void SMESH_Mesh_i::ExportDAT (const char *file)
1340 throw(SALOME::SALOME_Exception)
1342 Unexpect aCatch(SALOME_SalomeException);
1344 // Update Python script
1345 TPythonDump() << _this() << ".ExportDAT( '" << file << "' )";
1348 PrepareForWriting(file);
1349 _impl->ExportDAT(file);
1352 void SMESH_Mesh_i::ExportUNV (const char *file)
1353 throw(SALOME::SALOME_Exception)
1355 Unexpect aCatch(SALOME_SalomeException);
1357 // Update Python script
1358 TPythonDump() << _this() << ".ExportUNV( '" << file << "' )";
1361 PrepareForWriting(file);
1362 _impl->ExportUNV(file);
1365 void SMESH_Mesh_i::ExportSTL (const char *file, const bool isascii)
1366 throw(SALOME::SALOME_Exception)
1368 Unexpect aCatch(SALOME_SalomeException);
1370 // Update Python script
1371 TPythonDump() << _this() << ".ExportSTL( '" << file << "', " << isascii << " )";
1374 PrepareForWriting(file);
1375 _impl->ExportSTL(file, isascii);
1378 //=============================================================================
1382 //=============================================================================
1384 SALOME_MED::MESH_ptr SMESH_Mesh_i::GetMEDMesh()throw(SALOME::SALOME_Exception)
1386 Unexpect aCatch(SALOME_SalomeException);
1387 SMESH_MEDMesh_i *aMedMesh = new SMESH_MEDMesh_i(this);
1388 SALOME_MED::MESH_var aMesh = aMedMesh->_this();
1389 return aMesh._retn();
1392 //=============================================================================
1396 //=============================================================================
1397 CORBA::Long SMESH_Mesh_i::NbNodes()throw(SALOME::SALOME_Exception)
1399 Unexpect aCatch(SALOME_SalomeException);
1400 return _impl->NbNodes();
1403 //=============================================================================
1407 //=============================================================================
1408 CORBA::Long SMESH_Mesh_i::NbElements()throw (SALOME::SALOME_Exception)
1410 Unexpect aCatch(SALOME_SalomeException);
1411 return NbEdges() + NbFaces() + NbVolumes();
1414 //=============================================================================
1418 //=============================================================================
1419 CORBA::Long SMESH_Mesh_i::NbEdges()throw(SALOME::SALOME_Exception)
1421 Unexpect aCatch(SALOME_SalomeException);
1422 return _impl->NbEdges();
1425 CORBA::Long SMESH_Mesh_i::NbEdgesOfOrder(SMESH::ElementOrder order)
1426 throw(SALOME::SALOME_Exception)
1428 Unexpect aCatch(SALOME_SalomeException);
1429 return _impl->NbEdges( (::SMESH_Mesh::ElementOrder) order);
1432 //=============================================================================
1436 //=============================================================================
1437 CORBA::Long SMESH_Mesh_i::NbFaces()throw(SALOME::SALOME_Exception)
1439 Unexpect aCatch(SALOME_SalomeException);
1440 return _impl->NbFaces();
1443 CORBA::Long SMESH_Mesh_i::NbTriangles()throw(SALOME::SALOME_Exception)
1445 Unexpect aCatch(SALOME_SalomeException);
1446 return _impl->NbTriangles();
1449 CORBA::Long SMESH_Mesh_i::NbQuadrangles()throw(SALOME::SALOME_Exception)
1451 Unexpect aCatch(SALOME_SalomeException);
1452 return _impl->NbQuadrangles();
1455 CORBA::Long SMESH_Mesh_i::NbPolygons()throw(SALOME::SALOME_Exception)
1457 Unexpect aCatch(SALOME_SalomeException);
1458 return _impl->NbPolygons();
1461 CORBA::Long SMESH_Mesh_i::NbFacesOfOrder(SMESH::ElementOrder order)
1462 throw(SALOME::SALOME_Exception)
1464 Unexpect aCatch(SALOME_SalomeException);
1465 return _impl->NbFaces( (::SMESH_Mesh::ElementOrder) order);
1468 CORBA::Long SMESH_Mesh_i::NbTrianglesOfOrder(SMESH::ElementOrder order)
1469 throw(SALOME::SALOME_Exception)
1471 Unexpect aCatch(SALOME_SalomeException);
1472 return _impl->NbTriangles( (::SMESH_Mesh::ElementOrder) order);
1475 CORBA::Long SMESH_Mesh_i::NbQuadranglesOfOrder(SMESH::ElementOrder order)
1476 throw(SALOME::SALOME_Exception)
1478 Unexpect aCatch(SALOME_SalomeException);
1479 return _impl->NbQuadrangles( (::SMESH_Mesh::ElementOrder) order);
1482 //=============================================================================
1486 //=============================================================================
1487 CORBA::Long SMESH_Mesh_i::NbVolumes()throw(SALOME::SALOME_Exception)
1489 Unexpect aCatch(SALOME_SalomeException);
1490 return _impl->NbVolumes();
1493 CORBA::Long SMESH_Mesh_i::NbTetras()throw(SALOME::SALOME_Exception)
1495 Unexpect aCatch(SALOME_SalomeException);
1496 return _impl->NbTetras();
1499 CORBA::Long SMESH_Mesh_i::NbHexas()throw(SALOME::SALOME_Exception)
1501 Unexpect aCatch(SALOME_SalomeException);
1502 return _impl->NbHexas();
1505 CORBA::Long SMESH_Mesh_i::NbPyramids()throw(SALOME::SALOME_Exception)
1507 Unexpect aCatch(SALOME_SalomeException);
1508 return _impl->NbPyramids();
1511 CORBA::Long SMESH_Mesh_i::NbPrisms()throw(SALOME::SALOME_Exception)
1513 Unexpect aCatch(SALOME_SalomeException);
1514 return _impl->NbPrisms();
1517 CORBA::Long SMESH_Mesh_i::NbPolyhedrons()throw(SALOME::SALOME_Exception)
1519 Unexpect aCatch(SALOME_SalomeException);
1520 return _impl->NbPolyhedrons();
1523 CORBA::Long SMESH_Mesh_i::NbVolumesOfOrder(SMESH::ElementOrder order)
1524 throw(SALOME::SALOME_Exception)
1526 Unexpect aCatch(SALOME_SalomeException);
1527 return _impl->NbVolumes( (::SMESH_Mesh::ElementOrder) order);
1530 CORBA::Long SMESH_Mesh_i::NbTetrasOfOrder(SMESH::ElementOrder order)
1531 throw(SALOME::SALOME_Exception)
1533 Unexpect aCatch(SALOME_SalomeException);
1534 return _impl->NbTetras( (::SMESH_Mesh::ElementOrder) order);
1537 CORBA::Long SMESH_Mesh_i::NbHexasOfOrder(SMESH::ElementOrder order)
1538 throw(SALOME::SALOME_Exception)
1540 Unexpect aCatch(SALOME_SalomeException);
1541 return _impl->NbHexas( (::SMESH_Mesh::ElementOrder) order);
1544 CORBA::Long SMESH_Mesh_i::NbPyramidsOfOrder(SMESH::ElementOrder order)
1545 throw(SALOME::SALOME_Exception)
1547 Unexpect aCatch(SALOME_SalomeException);
1548 return _impl->NbPyramids( (::SMESH_Mesh::ElementOrder) order);
1551 CORBA::Long SMESH_Mesh_i::NbPrismsOfOrder(SMESH::ElementOrder order)
1552 throw(SALOME::SALOME_Exception)
1554 Unexpect aCatch(SALOME_SalomeException);
1555 return _impl->NbPrisms( (::SMESH_Mesh::ElementOrder) order);
1558 //=============================================================================
1562 //=============================================================================
1563 CORBA::Long SMESH_Mesh_i::NbSubMesh()throw(SALOME::SALOME_Exception)
1565 Unexpect aCatch(SALOME_SalomeException);
1566 return _impl->NbSubMesh();
1569 //=============================================================================
1573 //=============================================================================
1574 char* SMESH_Mesh_i::Dump()
1576 std::ostringstream os;
1578 return CORBA::string_dup( os.str().c_str() );
1581 //=============================================================================
1585 //=============================================================================
1586 SMESH::long_array* SMESH_Mesh_i::GetIDs()
1588 // SMESH::long_array_var aResult = new SMESH::long_array();
1589 // SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1590 // int aMinId = aSMESHDS_Mesh->MinElementID();
1591 // int aMaxId = aSMESHDS_Mesh->MaxElementID();
1593 // aResult->length(aMaxId - aMinId + 1);
1595 // for (int i = 0, id = aMinId; id <= aMaxId; id++ )
1596 // aResult[i++] = id;
1598 // return aResult._retn();
1600 return GetElementsId();
1603 //=============================================================================
1607 //=============================================================================
1609 SMESH::long_array* SMESH_Mesh_i::GetElementsId()
1610 throw (SALOME::SALOME_Exception)
1612 Unexpect aCatch(SALOME_SalomeException);
1613 MESSAGE("SMESH_Mesh_i::GetElementsId");
1614 SMESH::long_array_var aResult = new SMESH::long_array();
1615 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1617 if ( aSMESHDS_Mesh == NULL )
1618 return aResult._retn();
1620 long nbElements = NbElements();
1621 aResult->length( nbElements );
1622 SMDS_ElemIteratorPtr anIt = aSMESHDS_Mesh->elementsIterator();
1623 for ( int i = 0, n = nbElements; i < n && anIt->more(); i++ )
1624 aResult[i] = anIt->next()->GetID();
1626 return aResult._retn();
1630 //=============================================================================
1634 //=============================================================================
1636 SMESH::long_array* SMESH_Mesh_i::GetElementsByType( SMESH::ElementType theElemType )
1637 throw (SALOME::SALOME_Exception)
1639 Unexpect aCatch(SALOME_SalomeException);
1640 MESSAGE("SMESH_subMesh_i::GetElementsByType");
1641 SMESH::long_array_var aResult = new SMESH::long_array();
1642 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1644 if ( aSMESHDS_Mesh == NULL )
1645 return aResult._retn();
1647 long nbElements = NbElements();
1649 // No sense in returning ids of elements along with ids of nodes:
1650 // when theElemType == SMESH::ALL, return node ids only if
1651 // there are no elements
1652 if ( theElemType == SMESH::NODE || theElemType == SMESH::ALL && nbElements == 0 )
1653 return GetNodesId();
1655 aResult->length( nbElements );
1659 SMDS_ElemIteratorPtr anIt = aSMESHDS_Mesh->elementsIterator();
1660 while ( i < nbElements && anIt->more() ) {
1661 const SMDS_MeshElement* anElem = anIt->next();
1662 if ( theElemType == SMESH::ALL || anElem->GetType() == (SMDSAbs_ElementType)theElemType )
1663 aResult[i++] = anElem->GetID();
1666 aResult->length( i );
1668 return aResult._retn();
1671 //=============================================================================
1675 //=============================================================================
1677 SMESH::long_array* SMESH_Mesh_i::GetNodesId()
1678 throw (SALOME::SALOME_Exception)
1680 Unexpect aCatch(SALOME_SalomeException);
1681 MESSAGE("SMESH_subMesh_i::GetNodesId");
1682 SMESH::long_array_var aResult = new SMESH::long_array();
1683 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1685 if ( aSMESHDS_Mesh == NULL )
1686 return aResult._retn();
1688 long nbNodes = NbNodes();
1689 aResult->length( nbNodes );
1690 SMDS_NodeIteratorPtr anIt = aSMESHDS_Mesh->nodesIterator();
1691 for ( int i = 0, n = nbNodes; i < n && anIt->more(); i++ )
1692 aResult[i] = anIt->next()->GetID();
1694 return aResult._retn();
1697 //=============================================================================
1701 //=============================================================================
1703 SMESH::ElementType SMESH_Mesh_i::GetElementType( const CORBA::Long id, const bool iselem )
1704 throw (SALOME::SALOME_Exception)
1706 return ( SMESH::ElementType )_impl->GetElementType( id, iselem );
1710 //=============================================================================
1712 * Returns ID of elements for given submesh
1714 //=============================================================================
1715 SMESH::long_array* SMESH_Mesh_i::GetSubMeshElementsId(const CORBA::Long ShapeID)
1716 throw (SALOME::SALOME_Exception)
1718 SMESH::long_array_var aResult = new SMESH::long_array();
1720 SMESH_subMesh* SM = _impl->GetSubMeshContaining(ShapeID);
1721 if(!SM) return aResult._retn();
1723 SMESHDS_SubMesh* SDSM = SM->GetSubMeshDS();
1724 if(!SDSM) return aResult._retn();
1726 aResult->length(SDSM->NbElements());
1728 SMDS_ElemIteratorPtr eIt = SDSM->GetElements();
1730 while ( eIt->more() ) {
1731 aResult[i++] = eIt->next()->GetID();
1734 return aResult._retn();
1738 //=============================================================================
1740 * Returns ID of nodes for given submesh
1741 * If param all==true - returns all nodes, else -
1742 * returns only nodes on shapes.
1744 //=============================================================================
1745 SMESH::long_array* SMESH_Mesh_i::GetSubMeshNodesId(const CORBA::Long ShapeID, CORBA::Boolean all)
1746 throw (SALOME::SALOME_Exception)
1748 SMESH::long_array_var aResult = new SMESH::long_array();
1750 SMESH_subMesh* SM = _impl->GetSubMeshContaining(ShapeID);
1751 if(!SM) return aResult._retn();
1753 SMESHDS_SubMesh* SDSM = SM->GetSubMeshDS();
1754 if(!SDSM) return aResult._retn();
1756 map<int,const SMDS_MeshElement*> theElems;
1757 if( !all || (SDSM->NbElements()==0 && SDSM->NbNodes()==1) ) {
1758 SMDS_NodeIteratorPtr nIt = SDSM->GetNodes();
1759 while ( nIt->more() ) {
1760 const SMDS_MeshNode* elem = nIt->next();
1761 theElems.insert( make_pair(elem->GetID(),elem) );
1764 else { // all nodes of submesh elements
1765 SMDS_ElemIteratorPtr eIt = SDSM->GetElements();
1766 while ( eIt->more() ) {
1767 const SMDS_MeshElement* anElem = eIt->next();
1768 SMDS_ElemIteratorPtr nIt = anElem->nodesIterator();
1769 while ( nIt->more() ) {
1770 const SMDS_MeshElement* elem = nIt->next();
1771 theElems.insert( make_pair(elem->GetID(),elem) );
1776 aResult->length(theElems.size());
1777 map<int, const SMDS_MeshElement * >::iterator itElem;
1779 for ( itElem = theElems.begin(); itElem != theElems.end(); itElem++ )
1780 aResult[i++] = (*itElem).first;
1782 return aResult._retn();
1786 //=============================================================================
1788 * Returns type of elements for given submesh
1790 //=============================================================================
1791 SMESH::ElementType SMESH_Mesh_i::GetSubMeshElementType(const CORBA::Long ShapeID)
1792 throw (SALOME::SALOME_Exception)
1794 SMESH_subMesh* SM = _impl->GetSubMeshContaining(ShapeID);
1795 if(!SM) return SMESH::ALL;
1797 SMESHDS_SubMesh* SDSM = SM->GetSubMeshDS();
1798 if(!SDSM) return SMESH::ALL;
1800 if(SDSM->NbElements()==0)
1801 return (SM->GetSubShape().ShapeType() == TopAbs_VERTEX) ? SMESH::NODE : SMESH::ALL;
1803 SMDS_ElemIteratorPtr eIt = SDSM->GetElements();
1804 const SMDS_MeshElement* anElem = eIt->next();
1805 return ( SMESH::ElementType ) anElem->GetType();
1809 //=============================================================================
1813 //=============================================================================
1815 CORBA::LongLong SMESH_Mesh_i::GetMeshPtr()
1817 CORBA::LongLong pointeur = CORBA::LongLong(_impl);
1818 cerr << "CORBA::LongLong SMESH_Mesh_i::GetMeshPtr() " << pointeur << endl;
1823 //=============================================================================
1825 * Get XYZ coordinates of node as list of double
1826 * If there is not node for given ID - returns empty list
1828 //=============================================================================
1830 SMESH::double_array* SMESH_Mesh_i::GetNodeXYZ(const CORBA::Long id)
1832 SMESH::double_array_var aResult = new SMESH::double_array();
1833 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1834 if ( aSMESHDS_Mesh == NULL )
1835 return aResult._retn();
1838 const SMDS_MeshNode* aNode = aSMESHDS_Mesh->FindNode(id);
1840 return aResult._retn();
1844 aResult[0] = aNode->X();
1845 aResult[1] = aNode->Y();
1846 aResult[2] = aNode->Z();
1847 return aResult._retn();
1851 //=============================================================================
1853 * For given node returns list of IDs of inverse elements
1854 * If there is not node for given ID - returns empty list
1856 //=============================================================================
1858 SMESH::long_array* SMESH_Mesh_i::GetNodeInverseElements(const CORBA::Long id)
1860 SMESH::long_array_var aResult = new SMESH::long_array();
1861 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1862 if ( aSMESHDS_Mesh == NULL )
1863 return aResult._retn();
1866 const SMDS_MeshNode* aNode = aSMESHDS_Mesh->FindNode(id);
1868 return aResult._retn();
1870 // find inverse elements
1871 SMDS_ElemIteratorPtr eIt = aNode->GetInverseElementIterator();
1872 TColStd_SequenceOfInteger IDs;
1873 while(eIt->more()) {
1874 const SMDS_MeshElement* elem = eIt->next();
1875 IDs.Append(elem->GetID());
1877 if(IDs.Length()>0) {
1878 aResult->length(IDs.Length());
1880 for(; i<=IDs.Length(); i++) {
1881 aResult[i-1] = IDs.Value(i);
1884 return aResult._retn();
1888 //=============================================================================
1890 * If given element is node returns IDs of shape from position
1891 * If there is not node for given ID - returns -1
1893 //=============================================================================
1895 CORBA::Long SMESH_Mesh_i::GetShapeID(const CORBA::Long id)
1897 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1898 if ( aSMESHDS_Mesh == NULL )
1902 const SMDS_MeshNode* aNode = aSMESHDS_Mesh->FindNode(id);
1904 SMDS_PositionPtr pos = aNode->GetPosition();
1908 return pos->GetShapeId();
1915 //=============================================================================
1917 * For given element returns ID of result shape after
1918 * ::FindShape() from SMESH_MeshEditor
1919 * If there is not element for given ID - returns -1
1921 //=============================================================================
1923 CORBA::Long SMESH_Mesh_i::GetShapeIDForElem(const CORBA::Long id)
1925 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1926 if ( aSMESHDS_Mesh == NULL )
1929 // try to find element
1930 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
1934 //SMESH::SMESH_MeshEditor_var aMeshEditor = SMESH_Mesh_i::GetMeshEditor();
1935 ::SMESH_MeshEditor aMeshEditor(_impl);
1936 int index = aMeshEditor.FindShape( elem );
1944 //=============================================================================
1946 * Returns number of nodes for given element
1947 * If there is not element for given ID - returns -1
1949 //=============================================================================
1951 CORBA::Long SMESH_Mesh_i::GetElemNbNodes(const CORBA::Long id)
1953 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1954 if ( aSMESHDS_Mesh == NULL ) return -1;
1955 // try to find element
1956 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
1957 if(!elem) return -1;
1958 return elem->NbNodes();
1962 //=============================================================================
1964 * Returns ID of node by given index for given element
1965 * If there is not element for given ID - returns -1
1966 * If there is not node for given index - returns -2
1968 //=============================================================================
1970 CORBA::Long SMESH_Mesh_i::GetElemNode(const CORBA::Long id, const CORBA::Long index)
1972 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1973 if ( aSMESHDS_Mesh == NULL ) return -1;
1974 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
1975 if(!elem) return -1;
1976 if( index>=elem->NbNodes() || index<0 ) return -1;
1977 return elem->GetNode(index)->GetID();
1980 //=============================================================================
1982 * Returns IDs of nodes of given element
1984 //=============================================================================
1986 SMESH::long_array* SMESH_Mesh_i::GetElemNodes(const CORBA::Long id)
1988 SMESH::long_array_var aResult = new SMESH::long_array();
1989 if ( SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS() )
1991 if ( const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id) )
1993 aResult->length( elem->NbNodes() );
1994 for ( int i = 0; i < elem->NbNodes(); ++i )
1995 aResult[ i ] = elem->GetNode( i )->GetID();
1998 return aResult._retn();
2001 //=============================================================================
2003 * Returns true if given node is medium node
2004 * in given quadratic element
2006 //=============================================================================
2008 CORBA::Boolean SMESH_Mesh_i::IsMediumNode(const CORBA::Long ide, const CORBA::Long idn)
2010 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
2011 if ( aSMESHDS_Mesh == NULL ) return false;
2013 const SMDS_MeshNode* aNode = aSMESHDS_Mesh->FindNode(idn);
2014 if(!aNode) return false;
2015 // try to find element
2016 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(ide);
2017 if(!elem) return false;
2019 return elem->IsMediumNode(aNode);
2023 //=============================================================================
2025 * Returns true if given node is medium node
2026 * in one of quadratic elements
2028 //=============================================================================
2030 CORBA::Boolean SMESH_Mesh_i::IsMediumNodeOfAnyElem(const CORBA::Long idn,
2031 SMESH::ElementType theElemType)
2033 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
2034 if ( aSMESHDS_Mesh == NULL ) return false;
2037 const SMDS_MeshNode* aNode = aSMESHDS_Mesh->FindNode(idn);
2038 if(!aNode) return false;
2040 SMESH_MesherHelper aHelper( *(_impl) );
2042 SMDSAbs_ElementType aType;
2043 if(theElemType==SMESH::EDGE) aType = SMDSAbs_Edge;
2044 else if(theElemType==SMESH::FACE) aType = SMDSAbs_Face;
2045 else if(theElemType==SMESH::VOLUME) aType = SMDSAbs_Volume;
2046 else aType = SMDSAbs_All;
2048 return aHelper.IsMedium(aNode,aType);
2052 //=============================================================================
2054 * Returns number of edges for given element
2056 //=============================================================================
2058 CORBA::Long SMESH_Mesh_i::ElemNbEdges(const CORBA::Long id)
2060 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
2061 if ( aSMESHDS_Mesh == NULL ) return -1;
2062 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
2063 if(!elem) return -1;
2064 return elem->NbEdges();
2068 //=============================================================================
2070 * Returns number of faces for given element
2072 //=============================================================================
2074 CORBA::Long SMESH_Mesh_i::ElemNbFaces(const CORBA::Long id)
2076 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
2077 if ( aSMESHDS_Mesh == NULL ) return -1;
2078 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
2079 if(!elem) return -1;
2080 return elem->NbFaces();
2084 //=============================================================================
2086 * Returns true if given element is polygon
2088 //=============================================================================
2090 CORBA::Boolean SMESH_Mesh_i::IsPoly(const CORBA::Long id)
2092 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
2093 if ( aSMESHDS_Mesh == NULL ) return false;
2094 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
2095 if(!elem) return false;
2096 return elem->IsPoly();
2100 //=============================================================================
2102 * Returns true if given element is quadratic
2104 //=============================================================================
2106 CORBA::Boolean SMESH_Mesh_i::IsQuadratic(const CORBA::Long id)
2108 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
2109 if ( aSMESHDS_Mesh == NULL ) return false;
2110 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
2111 if(!elem) return false;
2112 return elem->IsQuadratic();
2116 //=============================================================================
2118 * Returns bary center for given element
2120 //=============================================================================
2122 SMESH::double_array* SMESH_Mesh_i::BaryCenter(const CORBA::Long id)
2124 SMESH::double_array_var aResult = new SMESH::double_array();
2125 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
2126 if ( aSMESHDS_Mesh == NULL )
2127 return aResult._retn();
2129 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
2131 return aResult._retn();
2133 if(elem->GetType()==SMDSAbs_Volume) {
2134 // use SMDS_VolumeTool
2135 SMDS_VolumeTool aTool;
2136 if(aTool.Set(elem)) {
2137 double x=0., y=0., z=0.;
2138 if(aTool.GetBaryCenter(x,y,z)) {
2148 SMDS_ElemIteratorPtr anIt = elem->nodesIterator();
2150 double x=0., y=0., z=0.;
2151 for(; anIt->more(); ) {
2153 const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>(anIt->next());
2167 return aResult._retn();
2171 //=============================================================================
2175 //=============================================================================
2176 void SMESH_Mesh_i::CreateGroupServants()
2178 // Create group servants, if any groups were imported
2179 list<int> aGroupIds = _impl->GetGroupIds();
2180 for ( list<int>::iterator it = aGroupIds.begin(); it != aGroupIds.end(); it++ ) {
2181 SMESH_Group_i* aGroupImpl = new SMESH_Group_i( SMESH_Gen_i::GetPOA(), this, *it );
2183 // PAL7962: san -- To ensure correct mapping of servant and correct reference counting in GenericObj_i
2184 SMESH_Gen_i::GetPOA()->activate_object( aGroupImpl );
2185 aGroupImpl->Register();
2186 // PAL7962: san -- To ensure correct mapping of servant and correct reference counting in GenericObj_i
2188 SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow( aGroupImpl->_this() );
2189 _mapGroups[*it] = SMESH::SMESH_Group::_duplicate( aGroup );
2191 // register CORBA object for persistence
2192 int nextId = _gen_i->RegisterObject( aGroup );
2193 if(MYDEBUG) MESSAGE( "Add group to map with id = "<< nextId);