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();
762 TPythonDump aPythonDump;
763 if ( !_mapGroups.empty() ) // (IMP13463) avoid "SyntaxError: can't assign to []"
767 aList->length( _mapGroups.size() );
769 map<int, SMESH::SMESH_GroupBase_ptr>::iterator it = _mapGroups.begin();
770 for ( ; it != _mapGroups.end(); it++ ) {
771 if ( CORBA::is_nil( it->second )) continue;
772 aList[i++] = SMESH::SMESH_GroupBase::_duplicate( it->second );
774 if (i > 1) aPythonDump << ", ";
775 aPythonDump << it->second;
779 catch(SALOME_Exception & S_ex) {
780 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
783 // Update Python script
784 if ( !_mapGroups.empty() ) // (IMP13463) avoid "SyntaxError: can't assign to []"
785 aPythonDump << " ] = " << _this() << ".GetGroups()";
787 return aList._retn();
790 //=============================================================================
792 * New group is created. All mesh elements that are
793 * present in initial groups are added to the new one
795 //=============================================================================
796 SMESH::SMESH_Group_ptr SMESH_Mesh_i::UnionGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
797 SMESH::SMESH_GroupBase_ptr theGroup2,
798 const char* theName )
799 throw (SALOME::SALOME_Exception)
803 if ( theGroup1->_is_nil() || theGroup2->_is_nil() ||
804 theGroup1->GetType() != theGroup2->GetType() )
805 return SMESH::SMESH_Group::_nil();
808 SMESH::SMESH_Group_var aResGrp = CreateGroup( theGroup1->GetType(), theName );
809 if ( aResGrp->_is_nil() )
810 return SMESH::SMESH_Group::_nil();
812 SMESH::long_array_var anIds1 = theGroup1->GetListOfID();
813 SMESH::long_array_var anIds2 = theGroup2->GetListOfID();
815 TColStd_MapOfInteger aResMap;
817 for ( int i1 = 0, n1 = anIds1->length(); i1 < n1; i1++ )
818 aResMap.Add( anIds1[ i1 ] );
820 for ( int i2 = 0, n2 = anIds2->length(); i2 < n2; i2++ )
821 aResMap.Add( anIds2[ i2 ] );
823 SMESH::long_array_var aResIds = new SMESH::long_array;
824 aResIds->length( aResMap.Extent() );
827 TColStd_MapIteratorOfMapOfInteger anIter( aResMap );
828 for( ; anIter.More(); anIter.Next() )
829 aResIds[ resI++ ] = anIter.Key();
831 aResGrp->Add( aResIds );
833 // Clear python lines, created by CreateGroup() and Add()
834 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
835 _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
836 _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
838 // Update Python script
839 TPythonDump() << aResGrp << " = " << _this() << ".UnionGroups( "
840 << theGroup1 << ", " << theGroup2 << ", '"
843 return aResGrp._retn();
847 return SMESH::SMESH_Group::_nil();
851 //=============================================================================
853 * New group is created. All mesh elements that are
854 * present in both initial groups are added to the new one.
856 //=============================================================================
857 SMESH::SMESH_Group_ptr SMESH_Mesh_i::IntersectGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
858 SMESH::SMESH_GroupBase_ptr theGroup2,
859 const char* theName )
860 throw (SALOME::SALOME_Exception)
862 if ( theGroup1->_is_nil() || theGroup2->_is_nil() ||
863 theGroup1->GetType() != theGroup2->GetType() )
864 return SMESH::SMESH_Group::_nil();
866 // Create Intersection
867 SMESH::SMESH_Group_var aResGrp = CreateGroup( theGroup1->GetType(), theName );
868 if ( aResGrp->_is_nil() )
871 SMESH::long_array_var anIds1 = theGroup1->GetListOfID();
872 SMESH::long_array_var anIds2 = theGroup2->GetListOfID();
874 TColStd_MapOfInteger aMap1;
876 for ( int i1 = 0, n1 = anIds1->length(); i1 < n1; i1++ )
877 aMap1.Add( anIds1[ i1 ] );
879 TColStd_SequenceOfInteger aSeq;
881 for ( int i2 = 0, n2 = anIds2->length(); i2 < n2; i2++ )
882 if ( aMap1.Contains( anIds2[ i2 ] ) )
883 aSeq.Append( anIds2[ i2 ] );
885 SMESH::long_array_var aResIds = new SMESH::long_array;
886 aResIds->length( aSeq.Length() );
888 for ( int resI = 0, resN = aSeq.Length(); resI < resN; resI++ )
889 aResIds[ resI ] = aSeq( resI + 1 );
891 aResGrp->Add( aResIds );
893 // Clear python lines, created by CreateGroup() and Add()
894 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
895 _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
896 _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
898 // Update Python script
899 TPythonDump() << aResGrp << " = " << _this() << ".IntersectGroups( "
900 << theGroup1 << ", " << theGroup2 << ", '" << theName << "')";
902 return aResGrp._retn();
905 //=============================================================================
907 * New group is created. All mesh elements that are present in
908 * main group but do not present in tool group are added to the new one
910 //=============================================================================
911 SMESH::SMESH_Group_ptr SMESH_Mesh_i::CutGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
912 SMESH::SMESH_GroupBase_ptr theGroup2,
913 const char* theName )
914 throw (SALOME::SALOME_Exception)
916 if ( theGroup1->_is_nil() || theGroup2->_is_nil() ||
917 theGroup1->GetType() != theGroup2->GetType() )
918 return SMESH::SMESH_Group::_nil();
921 SMESH::SMESH_Group_var aResGrp = CreateGroup( theGroup1->GetType(), theName );
922 if ( aResGrp->_is_nil() )
925 SMESH::long_array_var anIds1 = theGroup1->GetListOfID();
926 SMESH::long_array_var anIds2 = theGroup2->GetListOfID();
928 TColStd_MapOfInteger aMap2;
930 for ( int i2 = 0, n2 = anIds2->length(); i2 < n2; i2++ )
931 aMap2.Add( anIds2[ i2 ] );
934 TColStd_SequenceOfInteger aSeq;
935 for ( int i1 = 0, n1 = anIds1->length(); i1 < n1; i1++ )
936 if ( !aMap2.Contains( anIds1[ i1 ] ) )
937 aSeq.Append( anIds1[ i1 ] );
939 SMESH::long_array_var aResIds = new SMESH::long_array;
940 aResIds->length( aSeq.Length() );
942 for ( int resI = 0, resN = aSeq.Length(); resI < resN; resI++ )
943 aResIds[ resI ] = aSeq( resI + 1 );
945 aResGrp->Add( aResIds );
947 // Clear python lines, created by CreateGroup() and Add()
948 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
949 _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
950 _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
952 // Update Python script
953 TPythonDump() << aResGrp << " = " << _this() << ".CutGroups( "
954 << theGroup1 << ", " << theGroup2 << ", '"
957 return aResGrp._retn();
960 //=============================================================================
964 //=============================================================================
966 SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::createSubMesh( GEOM::GEOM_Object_ptr theSubShapeObject )
968 if(MYDEBUG) MESSAGE( "createSubMesh" );
969 TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape(theSubShapeObject);
971 ::SMESH_subMesh * mySubMesh = _impl->GetSubMesh(myLocSubShape);
972 int subMeshId = _impl->GetMeshDS()->ShapeToIndex( myLocSubShape );
973 SMESH_subMesh_i *subMeshServant = new SMESH_subMesh_i(myPOA, _gen_i, this, subMeshId);
974 SMESH::SMESH_subMesh_var subMesh
975 = SMESH::SMESH_subMesh::_narrow(subMeshServant->_this());
977 _mapSubMesh[subMeshId] = mySubMesh;
978 _mapSubMesh_i[subMeshId] = subMeshServant;
979 _mapSubMeshIor[subMeshId] = SMESH::SMESH_subMesh::_duplicate(subMesh);
981 // register CORBA object for persistence
982 int nextId = _gen_i->RegisterObject( subMesh );
983 if(MYDEBUG) MESSAGE( "Add submesh to map with id = "<< nextId);
985 return subMesh._retn();
988 //=======================================================================
989 //function : getSubMesh
991 //=======================================================================
993 SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::getSubMesh(int shapeID)
995 map<int, SMESH::SMESH_subMesh_ptr>::iterator it = _mapSubMeshIor.find( shapeID );
996 if ( it == _mapSubMeshIor.end() )
997 return SMESH::SMESH_subMesh::_nil();
999 return SMESH::SMESH_subMesh::_duplicate( (*it).second );
1003 //=============================================================================
1007 //=============================================================================
1009 void SMESH_Mesh_i::removeSubMesh (SMESH::SMESH_subMesh_ptr theSubMesh,
1010 GEOM::GEOM_Object_ptr theSubShapeObject )
1012 MESSAGE("SMESH_Mesh_i::removeSubMesh()");
1013 if ( theSubMesh->_is_nil() || theSubShapeObject->_is_nil() )
1017 SMESH::ListOfHypothesis_var aHypList = GetHypothesisList( theSubShapeObject );
1018 for ( int i = 0, n = aHypList->length(); i < n; i++ ) {
1019 removeHypothesis( theSubShapeObject, aHypList[i] );
1022 catch( const SALOME::SALOME_Exception& ) {
1023 INFOS("SMESH_Mesh_i::removeSubMesh(): exception caught!");
1026 int subMeshId = theSubMesh->GetId();
1028 _mapSubMesh.erase(subMeshId);
1029 _mapSubMesh_i.erase(subMeshId);
1030 _mapSubMeshIor.erase(subMeshId);
1031 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::removeSubMesh() completed");
1034 //=============================================================================
1038 //=============================================================================
1040 SMESH::SMESH_GroupBase_ptr SMESH_Mesh_i::createGroup (SMESH::ElementType theElemType,
1041 const char* theName,
1042 const TopoDS_Shape& theShape )
1045 SMESH::SMESH_GroupBase_var aGroup;
1046 if ( _impl->AddGroup( (SMDSAbs_ElementType)theElemType, theName, anId, theShape )) {
1047 SMESH_GroupBase_i* aGroupImpl;
1048 if ( !theShape.IsNull() )
1049 aGroupImpl = new SMESH_GroupOnGeom_i( SMESH_Gen_i::GetPOA(), this, anId );
1051 aGroupImpl = new SMESH_Group_i( SMESH_Gen_i::GetPOA(), this, anId );
1053 // PAL7962: san -- To ensure correct mapping of servant and correct reference counting in GenericObj_i
1054 SMESH_Gen_i::GetPOA()->activate_object( aGroupImpl );
1055 aGroupImpl->Register();
1056 // PAL7962: san -- To ensure correct mapping of servant and correct reference counting in GenericObj_i
1058 aGroup = SMESH::SMESH_GroupBase::_narrow( aGroupImpl->_this() );
1059 _mapGroups[anId] = SMESH::SMESH_GroupBase::_duplicate( aGroup );
1061 // register CORBA object for persistence
1062 int nextId = _gen_i->RegisterObject( aGroup );
1063 if(MYDEBUG) MESSAGE( "Add group to map with id = "<< nextId);
1065 return aGroup._retn();
1068 //=============================================================================
1070 * SMESH_Mesh_i::removeGroup
1072 * Should be called by ~SMESH_Group_i()
1074 //=============================================================================
1076 void SMESH_Mesh_i::removeGroup( const int theId )
1078 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::removeGroup()" );
1079 if ( _mapGroups.find( theId ) != _mapGroups.end() ) {
1080 _mapGroups.erase( theId );
1081 _impl->RemoveGroup( theId );
1086 //=============================================================================
1090 //=============================================================================
1092 SMESH::log_array * SMESH_Mesh_i::GetLog(CORBA::Boolean clearAfterGet)
1093 throw(SALOME::SALOME_Exception)
1095 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::GetLog");
1097 SMESH::log_array_var aLog;
1099 list < SMESHDS_Command * >logDS = _impl->GetLog();
1100 aLog = new SMESH::log_array;
1102 int lg = logDS.size();
1105 list < SMESHDS_Command * >::iterator its = logDS.begin();
1106 while(its != logDS.end()){
1107 SMESHDS_Command *com = *its;
1108 int comType = com->GetType();
1110 int lgcom = com->GetNumber();
1112 const list < int >&intList = com->GetIndexes();
1113 int inum = intList.size();
1115 list < int >::const_iterator ii = intList.begin();
1116 const list < double >&coordList = com->GetCoords();
1117 int rnum = coordList.size();
1119 list < double >::const_iterator ir = coordList.begin();
1120 aLog[indexLog].commandType = comType;
1121 aLog[indexLog].number = lgcom;
1122 aLog[indexLog].coords.length(rnum);
1123 aLog[indexLog].indexes.length(inum);
1124 for(int i = 0; i < rnum; i++){
1125 aLog[indexLog].coords[i] = *ir;
1126 //MESSAGE(" "<<i<<" "<<ir.Value());
1129 for(int i = 0; i < inum; i++){
1130 aLog[indexLog].indexes[i] = *ii;
1131 //MESSAGE(" "<<i<<" "<<ii.Value());
1140 catch(SALOME_Exception & S_ex){
1141 THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
1143 return aLog._retn();
1147 //=============================================================================
1151 //=============================================================================
1153 void SMESH_Mesh_i::ClearLog() throw(SALOME::SALOME_Exception)
1155 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::ClearLog");
1159 //=============================================================================
1163 //=============================================================================
1165 CORBA::Long SMESH_Mesh_i::GetId()throw(SALOME::SALOME_Exception)
1167 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::GetId");
1171 //=============================================================================
1175 //=============================================================================
1177 CORBA::Long SMESH_Mesh_i::GetStudyId()throw(SALOME::SALOME_Exception)
1182 //=============================================================================
1186 //=============================================================================
1188 void SMESH_Mesh_i::SetImpl(::SMESH_Mesh * impl)
1190 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::SetImpl");
1194 //=============================================================================
1198 //=============================================================================
1200 ::SMESH_Mesh & SMESH_Mesh_i::GetImpl()
1202 if(MYDEBUG) MESSAGE("SMESH_Mesh_i::GetImpl()");
1206 //=============================================================================
1208 * Return mesh editor
1210 //=============================================================================
1212 SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditor()
1214 // Create MeshEditor
1215 SMESH_MeshEditor_i *aMeshEditor = new SMESH_MeshEditor_i( _impl, false );
1216 SMESH::SMESH_MeshEditor_var aMesh = aMeshEditor->_this();
1218 // Update Python script
1219 TPythonDump() << aMeshEditor << " = " << _this() << ".GetMeshEditor()";
1221 return aMesh._retn();
1224 //=============================================================================
1226 * Return mesh edition previewer
1228 //=============================================================================
1230 SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditPreviewer()
1232 SMESH_MeshEditor_i *aMeshEditor = new SMESH_MeshEditor_i( _impl, true );
1233 SMESH::SMESH_MeshEditor_var aMesh = aMeshEditor->_this();
1234 return aMesh._retn();
1237 //=============================================================================
1239 * Export in different formats
1241 //=============================================================================
1243 CORBA::Boolean SMESH_Mesh_i::HasDuplicatedGroupNamesMED()
1245 return _impl->HasDuplicatedGroupNamesMED();
1248 static void PrepareForWriting (const char* file)
1250 TCollection_AsciiString aFullName ((char*)file);
1251 OSD_Path aPath (aFullName);
1252 OSD_File aFile (aPath);
1253 if (aFile.Exists()) {
1254 // existing filesystem node
1255 if (aFile.KindOfFile() == OSD_FILE) {
1256 if (aFile.IsWriteable()) {
1259 if (aFile.Failed()) {
1260 TCollection_AsciiString msg ("File ");
1261 msg += aFullName + " cannot be replaced.";
1262 THROW_SALOME_CORBA_EXCEPTION(msg.ToCString(), SALOME::BAD_PARAM);
1265 TCollection_AsciiString msg ("File ");
1266 msg += aFullName + " cannot be overwritten.";
1267 THROW_SALOME_CORBA_EXCEPTION(msg.ToCString(), SALOME::BAD_PARAM);
1270 TCollection_AsciiString msg ("Location ");
1271 msg += aFullName + " is not a file.";
1272 THROW_SALOME_CORBA_EXCEPTION(msg.ToCString(), SALOME::BAD_PARAM);
1275 // nonexisting file; check if it can be created
1277 aFile.Build(OSD_WriteOnly, OSD_Protection());
1278 if (aFile.Failed()) {
1279 TCollection_AsciiString msg ("You cannot create the file ");
1280 msg += aFullName + ". Check the directory existance and access rights.";
1281 THROW_SALOME_CORBA_EXCEPTION(msg.ToCString(), SALOME::BAD_PARAM);
1289 void SMESH_Mesh_i::ExportToMED (const char* file,
1290 CORBA::Boolean auto_groups,
1291 SMESH::MED_VERSION theVersion)
1292 throw(SALOME::SALOME_Exception)
1294 Unexpect aCatch(SALOME_SalomeException);
1296 // Update Python script
1297 TPythonDump() << _this() << ".ExportToMED( '"
1298 << file << "', " << auto_groups << ", " << theVersion << " )";
1301 PrepareForWriting(file);
1302 char* aMeshName = "Mesh";
1303 SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
1304 if ( !aStudy->_is_nil() ) {
1305 SALOMEDS::SObject_var aMeshSO = _gen_i->ObjectToSObject( aStudy, _this() );
1306 if ( !aMeshSO->_is_nil() ) {
1307 aMeshName = aMeshSO->GetName();
1309 //SCRUTE(aMeshName);
1310 //SCRUTE(aMeshSO->GetID());
1312 // asv : 27.10.04 : fix of 6903: check for StudyLocked before adding attributes
1313 if ( !aStudy->GetProperties()->IsLocked() )
1315 SALOMEDS::GenericAttribute_var anAttr;
1316 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
1317 SALOMEDS::AttributeExternalFileDef_var aFileName;
1318 anAttr=aStudyBuilder->FindOrCreateAttribute(aMeshSO, "AttributeExternalFileDef");
1319 aFileName = SALOMEDS::AttributeExternalFileDef::_narrow(anAttr);
1320 ASSERT(!aFileName->_is_nil());
1321 aFileName->SetValue(file);
1322 SALOMEDS::AttributeFileType_var aFileType;
1323 anAttr=aStudyBuilder->FindOrCreateAttribute(aMeshSO, "AttributeFileType");
1324 aFileType = SALOMEDS::AttributeFileType::_narrow(anAttr);
1325 ASSERT(!aFileType->_is_nil());
1326 aFileType->SetValue("FICHIERMED");
1330 _impl->ExportMED( file, aMeshName, auto_groups, theVersion );
1333 void SMESH_Mesh_i::ExportMED (const char* file,
1334 CORBA::Boolean auto_groups)
1335 throw(SALOME::SALOME_Exception)
1337 ExportToMED(file,auto_groups,SMESH::MED_V2_1);
1340 void SMESH_Mesh_i::ExportDAT (const char *file)
1341 throw(SALOME::SALOME_Exception)
1343 Unexpect aCatch(SALOME_SalomeException);
1345 // Update Python script
1346 TPythonDump() << _this() << ".ExportDAT( '" << file << "' )";
1349 PrepareForWriting(file);
1350 _impl->ExportDAT(file);
1353 void SMESH_Mesh_i::ExportUNV (const char *file)
1354 throw(SALOME::SALOME_Exception)
1356 Unexpect aCatch(SALOME_SalomeException);
1358 // Update Python script
1359 TPythonDump() << _this() << ".ExportUNV( '" << file << "' )";
1362 PrepareForWriting(file);
1363 _impl->ExportUNV(file);
1366 void SMESH_Mesh_i::ExportSTL (const char *file, const bool isascii)
1367 throw(SALOME::SALOME_Exception)
1369 Unexpect aCatch(SALOME_SalomeException);
1371 // Update Python script
1372 TPythonDump() << _this() << ".ExportSTL( '" << file << "', " << isascii << " )";
1375 PrepareForWriting(file);
1376 _impl->ExportSTL(file, isascii);
1379 //=============================================================================
1383 //=============================================================================
1385 SALOME_MED::MESH_ptr SMESH_Mesh_i::GetMEDMesh()throw(SALOME::SALOME_Exception)
1387 Unexpect aCatch(SALOME_SalomeException);
1388 SMESH_MEDMesh_i *aMedMesh = new SMESH_MEDMesh_i(this);
1389 SALOME_MED::MESH_var aMesh = aMedMesh->_this();
1390 return aMesh._retn();
1393 //=============================================================================
1397 //=============================================================================
1398 CORBA::Long SMESH_Mesh_i::NbNodes()throw(SALOME::SALOME_Exception)
1400 Unexpect aCatch(SALOME_SalomeException);
1401 return _impl->NbNodes();
1404 //=============================================================================
1408 //=============================================================================
1409 CORBA::Long SMESH_Mesh_i::NbElements()throw (SALOME::SALOME_Exception)
1411 Unexpect aCatch(SALOME_SalomeException);
1412 return NbEdges() + NbFaces() + NbVolumes();
1415 //=============================================================================
1419 //=============================================================================
1420 CORBA::Long SMESH_Mesh_i::NbEdges()throw(SALOME::SALOME_Exception)
1422 Unexpect aCatch(SALOME_SalomeException);
1423 return _impl->NbEdges();
1426 CORBA::Long SMESH_Mesh_i::NbEdgesOfOrder(SMESH::ElementOrder order)
1427 throw(SALOME::SALOME_Exception)
1429 Unexpect aCatch(SALOME_SalomeException);
1430 return _impl->NbEdges( (::SMESH_Mesh::ElementOrder) order);
1433 //=============================================================================
1437 //=============================================================================
1438 CORBA::Long SMESH_Mesh_i::NbFaces()throw(SALOME::SALOME_Exception)
1440 Unexpect aCatch(SALOME_SalomeException);
1441 return _impl->NbFaces();
1444 CORBA::Long SMESH_Mesh_i::NbTriangles()throw(SALOME::SALOME_Exception)
1446 Unexpect aCatch(SALOME_SalomeException);
1447 return _impl->NbTriangles();
1450 CORBA::Long SMESH_Mesh_i::NbQuadrangles()throw(SALOME::SALOME_Exception)
1452 Unexpect aCatch(SALOME_SalomeException);
1453 return _impl->NbQuadrangles();
1456 CORBA::Long SMESH_Mesh_i::NbPolygons()throw(SALOME::SALOME_Exception)
1458 Unexpect aCatch(SALOME_SalomeException);
1459 return _impl->NbPolygons();
1462 CORBA::Long SMESH_Mesh_i::NbFacesOfOrder(SMESH::ElementOrder order)
1463 throw(SALOME::SALOME_Exception)
1465 Unexpect aCatch(SALOME_SalomeException);
1466 return _impl->NbFaces( (::SMESH_Mesh::ElementOrder) order);
1469 CORBA::Long SMESH_Mesh_i::NbTrianglesOfOrder(SMESH::ElementOrder order)
1470 throw(SALOME::SALOME_Exception)
1472 Unexpect aCatch(SALOME_SalomeException);
1473 return _impl->NbTriangles( (::SMESH_Mesh::ElementOrder) order);
1476 CORBA::Long SMESH_Mesh_i::NbQuadranglesOfOrder(SMESH::ElementOrder order)
1477 throw(SALOME::SALOME_Exception)
1479 Unexpect aCatch(SALOME_SalomeException);
1480 return _impl->NbQuadrangles( (::SMESH_Mesh::ElementOrder) order);
1483 //=============================================================================
1487 //=============================================================================
1488 CORBA::Long SMESH_Mesh_i::NbVolumes()throw(SALOME::SALOME_Exception)
1490 Unexpect aCatch(SALOME_SalomeException);
1491 return _impl->NbVolumes();
1494 CORBA::Long SMESH_Mesh_i::NbTetras()throw(SALOME::SALOME_Exception)
1496 Unexpect aCatch(SALOME_SalomeException);
1497 return _impl->NbTetras();
1500 CORBA::Long SMESH_Mesh_i::NbHexas()throw(SALOME::SALOME_Exception)
1502 Unexpect aCatch(SALOME_SalomeException);
1503 return _impl->NbHexas();
1506 CORBA::Long SMESH_Mesh_i::NbPyramids()throw(SALOME::SALOME_Exception)
1508 Unexpect aCatch(SALOME_SalomeException);
1509 return _impl->NbPyramids();
1512 CORBA::Long SMESH_Mesh_i::NbPrisms()throw(SALOME::SALOME_Exception)
1514 Unexpect aCatch(SALOME_SalomeException);
1515 return _impl->NbPrisms();
1518 CORBA::Long SMESH_Mesh_i::NbPolyhedrons()throw(SALOME::SALOME_Exception)
1520 Unexpect aCatch(SALOME_SalomeException);
1521 return _impl->NbPolyhedrons();
1524 CORBA::Long SMESH_Mesh_i::NbVolumesOfOrder(SMESH::ElementOrder order)
1525 throw(SALOME::SALOME_Exception)
1527 Unexpect aCatch(SALOME_SalomeException);
1528 return _impl->NbVolumes( (::SMESH_Mesh::ElementOrder) order);
1531 CORBA::Long SMESH_Mesh_i::NbTetrasOfOrder(SMESH::ElementOrder order)
1532 throw(SALOME::SALOME_Exception)
1534 Unexpect aCatch(SALOME_SalomeException);
1535 return _impl->NbTetras( (::SMESH_Mesh::ElementOrder) order);
1538 CORBA::Long SMESH_Mesh_i::NbHexasOfOrder(SMESH::ElementOrder order)
1539 throw(SALOME::SALOME_Exception)
1541 Unexpect aCatch(SALOME_SalomeException);
1542 return _impl->NbHexas( (::SMESH_Mesh::ElementOrder) order);
1545 CORBA::Long SMESH_Mesh_i::NbPyramidsOfOrder(SMESH::ElementOrder order)
1546 throw(SALOME::SALOME_Exception)
1548 Unexpect aCatch(SALOME_SalomeException);
1549 return _impl->NbPyramids( (::SMESH_Mesh::ElementOrder) order);
1552 CORBA::Long SMESH_Mesh_i::NbPrismsOfOrder(SMESH::ElementOrder order)
1553 throw(SALOME::SALOME_Exception)
1555 Unexpect aCatch(SALOME_SalomeException);
1556 return _impl->NbPrisms( (::SMESH_Mesh::ElementOrder) order);
1559 //=============================================================================
1563 //=============================================================================
1564 CORBA::Long SMESH_Mesh_i::NbSubMesh()throw(SALOME::SALOME_Exception)
1566 Unexpect aCatch(SALOME_SalomeException);
1567 return _impl->NbSubMesh();
1570 //=============================================================================
1574 //=============================================================================
1575 char* SMESH_Mesh_i::Dump()
1577 std::ostringstream os;
1579 return CORBA::string_dup( os.str().c_str() );
1582 //=============================================================================
1586 //=============================================================================
1587 SMESH::long_array* SMESH_Mesh_i::GetIDs()
1589 // SMESH::long_array_var aResult = new SMESH::long_array();
1590 // SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1591 // int aMinId = aSMESHDS_Mesh->MinElementID();
1592 // int aMaxId = aSMESHDS_Mesh->MaxElementID();
1594 // aResult->length(aMaxId - aMinId + 1);
1596 // for (int i = 0, id = aMinId; id <= aMaxId; id++ )
1597 // aResult[i++] = id;
1599 // return aResult._retn();
1601 return GetElementsId();
1604 //=============================================================================
1608 //=============================================================================
1610 SMESH::long_array* SMESH_Mesh_i::GetElementsId()
1611 throw (SALOME::SALOME_Exception)
1613 Unexpect aCatch(SALOME_SalomeException);
1614 MESSAGE("SMESH_Mesh_i::GetElementsId");
1615 SMESH::long_array_var aResult = new SMESH::long_array();
1616 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1618 if ( aSMESHDS_Mesh == NULL )
1619 return aResult._retn();
1621 long nbElements = NbElements();
1622 aResult->length( nbElements );
1623 SMDS_ElemIteratorPtr anIt = aSMESHDS_Mesh->elementsIterator();
1624 for ( int i = 0, n = nbElements; i < n && anIt->more(); i++ )
1625 aResult[i] = anIt->next()->GetID();
1627 return aResult._retn();
1631 //=============================================================================
1635 //=============================================================================
1637 SMESH::long_array* SMESH_Mesh_i::GetElementsByType( SMESH::ElementType theElemType )
1638 throw (SALOME::SALOME_Exception)
1640 Unexpect aCatch(SALOME_SalomeException);
1641 MESSAGE("SMESH_subMesh_i::GetElementsByType");
1642 SMESH::long_array_var aResult = new SMESH::long_array();
1643 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1645 if ( aSMESHDS_Mesh == NULL )
1646 return aResult._retn();
1648 long nbElements = NbElements();
1650 // No sense in returning ids of elements along with ids of nodes:
1651 // when theElemType == SMESH::ALL, return node ids only if
1652 // there are no elements
1653 if ( theElemType == SMESH::NODE || theElemType == SMESH::ALL && nbElements == 0 )
1654 return GetNodesId();
1656 aResult->length( nbElements );
1660 SMDS_ElemIteratorPtr anIt = aSMESHDS_Mesh->elementsIterator();
1661 while ( i < nbElements && anIt->more() ) {
1662 const SMDS_MeshElement* anElem = anIt->next();
1663 if ( theElemType == SMESH::ALL || anElem->GetType() == (SMDSAbs_ElementType)theElemType )
1664 aResult[i++] = anElem->GetID();
1667 aResult->length( i );
1669 return aResult._retn();
1672 //=============================================================================
1676 //=============================================================================
1678 SMESH::long_array* SMESH_Mesh_i::GetNodesId()
1679 throw (SALOME::SALOME_Exception)
1681 Unexpect aCatch(SALOME_SalomeException);
1682 MESSAGE("SMESH_subMesh_i::GetNodesId");
1683 SMESH::long_array_var aResult = new SMESH::long_array();
1684 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1686 if ( aSMESHDS_Mesh == NULL )
1687 return aResult._retn();
1689 long nbNodes = NbNodes();
1690 aResult->length( nbNodes );
1691 SMDS_NodeIteratorPtr anIt = aSMESHDS_Mesh->nodesIterator();
1692 for ( int i = 0, n = nbNodes; i < n && anIt->more(); i++ )
1693 aResult[i] = anIt->next()->GetID();
1695 return aResult._retn();
1698 //=============================================================================
1702 //=============================================================================
1704 SMESH::ElementType SMESH_Mesh_i::GetElementType( const CORBA::Long id, const bool iselem )
1705 throw (SALOME::SALOME_Exception)
1707 return ( SMESH::ElementType )_impl->GetElementType( id, iselem );
1711 //=============================================================================
1713 * Returns ID of elements for given submesh
1715 //=============================================================================
1716 SMESH::long_array* SMESH_Mesh_i::GetSubMeshElementsId(const CORBA::Long ShapeID)
1717 throw (SALOME::SALOME_Exception)
1719 SMESH::long_array_var aResult = new SMESH::long_array();
1721 SMESH_subMesh* SM = _impl->GetSubMeshContaining(ShapeID);
1722 if(!SM) return aResult._retn();
1724 SMESHDS_SubMesh* SDSM = SM->GetSubMeshDS();
1725 if(!SDSM) return aResult._retn();
1727 aResult->length(SDSM->NbElements());
1729 SMDS_ElemIteratorPtr eIt = SDSM->GetElements();
1731 while ( eIt->more() ) {
1732 aResult[i++] = eIt->next()->GetID();
1735 return aResult._retn();
1739 //=============================================================================
1741 * Returns ID of nodes for given submesh
1742 * If param all==true - returns all nodes, else -
1743 * returns only nodes on shapes.
1745 //=============================================================================
1746 SMESH::long_array* SMESH_Mesh_i::GetSubMeshNodesId(const CORBA::Long ShapeID, CORBA::Boolean all)
1747 throw (SALOME::SALOME_Exception)
1749 SMESH::long_array_var aResult = new SMESH::long_array();
1751 SMESH_subMesh* SM = _impl->GetSubMeshContaining(ShapeID);
1752 if(!SM) return aResult._retn();
1754 SMESHDS_SubMesh* SDSM = SM->GetSubMeshDS();
1755 if(!SDSM) return aResult._retn();
1757 map<int,const SMDS_MeshElement*> theElems;
1758 if( !all || (SDSM->NbElements()==0 && SDSM->NbNodes()==1) ) {
1759 SMDS_NodeIteratorPtr nIt = SDSM->GetNodes();
1760 while ( nIt->more() ) {
1761 const SMDS_MeshNode* elem = nIt->next();
1762 theElems.insert( make_pair(elem->GetID(),elem) );
1765 else { // all nodes of submesh elements
1766 SMDS_ElemIteratorPtr eIt = SDSM->GetElements();
1767 while ( eIt->more() ) {
1768 const SMDS_MeshElement* anElem = eIt->next();
1769 SMDS_ElemIteratorPtr nIt = anElem->nodesIterator();
1770 while ( nIt->more() ) {
1771 const SMDS_MeshElement* elem = nIt->next();
1772 theElems.insert( make_pair(elem->GetID(),elem) );
1777 aResult->length(theElems.size());
1778 map<int, const SMDS_MeshElement * >::iterator itElem;
1780 for ( itElem = theElems.begin(); itElem != theElems.end(); itElem++ )
1781 aResult[i++] = (*itElem).first;
1783 return aResult._retn();
1787 //=============================================================================
1789 * Returns type of elements for given submesh
1791 //=============================================================================
1792 SMESH::ElementType SMESH_Mesh_i::GetSubMeshElementType(const CORBA::Long ShapeID)
1793 throw (SALOME::SALOME_Exception)
1795 SMESH_subMesh* SM = _impl->GetSubMeshContaining(ShapeID);
1796 if(!SM) return SMESH::ALL;
1798 SMESHDS_SubMesh* SDSM = SM->GetSubMeshDS();
1799 if(!SDSM) return SMESH::ALL;
1801 if(SDSM->NbElements()==0)
1802 return (SM->GetSubShape().ShapeType() == TopAbs_VERTEX) ? SMESH::NODE : SMESH::ALL;
1804 SMDS_ElemIteratorPtr eIt = SDSM->GetElements();
1805 const SMDS_MeshElement* anElem = eIt->next();
1806 return ( SMESH::ElementType ) anElem->GetType();
1810 //=============================================================================
1814 //=============================================================================
1816 CORBA::LongLong SMESH_Mesh_i::GetMeshPtr()
1818 CORBA::LongLong pointeur = CORBA::LongLong(_impl);
1819 cerr << "CORBA::LongLong SMESH_Mesh_i::GetMeshPtr() " << pointeur << endl;
1824 //=============================================================================
1826 * Get XYZ coordinates of node as list of double
1827 * If there is not node for given ID - returns empty list
1829 //=============================================================================
1831 SMESH::double_array* SMESH_Mesh_i::GetNodeXYZ(const CORBA::Long id)
1833 SMESH::double_array_var aResult = new SMESH::double_array();
1834 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1835 if ( aSMESHDS_Mesh == NULL )
1836 return aResult._retn();
1839 const SMDS_MeshNode* aNode = aSMESHDS_Mesh->FindNode(id);
1841 return aResult._retn();
1845 aResult[0] = aNode->X();
1846 aResult[1] = aNode->Y();
1847 aResult[2] = aNode->Z();
1848 return aResult._retn();
1852 //=============================================================================
1854 * For given node returns list of IDs of inverse elements
1855 * If there is not node for given ID - returns empty list
1857 //=============================================================================
1859 SMESH::long_array* SMESH_Mesh_i::GetNodeInverseElements(const CORBA::Long id)
1861 SMESH::long_array_var aResult = new SMESH::long_array();
1862 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1863 if ( aSMESHDS_Mesh == NULL )
1864 return aResult._retn();
1867 const SMDS_MeshNode* aNode = aSMESHDS_Mesh->FindNode(id);
1869 return aResult._retn();
1871 // find inverse elements
1872 SMDS_ElemIteratorPtr eIt = aNode->GetInverseElementIterator();
1873 TColStd_SequenceOfInteger IDs;
1874 while(eIt->more()) {
1875 const SMDS_MeshElement* elem = eIt->next();
1876 IDs.Append(elem->GetID());
1878 if(IDs.Length()>0) {
1879 aResult->length(IDs.Length());
1881 for(; i<=IDs.Length(); i++) {
1882 aResult[i-1] = IDs.Value(i);
1885 return aResult._retn();
1889 //=============================================================================
1891 * If given element is node returns IDs of shape from position
1892 * If there is not node for given ID - returns -1
1894 //=============================================================================
1896 CORBA::Long SMESH_Mesh_i::GetShapeID(const CORBA::Long id)
1898 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1899 if ( aSMESHDS_Mesh == NULL )
1903 const SMDS_MeshNode* aNode = aSMESHDS_Mesh->FindNode(id);
1905 SMDS_PositionPtr pos = aNode->GetPosition();
1909 return pos->GetShapeId();
1916 //=============================================================================
1918 * For given element returns ID of result shape after
1919 * ::FindShape() from SMESH_MeshEditor
1920 * If there is not element for given ID - returns -1
1922 //=============================================================================
1924 CORBA::Long SMESH_Mesh_i::GetShapeIDForElem(const CORBA::Long id)
1926 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1927 if ( aSMESHDS_Mesh == NULL )
1930 // try to find element
1931 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
1935 //SMESH::SMESH_MeshEditor_var aMeshEditor = SMESH_Mesh_i::GetMeshEditor();
1936 ::SMESH_MeshEditor aMeshEditor(_impl);
1937 int index = aMeshEditor.FindShape( elem );
1945 //=============================================================================
1947 * Returns number of nodes for given element
1948 * If there is not element for given ID - returns -1
1950 //=============================================================================
1952 CORBA::Long SMESH_Mesh_i::GetElemNbNodes(const CORBA::Long id)
1954 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1955 if ( aSMESHDS_Mesh == NULL ) return -1;
1956 // try to find element
1957 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
1958 if(!elem) return -1;
1959 return elem->NbNodes();
1963 //=============================================================================
1965 * Returns ID of node by given index for given element
1966 * If there is not element for given ID - returns -1
1967 * If there is not node for given index - returns -2
1969 //=============================================================================
1971 CORBA::Long SMESH_Mesh_i::GetElemNode(const CORBA::Long id, const CORBA::Long index)
1973 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1974 if ( aSMESHDS_Mesh == NULL ) return -1;
1975 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
1976 if(!elem) return -1;
1977 if( index>=elem->NbNodes() || index<0 ) return -1;
1978 return elem->GetNode(index)->GetID();
1981 //=============================================================================
1983 * Returns IDs of nodes of given element
1985 //=============================================================================
1987 SMESH::long_array* SMESH_Mesh_i::GetElemNodes(const CORBA::Long id)
1989 SMESH::long_array_var aResult = new SMESH::long_array();
1990 if ( SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS() )
1992 if ( const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id) )
1994 aResult->length( elem->NbNodes() );
1995 for ( int i = 0; i < elem->NbNodes(); ++i )
1996 aResult[ i ] = elem->GetNode( i )->GetID();
1999 return aResult._retn();
2002 //=============================================================================
2004 * Returns true if given node is medium node
2005 * in given quadratic element
2007 //=============================================================================
2009 CORBA::Boolean SMESH_Mesh_i::IsMediumNode(const CORBA::Long ide, const CORBA::Long idn)
2011 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
2012 if ( aSMESHDS_Mesh == NULL ) return false;
2014 const SMDS_MeshNode* aNode = aSMESHDS_Mesh->FindNode(idn);
2015 if(!aNode) return false;
2016 // try to find element
2017 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(ide);
2018 if(!elem) return false;
2020 return elem->IsMediumNode(aNode);
2024 //=============================================================================
2026 * Returns true if given node is medium node
2027 * in one of quadratic elements
2029 //=============================================================================
2031 CORBA::Boolean SMESH_Mesh_i::IsMediumNodeOfAnyElem(const CORBA::Long idn,
2032 SMESH::ElementType theElemType)
2034 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
2035 if ( aSMESHDS_Mesh == NULL ) return false;
2038 const SMDS_MeshNode* aNode = aSMESHDS_Mesh->FindNode(idn);
2039 if(!aNode) return false;
2041 SMESH_MesherHelper aHelper( *(_impl) );
2043 SMDSAbs_ElementType aType;
2044 if(theElemType==SMESH::EDGE) aType = SMDSAbs_Edge;
2045 else if(theElemType==SMESH::FACE) aType = SMDSAbs_Face;
2046 else if(theElemType==SMESH::VOLUME) aType = SMDSAbs_Volume;
2047 else aType = SMDSAbs_All;
2049 return aHelper.IsMedium(aNode,aType);
2053 //=============================================================================
2055 * Returns number of edges for given element
2057 //=============================================================================
2059 CORBA::Long SMESH_Mesh_i::ElemNbEdges(const CORBA::Long id)
2061 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
2062 if ( aSMESHDS_Mesh == NULL ) return -1;
2063 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
2064 if(!elem) return -1;
2065 return elem->NbEdges();
2069 //=============================================================================
2071 * Returns number of faces for given element
2073 //=============================================================================
2075 CORBA::Long SMESH_Mesh_i::ElemNbFaces(const CORBA::Long id)
2077 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
2078 if ( aSMESHDS_Mesh == NULL ) return -1;
2079 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
2080 if(!elem) return -1;
2081 return elem->NbFaces();
2085 //=============================================================================
2087 * Returns true if given element is polygon
2089 //=============================================================================
2091 CORBA::Boolean SMESH_Mesh_i::IsPoly(const CORBA::Long id)
2093 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
2094 if ( aSMESHDS_Mesh == NULL ) return false;
2095 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
2096 if(!elem) return false;
2097 return elem->IsPoly();
2101 //=============================================================================
2103 * Returns true if given element is quadratic
2105 //=============================================================================
2107 CORBA::Boolean SMESH_Mesh_i::IsQuadratic(const CORBA::Long id)
2109 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
2110 if ( aSMESHDS_Mesh == NULL ) return false;
2111 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
2112 if(!elem) return false;
2113 return elem->IsQuadratic();
2117 //=============================================================================
2119 * Returns bary center for given element
2121 //=============================================================================
2123 SMESH::double_array* SMESH_Mesh_i::BaryCenter(const CORBA::Long id)
2125 SMESH::double_array_var aResult = new SMESH::double_array();
2126 SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
2127 if ( aSMESHDS_Mesh == NULL )
2128 return aResult._retn();
2130 const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
2132 return aResult._retn();
2134 if(elem->GetType()==SMDSAbs_Volume) {
2135 // use SMDS_VolumeTool
2136 SMDS_VolumeTool aTool;
2137 if(aTool.Set(elem)) {
2138 double x=0., y=0., z=0.;
2139 if(aTool.GetBaryCenter(x,y,z)) {
2149 SMDS_ElemIteratorPtr anIt = elem->nodesIterator();
2151 double x=0., y=0., z=0.;
2152 for(; anIt->more(); ) {
2154 const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>(anIt->next());
2168 return aResult._retn();
2172 //=============================================================================
2176 //=============================================================================
2177 void SMESH_Mesh_i::CreateGroupServants()
2179 // Create group servants, if any groups were imported
2180 list<int> aGroupIds = _impl->GetGroupIds();
2181 for ( list<int>::iterator it = aGroupIds.begin(); it != aGroupIds.end(); it++ ) {
2182 SMESH_Group_i* aGroupImpl = new SMESH_Group_i( SMESH_Gen_i::GetPOA(), this, *it );
2184 // PAL7962: san -- To ensure correct mapping of servant and correct reference counting in GenericObj_i
2185 SMESH_Gen_i::GetPOA()->activate_object( aGroupImpl );
2186 aGroupImpl->Register();
2187 // PAL7962: san -- To ensure correct mapping of servant and correct reference counting in GenericObj_i
2189 SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow( aGroupImpl->_this() );
2190 _mapGroups[*it] = SMESH::SMESH_Group::_duplicate( aGroup );
2192 // register CORBA object for persistence
2193 int nextId = _gen_i->RegisterObject( aGroup );
2194 if(MYDEBUG) MESSAGE( "Add group to map with id = "<< nextId);