From df7c676da5e1cd0bb0f39262c829ad22a82d232d Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 25 Oct 2018 15:00:48 +0300 Subject: [PATCH] Fix the order of intersectors in selection names generation --- src/FeaturesPlugin/Test/TestExtrusion.py | 33 ++++++------------------ src/Selector/Selector_Selector.cpp | 8 +++--- 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/src/FeaturesPlugin/Test/TestExtrusion.py b/src/FeaturesPlugin/Test/TestExtrusion.py index 23494e923..158c60feb 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion.py +++ b/src/FeaturesPlugin/Test/TestExtrusion.py @@ -85,24 +85,16 @@ aSession.finishOperation() #========================================================================= # Make extrusion on circle #========================================================================= -# Build shape from sketcher results -aCircleSketchResult = aCircleSketchFeature.firstResult() -aCircleSketchEdges = modelAPI_ResultConstruction(aCircleSketchResult).shape() -origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")).dir() -aCircleSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aCircleSketchEdges, aCircleSketchFaces) -assert (len(aCircleSketchFaces) > 0) -assert (aCircleSketchFaces[0] is not None) +# Build face from sketcher results +aCircleSketchResult = modelAPI_ResultConstruction(aCircleSketchFeature.firstResult()) +assert (aCircleSketchResult.facesNum() > 0) # Create extrusion aSession.startOperation() anExtrusionFt = aPart.addFeature("Extrusion") assert (anExtrusionFt.getKind() == "Extrusion") # selection type FACE=4 anExtrusionFt.selectionList("base").append( - aCircleSketchResult, aCircleSketchFaces[0]) + aCircleSketchResult, aCircleSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("BySizes") anExtrusionFt.real("to_size").setValue(50) anExtrusionFt.real("from_size").setValue(0) @@ -147,8 +139,7 @@ aSession.startOperation() anExtrusionFt = aPart.addFeature("Extrusion") assert (anExtrusionFt.getKind() == "Extrusion") # selection type FACE=4 -anExtrusionFt.selectionList("base").append( - aCircleSketchResult, aCircleSketchFaces[0]) +anExtrusionFt.selectionList("base").append(aCircleSketchResult, aCircleSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("ByPlanesAndOffsets") anExtrusionFt.real("to_size").setValue(0) #TODO: remove anExtrusionFt.real("from_size").setValue(0) #TODO: remove @@ -213,20 +204,13 @@ aLineEEndPoint.setValue(0., -50.) aSession.finishOperation() # Extrude clamp -aClampSketchResult = aClampSketchFeature.firstResult() -aClampSketchEdges = modelAPI_ResultConstruction(aClampSketchResult).shape() -origin = geomDataAPI_Point(aClampSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aClampSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aClampSketchFeature.attribute("Norm")).dir() -aClampSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aClampSketchEdges, aClampSketchFaces) +aClampSketchResult = modelAPI_ResultConstruction(aClampSketchFeature.firstResult()) aSession.startOperation() aClampExtrusionFt = aPart.addFeature("Extrusion") assert (aClampExtrusionFt.getKind() == "Extrusion") # selection type FACE=4 aClampExtrusionFt.selectionList("base").append( - aClampSketchResult, aClampSketchFaces[0]) + aClampSketchResult, aClampSketchResult.face(0)) aClampExtrusionFt.string("CreationMethod").setValue("BySizes") aClampExtrusionFt.real("to_size").setValue(70) aClampExtrusionFt.real("from_size").setValue(0) @@ -245,8 +229,7 @@ aSession.startOperation() anExtrusionFt = aPart.addFeature("Extrusion") assert (anExtrusionFt.getKind() == "Extrusion") # selection type FACE=4 -anExtrusionFt.selectionList("base").append( - aCircleSketchResult, aCircleSketchFaces[0]) +anExtrusionFt.selectionList("base").append(aCircleSketchResult, aCircleSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("ByPlanesAndOffsets") anExtrusionFt.real("to_size").setValue(0) #TODO: remove anExtrusionFt.real("from_size").setValue(0) #TODO: remove diff --git a/src/Selector/Selector_Selector.cpp b/src/Selector/Selector_Selector.cpp index d4b1f2319..8fe3532ef 100644 --- a/src/Selector/Selector_Selector.cpp +++ b/src/Selector/Selector_Selector.cpp @@ -284,7 +284,7 @@ bool Selector_Selector::select(const TopoDS_Shape theContext, const TopoDS_Shape // try to find the shape of the higher level type in the context shape bool aFacesTried = false; // for identification of vertices, faces are tried, then edges TopoDS_ListOfShape aLastCommon; // to store the commons not good, but may be used for weak - TopTools_MapOfShape aLastIntersectors; + TopoDS_ListOfShape aLastIntersectors; while(aSelectionType != TopAbs_FACE || !aFacesTried) { if (aSelectionType == TopAbs_FACE) { if (theValue.ShapeType() != TopAbs_VERTEX) @@ -311,7 +311,7 @@ bool Selector_Selector::select(const TopoDS_Shape theContext, const TopoDS_Shape if (aCommon.Extent() == 1 && aCommon.First().IsSame(theValue)) { // name the intersectors mySubSelList.clear(); - TopTools_MapOfShape::Iterator anInt(anIntersectors); + TopoDS_ListOfShape::Iterator anInt(anIntList); for (; anInt.More(); anInt.Next()) { if (!selectBySubSelector(theContext, anInt.Value())) { break; // if some selector is failed, stop and search another solution @@ -323,7 +323,7 @@ bool Selector_Selector::select(const TopoDS_Shape theContext, const TopoDS_Shape } } else if (aCommon.Extent() > 1 && aLastCommon.IsEmpty()) { aLastCommon = aCommon; - aLastIntersectors = anIntersectors; + aLastIntersectors = anIntList; } } @@ -369,7 +369,7 @@ bool Selector_Selector::select(const TopoDS_Shape theContext, const TopoDS_Shape if (myWeakIndex != -1) { // name the intersectors mySubSelList.clear(); - TopTools_MapOfShape::Iterator anInt(aLastIntersectors); + TopoDS_ListOfShape::Iterator anInt(aLastIntersectors); for (; anInt.More(); anInt.Next()) { if (!selectBySubSelector(theContext, anInt.Value())) { break; // if some selector is failed, stop and search another solution -- 2.39.2