]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for the issue #3125 : Create wire - Add contour button
authormpv <mpv@opencascade.com>
Wed, 18 Dec 2019 09:39:22 +0000 (12:39 +0300)
committermpv <mpv@opencascade.com>
Wed, 18 Dec 2019 09:39:35 +0000 (12:39 +0300)
src/BuildPlugin/CMakeLists.txt
src/BuildPlugin/Test/Test3125.py [new file with mode: 0644]
src/Selector/Selector_Modify.cpp

index 2954b05c7f0cb94b7601731bcbd92103982f4172..d0568077dddc2fa021376588a2eb17e431f6c813 100644 (file)
@@ -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 (file)
index 0000000..e592da0
--- /dev/null
@@ -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])
index 246e0cdeca59ad19233480aa70bef6a95854878e..c73762a7d96a55e8d8a883336557c9b41e490790 100644 (file)
@@ -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;
+            }
           }
         }
       }