MCPcopy
hub / github.com/CadQuery/cadquery / fromFace

Method fromFace

cadquery/occ_impl/nurbs.py:241–272  ·  view source on GitHub ↗

Construct a surface from a face.

(cls, f: Face)

Source from the content-addressed store, hash-verified

239
240 @classmethod
241 def fromFace(cls, f: Face):
242 """
243 Construct a surface from a face.
244 """
245
246 assert (
247 f.geomType() == "BSPLINE"
248 ), "B-spline geometry required, try converting first."
249
250 g = cast(Geom_BSplineSurface, f._geomAdaptor())
251
252 uknots = np.repeat(list(g.UKnots()), list(g.UMultiplicities()))
253 vknots = np.repeat(list(g.VKnots()), list(g.VMultiplicities()))
254
255 tmp = []
256 for i in range(1, g.NbUPoles() + 1):
257 tmp.append(
258 [
259 [g.Pole(i, j).X(), g.Pole(i, j).Y(), g.Pole(i, j).Z(),]
260 for j in range(1, g.NbVPoles() + 1)
261 ]
262 )
263
264 pts = np.array(tmp)
265
266 uorder = g.UDegree()
267 vorder = g.VDegree()
268
269 uperiodic = g.IsUPeriodic()
270 vperiodic = g.IsVPeriodic()
271
272 return cls(pts, uknots, vknots, uorder, vorder, uperiodic, vperiodic)
273
274 def __call__(self, u: Array, v: Array) -> Array:
275 """

Callers 5

test_surfaceFunction · 0.80
torus_surfFunction · 0.80
test_surface_positionsFunction · 0.80
test_surface_tangentsFunction · 0.80
test_show_nurbsFunction · 0.80

Calls 3

appendMethod · 0.80
geomTypeMethod · 0.45
_geomAdaptorMethod · 0.45

Tested by 5

test_surfaceFunction · 0.64
torus_surfFunction · 0.64
test_surface_positionsFunction · 0.64
test_surface_tangentsFunction · 0.64
test_show_nurbsFunction · 0.64