diff --git a/src/Mod/Part/App/modelRefine.cpp b/src/Mod/Part/App/modelRefine.cpp index a51135f3e4..ada41fe931 100644 --- a/src/Mod/Part/App/modelRefine.cpp +++ b/src/Mod/Part/App/modelRefine.cpp @@ -60,6 +60,7 @@ # include # include # include +# include # include # include # include @@ -1042,6 +1043,7 @@ bool FaceUniter::process() typeObjects.push_back(&getBSplineObject()); //add more face types. + bool checkFinalShell = false; ModelRefine::FaceTypeSplitter splitter; splitter.addShell(workShell); std::vector::iterator typeIt; @@ -1072,7 +1074,7 @@ bool FaceUniter::process() // the created face should have the same orientation as the input faces const FaceVectorType& faces = adjacencySplitter.getGroup(adjacentIndex); if (!faces.empty() && newFace.Orientation() != faces[0].Orientation()) { - newFace.Orientation(faces[0].Orientation()); + checkFinalShell = true; } facesToSew.push_back(newFace); if (facesToRemove.capacity() <= facesToRemove.size() + adjacencySplitter.getGroup(adjacentIndex).size()) @@ -1154,6 +1156,19 @@ bool FaceUniter::process() faceFixer.Perform(); } workShell = TopoDS::Shell(edgeFuse.Shape()); + + // A difference of orientation between original and fused faces was previously detected + if (checkFinalShell) { + ShapeAnalysis_Shell check; + check.LoadShells(workShell); + if (!check.HasFreeEdges()) { + // the shell is a solid, make sure that volume is positive + GProp_GProps props; + BRepGProp::VolumeProperties(workShell, props); + if (props.Mass() < 0) + workShell = TopoDS::Shell(workShell.Reversed()); + } + } // update the list of modifications TopTools_DataMapOfShapeShape faceMap; edgeFuse.Faces(faceMap);