Makes a planar face from one or more wires
(cls, outerWire: Wire, innerWires: list[Wire] = [])
| 3640 | |
| 3641 | @classmethod |
| 3642 | def makeFromWires(cls, outerWire: Wire, innerWires: list[Wire] = []) -> Face: |
| 3643 | """ |
| 3644 | Makes a planar face from one or more wires |
| 3645 | """ |
| 3646 | |
| 3647 | if innerWires and not outerWire.IsClosed(): |
| 3648 | raise ValueError("Cannot build face(s): outer wire is not closed") |
| 3649 | |
| 3650 | # check if wires are coplanar |
| 3651 | ws = Compound.makeCompound([outerWire] + innerWires) |
| 3652 | if not BRepLib_FindSurface(ws.wrapped, OnlyPlane=True).Found(): |
| 3653 | raise ValueError("Cannot build face(s): wires not planar") |
| 3654 | |
| 3655 | # fix outer wire |
| 3656 | sf_s = ShapeFix_Shape(outerWire.wrapped) |
| 3657 | sf_s.Perform() |
| 3658 | wo = TopoDS.Wire(sf_s.Shape()) |
| 3659 | |
| 3660 | face_builder = BRepBuilderAPI_MakeFace(wo, True) |
| 3661 | |
| 3662 | for w in innerWires: |
| 3663 | if not w.IsClosed(): |
| 3664 | raise ValueError("Cannot build face(s): inner wire is not closed") |
| 3665 | face_builder.Add(w.wrapped) |
| 3666 | |
| 3667 | face_builder.Build() |
| 3668 | |
| 3669 | if not face_builder.IsDone(): |
| 3670 | raise ValueError(f"Cannot build face(s): {face_builder.Error()}") |
| 3671 | |
| 3672 | face = face_builder.Face() |
| 3673 | |
| 3674 | sf_f = ShapeFix_Face(face) |
| 3675 | sf_f.FixOrientation() |
| 3676 | sf_f.Perform() |
| 3677 | |
| 3678 | return cls(sf_f.Result()) |
| 3679 | |
| 3680 | @classmethod |
| 3681 | def makeSplineApprox( |