couple of tests and fix to avoid crash on selected edge

This commit is contained in:
Sergo
2017-03-17 02:21:41 -04:00
committed by wmayer
parent 13faa806e2
commit eda3620b71
2 changed files with 49 additions and 3 deletions

View File

@@ -1041,7 +1041,10 @@ Base::Vector3d ProfileBased::getProfileNormal() const {
}
else {
TopoDS_Shape shape = getVerifiedFace(true);
if(shape.ShapeType() == TopAbs_FACE) {
if (shape == TopoDS_Shape())
return SketchVector;
if (shape.ShapeType() == TopAbs_FACE) {
BRepAdaptor_Surface adapt(TopoDS::Face(shape));
double u = adapt.FirstUParameter() + (adapt.LastUParameter() - adapt.FirstUParameter())/2.;
double v = adapt.FirstVParameter() + (adapt.LastVParameter() - adapt.FirstVParameter())/2.;

View File

@@ -19,9 +19,9 @@
# USA *
#**************************************************************************
import FreeCAD, os, sys, unittest, Sketcher, PartDesign, TestSketcherApp
import FreeCAD, FreeCADGui, os, sys, unittest, Sketcher, PartDesign, TestSketcherApp
App = FreeCAD
Gui = FreeCADGui
#---------------------------------------------------------------------------
# define the test cases to test the FreeCAD Sketcher module
#---------------------------------------------------------------------------
@@ -44,3 +44,46 @@ class PartDesignPadTestCases(unittest.TestCase):
#closing doc
FreeCAD.closeDocument("PartDesignTest")
#print ("omit clos document for debuging")
class PartDesignRevolveTestCases(unittest.TestCase):
def setUp(self):
self.Doc = FreeCAD.newDocument("PartDesignTest")
def testRevolveFace(self):
self.Body1 = self.Doc.addObject('PartDesign::Body','Body')
self.Box1 = self.Doc.addObject('PartDesign::AdditiveBox','Box')
self.Body1.addObject(self.Box1)
self.Box1.Length=10.00
self.Box1.Width=10.00
self.Box1.Height=10.00
self.Doc.recompute()
self.Revolution = self.Doc.addObject("PartDesign::Revolution","Revolution")
self.Revolution.Profile = (self.Box1, ["Face6"])
self.Revolution.ReferenceAxis = (self.Doc.Y_Axis,[""])
self.Revolution.Angle = 180.0
self.Revolution.Reversed = 1
self.Body1.addObject(self.Revolution)
self.Doc.recompute()
self.failUnless(len(self.Revolution.Shape.Faces) == 10)
def testGrooveFace(self):
self.Body2 = self.Doc.addObject('PartDesign::Body','Body')
self.Box2 = self.Doc.addObject('PartDesign::AdditiveBox','Box')
self.Body2.addObject(self.Box2)
self.Box2.Length=10.00
self.Box2.Width=10.00
self.Box2.Height=10.00
self.Doc.recompute()
self.Groove = self.Doc.addObject("PartDesign::Groove","Groove")
self.Groove.Profile = (self.Box2, ["Face6"])
self.Groove.ReferenceAxis = (self.Doc.X_Axis,[""])
self.Groove.Angle = 180.0
self.Groove.Reversed = 1
self.Body2.addObject(self.Groove)
self.Doc.recompute()
self.failUnless(len(self.Groove.Shape.Faces) == 5)
def tearDown(self):
#closing doc
# FreeCAD.closeDocument("PartDesignTest")
print ("omit closing document for debugging")