Salome HOME
NPAL14335 (EDF 344 SMESH : "ERROR : Iterator not implemented " when loading a script)
authoreap <eap@opencascade.com>
Fri, 29 Dec 2006 14:37:28 +0000 (14:37 +0000)
committereap <eap@opencascade.com>
Fri, 29 Dec 2006 14:37:28 +0000 (14:37 +0000)
        use set<element,comparator> instead of map<ID,element> to
        have elements sorted by ID

src/SMESH/SMESH_MesherHelper.cxx
src/SMESH/SMESH_Pattern.cxx
src/SMESH_I/SMESH_Gen_i.cxx
src/SMESH_I/SMESH_MeshEditor_i.cxx
src/StdMeshers/StdMeshers_Penta_3D.cxx
src/StdMeshers/StdMeshers_ProjectionUtils.cxx

index c3e420317ad626a35470b08c8dfd25b6d74c0384..0d377958589927cba5aea58443bd1b8d85b3f91f 100644 (file)
@@ -914,12 +914,12 @@ bool SMESH_MesherHelper::LoadNodeColumns(TParam2ColumnMap & theParam2ColumnMap,
   // try to load the rest nodes
 
   // get all faces from theFace
-  map<int,const SMDS_MeshElement*> allFaces, foundFaces;
+  TIDSortedElemSet allFaces, foundFaces;
   eIt = smFace->GetElements();
   while ( eIt->more() ) {
     const SMDS_MeshElement* e = eIt->next();
     if ( e->GetType() == SMDSAbs_Face )
-      allFaces.insert( make_pair(e->GetID(),e) );
+      allFaces.insert( e );
   }
   // Starting from 2 neighbour nodes on theBaseEdge, look for a face
   // the nodes belong to, and between the nodes of the found face,
@@ -967,7 +967,7 @@ bool SMESH_MesherHelper::LoadNodeColumns(TParam2ColumnMap & theParam2ColumnMap,
             RETURN_BAD_RESULT( "Too many nodes in column "<< col <<": "<< row+1);
           }
           par_nVec_2->second[ row ] = node;
-          foundFaces.insert( make_pair(face->GetID(),face) );
+          foundFaces.insert( face );
           n2 = node;
           if ( nbFaceNodes==4 ) {
             n1 = par_nVec_1->second[ row ];
index 03bce5e4eba33e9c2bb38f63d8a48131214f786b..44396d2afbd43cc0d247785edf3431f7148ea1a8 100644 (file)
@@ -3257,11 +3257,11 @@ void SMESH_Pattern::
   myPolyElems.reserve( myIdsOnBoundary.size() );
 
   // make a set of refined elements
-  map<int,const SMDS_MeshElement* > avoidSet, elemSet;
+  TIDSortedElemSet avoidSet, elemSet;
   std::vector<const SMDS_MeshElement*>::iterator itv =  myElements.begin();
   for(; itv!=myElements.end(); itv++) {
     const SMDS_MeshElement* el = (*itv);
-    avoidSet.insert( make_pair(el->GetID(),el) );
+    avoidSet.insert( el );
   }
   //avoidSet.insert( myElements.begin(), myElements.end() );
 
@@ -3293,7 +3293,7 @@ void SMESH_Pattern::
           SMESH_MeshEditor::FindFaceInSet( n1, n2, elemSet, avoidSet );
         if ( face )
         {
-          avoidSet.insert ( make_pair(face->GetID(),face) );
+          avoidSet.insert ( face );
           myPolyElems.push_back( face );
 
           // some links of <face> are split;
@@ -3414,7 +3414,7 @@ void SMESH_Pattern::
         while ( eIt->more() )
         {
           const SMDS_MeshElement* elem = eIt->next();
-          if ( !volTool.Set( elem ) || !avoidSet.insert( make_pair(elem->GetID(),elem) ).second )
+          if ( !volTool.Set( elem ) || !avoidSet.insert( elem ).second )
             continue; // skip faces or refined elements
           // add polyhedron definition
           myPolyhedronQuantities.push_back(vector<int> ());
index 9673f56b4e511410bbbf914c705ee727401b914a..77cdfad143b8b78dd3bc963c9173eb9d3d1dae90 100644 (file)
@@ -2749,7 +2749,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
               aDataset->CloseOnDisk();
 
               // get elements sorted by ID
-              ::SMESH_MeshEditor::TIDSortedElemSet elemSet;
+              TIDSortedElemSet elemSet;
               if ( isNode )
                 while ( nIt->more() ) elemSet.insert( nIt->next() );
               else
@@ -2757,7 +2757,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
               ASSERT( elemSet.size() == nbElems );
 
               // add elements to submeshes
-              ::SMESH_MeshEditor::TIDSortedElemSet::iterator iE = elemSet.begin();
+              TIDSortedElemSet::iterator iE = elemSet.begin();
               for ( int i = 0; i < nbElems; ++i, ++iE )
               {
                 int smID = smIDs[ i ];
index 55fc2330dc48efb2f66ea72cad6967ad88b223e6..8447ab89e5d09efd1ea54ea09487465c5d09dc3b 100644 (file)
@@ -524,29 +524,32 @@ CORBA::Boolean SMESH_MeshEditor_i::ReorientObject(SMESH::SMESH_IDSource_ptr theO
   return isDone;
 }
 
-
-//=======================================================================
-//function : ToMap
-//purpose  : auxilary function for conversion long_array to std::map<>
-//           which is used in some methods
-//=======================================================================
-static void ToMap(const SMESH::long_array &              IDs,
-                  const SMESHDS_Mesh*                    aMesh,
-                  std::map<int,const SMDS_MeshElement*>& aMap,
-                  const SMDSAbs_ElementType              aType = SMDSAbs_All )
-{ 
-  for (int i=0; i<IDs.length(); i++) {
-    CORBA::Long ind = IDs[i];
-    std::map<int,const SMDS_MeshElement*>::iterator It = aMap.find(ind);
-    if(It==aMap.end()) {
+namespace
+{
+  //================================================================================
+  /*!
+   * \brief function for conversion long_array to TIDSortedElemSet
+    * \param IDs - array of IDs
+    * \param aMesh - mesh
+    * \param aMap - collection to fill
+    * \param aType - element type
+   */
+  //================================================================================
+
+  void ToMap(const SMESH::long_array & IDs,
+             const SMESHDS_Mesh*       aMesh,
+             TIDSortedElemSet&         aMap,
+             const SMDSAbs_ElementType aType = SMDSAbs_All )
+  { 
+    for (int i=0; i<IDs.length(); i++) {
+      CORBA::Long ind = IDs[i];
       const SMDS_MeshElement * elem = aMesh->FindElement(ind);
       if ( elem && ( aType == SMDSAbs_All || elem->GetType() == aType ))
-        aMap.insert( make_pair( elem->GetID(), elem ));
+        aMap.insert( elem );
     }
   }
 }
 
-
 //=============================================================================
 /*!
  *
@@ -560,7 +563,7 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array &   IDsOfE
   myLastCreatedNodes = new SMESH::long_array();
 
   SMESHDS_Mesh* aMesh = GetMeshDS();
-  map<int,const SMDS_MeshElement*> faces;
+  TIDSortedElemSet faces;
   ToMap(IDsOfElements, aMesh, faces, SMDSAbs_Face);
 
   SMESH::NumericalFunctor_i* aNumericalFunctor =
@@ -636,7 +639,7 @@ CORBA::Boolean SMESH_MeshEditor_i::QuadToTri (const SMESH::long_array &   IDsOfE
   myLastCreatedNodes = new SMESH::long_array();
 
   SMESHDS_Mesh* aMesh = GetMeshDS();
-  map<int,const SMDS_MeshElement*> faces;
+  TIDSortedElemSet faces;
   ToMap(IDsOfElements, aMesh, faces, SMDSAbs_Face);
 
   SMESH::NumericalFunctor_i* aNumericalFunctor =
@@ -709,7 +712,7 @@ CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfEle
   myLastCreatedNodes = new SMESH::long_array();
 
   SMESHDS_Mesh* aMesh = GetMeshDS();
-  map<int,const SMDS_MeshElement*> faces;
+  TIDSortedElemSet faces;
   ToMap(IDsOfElements, aMesh, faces, SMDSAbs_Face);
 
   // Update Python script
@@ -873,7 +876,7 @@ CORBA::Boolean
 
   SMESHDS_Mesh* aMesh = GetMeshDS();
 
-  map<int,const SMDS_MeshElement*> elements;
+  TIDSortedElemSet elements;
   ToMap(IDsOfElements, aMesh, elements, SMDSAbs_Face);
 
   set<const SMDS_MeshNode*> fixedNodes;
@@ -999,7 +1002,7 @@ void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElement
 
   SMESHDS_Mesh* aMesh = GetMeshDS();
 
-  map<int,const SMDS_MeshElement*> elements;
+  TIDSortedElemSet elements;
   ToMap(theIDsOfElements, aMesh, elements);
 
   gp_Ax1 Ax1 (gp_Pnt( theAxis.x, theAxis.y, theAxis.z ),
@@ -1071,7 +1074,7 @@ void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElemen
 #endif
     SMESHDS_Mesh* aMesh = GetMeshDS();
 
-    map<int,const SMDS_MeshElement*> elements;
+    TIDSortedElemSet elements;
     ToMap(theIDsOfElements, aMesh, elements);
 
     const SMESH::PointStruct * P = &theStepVector.PS;
@@ -1139,7 +1142,7 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObj
 
   SMESH::long_array_var allElementsId = theObject->GetIDs();
 
-  map<int,const SMDS_MeshElement*> elements;
+  TIDSortedElemSet elements;
   ToMap(allElementsId, aMesh, elements);
 
   const SMESH::PointStruct * P = &theStepVector.PS;
@@ -1174,7 +1177,7 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObj
 
   SMESH::long_array_var allElementsId = theObject->GetIDs();
 
-  map<int,const SMDS_MeshElement*> elements;
+  TIDSortedElemSet elements;
   ToMap(allElementsId, aMesh, elements);
 
   const SMESH::PointStruct * P = &theStepVector.PS;
@@ -1210,7 +1213,7 @@ void SMESH_MeshEditor_i::AdvancedExtrusion(const SMESH::long_array & theIDsOfEle
 
   SMESHDS_Mesh* aMesh = GetMeshDS();
 
-  map<int,const SMDS_MeshElement*> elements;
+  TIDSortedElemSet elements;
   ToMap(theIDsOfElements, aMesh, elements);
 
   const SMESH::PointStruct * P = &theStepVector.PS;
@@ -1284,7 +1287,7 @@ SMESH::SMESH_MeshEditor::Extrusion_Error
   if ( !nodeStart )
     return SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE;
 
-  map<int,const SMDS_MeshElement*> elements;
+  TIDSortedElemSet elements;
   ToMap(theIDsOfElements, aMesh, elements);
 
   list<double> angles;
@@ -1374,7 +1377,7 @@ void SMESH_MeshEditor_i::Mirror(const SMESH::long_array &           theIDsOfElem
 
   SMESHDS_Mesh* aMesh = GetMeshDS();
 
-  map<int,const SMDS_MeshElement*> elements;
+  TIDSortedElemSet elements;
   ToMap(theIDsOfElements, aMesh, elements);
 
   gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z );
@@ -1466,7 +1469,7 @@ void SMESH_MeshEditor_i::Translate(const SMESH::long_array & theIDsOfElements,
 
   SMESHDS_Mesh* aMesh = GetMeshDS();
 
-  map<int,const SMDS_MeshElement*> elements;
+  TIDSortedElemSet elements;
   ToMap(theIDsOfElements, aMesh, elements);
 
   gp_Trsf aTrsf;
@@ -1529,7 +1532,7 @@ void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements,
 
   SMESHDS_Mesh* aMesh = GetMeshDS();
 
-  map<int,const SMDS_MeshElement*> elements;
+  TIDSortedElemSet elements;
   ToMap(theIDsOfElements, aMesh, elements);
 
   gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z );
@@ -1909,7 +1912,7 @@ SMESH_MeshEditor_i::SewSideElements(const SMESH::long_array& IDsOfSide1Elements,
       !aSecondNode2ToMerge)
     return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE2_NODES;
 
-  map<int,const SMDS_MeshElement*> aSide1Elems, aSide2Elems;
+  TIDSortedElemSet aSide1Elems, aSide2Elems;
   ToMap(IDsOfSide1Elements, aMesh, aSide1Elems);
   ToMap(IDsOfSide2Elements, aMesh, aSide2Elems);
 
index f183a80dad9aeaae76ee5419eb59ac6063415996..51b33214fadc17d02597a094a397f46650cba7a2 100644 (file)
@@ -1554,12 +1554,12 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
   // try to load the rest nodes
 
   // get all faces from theFace
-  map<int,const SMDS_MeshElement*> allFaces, foundFaces;
+  TIDSortedElemSet allFaces, foundFaces;
   SMDS_ElemIteratorPtr eIt = smFace->GetElements();
   while ( eIt->more() ) {
     const SMDS_MeshElement* e = eIt->next();
     if ( e->GetType() == SMDSAbs_Face )
-      allFaces.insert( make_pair(e->GetID(),e) );
+      allFaces.insert( e );
   }
   // Starting from 2 neighbour nodes on theBaseEdge, look for a face
   // the nodes belong to, and between the nodes of the found face,
@@ -1606,7 +1606,7 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
             return false;
           }
           par_nVec_2->second[ row ] = node;
-          foundFaces.insert( make_pair(face->GetID(),face) );
+          foundFaces.insert( face );
           n2 = node;
           if ( nbFaceNodes==4 || (myCreateQuadratic && nbFaceNodes==8) ) {
             n1 = par_nVec_1->second[ row ];
index 2afedd4ce40c5c50128c4b7b0625739afa22f2f6..b1d3500c673993fcdf758e138fc96ce73d11da07 100644 (file)
@@ -976,12 +976,12 @@ FindMatchingNodesOnFaces( const TopoDS_Face&     face1,
       const SMDS_MeshElement* faceToKeep = 0;
       const SMDS_MeshNode* vNode = is2 ? vNode2 : vNode1;
       const SMDS_MeshNode* eNode = is2 ? eNode2[0] : eNode1[0];
-      std::map<int,const SMDS_MeshElement*> inSet, notInSet;
+      TIDSortedElemSet inSet, notInSet;
 
       const SMDS_MeshElement* f1 =
         SMESH_MeshEditor::FindFaceInSet( vNode, eNode, inSet, notInSet );
       if ( !f1 ) RETURN_BAD_RESULT("The first face on seam not found");
-      SMESH_MeshEditor::Insert( f1, notInSet );
+      notInSet.insert( f1 );
 
       const SMDS_MeshElement* f2 =
         SMESH_MeshEditor::FindFaceInSet( vNode, eNode, inSet, notInSet );