Part: Offset2D: fix save-load instability

Fixes #2699
It was found out that when direction of normal found by FindPlane
depends on if we are using result of offset directly, or after copying.

The fix (workaround) is to copy offset result inside  offset routine, so
that no unstable behavior makes its way to the user.
This commit is contained in:
DeepSOIC 2016-09-18 18:45:04 +03:00
parent 15c368d982
commit 47c745f228

View File

@ -2129,7 +2129,10 @@ TopoDS_Shape TopoShape::makeOffset2D(double offset, short joinType, bool fill, b
throw Base::Exception("BRepOffsetAPI_MakeOffset has crashed! (Unknown exception caught)"); throw Base::Exception("BRepOffsetAPI_MakeOffset has crashed! (Unknown exception caught)");
} }
TopoDS_Shape offsetWire = mkOffset.Shape(); //Copying shape to fix strange orientation behavior, OCC7.0.0. See bug #2699
// http://www.freecadweb.org/tracker/view.php?id=2699
TopoDS_Shape offsetWire = BRepBuilderAPI_Copy(mkOffset.Shape()).Shape();
if (offsetWire.IsNull()) if (offsetWire.IsNull())
throw Base::Exception("makeOffset2D: result of offset is null!"); throw Base::Exception("makeOffset2D: result of offset is null!");
ShapeExtend_Explorer xp; //using this explorer allows to avoid checking output type ShapeExtend_Explorer xp; //using this explorer allows to avoid checking output type
@ -2181,7 +2184,9 @@ TopoDS_Shape TopoShape::makeOffset2D(double offset, short joinType, bool fill, b
throw Base::Exception("BRepOffsetAPI_MakeOffset has crashed! (Unknown exception caught)"); throw Base::Exception("BRepOffsetAPI_MakeOffset has crashed! (Unknown exception caught)");
} }
offsetWire = mkOffset.Shape(); //Copying shape to fix strange orientation behavior, OCC7.0.0. See bug #2699
// http://www.freecadweb.org/tracker/view.php?id=2699
offsetWire = BRepBuilderAPI_Copy(mkOffset.Shape()).Shape();
} else { } else {
offsetWire = sourceWire; offsetWire = sourceWire;
} }
@ -2320,13 +2325,13 @@ TopoDS_Shape TopoShape::makeOffset2D(double offset, short joinType, bool fill, b
mkWire.Build(); mkWire.Build();
wires.push_front(TopoDS::Wire(mkWire.Wire().Reversed())); //not sure, why need reversing here. Found by trial-and-error wires.push_front(mkWire.Wire());
largestWire = &wires.front(); largestWire = &wires.front();
} }
//make the face //make the face
//TODO: replace all this reverseness alchemy with a common direction-tolerant face-with-holes-making code //TODO: replace all this reverseness alchemy with a common direction-tolerant face-with-holes-making code
BRepBuilderAPI_MakeFace mkFace(*largestWire); BRepBuilderAPI_MakeFace mkFace(TopoDS::Wire(offset < 0 ? (*largestWire) : (*largestWire).Reversed()));
for(TopoDS_Wire &w : wires){ for(TopoDS_Wire &w : wires){
if (&w != largestWire) if (&w != largestWire)
mkFace.Add(TopoDS::Wire(w.Reversed())); mkFace.Add(TopoDS::Wire(w.Reversed()));