From a199594e8a1e5357675d4641f0253c3a13683cf1 Mon Sep 17 00:00:00 2001 From: azv Date: Mon, 1 Jul 2019 13:12:47 +0300 Subject: [PATCH] Prototype of filter "F8: On/In/Out a Solid" --- src/FiltersPlugin/CMakeLists.txt | 8 +++ src/FiltersPlugin/FiltersPlugin_Plugin.cpp | 2 + .../FiltersPlugin_RelativeToSolid.cpp | 65 +++++++++++++++++++ .../FiltersPlugin_RelativeToSolid.h | 57 ++++++++++++++++ 4 files changed, 132 insertions(+) create mode 100644 src/FiltersPlugin/FiltersPlugin_RelativeToSolid.cpp create mode 100644 src/FiltersPlugin/FiltersPlugin_RelativeToSolid.h diff --git a/src/FiltersPlugin/CMakeLists.txt b/src/FiltersPlugin/CMakeLists.txt index 121dc0ff3..d0c305826 100644 --- a/src/FiltersPlugin/CMakeLists.txt +++ b/src/FiltersPlugin/CMakeLists.txt @@ -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 ) diff --git a/src/FiltersPlugin/FiltersPlugin_Plugin.cpp b/src/FiltersPlugin/FiltersPlugin_Plugin.cpp index 956e8477d..a0181d6bf 100644 --- a/src/FiltersPlugin/FiltersPlugin_Plugin.cpp +++ b/src/FiltersPlugin/FiltersPlugin_Plugin.cpp @@ -27,6 +27,7 @@ #include "FiltersPlugin_OnGeometry.h" #include "FiltersPlugin_OnPlaneSide.h" #include "FiltersPlugin_OppositeToEdge.h" +#include "FiltersPlugin_RelativeToSolid.h" #include #include @@ -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 index 000000000..c016db761 --- /dev/null +++ b/src/FiltersPlugin/FiltersPlugin_RelativeToSolid.cpp @@ -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 +#include + + +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 = +"" +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +""; + + +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 index 000000000..61d0b5900 --- /dev/null +++ b/src/FiltersPlugin/FiltersPlugin_RelativeToSolid.h @@ -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 + +/**\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 -- 2.39.2