Salome HOME
Issue #2998: Add help description for automatic creation of constraints
[modules/shaper.git] / src / FiltersPlugin / FiltersPlugin_OnPlane.cpp
index 3bb1019a2b9972b877444424c6cb2ba69ec10a5f..8ee128dc74f90646788ffb32987c5429766c07cd 100644 (file)
@@ -48,12 +48,15 @@ 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();
 }
 
-bool FiltersPlugin_OnPlane::isOk(const GeomShapePtr& theShape,
-  const ModelAPI_FiltersArgs& theArgs) const
+bool FiltersPlugin_OnPlane::isOk(const GeomShapePtr& theShape, const ResultPtr&,
+                                 const ModelAPI_FiltersArgs& theArgs) const
 {
   AttributePtr aAttr = theArgs.argument("OnPlane");
   AttributeSelectionListPtr aList =
@@ -80,14 +83,10 @@ bool FiltersPlugin_OnPlane::isOk(const GeomShapePtr& theShape,
           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;
       }
     }
@@ -99,31 +98,18 @@ bool FiltersPlugin_OnPlane::isOk(const GeomShapePtr& theShape,
       for (int i = 0; i < aList->size(); i++) {
         AttributeSelectionPtr aAttr = aList->value(i);
         GeomShapePtr aGeom = aAttr->value();
-        if (!aGeom->isSame(theShape)) {
-          GeomPlanePtr aPlane = getPlane(aAttr);
-          if (aPlane->isCoincident(aPln))
-            return true;
-        }
+        GeomPlanePtr aPlane = getPlane(aAttr);
+        if (aPlane->isCoincident(aPln))
+          return true;
       }
     }
   }
   return false;
 }
 
-static std::string XMLRepresentation =
-"<filter id = \"OnPlane\">"
-" <multi_selector id=\"OnPlane__OnPlane\""
-"   label=\"Planes:\""
-"   tooltip=\"Select planes or planar faces.\""
-"   type_choice=\"faces\">"
-"   <validator id=\"GeomValidators_ShapeType\" parameters=\"plane\"/>"
-" </multi_selector>"
-"</filter>";
-
-
 std::string FiltersPlugin_OnPlane::xmlRepresentation() const
 {
-  return XMLRepresentation;
+  return xmlFromFile("filter-OnPlane.xml");
 }
 
 void FiltersPlugin_OnPlane::initAttributes(ModelAPI_FiltersArgs& theArguments)