Skip to content

BSpline2D

Canonical path: NemAll_Python_Geometry.BSpline2D

Bases: PolyPoints2D

class for 2D (non uniform, rational) B-spline geometry

Methods:

  • Clear

    Clear data, getting invalid state

  • Count

    Get count of points.

  • CreateLine2D

    Create BSpline2D from Line2D

  • Empty

    Return true if no points, otherwise false.

  • EqualRef

    Test if reference points are equal.

  • Get

    Get the b-spline data.

  • GetDegree

    Gets spline degree

  • GetEndPoint

    Get the end point in world coordinate system.

  • GetEndRelPoint

    Get the end point

  • GetKnots

    Get knot vector

  • GetLastPoint

    Get the last point in world coordinate system.

  • GetPoint

    Get point in world coordinate system.

  • GetPointIndex

    Get index of the given point

  • GetPointIndexes

    Get indexes of the given point, in case that several points in the spline

  • GetRefPoint

    Get reference point.

  • GetRelPoint

    Get point in Local coordinate system.

  • GetStartPoint

    Get the start point in world coordinate system.

  • GetStartRelPoint

    Get the start point

  • GetWeights

    Get control points weights

  • Insert

    Overloaded function. See individual overloads.

  • InsertRel

    Insert relative point at specific position. Used local coordinates.

  • IsClosed

    Check if spline is closed ( first/last points are equal )

  • IsRational

    Check if the spline is rational

  • IsValid

    Check spline validity

  • Remove

    Remove point from specific position.

  • RemoveLastPoint

    Remove the last point

  • Reserve

    Reserve container capacity

  • Resize

    Specifies a new size for the points vector.

  • Reverse

    Reverse of current spline

  • Set

    Set the b-spline data.

  • SetDegree

    Set spline degree

  • SetEndPoint

    Set the end point in world coordinates

  • SetKnots

    Set knot vector

  • SetPeriodic

    Set the periodic flag

  • SetPoint

    Set point at given position in world coordinate system.

  • SetRefPoint

    Set reference point in world coordinate system.

  • SetRelPoint

    Set point at given position in relative coordinate system.

  • SetStartPoint

    Set the start point in world coordinates

  • SetWeights

    Set weights for control points

  • ToLineChain

    Get polyline as a chain of lines composed from 2 points.

  • __eq__

    Comparison of bsplines.

  • __getitem__

    Get point at position from index. Used world coordinates.

  • __iadd__

    Addition assignment operator

  • __init__

    Overloaded function. See individual overloads.

  • __mul__

    2D matrix transformation

  • __repr__

    Convert to string

  • __setitem__

    Set a value at position from index.

Attributes:

Degree property writable

Degree: int

Gets spline degree

EndPoint property writable

EndPoint: Point2D

Get the end point in world coordinate system.

EndRelPoint property

EndRelPoint: Point2D

Get the end point

IsPeriodic property writable

IsPeriodic: bool

Check if the spline is periodic

Knots property writable

Get knot vector

LastPoint property

LastPoint: Point2D

Get the last point in world coordinate system.

Points property writable

Points: list[Point2D]

Get the points

RefPoint property writable

RefPoint: Point2D

Get reference point.

StartPoint property writable

StartPoint: Point2D

Get the start point in world coordinate system.

StartRelPoint property

StartRelPoint: Point2D

Get the start point

Weights property writable

Weights: VecDoubleList

Get control points weights

Clear

Clear()

Clear data, getting invalid state

Count

Count() -> int

Get count of points.

Returns:

  • int

    bool.

CreateLine2D staticmethod

CreateLine2D(line: Line2D) -> BSpline2D

Create BSpline2D from Line2D

Parameters:

  • line (Line2D) –

    Input line.

Returns:

Empty

Empty() -> bool

Return true if no points, otherwise false.

Returns:

  • bool

    bool.

EqualRef

EqualRef(polyPoints: PolyPoints2D) -> bool

Test if reference points are equal.

Parameters:

Returns:

  • bool

    Reference points are equal: true/false

Get

Get() -> tuple[list[Point2D], list[float], list[float], int, bool]

Get the b-spline data.

Returns:

  • tuple[list[Point2D], list[float], list[float], int, bool]

    tuple(control points of b-spline, weights of b-spline, knots of b-spline, degree of b-spline, flag of periodicity of b-spline)

GetDegree

GetDegree() -> int

Gets spline degree

Returns:

  • int

    spline degree

GetEndPoint

GetEndPoint() -> Point2D

Get the end point in world coordinate system.

Returns:

  • Point2D

    end point in world coordinate system

GetEndRelPoint

GetEndRelPoint() -> Point2D

Get the end point

Returns:

GetKnots

GetKnots() -> VecDoubleList

Get knot vector

Returns:

GetLastPoint

GetLastPoint() -> Point2D

Get the last point in world coordinate system.

Returns:

  • Point2D

    last point in world coordinate system

GetPoint

GetPoint(index: int) -> Point2D

Get point in world coordinate system.

This method is checked and throwing Geometry::Exception when index is out of range.

Parameters:

  • index (int) –

    point index.

Returns:

  • Point2D

    point point in world coordinate system.

GetPointIndex

GetPointIndex(point: Point2D) -> tuple[bool, int]

Get index of the given point

Parameters:

  • point (Point2D) –

    Searched point

Returns:

  • tuple[bool, int]

    tuple(True if a point was found, Found index)

GetPointIndexes

GetPointIndexes(point: Point2D) -> tuple[bool, list[int]]

Get indexes of the given point, in case that several points in the spline will have the same coordinates

Parameters:

  • point (Point2D) –

    Searched point

Returns:

  • tuple[bool, list[int]]

    tuple(True if at least one point was found, Found indexes)

GetRefPoint

GetRefPoint() -> Point2D

Get reference point.

Returns:

  • Point2D

    the reference point in the world coordinate system.

GetRelPoint

GetRelPoint(index: int) -> Point2D

Get point in Local coordinate system.

This method is checked and throwing Geometry::Exception when index is out of range.

Parameters:

  • index (int) –

    point index.

Returns:

  • Point2D

    point the point at position index.

GetStartPoint

GetStartPoint() -> Point2D

Get the start point in world coordinate system.

Returns:

  • Point2D

    start point in world coordinate system

GetStartRelPoint

GetStartRelPoint() -> Point2D

Get the start point

Returns:

GetWeights

GetWeights() -> VecDoubleList

Get control points weights

Returns:

Insert overloaded

Insert(polyPoints: PolyPoints2D, position: int = 18446744073709551615) -> bool

Insert vector of points at specific position.

If return false then points weren't inserted.

Parameters:

  • polyPoints (PolyPoints2D) –

    the PolyPoints.

  • position (int, default: 18446744073709551615 ) –

    position where points will be inserted.

Returns:

  • bool

    bool true if successful.

Insert(point: Point2D, position: int = 18446744073709551615) -> bool

Insert point at specific position. Used world coordinates.

If return false then points weren't Inserted.

Parameters:

  • point (Point2D) –

    the Point.

  • position (int, default: 18446744073709551615 ) –

    position where points will be inserted.

Returns:

  • bool

    bool true if successful.

InsertRel

InsertRel(point: Point2D, position: int = 18446744073709551615) -> bool

Insert relative point at specific position. Used local coordinates.

If return false then points weren't Inserted.

Parameters:

  • point (Point2D) –

    the Point.

  • position (int, default: 18446744073709551615 ) –

    position where points will be inserted.

Returns:

  • bool

    bool true if successful.

IsClosed

IsClosed() -> bool

Check if spline is closed ( first/last points are equal )

Returns:

  • bool

    closed spline true/false

IsRational

IsRational() -> bool

Check if the spline is rational

Returns:

  • bool

    bool true = rational

IsValid

IsValid() -> bool

Check spline validity

Returns:

  • bool

    bool valid = true

Remove

Remove(position: int) -> bool

Remove point from specific position.

If return false then points weren't removed.

Parameters:

  • position (int) –

    position of point which will be removed.

Returns:

  • bool

    Point removed: true/false

RemoveLastPoint

RemoveLastPoint() -> bool

Remove the last point

Returns:

  • bool

    Point removed: true/false

Reserve

Reserve(newCount: int)

Reserve container capacity

Parameters:

  • newCount (int) –

    Expected size of container [count of points]

Resize

Resize(newSize: int)

Specifies a new size for the points vector.

Parameters:

  • newSize (int) –

    The new size of the points vector.

Reverse

Reverse()

Reverse of current spline

Method reverse Spline using reverse from PolyPoints and swapping tangents.

Set

Set(
    points: Point2DList,
    weights: VecDoubleList,
    knots: VecDoubleList,
    degree: int,
    isPeriodic: bool,
)

Set the b-spline data.

Parameters:

  • points (Point2DList) –

    control points of b-spline.

  • weights (VecDoubleList) –

    weights of b-spline.

  • knots (VecDoubleList) –

    knots of b-spline.

  • degree (int) –

    degree of b-spline.

  • isPeriodic (bool) –

    flag of periodicity of b-spline.

SetDegree

SetDegree(degree: int)

Set spline degree

Parameters:

  • degree (int) –

    desired degree

SetEndPoint

SetEndPoint(endpoint: Point2D)

Set the end point in world coordinates

Parameters:

  • endpoint (Point2D) –

    new end point

SetKnots

SetKnots(knots: VecDoubleList)

Set knot vector

Parameters:

SetPeriodic

SetPeriodic(flag: bool)

Set the periodic flag

Parameters:

  • flag (bool) –

    True if BSpline is periodic

SetPoint

SetPoint(point: Point2D, index: int)

Set point at given position in world coordinate system.

Parameters:

  • point (Point2D) –

    point in the world coordinate system.

  • index (int) –

    index of point which will be set

SetRefPoint

SetRefPoint(refPoint: Point2D)

Set reference point in world coordinate system.

Parameters:

  • refPoint (Point2D) –

    reference point in the world coordinate system.

SetRelPoint

SetRelPoint(point: Point2D, index: int)

Set point at given position in relative coordinate system.

Parameters:

  • point (Point2D) –

    point in the relative coordinate system.

  • index (int) –

    index of point which will be set

SetStartPoint

SetStartPoint(startpoint: Point2D)

Set the start point in world coordinates

Parameters:

  • startpoint (Point2D) –

    new start point

SetWeights

SetWeights(weights: VecDoubleList)

Set weights for control points

Parameters:

ToLineChain

ToLineChain() -> Point2DList

Get polyline as a chain of lines composed from 2 points.

Returns:

  • Point2DList

    vector of lines composed from 2 points (start and end point of a line)

__eq__

__eq__(bspline: BSpline2D) -> bool

Comparison of bsplines.

Be careful, this method work without tolerance!

Parameters:

  • bspline (BSpline2D) –

    bspline to be compared.

Returns:

  • bool

    True when bsplines are equal, otherwise false.

__getitem__

__getitem__(index: int) -> Point2D

Get point at position from index. Used world coordinates.

This method is checked and throwing Geometry::Exception when index is out of range.

Parameters:

  • index (int) –

    point index.

Returns:

__iadd__

__iadd__(point: Point2D) -> BSpline2D

Addition assignment operator

Parameters:

  • point (Point2D) –

    New Point2D which will be added to the bspline

Returns:

__init__ overloaded

__init__()

Initialize

__init__(
    points: Point2DList,
    weights: VecDoubleList,
    knots: VecDoubleList,
    degree: int,
    isPeriodic: bool,
)

Constructor from b-spline data. Creates b-spline using provided data.

Parameters:

  • points (Point2DList) –

    control points of b-spline.

  • weights (VecDoubleList) –

    weights of b-spline.

  • knots (VecDoubleList) –

    knots of b-spline.

  • degree (int) –

    degree of b-spline.

  • isPeriodic (bool) –

    flag of periodicity of b-spline.

__init__(spline: BSpline2D)

Copy constructor.

Parameters:

  • spline (BSpline2D) –

    Spline which will be copied.

__mul__

__mul__(matrix: Matrix2D) -> BSpline2D

2D matrix transformation

Parameters:

  • matrix (Matrix2D) –

    2D transformation matrix

Returns:

__repr__

__repr__() -> str

Convert to string

__setitem__

__setitem__(index: int | slice, value: Point2D)

Set a value at position from index.

Parameters:

  • index (int | slice) –

    index of the value.

  • value (Point2D) –

    value to insert.

Placeholder