Salome HOME
Issue #20450: [Windows] conflicting file names
[modules/shaper.git] / src / FiltersPlugin / FiltersPlugin_OnPlane.cpp
index b9f6329560cf737813e4d96767aeacf886133400..095117a0e0587c84bc5f165fc1058db12644e70a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -41,6 +41,8 @@ bool FiltersPlugin_OnPlane::isSupported(GeomAPI_Shape::ShapeType theType) const
   case GeomAPI_Shape::EDGE:
   case GeomAPI_Shape::VERTEX:
     return true;
+  default: // [to avoid compilation warning]
+    break;
   }
   return false;
 }
@@ -48,6 +50,9 @@ bool FiltersPlugin_OnPlane::isSupported(GeomAPI_Shape::ShapeType theType) const
 GeomPlanePtr getPlane(AttributeSelectionPtr theAttr)
 {
   GeomShapePtr aGeom = theAttr->value();
+  if (!aGeom.get()) {  // construction plane, #2942
+    aGeom = theAttr->context()->shape();
+  }
   GeomFacePtr aFace(new GeomAPI_Face(aGeom));
   return aFace->getPlane();
 }
@@ -80,14 +85,10 @@ bool FiltersPlugin_OnPlane::isOk(const GeomShapePtr& theShape, const ResultPtr&,
           return true;
       }
     }
-    else if (aEdge->isCircle()) {
-      GeomCurvePtr aCurve(new GeomAPI_Curve(aEdge));
-      GeomCirclePtr aCircle(new GeomAPI_Circ(aCurve));
-      GeomDirPtr aDir = aCircle->normal();
-      GeomPointPtr aPnt = aCircle->center();
+    else if (aEdge->isPlanar()) {
       for (int i = 0; i < aList->size(); i++) {
         GeomPlanePtr aPlane = getPlane(aList->value(i));
-        if ((aPlane->direction()->isParallel(aDir)) && (aPlane->distance(aPnt) < LIN_TOLERANCE))
+        if (aEdge->isInPlane(aPlane))
           return true;
       }
     }
@@ -97,9 +98,8 @@ bool FiltersPlugin_OnPlane::isOk(const GeomShapePtr& theShape, const ResultPtr&,
     if (aFace->isPlanar()) {
       GeomPlanePtr aPln = aFace->getPlane();
       for (int i = 0; i < aList->size(); i++) {
-        AttributeSelectionPtr aAttr = aList->value(i);
-        GeomShapePtr aGeom = aAttr->value();
-        GeomPlanePtr aPlane = getPlane(aAttr);
+        AttributeSelectionPtr aCurAttr = aList->value(i);
+        GeomPlanePtr aPlane = getPlane(aCurAttr);
         if (aPlane->isCoincident(aPln))
           return true;
       }