File size: 6,671 Bytes
985c397 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | # SPDX-License-Identifier: LGPL-2.1-or-later
from __future__ import annotations
from Base.Metadata import export, constmethod
from Base.Vector import Vector
from Part.App.Geom2d.Geometry2d import Geometry2d
from Part.App.Geom2d.BSplineCurve import BSplineCurve
from typing import Final, overload, List
@export(
Include="Mod/Part/App/Geometry2d.h",
FatherInclude="Mod/Part/App/Geom2d/Geometry2dPy.h",
Twin="Geom2dCurve",
TwinPointer="Geom2dCurve",
PythonName="Part.Geom2d.Curve2d",
Constructor=True,
)
class Curve2d(Geometry2d):
"""
The abstract class Geom2dCurve is the root class of all curve objects.
Author: Werner Mayer (wmayer@users.sourceforge.net)
Licence: LGPL
"""
Continuity: Final[str] = ...
"""Returns the global continuity of the curve."""
Closed: Final[bool] = ...
"""Returns true if the curve is closed."""
Periodic: Final[bool] = ...
"""Returns true if the curve is periodic."""
FirstParameter: Final[float] = ...
"""Returns the value of the first parameter."""
LastParameter: Final[float] = ...
"""Returns the value of the last parameter."""
def reverse(self) -> None:
"""
Changes the direction of parametrization of the curve.
"""
...
@constmethod
def toShape(self) -> object:
"""
Return the shape for the geometry.
"""
...
@overload
@constmethod
def discretize(self, *, Number: int) -> List[Vector]: ...
@overload
@constmethod
def discretize(self, *, QuasiNumber: int) -> List[Vector]: ...
@overload
@constmethod
def discretize(self, *, Distance: float) -> List[Vector]: ...
@overload
@constmethod
def discretize(self, *, Deflection: float) -> List[Vector]: ...
@overload
@constmethod
def discretize(self, *, QuasiDeflection: float) -> List[Vector]: ...
@overload
@constmethod
def discretize(self, *, Angular: float, Curvature: float, Minimum: int = 2) -> List[Vector]: ...
@constmethod
def discretize(self, **kwargs) -> List[Vector]:
"""
Discretizes the curve and returns a list of points.
The function accepts keywords as argument:
discretize(Number=n) => gives a list of 'n' equidistant points.
discretize(QuasiNumber=n) => gives a list of 'n' quasi-equidistant points (is faster than the method above).
discretize(Distance=d) => gives a list of equidistant points with distance 'd'.
discretize(Deflection=d) => gives a list of points with a maximum deflection 'd' to the curve.
discretize(QuasiDeflection=d) => gives a list of points with a maximum deflection 'd' to the curve (faster).
discretize(Angular=a,Curvature=c,[Minimum=m]) => gives a list of points with an angular deflection of 'a'
and a curvature deflection of 'c'. Optionally a minimum number of points
can be set, which by default is set to 2.
Optionally you can set the keywords 'First' and 'Last' to define
a sub-range of the parameter range of the curve.
If no keyword is given, then it depends on whether the argument is an int or float.
If it's an int then the behaviour is as if using the keyword 'Number',
if it's a float then the behaviour is as if using the keyword 'Distance'.
Example:
import Part
c=PartGeom2d.Circle2d()
c.Radius=5
p=c.discretize(Number=50,First=3.14)
s=Part.Compound([Part.Vertex(i) for i in p])
Part.show(s)
p=c.discretize(Angular=0.09,Curvature=0.01,Last=3.14,Minimum=100)
s=Part.Compound([Part.Vertex(i) for i in p])
Part.show(s)
"""
...
@overload
def length(self, /) -> float: ...
@overload
def length(self, uMin: float, /) -> float: ...
@overload
def length(self, uMin: float, uMax: float, /) -> float: ...
@overload
def length(self, uMin: float, uMax: float, Tol: float, /) -> float: ...
def length(self, *args: float) -> float:
"""
Computes the length of a curve
length([uMin,uMax,Tol]) -> Float
"""
...
@overload
def parameterAtDistance(self, abscissa: float, /) -> float: ...
@overload
def parameterAtDistance(self, abscissa: float, startingParameter: float, /) -> float: ...
def parameterAtDistance(self, *args: float) -> float:
"""
Returns the parameter on the curve of a point at
the given distance from a starting parameter.
parameterAtDistance([abscissa, startingParameter]) -> Float
"""
...
def value(self, u: float, /) -> Vector:
"""
Computes the point of parameter u on this curve
"""
...
def tangent(self, u: float, /) -> Vector:
"""
Computes the tangent of parameter u on this curve
"""
...
def parameter(self, point: Vector, /) -> float:
"""
Returns the parameter on the curve of the
nearest orthogonal projection of the point.
"""
...
@constmethod
def normal(self, pos: float, /) -> Vector:
"""
Vector = normal(pos) - Get the normal vector at the given parameter [First|Last] if defined.
"""
...
@constmethod
def curvature(self, pos: float, /) -> float:
"""
Float = curvature(pos) - Get the curvature at the given parameter [First|Last] if defined.
"""
...
@constmethod
def centerOfCurvature(self, pos: float, /) -> Vector:
"""
Vector = centerOfCurvature(float pos) - Get the center of curvature at the given parameter [First|Last] if defined.
"""
...
@constmethod
def intersectCC(self, other: "Curve2d", /) -> List[Vector]:
"""
Returns all intersection points between this curve and the given curve.
"""
...
@overload
def toBSpline(self, /) -> BSplineCurve: ...
@overload
def toBSpline(self, First: float, Last: float, /) -> BSplineCurve: ...
def toBSpline(self, *args: float) -> BSplineCurve:
"""
Converts a curve of any type (only part from First to Last)
toBSpline([Float=First, Float=Last]) -> B-Spline curve
"""
...
def approximateBSpline(
self, Tolerance: float, MaxSegments: int, MaxDegree: int, Order: str = "C2", /
) -> BSplineCurve:
"""
Approximates a curve of any type to a B-Spline curve
approximateBSpline(Tolerance, MaxSegments, MaxDegree, [Order='C2']) -> B-Spline curve
"""
...
|