1
1
"""Arc data."""
2
+ from __future__ import annotations
3
+
4
+ from typing import TYPE_CHECKING
5
+
6
+ if TYPE_CHECKING :
7
+ from ansys .edb .core .typing import PointLike
8
+
9
+
2
10
from enum import Enum
3
11
import math
4
12
@@ -23,19 +31,15 @@ class ArcData:
23
31
24
32
__stub : arc_data_pb2_grpc .ArcDataServiceStub = session .StubAccessor (session .StubType .arc_data )
25
33
26
- def __init__ (self , start , end , ** kwargs ):
34
+ def __init__ (self , start : PointLike , end : PointLike , ** kwargs ):
27
35
"""Create an arc.
28
36
29
37
Parameters
30
38
----------
31
- start : ansys.edb.core.typing.PointLike
32
- end : ansys.edb.core.typing.PointLike
39
+ start : :term:`Point2DLike`
40
+ end : :term:`Point2DLike`
33
41
height: float, int, optional
34
- thru : ansys.edb.core.typing.PointLike, optional
35
42
direction : Literal["cw", "ccw", "colinear"], optional
36
- radius : float, optional
37
- center : ansys.edb.core.typing.PointLike, optional
38
- is_big : bool, optional
39
43
"""
40
44
self ._start = conversions .to_point (start )
41
45
self ._end = conversions .to_point (end )
@@ -47,7 +51,7 @@ def __init__(self, start, end, **kwargs):
47
51
if "direction" in kwargs :
48
52
self ._height_options ["direction" ] = RotationDirection (kwargs ["direction" ])
49
53
50
- def __str__ (self ):
54
+ def __str__ (self ) -> str :
51
55
"""Generate a readable string for the arc.
52
56
53
57
Returns
@@ -61,31 +65,43 @@ def __str__(self):
61
65
return f"{ self .start } { arc } { self .end } "
62
66
63
67
@property
64
- def start (self ):
65
- """:class:`.PointData`: Start point of the arc."""
68
+ def start (self ) -> PointData :
69
+ """
70
+ :class:`.PointData`: Start point of the arc.
71
+
72
+ This property is read-only.
73
+ """
66
74
return self ._start
67
75
68
76
@property
69
- def end (self ):
70
- """:class:`.PointData`: End point of the arc."""
77
+ def end (self ) -> PointData :
78
+ """
79
+ :class:`.PointData`: End point of the arc.
80
+
81
+ This property is read-only.
82
+ """
71
83
return self ._end
72
84
73
85
@property
74
- def height (self ):
75
- """:obj:`float`: Height of the arc."""
86
+ def height (self ) -> float :
87
+ """
88
+ :obj:`float`: Height of the arc.
89
+
90
+ This property is read-only.
91
+ """
76
92
if self ._height is None :
77
93
self ._height = self .__stub .GetHeight (messages .arc_message (self )).value
78
94
79
95
return self ._height
80
96
81
- def is_point (self , tolerance = 0.0 ):
97
+ def is_point (self , tolerance : float = 0.0 ) -> bool :
82
98
"""Determine if the arc is a point.
83
99
84
100
An arc is a point when its start and end points are the same.
85
101
86
102
Parameters
87
103
----------
88
- tolerance : float, optional
104
+ tolerance : float, default: 0.0
89
105
Tolearance.
90
106
91
107
Returns
@@ -95,12 +111,12 @@ def is_point(self, tolerance=0.0):
95
111
"""
96
112
return self .is_segment (tolerance ) and self .start .equals (self .end , tolerance )
97
113
98
- def is_segment (self , tolerance = 0.0 ):
114
+ def is_segment (self , tolerance : float = 0.0 ) -> bool :
99
115
"""Determine if the arc is a straight line segment.
100
116
101
117
Parameters
102
118
----------
103
- tolerance : float, optional
119
+ tolerance : float, default: 0.0
104
120
Tolearance.
105
121
106
122
Returns
@@ -112,28 +128,44 @@ def is_segment(self, tolerance=0.0):
112
128
113
129
@property
114
130
@parser .to_point_data
115
- def center (self ):
116
- """:class:`.PointData`: Center point of the arc."""
131
+ def center (self ) -> PointData :
132
+ """
133
+ :class:`.PointData`: Center point of the arc.
134
+
135
+ This property is read-only.
136
+ """
117
137
return self .__stub .GetCenter (messages .arc_message (self ))
118
138
119
139
@property
120
140
@parser .to_point_data
121
- def midpoint (self ):
122
- """:class:`.PointData`: Midpoint of the arc."""
141
+ def midpoint (self ) -> PointData :
142
+ """
143
+ :class:`.PointData`: Midpoint of the arc.
144
+
145
+ This property is read-only.
146
+ """
123
147
return self .__stub .GetMidpoint (messages .arc_message (self ))
124
148
125
149
@property
126
- def radius (self ):
127
- """:obj:`float`: Radius of the arc."""
150
+ def radius (self ) -> float :
151
+ """
152
+ :obj:`float`: Radius of the arc.
153
+
154
+ This property is read-only.
155
+ """
128
156
return self .__stub .GetRadius (messages .arc_message (self )).value
129
157
130
158
@property
131
159
@parser .to_polygon_data
132
- def bbox (self ):
133
- """:class:`.PolygonData`: Rectangular bounding box of the arc."""
160
+ def bbox (self ) -> PolygonData :
161
+ """
162
+ :class:`.PolygonData`: Rectangular bounding box of the arc.
163
+
164
+ This property is read-only.
165
+ """
134
166
return self .__stub .GetBoundingBox (messages .arc_message (self ))
135
167
136
- def is_big (self ):
168
+ def is_big (self ) -> bool :
137
169
"""Determine if the arc is big.
138
170
139
171
Returns
@@ -144,10 +176,10 @@ def is_big(self):
144
176
dist = self .start .distance (self .end )
145
177
return 2 * math .fabs (self .height ) > dist
146
178
147
- def is_left (self ):
179
+ def is_left (self ) -> bool :
148
180
"""Determine if the arc rotates clockwise.
149
181
150
- This method is the same as the `` is_cw` ` method.
182
+ This method is the same as the :obj:` is_cw` method.
151
183
152
184
Returns
153
185
-------
@@ -156,7 +188,7 @@ def is_left(self):
156
188
"""
157
189
return self .is_cw ()
158
190
159
- def is_cw (self ):
191
+ def is_cw (self ) -> bool :
160
192
"""Determine if the arc rotates clockwise.
161
193
162
194
This method is the same as the ``is_left`` method.
@@ -168,7 +200,7 @@ def is_cw(self):
168
200
"""
169
201
return self .height > 0.0
170
202
171
- def is_ccw (self ):
203
+ def is_ccw (self ) -> bool :
172
204
"""Determine if the arc rotates counter-clockwise.
173
205
174
206
Returns
@@ -179,16 +211,20 @@ def is_ccw(self):
179
211
return self .height < 0.0
180
212
181
213
@property
182
- def direction (self ):
183
- """:obj:`Literal["cw", "ccw", "colinear"]`: Rotational direction of the arc."""
214
+ def direction (self ) -> str :
215
+ """
216
+ :obj:`str` : Rotational direction of the arc which can be "cw" or "ccw" or "colinear".
217
+
218
+ This property is read-only.
219
+ """
184
220
if self .is_cw ():
185
221
return "cw"
186
222
elif self .is_ccw ():
187
223
return "ccw"
188
224
else :
189
225
return "colinear"
190
226
191
- def angle (self , arc = None ):
227
+ def angle (self , arc : ArcData = None ) -> float :
192
228
"""Get the angle between this arc and another arc if provided or the angle of this arc.
193
229
194
230
Parameters
@@ -214,24 +250,32 @@ def angle(self, arc=None):
214
250
return vec1 .angle (vec2 )
215
251
216
252
@property
217
- def length (self ):
218
- """:obj:`str`: Circumference length of the arc."""
253
+ def length (self ) -> str :
254
+ """
255
+ :obj:`str`: Circumference length of the arc.
256
+
257
+ This property is read-only.
258
+ """
219
259
if self .is_segment ():
220
260
return self .start .distance (self .end )
221
261
else :
222
262
return math .fabs (self .angle () * self .radius )
223
263
224
264
@property
225
- def points (self ):
226
- """:obj:`list` of :class:`.PointData`: Geometric points representing the arc."""
265
+ def points (self ) -> list [PointData ]:
266
+ """
267
+ :obj:`list` of :class:`.PointData`: Geometric points representing the arc.
268
+
269
+ This property is read-only.
270
+ """
227
271
return [self ._start , PointData (self .height ), self ._end ]
228
272
229
- def tangent_at (self , point ) :
273
+ def tangent_at (self , point : PointLike ) -> PointData :
230
274
"""Get the tangent vector of the arc at a given point.
231
275
232
276
Parameters
233
277
----------
234
- point : ansys.edb.core.typing.PointLike
278
+ point : :term:`Point2DLike`
235
279
Point.
236
280
237
281
Returns
@@ -250,16 +294,16 @@ def tangent_at(self, point):
250
294
return PointData (vec .y , - vec .x )
251
295
252
296
@parser .to_box
253
- def closest_points (self , other ) :
297
+ def closest_points (self , other : ArcData ) -> tuple [ PointData , PointData ] :
254
298
"""Get the closest points from this arc to another arc, and vice versa.
255
299
256
300
Parameters
257
301
----------
258
- other : ArcData
302
+ other : . ArcData
259
303
Other arc.
260
304
261
305
Returns
262
306
-------
263
- tuple[ .PointData, .PointData]
307
+ tuple of ( .PointData, .PointData)
264
308
"""
265
309
return self .__stub .ClosestPoints (messages .arc_data_two_points (self , other ))
0 commit comments