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

Class Surface

cadquery/occ_impl/nurbs.py:195–351  ·  view source on GitHub ↗

B-spline surface container.

Source from the content-addressed store, hash-verified

193
194
195class Surface(NamedTuple):
196 """
197 B-spline surface container.
198 """
199
200 pts: Array
201 uknots: Array
202 vknots: Array
203 uorder: int
204 vorder: int
205 uperiodic: bool
206 vperiodic: bool
207
208 def surface(self) -> Geom_BSplineSurface:
209 """
210 Convert to a OCCT Surface object.
211 """
212
213 unique_knots, mults_arr = np.unique(self.uknots, return_counts=True)
214 uknots = _colRealArray(unique_knots)
215 umults = _colIntArray(mults_arr)
216
217 unique_knots, mults_arr = np.unique(self.vknots, return_counts=True)
218 vknots = _colRealArray(unique_knots)
219 vmults = _colIntArray(mults_arr)
220
221 return Geom_BSplineSurface(
222 _colPtsArray2(self.pts),
223 uknots,
224 vknots,
225 umults,
226 vmults,
227 self.uorder,
228 self.vorder,
229 self.uperiodic,
230 self.vperiodic,
231 )
232
233 def face(self, tol: float = 1e-3) -> Face:
234 """
235 Convert to a Face object.
236 """
237
238 return Face(BRepBuilderAPI_MakeFace(self.surface(), tol).Shape())
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()))

Callers 6

test_surfaceFunction · 0.90
simple_surfFunction · 0.90
approximate2DFunction · 0.85
constrainedApproximate2DFunction · 0.85
periodicLoftFunction · 0.85
loftFunction · 0.85

Calls

no outgoing calls

Tested by 2

test_surfaceFunction · 0.72
simple_surfFunction · 0.72