mark-p-thomas : Polyline Modifications

Sections

Introduction

This page shows graphically the operational actions & ordering of polyline modifications. Child pages show in depth how this is performed on the polyline data structure itself.

For all of these operations, the library handles the following cases:

  • Single vertex values

  • Array of vertex values

  • Single vertex node

  • Array of vertex nodes

  • Another polyline

It is assumed for arrays of nodes/vertices provided that the items are in order and contiguous.

When values are provided, a node is created to store the value, after which cases are the same as for vertex nodes.

When vertex nodes are provided, segment nodes are created & prev/next references are updated appropriately.

When polylines are provided, segments nodes are only created where necessary for joining adjacent nodes, and prev/next references are only modified for the adjacencies of the existing & provided polylines.

Construction

Construction is basically repeated insertions at the end of a polyline, typically with only a set of vertices inserted one at a time.

  • See: Insertion in a polyline data structure for more information.

Insertion

Insertion is handled a bit differently between being done at the ends vs. in the middle. The ends are handled similar to each other, but mirrored.

Inserting in the middle must reference a vertex. However, the insertion can be performed either before or after the referenced vertex.

Inserting at the ends of a polyline just require specifying whether it is at the head or tail of the vertices. These operations can just simply be called prepend & append, respectively.

  • Note: This can condense down to a single node case.

  • See: Insertion in a polyline data structure for more information.

Removal

Removal is handled a bit differently between being done at the ends vs. in the middle. The ends are handled similar to each other, but mirrored.

Removing vertices in the middle of a polyline must reference a vertex as well as a range. Similar to inserting, removal can be before or after a vertex, while the range indicates a contiguous set of vertices & associated segments to remove.

Removal at the ends of a polyline are essentially trimming a polyline. These operations can just simply be called trimBefore & trimAfter, with a trim case that handles both. In these cases, no range is needed, just the reference vertex.

  • Note: This can condense down to a single node case.

  • See: Removal in a polyline data structure for more information.

Replacement

Replacements in a polyline are merely the removal of a range of nodes, followed by an insertion of a set of nodes within the same range. As such, the operation solely relies on calling these other 2 operations in that sequence.

  • Note: This can condense down to a single node case.

  • See: Insertion & Removals in a polyline data structure for more information.

Splitting

Splitting is the process of creating 2 polylines out of the original polyline, split about a given vertex node. Splitting is never actually done on a segment as a segment must always have 2 adjacent vertices by definition. The case of splitting by referencing a segment can be handled by splitting at both of it’s adjacent vertices to get 3 polylines & dropping the 2nd polyline.

  • See: Splitting a polyline data structure for more information.

Range Copying

Often times a polyline may only have portions of it copied. However, these portions are usually a contiguous set. As such, this data structure always copies along a range of vertices. For copying/cloning the entire polyline, the range is just the full polyline length. Ranges are never specified for segments as segments must always have 2 adjacent vertices.

Child Pages