Salome HOME
updated copyright message
[modules/shaper.git] / src / FiltersPlugin / FiltersPlugin_OnPlaneSide.cpp
index b19a98ec5898d876ba6d233332d1d20ca7b395c7..f786a15d6cf6fc41e5b6bb03b6dc2eaf9eb31097 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 #include <GeomAPI_XYZ.h>
 
 
-bool FiltersPlugin_OnPlaneSide::isSupported(GeomAPI_Shape::ShapeType theType) const
+bool FiltersPlugin_OnPlaneSide::isSupported(GeomAPI_Shape::ShapeType /*theType*/) const
 {
   return true;
 }
 
-bool FiltersPlugin_OnPlaneSide::isOk(const GeomShapePtr& theShape,
+bool FiltersPlugin_OnPlaneSide::isOk(const GeomShapePtr& theShape, const ResultPtr&,
                                      const ModelAPI_FiltersArgs& theArgs) const
 {
   static const double THE_TOLERANCE = 1.e-7;
@@ -42,8 +42,12 @@ bool FiltersPlugin_OnPlaneSide::isOk(const GeomShapePtr& theShape,
   if (!aList.get())
     return false;
   GeomShapePtr aPlanarShape = aList->value();
-  if (!aPlanarShape)
-    aPlanarShape = aList->context()->shape();
+  if (!aPlanarShape) {
+    ResultPtr aContext = aList->context();
+    if (!aContext)
+      return false;
+    aPlanarShape = aContext->shape();
+  }
 
   GeomPlanePtr aPlane = aPlanarShape->face()->getPlane();
   GeomPointPtr aPlaneLoc = aPlane->location();
@@ -55,20 +59,9 @@ bool FiltersPlugin_OnPlaneSide::isOk(const GeomShapePtr& theShape,
   return aVec->dot(aPlaneNorm->xyz()) > THE_TOLERANCE;
 }
 
-static std::string XMLRepresentation =
-"<filter id = \"OnPlaneSide\">"
-" <shape_selector id=\"OnPlaneSide__OnPlaneSide\""
-"   label=\"Plane:\""
-"   tooltip=\"Select plane or planar face.\""
-"   shape_types=\"faces\">"
-"   <validator id=\"GeomValidators_ShapeType\" parameters=\"plane\"/>"
-" </shape_selector>"
-"</filter>";
-
-
 std::string FiltersPlugin_OnPlaneSide::xmlRepresentation() const
 {
-  return XMLRepresentation;
+  return xmlFromFile("filter-OnPlaneSide.xml");
 }
 
 void FiltersPlugin_OnPlaneSide::initAttributes(ModelAPI_FiltersArgs& theArguments)