Salome HOME
23416: [CEA 2033] Impossible to re-compute a mesh from an hdf
authoreap <eap@opencascade.com>
Thu, 2 Mar 2017 14:12:17 +0000 (17:12 +0300)
committereap <eap@opencascade.com>
Thu, 2 Mar 2017 14:12:17 +0000 (17:12 +0300)
Avoid duplicates in list if ids defining periodicity

src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx

index 47eb29e37a7fa16935b6b5d6f0dc74af5cca857f..19e1c59a531ef7209e131e1f181503333d25cb8f 100644 (file)
@@ -729,29 +729,26 @@ void createAttractorOnFace(TopoDS_Shape GeomShape, std::string AttractorFunction
 }
 
 // One sub-shape to get ids from
-BLSURFPlugin_BLSURF::TListOfIDs _getSubShapeIDsInMainShape(TopoDS_Shape theMainShape, TopoDS_Shape theSubShape,
-    TopAbs_ShapeEnum theShapeType)
+BLSURFPlugin_BLSURF::TListOfIDs _getSubShapeIDsInMainShape(const TopoDS_Shape& theMainShape,
+                                                           const TopoDS_Shape& theSubShape,
+                                                           TopAbs_ShapeEnum    theShapeType)
 {
   BLSURFPlugin_BLSURF::TListOfIDs face_ids;
+
+  TopTools_MapOfShape subShapes;
   TopTools_IndexedMapOfShape anIndices;
-  anIndices.Clear();
   TopExp::MapShapes(theMainShape, theShapeType, anIndices);
 
-//  Standard_Boolean result = BRepTools::Write(theMainShape,"main_shape.brep");
-
   for (TopExp_Explorer face_iter(theSubShape,theShapeType);face_iter.More();face_iter.Next())
+  {
+    if ( subShapes.Add( face_iter.Current() )) // issue 23416
     {
-      int face_id = anIndices.FindIndex(face_iter.Current());
-      if (face_id == 0)
-        throw SALOME_Exception ( SMESH_Comment("Sub_shape not found in main_shape"));
-      face_ids.push_back(face_id);
-//      std::ostringstream o;
-//      o << "face_" << face_id << ".brep";
-//      std::string face_name = o.str();
-//      const TopoDS_Face& face = TopoDS::Face(face_iter.Current());
-//      Standard_Boolean result = BRepTools::Write(face,face_name.c_str());
+      int face_id = anIndices.FindIndex( face_iter.Current() );
+      if ( face_id == 0 )
+        throw SALOME_Exception( "Periodicity: sub_shape not found in main_shape");
+      face_ids.push_back( face_id );
     }
-
+  }
   return face_ids;
 }
 
@@ -2393,6 +2390,8 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh&         aMesh,
       for (std::size_t j=0; j < theFace2_ids.size(); j++)
         o << theFace2_ids[j] << ", ";
       o << "]";
+      // if ( _hypothesis->GetVerbosity() > _hypothesis->GetDefaultVerbosity() )
+      //   cout << o.str() << endl;
       if (_preCadFacesIDsPeriodicityVector[i].theSourceVerticesCoords.empty())
       {
         // If no source points, call peridoicity without transformation function
@@ -2435,6 +2434,8 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh&         aMesh,
       for (std::size_t j=0; j < theEdge2_ids.size(); j++)
         o << theEdge2_ids[j] << ", ";
       o << "]";
+      // if ( _hypothesis->GetVerbosity() > _hypothesis->GetDefaultVerbosity() )
+      //   cout << o.str() << endl;
 
       if (_preCadEdgesIDsPeriodicityVector[i].theSourceVerticesCoords.empty())
       {