PartDesign: Add method suggesting Revolution Reversed property so that material is always added to the support
This commit is contained in:
parent
8eef02111d
commit
ccf15f968c
|
@ -34,6 +34,8 @@
|
||||||
# include <BRepAlgoAPI_Fuse.hxx>
|
# include <BRepAlgoAPI_Fuse.hxx>
|
||||||
# include <Precision.hxx>
|
# include <Precision.hxx>
|
||||||
# include <gp_Lin.hxx>
|
# include <gp_Lin.hxx>
|
||||||
|
# include <GProp_GProps.hxx>
|
||||||
|
# include <BRepGProp.hxx>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Base/Axis.h>
|
#include <Base/Axis.h>
|
||||||
|
@ -75,9 +77,9 @@ App::DocumentObjectExecReturn *Revolution::execute(void)
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
double angle = Angle.getValue();
|
double angle = Angle.getValue();
|
||||||
if (angle < Precision::Confusion())
|
if (angle < Precision::Confusion())
|
||||||
return new App::DocumentObjectExecReturn("Angle of groove too small");
|
return new App::DocumentObjectExecReturn("Angle of revolution too small");
|
||||||
if (angle > 360.0)
|
if (angle > 360.0)
|
||||||
return new App::DocumentObjectExecReturn("Angle of groove too large");
|
return new App::DocumentObjectExecReturn("Angle of revolution too large");
|
||||||
|
|
||||||
angle = Base::toRadians<double>(angle);
|
angle = Base::toRadians<double>(angle);
|
||||||
// Reverse angle if selected
|
// Reverse angle if selected
|
||||||
|
@ -205,4 +207,40 @@ App::DocumentObjectExecReturn *Revolution::execute(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Revolution::suggestReversed(void) const
|
||||||
|
{
|
||||||
|
// suggest a value for Reversed flag so that material is added to the support
|
||||||
|
try {
|
||||||
|
Part::Part2DObject* sketch = getVerifiedSketch();
|
||||||
|
std::vector<TopoDS_Wire> wires = getSketchWires();
|
||||||
|
TopoDS_Shape sketchshape = makeFace(wires);
|
||||||
|
|
||||||
|
Base::Vector3f b = Base.getValue();
|
||||||
|
Base::Vector3f v = Axis.getValue();
|
||||||
|
|
||||||
|
// get centre of gravity of the sketch face
|
||||||
|
GProp_GProps props;
|
||||||
|
BRepGProp::SurfaceProperties(sketchshape, props);
|
||||||
|
gp_Pnt cog = props.CentreOfMass();
|
||||||
|
Base::Vector3f p_cog(cog.X(), cog.Y(), cog.Z());
|
||||||
|
// get direction to cog from its projection on the revolve axis
|
||||||
|
Base::Vector3f perp_dir = p_cog - p_cog.Perpendicular(b, v);
|
||||||
|
// get cross product of projection direction with revolve axis direction
|
||||||
|
Base::Vector3f cross = v % perp_dir;
|
||||||
|
// get sketch vector pointing away from support material
|
||||||
|
Base::Placement SketchPos = sketch->Placement.getValue();
|
||||||
|
Base::Rotation SketchOrientation = SketchPos.getRotation();
|
||||||
|
Base::Vector3d SketchNormal(0,0,1);
|
||||||
|
SketchOrientation.multVec(SketchNormal,SketchNormal);
|
||||||
|
// simply convert double to float
|
||||||
|
Base::Vector3f norm(SketchNormal.x, SketchNormal.y, SketchNormal.z);
|
||||||
|
|
||||||
|
// return true if the angle between norm and cross is acute
|
||||||
|
return norm * cross < 0.f;
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,8 @@ public:
|
||||||
return "PartDesignGui::ViewProviderRevolution";
|
return "PartDesignGui::ViewProviderRevolution";
|
||||||
}
|
}
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
bool suggestReversed(void) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace PartDesign
|
} //namespace PartDesign
|
||||||
|
|
Loading…
Reference in New Issue
Block a user