From: mpv Date: Wed, 18 Dec 2019 09:39:22 +0000 (+0300) Subject: Fix for the issue #3125 : Create wire - Add contour button X-Git-Tag: V9_5_0a1~83 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9aded1dc3aab3c16a06e1e73899cb67b682b79e9;p=modules%2Fshaper.git Fix for the issue #3125 : Create wire - Add contour button --- diff --git a/src/BuildPlugin/CMakeLists.txt b/src/BuildPlugin/CMakeLists.txt index 2954b05c7..d0568077d 100644 --- a/src/BuildPlugin/CMakeLists.txt +++ b/src/BuildPlugin/CMakeLists.txt @@ -155,4 +155,5 @@ ADD_UNIT_TESTS(TestVertex.py Test2415.py Test2439.py Test2454.py + Test3125.py ) diff --git a/src/BuildPlugin/Test/Test3125.py b/src/BuildPlugin/Test/Test3125.py new file mode 100644 index 000000000..e592da03f --- /dev/null +++ b/src/BuildPlugin/Test/Test3125.py @@ -0,0 +1,48 @@ +# 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 +# + +# Checking of adding a partset-sketcher edges into the wire by the "Add contour" action +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOZ")) +SketchLine_1 = Sketch_1.addLine(-24.8768472906404, 33.33497536945814, 36.81773399014779, 23.38423645320196) +SketchLine_2 = Sketch_1.addLine(36.81773399014779, 23.38423645320196, 11.31896551724138, -27.61330049261085) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchLine_3 = Sketch_1.addLine(11.31896551724138, -27.61330049261085, -24.8768472906404, 33.33497536945814) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint()) +model.do() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Wire_1_objects = [model.selection("EDGE", "PartSet/Sketch_1/SketchLine_3")] +Wire_1 = model.addWire(Part_1_doc, Wire_1_objects, False) +Wire_1.feature().customAction("add_contour") +model.end() + +from ModelAPI import * +from GeomAPI import * + +aFactory = ModelAPI_Session.get().validators() +assert(aFactory.validate(Wire_1.feature())) + +model.testNbResults(Wire_1, 1) +model.testNbSubShapes(Wire_1, GeomAPI_Shape.EDGE, [3]) +model.testNbSubShapes(Wire_1, GeomAPI_Shape.VERTEX, [6]) diff --git a/src/Selector/Selector_Modify.cpp b/src/Selector/Selector_Modify.cpp index 246e0cdec..c73762a7d 100644 --- a/src/Selector/Selector_Modify.cpp +++ b/src/Selector/Selector_Modify.cpp @@ -48,32 +48,34 @@ static void findBases(TDF_Label theAccess, Handle(TNaming_NamedShape) theFinal, bool aMustBeAtFinal, const TDF_Label& theAdditionalDocument, TDF_LabelList& theResult) { bool aFoundAnyShape = false; - TNaming_SameShapeIterator aLabIter(theValue, theAccess); - for(; aLabIter.More(); aLabIter.Next()) { - Handle(TNaming_NamedShape) aNS; - if (aLabIter.Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) { - if (aMustBeAtFinal && aNS != theFinal) - continue; // looking for old at the same final label only - TNaming_Evolution anEvolution = aNS->Evolution(); - if (anEvolution == TNaming_PRIMITIVE) { - // check that this is not in the results already - const TDF_Label aResult = aNS->Label(); - TDF_LabelList::Iterator aResIter(theResult); - for(; aResIter.More(); aResIter.Next()) { - if (aResIter.Value().IsEqual(aResult)) - break; + if (TNaming_Tool::HasLabel(theAccess, theValue)) { + TNaming_SameShapeIterator aLabIter(theValue, theAccess); + for(; aLabIter.More(); aLabIter.Next()) { + Handle(TNaming_NamedShape) aNS; + if (aLabIter.Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + if (aMustBeAtFinal && aNS != theFinal) + continue; // looking for old at the same final label only + TNaming_Evolution anEvolution = aNS->Evolution(); + if (anEvolution == TNaming_PRIMITIVE) { + // check that this is not in the results already + const TDF_Label aResult = aNS->Label(); + TDF_LabelList::Iterator aResIter(theResult); + for(; aResIter.More(); aResIter.Next()) { + if (aResIter.Value().IsEqual(aResult)) + break; + } + if (!aResIter.More()) // not found, so add this new + theResult.Append(aResult); + aFoundAnyShape = true; } - if (!aResIter.More()) // not found, so add this new - theResult.Append(aResult); - aFoundAnyShape = true; - } - if (anEvolution == TNaming_GENERATED || anEvolution == TNaming_MODIFY) { - for(TNaming_Iterator aThisIter(aNS); aThisIter.More(); aThisIter.Next()) { - if (aThisIter.NewShape().IsSame(theValue)) { - // continue recursively, null NS means that any NS are ok - findBases(theAccess, theFinal, aThisIter.OldShape(), - false, theAdditionalDocument, theResult); - aFoundAnyShape = true; + if (anEvolution == TNaming_GENERATED || anEvolution == TNaming_MODIFY) { + for(TNaming_Iterator aThisIter(aNS); aThisIter.More(); aThisIter.Next()) { + if (aThisIter.NewShape().IsSame(theValue)) { + // continue recursively, null NS means that any NS are ok + findBases(theAccess, theFinal, aThisIter.OldShape(), + false, theAdditionalDocument, theResult); + aFoundAnyShape = true; + } } } }