Toponaming: Refactor refine to its own FeatureRefine class
This commit is contained in:
@@ -26,7 +26,7 @@ from math import pi, tan, cos, acos
|
||||
import FreeCAD
|
||||
Quantity = FreeCAD.Units.Quantity # FIXME from FreeCAD.Units import Quantity doesn't work
|
||||
from FreeCAD import Vector
|
||||
from Part import makeCircle, Precision
|
||||
from Part import makeCircle, Precision, Solid
|
||||
import InvoluteGearFeature
|
||||
|
||||
FIXTURE_PATH = pathlib.Path(__file__).parent / "Fixtures"
|
||||
@@ -263,7 +263,7 @@ class TestInvoluteGear(unittest.TestCase):
|
||||
pocket.Reversed = True # need to "pocket upwards" into the cylinder
|
||||
pocket.Type = 'ThroughAll'
|
||||
self.assertSuccessfulRecompute()
|
||||
self.assertSolid(pocket.Shape)
|
||||
self.assertSolid(Solid(pocket.Shape)) # Can be a compound, make that into a Solid if needed.
|
||||
|
||||
def testRecomputeExternalGearFromV020(self):
|
||||
FreeCAD.closeDocument(self.Doc.Name) # this was created in setUp(self)
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#***************************************************************************
|
||||
|
||||
import unittest
|
||||
import math
|
||||
|
||||
import FreeCAD
|
||||
import TestSketcherApp
|
||||
@@ -72,26 +73,14 @@ class TestMultiTransform(unittest.TestCase):
|
||||
# Make first offset cube Pad
|
||||
PadSketch = Doc.addObject('Sketcher::SketchObject', 'SketchPad')
|
||||
Body.addObject(PadSketch)
|
||||
TestSketcherApp.CreateRectangleSketch(PadSketch, (0, 0), (10, 10))
|
||||
xw = yw = zw = 10
|
||||
TestSketcherApp.CreateRectangleSketch(PadSketch, (0, 0), (xw, yw))
|
||||
Doc.recompute()
|
||||
Pad = Doc.addObject("PartDesign::Pad", "Pad")
|
||||
Body.addObject(Pad)
|
||||
Pad.Profile = PadSketch
|
||||
Pad.Length = 10
|
||||
Pad.Length = zw
|
||||
Doc.recompute()
|
||||
|
||||
PadSketch2 = Doc.addObject('Sketcher::SketchObject', 'SketchPad')
|
||||
PadSketch2.AttachmentSupport = (Pad, ('Face6',))
|
||||
Body.addObject(PadSketch2)
|
||||
TestSketcherApp.CreateRectangleSketch(PadSketch, (9, 9), (1, 1))
|
||||
Doc.recompute()
|
||||
Pad2 = Doc.addObject("PartDesign::Pad", "Pad2")
|
||||
Body.addObject(Pad2)
|
||||
Pad2.Profile = PadSketch2
|
||||
Pad2.Length = 10
|
||||
Doc.recompute()
|
||||
|
||||
|
||||
MultiTransform = Doc.addObject("PartDesign::MultiTransform","MultiTransform")
|
||||
Doc.recompute()
|
||||
MultiTransform.Originals = [Pad]
|
||||
@@ -100,27 +89,43 @@ class TestMultiTransform(unittest.TestCase):
|
||||
Doc.recompute()
|
||||
Mirrored = Doc.addObject("PartDesign::Mirrored","Mirrored")
|
||||
Mirrored.MirrorPlane = (Doc.getObject('XY_Plane'), [''])
|
||||
Mirrored.Refine = True
|
||||
Body.addObject(Mirrored)
|
||||
Mirrored2 = Doc.addObject("PartDesign::Mirrored","Mirrored")
|
||||
Mirrored2.MirrorPlane = (Doc.getObject('XZ_Plane'), [""])
|
||||
Mirrored2.Refine = True
|
||||
Body.addObject(Mirrored2)
|
||||
MultiTransform.Transformations = [Mirrored,Mirrored2]
|
||||
MultiTransform.Refine = True
|
||||
Doc.recompute()
|
||||
Fillet = Doc.addObject("PartDesign::Fillet","Fillet")
|
||||
Fillet.Base = (MultiTransform, ['Face'+str(i+1) for i in range(2)])
|
||||
Fillet.Radius = 3
|
||||
Fillet.Base = (MultiTransform, [ "Face1", "Face2" ])
|
||||
radius = 3
|
||||
Fillet.Radius = radius
|
||||
Body.addObject(Fillet)
|
||||
# Add a fillet here.
|
||||
# Now do that copy thing...
|
||||
# Broken out calculation of volume with two adjacent filleted faces = 5 long edges, 2 short edges,
|
||||
# 2 fully rounded corners and 4 corners with only 2 fillets meeting
|
||||
cubeVolume = xw * yw * zw * 2 * 2 # Mirrored and mirrored again.
|
||||
filletOuter = radius ** 2 * ( xw - radius * 2 ) # Volume of the rect prisms the fillets are in.
|
||||
filletCorner = radius ** 3 # Volume of the rect prism corners
|
||||
qRoundArea = math.pi * radius ** 2 / 4 # Area of the quarter round fillet profile
|
||||
filletPrism = qRoundArea * ( xw - radius * 2 ) # Volume of fillet minus corners
|
||||
fillet3Corner = math.pi * radius ** 3 * 4 / 3 / 8 # Volume of a fully rounded corner ( Sphere / 8 )
|
||||
fillet2Corner = radius ** 2 * 2 # Volume of corner with two fillets intersecting
|
||||
fillet1Corner = math.pi * radius ** 2 / 4 * radius # Volume of corner with stopped single fillet
|
||||
extraFillet = qRoundArea * xw # extra fillet in a mirrored direction
|
||||
filletOuterExt = radius ** 2 * 10 # extra rect prim surrounding fillet
|
||||
rectBox = cubeVolume - (4 + 3) * (filletOuter + filletCorner ) - 5 * filletOuterExt + filletCorner
|
||||
fillets = ( 4 + 3 ) * filletPrism + 5 * extraFillet + fillet3Corner * 2 + fillet2Corner * 4 + fillet1Corner * 0
|
||||
volume = rectBox + fillets
|
||||
# Act
|
||||
Link = Doc.addObject('App::Link','Link001')
|
||||
Link.setLink(Doc.Body)
|
||||
Link.Label='Body001'
|
||||
# Act
|
||||
# There are properties on those objects with values
|
||||
# Link.addProperty("App::PropertyInteger","test2","Table2")
|
||||
Doc.recompute()
|
||||
# Assert
|
||||
self.assertAlmostEqual(Body.Shape.Volume, 990)
|
||||
self.assertAlmostEqual(Link.Shape.Volume, 990)
|
||||
self.assertAlmostEqual(abs(Body.Shape.Volume), volume, 6)
|
||||
self.assertAlmostEqual(abs(Link.Shape.Volume), volume, 6)
|
||||
|
||||
def testMultiTransformBody(self):
|
||||
pass
|
||||
@@ -132,5 +137,5 @@ class TestMultiTransform(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
#closing doc
|
||||
FreeCAD.closeDocument("PartDesignTestMultiTransform")
|
||||
#print ("omit closing document for debugging")
|
||||
# print ("omit closing document for debugging")
|
||||
|
||||
|
||||
@@ -785,6 +785,7 @@ class TestTopologicalNamingProblem(unittest.TestCase):
|
||||
body = self.Doc.addObject("PartDesign::Body", "Body")
|
||||
box = self.Doc.addObject("PartDesign::AdditiveBox", "Box")
|
||||
body.addObject(box)
|
||||
self.Doc.recompute()
|
||||
sketch = self.Doc.addObject("Sketcher::SketchObject", "Sketch")
|
||||
sketch.AttachmentSupport = (box, "Face6")
|
||||
sketch.MapMode = "FlatFace"
|
||||
@@ -803,10 +804,9 @@ class TestTopologicalNamingProblem(unittest.TestCase):
|
||||
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 32)
|
||||
self.assertEqual(body.Shape.ElementMapSize, 32)
|
||||
self.assertEqual(sketch.Shape.ElementMapSize, 2)
|
||||
self.assertEqual(hole.Shape.ElementMapSize, 32)
|
||||
# self.assertNotEqual(hole.Shape.ElementReverseMap['Vertex1'],"Vertex1") # NewName, not OldName
|
||||
self.assertNotEqual(body.Shape.ElementReverseMap['Vertex1'],"Vertex1") # NewName, not OldName
|
||||
self.assertEqual(
|
||||
self.countFacesEdgesVertexes(hole.Shape.ElementReverseMap), (7, 15, 10)
|
||||
self.countFacesEdgesVertexes(body.Shape.ElementReverseMap), (7, 15, 10)
|
||||
)
|
||||
volume = 1000 - 10 * math.pi * 3 * 3
|
||||
self.assertAlmostEqual(hole.Shape.Volume, volume)
|
||||
|
||||
Reference in New Issue
Block a user