FreeCAD

Форк
0
/
TestPathOpDeburr.py 
165 строк · 6.7 Кб
1
# -*- coding: utf-8 -*-
2
# ***************************************************************************
3
# *   Copyright (c) 2018 sliptonic <shopinthewoods@gmail.com>               *
4
# *                                                                         *
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.                                 *
10
# *                                                                         *
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.                  *
15
# *                                                                         *
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  *
19
# *   USA                                                                   *
20
# *                                                                         *
21
# ***************************************************************************
22

23
import Path
24
import Path.Op.Deburr as PathDeburr
25
import Path.Tool.Bit as PathToolBit
26
import Tests.PathTestUtils as PathTestUtils
27

28
Path.Log.setLevel(Path.Log.Level.INFO, Path.Log.thisModule())
29
# Path.Log.trackModule(Path.Log.thisModule())
30

31

32
class MockToolBit(object):
33
    def __init__(self, name="t1", diameter=5.0):
34
        self.Diameter = diameter
35
        self.FlatRadius = 0
36
        self.CuttingEdgeAngle = 60
37

38

39
class TestPathOpDeburr(PathTestUtils.PathTestBase):
40
    def test00(self):
41
        """Verify chamfer depth and offset for an end mill."""
42
        tool = MockToolBit()
43
        tool.Diameter = 20
44
        tool.FlatRadius = 0
45
        tool.CuttingEdgeAngle = 180
46

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)
51

52
        # legacy tools - no problem, same result
53
        tool.CuttingEdgeAngle = 0
54

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)
59

60
    def test01(self):
61
        """Verify chamfer depth and offset for a 90 deg v-bit."""
62
        tool = MockToolBit()
63
        tool.FlatRadius = 0
64
        tool.CuttingEdgeAngle = 90
65

66
        (depth, offset, __, info) = PathDeburr.toolDepthAndOffset(1, 0, tool, True)
67
        self.assertRoughly(1, depth)
68
        self.assertRoughly(0, offset)
69
        self.assertFalse(info)
70

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)
75

76
    def test02(self):
77
        """Verify chamfer depth and offset for a 90 deg v-bit with non 0 flat radius."""
78
        tool = MockToolBit()
79
        tool.FlatRadius = 0.3
80
        tool.CuttingEdgeAngle = 90
81

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)
86

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)
91

92
    def test03(self):
93
        """Verify chamfer depth and offset for a 60 deg v-bit with non 0 flat radius."""
94
        tool = MockToolBit()
95
        tool.FlatRadius = 0.1
96
        tool.CuttingEdgeAngle = 60
97

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)
102

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)
107

108
    def test04(self):
109
        """Verify chamfer depth and offset for a 30 deg v-bit with non 0 flat radius."""
110
        tool = MockToolBit()
111
        tool.FlatRadius = 0.1
112
        tool.CuttingEdgeAngle = 30
113

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)
118

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)
123

124
    def test10(self):
125
        """Verify missing cutting edge angle info prints only once."""
126

127
        class FakeEndmill(object):
128
            def __init__(self, dia):
129
                self.Diameter = dia
130

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)
144

145
    def test11(self):
146
        """Verify missing tip diameter info prints only once."""
147

148
        class FakePointyBit(object):
149
            def __init__(self, dia, angle):
150
                self.Diameter = dia
151
                self.CuttingEdgeAngle = angle
152

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)
166

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.