Skip to content

Commit

Permalink
[PD] Check for reversal in PartDesign::Feature::getSolid()
Browse files Browse the repository at this point in the history
Fixes FreeCAD#6584.

Under certain circumstances the created `TopoDS_Solid`s can be inverted. For
issue FreeCAD#6584, this happened when creating PolarPattern.
  • Loading branch information
AjinkyaDahale committed Mar 28, 2022
1 parent 5974abe commit 37589a0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Mod/PartDesign/App/Feature.cpp
Expand Up @@ -25,6 +25,7 @@
#ifndef _PreComp_
# include <BRep_Tool.hxx>
# include <BRepBuilderAPI_MakeFace.hxx>
# include <BRepGProp.hxx>
# include <gp_Pln.hxx>
# include <gp_Pnt.hxx>
# include <Standard_Failure.hxx>
Expand Down Expand Up @@ -73,7 +74,15 @@ TopoDS_Shape Feature::getSolid(const TopoDS_Shape& shape)
TopExp_Explorer xp;
xp.Init(shape,TopAbs_SOLID);
if (xp.More()) {
return xp.Current();
TopoDS_Shape solid = xp.Current();

// It can happen that a solid is flipped. Reverse if it happens.
GProp_GProps props;
BRepGProp::VolumeProperties(solid, props);
if (props.Mass() < 0)
solid.Reverse();

return solid;
}

return TopoDS_Shape();
Expand Down

0 comments on commit 37589a0

Please sign in to comment.