Skip to content

OCCCurve ¤

OCCCurve(native_curve: Geom_Curve, name=None)

Class representing a general curve object.

Parameters:

  • native_curve (Geom_Curve) –

    An existing OCC curve.

  • name (str, default: None ) –

    The name of the curve.

Attributes:

  • dimension (int) –

    The dimension of the curve.

  • domain (tuple[float, float]) –

    The domain of the parameter space of the curve.

  • end (Point) –

    The end point of the curve.

  • is_closed (bool) –

    Flag indicating that the curve is closed.

  • is_periodic (bool) –

    Flag indicating that the curve is periodic.

  • start (Point) –

    The start point of the curve.

Functions¤

aabb ¤

aabb(precision: float = 0.0) -> Box

Compute the axis aligned bounding box of the curve.

Parameters:

  • precision (float, default: 0.0 ) –

    The precision.

Returns:

closest_parameters_curve ¤

closest_parameters_curve(
    curve: OCCCurve, return_distance: bool = False
) -> tuple[float, float] | tuple[tuple[float, float], float]

Computes the curve parameters where the curve is the closest to another given curve.

Parameters:

  • curve (OCCCurve) –

    The curve to find the closest distance to.

  • return_distance (bool, default: False ) –

    If True, return the minimum distance between the two curves in addition to the curve parameters.

Returns:

  • tuple[float, float] | tuple[tuple[float, float], float]

    If return_distance is False, the lowest distance parameters on the two curves. If return_distance is True, the distance between the two curves in addition to the curve parameters.

closest_point ¤

closest_point(
    point: Point, return_parameter: bool = False
) -> Point | tuple[Point, float] | None

Compute the closest point on the curve to a given point. If an orthogonal projection is not possible, the start or end point is returned, whichever is closer.

Parameters:

  • point (Point) –

    The point to project to the curve.

  • return_parameter (bool, default: False ) –

    If True, return the curve parameter in addition to the closest point.

Returns:

  • Point | tuple[Point, float]

    If return_parameter is False, the nearest point on the curve. If return_parameter is True, the nearest point on the curve and the corresponding parameter.

closest_points_curve ¤

closest_points_curve(
    curve: OCCCurve, return_distance: bool = False
) -> tuple[Point, Point] | tuple[tuple[Point, Point], float]

Computes the points on curves where the curve is the closest to another given curve.

Parameters:

  • curve (OCCCurve) –

    The curve to find the closest distance to.

  • return_distance (bool, default: False ) –

    If True, return the minimum distance between the curves in addition to the closest points.

Returns:

copy ¤

copy() -> OCCCurve

Make an independent copy of the current curve.

Returns:

curvature_at ¤

curvature_at(t: float) -> Vector

Compute the curvature vector at a curve parameter.

Parameters:

  • t (float) –

    The curve parameter.

Returns:

Raises:

  • ValueError

    If the parameter is not in the curve domain.

divide_by_count ¤

divide_by_count(
    count: int, return_points: bool = False, precision: float = 1e-06
) -> list[float] | tuple[list[float], list[Point]]

Divide the curve into a specific number of equal length segments.

Parameters:

  • count (int) –

    The number of segments.

  • return_points (bool, default: False ) –

    If True, return the list of division parameters, and the points corresponding to those parameters. If False, return only the list of parameters.

  • precision (float, default: 1e-06 ) –

    The precision used for calculating the segments.

Returns:

  • list[float] | tuple[list[float], list[Point]]

    If return_points is False, the parameters of the discretisation. If return_points is True, a list of points in addition to the parameters of the discretisation.

divide_by_length ¤

divide_by_length(
    length: float, return_points: bool = False, precision: float = 1e-06
) -> list[float] | tuple[list[float], list[Point]]

Divide the curve into segments of a given length.

Note that the end point of the last segment might not coincide with the end point of the curve.

Parameters:

  • length (float) –

    The length of the segments.

  • return_points (bool, default: False ) –

    If True, return the list of division parameters, and the points corresponding to those parameters. If False, return only the list of parameters.

  • precision (float, default: 1e-06 ) –

    The precision used for calculating the segments.

Returns:

  • list[float] | tuple[list[float], list[Point]]

    If return_points is False, the parameters of the discretisation. If return_points is True, a list of points in addition to the parameters of the discretisation.

embedded ¤

embedded(surface) -> OCCCurve2d

Return a new curve embedded in the parameter space of the surface.

Parameters:

  • surface

    The embedding surface.

Returns:

frame_at ¤

frame_at(t: float) -> Frame

Compute the local frame at a curve parameter.

Parameters:

  • t (float) –

    The curve parameter.

Returns:

Raises:

  • ValueError

    If the parameter is not in the curve domain.

from_native classmethod ¤

from_native(native_curve: Geom_Curve) -> OCCCurve

Construct a curve from an existing OCC BSplineCurve.

Parameters:

  • native_curve (Geom_Curve) –

Returns:

from_occ classmethod ¤

from_occ(native_curve: Geom_Curve) -> OCCCurve

Construct a curve from an existing OCC BSplineCurve.

Parameters:

  • native_curve (Geom_Curve) –

Returns:

Warnings

.. deprecated:: 1.3 Use from_native instead.

length ¤

length(precision: float = 0.001) -> float

Compute the length of the curve.

Parameters:

  • precision (float, default: 0.001 ) –

    The precision used for calculating the length.

Returns:

offset ¤

offset(distance: float, direction: Vector) -> OCCCurve

Return a new curve that is the offset of this curve over the specified distance in the given direction.

Parameters:

  • distance (float) –

    The offset distance.

  • direction (Vector) –

    The offset direction. Note that this direction defines the normal of the offset plane. At every point of the curve, a positive offset ditance will generate a corresponding offset point in the direction of the cross product vector of the curve tangent and the offset plane normal.

Returns:

parameter_at_distance ¤

parameter_at_distance(t: float, distance: float, precision: float = 0.1) -> float

Compute the parameter of a point on the curve at a given distance along the curve from a point at a given parameter.

Parameters:

  • t (float) –

    The parameter of the starting point.

  • distance (float) –

    The distance along the curve from the point at the given parameter.

  • precision (float, default: 0.1 ) –

    The required precision of the result.

Returns:

  • float

    The new parameter.

point_at ¤

point_at(t: float) -> Point

Compute the point at a curve parameter.

Parameters:

  • t (float) –

    The curve parameter.

Returns:

Raises:

  • ValueError

    If the parameter is not in the curve domain.

projected ¤

projected(surface) -> OCCCurve

Return a copy of the curve projected onto a surface.

Parameters:

  • surface

    The projection surface.

Returns:

reverse ¤

reverse() -> None

Reverse the parametrisation of the curve.

Returns:

  • None

tangent_at ¤

tangent_at(t: float) -> Vector

Compute the tangent vector at a curve parameter.

Parameters:

  • t (float) –

    The curve parameter.

Returns:

Raises:

  • ValueError

    If the parameter is not in the curve domain.

to_polyline ¤

to_polyline(n: int = 100) -> Polyline

Convert the curve to a polyline.

Parameters:

  • n (int, default: 100 ) –

    The number of polyline points.

Returns:

  • class:`compas.geometry.Polyline`

to_step ¤

to_step(filepath: str, schema: str = 'AP203') -> None

Write the curve geometry to a STP file.

Parameters:

  • filepath (str) –

    The path to the file.

  • schema (str, default: 'AP203' ) –

    The STEP schema.

Returns:

  • None

transform ¤

transform(T: Transformation) -> None

Transform this curve.

Parameters:

Returns:

  • None