2222from compas_occ .conversions import floats2_from_array2
2323from compas_occ .conversions import points2_from_array2
2424
25- from ..curves import NurbsCurve
26- from ._surface import Surface
25+ from ..curves import OCCNurbsCurve
26+
27+ from compas .geometry import NurbsSurface
2728
2829from OCC .Core .gp import gp_Trsf
2930from OCC .Core .gp import gp_Pnt
4647from OCC .Core .BndLib import BndLib_AddSurface_AddOptimal
4748from OCC .Core .BRepBndLib import brepbndlib_AddOBB
4849
50+
4951Point .from_occ = classmethod (compas_point_from_occ_point )
5052Point .to_occ = compas_point_to_occ_point
5153Vector .from_occ = classmethod (compas_vector_from_occ_vector )
@@ -83,7 +85,7 @@ def __iter__(self):
8385 return iter (self .points )
8486
8587
86- class NurbsSurface ( Surface ):
88+ class OCCNurbsSurface ( NurbsSurface ):
8789 """Class representing a NURBS surface based on the BSplineSurface of the OCC geometry kernel.
8890
8991 Attributes
@@ -143,7 +145,7 @@ def __init__(self, name: str = None) -> None:
143145 self .occ_surface = None
144146 self ._points = None
145147
146- def __eq__ (self , other : 'NurbsSurface ' ) -> bool :
148+ def __eq__ (self , other : 'OCCNurbsSurface ' ) -> bool :
147149 for a , b in zip (flatten (self .points ), flatten (other .points )):
148150 if a != b :
149151 return False
@@ -164,7 +166,7 @@ def __eq__(self, other: 'NurbsSurface') -> bool:
164166
165167 def __str__ (self ):
166168 lines = [
167- 'NurbsSurface ' ,
169+ 'OCCNurbsSurface ' ,
168170 '--------------' ,
169171 f'Points: { self .points } ' ,
170172 f'Weights: { self .weights } ' ,
@@ -226,7 +228,7 @@ def data(self, data: Dict):
226228 )
227229
228230 @classmethod
229- def from_data (cls , data : Dict ) -> 'NurbsSurface ' :
231+ def from_data (cls , data : Dict ) -> 'OCCNurbsSurface ' :
230232 """Construct a BSpline surface from its data representation.
231233
232234 Parameters
@@ -236,7 +238,7 @@ def from_data(cls, data: Dict) -> 'NurbsSurface':
236238
237239 Returns
238240 -------
239- :class:`compas_occ.geometry.NurbsSurface `
241+ :class:`compas_occ.geometry.OCCNurbsSurface `
240242 The constructed surface.
241243
242244 """
@@ -264,7 +266,7 @@ def from_data(cls, data: Dict) -> 'NurbsSurface':
264266 # ==============================================================================
265267
266268 @classmethod
267- def from_occ (cls , occ_surface : Geom_BSplineSurface ) -> 'NurbsSurface ' :
269+ def from_occ (cls , occ_surface : Geom_BSplineSurface ) -> 'OCCNurbsSurface ' :
268270 """Construct a NUBRS surface from an existing OCC BSplineSurface."""
269271 surface = cls ()
270272 surface .occ_surface = occ_surface
@@ -281,7 +283,7 @@ def from_parameters(cls,
281283 u_degree : int ,
282284 v_degree : int ,
283285 is_u_periodic : bool = False ,
284- is_v_periodic : bool = False ) -> 'NurbsSurface ' :
286+ is_v_periodic : bool = False ) -> 'OCCNurbsSurface ' :
285287 """Construct a NURBS surface from explicit parameters."""
286288 surface = cls ()
287289 surface .occ_surface = Geom_BSplineSurface (
@@ -302,7 +304,7 @@ def from_parameters(cls,
302304 def from_points (cls ,
303305 points : List [List [Point ]],
304306 u_degree : int = 3 ,
305- v_degree : int = 3 ) -> 'NurbsSurface ' :
307+ v_degree : int = 3 ) -> 'OCCNurbsSurface ' :
306308 """Construct a NURBS surface from control points."""
307309 u = len (points [0 ])
308310 v = len (points )
@@ -335,7 +337,7 @@ def from_points(cls,
335337 )
336338
337339 @classmethod
338- def from_meshgrid (cls , nu : int = 10 , nv : int = 10 ) -> 'NurbsSurface ' :
340+ def from_meshgrid (cls , nu : int = 10 , nv : int = 10 ) -> 'OCCNurbsSurface ' :
339341 """Construct a NURBS surface from a mesh grid."""
340342 UU , VV = meshgrid (linspace (0 , nu , nu + 1 ), linspace (0 , nv , nv + 1 ))
341343 points = []
@@ -347,18 +349,18 @@ def from_meshgrid(cls, nu: int = 10, nv: int = 10) -> 'NurbsSurface':
347349 return cls .from_points (points = points )
348350
349351 @classmethod
350- def from_step (cls , filepath : str ) -> 'NurbsSurface ' :
352+ def from_step (cls , filepath : str ) -> 'OCCNurbsSurface ' :
351353 """Load a NURBS surface from a STP file."""
352354 raise NotImplementedError
353355
354356 @classmethod
355- def from_face (cls , face : TopoDS_Face ) -> 'NurbsSurface ' :
357+ def from_face (cls , face : TopoDS_Face ) -> 'OCCNurbsSurface ' :
356358 """Construct a NURBS surface from an existing OCC TopoDS_Face."""
357359 srf = BRep_Tool_Surface (face )
358360 return cls .from_occ (srf )
359361
360362 @classmethod
361- def from_fill (cls , curve1 : NurbsCurve , curve2 : NurbsCurve ) -> 'NurbsSurface ' :
363+ def from_fill (cls , curve1 : OCCNurbsCurve , curve2 : OCCNurbsCurve ) -> 'OCCNurbsSurface ' :
362364 """Construct a NURBS surface from the infill between two NURBS curves."""
363365 surface = cls ()
364366 occ_fill = GeomFill_BSplineCurves (curve1 .occ_curve , curve2 .occ_curve , GeomFill_CoonsStyle )
@@ -520,7 +522,7 @@ def is_v_periodic(self) -> bool:
520522 # Methods
521523 # ==============================================================================
522524
523- def copy (self ) -> 'NurbsSurface ' :
525+ def copy (self ) -> 'OCCNurbsSurface ' :
524526 """Make an independent copy of the surface."""
525527 return NurbsSurface .from_parameters (
526528 self .points ,
@@ -541,7 +543,7 @@ def transform(self, T: Transformation) -> None:
541543 _T .SetValues (* T .list [:12 ])
542544 self .occ_surface .Transform (_T )
543545
544- def transformed (self , T : Transformation ) -> 'NurbsSurface ' :
546+ def transformed (self , T : Transformation ) -> 'OCCNurbsSurface ' :
545547 """Transform an independent copy of this surface."""
546548 copy = self .copy ()
547549 copy .transform (T )
@@ -569,17 +571,17 @@ def v_space(self, n: int = 10) -> Generator[float, None, None]:
569571 vmin , vmax = self .v_domain
570572 return np .linspace (vmin , vmax , n )
571573
572- def u_isocurve (self , u : float ) -> NurbsCurve :
574+ def u_isocurve (self , u : float ) -> OCCNurbsCurve :
573575 """Compute the isoparametric curve at parameter u."""
574576 occ_curve = self .occ_surface .UIso (u )
575- return NurbsCurve .from_occ (occ_curve )
577+ return OCCNurbsCurve .from_occ (occ_curve )
576578
577- def v_isocurve (self , v : float ) -> NurbsCurve :
579+ def v_isocurve (self , v : float ) -> OCCNurbsCurve :
578580 """Compute the isoparametric curve at parameter v."""
579581 occ_curve = self .occ_surface .VIso (v )
580- return NurbsCurve .from_occ (occ_curve )
582+ return OCCNurbsCurve .from_occ (occ_curve )
581583
582- def boundary (self ) -> List [NurbsCurve ]:
584+ def boundary (self ) -> List [OCCNurbsCurve ]:
583585 """Compute the boundary curves of the surface."""
584586 umin , umax , vmin , vmax = self .occ_surface .Bounds ()
585587 curves = [
0 commit comments