Salome HOME
0021543: EDF 1978 SMESH: Viscous layer for 2D meshes
authoreap <eap@opencascade.com>
Mon, 15 Oct 2012 14:34:23 +0000 (14:34 +0000)
committereap <eap@opencascade.com>
Mon, 15 Oct 2012 14:34:23 +0000 (14:34 +0000)
 In FindEqualElements(), use idSourceToSet()

src/SMESH_I/SMESH_MeshEditor_i.cxx

index a5b5f88c16998a07f94d73e784c616a7673aa502..d4545e0b6ce698cba04c7cd28011b5b4948e1b44 100644 (file)
@@ -4450,18 +4450,8 @@ void SMESH_MeshEditor_i::FindEqualElements(SMESH::SMESH_IDSource_ptr      theObj
   SMESH::SMESH_GroupBase_var group = SMESH::SMESH_GroupBase::_narrow(theObject);
   if ( !(!group->_is_nil() && group->GetType() == SMESH::NODE) )
   {
-    typedef list<int> TListOfIDs;
-    set<const SMDS_MeshElement*> elems;
-    SMESH::long_array_var aElementsId = theObject->GetIDs();
-    SMESHDS_Mesh* aMesh = GetMeshDS();
-
-    for(int i = 0; i < aElementsId->length(); i++) {
-      CORBA::Long anID = aElementsId[i];
-      const SMDS_MeshElement * elem = aMesh->FindElement(anID);
-      if (elem) {
-        elems.insert(elem);
-      }
-    }
+    TIDSortedElemSet elems;
+    idSourceToSet( theObject, GetMeshDS(), elems, SMDSAbs_All, /*emptyIfIsMesh=*/true);
 
     ::SMESH_MeshEditor::TListOfListOfElementsID aListOfListOfElementsID;
     myEditor.FindEqualElements( elems, aListOfListOfElementsID );
@@ -4469,15 +4459,16 @@ void SMESH_MeshEditor_i::FindEqualElements(SMESH::SMESH_IDSource_ptr      theObj
     GroupsOfElementsID = new SMESH::array_of_long_array;
     GroupsOfElementsID->length( aListOfListOfElementsID.size() );
 
-    ::SMESH_MeshEditor::TListOfListOfElementsID::iterator arraysIt = aListOfListOfElementsID.begin();
-    for (CORBA::Long j = 0; arraysIt != aListOfListOfElementsID.end(); ++arraysIt, ++j) {
+    ::SMESH_MeshEditor::TListOfListOfElementsID::iterator arraysIt =
+        aListOfListOfElementsID.begin();
+    for (CORBA::Long j = 0; arraysIt != aListOfListOfElementsID.end(); ++arraysIt, ++j)
+    {
       SMESH::long_array& aGroup = (*GroupsOfElementsID)[ j ];
-      TListOfIDs& listOfIDs = *arraysIt;
+      list<int>&      listOfIDs = *arraysIt;
       aGroup.length( listOfIDs.size() );
-      TListOfIDs::iterator idIt = listOfIDs.begin();
-      for (int k = 0; idIt != listOfIDs.end(); ++idIt, ++k ) {
+      list<int>::iterator idIt = listOfIDs.begin();
+      for (int k = 0; idIt != listOfIDs.end(); ++idIt, ++k )
         aGroup[ k ] = *idIt;
-      }
     }
 
     TPythonDump() << "equal_elements = " << this << ".FindEqualElements( "