Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CpNode

The primary class of the library.

Since the MAT is a full representation of the shape boundary an instance of this class contains both the information of a boundary point and a medial axis point (and edge to the next point(s)). It also contains edges to other CpNodes which allows for traversal of the MAT and thus implictly represents the entire MAT.

To get the maximal disk circle (of which the center is on the medial axis) use cp.circle.

To get the boundary point, use cp.pointOnShape.

The edge, next (resp. prev) allows one to move anti-clockwise (resp. clockwise) on the shape boundary to the next CpNode. This also imposes a direction of traversal of the MAT edges and vertices.

The edge nextOnCircle (resp. prevOnCircle) allows one to go anti-clockwise (resp. clockwise) around the maximal disks implied by the CpNode to the next maximal disk contact point. This is equivalent to following other branches on the MAT.

Each CpNode has a property, matCurveToNextVertex, which is a bezier curve from the maximal disk of this CpNode to the next CpNode's maximal disk and thus directly represents a piece of the medial axis.

The getter, children, returns the children of this CpNode when seen as a MAT edge. Only children in a 'forward' direction are returned. These include all edges except the 'backward' edge given by prevOnCircle. For CpNodes having a maximal disk with 2 contact points (a 2-prong, the usual case) the children will be the single edge next. For a 3-prong this will be the edgese next and nextOnCircle, etc. children allows one to easily traverse the MAT tree - see e.g. the implementation of traverseEdges.

vertexChildren is similar to children but returns the child nodes of the tree when CpNode is seen as a MAT vertex point (as opposed to edge). In this way the dual graph of the tree can easily be traversed - see e.g. traverseVertices. Generally, however, traversing the edges is preferred as it returns the entire Medial Axis (by utilizing matCurveToNextVertex on each returned edge).

It may be worth mentioning that by traversing from the CpNode by following next repeatedly until one is back at the same CpNode allows one to 'go around' the shape and at the same time traverse the MAT twice in different directions.

Index

Constructors

constructor

  • Primarily for internal use.

    Parameters

    • cp: ContactPoint

      The shape boundary contact point, i.e. a CpNode without its edges.

    • isHoleClosing: boolean

      If true, this CpNode belongs to a hole-closing maximal disk.

    • isIntersection: boolean
    • Default value prev: CpNode = undefined

      The previous (going clockwise around the boundary) contact point (CpNode).

    • Default value next: CpNode = undefined

      The next (going ant-clockwise around the boundary) contact (CpNode).

    • Default value prevOnCircle: CpNode = undefined

      The previous CpNode (going clockwise around the inscribed circle defined by the maximal disk).

    • Default value nextOnCircle: CpNode = undefined

      The next CpNode (going anti-clockwise around the inscribed circle defined by the maximal disk).

    • Default value matCurveToNextVertex: number[][] = undefined

      The actual medial axis curve from this CpNode's maximal disk circle to the next CpNode's circle. It is a bezier curve of order 1, 2 or 3.

    Returns CpNode

Properties

cp

The shape boundary contact point, i.e. a CpNode without its edges.

isHoleClosing

isHoleClosing: boolean

If true, this CpNode belongs to a hole-closing maximal disk.

isIntersection

isIntersection: boolean

matCurveToNextVertex

matCurveToNextVertex: number[][]

The actual medial axis curve from this CpNode's maximal disk circle to the next CpNode's circle. It is a bezier curve of order 1, 2 or 3.

next

next: CpNode

The next (going ant-clockwise around the boundary) contact (CpNode).

nextOnCircle

nextOnCircle: CpNode

The next CpNode (going anti-clockwise around the inscribed circle defined by the maximal disk).

prev

prev: CpNode

The previous (going clockwise around the boundary) contact point (CpNode).

prevOnCircle

prevOnCircle: CpNode

The previous CpNode (going clockwise around the inscribed circle defined by the maximal disk).

Accessors

children

  • Returns the children of this CpNode when seen as a MAT edge. Only children in a 'forward' direction are returned. These include all edges except the 'backward' edge given by prevOnCircle.

    Returns CpNode[]

vertexChildren

  • get vertexChildren(): CpNode[]
  • Similar to children but returns the child nodes of the tree when CpNode is seen as a MAT vertex point (as opposed to edge). In this way the dual graph of the tree can easily be traversed - see e.g. traverseVertices. Generally, however, traversing the edges is preferred as it returns the entire Medial Axis (by utilizing matCurveToNextVertex on each returned edge).

    Returns CpNode[]

Methods

clone

  • Returns a deep clone of this CpNode. Can be used to copy the MAT since cloning a single CpNode necessarily implies cloning all CpNodes on the same MAT tree.

    Returns CpNode

getAllOnLoop

  • Returns all CpNodes on the MAT that this CpNode is part of starting from the current one and going anti-clockwise around the shape.

    Returns CpNode[]

getCpNodesOnCircle

  • getCpNodesOnCircle(exclThis?: boolean): CpNode[]
  • Return this (except if exclThis is truthy) and the the other CpNodes around the maximal disk vertex circle in an anti-clockwise order.

    Parameters

    • Default value exclThis: boolean = false

      If true the returned array does not include this CpNode.

    Returns CpNode[]

getProngCount

  • getProngCount(): number
  • Returns the number of contact points on the maximal disk circle implied by this CpNode.

    Note, however, that even one-prongs and sharp corners will return 2 (see isTerminating for more details); if this is not desired use getRealProngCount instead which will return 1 in these cases.

    Returns number

getRealProngCount

  • getRealProngCount(): number
  • Returns the number of contact points (up to planar coordinates) on the maximal disk circle implied by this CpNode.

    See also getProngCount.

    Returns number

isOneProng

  • isOneProng(): boolean
  • Returns true if this CpNode's maximal disk has only one contact point on the shape boundary (up to planar coordinates). These includes sharp corners.

    Note, however, that two CpNodes are stored for each such point to preserve symmetry - see isTerminating for more details.

    Returns boolean

isSharp

  • isSharp(): boolean
  • Returns true if this CpNode represents a sharp corner, i.e. the limiting case of a two-prong having zero radius.

    Note that two CpNodes are stored for each sharp corner, one being terminating and one not. See isTerminating for more details.

    Returns boolean

isTerminating

  • isTerminating(): boolean
  • Returns true if this CpNode is terminating, i.e. implies a leaf MAT vertex.

    This is always the case for sharp corners and maximal disks with a single contact point. Note, however, that even in these cases there are two contact points stored (sitting 'on top' of each other) for the maximal disk. It can be seen as a limiting case of a two-prong where the distance between two of the contact points tend to zero. One point (represented by a CpNode of course) will be terminating with the other point being its next, whereas the other point will not be terminating and 'points' back into the shape.

    Returns boolean

remove

  • Primarily for internal use.

    Parameters

    • cpTree: LlRbTree<CpNode>

      The tree graph holding the [[CpNodes]] of the MAT.

    • cpNode: CpNode

      The CpNode to remove.

    Returns void

Static comparator

  • Primarily for internal use.

    Compares the order of two CpNodes. The order is cyclic and depends on a CpNode's relative position along the shape boundary.

    Parameters

    Returns number

Static insert

  • Primarily for internal use.

    Insert a CpNode into the MAT tree graph after the specified point and returns the freshly inserted CpNode.

    Parameters

    • isHoleClosing: boolean

      True if this is a hole closing contact point.

    • isIntersection: boolean

      True if this is a contact point at a shape boundary intersection point.

    • cpTree: LlRbTree<CpNode>

      The tree graph holding the [[CpNodes]] of the MAT.

    • cp: ContactPoint

      ContactPoint defining the CpNode.

    • prev_: CpNode

      Inserts the new CpNode right after this item if the loop is not empty, else insert the new CpNode as the only item in the loop.

    Returns CpNode

Static isOnSameCircle

Generated using TypeDoc