Abstract base class for IShape implementations that represent polygons.
abstract class
|
ShapePolygonSimpleBase
|
extends
|
ShapePolygonBase
|
This class represents a simple polygon (i.e. a single closed, non-intersecting ring).
Returns the configuration value that describes this object.
public
override
sealed
method
|
ToConfig
()
|
||
type
|
ConfigValue
|
||
returns
|
|
The configuration value. | |
inherited
|
ShapeVertices.ToConfig
|
Remarks:
All configurable objects need to implement this interface. For simple types, it is preferable to delegate to ToValue.
The returned value may be of type Invalid, which means that this object in its current state cannot be described with the configuration API.
Before returning the resulting configuration value, Cache must be called on it, passing this IConfigurable object as parameter.
Returns the axis-aligned bounding box of this shape.
public
override
sealed
property
|
Bounds
{
get
}
|
||
type
|
Box2D
|
||
value
|
The axis-aligned bounding box. | ||
inherited
|
ShapeVertices.Bounds
|
Remarks:
The bounding box is defined as the smallest possible rectangle that contains all points which have a shape distance of zero or less.
Returns the number of shape edges.
public
override
sealed
property
|
EdgeCount
{
get
}
|
||
type
|
int32
|
||
value
|
|
The number of shape edges. | |
overrides
|
ShapeBase.EdgeCount
|
See also:
IShape.EdgeAtDefines how the vertex winding of polygon contours is interpreted (outer rings vs. holes).
public
override
property
|
EdgeParity
{
get
}
|
||
type
|
int32
|
||
value
|
The
parity
value:
+/-
1
for
polygons,
0
for
non-polygon
shapes.
|
||
inherited
|
ShapePolygonBase.EdgeParity
|
Remarks:
A polygon contour is classified as an outer ring or a hole according to the sign of its signed area:
outer := sign(Area(contour)) == Parity hole := sign(Area(contour)) != ParityThe default value is
-1
(i.e.
clockwise
orientation
in
a
standard
Cartesian
coordinate
system).
The coordinate system of the shape.
public
override
property
|
Georef
{
get
}
|
||
type
|
CoordinateSystem
|
||
value
|
|
The coordinate system. | |
inherited
|
Shape.Georef
|
Remarks:
The default coordinate system is a local one (see IsLocal) in metres (see Metre).
Is this a cubemap shape?
public
virtual
property
|
IsCubemap
{
get
}
|
||
type
|
bool
|
||
value
|
true
if
this
is
a
cubemap
shape,
false
if
not. |
||
inherited
|
ShapeBase.IsCubemap
|
Remarks:
Cubemap shapes have a geographic coordinate system (see IsGeographic) and six separate sub-shapes, one for each cubemap face (see Cubemap)).
See also:
IShape.TransformCubemapDoes this shape consist of plain geometry only?
public
virtual
property
|
IsGeometry
{
get
}
|
||
type
|
bool
|
||
value
|
true
if
this
shape
has
plain
geometry
only,
false
if
not. |
||
inherited
|
ShapeBase.IsGeometry
|
Remarks:
Shapes with plain geometry can be rebuilt via Geometry.
Returns the serial type of this object.
public
property
|
SerialType
{
get
}
|
||
type
|
ISerialTypeInfo
|
||
value
|
|
The serial type. | |
inherited
|
SerializableBase.SerialType
|
Returns the serial data version.
public
virtual
property
|
SerialVersion
{
get
}
|
||
type
|
int32
|
||
value
|
|
The serial data version tag. | |
inherited
|
SerializableBase.SerialVersion
|
Remarks:
An ISerializable implementation is required to support all versions up to the one returned by SerialVersion.
See also:
ISerializable.SerializeReturns the number of shape triangles.
public
virtual
property
|
TriangleCount
{
get
}
|
||
type
|
int32
|
||
value
|
|
The number of shape triangles. | |
inherited
|
ShapeBase.TriangleCount
|
The shape type.
public
virtual
property
|
Type
{
get
}
|
||
type
|
ShapeType
|
||
value
|
The shape type. | ||
inherited
|
ShapeBase.Type
|
Returns the number of shape vertices.
public
override
sealed
property
|
VertexCount
{
get
}
|
||
type
|
int32
|
||
value
|
|
The number of shape vertices. | |
inherited
|
ShapeVertices.VertexCount
|
Remarks:
When the vertex count is zero, the shape is defined implicitly. If the vertex count is greater than zero, the shape is explicitly defined by its vertices.
See also:
IShape.VertexAtReturns a shape that returns the absolute distance value (i.e. the outline of this shape).
public
virtual
method
|
Absolute
()
|
||
type
|
IShape
|
||
returns
|
|
The resulting shape. | |
inherited
|
ShapeBase.Absolute
|
Accepts the given IShapeVisitor object.
public
override
sealed
method
|
Accept
(IShapeVisitor visitor,
object userData = null)
|
||
params
|
visitor
|
[not-null]
|
The shape visitor object. |
userData
|
Optional
user
data.
Defaults
to
null . |
||
inherited
|
ShapePolygonBase.Accept
|
Checks the intersection between this shape and the given bounds.
[ThreadSafe]
|
||||
public
virtual
method
|
CheckIntersection
(Box2D box,
float64 offset = 0)
|
|||
type
|
int32
|
|||
params
|
box
|
The box bounds. | ||
offset
|
Optional
distance
offset
to
apply
to
this
shape
for
the
intersection
test.
Defaults
to
0 .
|
|||
returns
|
-1
if
this
shape
and
box
are
disjoint.
0
if
this
shape
and
box
intersect.
1
if
box
fully
contains
this
shape.
2
if
this
shape
fully
contains
box.
|
|||
inherited
|
ShapeBase.CheckIntersection
|
Compiles this shape into the most compact form.
public
virtual
method
|
Compile
()
|
||
type
|
IShape
|
||
returns
|
|
The resulting shape. | |
inherited
|
ShapeBase.Compile
|
Remarks:
Calling this method will not modify the geometry of a shape, only the object model structure.
Initializes the state of this object from the given data stream.
public
override
method
|
Deserialize
(int32 serialVersion,
ISerializer data)
|
||
type
|
ISerializable
|
||
params
|
serialVersion
|
[>=1]
|
The serial data version. |
data
|
[not-null]
|
The serial data stream. | |
returns
|
|
The
deserialized
object.
This
will
typically
be
this ,
but
in
some
circumstances,
another
instance
may
be
returned
(e.g.
singletons).
|
|
overrides
|
ShapePolygonBase.Deserialize
|
Remarks:
The Deserialize method will be called immediately after the object has been instantiated via its default constructor.
The provided serialVersion number is guaranteed to be equal to or less than the SerialVersion returned by this object (i.e. ISerializable object must provide backwards compatibility).
See also:
ISerializable.SerializeComputes the smallest distance from the given point to the shape.
[ThreadSafe]
|
||||
public
abstract
method
|
DistanceTo
(float64 x,
float64 y,
float64 maximum = Maths.MaxDouble)
|
|||
type
|
float64
|
|||
params
|
x
|
X-coordinate of point. | ||
y
|
Y-coordinate of point. | |||
maximum
|
The maximum relevant distance. This is a hint for the implementing class which can be exploited in order to optimize performance. | |||
returns
|
Smallest distance to the shape. | |||
inherited
|
ShapeBase.DistanceTo
|
Remarks:
If the point lies outside of the shape, the returned distance will be greater than zero. If the point is inside of the shape, the returned distance will be negative. The returned distance will be zero if the point exactly lies on the shape boundary.
Computes the smallest distance from the given point to the shape, additionally returning the corresponding nearest feature point on the shape.
[ThreadSafe]
|
||||
public
virtual
method
|
DistanceTo
(float64 x,
float64 y,
out Vec3I vertices,
out Vec3D weights,
float64 maximum = Maths.MaxDouble)
|
|||
type
|
float64
|
|||
params
|
x
|
X-coordinate of point. | ||
y
|
Y-coordinate of point. | |||
vertices
|
Shape vertex indices (see VertexAt) that describe the location of the nearest shape feature. | |||
weights
|
Location
of
the
nearest
shape
feature,
given
as
relative
weights
(i.e.
the
weight
sum
is
1 )
of
vertices.
The
weights
are
sorted
in
descending
order,
i.e.
X
always
holds
the
greatest
weight
and
Z
always
holds
the
smallest
weight.
|
|||
maximum
|
The maximum relevant distance. This is a hint for the implementing class which can be exploited in order to optimize performance. | |||
returns
|
Smallest distance to the shape. All results greater than maximum are considered irrelevant. Implementing methods are free to discard those results. | |||
inherited
|
ShapeBase.DistanceTo
|
Remarks:
If the point lies outside of the shape, the returned distance will be greater than zero. If the point is inside of the shape, the returned distance will be negative. The returned distance will be zero if the point exactly lies on the shape boundary.
Returns a shape edge.
public
override
sealed
method
|
EdgeAt
(int32 index)
|
||
type
|
Vec2I
|
||
params
|
index
|
[0..EdgeCount-1]
|
The edge index. |
returns
|
The shape edge. | ||
overrides
|
ShapeBase.EdgeAt
|
Remarks:
Each edge connects two vertices (see VertexAt), in the direction from X to Y.
All points that lie on an edge have a shape distance of zero.
See also:
IShapeInfo.EdgeCountReturns the neighbouring edges for walking along a polygon contour.
public
override
sealed
method
|
EdgeWalk
(int32 index)
|
||
type
|
Vec2I
|
||
params
|
index
|
[0..EdgeCount-1]
|
The edge index. |
returns
|
Index
of
neighbouring
edge
(see
IShape):
X points to previous edge, Y points to next edge. The component will be -1
if
there
is
no
neighbouring
edge
(i.e.
the
contour
is
not
closed).
Both
components
will
be
-1
for
non-polygon
shapes.
|
||
overrides
|
ShapeBase.EdgeWalk
|
Returns the shape on the given cubemap face.
public
virtual
method
|
Face
(CubemapFace face)
|
||
type
|
IShape
|
||
params
|
face
|
The cubemap face. | |
returns
|
The
shape
or
null
if
there
are
no
shape
parts
on
the
given
cubemap
face.
|
||
inherited
|
ShapeBase.Face
|
Remarks:
Passing
NegZ
to
an
ordinary
shape
will
return
this
.
Cubemap
shapes
(see
TransformCubemap)
will
return
an
aggregated
shape
for
each
cubemap
face,
or
null
.
Cubemap shapes are used by IHeightmapShape and IPixelPyramidShape objects.
Inverts this shape.
public
virtual
method
|
Invert
()
|
||
type
|
IShape
|
||
returns
|
|
The inverted shape. | |
inherited
|
ShapeBase.Invert
|
Returns a composite shape that returns the maximum distance value (i.e. intersection of this shape and the given one).
public
virtual
method
|
Maximum
(IShape shape)
|
||
type
|
IShape
|
||
params
|
shape
|
[not-null]
|
The other shape. |
returns
|
|
The resulting shape. | |
inherited
|
ShapeBase.Maximum
|
Returns a composite shape that returns the minimum distance value (i.e. the union of this shape and the given one).
public
virtual
method
|
Minimum
(IShape shape)
|
||
type
|
IShape
|
||
params
|
shape
|
[not-null]
|
The other shape. |
returns
|
|
The resulting shape. | |
inherited
|
ShapeBase.Minimum
|
public
static
method
|
NearestEdge
(int32 i,
int32 n,
float64 ax,
float64 ay,
float64 bx,
float64 by,
float64 distanceSqr,
ref Vec3I vertices,
ref Vec3D weights)
|
||
type
|
float64
|
||
params
|
i
|
||
n
|
|||
ax
|
|||
ay
|
|||
bx
|
|||
by
|
|||
distanceSqr
|
|||
vertices
|
|||
weights
|
Applies a distance offset to this shape.
public
virtual
method
|
Offset
(float64 offset)
|
||
type
|
IShape
|
||
params
|
offset
|
The distance offset to apply. | |
returns
|
|
The resulting shape. | |
inherited
|
ShapeBase.Offset
|
Serializes the current state of this object to the given data stream.
public
override
method
|
Serialize
(ISerializer data)
|
||
params
|
data
|
[not-null]
|
The serial data stream. |
inherited
|
ShapePolygonBase.Serialize
|
See also:
ISerializable.DeserializeTransforms this shape using the given 2D homogeneous matrix.
public
virtual
method
|
TransformCoordinates
(Mat3D matrix)
|
||
type
|
IShape
|
||
params
|
matrix
|
The 2D homogeneous matrix. | |
returns
|
|
The transforming shape. | |
inherited
|
ShapeBase.TransformCoordinates
|
Remarks:
Shape
coordinates
of
this
shape
are
multiplied
with
matrix
using
Mul2
(w
=
1
)
in
order
to
produce
shape
coordinates
of
the
returned
shape.
Transforms this shape to the given coordinate system.
public
virtual
method
|
TransformCoordinateSystem
(CoordinateSystem target,
float64 accuracy = 0)
|
||
type
|
IShape
|
||
params
|
target
|
[not-null]
|
The target coordinate system. |
accuracy
|
[>=0]
|
Optional
accuracy
to
use
for
subdivision
of
edges.
Given
as
a
maximum
error
in
the
target
coordinate
system
(see
target.
HorizontalUnit).
Set
to
0
to
disable
edge
subdivision.
Defaults
to
0 .
|
|
returns
|
|
The transforming shape. | |
inherited
|
ShapeBase.TransformCoordinateSystem
|
Remarks:
Transformation cannot be performed from resp. to a local coordinate system (see IsLocal). A transformation between two local coordinate system is possible, but only a conversion regarding unit of measure (see LocalUnit) and coordinate system flags (see CoordinateSystemFlags) is done.
Implicit shapes cannot be transformed (see IShape).
Transforms this shape to a geographic cubemap coordinate system.
public
virtual
method
|
TransformCubemap
(float64 accuracy = 0)
|
||
type
|
IShape
|
||
params
|
accuracy
|
[>=0]
|
Optional
accuracy
to
use
for
subdivision
of
edges.
Given
as
a
maximum
error
in
the
target
coordinate
system
(see
Face).
Set
to
0
to
disable
edge
subdivision.
Defaults
to
0 .
|
returns
|
|
The transforming cubemap shape. | |
inherited
|
ShapeBase.TransformCubemap
|
See also:
CoordinateSystem.ToCubemapFaceTransforms this shape to the given coordinate system.
public
virtual
method
|
TransformGeometry
(CoordinateSystemTransform transform,
float64 accuracy = 0)
|
||
type
|
IShape
|
||
params
|
transform
|
[not-null]
|
The coordinate system transformation to apply. |
accuracy
|
[>=0]
|
Optional
accuracy
to
use
for
subdivision
of
edges.
Given
as
a
maximum
error
in
the
target
coordinate
system
(see
transform.
Target.
HorizontalUnit).
Set
to
0
to
disable
edge
subdivision.
Defaults
to
0 .
|
|
returns
|
The
transformed
shape
or
null
if
the
transformed
shape
is
empty
or
if
the
transformation
is
not
possible
(see
remarks).
|
||
inherited
|
ShapeBase.TransformGeometry
|
Remarks:
Transformation cannot be performed from resp. to a local coordinate system (see IsLocal). A transformation between two local coordinate system is possible, but only a conversion regarding unit of measure (see LocalUnit) and coordinate system flags (see CoordinateSystemFlags) is done.
Implicit shapes cannot be transformed (see IShape).
Returns a shape triangle.
public
virtual
method
|
TriangleAt
(int32 index)
|
||
type
|
Vec3I
|
||
params
|
index
|
[0..TriangleCount-1]
|
The triangle index. |
returns
|
The shape triangle. | ||
inherited
|
ShapeBase.TriangleAt
|
Remarks:
Each triangle connects three vertices (see IShape), in the order X, Y, Z, where X <Y and X < Z. The vertex winding is chosen so that the signed triangle area is positive (see Area).
Returns a shape vertex.
public
override
method
|
VertexAt
(int32 index)
|
||
type
|
Vec2D
|
||
params
|
index
|
[0..VertexCount-1]
|
The vertex index. |
returns
|
The shape vertex. | ||
inherited
|
ShapeVertices.VertexAt
|
Remarks:
All vertices have a shape distance of zero.
See also:
IShapeInfo.VertexCountA 'very small' positive value in the scale of this shape.
protected
field
|
epsilon
|
||
type
|
float64
|
||
inherited
|
ShapeVertices.epsilon
|
Maximum vertex index.
protected
field
|
n
|
||
type
|
int32
|
The polygon parity is negative?
protected
field
|
negative
|
||
type
|
bool
|
||
inherited
|
ShapePolygonBase.negative
|
The list of shape vertices.
protected
field
|
vertices
|
||
type
|
Vec2D[]
|
||
inherited
|
ShapeVertices.vertices
|
protected
constructor
|
ShapePolygonSimpleBase
(ISerialTypeInfo serialId)
|
||
params
|
serialId
|
protected
constructor
|
ShapePolygonSimpleBase
(ISerialTypeInfo serialId,
bool negative,
Vec2D[] vertices,
CoordinateSystem georef)
|
||
params
|
serialId
|
||
negative
|
|||
vertices
|
|||
georef
|
Computes the signed distance from the given point towards the polygon border.
protected
method
|
DistanceTo
(float64 x,
float64 y,
float64 distance,
Vec3I vertices,
Vec3D weights)
|
||
type
|
float64
|
||
params
|
x
|
X-coordinate of point. | |
y
|
Y-coordinate of point. | ||
distance
|
Absolute distance of point to polygon border (see remarks). | ||
vertices
|
The polygon contour segment that corresponds to distance. | ||
weights
|
Relative vertex weights of vertices. | ||
returns
|
The signed distance (negative is inside, positive is outside). | ||
inherited
|
ShapePolygonBase.DistanceTo
|
Remarks:
The absolute distance from a point to the polygon border can be computed by using the DistancePointToLineSegment method or by using a spatial quadtree of line segments (see SpatialQuadtree).
The vertices and weights parameters are interpreted as follows:
weights.Z = 0 weights.X >= weights.Y >= 0 weights.X + weights.Y = 1 point = this.vertices[vertices.X] * weights.X + this.vertices[vertices.Y] * weights.Y distance = | point - (x,y) |Additional information is encoded into vertices:
Distance to polygon vertex (weights.X == 1): vertices.X := vertex index of point (see above). vertices.Y := index of previous contour vertex or negative if not existent vertices.Z := index of next contour vertex of negative if not existent Distance to polygon edge (weights.X < 1): vertices.X := index of nearest edge vertex. vertices.Y := index of farthest edge vertex. vertices.Z := The polygon edge direction, expressed with X and Y: +1 : X->Y -1 : Y->X
Returns the next vertex.
protected
method
|
Next
(int32 vertex)
|
||
type
|
int32
|
||
params
|
vertex
|
The vertex index. | |
returns
|
Index of next vertex. |
Returns the previous vertex.
protected
method
|
Prev
(int32 vertex)
|
||
type
|
int32
|
||
params
|
vertex
|
The vertex index. | |
returns
|
Index of previous vertex. |