-
Notifications
You must be signed in to change notification settings - Fork 45
/
test_TColgp.py
144 lines (127 loc) · 4.13 KB
/
test_TColgp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# This file is part of pyOCCT which provides Python bindings to the OpenCASCADE
# geometry kernel.
#
# Copyright (C) 2016-2018 Laughlin Research, LLC
# Copyright (C) 2019 Trevor Laughlin and the pyOCCT contributors
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import unittest
from OCCT.TColgp import TColgp_HArray1OfPnt, TColgp_Array1OfPnt, \
TColgp_HSequenceOfPnt, TColgp_SequenceOfPnt
from OCCT.gp import gp_Pnt
class Test_TColgp_HArray1OfPnt(unittest.TestCase):
"""
Test for TColgp_HArray1OfPnt class mostly to test binding of the
DEFINE_HARRAY1 macro.
"""
@classmethod
def setUpClass(cls):
"""
Set up for TColgp_HArray1OfPnt.
"""
p1 = gp_Pnt()
p2 = gp_Pnt(1, 0, 0)
p3 = gp_Pnt(2, 0, 0)
arr = TColgp_Array1OfPnt(1, 3)
arr.SetValue(1, p1)
arr.SetValue(2, p2)
arr.SetValue(3, p3)
cls._harr = TColgp_HArray1OfPnt(arr)
def test_Array1(self):
"""
Test TColgp_HArray1OfPnt::Array1
"""
arr = self._harr.Array1()
self.assertIsInstance(arr, TColgp_Array1OfPnt)
self.assertEqual(arr.Length(), 3)
p = arr.Value(1)
self.assertAlmostEqual(p.X(), 0.)
p = arr.Value(2)
self.assertAlmostEqual(p.X(), 1.)
p = arr.Value(3)
self.assertAlmostEqual(p.X(), 2.)
def test_Size(self):
"""
Test TColgp_HArray1OfPnt::Size
"""
self.assertEqual(self._harr.Size(), 3)
def test_Length(self):
"""
Test TColgp_HArray1OfPnt::Length
"""
self.assertEqual(self._harr.Length(), 3)
def test_Value(self):
"""
Test TColgp_HArray1OfPnt::Value
"""
p = self._harr.Value(1)
self.assertAlmostEqual(p.X(), 0.)
p = self._harr.Value(2)
self.assertAlmostEqual(p.X(), 1.)
p = self._harr.Value(3)
self.assertAlmostEqual(p.X(), 2.)
class Test_TColgp_HSequenceOfPnt(unittest.TestCase):
"""
Test for TColgp_HSequenceOfPnt class mostly to test binding of the
DEFINE_HSEQUENCE macro.
"""
@classmethod
def setUpClass(cls):
"""
Set up for TColgp_HSequenceOfPnt.
"""
p1 = gp_Pnt()
p2 = gp_Pnt(1, 0, 0)
p3 = gp_Pnt(2, 0, 0)
seq = TColgp_SequenceOfPnt()
seq.Append(p1)
seq.Append(p2)
seq.Append(p3)
cls._hseq = TColgp_HSequenceOfPnt(seq)
def test_Sequence(self):
"""
Test TColgp_HSequenceOfPnt::Sequence
"""
seq = self._hseq.Sequence()
self.assertIsInstance(seq, TColgp_SequenceOfPnt)
self.assertEqual(seq.Length(), 3)
p = seq.Value(1)
self.assertAlmostEqual(p.X(), 0.)
p = seq.Value(2)
self.assertAlmostEqual(p.X(), 1.)
p = seq.Value(3)
self.assertAlmostEqual(p.X(), 2.)
def test_Size(self):
"""
Test TColgp_HSequenceOfPnt::Size
"""
self.assertEqual(self._hseq.Size(), 3)
def test_Length(self):
"""
Test TColgp_HSequenceOfPnt::Length
"""
self.assertEqual(self._hseq.Length(), 3)
def test_Value(self):
"""
Test TColgp_HSequenceOfPnt::Value
"""
p = self._hseq.Value(1)
self.assertAlmostEqual(p.X(), 0.)
p = self._hseq.Value(2)
self.assertAlmostEqual(p.X(), 1.)
p = self._hseq.Value(3)
self.assertAlmostEqual(p.X(), 2.)
if __name__ == '__main__':
unittest.main()