Approximate a spline through the provided points. :param listOfVector: a list of Vectors that represent the points :param tol: tolerance of the algorithm (consult OCC documentation). :param smoothing: optional tuple of 3 weights use for variational smoothing (defaul
(
cls,
listOfVector: list[Vector],
tol: float = 1e-3,
smoothing: tuple[float, float, float] | None = None,
minDeg: int = 1,
maxDeg: int = 6,
)
| 2775 | |
| 2776 | @classmethod |
| 2777 | def makeSplineApprox( |
| 2778 | cls, |
| 2779 | listOfVector: list[Vector], |
| 2780 | tol: float = 1e-3, |
| 2781 | smoothing: tuple[float, float, float] | None = None, |
| 2782 | minDeg: int = 1, |
| 2783 | maxDeg: int = 6, |
| 2784 | ) -> Edge: |
| 2785 | """ |
| 2786 | Approximate a spline through the provided points. |
| 2787 | |
| 2788 | :param listOfVector: a list of Vectors that represent the points |
| 2789 | :param tol: tolerance of the algorithm (consult OCC documentation). |
| 2790 | :param smoothing: optional tuple of 3 weights use for variational smoothing (default: None) |
| 2791 | :param minDeg: minimum spline degree. Enforced only when smothing is None (default: 1) |
| 2792 | :param maxDeg: maximum spline degree (default: 6) |
| 2793 | :return: an Edge |
| 2794 | """ |
| 2795 | pnts = TColgp_HArray1OfPnt(1, len(listOfVector)) |
| 2796 | for ix, v in enumerate(listOfVector): |
| 2797 | pnts.SetValue(ix + 1, v.toPnt()) |
| 2798 | |
| 2799 | if smoothing: |
| 2800 | spline_builder = GeomAPI_PointsToBSpline( |
| 2801 | pnts, *smoothing, DegMax=maxDeg, Tol3D=tol |
| 2802 | ) |
| 2803 | else: |
| 2804 | spline_builder = GeomAPI_PointsToBSpline( |
| 2805 | pnts, DegMin=minDeg, DegMax=maxDeg, Tol3D=tol |
| 2806 | ) |
| 2807 | |
| 2808 | if not spline_builder.IsDone(): |
| 2809 | raise ValueError("B-spline approximation failed") |
| 2810 | |
| 2811 | spline_geom = spline_builder.Curve() |
| 2812 | |
| 2813 | return cls(BRepBuilderAPI_MakeEdge(spline_geom).Edge()) |
| 2814 | |
| 2815 | @classmethod |
| 2816 | def makeThreePointArc(cls, v1: VectorLike, v2: VectorLike, v3: VectorLike) -> Edge: |