[PD] Fix Pad uptoshape and add unit test
This commit is contained in:
committed by
Chris Hennes
parent
d6e9be45bb
commit
22fbfeddc2
@@ -4231,10 +4231,12 @@ TopoShape& TopoShape::makeElementPrismUntil(const TopoShape& _base,
|
||||
BRepFeat_MakePrism PrismMaker;
|
||||
|
||||
// don't remove limits of concave face
|
||||
Base::Vector3d vCog;
|
||||
profile.getCenterOfGravity(vCog);
|
||||
gp_Pnt pCog(vCog.x, vCog.y, vCog.z);
|
||||
checkLimits = ! Part::Tools::isConcave(TopoDS::Face(__uptoface.getShape()), pCog , direction);
|
||||
if (checkLimits && __uptoface.shapeType(true) == TopAbs_FACE){
|
||||
Base::Vector3d vCog;
|
||||
profile.getCenterOfGravity(vCog);
|
||||
gp_Pnt pCog(vCog.x, vCog.y, vCog.z);
|
||||
checkLimits = ! Part::Tools::isConcave(TopoDS::Face(__uptoface.getShape()), pCog , direction);
|
||||
}
|
||||
|
||||
TopoShape _uptoface(__uptoface);
|
||||
if (checkLimits && _uptoface.shapeType(true) == TopAbs_FACE
|
||||
|
||||
@@ -211,6 +211,36 @@ class TestPad(unittest.TestCase):
|
||||
self.Doc.recompute()
|
||||
self.assertAlmostEqual(self.Pad.Shape.Volume, 2208.0963, places=4)
|
||||
|
||||
def testPadToShapeCase(self):
|
||||
self.Body = self.Doc.addObject('PartDesign::Body','Body')
|
||||
# Make first offset cube Pad
|
||||
self.PadSketch = self.Doc.addObject('Sketcher::SketchObject', 'SketchPad')
|
||||
self.Body.addObject(self.PadSketch)
|
||||
TestSketcherApp.CreateRectangleSketch(self.PadSketch, (0, 1), (1, 1))
|
||||
self.Doc.recompute()
|
||||
self.Pad = self.Doc.addObject("PartDesign::Pad", "Pad")
|
||||
self.Body.addObject(self.Pad)
|
||||
self.Pad.Profile = self.PadSketch
|
||||
self.Pad.Length = 1
|
||||
self.Doc.recompute()
|
||||
# Make second pad on different plane and pad to first
|
||||
self.PadSketch1 = self.Doc.addObject('Sketcher::SketchObject', 'SketchPad1')
|
||||
self.Body.addObject(self.PadSketch1)
|
||||
self.PadSketch1.MapMode = 'FlatFace'
|
||||
self.PadSketch1.AttachmentSupport = (self.Doc.XZ_Plane, [''])
|
||||
self.PadSketch1.AttachmentOffset.Rotation.Axis = App.Vector(0,1,0)
|
||||
self.PadSketch1.AttachmentOffset.Rotation.Angle = 0.436332 # 25°
|
||||
self.PadSketch1.AttachmentOffset.Base.z = 1
|
||||
self.Doc.recompute()
|
||||
TestSketcherApp.CreateRectangleSketch(self.PadSketch1, (1, 0), (1, 1))
|
||||
self.Doc.recompute()
|
||||
self.Pad1 = self.Doc.addObject("PartDesign::Pad", "Pad1")
|
||||
self.Body.addObject(self.Pad1)
|
||||
self.Pad1.Profile = self.PadSketch1
|
||||
self.Pad1.Type = 5
|
||||
self.Doc.recompute()
|
||||
self.assertAlmostEqual(self.Pad1.Shape.Volume, 2.58787, places=4)
|
||||
|
||||
def tearDown(self):
|
||||
#closing doc
|
||||
FreeCAD.closeDocument("PartDesignTestPad")
|
||||
|
||||
Reference in New Issue
Block a user