--- /dev/null
+# 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
+#
+
+# Test of movement of the group of whole result with different results shape types: only one shape type must be in the moved group
+from salome.shaper import model
+from GeomAPI import *
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchCircle_1 = Sketch_1.addCircle(17.20575221238938, 2.793141592920342, 8.375699762004958)
+model.do()
+Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
+SketchLine_1 = Sketch_2.addLine(24.25155410709516, 6.639479956172791, 20.59251568321609, -12.31511385947313)
+model.do()
+Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")])
+Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchLine_1")])
+Group_1 = model.addGroup(Part_1_doc, "Edges", [model.selection("EDGE", "Edge_1_1")])
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("EDGE", "Edge_1_1")], 20190506)
+model.do()
+# move group after the partition
+Part_1_doc.moveFeature(Group_1.feature(), Partition_1.feature())
+model.end()
+
+# check that only two edges are in the group result, no face
+assert(len(Group_1.feature().results())==1)
+model.testNbSubShapes(Group_1, GeomAPI_Shape.EDGE, [2])
+
+assert(model.checkPythonDump())
aListShapeType = GeomAPI_Shape::FACE;
}
+ // issue #3031: skip topology if there is more convenient shape type presents in the
+ // same context as a result of this
+ bool isWholeResult = myParent && myParent->isWholeResultAllowed() && !aSubShape.get();
+ GeomAPI_Shape::ShapeType allowedType = GeomAPI_Shape::SHAPE;
+ if (isWholeResult) {
+ std::list<ResultPtr>::iterator aNewCont = aNewContexts.begin();
+ TopTools_ListIteratorOfListOfShape aNewValues(aValShapes);
+ for(; aNewCont != aNewContexts.end(); aNewCont++, aNewValues.Next()) {
+ if (aNewValues.Value().IsNull()) { // only for the whole context
+ GeomAPI_Shape::ShapeType aShapeType = (*aNewCont)->shape()->shapeType();
+ if (allowedType == GeomAPI_Shape::SHAPE) { // just set this one
+ allowedType = aShapeType;
+ } else {
+ GeomAPI_Shape::ShapeType anAllowed = allowedType;
+ if (anAllowed != aShapeType) { // select the best, nearest to the origin
+ GeomAPI_Shape::ShapeType anOldShapeType = aContext->shape()->shapeType();
+ GeomAPI_Shape::ShapeType aDeltaAllowed =
+ (GeomAPI_Shape::ShapeType)(anOldShapeType - anAllowed);
+ if (aDeltaAllowed < 0)
+ aDeltaAllowed = (GeomAPI_Shape::ShapeType)(-aDeltaAllowed);
+ GeomAPI_Shape::ShapeType aDeltaThis =
+ (GeomAPI_Shape::ShapeType)(anOldShapeType - aShapeType);
+ if (aDeltaThis < 0)
+ aDeltaThis = (GeomAPI_Shape::ShapeType)(-aDeltaThis);
+ if (aDeltaThis == aDeltaAllowed) { // equal distance to context, select complicated
+ if (anOldShapeType < anAllowed)
+ allowedType = aShapeType;
+ } else if (aDeltaAllowed > aDeltaThis) { // this wins
+ allowedType = aShapeType;
+ }
+ }
+ }
+ }
+ }
+ }
+
std::list<ResultPtr>::iterator aNewCont = aNewContexts.begin();
TopTools_ListIteratorOfListOfShape aNewValues(aValShapes);
bool aFirst = true; // first is set to this, next are appended to parent
if (aSkippedContext.count(*aNewCont))
continue;
+ if (isWholeResult && aNewValues.Value().IsNull())
+ if ((*aNewCont)->shape()->shapeType() != allowedType)
+ continue; // there is better result exists with the better shape type (issue #3031)
+
GeomShapePtr aValueShape;
if (!aNewValues.Value().IsNull()) {
aValueShape = std::make_shared<GeomAPI_Shape>();
}
if (aListShapeType != GeomAPI_Shape::SHAPE && aListShapeType != aShapeShapeType) {
// exception is for whole results selected
- if (!myParent || !myParent->isWholeResultAllowed() || aSubShape.get()) {
+ if (!isWholeResult) {
continue;
}
}