22
22
"""Provides for creating and managing a NURBS curve."""
23
23
24
24
from functools import cached_property
25
- from typing import Optional
25
+ from typing import TYPE_CHECKING , Optional
26
26
27
27
from beartype import beartype as check_input_types
28
- import geomdl .NURBS as geomdl_nurbs # noqa: N811
29
28
30
29
from ansys .geometry .core .math import Matrix44 , Point3D
31
30
from ansys .geometry .core .math .vector import Vector3D
39
38
)
40
39
from ansys .geometry .core .typing import Real
41
40
41
+ if TYPE_CHECKING : # pragma: no cover
42
+ import geomdl .NURBS as geomdl_nurbs # noqa: N811
43
+
42
44
43
45
class NURBSCurve (Curve ):
44
46
"""Represents a NURBS curve.
@@ -53,14 +55,20 @@ class NURBSCurve(Curve):
53
55
54
56
"""
55
57
56
- def __init__ (
57
- self ,
58
- ):
58
+ def __init__ (self ):
59
59
"""Initialize ``NURBSCurve`` class."""
60
+ try :
61
+ import geomdl .NURBS as geomdl_nurbs # noqa: N811
62
+ except ImportError as e : # pragma: no cover
63
+ raise ImportError (
64
+ "The `geomdl` library is required to use the NURBSCurve class. "
65
+ "Please install it using `pip install geomdl`."
66
+ ) from e
67
+
60
68
self ._nurbs_curve = geomdl_nurbs .Curve ()
61
69
62
70
@property
63
- def geomdl_nurbs_curve (self ) -> geomdl_nurbs .Curve :
71
+ def geomdl_nurbs_curve (self ) -> " geomdl_nurbs.Curve" :
64
72
"""Get the underlying NURBS curve.
65
73
66
74
Notes
@@ -237,7 +245,7 @@ def project_point(
237
245
238
246
# Function to minimize (distance squared)
239
247
def distance_squared (
240
- u : float , geomdl_nurbs_curbe : geomdl_nurbs .Curve , point : np .ndarray
248
+ u : float , geomdl_nurbs_curbe : " geomdl_nurbs.Curve" , point : np .ndarray
241
249
) -> np .ndarray :
242
250
point_on_curve = np .array (geomdl_nurbs_curbe .evaluate_single (u ))
243
251
return np .sum ((point_on_curve - point ) ** 2 )
0 commit comments