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++;
98 thePOA->activate_object( this );
101 //=============================================================================
105 //=============================================================================
107 SMESH_Mesh_i::~SMESH_Mesh_i()
109 INFOS("~SMESH_Mesh_i");
110 map<int, SMESH::SMESH_GroupBase_ptr>::iterator it;
111 for ( it = _mapGroups.begin(); it != _mapGroups.end(); it++ ) {
112 SMESH_GroupBase_i* aGroup = dynamic_cast<SMESH_GroupBase_i*>( SMESH_Gen_i::GetServant( it->second ).in() );
115 // this method is colled from destructor of group (PAL6331)
116 //_impl->RemoveGroup( aGroup->GetLocalID() );
124 //=============================================================================
128 * Associates <this> mesh with <theShape> and puts a reference
129 * to <theShape> into the current study;
130 * the previous shape is substituted by the new one.
132 //=============================================================================
134 void SMESH_Mesh_i::SetShape( GEOM::GEOM_Object_ptr theShapeObject )
135 throw (SALOME::SALOME_Exception)
137 Unexpect aCatch(SALOME_SalomeException);
139 _impl->ShapeToMesh( _gen_i->GeomObjectToShape( theShapeObject ));
141 catch(SALOME_Exception & S_ex) {
142 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
146 //================================================================================
148 * \brief return true if mesh has a shape to build a shape on
150 //================================================================================
152 CORBA::Boolean SMESH_Mesh_i::HasShapeToMesh()
153 throw (SALOME::SALOME_Exception)
155 Unexpect aCatch(SALOME_SalomeException);
158 res = _impl->HasShapeToMesh();
160 catch(SALOME_Exception & S_ex) {
161 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
166 //=======================================================================
167 //function : GetShapeToMesh
169 //=======================================================================
171 GEOM::GEOM_Object_ptr SMESH_Mesh_i::GetShapeToMesh()
172 throw (SALOME::SALOME_Exception)
174 Unexpect aCatch(SALOME_SalomeException);
175 GEOM::GEOM_Object_var aShapeObj;
177 TopoDS_Shape S = _impl->GetMeshDS()->ShapeToMesh();
179 aShapeObj = _gen_i->ShapeToGeomObject( S );
181 catch(SALOME_Exception & S_ex) {
182 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
184 return aShapeObj._retn();
187 //=============================================================================
191 //=============================================================================
193 static SMESH::DriverMED_ReadStatus ConvertDriverMEDReadStatus (int theStatus)
195 SMESH::DriverMED_ReadStatus res;
198 case DriverMED_R_SMESHDS_Mesh::DRS_OK:
199 res = SMESH::DRS_OK; break;
200 case DriverMED_R_SMESHDS_Mesh::DRS_EMPTY:
201 res = SMESH::DRS_EMPTY; break;
202 case DriverMED_R_SMESHDS_Mesh::DRS_WARN_RENUMBER:
203 res = SMESH::DRS_WARN_RENUMBER; break;
204 case DriverMED_R_SMESHDS_Mesh::DRS_WARN_SKIP_ELEM:
205 res = SMESH::DRS_WARN_SKIP_ELEM; break;
206 case DriverMED_R_SMESHDS_Mesh::DRS_FAIL:
208 res = SMESH::DRS_FAIL; break;
213 //=============================================================================
217 * Imports mesh data from MED file
219 //=============================================================================
221 SMESH::DriverMED_ReadStatus
222 SMESH_Mesh_i::ImportMEDFile( const char* theFileName, const char* theMeshName )
223 throw ( SALOME::SALOME_Exception )
225 Unexpect aCatch(SALOME_SalomeException);
228 status = importMEDFile( theFileName, theMeshName );
230 catch( SALOME_Exception& S_ex ) {
231 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
234 THROW_SALOME_CORBA_EXCEPTION("ImportMEDFile(): unknown exception", SALOME::BAD_PARAM);
237 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
238 if ( !aStudy->_is_nil() ) {
239 // publishing of the groups in the study (sub-meshes are out of scope of MED import)
240 map<int, SMESH::SMESH_GroupBase_ptr>::iterator it = _mapGroups.begin();
241 for (; it != _mapGroups.end(); it++ ) {
242 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_duplicate( it->second );
243 _gen_i->PublishGroup( aStudy, _this(), aGroup,
244 GEOM::GEOM_Object::_nil(), aGroup->GetName());
247 return ConvertDriverMEDReadStatus(status);
250 //=============================================================================
254 * Imports mesh data from MED file
256 //=============================================================================
258 int SMESH_Mesh_i::ImportUNVFile( const char* theFileName )
259 throw ( SALOME::SALOME_Exception )
261 // Read mesh with name = <theMeshName> into SMESH_Mesh
262 _impl->UNVToMesh( theFileName );
264 CreateGroupServants();
266 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
267 if ( !aStudy->_is_nil() ) {
268 // publishing of the groups in the study (sub-meshes are out of scope of UNV import)
269 map<int, SMESH::SMESH_GroupBase_ptr>::iterator it = _mapGroups.begin();
270 for (; it != _mapGroups.end(); it++ ) {
271 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_duplicate( it->second );
272 _gen_i->PublishGroup( aStudy, _this(), aGroup,
273 GEOM::GEOM_Object::_nil(), aGroup->GetName());
279 //=============================================================================
283 * Imports mesh data from STL file
285 //=============================================================================
286 int SMESH_Mesh_i::ImportSTLFile( const char* theFileName )
287 throw ( SALOME::SALOME_Exception )
289 // Read mesh with name = <theMeshName> into SMESH_Mesh
290 _impl->STLToMesh( theFileName );
295 //=============================================================================
299 * Imports mesh data from MED file
301 //=============================================================================
303 int SMESH_Mesh_i::importMEDFile( const char* theFileName, const char* theMeshName )
305 // Read mesh with name = <theMeshName> and all its groups into SMESH_Mesh
306 int status = _impl->MEDToMesh( theFileName, theMeshName );
307 CreateGroupServants();
312 //=============================================================================
316 //=============================================================================
318 #define RETURNCASE(hyp_stat) case SMESH_Hypothesis::hyp_stat: return SMESH::hyp_stat;
320 static SMESH::Hypothesis_Status ConvertHypothesisStatus
321 (SMESH_Hypothesis::Hypothesis_Status theStatus)
324 RETURNCASE( HYP_OK );
325 RETURNCASE( HYP_MISSING );
326 RETURNCASE( HYP_CONCURENT );
327 RETURNCASE( HYP_BAD_PARAMETER );
328 RETURNCASE( HYP_HIDDEN_ALGO );
329 RETURNCASE( HYP_HIDING_ALGO );
330 RETURNCASE( HYP_UNKNOWN_FATAL );
331 RETURNCASE( HYP_INCOMPATIBLE );
332 RETURNCASE( HYP_NOTCONFORM );
333 RETURNCASE( HYP_ALREADY_EXIST );
334 RETURNCASE( HYP_BAD_DIM );
335 RETURNCASE( HYP_BAD_SUBSHAPE );
336 RETURNCASE( HYP_BAD_GEOMETRY );
339 return SMESH::HYP_UNKNOWN_FATAL;
342 //=============================================================================
346 * calls internal addHypothesis() and then adds a reference to <anHyp> under
347 * the SObject actually having a reference to <aSubShape>.
348 * NB: For this method to work, it is necessary to add a reference to sub-shape first.
350 //=============================================================================
352 SMESH::Hypothesis_Status SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
353 SMESH::SMESH_Hypothesis_ptr anHyp)
354 throw(SALOME::SALOME_Exception)
356 Unexpect aCatch(SALOME_SalomeException);
357 SMESH_Hypothesis::Hypothesis_Status status = addHypothesis( aSubShapeObject, anHyp );
359 if ( !SMESH_Hypothesis::IsStatusFatal(status) )
360 _gen_i->AddHypothesisToShape(_gen_i->GetCurrentStudy(), _this(),
361 aSubShapeObject, anHyp );
363 if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status );
365 // Update Python script
366 TPythonDump() << "status = " << _this() << ".AddHypothesis( "
367 << aSubShapeObject << ", " << anHyp << " )";
369 return ConvertHypothesisStatus(status);
372 //=============================================================================
376 //=============================================================================
378 SMESH_Hypothesis::Hypothesis_Status
379 SMESH_Mesh_i::addHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
380 SMESH::SMESH_Hypothesis_ptr anHyp)
382 if(MYDEBUG) MESSAGE("addHypothesis");
384 if (CORBA::is_nil(aSubShapeObject))
385 THROW_SALOME_CORBA_EXCEPTION("bad subShape reference",
388 SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow(anHyp);
389 if (CORBA::is_nil(myHyp))
390 THROW_SALOME_CORBA_EXCEPTION("bad hypothesis reference",
393 SMESH_Hypothesis::Hypothesis_Status status = SMESH_Hypothesis::HYP_OK;
396 TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape( aSubShapeObject);
397 int hypId = myHyp->GetId();
398 status = _impl->AddHypothesis(myLocSubShape, hypId);
399 if ( !SMESH_Hypothesis::IsStatusFatal(status) ) {
400 _mapHypo[hypId] = SMESH::SMESH_Hypothesis::_duplicate( myHyp );
401 // assure there is a corresponding submesh
402 if ( !_impl->IsMainShape( myLocSubShape )) {
403 int shapeId = _impl->GetMeshDS()->ShapeToIndex( myLocSubShape );
404 if ( _mapSubMesh_i.find( shapeId ) == _mapSubMesh_i.end() )
405 createSubMesh( aSubShapeObject );
409 catch(SALOME_Exception & S_ex)
411 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
416 //=============================================================================
420 //=============================================================================
422 SMESH::Hypothesis_Status SMESH_Mesh_i::RemoveHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
423 SMESH::SMESH_Hypothesis_ptr anHyp)
424 throw(SALOME::SALOME_Exception)
426 Unexpect aCatch(SALOME_SalomeException);
427 SMESH_Hypothesis::Hypothesis_Status status = removeHypothesis( aSubShapeObject, anHyp );
429 if ( !SMESH_Hypothesis::IsStatusFatal(status) )
430 _gen_i->RemoveHypothesisFromShape(_gen_i->GetCurrentStudy(), _this(),
431 aSubShapeObject, anHyp );
433 // Update Python script
434 TPythonDump() << "status = " << _this() << ".RemoveHypothesis( "
435 << aSubShapeObject << ", " << anHyp << " )";
437 return ConvertHypothesisStatus(status);
440 //=============================================================================
444 //=============================================================================
446 SMESH_Hypothesis::Hypothesis_Status SMESH_Mesh_i::removeHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
447 SMESH::SMESH_Hypothesis_ptr anHyp)
449 if(MYDEBUG) MESSAGE("removeHypothesis()");
450 // **** proposer liste de subShape (selection multiple)
452 if (CORBA::is_nil(aSubShapeObject))
453 THROW_SALOME_CORBA_EXCEPTION("bad subShape reference",
456 SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow(anHyp);
457 if (CORBA::is_nil(myHyp))
458 THROW_SALOME_CORBA_EXCEPTION("bad hypothesis reference",
461 SMESH_Hypothesis::Hypothesis_Status status = SMESH_Hypothesis::HYP_OK;
464 TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape(aSubShapeObject);
465 int hypId = myHyp->GetId();
466 status = _impl->RemoveHypothesis(myLocSubShape, hypId);
467 if ( !SMESH_Hypothesis::IsStatusFatal(status) )
468 _mapHypo.erase( hypId );
470 catch(SALOME_Exception & S_ex)
472 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
477 //=============================================================================
481 //=============================================================================
483 SMESH::ListOfHypothesis *
484 SMESH_Mesh_i::GetHypothesisList(GEOM::GEOM_Object_ptr aSubShapeObject)
485 throw(SALOME::SALOME_Exception)
487 Unexpect aCatch(SALOME_SalomeException);
488 if (MYDEBUG) MESSAGE("GetHypothesisList");
489 if (CORBA::is_nil(aSubShapeObject))
490 THROW_SALOME_CORBA_EXCEPTION("bad subShape reference",
493 SMESH::ListOfHypothesis_var aList = new SMESH::ListOfHypothesis();
496 TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape(aSubShapeObject);
497 const list<const SMESHDS_Hypothesis*>& aLocalList = _impl->GetHypothesisList( myLocSubShape );
498 int i = 0, n = aLocalList.size();
501 for ( list<const SMESHDS_Hypothesis*>::const_iterator anIt = aLocalList.begin(); i < n && anIt != aLocalList.end(); anIt++ ) {
502 SMESHDS_Hypothesis* aHyp = (SMESHDS_Hypothesis*)(*anIt);
503 if ( _mapHypo.find( aHyp->GetID() ) != _mapHypo.end() )
504 aList[i++] = SMESH::SMESH_Hypothesis::_narrow( _mapHypo[aHyp->GetID()] );
509 catch(SALOME_Exception & S_ex) {
510 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
513 return aList._retn();
516 //=============================================================================
520 //=============================================================================
521 SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::GetSubMesh(GEOM::GEOM_Object_ptr aSubShapeObject,
522 const char* theName )
523 throw(SALOME::SALOME_Exception)
525 Unexpect aCatch(SALOME_SalomeException);
526 MESSAGE("SMESH_Mesh_i::GetSubMesh");
527 if (CORBA::is_nil(aSubShapeObject))
528 THROW_SALOME_CORBA_EXCEPTION("bad subShape reference",
531 SMESH::SMESH_subMesh_var subMesh;
532 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(_this());
534 TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape(aSubShapeObject);
536 //Get or Create the SMESH_subMesh object implementation
538 int subMeshId = _impl->GetMeshDS()->ShapeToIndex( myLocSubShape );
539 subMesh = getSubMesh( subMeshId );
541 // create a new subMesh object servant if there is none for the shape
542 if ( subMesh->_is_nil() )
543 subMesh = createSubMesh( aSubShapeObject );
545 if ( _gen_i->CanPublishInStudy( subMesh )) {
546 SALOMEDS::SObject_var aSO =
547 _gen_i->PublishSubMesh(_gen_i->GetCurrentStudy(), aMesh,
548 subMesh, aSubShapeObject, theName );
549 if ( !aSO->_is_nil()) {
550 // Update Python script
551 TPythonDump() << aSO << " = " << _this() << ".GetSubMesh( "
552 << aSubShapeObject << ", '" << theName << "' )";
556 catch(SALOME_Exception & S_ex) {
557 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
559 return subMesh._retn();
562 //=============================================================================
566 //=============================================================================
568 void SMESH_Mesh_i::RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh )
569 throw (SALOME::SALOME_Exception)
571 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::RemoveSubMesh");
572 if ( theSubMesh->_is_nil() )
575 GEOM::GEOM_Object_var aSubShapeObject;
576 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
577 if ( !aStudy->_is_nil() ) {
578 // Remove submesh's SObject
579 SALOMEDS::SObject_var anSO = _gen_i->ObjectToSObject( aStudy, theSubMesh );
580 if ( !anSO->_is_nil() ) {
581 long aTag = SMESH_Gen_i::GetRefOnShapeTag();
582 SALOMEDS::SObject_var anObj, aRef;
583 if ( anSO->FindSubObject( aTag, anObj ) && anObj->ReferencedObject( aRef ) )
584 aSubShapeObject = GEOM::GEOM_Object::_narrow( aRef->GetObject() );
586 aStudy->NewBuilder()->RemoveObjectWithChildren( anSO );
588 // Update Python script
589 TPythonDump() << _this() << ".RemoveSubMesh( " << anSO << " )";
593 removeSubMesh( theSubMesh, aSubShapeObject.in() );
596 //=============================================================================
600 //=============================================================================
601 #define CASE2STRING(enum) case SMESH::enum: return "SMESH."#enum;
602 inline TCollection_AsciiString ElementTypeString (SMESH::ElementType theElemType)
604 switch (theElemType) {
609 CASE2STRING( VOLUME );
615 //=============================================================================
619 //=============================================================================
621 SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateGroup( SMESH::ElementType theElemType,
622 const char* theName )
623 throw(SALOME::SALOME_Exception)
625 Unexpect aCatch(SALOME_SalomeException);
626 SMESH::SMESH_Group_var aNewGroup =
627 SMESH::SMESH_Group::_narrow( createGroup( theElemType, theName ));
629 if ( _gen_i->CanPublishInStudy( aNewGroup ) ) {
630 SALOMEDS::SObject_var aSO =
631 _gen_i->PublishGroup(_gen_i->GetCurrentStudy(), _this(),
632 aNewGroup, GEOM::GEOM_Object::_nil(), theName);
633 if ( !aSO->_is_nil()) {
634 // Update Python script
635 TPythonDump() << aSO << " = " << _this() << ".CreateGroup( "
636 << ElementTypeString(theElemType) << ", '" << theName << "' )";
639 return aNewGroup._retn();
643 //=============================================================================
647 //=============================================================================
648 SMESH::SMESH_GroupOnGeom_ptr SMESH_Mesh_i::CreateGroupFromGEOM (SMESH::ElementType theElemType,
650 GEOM::GEOM_Object_ptr theGeomObj)
651 throw(SALOME::SALOME_Exception)
653 Unexpect aCatch(SALOME_SalomeException);
654 SMESH::SMESH_GroupOnGeom_var aNewGroup;
656 TopoDS_Shape aShape = _gen_i->GeomObjectToShape( theGeomObj );
657 if ( !aShape.IsNull() ) {
658 aNewGroup = SMESH::SMESH_GroupOnGeom::_narrow
659 ( createGroup( theElemType, theName, aShape ));
660 if ( _gen_i->CanPublishInStudy( aNewGroup ) ) {
661 SALOMEDS::SObject_var aSO =
662 _gen_i->PublishGroup(_gen_i->GetCurrentStudy(), _this(),
663 aNewGroup, theGeomObj, theName);
664 if ( !aSO->_is_nil()) {
665 // Update Python script
666 TPythonDump() << aSO << " = " << _this() << ".CreateGroupFromGEOM("
667 << ElementTypeString(theElemType) << ", '" << theName << "', "
668 << theGeomObj << " )";
673 return aNewGroup._retn();
676 //=============================================================================
680 //=============================================================================
682 void SMESH_Mesh_i::RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup )
683 throw (SALOME::SALOME_Exception)
685 if ( theGroup->_is_nil() )
688 SMESH_GroupBase_i* aGroup =
689 dynamic_cast<SMESH_GroupBase_i*>( SMESH_Gen_i::GetServant( theGroup ).in() );
693 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
694 if ( !aStudy->_is_nil() ) {
695 SALOMEDS::SObject_var aGroupSO = _gen_i->ObjectToSObject( aStudy, theGroup );
697 if ( !aGroupSO->_is_nil() ) {
698 // Update Python script
699 TPythonDump() << _this() << ".RemoveGroup( " << aGroupSO << " )";
701 // Remove group's SObject
702 aStudy->NewBuilder()->RemoveObject( aGroupSO );
706 // Remove the group from SMESH data structures
707 removeGroup( aGroup->GetLocalID() );
710 //=============================================================================
711 /*! RemoveGroupWithContents
712 * Remove group with its contents
714 //=============================================================================
715 void SMESH_Mesh_i::RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup )
716 throw (SALOME::SALOME_Exception)
718 if ( theGroup->_is_nil() )
721 SMESH_GroupBase_i* aGroup =
722 dynamic_cast<SMESH_GroupBase_i*>( SMESH_Gen_i::GetServant( theGroup ).in() );
726 SMESH::long_array_var anIds = aGroup->GetListOfID();
727 SMESH::SMESH_MeshEditor_var aMeshEditor = SMESH_Mesh_i::GetMeshEditor();
729 // Update Python script
730 TPythonDump() << _this() << ".RemoveGroupWithContents( " << theGroup << " )";
733 if ( aGroup->GetType() == SMESH::NODE )
734 aMeshEditor->RemoveNodes( anIds );
736 aMeshEditor->RemoveElements( anIds );
739 RemoveGroup( theGroup );
741 // Clear python lines, created by RemoveNodes/Elements() and RemoveGroup()
742 _gen_i->RemoveLastFromPythonScript(_gen_i->GetCurrentStudy()->StudyId());
743 _gen_i->RemoveLastFromPythonScript(_gen_i->GetCurrentStudy()->StudyId());
747 //================================================================================
749 * \brief Get the list of groups existing in the mesh
750 * \retval SMESH::ListOfGroups * - list of groups
752 //================================================================================
754 SMESH::ListOfGroups * SMESH_Mesh_i::GetGroups() throw(SALOME::SALOME_Exception)
756 Unexpect aCatch(SALOME_SalomeException);
757 if (MYDEBUG) MESSAGE("GetGroups");
759 SMESH::ListOfGroups_var aList = new SMESH::ListOfGroups();
761 TPythonDump aPythonDump;
765 aList->length( _mapGroups.size() );
767 map<int, SMESH::SMESH_GroupBase_ptr>::iterator it = _mapGroups.begin();
768 for ( ; it != _mapGroups.end(); it++ ) {
769 if ( CORBA::is_nil( it->second )) continue;
770 aList[i++] = SMESH::SMESH_GroupBase::_duplicate( it->second );
772 if (i > 1) aPythonDump << ", ";
773 aPythonDump << it->second;
777 catch(SALOME_Exception & S_ex) {
778 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
781 // Update Python script
782 aPythonDump << " ] = " << _this() << ".GetGroups()";
784 return aList._retn();
787 //=============================================================================
789 * New group is created. All mesh elements that are
790 * present in initial groups are added to the new one
792 //=============================================================================
793 SMESH::SMESH_Group_ptr SMESH_Mesh_i::UnionGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
794 SMESH::SMESH_GroupBase_ptr theGroup2,
795 const char* theName )
796 throw (SALOME::SALOME_Exception)
800 if ( theGroup1->_is_nil() || theGroup2->_is_nil() ||
801 theGroup1->GetType() != theGroup2->GetType() )
802 return SMESH::SMESH_Group::_nil();
805 SMESH::SMESH_Group_var aResGrp = CreateGroup( theGroup1->GetType(), theName );
806 if ( aResGrp->_is_nil() )
807 return SMESH::SMESH_Group::_nil();
809 SMESH::long_array_var anIds1 = theGroup1->GetListOfID();
810 SMESH::long_array_var anIds2 = theGroup2->GetListOfID();
812 TColStd_MapOfInteger aResMap;
814 for ( int i1 = 0, n1 = anIds1->length(); i1 < n1; i1++ )
815 aResMap.Add( anIds1[ i1 ] );
817 for ( int i2 = 0, n2 = anIds2->length(); i2 < n2; i2++ )
818 aResMap.Add( anIds2[ i2 ] );
820 SMESH::long_array_var aResIds = new SMESH::long_array;
821 aResIds->length( aResMap.Extent() );
824 TColStd_MapIteratorOfMapOfInteger anIter( aResMap );
825 for( ; anIter.More(); anIter.Next() )
826 aResIds[ resI++ ] = anIter.Key();
828 aResGrp->Add( aResIds );
830 // Clear python lines, created by CreateGroup() and Add()
831 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
832 _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
833 _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
835 // Update Python script
836 TPythonDump() << aResGrp << " = " << _this() << ".UnionGroups( "
837 << theGroup1 << ", " << theGroup2 << ", '"
840 return aResGrp._retn();
844 return SMESH::SMESH_Group::_nil();
848 //=============================================================================
850 * New group is created. All mesh elements that are
851 * present in both initial groups are added to the new one.
853 //=============================================================================
854 SMESH::SMESH_Group_ptr SMESH_Mesh_i::IntersectGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
855 SMESH::SMESH_GroupBase_ptr theGroup2,
856 const char* theName )
857 throw (SALOME::SALOME_Exception)
859 if ( theGroup1->_is_nil() || theGroup2->_is_nil() ||
860 theGroup1->GetType() != theGroup2->GetType() )
861 return SMESH::SMESH_Group::_nil();
863 // Create Intersection
864 SMESH::SMESH_Group_var aResGrp = CreateGroup( theGroup1->GetType(), theName );
865 if ( aResGrp->_is_nil() )
868 SMESH::long_array_var anIds1 = theGroup1->GetListOfID();
869 SMESH::long_array_var anIds2 = theGroup2->GetListOfID();
871 TColStd_MapOfInteger aMap1;
873 for ( int i1 = 0, n1 = anIds1->length(); i1 < n1; i1++ )
874 aMap1.Add( anIds1[ i1 ] );
876 TColStd_SequenceOfInteger aSeq;
878 for ( int i2 = 0, n2 = anIds2->length(); i2 < n2; i2++ )
879 if ( aMap1.Contains( anIds2[ i2 ] ) )
880 aSeq.Append( anIds2[ i2 ] );
882 SMESH::long_array_var aResIds = new SMESH::long_array;
883 aResIds->length( aSeq.Length() );
885 for ( int resI = 0, resN = aSeq.Length(); resI < resN; resI++ )
886 aResIds[ resI ] = aSeq( resI + 1 );
888 aResGrp->Add( aResIds );
890 // Clear python lines, created by CreateGroup() and Add()
891 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
892 _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
893 _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
895 // Update Python script
896 TPythonDump() << aResGrp << " = " << _this() << ".IntersectGroups( "
897 << theGroup1 << ", " << theGroup2 << ", '" << theName << "')";
899 return aResGrp._retn();
902 //=============================================================================
904 * New group is created. All mesh elements that are present in
905 * main group but do not present in tool group are added to the new one
907 //=============================================================================
908 SMESH::SMESH_Group_ptr SMESH_Mesh_i::CutGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
909 SMESH::SMESH_GroupBase_ptr theGroup2,
910 const char* theName )
911 throw (SALOME::SALOME_Exception)
913 if ( theGroup1->_is_nil() || theGroup2->_is_nil() ||
914 theGroup1->GetType() != theGroup2->GetType() )
915 return SMESH::SMESH_Group::_nil();
918 SMESH::SMESH_Group_var aResGrp = CreateGroup( theGroup1->GetType(), theName );
919 if ( aResGrp->_is_nil() )
922 SMESH::long_array_var anIds1 = theGroup1->GetListOfID();
923 SMESH::long_array_var anIds2 = theGroup2->GetListOfID();
925 TColStd_MapOfInteger aMap2;
927 for ( int i2 = 0, n2 = anIds2->length(); i2 < n2; i2++ )
928 aMap2.Add( anIds2[ i2 ] );
931 TColStd_SequenceOfInteger aSeq;
932 for ( int i1 = 0, n1 = anIds1->length(); i1 < n1; i1++ )
933 if ( !aMap2.Contains( anIds1[ i1 ] ) )
934 aSeq.Append( anIds1[ i1 ] );
936 SMESH::long_array_var aResIds = new SMESH::long_array;
937 aResIds->length( aSeq.Length() );
939 for ( int resI = 0, resN = aSeq.Length(); resI < resN; resI++ )
940 aResIds[ resI ] = aSeq( resI + 1 );
942 aResGrp->Add( aResIds );
944 // Clear python lines, created by CreateGroup() and Add()
945 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
946 _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
947 _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
949 // Update Python script
950 TPythonDump() << aResGrp << " = " << _this() << ".CutGroups( "
951 << theGroup1 << ", " << theGroup2 << ", '"
954 return aResGrp._retn();
957 //=============================================================================
961 //=============================================================================
963 SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::createSubMesh( GEOM::GEOM_Object_ptr theSubShapeObject )
965 if(MYDEBUG) MESSAGE( "createSubMesh" );
966 TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape(theSubShapeObject);
968 ::SMESH_subMesh * mySubMesh = _impl->GetSubMesh(myLocSubShape);
969 int subMeshId = _impl->GetMeshDS()->ShapeToIndex( myLocSubShape );
970 SMESH_subMesh_i *subMeshServant = new SMESH_subMesh_i(myPOA, _gen_i, this, subMeshId);
971 SMESH::SMESH_subMesh_var subMesh
972 = SMESH::SMESH_subMesh::_narrow(subMeshServant->_this());
974 _mapSubMesh[subMeshId] = mySubMesh;
975 _mapSubMesh_i[subMeshId] = subMeshServant;
976 _mapSubMeshIor[subMeshId] = SMESH::SMESH_subMesh::_duplicate(subMesh);
978 // register CORBA object for persistence
979 int nextId = _gen_i->RegisterObject( subMesh );
980 if(MYDEBUG) MESSAGE( "Add submesh to map with id = "<< nextId);
982 return subMesh._retn();
985 //=======================================================================
986 //function : getSubMesh
988 //=======================================================================
990 SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::getSubMesh(int shapeID)
992 map<int, SMESH::SMESH_subMesh_ptr>::iterator it = _mapSubMeshIor.find( shapeID );
993 if ( it == _mapSubMeshIor.end() )
994 return SMESH::SMESH_subMesh::_nil();
996 return SMESH::SMESH_subMesh::_duplicate( (*it).second );
1000 //=============================================================================
1004 //=============================================================================
1006 void SMESH_Mesh_i::removeSubMesh (SMESH::SMESH_subMesh_ptr theSubMesh,
1007 GEOM::GEOM_Object_ptr theSubShapeObject )
1009 MESSAGE("SMESH_Mesh_i::removeSubMesh()");
1010 if ( theSubMesh->_is_nil() || theSubShapeObject->_is_nil() )
1014 SMESH::ListOfHypothesis_var aHypList = GetHypothesisList( theSubShapeObject );
1015 for ( int i = 0, n = aHypList->length(); i < n; i++ ) {
1016 removeHypothesis( theSubShapeObject, aHypList[i] );
1019 catch( const SALOME::SALOME_Exception& ) {
1020 INFOS("SMESH_Mesh_i::removeSubMesh(): exception caught!");
1023 int subMeshId = theSubMesh->GetId();
1025 _mapSubMesh.erase(subMeshId);
1026 _mapSubMesh_i.erase(subMeshId);
1027 _mapSubMeshIor.erase(subMeshId);
1028 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::removeSubMesh() completed");
1031 //=============================================================================
1035 //=============================================================================
1037 SMESH::SMESH_GroupBase_ptr SMESH_Mesh_i::createGroup (SMESH::ElementType theElemType,
1038 const char* theName,
1039 const TopoDS_Shape& theShape )
1042 SMESH::SMESH_GroupBase_var aGroup;
1043 if ( _impl->AddGroup( (SMDSAbs_ElementType)theElemType, theName, anId, theShape )) {
1044 SMESH_GroupBase_i* aGroupImpl;
1045 if ( !theShape.IsNull() )
1046 aGroupImpl = new SMESH_GroupOnGeom_i( SMESH_Gen_i::GetPOA(), this, anId );
1048 aGroupImpl = new SMESH_Group_i( SMESH_Gen_i::GetPOA(), this, anId );
1050 // PAL7962: san -- To ensure correct mapping of servant and correct reference counting in GenericObj_i
1051 SMESH_Gen_i::GetPOA()->activate_object( aGroupImpl );
1052 aGroupImpl->Register();
1053 // PAL7962: san -- To ensure correct mapping of servant and correct reference counting in GenericObj_i
1055 aGroup = SMESH::SMESH_GroupBase::_narrow( aGroupImpl->_this() );
1056 _mapGroups[anId] = SMESH::SMESH_GroupBase::_duplicate( aGroup );
1058 // register CORBA object for persistence
1059 int nextId = _gen_i->RegisterObject( aGroup );
1060 if(MYDEBUG) MESSAGE( "Add group to map with id = "<< nextId);
1062 return aGroup._retn();
1065 //=============================================================================
1067 * SMESH_Mesh_i::removeGroup
1069 * Should be called by ~SMESH_Group_i()
1071 //=============================================================================
1073 void SMESH_Mesh_i::removeGroup( const int theId )
1075 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::removeGroup()" );
1076 if ( _mapGroups.find( theId ) != _mapGroups.end() ) {
1077 _mapGroups.erase( theId );
1078 _impl->RemoveGroup( theId );
1083 //=============================================================================
1087 //=============================================================================
1089 SMESH::log_array * SMESH_Mesh_i::GetLog(CORBA::Boolean clearAfterGet)
1090 throw(SALOME::SALOME_Exception)
1092 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::GetLog");
1094 SMESH::log_array_var aLog;
1096 list < SMESHDS_Command * >logDS = _impl->GetLog();
1097 aLog = new SMESH::log_array;
1099 int lg = logDS.size();
1102 list < SMESHDS_Command * >::iterator its = logDS.begin();
1103 while(its != logDS.end()){
1104 SMESHDS_Command *com = *its;
1105 int comType = com->GetType();
1107 int lgcom = com->GetNumber();
1109 const list < int >&intList = com->GetIndexes();
1110 int inum = intList.size();
1112 list < int >::const_iterator ii = intList.begin();
1113 const list < double >&coordList = com->GetCoords();
1114 int rnum = coordList.size();
1116 list < double >::const_iterator ir = coordList.begin();
1117 aLog[indexLog].commandType = comType;
1118 aLog[indexLog].number = lgcom;
1119 aLog[indexLog].coords.length(rnum);
1120 aLog[indexLog].indexes.length(inum);
1121 for(int i = 0; i < rnum; i++){
1122 aLog[indexLog].coords[i] = *ir;
1123 //MESSAGE(" "<<i<<" "<<ir.Value());
1126 for(int i = 0; i < inum; i++){
1127 aLog[indexLog].indexes[i] = *ii;
1128 //MESSAGE(" "<<i<<" "<<ii.Value());
1137 catch(SALOME_Exception & S_ex){
1138 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
1140 return aLog._retn();
1144 //=============================================================================
1148 //=============================================================================
1150 void SMESH_Mesh_i::ClearLog() throw(SALOME::SALOME_Exception)
1152 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::ClearLog");
1156 //=============================================================================
1160 //=============================================================================
1162 CORBA::Long SMESH_Mesh_i::GetId()throw(SALOME::SALOME_Exception)
1164 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::GetId");
1168 //=============================================================================
1172 //=============================================================================
1174 CORBA::Long SMESH_Mesh_i::GetStudyId()throw(SALOME::SALOME_Exception)
1179 //=============================================================================
1183 //=============================================================================
1185 void SMESH_Mesh_i::SetImpl(::SMESH_Mesh * impl)
1187 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::SetImpl");
1191 //=============================================================================
1195 //=============================================================================
1197 ::SMESH_Mesh & SMESH_Mesh_i::GetImpl()
1199 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::GetImpl()");
1203 //=============================================================================
1205 * Return mesh editor
1207 //=============================================================================
1209 SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditor()
1211 // Create MeshEditor
1212 SMESH_MeshEditor_i *aMeshEditor = new SMESH_MeshEditor_i( _impl, false );
1213 SMESH::SMESH_MeshEditor_var aMesh = aMeshEditor->_this();
1215 // Update Python script
1216 TPythonDump() << aMeshEditor << " = " << _this() << ".GetMeshEditor()";
1218 return aMesh._retn();
1221 //=============================================================================
1223 * Return mesh edition previewer
1225 //=============================================================================
1227 SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditPreviewer()
1229 SMESH_MeshEditor_i *aMeshEditor = new SMESH_MeshEditor_i( _impl, true );
1230 SMESH::SMESH_MeshEditor_var aMesh = aMeshEditor->_this();
1231 return aMesh._retn();
1234 //=============================================================================
1236 * Export in different formats
1238 //=============================================================================
1240 CORBA::Boolean SMESH_Mesh_i::HasDuplicatedGroupNamesMED()
1242 return _impl->HasDuplicatedGroupNamesMED();
1245 static void PrepareForWriting (const char* file)
1247 TCollection_AsciiString aFullName ((char*)file);
1248 OSD_Path aPath (aFullName);
1249 OSD_File aFile (aPath);
1250 if (aFile.Exists()) {
1251 // existing filesystem node
1252 if (aFile.KindOfFile() == OSD_FILE) {
1253 if (aFile.IsWriteable()) {
1256 if (aFile.Failed()) {
1257 TCollection_AsciiString msg ("File ");
1258 msg += aFullName + " cannot be replaced.";
1259 THROW_SALOME_CORBA_EXCEPTION(msg.ToCString(), SALOME::BAD_PARAM);
1262 TCollection_AsciiString msg ("File ");
1263 msg += aFullName + " cannot be overwritten.";
1264 THROW_SALOME_CORBA_EXCEPTION(msg.ToCString(), SALOME::BAD_PARAM);
1267 TCollection_AsciiString msg ("Location ");
1268 msg += aFullName + " is not a file.";
1269 THROW_SALOME_CORBA_EXCEPTION(msg.ToCString(), SALOME::BAD_PARAM);
1272 // nonexisting file; check if it can be created
1274 aFile.Build(OSD_WriteOnly, OSD_Protection());
1275 if (aFile.Failed()) {
1276 TCollection_AsciiString msg ("You cannot create the file ");
1277 msg += aFullName + ". Check the directory existance and access rights.";
1278 THROW_SALOME_CORBA_EXCEPTION(msg.ToCString(), SALOME::BAD_PARAM);
1286 void SMESH_Mesh_i::ExportToMED (const char* file,
1287 CORBA::Boolean auto_groups,
1288 SMESH::MED_VERSION theVersion)
1289 throw(SALOME::SALOME_Exception)
1291 Unexpect aCatch(SALOME_SalomeException);
1293 // Update Python script
1294 TPythonDump() << _this() << ".ExportToMED( '"
1295 << file << "', " << auto_groups << ", " << theVersion << " )";
1298 PrepareForWriting(file);
1299 char* aMeshName = "Mesh";
1300 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
1301 if ( !aStudy->_is_nil() ) {
1302 SALOMEDS::SObject_var aMeshSO = _gen_i->ObjectToSObject( aStudy, _this() );
1303 if ( !aMeshSO->_is_nil() ) {
1304 aMeshName = aMeshSO->GetName();
1306 //SCRUTE(aMeshName);
1307 //SCRUTE(aMeshSO->GetID());
1309 // asv : 27.10.04 : fix of 6903: check for StudyLocked before adding attributes
1310 if ( !aStudy->GetProperties()->IsLocked() )
1312 SALOMEDS::GenericAttribute_var anAttr;
1313 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
1314 SALOMEDS::AttributeExternalFileDef_var aFileName;
1315 anAttr=aStudyBuilder->FindOrCreateAttribute(aMeshSO, "AttributeExternalFileDef");
1316 aFileName = SALOMEDS::AttributeExternalFileDef::_narrow(anAttr);
1317 ASSERT(!aFileName->_is_nil());
1318 aFileName->SetValue(file);
1319 SALOMEDS::AttributeFileType_var aFileType;
1320 anAttr=aStudyBuilder->FindOrCreateAttribute(aMeshSO, "AttributeFileType");
1321 aFileType = SALOMEDS::AttributeFileType::_narrow(anAttr);
1322 ASSERT(!aFileType->_is_nil());
1323 aFileType->SetValue("FICHIERMED");
1327 _impl->ExportMED( file, aMeshName, auto_groups, theVersion );
1330 void SMESH_Mesh_i::ExportMED (const char* file,
1331 CORBA::Boolean auto_groups)
1332 throw(SALOME::SALOME_Exception)
1334 ExportToMED(file,auto_groups,SMESH::MED_V2_1);
1337 void SMESH_Mesh_i::ExportDAT (const char *file)
1338 throw(SALOME::SALOME_Exception)
1340 Unexpect aCatch(SALOME_SalomeException);
1342 // Update Python script
1343 TPythonDump() << _this() << ".ExportDAT( '" << file << "' )";
1346 PrepareForWriting(file);
1347 _impl->ExportDAT(file);
1350 void SMESH_Mesh_i::ExportUNV (const char *file)
1351 throw(SALOME::SALOME_Exception)
1353 Unexpect aCatch(SALOME_SalomeException);
1355 // Update Python script
1356 TPythonDump() << _this() << ".ExportUNV( '" << file << "' )";
1359 PrepareForWriting(file);
1360 _impl->ExportUNV(file);
1363 void SMESH_Mesh_i::ExportSTL (const char *file, const bool isascii)
1364 throw(SALOME::SALOME_Exception)
1366 Unexpect aCatch(SALOME_SalomeException);
1368 // Update Python script
1369 TPythonDump() << _this() << ".ExportSTL( '" << file << "', " << isascii << " )";
1372 PrepareForWriting(file);
1373 _impl->ExportSTL(file, isascii);
1376 //=============================================================================
1380 //=============================================================================
1382 SALOME_MED::MESH_ptr SMESH_Mesh_i::GetMEDMesh()throw(SALOME::SALOME_Exception)
1384 Unexpect aCatch(SALOME_SalomeException);
1385 SMESH_MEDMesh_i *aMedMesh = new SMESH_MEDMesh_i(this);
1386 SALOME_MED::MESH_var aMesh = aMedMesh->_this();
1387 return aMesh._retn();
1390 //=============================================================================
1394 //=============================================================================
1395 CORBA::Long SMESH_Mesh_i::NbNodes()throw(SALOME::SALOME_Exception)
1397 Unexpect aCatch(SALOME_SalomeException);
1398 return _impl->NbNodes();
1401 //=============================================================================
1405 //=============================================================================
1406 CORBA::Long SMESH_Mesh_i::NbElements()throw (SALOME::SALOME_Exception)
1408 Unexpect aCatch(SALOME_SalomeException);
1409 return NbEdges() + NbFaces() + NbVolumes();
1412 //=============================================================================
1416 //=============================================================================
1417 CORBA::Long SMESH_Mesh_i::NbEdges()throw(SALOME::SALOME_Exception)
1419 Unexpect aCatch(SALOME_SalomeException);
1420 return _impl->NbEdges();
1423 CORBA::Long SMESH_Mesh_i::NbEdgesOfOrder(SMESH::ElementOrder order)
1424 throw(SALOME::SALOME_Exception)
1426 Unexpect aCatch(SALOME_SalomeException);
1427 return _impl->NbEdges( (::SMESH_Mesh::ElementOrder) order);
1430 //=============================================================================
1434 //=============================================================================
1435 CORBA::Long SMESH_Mesh_i::NbFaces()throw(SALOME::SALOME_Exception)
1437 Unexpect aCatch(SALOME_SalomeException);
1438 return _impl->NbFaces();
1441 CORBA::Long SMESH_Mesh_i::NbTriangles()throw(SALOME::SALOME_Exception)
1443 Unexpect aCatch(SALOME_SalomeException);
1444 return _impl->NbTriangles();
1447 CORBA::Long SMESH_Mesh_i::NbQuadrangles()throw(SALOME::SALOME_Exception)
1449 Unexpect aCatch(SALOME_SalomeException);
1450 return _impl->NbQuadrangles();
1453 CORBA::Long SMESH_Mesh_i::NbPolygons()throw(SALOME::SALOME_Exception)
1455 Unexpect aCatch(SALOME_SalomeException);
1456 return _impl->NbPolygons();
1459 CORBA::Long SMESH_Mesh_i::NbFacesOfOrder(SMESH::ElementOrder order)
1460 throw(SALOME::SALOME_Exception)
1462 Unexpect aCatch(SALOME_SalomeException);
1463 return _impl->NbFaces( (::SMESH_Mesh::ElementOrder) order);
1466 CORBA::Long SMESH_Mesh_i::NbTrianglesOfOrder(SMESH::ElementOrder order)
1467 throw(SALOME::SALOME_Exception)
1469 Unexpect aCatch(SALOME_SalomeException);
1470 return _impl->NbTriangles( (::SMESH_Mesh::ElementOrder) order);
1473 CORBA::Long SMESH_Mesh_i::NbQuadranglesOfOrder(SMESH::ElementOrder order)
1474 throw(SALOME::SALOME_Exception)
1476 Unexpect aCatch(SALOME_SalomeException);
1477 return _impl->NbQuadrangles( (::SMESH_Mesh::ElementOrder) order);
1480 //=============================================================================
1484 //=============================================================================
1485 CORBA::Long SMESH_Mesh_i::NbVolumes()throw(SALOME::SALOME_Exception)
1487 Unexpect aCatch(SALOME_SalomeException);
1488 return _impl->NbVolumes();
1491 CORBA::Long SMESH_Mesh_i::NbTetras()throw(SALOME::SALOME_Exception)
1493 Unexpect aCatch(SALOME_SalomeException);
1494 return _impl->NbTetras();
1497 CORBA::Long SMESH_Mesh_i::NbHexas()throw(SALOME::SALOME_Exception)
1499 Unexpect aCatch(SALOME_SalomeException);
1500 return _impl->NbHexas();
1503 CORBA::Long SMESH_Mesh_i::NbPyramids()throw(SALOME::SALOME_Exception)
1505 Unexpect aCatch(SALOME_SalomeException);
1506 return _impl->NbPyramids();
1509 CORBA::Long SMESH_Mesh_i::NbPrisms()throw(SALOME::SALOME_Exception)
1511 Unexpect aCatch(SALOME_SalomeException);
1512 return _impl->NbPrisms();
1515 CORBA::Long SMESH_Mesh_i::NbPolyhedrons()throw(SALOME::SALOME_Exception)
1517 Unexpect aCatch(SALOME_SalomeException);
1518 return _impl->NbPolyhedrons();
1521 CORBA::Long SMESH_Mesh_i::NbVolumesOfOrder(SMESH::ElementOrder order)
1522 throw(SALOME::SALOME_Exception)
1524 Unexpect aCatch(SALOME_SalomeException);
1525 return _impl->NbVolumes( (::SMESH_Mesh::ElementOrder) order);
1528 CORBA::Long SMESH_Mesh_i::NbTetrasOfOrder(SMESH::ElementOrder order)
1529 throw(SALOME::SALOME_Exception)
1531 Unexpect aCatch(SALOME_SalomeException);
1532 return _impl->NbTetras( (::SMESH_Mesh::ElementOrder) order);
1535 CORBA::Long SMESH_Mesh_i::NbHexasOfOrder(SMESH::ElementOrder order)
1536 throw(SALOME::SALOME_Exception)
1538 Unexpect aCatch(SALOME_SalomeException);
1539 return _impl->NbHexas( (::SMESH_Mesh::ElementOrder) order);
1542 CORBA::Long SMESH_Mesh_i::NbPyramidsOfOrder(SMESH::ElementOrder order)
1543 throw(SALOME::SALOME_Exception)
1545 Unexpect aCatch(SALOME_SalomeException);
1546 return _impl->NbPyramids( (::SMESH_Mesh::ElementOrder) order);
1549 CORBA::Long SMESH_Mesh_i::NbPrismsOfOrder(SMESH::ElementOrder order)
1550 throw(SALOME::SALOME_Exception)
1552 Unexpect aCatch(SALOME_SalomeException);
1553 return _impl->NbPrisms( (::SMESH_Mesh::ElementOrder) order);
1556 //=============================================================================
1560 //=============================================================================
1561 CORBA::Long SMESH_Mesh_i::NbSubMesh()throw(SALOME::SALOME_Exception)
1563 Unexpect aCatch(SALOME_SalomeException);
1564 return _impl->NbSubMesh();
1567 //=============================================================================
1571 //=============================================================================
1572 char* SMESH_Mesh_i::Dump()
1574 std::ostringstream os;
1576 return CORBA::string_dup( os.str().c_str() );
1579 //=============================================================================
1583 //=============================================================================
1584 SMESH::long_array* SMESH_Mesh_i::GetIDs()
1586 // SMESH::long_array_var aResult = new SMESH::long_array();
1587 // SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1588 // int aMinId = aSMESHDS_Mesh->MinElementID();
1589 // int aMaxId = aSMESHDS_Mesh->MaxElementID();
1591 // aResult->length(aMaxId - aMinId + 1);
1593 // for (int i = 0, id = aMinId; id <= aMaxId; id++ )
1594 // aResult[i++] = id;
1596 // return aResult._retn();
1598 return GetElementsId();
1601 //=============================================================================
1605 //=============================================================================
1607 SMESH::long_array* SMESH_Mesh_i::GetElementsId()
1608 throw (SALOME::SALOME_Exception)
1610 Unexpect aCatch(SALOME_SalomeException);
1611 MESSAGE("SMESH_Mesh_i::GetElementsId");
1612 SMESH::long_array_var aResult = new SMESH::long_array();
1613 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1615 if ( aSMESHDS_Mesh == NULL )
1616 return aResult._retn();
1618 long nbElements = NbElements();
1619 aResult->length( nbElements );
1620 SMDS_ElemIteratorPtr anIt = aSMESHDS_Mesh->elementsIterator();
1621 for ( int i = 0, n = nbElements; i < n && anIt->more(); i++ )
1622 aResult[i] = anIt->next()->GetID();
1624 return aResult._retn();
1628 //=============================================================================
1632 //=============================================================================
1634 SMESH::long_array* SMESH_Mesh_i::GetElementsByType( SMESH::ElementType theElemType )
1635 throw (SALOME::SALOME_Exception)
1637 Unexpect aCatch(SALOME_SalomeException);
1638 MESSAGE("SMESH_subMesh_i::GetElementsByType");
1639 SMESH::long_array_var aResult = new SMESH::long_array();
1640 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1642 if ( aSMESHDS_Mesh == NULL )
1643 return aResult._retn();
1645 long nbElements = NbElements();
1647 // No sense in returning ids of elements along with ids of nodes:
1648 // when theElemType == SMESH::ALL, return node ids only if
1649 // there are no elements
1650 if ( theElemType == SMESH::NODE || theElemType == SMESH::ALL && nbElements == 0 )
1651 return GetNodesId();
1653 aResult->length( nbElements );
1657 SMDS_ElemIteratorPtr anIt = aSMESHDS_Mesh->elementsIterator();
1658 while ( i < nbElements && anIt->more() ) {
1659 const SMDS_MeshElement* anElem = anIt->next();
1660 if ( theElemType == SMESH::ALL || anElem->GetType() == (SMDSAbs_ElementType)theElemType )
1661 aResult[i++] = anElem->GetID();
1664 aResult->length( i );
1666 return aResult._retn();
1669 //=============================================================================
1673 //=============================================================================
1675 SMESH::long_array* SMESH_Mesh_i::GetNodesId()
1676 throw (SALOME::SALOME_Exception)
1678 Unexpect aCatch(SALOME_SalomeException);
1679 MESSAGE("SMESH_subMesh_i::GetNodesId");
1680 SMESH::long_array_var aResult = new SMESH::long_array();
1681 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1683 if ( aSMESHDS_Mesh == NULL )
1684 return aResult._retn();
1686 long nbNodes = NbNodes();
1687 aResult->length( nbNodes );
1688 SMDS_NodeIteratorPtr anIt = aSMESHDS_Mesh->nodesIterator();
1689 for ( int i = 0, n = nbNodes; i < n && anIt->more(); i++ )
1690 aResult[i] = anIt->next()->GetID();
1692 return aResult._retn();
1695 //=============================================================================
1699 //=============================================================================
1701 SMESH::ElementType SMESH_Mesh_i::GetElementType( const CORBA::Long id, const bool iselem )
1702 throw (SALOME::SALOME_Exception)
1704 return ( SMESH::ElementType )_impl->GetElementType( id, iselem );
1708 //=============================================================================
1710 * Returns ID of elements for given submesh
1712 //=============================================================================
1713 SMESH::long_array* SMESH_Mesh_i::GetSubMeshElementsId(const CORBA::Long ShapeID)
1714 throw (SALOME::SALOME_Exception)
1716 SMESH::long_array_var aResult = new SMESH::long_array();
1718 SMESH_subMesh* SM = _impl->GetSubMeshContaining(ShapeID);
1719 if(!SM) return aResult._retn();
1721 SMESHDS_SubMesh* SDSM = SM->GetSubMeshDS();
1722 if(!SDSM) return aResult._retn();
1724 aResult->length(SDSM->NbElements());
1726 SMDS_ElemIteratorPtr eIt = SDSM->GetElements();
1728 while ( eIt->more() ) {
1729 aResult[i++] = eIt->next()->GetID();
1732 return aResult._retn();
1736 //=============================================================================
1738 * Returns ID of nodes for given submesh
1739 * If param all==true - returns all nodes, else -
1740 * returns only nodes on shapes.
1742 //=============================================================================
1743 SMESH::long_array* SMESH_Mesh_i::GetSubMeshNodesId(const CORBA::Long ShapeID, CORBA::Boolean all)
1744 throw (SALOME::SALOME_Exception)
1746 SMESH::long_array_var aResult = new SMESH::long_array();
1748 SMESH_subMesh* SM = _impl->GetSubMeshContaining(ShapeID);
1749 if(!SM) return aResult._retn();
1751 SMESHDS_SubMesh* SDSM = SM->GetSubMeshDS();
1752 if(!SDSM) return aResult._retn();
1754 map<int,const SMDS_MeshElement*> theElems;
1755 if( !all || (SDSM->NbElements()==0 && SDSM->NbNodes()==1) ) {
1756 SMDS_NodeIteratorPtr nIt = SDSM->GetNodes();
1757 while ( nIt->more() ) {
1758 const SMDS_MeshNode* elem = nIt->next();
1759 theElems.insert( make_pair(elem->GetID(),elem) );
1762 else { // all nodes of submesh elements
1763 SMDS_ElemIteratorPtr eIt = SDSM->GetElements();
1764 while ( eIt->more() ) {
1765 const SMDS_MeshElement* anElem = eIt->next();
1766 SMDS_ElemIteratorPtr nIt = anElem->nodesIterator();
1767 while ( nIt->more() ) {
1768 const SMDS_MeshElement* elem = nIt->next();
1769 theElems.insert( make_pair(elem->GetID(),elem) );
1774 aResult->length(theElems.size());
1775 map<int, const SMDS_MeshElement * >::iterator itElem;
1777 for ( itElem = theElems.begin(); itElem != theElems.end(); itElem++ )
1778 aResult[i++] = (*itElem).first;
1780 return aResult._retn();
1784 //=============================================================================
1786 * Returns type of elements for given submesh
1788 //=============================================================================
1789 SMESH::ElementType SMESH_Mesh_i::GetSubMeshElementType(const CORBA::Long ShapeID)
1790 throw (SALOME::SALOME_Exception)
1792 SMESH_subMesh* SM = _impl->GetSubMeshContaining(ShapeID);
1793 if(!SM) return SMESH::ALL;
1795 SMESHDS_SubMesh* SDSM = SM->GetSubMeshDS();
1796 if(!SDSM) return SMESH::ALL;
1798 if(SDSM->NbElements()==0)
1799 return (SM->GetSubShape().ShapeType() == TopAbs_VERTEX) ? SMESH::NODE : SMESH::ALL;
1801 SMDS_ElemIteratorPtr eIt = SDSM->GetElements();
1802 const SMDS_MeshElement* anElem = eIt->next();
1803 return ( SMESH::ElementType ) anElem->GetType();
1807 //=============================================================================
1811 //=============================================================================
1813 CORBA::Long SMESH_Mesh_i::GetMeshPtr()
1815 return CORBA::Long(size_t(_impl));
1819 //=============================================================================
1821 * Get XYZ coordinates of node as list of double
1822 * If there is not node for given ID - returns empty list
1824 //=============================================================================
1826 SMESH::double_array* SMESH_Mesh_i::GetNodeXYZ(const CORBA::Long id)
1828 SMESH::double_array_var aResult = new SMESH::double_array();
1829 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1830 if ( aSMESHDS_Mesh == NULL )
1831 return aResult._retn();
1834 const SMDS_MeshNode* aNode = aSMESHDS_Mesh->FindNode(id);
1836 return aResult._retn();
1840 aResult[0] = aNode->X();
1841 aResult[1] = aNode->Y();
1842 aResult[2] = aNode->Z();
1843 return aResult._retn();
1847 //=============================================================================
1849 * For given node returns list of IDs of inverse elements
1850 * If there is not node for given ID - returns empty list
1852 //=============================================================================
1854 SMESH::long_array* SMESH_Mesh_i::GetNodeInverseElements(const CORBA::Long id)
1856 SMESH::long_array_var aResult = new SMESH::long_array();
1857 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1858 if ( aSMESHDS_Mesh == NULL )
1859 return aResult._retn();
1862 const SMDS_MeshNode* aNode = aSMESHDS_Mesh->FindNode(id);
1864 return aResult._retn();
1866 // find inverse elements
1867 SMDS_ElemIteratorPtr eIt = aNode->GetInverseElementIterator();
1868 TColStd_SequenceOfInteger IDs;
1869 while(eIt->more()) {
1870 const SMDS_MeshElement* elem = eIt->next();
1871 IDs.Append(elem->GetID());
1873 if(IDs.Length()>0) {
1874 aResult->length(IDs.Length());
1876 for(; i<=IDs.Length(); i++) {
1877 aResult[i-1] = IDs.Value(i);
1880 return aResult._retn();
1884 //=============================================================================
1886 * If given element is node returns IDs of shape from position
1887 * If there is not node for given ID - returns -1
1889 //=============================================================================
1891 CORBA::Long SMESH_Mesh_i::GetShapeID(const CORBA::Long id)
1893 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1894 if ( aSMESHDS_Mesh == NULL )
1898 const SMDS_MeshNode* aNode = aSMESHDS_Mesh->FindNode(id);
1900 SMDS_PositionPtr pos = aNode->GetPosition();
1904 return pos->GetShapeId();
1911 //=============================================================================
1913 * For given element returns ID of result shape after
1914 * ::FindShape() from SMESH_MeshEditor
1915 * If there is not element for given ID - returns -1
1917 //=============================================================================
1919 CORBA::Long SMESH_Mesh_i::GetShapeIDForElem(const CORBA::Long id)
1921 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1922 if ( aSMESHDS_Mesh == NULL )
1925 // try to find element
1926 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
1930 //SMESH::SMESH_MeshEditor_var aMeshEditor = SMESH_Mesh_i::GetMeshEditor();
1931 ::SMESH_MeshEditor aMeshEditor(_impl);
1932 int index = aMeshEditor.FindShape( elem );
1940 //=============================================================================
1942 * Returns number of nodes for given element
1943 * If there is not element for given ID - returns -1
1945 //=============================================================================
1947 CORBA::Long SMESH_Mesh_i::GetElemNbNodes(const CORBA::Long id)
1949 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1950 if ( aSMESHDS_Mesh == NULL ) return -1;
1951 // try to find element
1952 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
1953 if(!elem) return -1;
1954 return elem->NbNodes();
1958 //=============================================================================
1960 * Returns ID of node by given index for given element
1961 * If there is not element for given ID - returns -1
1962 * If there is not node for given index - returns -2
1964 //=============================================================================
1966 CORBA::Long SMESH_Mesh_i::GetElemNode(const CORBA::Long id, const CORBA::Long index)
1968 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1969 if ( aSMESHDS_Mesh == NULL ) return -1;
1970 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
1971 if(!elem) return -1;
1972 if( index>=elem->NbNodes() || index<0 ) return -1;
1973 return elem->GetNode(index)->GetID();
1976 //=============================================================================
1978 * Returns IDs of nodes of given element
1980 //=============================================================================
1982 SMESH::long_array* SMESH_Mesh_i::GetElemNodes(const CORBA::Long id)
1984 SMESH::long_array_var aResult = new SMESH::long_array();
1985 if ( SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS() )
1987 if ( const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id) )
1989 aResult->length( elem->NbNodes() );
1990 for ( int i = 0; i < elem->NbNodes(); ++i )
1991 aResult[ i ] = elem->GetNode( i )->GetID();
1994 return aResult._retn();
1997 //=============================================================================
1999 * Returns true if given node is medium node
2000 * in given quadratic element
2002 //=============================================================================
2004 CORBA::Boolean SMESH_Mesh_i::IsMediumNode(const CORBA::Long ide, const CORBA::Long idn)
2006 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
2007 if ( aSMESHDS_Mesh == NULL ) return false;
2009 const SMDS_MeshNode* aNode = aSMESHDS_Mesh->FindNode(idn);
2010 if(!aNode) return false;
2011 // try to find element
2012 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(ide);
2013 if(!elem) return false;
2015 return elem->IsMediumNode(aNode);
2019 //=============================================================================
2021 * Returns true if given node is medium node
2022 * in one of quadratic elements
2024 //=============================================================================
2026 CORBA::Boolean SMESH_Mesh_i::IsMediumNodeOfAnyElem(const CORBA::Long idn,
2027 SMESH::ElementType theElemType)
2029 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
2030 if ( aSMESHDS_Mesh == NULL ) return false;
2033 const SMDS_MeshNode* aNode = aSMESHDS_Mesh->FindNode(idn);
2034 if(!aNode) return false;
2036 SMESH_MesherHelper aHelper( *(_impl) );
2038 SMDSAbs_ElementType aType;
2039 if(theElemType==SMESH::EDGE) aType = SMDSAbs_Edge;
2040 else if(theElemType==SMESH::FACE) aType = SMDSAbs_Face;
2041 else if(theElemType==SMESH::VOLUME) aType = SMDSAbs_Volume;
2042 else aType = SMDSAbs_All;
2044 return aHelper.IsMedium(aNode,aType);
2048 //=============================================================================
2050 * Returns number of edges for given element
2052 //=============================================================================
2054 CORBA::Long SMESH_Mesh_i::ElemNbEdges(const CORBA::Long id)
2056 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
2057 if ( aSMESHDS_Mesh == NULL ) return -1;
2058 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
2059 if(!elem) return -1;
2060 return elem->NbEdges();
2064 //=============================================================================
2066 * Returns number of faces for given element
2068 //=============================================================================
2070 CORBA::Long SMESH_Mesh_i::ElemNbFaces(const CORBA::Long id)
2072 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
2073 if ( aSMESHDS_Mesh == NULL ) return -1;
2074 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
2075 if(!elem) return -1;
2076 return elem->NbFaces();
2080 //=============================================================================
2082 * Returns true if given element is polygon
2084 //=============================================================================
2086 CORBA::Boolean SMESH_Mesh_i::IsPoly(const CORBA::Long id)
2088 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
2089 if ( aSMESHDS_Mesh == NULL ) return false;
2090 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
2091 if(!elem) return false;
2092 return elem->IsPoly();
2096 //=============================================================================
2098 * Returns true if given element is quadratic
2100 //=============================================================================
2102 CORBA::Boolean SMESH_Mesh_i::IsQuadratic(const CORBA::Long id)
2104 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
2105 if ( aSMESHDS_Mesh == NULL ) return false;
2106 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
2107 if(!elem) return false;
2108 return elem->IsQuadratic();
2112 //=============================================================================
2114 * Returns bary center for given element
2116 //=============================================================================
2118 SMESH::double_array* SMESH_Mesh_i::BaryCenter(const CORBA::Long id)
2120 SMESH::double_array_var aResult = new SMESH::double_array();
2121 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
2122 if ( aSMESHDS_Mesh == NULL )
2123 return aResult._retn();
2125 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
2127 return aResult._retn();
2129 if(elem->GetType()==SMDSAbs_Volume) {
2130 // use SMDS_VolumeTool
2131 SMDS_VolumeTool aTool;
2132 if(aTool.Set(elem)) {
2133 double x=0., y=0., z=0.;
2134 if(aTool.GetBaryCenter(x,y,z)) {
2144 SMDS_ElemIteratorPtr anIt = elem->nodesIterator();
2146 double x=0., y=0., z=0.;
2147 for(; anIt->more(); ) {
2149 const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>(anIt->next());
2163 return aResult._retn();
2167 //=============================================================================
2171 //=============================================================================
2172 void SMESH_Mesh_i::CreateGroupServants()
2174 // Create group servants, if any groups were imported
2175 list<int> aGroupIds = _impl->GetGroupIds();
2176 for ( list<int>::iterator it = aGroupIds.begin(); it != aGroupIds.end(); it++ ) {
2177 SMESH_Group_i* aGroupImpl = new SMESH_Group_i( SMESH_Gen_i::GetPOA(), this, *it );
2179 // PAL7962: san -- To ensure correct mapping of servant and correct reference counting in GenericObj_i
2180 SMESH_Gen_i::GetPOA()->activate_object( aGroupImpl );
2181 aGroupImpl->Register();
2182 // PAL7962: san -- To ensure correct mapping of servant and correct reference counting in GenericObj_i
2184 SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow( aGroupImpl->_this() );
2185 _mapGroups[*it] = SMESH::SMESH_Group::_duplicate( aGroup );
2187 // register CORBA object for persistence
2188 int nextId = _gen_i->RegisterObject( aGroup );
2189 if(MYDEBUG) MESSAGE( "Add group to map with id = "<< nextId);