Skip to content

Commit

Permalink
couple of tests and fix to avoid crash on selected edge
Browse files Browse the repository at this point in the history
  • Loading branch information
usakhelo authored and wwmayer committed Mar 18, 2017
1 parent d23e603 commit 02166ed
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/Mod/PartDesign/App/FeatureSketchBased.cpp
Expand Up @@ -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.;
Expand Down
47 changes: 45 additions & 2 deletions src/Mod/PartDesign/TestPartDesignApp.py
Expand Up @@ -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
#---------------------------------------------------------------------------
Expand All @@ -44,3 +44,46 @@ def tearDown(self):
#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")

0 comments on commit 02166ed

Please sign in to comment.