Skip to content

Commit 43fda92

Browse files
FIX: fix geometry doc (#543)
Co-authored-by: drewm102 <[email protected]>
1 parent 10102fc commit 43fda92

File tree

8 files changed

+456
-283
lines changed

8 files changed

+456
-283
lines changed

doc/source/api/geometry.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Classes
1111

1212
arc_data.ArcData
1313
r_tree.RTree
14+
r_tree.RTreeObj
1415
polygon_data.PolygonData
1516
point_data.PointData
1617
point3d_data.Point3DData
@@ -22,6 +23,7 @@ Enums
2223
.. autosummary::
2324
:toctree: _autosummary
2425

26+
arc_data.RotationDirection
2527
polygon_data.ExtentType
2628
polygon_data.PolygonSenseType
2729
polygon_data.IntersectionType

src/ansys/edb/core/geometry/arc_data.py

Lines changed: 87 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
"""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+
210
from enum import Enum
311
import math
412

@@ -23,19 +31,15 @@ class ArcData:
2331

2432
__stub: arc_data_pb2_grpc.ArcDataServiceStub = session.StubAccessor(session.StubType.arc_data)
2533

26-
def __init__(self, start, end, **kwargs):
34+
def __init__(self, start: PointLike, end: PointLike, **kwargs):
2735
"""Create an arc.
2836
2937
Parameters
3038
----------
31-
start : ansys.edb.core.typing.PointLike
32-
end : ansys.edb.core.typing.PointLike
39+
start : :term:`Point2DLike`
40+
end : :term:`Point2DLike`
3341
height: float, int, optional
34-
thru : ansys.edb.core.typing.PointLike, optional
3542
direction : Literal["cw", "ccw", "colinear"], optional
36-
radius : float, optional
37-
center : ansys.edb.core.typing.PointLike, optional
38-
is_big : bool, optional
3943
"""
4044
self._start = conversions.to_point(start)
4145
self._end = conversions.to_point(end)
@@ -47,7 +51,7 @@ def __init__(self, start, end, **kwargs):
4751
if "direction" in kwargs:
4852
self._height_options["direction"] = RotationDirection(kwargs["direction"])
4953

50-
def __str__(self):
54+
def __str__(self) -> str:
5155
"""Generate a readable string for the arc.
5256
5357
Returns
@@ -61,31 +65,43 @@ def __str__(self):
6165
return f"{self.start} {arc} {self.end}"
6266

6367
@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+
"""
6674
return self._start
6775

6876
@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+
"""
7183
return self._end
7284

7385
@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+
"""
7692
if self._height is None:
7793
self._height = self.__stub.GetHeight(messages.arc_message(self)).value
7894

7995
return self._height
8096

81-
def is_point(self, tolerance=0.0):
97+
def is_point(self, tolerance: float = 0.0) -> bool:
8298
"""Determine if the arc is a point.
8399
84100
An arc is a point when its start and end points are the same.
85101
86102
Parameters
87103
----------
88-
tolerance : float, optional
104+
tolerance : float, default: 0.0
89105
Tolearance.
90106
91107
Returns
@@ -95,12 +111,12 @@ def is_point(self, tolerance=0.0):
95111
"""
96112
return self.is_segment(tolerance) and self.start.equals(self.end, tolerance)
97113

98-
def is_segment(self, tolerance=0.0):
114+
def is_segment(self, tolerance: float = 0.0) -> bool:
99115
"""Determine if the arc is a straight line segment.
100116
101117
Parameters
102118
----------
103-
tolerance : float, optional
119+
tolerance : float, default: 0.0
104120
Tolearance.
105121
106122
Returns
@@ -112,28 +128,44 @@ def is_segment(self, tolerance=0.0):
112128

113129
@property
114130
@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+
"""
117137
return self.__stub.GetCenter(messages.arc_message(self))
118138

119139
@property
120140
@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+
"""
123147
return self.__stub.GetMidpoint(messages.arc_message(self))
124148

125149
@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+
"""
128156
return self.__stub.GetRadius(messages.arc_message(self)).value
129157

130158
@property
131159
@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+
"""
134166
return self.__stub.GetBoundingBox(messages.arc_message(self))
135167

136-
def is_big(self):
168+
def is_big(self) -> bool:
137169
"""Determine if the arc is big.
138170
139171
Returns
@@ -144,10 +176,10 @@ def is_big(self):
144176
dist = self.start.distance(self.end)
145177
return 2 * math.fabs(self.height) > dist
146178

147-
def is_left(self):
179+
def is_left(self) -> bool:
148180
"""Determine if the arc rotates clockwise.
149181
150-
This method is the same as the ``is_cw`` method.
182+
This method is the same as the :obj:`is_cw` method.
151183
152184
Returns
153185
-------
@@ -156,7 +188,7 @@ def is_left(self):
156188
"""
157189
return self.is_cw()
158190

159-
def is_cw(self):
191+
def is_cw(self) -> bool:
160192
"""Determine if the arc rotates clockwise.
161193
162194
This method is the same as the ``is_left`` method.
@@ -168,7 +200,7 @@ def is_cw(self):
168200
"""
169201
return self.height > 0.0
170202

171-
def is_ccw(self):
203+
def is_ccw(self) -> bool:
172204
"""Determine if the arc rotates counter-clockwise.
173205
174206
Returns
@@ -179,16 +211,20 @@ def is_ccw(self):
179211
return self.height < 0.0
180212

181213
@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+
"""
184220
if self.is_cw():
185221
return "cw"
186222
elif self.is_ccw():
187223
return "ccw"
188224
else:
189225
return "colinear"
190226

191-
def angle(self, arc=None):
227+
def angle(self, arc: ArcData = None) -> float:
192228
"""Get the angle between this arc and another arc if provided or the angle of this arc.
193229
194230
Parameters
@@ -214,24 +250,32 @@ def angle(self, arc=None):
214250
return vec1.angle(vec2)
215251

216252
@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+
"""
219259
if self.is_segment():
220260
return self.start.distance(self.end)
221261
else:
222262
return math.fabs(self.angle() * self.radius)
223263

224264
@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+
"""
227271
return [self._start, PointData(self.height), self._end]
228272

229-
def tangent_at(self, point):
273+
def tangent_at(self, point: PointLike) -> PointData:
230274
"""Get the tangent vector of the arc at a given point.
231275
232276
Parameters
233277
----------
234-
point : ansys.edb.core.typing.PointLike
278+
point : :term:`Point2DLike`
235279
Point.
236280
237281
Returns
@@ -250,16 +294,16 @@ def tangent_at(self, point):
250294
return PointData(vec.y, -vec.x)
251295

252296
@parser.to_box
253-
def closest_points(self, other):
297+
def closest_points(self, other: ArcData) -> tuple[PointData, PointData]:
254298
"""Get the closest points from this arc to another arc, and vice versa.
255299
256300
Parameters
257301
----------
258-
other : ArcData
302+
other : .ArcData
259303
Other arc.
260304
261305
Returns
262306
-------
263-
tuple[.PointData, .PointData]
307+
tuple of (.PointData, .PointData)
264308
"""
265309
return self.__stub.ClosestPoints(messages.arc_data_two_points(self, other))

0 commit comments

Comments
 (0)