Skip to content

Commit

Permalink
Merge pull request #285 from DeepSOIC/PartOffset2D_fix1
Browse files Browse the repository at this point in the history
Part: Offset2D: fix save-load instability (bug #2699)
  • Loading branch information
yorikvanhavre committed Sep 19, 2016
2 parents 15c368d + 47c745f commit c866df1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Mod/Part/App/TopoShape.cpp
Expand Up @@ -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)");
}

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())
throw Base::Exception("makeOffset2D: result of offset is null!");
ShapeExtend_Explorer xp; //using this explorer allows to avoid checking output type
Expand Down Expand Up @@ -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)");
}

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 {
offsetWire = sourceWire;
}
Expand Down Expand Up @@ -2320,13 +2325,13 @@ TopoDS_Shape TopoShape::makeOffset2D(double offset, short joinType, bool fill, b

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();
}

//make the face
//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){
if (&w != largestWire)
mkFace.Add(TopoDS::Wire(w.Reversed()));
Expand Down

0 comments on commit c866df1

Please sign in to comment.