X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_FiltersFactory.cpp;h=005d927ce00b2dba18b51c4a1197fab9f5b9f68f;hb=06e7f5859095193fc7f498bd89a7d28009794f53;hp=df0f4e061a78d7c8a2f1a46b956b06db66b6d09b;hpb=1fd15bed1c62f994a3438bc4a12f44d0361f98c9;p=modules%2Fshaper.git diff --git a/src/Model/Model_FiltersFactory.cpp b/src/Model/Model_FiltersFactory.cpp index df0f4e061..005d927ce 100644 --- a/src/Model/Model_FiltersFactory.cpp +++ b/src/Model/Model_FiltersFactory.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 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 @@ -23,6 +23,7 @@ #include "ModelAPI_AttributeSelectionList.h" #include +#include "GeomAPI_Edge.h" void Model_FiltersFactory::registerFilter(const std::string& theID, ModelAPI_Filter* theFilter) { @@ -112,6 +113,59 @@ bool Model_FiltersFactory::isValid(FeaturePtr theFiltersFeature, return true; } +std::list< std::pair > Model_FiltersFactory::select +(const FiltersFeaturePtr& theFilterFeature, + const GeomAPI_Shape::ShapeType theShapeType) +{ + std::list< std::pair > aResList; + + DocumentPtr aDoc = theFilterFeature->document(); + int aNb = aDoc->size(ModelAPI_ResultBody::group()); + ObjectPtr aObj; + ResultBodyPtr aBody; + for (int i = 0; i < aNb; i++) { + aObj = aDoc->object(ModelAPI_ResultBody::group(), i); + aBody = std::dynamic_pointer_cast(aObj); + GeomShapePtr aShape = aBody->shape(); + std::list aSubShapes = aShape->subShapes(theShapeType, true); + std::list::const_iterator aShapesIt; + for (aShapesIt = aSubShapes.cbegin(); aShapesIt != aSubShapes.cend(); aShapesIt++) { + GeomShapePtr aSubShape = (*aShapesIt); + + // degenerated edge is not valid selection + if (theShapeType == GeomAPI_Shape::EDGE) + if (aSubShape->edge()->isDegenerated()) + continue; + + bool isValid = this->isValid(theFilterFeature, aBody, aSubShape); + + if (isValid) { + // bos #24043: Naming on a compsolid works wrong. + // Find a simple sub-result for the ViewerPrs context: + ResultBodyPtr aContext = aBody; + bool isComposite = aContext->numberOfSubs() > 0; + while (isComposite) { + isComposite = false; + int nbSubs = aContext->numberOfSubs(); + for (int aSubIndex = 0; aSubIndex < nbSubs; aSubIndex++) { + ResultBodyPtr aSubResult = aContext->subResult(aSubIndex); + GeomShapePtr aSubResultShape = aSubResult->shape(); + if (aSubResultShape->isSubShape(aSubShape)) { + aContext = aSubResult; + isComposite = aContext->numberOfSubs() > 0; + break; + } + } + } + std::pair aPair (aContext, aSubShape); + aResList.push_back(aPair); + } + } + } + + return aResList; +} + /// Returns list of filters for the given shape type /// \param theType a shape type std::list Model_FiltersFactory::filters(GeomAPI_Shape::ShapeType theType)