Salome HOME
updated copyright message
[modules/shaper.git] / src / FiltersAPI / FiltersAPI_Selection.cpp
index 93a4444d92826fc518672c035b049280811ff059..b600746dad0624386ec3b19c1131fa0198d4bb71 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 "FiltersAPI_Selection.h"
 
+#include "GeomAPI_Edge.h"
+#include "ModelAPI_Session.h"
+#include "ModelAPI_FiltersFactory.h"
+#include "ModelHighAPI_Services.h"
+
 FiltersAPI_Selection::FiltersAPI_Selection(const FiltersPtr & theFeature)
 {
   myVariantType = VT_Filtering;
@@ -29,6 +34,38 @@ FiltersAPI_Selection::~FiltersAPI_Selection()
 {
 }
 
+FiltersFeaturePtr FiltersAPI_Selection::feature() const
+{
+  return myFilterFeature;
+}
+
+std::list<ModelHighAPI_Selection> FiltersAPI_Selection::select
+                                  (const std::string theShapeType) const
+{
+  return select(GeomAPI_Shape::shapeTypeByStr(theShapeType));
+}
+
+std::list<ModelHighAPI_Selection> FiltersAPI_Selection::select
+                                  (const GeomAPI_Shape::ShapeType theShapeType) const
+{
+  // finish operation to make sure the selection is done on the current state of the history
+  apply();
+
+  std::list<ModelHighAPI_Selection> aSelList;
+  static SessionPtr aSession = ModelAPI_Session::get();
+  std::list< std::pair<ResultPtr, GeomShapePtr> > aResList =
+    aSession->filters()->select(myFilterFeature, theShapeType);
+
+  std::list< std::pair<ResultPtr, GeomShapePtr> >::const_iterator itSelected = aResList.cbegin();
+  for (; itSelected != aResList.cend(); itSelected++) {
+    ResultPtr aCurRes = (*itSelected).first;
+    GeomShapePtr aSubShape = (*itSelected).second;
+    aSelList.push_back(ModelHighAPI_Selection(aCurRes, aSubShape));
+  }
+
+  return aSelList;
+}
+
 // ================================================================================================
 FiltersAPI_Selection filters(const std::shared_ptr<ModelAPI_Document>& thePart,
                              const std::list<FilterAPIPtr>& theFilters)