- ASSERT(_mapSubMeshIor.find(subMeshId) != _mapSubMeshIor.end());
- return SMESH::SMESH_subMesh::_duplicate(_mapSubMeshIor[subMeshId]);
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
-SMESH::log_array* SMESH_Mesh_i::GetLog(CORBA::Boolean clearAfterGet)
- throw (SALOME::SALOME_Exception)
-{
- MESSAGE("SMESH_Mesh_i::GetLog");
-
- SMESH::log_array_var aLog;
- try
- {
- const SMESHDS_ListOfCommand& logDS =_impl->GetLog();
- aLog = new SMESH::log_array;
- int indexLog = 0;
- int lg = logDS.Extent();
- SCRUTE(lg);
- aLog->length(lg);
- SMESHDS_ListIteratorOfListOfCommand its(logDS);
- while(its.More())
- {
- Handle(SMESHDS_Command) com = its.Value();
- int comType = com->GetType();
- //SCRUTE(comType);
- int lgcom = com->GetNumber();
- //SCRUTE(lgcom);
- const TColStd_ListOfInteger& intList = com->GetIndexes();
- int inum = intList.Extent();
- //SCRUTE(inum);
- TColStd_ListIteratorOfListOfInteger ii(intList);
- const TColStd_ListOfReal& coordList = com->GetCoords();
- int rnum = coordList.Extent();
- //SCRUTE(rnum);
- TColStd_ListIteratorOfListOfReal ir(coordList);
- aLog[indexLog].commandType = comType;
- aLog[indexLog].number = lgcom;
- aLog[indexLog].coords.length(rnum);
- aLog[indexLog].indexes.length(inum);
- for (int i=0; i<rnum; i++)
- {
- aLog[indexLog].coords[i] = ir.Value();
- //MESSAGE(" "<<i<<" "<<ir.Value());
- ir.Next();
- }
- for (int i=0; i<inum; i++)
- {
- aLog[indexLog].indexes[i] = ii.Value();
- //MESSAGE(" "<<i<<" "<<ii.Value());
- ii.Next();
- }
- indexLog++;
- its.Next();
- }
- if (clearAfterGet) _impl->ClearLog();
- }
- catch (SALOME_Exception& S_ex)
- {
- THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
- }
- return aLog._retn();
-}
-
-// SMESH::string_array* SMESH_Mesh_i::GetLog(CORBA::Boolean clearAfterGet)
-// throw (SALOME::SALOME_Exception)
-// {
-// MESSAGE("SMESH_Mesh_i::GetLog");
-
-// SMESH::string_array_var aLog;
-// try
-// {
-// const SMESHDS_ListOfCommand& logDS =_impl->GetLog();
-// aLog = new SMESH::string_array;
-// int logSize = 0;
-// int indexLog = 0;
-// int lg = logDS.Extent();
-// SCRUTE(lg);
-// SMESHDS_ListIteratorOfListOfCommand its(logDS);
-// while(its.More())
-// {
-// Handle(SMESHDS_Command) com = its.Value();
-// int comType = com->GetType();
-// SCRUTE(comType);
-// int lgcom = com->GetNumber();
-// SCRUTE(lgcom);
-// logSize += lgcom;
-// aLog->length(logSize);
-// SCRUTE(logSize);
-// const TColStd_ListOfInteger& intList = com->GetIndexes();
-// TColStd_ListIteratorOfListOfInteger ii(intList);
-// const TColStd_ListOfReal& coordList = com->GetCoords();
-// TColStd_ListIteratorOfListOfReal ir(coordList);
-// for (int icom = 1; icom <= lgcom; icom++)
-// {
-// ostringstream S;
-// switch (comType)
-// {
-// case SMESHDS_AddNode:
-// S << "AddNode " << ii.Value(); ii.Next();
-// S << " " << ir.Value(); ir.Next();
-// S << " " << ir.Value(); ir.Next();
-// S << " " << ir.Value(); ir.Next();
-// break;
-// case SMESHDS_AddEdge:
-// S << "AddEdge " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// break;
-// case SMESHDS_AddTriangle:
-// S << "AddFace " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// break;
-// case SMESHDS_AddQuadrangle:
-// S << "AddFace " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// break;
-// case SMESHDS_AddTetrahedron:
-// S << "AddVolume " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// break;
-// case SMESHDS_AddPyramid:
-// S << "AddVolume " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// break;
-// case SMESHDS_AddPrism:
-// S << "AddVolume " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// break;
-// case SMESHDS_AddHexahedron:
-// S << "AddVolume " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// S << " " << ii.Value(); ii.Next();
-// break;
-// case SMESHDS_RemoveNode:
-// S << "RemoveNode " << ii.Value(); ii.Next();
-// break;
-// case SMESHDS_RemoveElement:
-// S << "RemoveElement " << ii.Value(); ii.Next();
-// break;
-// default:
-// ASSERT(0);
-// break;
-// }
-// string ch = S.str();
-// SCRUTE(ch);
-// aLog[indexLog++] = CORBA::string_dup(ch.c_str());
-// }
-// its.Next();
-// }
-// if (clearAfterGet) _impl->ClearLog();
-// }
-// catch (SALOME_Exception& S_ex)
-// {
-// THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
-// }
-// return aLog._retn();
-// }
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
-void SMESH_Mesh_i::ClearLog()
+ for ( int i1 = 0, n1 = anIds1->length(); i1 < n1; i1++ )
+ aResMap.Add( anIds1[ i1 ] );
+
+ for ( int i2 = 0, n2 = anIds2->length(); i2 < n2; i2++ )
+ aResMap.Add( anIds2[ i2 ] );
+
+ SMESH::long_array_var aResIds = new SMESH::long_array;
+ aResIds->length( aResMap.Extent() );
+
+ int resI = 0;
+ TColStd_MapIteratorOfMapOfInteger anIter( aResMap );
+ for( ; anIter.More(); anIter.Next() )
+ aResIds[ resI++ ] = anIter.Key();
+
+ aResGrp->Add( aResIds );
+
+ // Clear python lines, created by CreateGroup() and Add()
+ SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
+ _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
+ _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
+
+ // Update Python script
+ TCollection_AsciiString aStr;
+ SMESH_Gen_i::AddObject(aStr, aResGrp) += " = ";
+ SMESH_Gen_i::AddObject(aStr, _this()) += ".UnionGroups(";
+ SMESH_Gen_i::AddObject(aStr, theGroup1) += ", ";
+ SMESH_Gen_i::AddObject(aStr, theGroup2) += ", \"";
+ aStr += TCollection_AsciiString((char*)theName) + "\")";
+
+ SMESH_Gen_i::AddToCurrentPyScript(aStr);
+
+ return aResGrp._retn();
+ }
+ catch( ... )
+ {
+ return SMESH::SMESH_Group::_nil();
+ }
+}
+
+//=============================================================================
+/*! IntersectGroups
+ * New group is created. All mesh elements that are
+ * present in both initial groups are added to the new one.
+ */
+//=============================================================================
+SMESH::SMESH_Group_ptr SMESH_Mesh_i::IntersectGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
+ SMESH::SMESH_GroupBase_ptr theGroup2,
+ const char* theName )