Bool.dll Library Logo

Utility Functions

Convert2CounterClockwise

Convexing

AreaOfPolygon

Path2BndrysU

OPath2Bndrys

 

Path2Bndrys

PathClip2Wnd

GetCutLines

BoolClip_Union_MT

RtnEdges_MT

 

BoolConnectedSets

BoolClipPath2Region

BoolObjectInRegion

PointInsidePoly

PointInPolyArr



 

Convert2CounterClockwise

illustrates how a polygon's vertices are re-ordered to be in CCW order.

Syntax:

void Convert2CounterClockwise(int n, int* xy);

Function:

used to convert a polygon so that the vertices are arranged in the counter clockwise direction. Some CAD systems expect a polygon's vertices to appear in this direction and treat it as filled. The location of the first coordinate is not constrained.

Inputs:

n - number of vertices

xy - an array of xy coordinate pairs. The first and last pair are the same point.

Outputs:

xy - an array of coordinate pairs. The first and last pair are not changed but the order of the inner pairs may be to produce the desired direction.



Convexing

illustrates how a polygon is broken into convex pieces.

Syntax:

int Convexing
(int n, int* xy,
 int** numarr,int*** XYarr, int* pnumpolys,
 short cnv, short validate);

Function:

tests a polygon for convex (in X or both in X and Y) and breaks down polygons as needed to insure that they are convex. A single source polygon can generate multiple convex polygons.

Inputs:

n - number of vertices in the source polygon

xy - an array containing the vertex pairs for the source polygon.

cnv - BOOL_CONVEX_IN_X or BOOL_FULLY_CONVEX (this controls the type of convexing output independent of the Set_Cnv_Output_MT.)

validate - 0: do not perform validation on input; 1: perform validation on input.

data structure for convexing input

Outputs:

numarr - an array where each element contains the number of vertices for the output polygons.

XYarr - an contiguous array containing the vertex data for the polygons.

pnumpolys - number of output convex polygons

data structure for convexing output

Return Values:

  CONVEX_ERR    no output polygons - internal error
  CONVEX_OK     input data is not Manhattan
  CONVEX_MANH   input data is Manhattan

Note:



AreaOfPolygon

Syntax:

double AreaOfPolygon(int n, int* xy);

Function:

Used to compute the area of a polygon

Inputs:

n - number of vertices in the input polygon

xy - array containing the vertex pair list

Returns:

AreaOfPolygon - the computed area of the polygon.

Notes

The polygon input must be standard - not a Leonov polygon - however it may contain cut lines.





OPath2Bndrys

illustrates how the round end caps are approximated using chords.

Syntax:

int OPath2Bndrys
(int* xy,
 int u,
 int width,
 int*** XY_out_arr, int** pair_num_out_arr,
 short arcres,
 double chord_error);

Function:

Converts a path of Type 1 (round endcap) into boundary data. Each segment of the path is converted into its own boundary with an approximation of the round end caps.

Inputs:

xy - an array of vertices for the path

u - the number of vertices in the path

width - the width of the path

arcres - arc resolution (in degrees) to use for fracturing the end caps.

chord_error - chord error parameter to use for fracturing the end caps and bend radii. If set ==0 then the arc resolution parameter determines the number of chords.

If both arcres and chord_error are simultaneously specified, then the parameter that would produce the "finer" approximation is used.

input data structure for Opath2bndrys

Output:

XY_out_arr - an array containing the XY coordinates of the resulting boundaries.

pair_num_out_arr - an array containing the vertex count for each of the output boundaries

OPath2Bndrys - the function returns the number of output polys.

output data structure for Opath2bndrys

Return Code:

the number of polygons output




Path2BndrysUnion

Syntax:

int Path2BndrysUnion
(int* Path, int N,
 int*** XY_out_arr, int** pair_num_out_arr,
 int unionize, int bdll_handle);

Function:

Converts a path (of type 0 or 2) into a boundary. If unionize = 0, then the function returns boundaries representing individual path sections; if unionize = 1 then the individual sections are unionized into a single boundary.

Arguments

Path - an array whose first element is the Path Type (0 | 2) and second element the path width. Following those two elements are the list of XY coordinate pairs.

N = (2 x number of vertices) + 2 in the path.

unionize - 0 = do not unionize segments; 1 = unionize returned polygonal segments

input for path2bndry

bdll_handle - handle for this call.


Output:

XY_out_arr - an array containing the XY coordinate pairs.

pair_num_out_arr - an array containing vertex count of each output polygon.

output for path2bndry; union=0 output for path2bndry; union=1

Error codes:

0: (success)
non-zero value: the number of polygons created.




PathClip2Wnd

Syntax:

int PathClip2Wnd
(int* xy, int n, int* Wnd,
 int*** pXYarr, int** pNarr);

Function:

Used to test and clip a path (only type 0|2 - does not support type 1 paths) to a user specified window. If the path is fully contained inside of the window then the function returns 0. Otherwise, the path is broken into its segments. This function does not take into account a path's width.

illustrates the clipping of path data to a window

Inputs:

xy - an array containing the XY coordinates of the path. The first element of the array contains the path type (0|2) and the second element of the array contains the path width.

n - number of vertices in the path

Wnd - an array (4 elements) containing the LLx, LLy, URx and URy coordinates of the window.

input data structure for path

Output:

pXYarr - an XY coordinate array of all vertices for the resulting output paths
pNarr - an array of the number of vertices belonging to each path

Return Codes

0: (success)
non-zero value: indicating that an error occurred during initialization.

Example





GetCutLines

illustrates cutlines in a polygon.

Syntax:

int GetCutlines
(int* xy, int n,
 int** pXY, int* pN);

Function:

For a polygon with coordinate list xy, this function calculates the list of cutlines and returns them in an array.

Inputs:

xy - an array of the input polygon's coordinates

n - the number of vertices contained in the polygon.

input data structure for GetCutLines

Outputs:

pXY - an array containing the cut line coordinates (in pairs)

pN - the number of cut lines in the polygon. Since each cutline requires two vertices and cutlines always are enumerated in pairs, the number of elements in pXY is 4 x pN.

output data structure for GetCutLines

Return Codes:

 0 no cutlines were found
 1 cut lines returned

Related Functions

BoolRelease_array should be called after this function to release memory.





RtnEdges_MT

illustrates which edges are returned for sliced polygons.

Syntax:

RtnEdges_MT(int **xy, int bdll_handle);

Function:

will return a list of shared edges where a polygon was broken as a result of a polygon violating the max number of vertices restriction and when the output mode is set to butting. This function does not apply when output is set to cut lines.

If there are N returned edges, then the size of the xy array = 4 x N x sizeof(int).

xy[i*2],xy[i*2 + 1] and xy [i*2 +2],xy[i*2+3] are the endpoint coordinates of the ith returned edge.

Inputs:

bdll_handle: thread handle

Return Code

the number of edges found.

Related Functions

BoolRelease_array should be called after this function call to release memory; BoolSet_Maxpts_MT is used to set the maximum vertex count for a polygon.




BoolConnectedSets

Syntax:

int BoolConnectedSets
    (int** XY_in_arr, int* pair_num_in_arr, int bndrs,
      int*** pindexarr, int** pnumbers, int* psets);

Function:

This function takes a list of polygons as input and creates sets of touching/overlapping polygons. It then returns the number of groups, the number of polygons per group and indexes to the polygons by group.

connected sets are polygons that are touching or overlapping

Inputs:

XY_in_arr - an array of coordinate pairs for the input boundaries
pair_num_in_arrays - an array of the number of coordinate pairs
bndrs - the number of boundaries in the input set

array setup for input data

Output

output polygon groupings

pindexarr - an array of lists. This array will have one list for each connected set. Each list points to the locations of the polygons for that set.
pnumbers - an array containing the number of polygons in each set.
psets - an integer showing number of polygon sets (7 in this example)
output array configuration

Return codes:

0: all polygons are closed
non-zero value: indicates the number of non-closed boundaries.




BoolClipPath2Region

Syntax:

int BoolClipPath2Region
   (int* xy, int n, int width, int pathtype,
        int* bndry, int bndryVert, int*** pXYarr, int** pNarr, int index);

Function:

This function takes a path as the first input argument and a "clipping" boundary as the second input argument. The function first checks the validity of the clipping boundary and then whether the path lies fully outside of the boundary, completely inside of the boundary or crosses the boundary. If it crosses the boundary the function returns a new path that has been clipped to the edges of the boundary.

clipping a path to a boundary

Inputs:

xy - array of xy coordinates for the path
n - the number of vertices for the path
width - the width of the path
pathtype - 0 = flush; 1 = half round; 2 = half width extended.
bndry - the array of xy vertices for the clipping boundary
bndyrVert - the number of vertices making up the clipping boundary

Outputs:

pXYarr
pNarr
index

Returns:

-2: the boundary is not closed
-1: the path is fully outside of the boundary
 0: the path is completely inside of the boundary
positive integer: the number of boundaries returned within the region





BoolObjectInRegion

Syntax:

int BoolObjectInRegion
    (int* xy1, int n1, int pathtype1, int width1,
        int* xy2, int n2, int* pstatus, int index);

Function:

This function tells you if the entity under consideration (a path or boundary) is enclosed by the "reference" boundary. The first entity is either a boundary ( if pathtype1 = -1), or a path in which case pathtype1 = 0, 1 or 2. The second entity (i.e. the reference boundary) is always a boundary.

object in region test

Inputs:

The first object is either a a path or boundary description

int* xy1       an array of xy coordinates
int n1         the number of vertices

int pathtype1  the pathtype
 -1 = boundary
  0 = flush
  1 = half round,
  2 = half width extended

int width1     the path width

The second object is the reference boundary description

int* xy2      an array of xy coordinates
int n2        the number of vertices in this boundary  

Output

pstatus - the address of the variable answering the question: is object 1 inside of object 2?

    0 = the two objects intersect
    1 = object 1 lies completely inside of object 2
    2 = object 2 lies completely inside of object 1
    3 = the objects are disjoint

Return Codes

-2: the second object, the reference boundary is not closed
-1: the first object (a boundary) is not closed





PointInPolyArr

Syntax:

int PointInPolyArr
    (int x, int y, int** XYarr,
        int* pairnumarr, int N, int* indexarr);


Function:

given a point x,y and an array of polygons, you wish to determine if the point is inside or touching any of the polygons. Similar to the function PointInsidePoly but allows the user to specify a number of polygons at one time.

Inputs:

The first object is either a a path or boundary description

int x, int y    the point to evaluate
int** XYarr     an array of polygons   
int* pairnumarr an array of vertex counts for the polygons in XYarr
int N           the number of polygons in XYarr        
  

Output

int* indexarr   the caller's array where return values (0,1,2,3)
                will be stored for each point/polygon test. 

Return Codes

0  success
-1 failed

Related Function

PointsInsidePoly






PointInsidePoly

Syntax:

int PointInsidePoly (int x, int y, int n, int* xy);

Function:

This function determines whether the specified point is outside, inside, on an edge or on a vertex of a given polygon.

point inside of polygon

Inputs:

int x, int y    the coordinates of a point
int n           the number of vertices in the polygon
int* xy         an array of xy pairs for the polygon vertices

Return Code

0 - point is outside the polygon
1 - point is inside the polygon
2 - point is on an edge of the polygon
3 - point is on a vertex of the polygon







  Documentation Download Price Revision History



ARTWORK CONVERSION SOFTWARE, INC.       Company Profile
417 Ingalls St., Santa Cruz, CA 95060    Tel (831) 426-6163     Fax 426-2824    email: info@artwork.com