Salome HOME
[EDF] (2023-T1) Filters on group 22/head
authorEkaterina Sukhareva <ekaterina.sukhareva@opencascade.com>
Fri, 29 Sep 2023 16:26:02 +0000 (17:26 +0100)
committerEkaterina Sukhareva <ekaterina.sukhareva@opencascade.com>
Tue, 24 Oct 2023 11:50:31 +0000 (12:50 +0100)
13 files changed:
src/FiltersPlugin/CMakeLists.txt
src/FiltersPlugin/FiltersPlugin_OnShapeName.cpp [new file with mode: 0644]
src/FiltersPlugin/FiltersPlugin_OnShapeName.h [new file with mode: 0644]
src/FiltersPlugin/FiltersPlugin_Plugin.cpp
src/FiltersPlugin/FiltersPlugin_msg_en.ts
src/FiltersPlugin/FiltersPlugin_msg_fr.ts
src/FiltersPlugin/Test/TestFilter_OnShapeName.py [new file with mode: 0644]
src/FiltersPlugin/Test/TestFilters_Supported.py
src/FiltersPlugin/doc/FiltersPlugin.rst
src/FiltersPlugin/doc/images/selection_byShapeName1.png [new file with mode: 0755]
src/FiltersPlugin/doc/images/selection_byShapeName2.png [new file with mode: 0755]
src/FiltersPlugin/filter-OnShapeName.xml [new file with mode: 0644]
src/FiltersPlugin/tests.set

index 81f3846349e562bff4be5f3cf9c6f5018c695502..a3938251a06a245b8431031598c81c77579c962a 100644 (file)
@@ -31,6 +31,7 @@ SET(PROJECT_HEADERS
     FiltersPlugin_OnLine.h
     FiltersPlugin_OnGeometry.h
     FiltersPlugin_OnPlaneSide.h
+    FiltersPlugin_OnShapeName.h
     FiltersPlugin_OppositeToEdge.h
     FiltersPlugin_RelativeToSolid.h
     FiltersPlugin_ExternalFaces.h
@@ -52,6 +53,7 @@ SET(PROJECT_SOURCES
     FiltersPlugin_OnLine.cpp
     FiltersPlugin_OnGeometry.cpp
     FiltersPlugin_OnPlaneSide.cpp
+    FiltersPlugin_OnShapeName.cpp
     FiltersPlugin_OppositeToEdge.cpp
     FiltersPlugin_RelativeToSolid.cpp
     FiltersPlugin_ExternalFaces.cpp
@@ -83,6 +85,7 @@ SET(XML_RESOURCES
   filter-OnLine.xml
   filter-OnPlane.xml
   filter-OnPlaneSide.xml
+  filter-OnShapeName.xml
   filter-OppositeToEdge.xml
   filter-RelativeToSolid.xml
   filter-TopoConnectedFaces.xml
@@ -101,12 +104,13 @@ SET(TEXT_RESOURCES
 SOURCE_GROUP ("XML Files" FILES ${XML_RESOURCES})
 SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES})
 
-ADD_DEFINITIONS(-DFILTERS_EXPORTS ${OpenCASCADE_DEFINITIONS})
+ADD_DEFINITIONS(-DFILTERS_EXPORTS ${OpenCASCADE_DEFINITIONS} ${BOOST_DEFINITIONS})
 ADD_LIBRARY(FiltersPlugin SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES} ${TEXT_RESOURCES})
 TARGET_LINK_LIBRARIES(FiltersPlugin ${PROJECT_LIBRARIES})
 
 INCLUDE_DIRECTORIES(
   ${OpenCASCADE_INCLUDE_DIR}
+  ${Boost_INCLUDE_DIRS}
   ${PROJECT_SOURCE_DIR}/src/ModelAPI
   ${PROJECT_SOURCE_DIR}/src/Config
   ${PROJECT_SOURCE_DIR}/src/Events
@@ -115,6 +119,7 @@ INCLUDE_DIRECTORIES(
   ${PROJECT_SOURCE_DIR}/src/GeomDataAPI
   ${PROJECT_SOURCE_DIR}/src/GeomValidators
   ${PROJECT_SOURCE_DIR}/src/CollectionPlugin
+  ${PROJECT_SOURCE_DIR}/src/Locale
 )
 
 INSTALL(TARGETS FiltersPlugin DESTINATION ${SHAPER_INSTALL_PLUGIN_FILES})
diff --git a/src/FiltersPlugin/FiltersPlugin_OnShapeName.cpp b/src/FiltersPlugin/FiltersPlugin_OnShapeName.cpp
new file mode 100644 (file)
index 0000000..759ec6b
--- /dev/null
@@ -0,0 +1,120 @@
+// 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
+// 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_OnShapeName.h"
+
+#include <ModelAPI_AttributeString.h>
+// #include <Model_Data.h>
+// #include <TDF_Label.hxx>
+// #include <TNaming_Builder.hxx>
+// #include <TNaming_NamedShape.hxx>
+// #include <TDataStd_Name.hxx>
+// #include <TNaming_Tool.hxx>
+// #include <TopoDS_Shape.hxx>
+
+#include <Locale_Convert.h>
+#include <boost/algorithm/string.hpp>
+
+bool FiltersPlugin_OnShapeName::isSupported(GeomAPI_Shape::ShapeType /*theType*/) const
+{
+  return true;
+}
+
+static bool getShapesName(const GeomShapePtr& theShape,
+                          ResultBodyPtr theResultBody,
+                          std::string& theShapeName)
+{
+  int nbSubRes = theResultBody->numberOfSubs();
+  if(theResultBody->shape()->isSame(theShape) || (nbSubRes == 0 && theResultBody->shape()->isSubShape(theShape)))
+  {
+    DataPtr data = theResultBody->data();
+    if (data.get()) 
+    {
+      theShapeName = Locale::Convert::toString(data->name());
+      return true;
+    }
+  }
+
+  bool aResult(false);
+  ResultBodyPtr subResult;
+  for (int i = 0; i < nbSubRes; i++)
+  {
+    subResult = theResultBody->subResult(i);
+    if(getShapesName(theShape, subResult, theShapeName))
+    {
+      aResult = true;
+      break;
+    }
+  }
+
+  return aResult;
+}
+
+bool FiltersPlugin_OnShapeName::isOk(const GeomShapePtr& theShape, const ResultPtr& theResult,
+                                     const ModelAPI_FiltersArgs& theArgs) const
+{
+  AttributePtr anAttr = theArgs.argument("pattern");
+  AttributeStringPtr aValue = std::dynamic_pointer_cast<ModelAPI_AttributeString>(anAttr);
+  if (!aValue.get()|| !anAttr->isInitialized())
+    return false;
+  std::string aPattern= aValue->value();
+
+
+  ResultBodyPtr aBodyRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
+  std::string aShapeName;
+  if(!getShapesName(theShape, aBodyRes, aShapeName))
+  {
+    return false;
+  }
+
+  //remove * from both sides of pattern
+  if(aPattern.back() == '*' && aPattern.front() == '*')
+  {
+    aPattern.pop_back();
+    aPattern.erase(aPattern.begin());
+  }
+
+  bool isFound = false;
+  if(aPattern.front() == '*')
+  {
+    aPattern.erase(aPattern.begin());
+    isFound = boost::algorithm::ends_with(aShapeName, aPattern);
+  }
+  else if(aPattern.back() == '*')
+  {
+    aPattern.pop_back();
+    isFound = boost::algorithm::starts_with(aShapeName, aPattern);
+  }
+  else
+  {
+    isFound = (aShapeName.find(aPattern) != std::string::npos);
+  }
+
+  return isFound;
+}
+
+std::string FiltersPlugin_OnShapeName::xmlRepresentation() const
+{
+  return xmlFromFile("filter-OnShapeName.xml");
+}
+
+void FiltersPlugin_OnShapeName::initAttributes(ModelAPI_FiltersArgs& theArguments)
+{
+  theArguments.initAttribute("pattern", ModelAPI_AttributeString::typeId());
+}
\ No newline at end of file
diff --git a/src/FiltersPlugin/FiltersPlugin_OnShapeName.h b/src/FiltersPlugin/FiltersPlugin_OnShapeName.h
new file mode 100644 (file)
index 0000000..fc1c480
--- /dev/null
@@ -0,0 +1,59 @@
+// 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
+// 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_ONSHAPENAME_H_
+#define FILTERSPLUGIN_ONSHAPENAME_H_
+
+#include "FiltersPlugin.h"
+
+#include <ModelAPI_Filter.h>
+
+/**\class FiltersPlugin_OnPlaneSide
+* \ingroup DataModel
+* \brief Filter for objects which lying on the side of selected plane
+*/
+class FiltersPlugin_OnShapeName : public ModelAPI_Filter
+{
+public:
+    FiltersPlugin_OnShapeName() : ModelAPI_Filter() {}
+
+    virtual const std::string& name() const 
+    {
+        static const std::string kName("On shape name");
+        return kName;
+    }
+
+    /// Returns true for face type
+    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
+    /// \param theArgs arguments of the filter
+    virtual bool isOk(const GeomShapePtr& theShape, const ResultPtr&,
+                      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
index e543fbb7c6518437cebb829e54397c7f1a52b9af..db12b2ce3e494b54051808e749cba402ea61fd81 100644 (file)
@@ -28,6 +28,7 @@
 #include "FiltersPlugin_OnLine.h"
 #include "FiltersPlugin_OnPlane.h"
 #include "FiltersPlugin_OnPlaneSide.h"
+#include "FiltersPlugin_OnShapeName.h"
 #include "FiltersPlugin_OppositeToEdge.h"
 #include "FiltersPlugin_Plugin.h"
 #include "FiltersPlugin_RelativeToSolid.h"
@@ -64,6 +65,7 @@ FiltersPlugin_Plugin::FiltersPlugin_Plugin()
   aFactory->registerFilter("VolumeSize", new FiltersPlugin_VolumeSize);
   aFactory->registerFilter("FeatureEdges", new FiltersPlugin_FeatureEdges);
   aFactory->registerFilter("ContinuousFaces", new FiltersPlugin_ContinuousFaces);
+  aFactory->registerFilter("OnShapeName", new FiltersPlugin_OnShapeName);
 
   Config_ModuleReader::loadScript("FiltersPlugin_TopoConnectedFaces");
 
index e20f87ad1c3117d1632d2bd4ee44b111e3dad1b3..2d24466efa67d478f5e48a18a700cff9453caef1 100644 (file)
       <source>Opposite to an edge</source>
       <translation>Opposite to an edge</translation>
     </message>
+    <message>
+      <source>On shape name</source>
+      <translation>On shape name</translation>
+    </message>
     <message>
       <source>Topologically connected faces</source>
       <translation>Topologically connected faces</translation>
     </message>
   </context>
 
+  <!-- OnShapeName -->
+  <context>
+    <name>OnShapeName</name>
+    <message>
+      <source>Search pattern:</source>
+      <translation>Search pattern:</translation>
+    </message>
+  </context>
+
 </TS>
index eb39232e58d1a8d661d44fe39f90feb78e5251a1..53ab64b01fca996010f36cecc8076e983c4d1e0a 100644 (file)
       <source>Opposite to an edge</source>
       <translation>En face d&apos;un bord</translation>
     </message>
+    <message>
+      <source>On shape name</source>
+      <translation>Sur le nom des shapes</translation>
+    </message>
     <message>
       <source>Topologically connected faces</source>
       <translation>Faces topologiquement connectés</translation>
     </message>
   </context>
 
+  <!-- OnShapeName -->
+  <context>
+    <name>OnShapeName</name>
+    <message>
+      <source>Search pattern:</source>
+      <translation>Modèle de recherche:</translation>
+    </message>
+  </context>
+
 </TS>
diff --git a/src/FiltersPlugin/Test/TestFilter_OnShapeName.py b/src/FiltersPlugin/Test/TestFilter_OnShapeName.py
new file mode 100644 (file)
index 0000000..a1262dd
--- /dev/null
@@ -0,0 +1,197 @@
+# 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
+# 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
+#
+
+import sys
+import salome
+
+salome.salome_init()
+import salome_notebook
+notebook = salome_notebook.NoteBook()
+sys.path.insert(0, r'/home/eksu/S2')
+
+###
+### SHAPER component
+###
+
+from SketchAPI import *
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+
+### Create Part
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+model.addParameter(Part_1_doc, "rayon", '10.')
+model.addParameter(Part_1_doc, "hauteur", '2.*rayon')
+
+### Create Sketch
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+
+### Create SketchProjection
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+
+### Create SketchCircle
+SketchCircle_1 = Sketch_1.addCircle(0, 0, 10)
+Sketch_1.setCoincident(SketchPoint_1.result(), SketchCircle_1.center())
+Sketch_1.setRadius(SketchCircle_1.results()[1], "rayon ")
+model.do()
+
+### Create Extrusion
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_1")], model.selection(), "hauteur ", "hauteur/4.", "Faces|Wires")
+
+### Create Sketch
+Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
+
+### Create SketchLine
+SketchLine_1 = Sketch_2.addLine(12.5, -12.5, -12.5, -12.5)
+
+### Create SketchProjection
+SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_2 = SketchProjection_2.createdFeature()
+
+### Create SketchLine
+SketchLine_2 = Sketch_2.addLine(-12.5, -12.5, -12.5, 12.5)
+
+### Create SketchLine
+SketchLine_3 = Sketch_2.addLine(-12.5, 12.5, 12.5, 12.5)
+
+### Create SketchLine
+SketchLine_4 = Sketch_2.addLine(12.5, 12.5, 12.5, -12.5)
+Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+Sketch_2.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+Sketch_2.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+
+### Create SketchLine
+SketchLine_5 = Sketch_2.addLine(12.5, -12.5, -12.5, 12.5)
+SketchLine_5.setAuxiliary(True)
+
+### Create SketchLine
+SketchLine_6 = Sketch_2.addLine(-12.5, -12.5, 12.5, 12.5)
+SketchLine_6.setAuxiliary(True)
+Sketch_2.setCoincident(SketchLine_1.startPoint(), SketchLine_5.startPoint())
+Sketch_2.setCoincident(SketchLine_2.startPoint(), SketchLine_6.startPoint())
+Sketch_2.setCoincident(SketchLine_3.startPoint(), SketchLine_5.endPoint())
+Sketch_2.setCoincident(SketchLine_4.startPoint(), SketchLine_6.endPoint())
+Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_5.result())
+Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_6.result())
+Sketch_2.setHorizontal(SketchLine_1.result())
+Sketch_2.setVertical(SketchLine_2.result())
+Sketch_2.setHorizontal(SketchLine_3.result())
+Sketch_2.setVertical(SketchLine_4.result())
+Sketch_2.setLength(SketchLine_3.result(), "2.5*rayon")
+Sketch_2.setEqual(SketchLine_3.result(), SketchLine_2.result())
+model.do()
+
+### Create Extrusion
+Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_2")], model.selection(), 0, "2.*rayon", "Faces|Wires")
+
+### Create Sketch
+Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
+
+### Create SketchLine
+SketchLine_7 = Sketch_3.addLine(-4.930380657631324e-32, -6, -4.930380657631324e-32, 6)
+
+### Create SketchProjection
+SketchProjection_3 = Sketch_3.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_3 = SketchProjection_3.createdFeature()
+Sketch_3.setMiddlePoint(SketchAPI_Point(SketchPoint_3).coordinates(), SketchLine_7.result())
+Sketch_3.setVertical(SketchLine_7.result())
+Sketch_3.setLength(SketchLine_7.result(), "1.2*rayon")
+model.do()
+
+### Create Extrusion
+Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_3")], model.selection("EDGE", "PartSet/OZ"), "hauteur*1.4", "hauteur*0.4", "Edges")
+
+### Create Extrusion
+Extrusion_4 = model.addExtrusion(Part_1_doc, [model.selection("VERTEX", "PartSet/Origin")], model.selection("EDGE", "PartSet/OY"), "rayon*1.6", "rayon*1.6")
+
+### Create Translation
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "all-in-Extrusion_4")], axis = model.selection("EDGE", "PartSet/OZ"), distance = "hauteur*0.5", keepSubResults = True)
+
+### Create Partition
+Partition_1_objects = [model.selection("COMPOUND", "all-in-Extrusion_1"),
+                       model.selection("COMPOUND", "all-in-Extrusion_2"),
+                       model.selection("COMPOUND", "all-in-Extrusion_3"),
+                       model.selection("COMPOUND", "all-in-Translation_1")]
+Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects, keepSubResults = True)
+Partition_1.result().subResult(0).setName("Volumes")
+Partition_1.result().subResult(0).subResult(0).setName("Cylindre bas")
+Partition_1.result().subResult(0).subResult(1).setName("Cylindre haut")
+Partition_1.result().subResult(0).subResult(2).setName("Cube Creux")
+Partition_1.result().subResult(1).setName("Plaque")
+Partition_1.result().subResult(2).setName("Poutre 1")
+Partition_1.result().subResult(3).setName("Poutre 2")
+
+### Create Group
+Group_1_objects = [model.selection("VERTEX", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_4][Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_3][Extrusion_2_1/From_Face]"),
+                   model.selection("VERTEX", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_4][Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_3][Cube Creux/Modified_Face&Extrusion_2_1/To_Face]"),
+                   model.selection("VERTEX", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_4][Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_1][Extrusion_2_1/From_Face]"),
+                   model.selection("VERTEX", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_4][Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_1][Cube Creux/Modified_Face&Extrusion_2_1/To_Face]"),
+                   model.selection("VERTEX", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_3][Extrusion_2_1/From_Face][Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_2]"),
+                   model.selection("VERTEX", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_3][Cube Creux/Modified_Face&Extrusion_2_1/To_Face][Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_2]"),
+                   model.selection("VERTEX", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_1][Extrusion_2_1/From_Face][Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_2]"),
+                   model.selection("VERTEX", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_1][Cube Creux/Modified_Face&Extrusion_2_1/To_Face][Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_2]"),
+                   model.selection("VERTEX", "[Extrusion_3_1/From_Edge]e[Cube Creux/Modified_Edge&Sketch_3/SketchLine_7_StartVertex]e"),
+                   model.selection("VERTEX", "[Extrusion_3_1/From_Edge]e[Cube Creux/Modified_Edge&Sketch_3/SketchLine_7_EndVertex]e"), model.filters(Part_1_doc, [model.addFilter(name = "OnShapeName", args = ["Cube"])])]
+Group_1 = model.addGroup(Part_1_doc, "Vertices", Group_1_objects)
+Group_1.setName("CubeVertices_1")
+Group_1.result().setName("CubeVertices_1")
+
+### Create Group
+Group_2_objects = [model.selection("EDGE", "(Cylindre haut/Generated_Edge&Extrusion_2_1/To_Face&Sketch_1/SketchCircle_1_2)([Cylindre haut/Modified_Face&Sketch_1/SketchCircle_1_2][Cylindre haut/Modified_Face&Extrusion_1_1/To_Face])"),
+                   model.selection("EDGE", "[Cylindre haut/Modified_Face&Sketch_1/SketchCircle_1_2][Cylindre haut/Modified_Face&Extrusion_1_1/To_Face]"),
+                   model.selection("EDGE", "Cylindre haut/Generated_Edge&Sketch_3/Sketch_3&Extrusion_1_1/To_Face"),
+                   model.selection("EDGE", "Cylindre haut/Modified_Edge&Sketch_3/SketchLine_7_EndVertex&new_weak_name_1"),
+                   model.selection("EDGE", "Cylindre haut/Modified_Edge&PartSet/Origin/Origin&new_weak_name_2"),
+                   model.selection("EDGE", "Cylindre haut/Modified_Edge&Sketch_3/SketchLine_7_StartVertex&new_weak_name_1"),
+                   model.selection("EDGE", "Cylindre haut/Modified_Edge&Sketch_3/SketchLine_7_EndVertex&new_weak_name_2"),
+                   model.selection("EDGE", "Cylindre haut/Modified_Edge&Sketch_3/SketchLine_7_StartVertex&new_weak_name_2"),
+                   model.selection("EDGE", "Cylindre haut/Modified_Edge&PartSet/Origin/Origin&new_weak_name_1"),
+                   model.selection("EDGE", "Cylindre haut/Modified_Edge&PartSet/Origin/Origin&new_weak_name_3"),
+                   model.selection("SOLID", "Cylindre bas"), model.filters(Part_1_doc, [model.addFilter(name = "OnShapeName", args = ["Cyl"])])]
+Group_2 = model.addGroup(Part_1_doc, "Edges", Group_2_objects)
+Group_2.setName("CylEdges_2")
+Group_2.result().setName("CylEdges_2")
+
+### Create Group
+Group_3 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Plaque"), model.filters(Part_1_doc, [model.addFilter(name = "OnShapeName", args = ["Plaq"])])])
+Group_3.setName("Plaque_3")
+Group_3.result().setName("Plaque_3")
+
+### Create Group
+Group_4 = model.addGroup(Part_1_doc, "Solids", [model.selection("SOLID", "Cylindre haut"), model.selection("SOLID", "Cylindre bas"), model.filters(Part_1_doc, [model.addFilter(name = "OnShapeName", args = ["Cyl"])])])
+Group_4.setName("Cyllindres_4")
+Group_4.result().setName("Cyllindres_4")
+
+model.end()
+
+###
+### SHAPERSTUDY component
+###
+
+model.publishToShaperStudy()
+import SHAPERSTUDY
+Partition_1_1, CubeVertices_1, CylEdges_2, Plaque_3, Cyllindres_4, = SHAPERSTUDY.shape(model.featureStringId(Partition_1))
+
+if salome.sg.hasDesktop():
+  salome.sg.updateObjBrowser()
index e6b4934353d308722160bc3daf87366f680df088..b2ff5bb3c51a18fd8f3f2e7b0de6491e1f0e4055 100644 (file)
@@ -39,15 +39,16 @@ FILTER_FACE_SIZE = "FaceSize"
 FILTER_VOLUME_SIZE = "VolumeSize"
 FILTER_FEATURE_EDGES = "FeatureEdges"
 FILTER_CONTINUOUS_FACES= "ContinuousFaces"
+FILTER_ON_SHAPE_NAME = "OnShapeName"
 
 # Reference data (supported filters) for each type of shape
 Reference = {
-    GeomAPI_Shape.VERTEX : [FILTER_BELONGS_TO, FILTER_ON_PLANE, FILTER_ON_LINE, FILTER_ON_PLANE_SIDE, FILTER_RELATIVE_TO_SOLID],
-    GeomAPI_Shape.EDGE   : [FILTER_BELONGS_TO, FILTER_ON_PLANE, FILTER_ON_LINE, FILTER_ON_GEOMETRY, FILTER_ON_PLANE_SIDE, FILTER_OPPOSITE_TO_EDGE, FILTER_RELATIVE_TO_SOLID, FILTER_EDGE_SIZE, FILTER_FEATURE_EDGES],
-    GeomAPI_Shape.WIRE   : [FILTER_BELONGS_TO, FILTER_ON_PLANE, FILTER_ON_PLANE_SIDE, FILTER_RELATIVE_TO_SOLID],
-    GeomAPI_Shape.FACE   : [FILTER_BELONGS_TO, FILTER_ON_PLANE, FILTER_ON_GEOMETRY, FILTER_ON_PLANE_SIDE, FILTER_RELATIVE_TO_SOLID, FILTER_EXTERNAL_FACES, FILTER_HORIZONTAL_FACES, FILTER_VERTICAL_FACES, FILTER_CONNECTED_FACES, FILTER_FACE_SIZE, FILTER_CONTINUOUS_FACES],
-    GeomAPI_Shape.SHELL  : [FILTER_BELONGS_TO, FILTER_ON_PLANE, FILTER_ON_PLANE_SIDE, FILTER_RELATIVE_TO_SOLID],
-    GeomAPI_Shape.SOLID  : [FILTER_BELONGS_TO, FILTER_ON_PLANE_SIDE, FILTER_VOLUME_SIZE],
+    GeomAPI_Shape.VERTEX : [FILTER_BELONGS_TO, FILTER_ON_PLANE, FILTER_ON_LINE, FILTER_ON_PLANE_SIDE, FILTER_RELATIVE_TO_SOLID, FILTER_ON_SHAPE_NAME],
+    GeomAPI_Shape.EDGE   : [FILTER_BELONGS_TO, FILTER_ON_PLANE, FILTER_ON_LINE, FILTER_ON_GEOMETRY, FILTER_ON_PLANE_SIDE, FILTER_OPPOSITE_TO_EDGE, FILTER_RELATIVE_TO_SOLID, FILTER_EDGE_SIZE, FILTER_FEATURE_EDGES, FILTER_ON_SHAPE_NAME],
+    GeomAPI_Shape.WIRE   : [FILTER_BELONGS_TO, FILTER_ON_PLANE, FILTER_ON_PLANE_SIDE, FILTER_RELATIVE_TO_SOLID, FILTER_ON_SHAPE_NAME],
+    GeomAPI_Shape.FACE   : [FILTER_BELONGS_TO, FILTER_ON_PLANE, FILTER_ON_GEOMETRY, FILTER_ON_PLANE_SIDE, FILTER_RELATIVE_TO_SOLID, FILTER_EXTERNAL_FACES, FILTER_HORIZONTAL_FACES, FILTER_VERTICAL_FACES, FILTER_CONNECTED_FACES, FILTER_FACE_SIZE, FILTER_CONTINUOUS_FACES, FILTER_ON_SHAPE_NAME],
+    GeomAPI_Shape.SHELL  : [FILTER_BELONGS_TO, FILTER_ON_PLANE, FILTER_ON_PLANE_SIDE, FILTER_RELATIVE_TO_SOLID, FILTER_ON_SHAPE_NAME],
+    GeomAPI_Shape.SOLID  : [FILTER_BELONGS_TO, FILTER_ON_PLANE_SIDE, FILTER_VOLUME_SIZE, FILTER_ON_SHAPE_NAME],
 }
 
 model.begin()
index 3d9bbb4920e93119e76e41ea0bcae801fceb07f6..00c0c2791b939ea4b644e3a4688f6e0ee81e0933 100644 (file)
@@ -179,3 +179,22 @@ This algorithm finds all the faces topologically connected the argument selected
 - **Algorithm:**
     - If a point of an edge is selected as an argument, the result is all faces that contain this argument.If a face is selected, the result is all faces that have shared edges or vertices with this selection.
     - If “propagation” flag is enabled (it is disabled by default), the algorithm becomes recursive: all connected faces are added to the results. So, for the solid shape there will be all faces except internal-volumes faces, not connected to any external faces.
+
+**On shape name**
+
+- **Result type:** Any
+- **Arguments:** A string value, representing a pattern for searching by result name. The pattern can be the full name of result or its part. Pattern is case sensitive. There are several options for the pattern input:
+
+    - **Pattern*** to search for results with names matching from the beginning strictly. 
+    - ***Pattern** to search for results with names matching from the ending strictly. 
+    - **Pattern** to search for results with names containing this regular expression. 
+    - ***Pattern*** to search for results with names containing this regular expression. 
+- **Algorithm:**
+    - Returns objects that contain a pattern in their names or subobjects of these objects.
+    - For example, if we have in the result a shape with the name “cube” and we want to select all the edges according to the pattern "cube", then we will get all the edges of the object with name "cube".
+    - There are two examples: selecting all edges belonging to objects from the result with a name starting with "Cyl" and selecting all vertices belonging to objects from the result with a name containing pattern "Cube":
+.. figure:: images/selection_byShapeName1.png
+  :align: center
+
+.. figure:: images/selection_byShapeName2.png
+  :align: center
diff --git a/src/FiltersPlugin/doc/images/selection_byShapeName1.png b/src/FiltersPlugin/doc/images/selection_byShapeName1.png
new file mode 100755 (executable)
index 0000000..4cd7a26
Binary files /dev/null and b/src/FiltersPlugin/doc/images/selection_byShapeName1.png differ
diff --git a/src/FiltersPlugin/doc/images/selection_byShapeName2.png b/src/FiltersPlugin/doc/images/selection_byShapeName2.png
new file mode 100755 (executable)
index 0000000..69827e5
Binary files /dev/null and b/src/FiltersPlugin/doc/images/selection_byShapeName2.png differ
diff --git a/src/FiltersPlugin/filter-OnShapeName.xml b/src/FiltersPlugin/filter-OnShapeName.xml
new file mode 100644 (file)
index 0000000..49d2fa2
--- /dev/null
@@ -0,0 +1,4 @@
+<filter id="OnShapeName">
+  <stringvalue id="OnShapeName__pattern" label="Search pattern:">
+  </stringvalue>
+</filter>
index f3a894b59c105f96a6aae98d60af5c9e80e7ba96..64a44e684dcacdb0470e9bdd38001c5df2d0932a 100644 (file)
@@ -124,4 +124,5 @@ SET(TEST_NAMES
   TestFilter_FeatureEdges.py
   TestFilter_ContinuousFaces.py
   TestFilter_VolumeSize.py
+  TestFilter_OnShapeName.py
 )