From: mpv Date: Thu, 29 Nov 2018 11:07:05 +0000 (+0300) Subject: Added the container-selection case X-Git-Tag: End2018~134 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ca6485c9c9f5f20a53930a309f086cd680ffd171;p=modules%2Fshaper.git Added the container-selection case --- diff --git a/src/ModelAPI/Test/TestContainerSelector.py b/src/ModelAPI/Test/TestContainerSelector.py new file mode 100644 index 000000000..3f5b59221 --- /dev/null +++ b/src/ModelAPI/Test/TestContainerSelector.py @@ -0,0 +1,36 @@ +## Copyright (C) 2014-2017 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 +## + +# -*- coding: utf-8 -*- + +from salome.shaper import model +from GeomAPI import * + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +model.do() +# a wire selection: container of intersections (edges are intesection of faces) +Wire_1 = model.addWire(Part_1_doc, [model.selection("WIRE", "[[Box_1_1/Left][Box_1_1/Bottom]][[Box_1_1/Front][Box_1_1/Left]][[Box_1_1/Left][Box_1_1/Top]][[Box_1_1/Back][Box_1_1/Left]]")]) +model.end() + +assert(model.checkPythonDump()) diff --git a/src/Selector/Selector_Container.cpp b/src/Selector/Selector_Container.cpp index f10fa46d6..e36d747d2 100644 --- a/src/Selector/Selector_Container.cpp +++ b/src/Selector/Selector_Container.cpp @@ -89,6 +89,17 @@ TDF_Label Selector_Container::restoreByName(std::string theName, for(size_t aStart = 0; aStart != std::string::npos; aStart = theName.find('[', aStart + 1)) { size_t anEndPos = theName.find(']', aStart + 1); if (anEndPos != std::string::npos) { + // there could be sub-intersections, so, [[...]] case; searching for other open-bracket + size_t aNextStart = theName.find('[', aStart + 1); + while(aNextStart != std::string::npos && aNextStart < anEndPos) { + anEndPos = theName.find(']', anEndPos + 1); + if (anEndPos == std::string::npos) { + return TDF_Label(); // invalid parentheses + } + aNextStart = theName.find('[', aNextStart + 1); + } + if (anEndPos == std::string::npos) + return TDF_Label(); // invalid parentheses std::string aSubStr = theName.substr(aStart + 1, anEndPos - aStart - 1); TopAbs_ShapeEnum aSubShapeType = TopAbs_FACE; switch (myShapeType) { @@ -116,6 +127,7 @@ TDF_Label Selector_Container::restoreByName(std::string theName, } } else return TDF_Label(); // invalid parentheses + aStart = anEndPos; // for recursive parenthesis set start on the current end } return aContext; }