2626
2727from beartype import beartype as check_input_types
2828
29- from ansys .geometry .core .math import Point3D
29+ from ansys .geometry .core .math import ZERO_POINT3D , Point3D
30+ from ansys .geometry .core .math .constants import UNITVECTOR3D_X , UNITVECTOR3D_Z
3031from ansys .geometry .core .math .matrix import Matrix44
3132from ansys .geometry .core .math .vector import UnitVector3D , Vector3D
3233from ansys .geometry .core .shapes .parameterization import (
@@ -57,7 +58,13 @@ class NURBSSurface(Surface):
5758
5859 """
5960
60- def __init__ (self , geomdl_object : "geomdl_nurbs.Surface" = None ):
61+ def __init__ (
62+ self ,
63+ origin : Point3D = ZERO_POINT3D ,
64+ reference : UnitVector3D = UNITVECTOR3D_X ,
65+ axis : UnitVector3D = UNITVECTOR3D_Z ,
66+ geomdl_object : "geomdl_nurbs.Surface" = None ,
67+ ):
6168 """Initialize ``NURBSSurface`` class."""
6269 try :
6370 import geomdl .NURBS as geomdl_nurbs # noqa: N811
@@ -68,6 +75,9 @@ def __init__(self, geomdl_object: "geomdl_nurbs.Surface" = None):
6875 ) from e
6976
7077 self ._nurbs_surface = geomdl_object if geomdl_object else geomdl_nurbs .Surface ()
78+ self ._origin = origin
79+ self ._reference = reference
80+ self ._axis = axis
7181
7282 @property
7383 def geomdl_nurbs_surface (self ) -> "geomdl_nurbs.Surface" :
@@ -110,6 +120,21 @@ def weights(self) -> list[Real]:
110120 """Get the weights of the control points."""
111121 return self ._nurbs_surface .weights
112122
123+ @property
124+ def origin (self ) -> Point3D :
125+ """Get the origin of the surface."""
126+ return self ._origin
127+
128+ @property
129+ def dir_x (self ) -> UnitVector3D :
130+ """Get the reference direction of the surface."""
131+ return self ._reference
132+
133+ @property
134+ def dir_z (self ) -> UnitVector3D :
135+ """Get the axis direction of the surface."""
136+ return self ._axis
137+
113138 @classmethod
114139 @check_input_types
115140 def from_control_points (
@@ -120,6 +145,9 @@ def from_control_points(
120145 knots_v : list [Real ],
121146 control_points : list [Point3D ],
122147 weights : list [Real ] = None ,
148+ origin : Point3D = ZERO_POINT3D ,
149+ reference : UnitVector3D = UNITVECTOR3D_X ,
150+ axis : UnitVector3D = UNITVECTOR3D_Z ,
123151 ) -> "NURBSSurface" :
124152 """Create a NURBS surface from control points and knot vectors.
125153
@@ -139,13 +167,19 @@ def from_control_points(
139167 Weights for the control points. If not provided, all weights are set to 1.
140168 delta : float, optional
141169 Evaluation delta for the surface. Default is 0.01.
170+ origin : Point3D, optional
171+ Origin of the surface. Default is (0, 0, 0).
172+ reference : UnitVector3D, optional
173+ Reference direction of the surface. Default is (1, 0, 0).
174+ axis : UnitVector3D, optional
175+ Axis direction of the surface. Default is (0, 0, 1).
142176
143177 Returns
144178 -------
145179 NURBSSurface
146180 Created NURBS surface.
147181 """
148- nurbs_surface = cls ()
182+ nurbs_surface = cls (origin , reference , axis )
149183 nurbs_surface ._nurbs_surface .degree_u = degree_u
150184 nurbs_surface ._nurbs_surface .degree_v = degree_v
151185
@@ -182,6 +216,9 @@ def fit_surface_from_points(
182216 size_v : int ,
183217 degree_u : int ,
184218 degree_v : int ,
219+ origin : Point3D = ZERO_POINT3D ,
220+ reference : UnitVector3D = UNITVECTOR3D_X ,
221+ axis : UnitVector3D = UNITVECTOR3D_Z ,
185222 ) -> "NURBSSurface" :
186223 """Fit a NURBS surface to a set of points.
187224
@@ -197,6 +234,12 @@ def fit_surface_from_points(
197234 Degree of the surface in the U direction.
198235 degree_v : int
199236 Degree of the surface in the V direction.
237+ origin : Point3D, optional
238+ Origin of the surface. Default is (0, 0, 0).
239+ reference : UnitVector3D, optional
240+ Reference direction of the surface. Default is (1, 0, 0).
241+ axis : UnitVector3D, optional
242+ Axis direction of the surface. Default is (0, 0, 1).
200243
201244 Returns
202245 -------
@@ -215,7 +258,7 @@ def fit_surface_from_points(
215258 degree_v = degree_v ,
216259 )
217260
218- nurbs_surface = cls ()
261+ nurbs_surface = cls (origin , reference , axis )
219262 nurbs_surface ._nurbs_surface .degree_u = degree_u
220263 nurbs_surface ._nurbs_surface .degree_v = degree_v
221264
0 commit comments