]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Prototype of filter "F8: On/In/Out a Solid"
authorazv <azv@opencascade.com>
Mon, 1 Jul 2019 10:12:47 +0000 (13:12 +0300)
committerazv <azv@opencascade.com>
Mon, 1 Jul 2019 10:12:47 +0000 (13:12 +0300)
src/FiltersPlugin/CMakeLists.txt
src/FiltersPlugin/FiltersPlugin_Plugin.cpp
src/FiltersPlugin/FiltersPlugin_RelativeToSolid.cpp [new file with mode: 0644]
src/FiltersPlugin/FiltersPlugin_RelativeToSolid.h [new file with mode: 0644]

index 121dc0ff3e33c69451268508954cf71b3cc859fa..d0c3058264fa8e4943b876cfaf79da7ada0b1ae6 100644 (file)
@@ -32,6 +32,7 @@ SET(PROJECT_HEADERS
     FiltersPlugin_OnGeometry.h
     FiltersPlugin_OnPlaneSide.h
     FiltersPlugin_OppositeToEdge.h
+    FiltersPlugin_RelativeToSolid.h
 )
 
 SET(PROJECT_SOURCES
@@ -45,6 +46,7 @@ SET(PROJECT_SOURCES
     FiltersPlugin_OnGeometry.cpp
     FiltersPlugin_OnPlaneSide.cpp
     FiltersPlugin_OppositeToEdge.cpp
+    FiltersPlugin_RelativeToSolid.cpp
 )
 
 SET(PROJECT_LIBRARIES
@@ -84,6 +86,12 @@ ADD_UNIT_TESTS(
   TestFilter_OnPlaneSide_Face.py
   TestFilter_OnPlaneSide_Plane.py
   TestFilter_OppositeToEdge.py
+#  TestFilter_RelativeToSolid_In.py
+#  TestFilter_RelativeToSolid_Out.py
+#  TestFilter_RelativeToSolid_On.py
+#  TestFilter_RelativeToSolid_NotOn.py
+#  TestFilter_RelativeToSolid_InAndOn.py
+#  TestFilter_RelativeToSolid_OutAndOn.py
   TestFilter_HorizontalFaces.py
   TestFilter_VerticalFaces.py
 )
index 956e8477db7b5360813f0bd67fbb9cab3eff6dfd..a0181d6bf13d874e783f49eca1358d545986d290 100644 (file)
@@ -27,6 +27,7 @@
 #include "FiltersPlugin_OnGeometry.h"
 #include "FiltersPlugin_OnPlaneSide.h"
 #include "FiltersPlugin_OppositeToEdge.h"
+#include "FiltersPlugin_RelativeToSolid.h"
 
 #include <ModelAPI_Session.h>
 #include <ModelAPI_FiltersFactory.h>
@@ -47,6 +48,7 @@ FiltersPlugin_Plugin::FiltersPlugin_Plugin()
   aFactory->registerFilter("OnGeometry", new FiltersPlugin_OnGeometry);
   aFactory->registerFilter("OnPlaneSide", new FiltersPlugin_OnPlaneSide);
   aFactory->registerFilter("OppositeToEdge", new FiltersPlugin_OppositeToEdge);
+  aFactory->registerFilter("RelativeToSolid", new FiltersPlugin_RelativeToSolid);
 
   ModelAPI_Session::get()->registerPlugin(this);
 }
diff --git a/src/FiltersPlugin/FiltersPlugin_RelativeToSolid.cpp b/src/FiltersPlugin/FiltersPlugin_RelativeToSolid.cpp
new file mode 100644 (file)
index 0000000..c016db7
--- /dev/null
@@ -0,0 +1,65 @@
+// Copyright (C) 2014-2019  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "FiltersPlugin_RelativeToSolid.h"
+
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeString.h>
+
+
+bool FiltersPlugin_RelativeToSolid::isSupported(GeomAPI_Shape::ShapeType theType) const
+{
+  return true;
+}
+
+bool FiltersPlugin_RelativeToSolid::isOk(const GeomShapePtr& theShape,
+                                         const ModelAPI_FiltersArgs& theArgs) const
+{
+  return false;
+}
+
+static std::string XMLRepresentation =
+"<filter id = \"RelativeToSolid\">"
+" <shape_selector id=\"RelativeToSolid__Solid\""
+"   label=\"Solid:\""
+"   tooltip=\"Select a solid.\""
+"   shape_types=\"solids\">"
+"   <validator id=\"GeomValidators_ShapeType\" parameters=\"solid\"/>"
+" </shape_selector>"
+" <switch id=\"RelativeToSolid__Location\" label=\"Algorithm:\">"
+"   <case id=\"in\" title=\"In\"/>"
+"   <case id=\"out\" title=\"Out\"/>"
+"   <case id=\"on\" title=\"On\"/>"
+"   <case id=\"noton\" title=\"Not On\"/>"
+"   <case id=\"inon\" title=\"In & On\"/>"
+"   <case id=\"outon\" title=\"On & Out\"/>"
+" </switch>"
+"</filter>";
+
+
+std::string FiltersPlugin_RelativeToSolid::xmlRepresentation() const
+{
+  return XMLRepresentation;
+}
+
+void FiltersPlugin_RelativeToSolid::initAttributes(ModelAPI_FiltersArgs& theArguments)
+{
+  theArguments.initAttribute("Solid", ModelAPI_AttributeSelection::typeId());
+  theArguments.initAttribute("Location", ModelAPI_AttributeString::typeId());
+}
diff --git a/src/FiltersPlugin/FiltersPlugin_RelativeToSolid.h b/src/FiltersPlugin/FiltersPlugin_RelativeToSolid.h
new file mode 100644 (file)
index 0000000..61d0b59
--- /dev/null
@@ -0,0 +1,57 @@
+// Copyright (C) 2014-2019  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef FILTERSPLUGIN_RELATIVETOSOLID_H_
+#define FILTERSPLUGIN_RELATIVETOSOLID_H_
+
+#include "FiltersPlugin.h"
+
+#include <ModelAPI_Filter.h>
+
+/**\class FiltersPlugin_RelativeToSolid
+* \ingroup DataModel
+* \brief Filter for objects inside/outside/on the selected solid
+*/
+class FiltersPlugin_RelativeToSolid : public ModelAPI_Filter
+{
+public:
+  FiltersPlugin_RelativeToSolid() : ModelAPI_Filter() {}
+
+  virtual const std::string& name() const {
+    static const std::string kName("On/In/Out a solid");
+    return kName;
+  }
+
+  /// Returns true for any type because it supports all selection types
+  virtual bool isSupported(GeomAPI_Shape::ShapeType theType) const override;
+
+  /// This method should contain the filter logic. It returns true if the given shape
+  /// is accepted by the filter.
+  /// \param theShape the given shape
+  virtual bool isOk(const GeomShapePtr& theShape,
+                    const ModelAPI_FiltersArgs& theArgs) const override;
+
+  /// Returns XML string which represents GUI of the filter
+  virtual std::string xmlRepresentation() const override;
+
+  /// Initializes arguments of a filter.
+  virtual void initAttributes(ModelAPI_FiltersArgs& theArguments) override;
+};
+
+#endif
\ No newline at end of file