Construct a surface from a face.
(cls, f: Face)
| 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 | """ |