Woolz Image Processing  Version 1.7.5
WlzPolyline

## Files

file  WlzPolyDecimate.c
Functions to decimate polyline and boundary domains The functions remove vertices that are parts of straight lines as defined by a maximum distance. The algorithm starts at vertex 1, walks along the line until at least one vertex between the start and current position is more than max-dist from the straight line between vertex 1 and current. All vertices between position 1 and current-1 are removed and position 1 is incremented (to what was current-1). The process is then repeated.

file  WlzPolyEquispace.c
Builds a new polygon domain with equi-spaced vertices.

file  WlzPolyReverse.c
Functions to reverse the vertex ordering in a polygon domain.

file  WlzPolySmooth.c
Smoothing operations for polylines.

file  WlzPolyToObj.c
Makes a domain object from a polygon.

file  WlzPolyUtils.c
Functions for manipulating polygon domains.

## Data Structures

struct  _WlzPolygonDomain
A 2D polyline domain with possible types: WLZ_POLYGON_INT, WLZ_POLYGON_FLOAT or WLZ_POLYGON_DOUBLE. Typedef: WlzPolygonDomain. More...

struct  _WlzPolygonDomain3
A 2D polyline domain with possible types:WLZ_POLYGON_INT, WLZ_POLYGON_FLOAT or WLZ_POLYGON_DOUBLE. Typedef: WlzPolygonDomain. More...

## Macros

#define MAX_POLYSMOOTH_ITERATIONS   10

## Enumerations

enum  _WlzPolyFillMode {
WLZ_SIMPLE_FILL,
WLZ_EVEN_ODD_FILL,
WLZ_VERTEX_FILL
}
Polygon fill modes. Typedef: WlzPolyFillMode. More...

## Functions

double WlzIVtx2TriangleHeight (WlzIVertex2 *vtxs, int i, int j, int k)
Calculate the height of a triangle from the last vertex to the line defined by the first two. Uses formula that can be derived from Faux and Pratt p57-65 or see my lab notebook #1, p17. For three vertices $$\mathbf{v_1}, \mathbf{v_2}, \mathbf{v_3},$$ we define the vectors $$\mathbf{r} = \mathbf{v_2} - \mathbf{v_1}$$, $$\mathbf{s} = \mathbf{v_3} - \mathbf{v_1}$$ then the the required height $$h$$ is given by:

$h = \frac{|\mathbf{r}|^2|\mathbf{s}|^2 - (\mathbf{r}\cdot\mathbf{s})^2} {|\mathbf{r}|^2}$

WlzPolygonDomainWlzPolyDecimate (WlzPolygonDomain *poly, int wrap, double maxDist, WlzErrorNum *dstErr)
Decimate a polyline by removing vertices that are within straight line segments as defined by a maximum distance. The algorithm starts at vertex 1, walks along the line until at least one vertex between the start and current position is more than maxDist from the straight line between vertex 1 and current. All vertices between position 1 and current-1 are removed and position 1 is incremented (to what was current-1). The process is then repeated. More...

double WlzPolyLength (WlzPolygonDomain *poly, int wrap, WlzErrorNum *dstErr)
Calculate the length of the input polyline. More...

WlzPolygonDomainWlzPolyEquispace (WlzPolygonDomain *poly, int wrap, double spacing, int keepOrigVtxs, WlzErrorNum *dstErr)
Create a new polygon domain with vertices qually spaced along the original polyline. The wrap value is preserved and if keepOrigVtxs is non-zero then the original vertices will be kept. This results in non-equal spacing but the new line will be faithfull to the old and not "cut-corners". More...

WlzPolygonDomainWlzPolyReverse (WlzPolygonDomain *poly, WlzErrorNum *dstErr)
Reverse the vertex ordering in a polygon domain. More...

WlzPolygonDomainWlzPolySmooth (WlzPolygonDomain *poly, int wrap, int iterations, WlzErrorNum *dstErr)
performs iterative 1-2-1 smoothing on the polyline treating the x & y values independently. The smoothing of an integer polyline is done by converting first to double vertices then cnverting back at the end. More...

int WlzPolyCrossings (WlzIVertex2 vtx, WlzPolygonDomain *pgdm, WlzErrorNum *dstErr)
Procedure to calculate winding number of the polygon with respect to the vertex. The algorithm is from "Comp Geom in C" by O'Rourke chap 7. It assumes integer vertices and that the vertex is not on the polyline. More...

int WlzPolyCrossingsD (WlzDVertex2 vtx, WlzPolygonDomain *pgdm, WlzErrorNum *dstErr)
Procedure to calculate winding number of the polygon with respect to the vertex. The algorithm is from "Comp Geom in C" by O'Rourke chap 7. It assumes double vertices and that the vertex is not on the polyline. More...

int WlzInsidePolyEO (WlzIVertex2 vtx, WlzPolygonDomain *pgdm, WlzErrorNum *dstErr)
Procedure to calculate if a vertex is inside the polygon using the even-odd rule. Algorithm from "Comp Geom in C" by O'Rourke chap 7 Assumes integer vertices and that the vertex is not on the polyline. More...

int WlzInsidePolyEOD (WlzDVertex2 vtx, WlzPolygonDomain *pgdm, WlzErrorNum *dstErr)
Procedure to calculate if a vertex is inside the polygon using the even-odd rule. Algorithm from "Comp Geom in C" by O'Rourke chap 7 Assumes integer vertices and that the vertex is not on the polyline. More...

WlzObjectWlzPolygonToObj (WlzObject *polygon, WlzPolyFillMode fillMode, WlzErrorNum *dstErr)
Convert the input polygon to an interval domain. The domain is defined by the fillMode see WlzPolyToObj(). More...

WlzObjectWlzPolyToObj (WlzPolygonDomain *pgdm, WlzPolyFillMode fillMode, WlzErrorNum *dstErr)
Convert the input polygon to an interval domain. The domain is defined by the fillMode: WLZ_SIMPLE_FILL - all pixels with winding number non-zero; WLZ_EVEN_ODD_FILL - all pixels with odd winding number; WLZ_VERTEX_FILL - all pixels through which the polyline passes. More...

WlzObjectWlzPolyTo8Polygon (WlzPolygonDomain *pgdm, int wrap, WlzErrorNum *dstErr)
Returns the 8-connected, integer vertex polyline corresponding to the input polygon. The wrap value (number of overlapping vertices of the polygon ends) is included in case this is called to create an 8-connected boundary fro which the wrap needs to be preserved. WLZ_POLYGON_FLOAT and WLZ_POLYGON_DOUBLE polylines are converted to integer vertices using WlzValueCopyFVertexToIVertex and WlzValueCopyDVertexToIVertex respectively. More...

WlzErrorNum WlzPolyVertices2I (WlzPolygonDomain *poly, int *dstArySz, WlzIVertex2 **dstPolyAry)
Access to an polygon domain's integer vertices. More...

WlzErrorNum WlzPolyVertices2D (WlzPolygonDomain *poly, int *dstArySz, WlzDVertex2 **dstPolyAry)
Access to an polygon domain's double precision vertices. More...

## Macro Definition Documentation

 #define MAX_POLYSMOOTH_ITERATIONS   10

Maximum number of iterations of 1-2-1 smoothing in WlzPolySmooth

Referenced by WlzPolySmooth().

## Enumeration Type Documentation

 enum _WlzPolyFillMode

Polygon fill modes. Typedef: WlzPolyFillMode.

Enumerator
WLZ_SIMPLE_FILL

Fill all pixels with winding number > 0

WLZ_EVEN_ODD_FILL

Fill all pixels with odd winding number

WLZ_VERTEX_FILL

Fill all pixels lying under the polyline

## Function Documentation

 double WlzIVtx2TriangleHeight ( WlzIVertex2 * vtxs, int i, int j, int k )

Calculate the height of a triangle from the last vertex to the line defined by the first two. Uses formula that can be derived from Faux and Pratt p57-65 or see my lab notebook #1, p17. For three vertices $$\mathbf{v_1}, \mathbf{v_2}, \mathbf{v_3},$$ we define the vectors $$\mathbf{r} = \mathbf{v_2} - \mathbf{v_1}$$, $$\mathbf{s} = \mathbf{v_3} - \mathbf{v_1}$$ then the the required height $$h$$ is given by:

$h = \frac{|\mathbf{r}|^2|\mathbf{s}|^2 - (\mathbf{r}\cdot\mathbf{s})^2} {|\mathbf{r}|^2}$

.

Returns
height of the triangle to vertex k from baseline defined by vertices i, j
Parameters
 vtxs vertex array i index of first vertex j index of second vertex k index of third vertex
Source:
WlzPolyDecimate.c

Referenced by WlzPolyDecimate().

 WlzPolygonDomain* WlzPolyDecimate ( WlzPolygonDomain * poly, int wrap, double maxDist, WlzErrorNum * dstErr )

Decimate a polyline by removing vertices that are within straight line segments as defined by a maximum distance. The algorithm starts at vertex 1, walks along the line until at least one vertex between the start and current position is more than maxDist from the straight line between vertex 1 and current. All vertices between position 1 and current-1 are removed and position 1 is incremented (to what was current-1). The process is then repeated.

Returns
decimated polygon domain, NULL on error
Parameters
 poly input polygon domain wrap wrap value of the input polyline, the returned line will have wrap=1 if the input wrap >= 1 maxDist distance parameter to test vertex removal dstErr error return
Source:
WlzPolyDecimate.c

Referenced by WlzBoundDecimate(), and WlzMeshTransformVerify().

 double WlzPolyLength ( WlzPolygonDomain * poly, int wrap, WlzErrorNum * dstErr )

Calculate the length of the input polyline.

Returns
length of the input polygon domain
Parameters
 poly input polygon domain wrap wrap value of the p[olygon dstErr error return
Source:
WlzPolyEquispace.c

Referenced by WlzPolyEquispace().

 WlzPolygonDomain* WlzPolyEquispace ( WlzPolygonDomain * poly, int wrap, double spacing, int keepOrigVtxs, WlzErrorNum * dstErr )

Create a new polygon domain with vertices qually spaced along the original polyline. The wrap value is preserved and if keepOrigVtxs is non-zero then the original vertices will be kept. This results in non-equal spacing but the new line will be faithfull to the old and not "cut-corners".

Returns
new polygon domain with equally spaced vertices and the given wrap value
Parameters
 poly input polygon domain wrap wrap value of the input polygon spacing required spacing keepOrigVtxs flag to retain the original vertices, currently ignored dstErr error return
Source:
WlzPolyEquispace.c

Referenced by WlzCMeshCompSurfMapToDomain(), and WlzPolySmooth().

 WlzPolygonDomain* WlzPolyReverse ( WlzPolygonDomain * poly, WlzErrorNum * dstErr )

Reverse the vertex ordering in a polygon domain.

Returns
New polygon domain with vertices reversed
Parameters
 poly input polygon domain dstErr error return
Source:
WlzPolyReverse.c
 WlzPolygonDomain* WlzPolySmooth ( WlzPolygonDomain * poly, int wrap, int iterations, WlzErrorNum * dstErr )

performs iterative 1-2-1 smoothing on the polyline treating the x & y values independently. The smoothing of an integer polyline is done by converting first to double vertices then cnverting back at the end.

Returns
smoothed polygon domain, NULL on error
Parameters
 poly input polygon domain, same type as the input polyline but after passing through WlzPolyEquispace wrap wrap parameter for the input polyline, the new will have the same wrap iterations number of ierations of 1-2-1 smoothing dstErr error return
Source:
WlzPolySmooth.c

Referenced by WlzBoundSmooth().

 int WlzPolyCrossings ( WlzIVertex2 vtx, WlzPolygonDomain * pgdm, WlzErrorNum * dstErr )

Procedure to calculate winding number of the polygon with respect to the vertex. The algorithm is from "Comp Geom in C" by O'Rourke chap 7. It assumes integer vertices and that the vertex is not on the polyline.

Returns
Winding number of the polyline with respect to the vertex
Parameters
 vtx input vertex pgdm input polygon domain dstErr error return
Source:
WlzPolyToObj.c

Referenced by WlzInsidePolyEO().

 int WlzPolyCrossingsD ( WlzDVertex2 vtx, WlzPolygonDomain * pgdm, WlzErrorNum * dstErr )

Procedure to calculate winding number of the polygon with respect to the vertex. The algorithm is from "Comp Geom in C" by O'Rourke chap 7. It assumes double vertices and that the vertex is not on the polyline.

Returns
Winding number of the polyline with respect to the vertex
Parameters
 vtx input vertex pgdm input polygon domain dstErr error return
Source:
WlzPolyToObj.c

Referenced by WlzInsidePolyEOD().

 int WlzInsidePolyEO ( WlzIVertex2 vtx, WlzPolygonDomain * pgdm, WlzErrorNum * dstErr )

Procedure to calculate if a vertex is inside the polygon using the even-odd rule. Algorithm from "Comp Geom in C" by O'Rourke chap 7 Assumes integer vertices and that the vertex is not on the polyline.

Returns
1 if the vertex is "inside" the polyline, 0 otherwise
Parameters
 vtx the input test vertex pgdm input polygon domain dstErr return error
Source:
WlzPolyToObj.c

References WLZ_ERR_NONE, and WlzPolyCrossings().

Referenced by WlzPolyToObj().

 int WlzInsidePolyEOD ( WlzDVertex2 vtx, WlzPolygonDomain * pgdm, WlzErrorNum * dstErr )

Procedure to calculate if a vertex is inside the polygon using the even-odd rule. Algorithm from "Comp Geom in C" by O'Rourke chap 7 Assumes integer vertices and that the vertex is not on the polyline.

Returns
1 if the vertex is "inside" the polyline, 0 otherwise
Parameters
 vtx the input test vertex pgdm input polygon domain dstErr return error
Source:
WlzPolyToObj.c

References _WlzIVertex2::vtX, WLZ_ERR_NONE, and WlzPolyCrossingsD().

 WlzObject* WlzPolygonToObj ( WlzObject * polygon, WlzPolyFillMode fillMode, WlzErrorNum * dstErr )

Convert the input polygon to an interval domain. The domain is defined by the fillMode see WlzPolyToObj().

Returns
Woolz 2D domain object corresponding to the input polygon
Parameters
 polygon input polygon object fillMode determines what is "inside" the domain, one of: WLZ_SIMPLE_FILL, WLZ_EVEN_ODD_FILL or WLZ_VERTEX_FILL dstErr return error
Source:
WlzPolyToObj.c
 WlzObject* WlzPolyToObj ( WlzPolygonDomain * pgdm, WlzPolyFillMode fillMode, WlzErrorNum * dstErr )

Convert the input polygon to an interval domain. The domain is defined by the fillMode: WLZ_SIMPLE_FILL - all pixels with winding number non-zero; WLZ_EVEN_ODD_FILL - all pixels with odd winding number; WLZ_VERTEX_FILL - all pixels through which the polyline passes.

Returns
Woolz 2D domain object corresponding to the input polygon domain
Parameters
 pgdm input polygon domain fillMode determines which pixels are part of the domain one of: WLZ_SIMPLE_FILL, WLZ_EVEN_ODD_FILL or WLZ_VERTEX_FILL dstErr return error
Source:
WlzPolyToObj.c

Referenced by WlzBoundToObj(), WlzGreyMask(), WlzGreyTemplate(), WlzMeshFromObjBox(), and WlzPolygonToObj().

 WlzObject* WlzPolyTo8Polygon ( WlzPolygonDomain * pgdm, int wrap, WlzErrorNum * dstErr )

Returns the 8-connected, integer vertex polyline corresponding to the input polygon. The wrap value (number of overlapping vertices of the polygon ends) is included in case this is called to create an 8-connected boundary fro which the wrap needs to be preserved. WLZ_POLYGON_FLOAT and WLZ_POLYGON_DOUBLE polylines are converted to integer vertices using WlzValueCopyFVertexToIVertex and WlzValueCopyDVertexToIVertex respectively.

Returns
8-connected polygon object
Parameters
 pgdm input polygon domain wrap wrap value of the new polygon domain dstErr error return
Source:
WlzPolyToObj.c
 WlzErrorNum WlzPolyVertices2I ( WlzPolygonDomain * poly, int * dstArySz, WlzIVertex2 ** dstPolyAry )

Access to an polygon domain's integer vertices.

Returns
Woolz error code.
Parameters
 poly Given polygon domain. dstArySz Destination pointer for the number of vertices. dstPolyAry Destination pointer for the vertices.
 WlzErrorNum WlzPolyVertices2D ( WlzPolygonDomain * poly, int * dstArySz, WlzDVertex2 ** dstPolyAry )

Access to an polygon domain's double precision vertices.

Returns
Woolz error code.
Parameters
 poly Given polygon domain. dstArySz Destination pointer for the number of vertices. dstPolyAry Destination pointer for the vertices.