2
# ***************************************************************************
3
# * Copyright (c) 2018 sliptonic <shopinthewoods@gmail.com> *
5
# * This program is free software; you can redistribute it and/or modify *
6
# * it under the terms of the GNU Lesser General Public License (LGPL) *
7
# * as published by the Free Software Foundation; either version 2 of *
8
# * the License, or (at your option) any later version. *
9
# * for detail see the LICENCE text file. *
11
# * This program is distributed in the hope that it will be useful, *
12
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
# * GNU Library General Public License for more details. *
16
# * You should have received a copy of the GNU Library General Public *
17
# * License along with this program; if not, write to the Free Software *
18
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
21
# ***************************************************************************
24
import Path.Op.Deburr as PathDeburr
25
import Path.Tool.Bit as PathToolBit
26
import Tests.PathTestUtils as PathTestUtils
28
Path.Log.setLevel(Path.Log.Level.INFO, Path.Log.thisModule())
29
# Path.Log.trackModule(Path.Log.thisModule())
32
class MockToolBit(object):
33
def __init__(self, name="t1", diameter=5.0):
34
self.Diameter = diameter
36
self.CuttingEdgeAngle = 60
39
class TestPathOpDeburr(PathTestUtils.PathTestBase):
41
"""Verify chamfer depth and offset for an end mill."""
45
tool.CuttingEdgeAngle = 180
47
(depth, offset, __, info) = PathDeburr.toolDepthAndOffset(1, 0.01, tool, True)
48
self.assertRoughly(0.01, depth)
49
self.assertRoughly(9, offset)
50
self.assertFalse(info)
52
# legacy tools - no problem, same result
53
tool.CuttingEdgeAngle = 0
55
(depth, offset, __, info) = PathDeburr.toolDepthAndOffset(1, 0.01, tool, True)
56
self.assertRoughly(0.01, depth)
57
self.assertRoughly(9, offset)
58
self.assertFalse(info)
61
"""Verify chamfer depth and offset for a 90 deg v-bit."""
64
tool.CuttingEdgeAngle = 90
66
(depth, offset, __, info) = PathDeburr.toolDepthAndOffset(1, 0, tool, True)
67
self.assertRoughly(1, depth)
68
self.assertRoughly(0, offset)
69
self.assertFalse(info)
71
(depth, offset, __, info) = PathDeburr.toolDepthAndOffset(1, 0.2, tool, True)
72
self.assertRoughly(1.2, depth)
73
self.assertRoughly(0.2, offset)
74
self.assertFalse(info)
77
"""Verify chamfer depth and offset for a 90 deg v-bit with non 0 flat radius."""
80
tool.CuttingEdgeAngle = 90
82
(depth, offset, __, info) = PathDeburr.toolDepthAndOffset(1, 0, tool, True)
83
self.assertRoughly(1, depth)
84
self.assertRoughly(0.3, offset)
85
self.assertFalse(info)
87
(depth, offset, __, info) = PathDeburr.toolDepthAndOffset(2, 0.2, tool, True)
88
self.assertRoughly(2.2, depth)
89
self.assertRoughly(0.5, offset)
90
self.assertFalse(info)
93
"""Verify chamfer depth and offset for a 60 deg v-bit with non 0 flat radius."""
96
tool.CuttingEdgeAngle = 60
98
(depth, offset, __, info) = PathDeburr.toolDepthAndOffset(1, 0.5, tool, True)
99
self.assertRoughly(2.232051, depth)
100
self.assertRoughly(0.388675, offset)
101
self.assertFalse(info)
103
(depth, offset, __, info) = PathDeburr.toolDepthAndOffset(3, 1, tool, True)
104
self.assertRoughly(6.196153, depth)
105
self.assertRoughly(0.677350, offset)
106
self.assertFalse(info)
109
"""Verify chamfer depth and offset for a 30 deg v-bit with non 0 flat radius."""
111
tool.FlatRadius = 0.1
112
tool.CuttingEdgeAngle = 30
114
(depth, offset, __, info) = PathDeburr.toolDepthAndOffset(1, 0.5, tool, True)
115
self.assertRoughly(4.232051, depth)
116
self.assertRoughly(0.233975, offset)
117
self.assertFalse(info)
119
(depth, offset, __, info) = PathDeburr.toolDepthAndOffset(3, 1, tool, True)
120
self.assertRoughly(12.196155, depth)
121
self.assertRoughly(0.367949, offset)
122
self.assertFalse(info)
125
"""Verify missing cutting edge angle info prints only once."""
127
class FakeEndmill(object):
128
def __init__(self, dia):
131
tool = FakeEndmill(10)
132
(depth, offset, __, info) = PathDeburr.toolDepthAndOffset(1, 0.1, tool, True)
133
self.assertRoughly(0.1, depth)
134
self.assertRoughly(4, offset)
135
self.assertTrue(info)
136
(depth, offset, __, info) = PathDeburr.toolDepthAndOffset(1, 0.1, tool, not info)
137
self.assertRoughly(0.1, depth)
138
self.assertRoughly(4, offset)
139
self.assertTrue(info)
140
(depth, offset, __, info) = PathDeburr.toolDepthAndOffset(1, 0.1, tool, not info)
141
self.assertRoughly(0.1, depth)
142
self.assertRoughly(4, offset)
143
self.assertTrue(info)
146
"""Verify missing tip diameter info prints only once."""
148
class FakePointyBit(object):
149
def __init__(self, dia, angle):
151
self.CuttingEdgeAngle = angle
153
tool = FakePointyBit(10, 90)
154
(depth, offset, __, info) = PathDeburr.toolDepthAndOffset(1, 0.1, tool, True)
155
self.assertRoughly(1.1, depth)
156
self.assertRoughly(0.1, offset)
157
self.assertTrue(info)
158
(depth, offset, __, info) = PathDeburr.toolDepthAndOffset(1, 0.1, tool, not info)
159
self.assertRoughly(1.1, depth)
160
self.assertRoughly(0.1, offset)
161
self.assertTrue(info)
162
(depth, offset, __, info) = PathDeburr.toolDepthAndOffset(1, 0.1, tool, not info)
163
self.assertRoughly(1.1, depth)
164
self.assertRoughly(0.1, offset)
165
self.assertTrue(info)