Struct LinearRing2View
Non-owning read-only view of an ordered cyclic sequence of 2D points.
struct LinearRing2View(T)
if (isGeoScalar!T);
Supported scalar types are int, long, float, double, and real.
LinearRing2View is an empty ring.
LinearRing2View does not allocate or copy point data. The caller retains ownership of the backing storage, which must remain valid for the lifetime of the view.
The view aliases its backing storage. Changes made to mutable backing storage through its owner remain visible through an existing view. Mutation is not exposed through LinearRing2View itself.
Closure is implicit: for a non-empty ring the final stored vertex is connected back to the first stored vertex.
No normalization is performed. An explicitly repeated first vertex remains an ordinary stored vertex and participates in the implicit closing traversal.
Empty and degenerate rings are valid representations.
Constructors
| Name | Description |
|---|---|
this
(points)
|
Constructs a view over contiguous point storage. |
Properties
| Name | Type | Description |
|---|---|---|
empty[get]
|
bool | True when the ring contains no stored vertices. |
length[get]
|
size_t | Number of stored vertices. |
segmentCount[get]
|
size_t | Number of segments in the cyclic traversal. |
Methods
| Name | Description |
|---|---|
opIndex
(index)
|
Returns one vertex by value. |
segment
(index)
|
Returns one segment in stored traversal order. |
Example
Example using the implicit closing edge of a linear ring.
import geo;
alias P = Point2!double;
alias S = Segment2!double;
alias R = LinearRing2View!double;
P[3] points = [
P(0.0, 0.0),
P(4.0, 0.0),
P(0.0, 3.0)
];
auto ring =
R(points[]);
assert(!ring .empty);
assert(ring .length == 3);
assert(ring .segmentCount == 3);
assert(
ring[1] ==
P(4.0, 0.0)
);
/*
* Ring closure is implicit: the final segment returns to vertex 0.
*/
assert(
ring .segment(2) ==
S(
P(0.0, 3.0),
P(0.0, 0.0)
)
);