]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix regression after - bos #35156 Non planar Faces
authorEkaterina Sukhareva <ekaterina.sukhareva@opencascade.com>
Fri, 10 Nov 2023 10:36:43 +0000 (10:36 +0000)
committermbs <martin.bernhard@opencascade.com>
Mon, 13 Nov 2023 07:38:13 +0000 (07:38 +0000)
src/BuildPlugin/BuildPlugin_Face.cpp
src/BuildPlugin/BuildPlugin_Validators.cpp

index 874ff58f3663b509ededd16b84471677e7ba9f7d..bdad8006215ae6c503f6f75f8e952cf169fb676c 100644 (file)
@@ -60,7 +60,8 @@ void BuildPlugin_Face::execute()
   }
 
   // Collect base shapes.
-  ListOfShape anEdges;
+  ListOfShape anAllEdges;
+  ListOfShape aPlanarEdges;
   ListOfShape aNonPlanarEdges;
   ListOfShape anOriginalFaces;
   ListOfShape aContexts;
@@ -101,26 +102,40 @@ void BuildPlugin_Face::execute()
 
     for(GeomAPI_ShapeExplorer anExp(aShape, GeomAPI_Shape::EDGE); anExp.more(); anExp.next()) {
       GeomShapePtr anEdge = anExp.current();
-      isPlanar? anEdges.push_back(anEdge) : aNonPlanarEdges.push_back(anEdge);
+      anAllEdges.push_back(anEdge);
+      isPlanar? aPlanarEdges.push_back(anEdge) : aNonPlanarEdges.push_back(anEdge);
     }
   }
 
-  if (!anEdges.empty())
+  bool isAllPlanar(false);
+  if(!anAllEdges.empty())
   {
-    //check is planar objects belong to nke
-    std::shared_ptr<GeomAPI_Pln> aPln = GeomAlgoAPI_ShapeTools::findPlane(anEdges);
+    //check if all the object actually belong to one plane.
+    std::shared_ptr<GeomAPI_Pln> aPln = GeomAlgoAPI_ShapeTools::findPlane(anAllEdges);
+    if(aPln.get() && !aNonPlanarEdges.empty()) 
+    {
+      aPlanarEdges.insert(aPlanarEdges.end(), aNonPlanarEdges.begin(), aNonPlanarEdges.end());
+      aNonPlanarEdges.clear();
+      isAllPlanar = true;
+    }
+  }
+
+  if (!isAllPlanar && !aPlanarEdges.empty())
+  {
+    //check is planar objects belong to one plane
+    std::shared_ptr<GeomAPI_Pln> aPln = GeomAlgoAPI_ShapeTools::findPlane(aPlanarEdges);
     if(!aPln.get())
     {
-      aNonPlanarEdges.insert(aNonPlanarEdges.end(), anEdges.begin(), anEdges.end());
-      anEdges.clear();
+      aNonPlanarEdges.insert(aNonPlanarEdges.end(), aPlanarEdges.begin(), aPlanarEdges.end());
+      aPlanarEdges.clear();
     }
   }
 
   // Build faces by edges.
   ListOfShape aFaces;
   GeomMakeShapePtr aFaceBuilder;
-  if (!anEdges.empty())
-    buildFacesByEdges(anEdges, aListOfNormals, aFaces, aFaceBuilder);
+  if (!aPlanarEdges.empty())
+    buildFacesByEdges(aPlanarEdges, aListOfNormals, aFaces, aFaceBuilder);
   int aNbFacesFromEdges = (int)aFaces.size();
 
   // Build non-planar faces by edges.
@@ -153,7 +168,7 @@ void BuildPlugin_Face::execute()
 
     ListOfShape aBaseShapes;
     if (anIndex < aNbFacesFromEdges)
-      aBaseShapes = anEdges;
+      aBaseShapes = aPlanarEdges;
     else if(anIndex < aNbNonPlanarFaces)
       aBaseShapes = aNonPlanarEdges;
     else
index 81c16c770faee3e8ab8cae572f92a5c9f58eaa76..8d12b7cad01ad82b06eae04c658a4cacfb5ccfaa 100644 (file)
@@ -353,6 +353,20 @@ bool BuildPlugin_ValidatorBaseForFace::isValid(const std::shared_ptr<ModelAPI_Fe
     }
   }
 
+  if (!anAllEdges.empty()) {
+    // Check that they are planar.
+    std::shared_ptr<GeomAPI_Pln> aPln = GeomAlgoAPI_ShapeTools::findPlane(anAllEdges);
+    if(aPln.get()) {
+        // Check that selected objects have closed contours.
+      GeomAlgoAPI_SketchBuilder aBuilder(aPln, anAllEdges);
+      const ListOfShape& aFaces = aBuilder.faces();
+      if(!aFaces.empty()) {
+        return true;
+      }
+    }
+  }
+
+
   //check only planar onjects
   bool isPlanarBelongToOnePlane(false);
   if (!aPlanarEdges.empty()) {