Mapper  0.9.0
API documentation
Classes | Macros | Typedefs | Functions
path.c File Reference

(9169056 on 6 Feb 2019)

#include <math.h>
#include "libocad.h"
#include "geometry.h"
Include dependency graph for path.c:

Classes

struct  _IntPath
 

Macros

#define MAX_PATH_POINTS   32768
 
#define F_PATH_CONTROL   1
 
#define F_PATH_CORNER   2
 
#define F_PATH_DASH   4
 
#define F_PATH_MOVE   8
 
#define F_PATH_NO_STROKE   16
 
#define F_PATH_HOLE   0x80
 

Typedefs

typedef struct _IntPath IntPath
 

Functions

bool ocad_path_iterate (u32 npts, const OCADPoint *pts, IntPathCallback callback, void *param)
 Iterates over an OCADPath by first converting it to an IntPath, and then calling ocad_internal_path_iterate. More...
 
s64 ocad_path_area (s32 *path, u32 start, u32 count)
 Returns the signed area of a subsection of path, in map units. More...
 
void ocad_path_map (const Transform *matrix, const OCADPoint *pts, OCADPoint *opts, u32 npts)
 Applies a matrix transformation to a collection of contiguous OCADPoints. More...
 
bool ocad_path_unmap (const Transform *matrix, const OCADPoint *pts, OCADPoint *opts, u32 npts)
 Applies the inverse of a matrix transformation to a collection of contiguous OCADPoints. More...
 
bool ocad_path_bounds_rect (OCADRect *rect, u32 npts, const OCADPoint *pts)
 Stores the smallest bounding rectangle that contains all the provided OCADPoints into rect. More...
 
bool ocad_path_bounds (s32 *rect, u32 npts, const OCADPoint *pts)
 Stores the smallest bounding rectangle that contains all the provided OCADPoints into rect, as an array of four integers in the order (min-x, min-y, max-x, max-y). More...
 
bool ocad_rect_grow (OCADRect *prect, s32 amount)
 Grows the boundaries of an OCADRect by the given amount, in map units. More...
 
bool ocad_rect_intersects (const OCADRect *r1, const OCADRect *r2)
 Calculates the intersection of r2 with r1. More...
 
void ocad_rect_union (OCADRect *r1, const OCADRect *r2)
 Merges the second rectangle into the first. More...
 

Macro Definition Documentation

◆ F_PATH_CONTROL

#define F_PATH_CONTROL   1

◆ F_PATH_CORNER

#define F_PATH_CORNER   2

◆ F_PATH_DASH

#define F_PATH_DASH   4

◆ F_PATH_HOLE

#define F_PATH_HOLE   0x80

◆ F_PATH_MOVE

#define F_PATH_MOVE   8

◆ F_PATH_NO_STROKE

#define F_PATH_NO_STROKE   16

◆ MAX_PATH_POINTS

#define MAX_PATH_POINTS   32768

Typedef Documentation

◆ IntPath

typedef struct _IntPath IntPath

Function Documentation

◆ ocad_path_area()

s64 ocad_path_area ( s32 path,
u32  start,
u32  count 
)

Returns the signed area of a subsection of path, in map units.

◆ ocad_path_bounds()

bool ocad_path_bounds ( s32 rect,
u32  npts,
const OCADPoint *  pts 
)

Stores the smallest bounding rectangle that contains all the provided OCADPoints into rect, as an array of four integers in the order (min-x, min-y, max-x, max-y).

Calculates the bounds of the given path and returns it in the provided rectangle.

If npts is 0, then the array is not modified and FALSE is returned; otherwise, it is modified and TRUE is returned.

◆ ocad_path_bounds_rect()

bool ocad_path_bounds_rect ( OCADRect *  rect,
u32  npts,
const OCADPoint *  pts 
)

Stores the smallest bounding rectangle that contains all the provided OCADPoints into rect.

Calculates the bounds of the given path and returns it in the provided rectangle.

All flags within the OCADRect are set to 0. If npts is 0, then rect is not modified and FALSE is returned; otherwise, it is modified and TRUE is returned.

◆ ocad_path_iterate()

bool ocad_path_iterate ( u32  npts,
const OCADPoint *  pts,
IntPathCallback  callback,
void *  param 
)

Iterates over an OCADPath by first converting it to an IntPath, and then calling ocad_internal_path_iterate.

Iterates over an set of OCAD points, providing a list of PostScript-like path segments.

◆ ocad_path_map()

void ocad_path_map ( const Transform matrix,
const OCADPoint *  pts,
OCADPoint *  opts,
u32  npts 
)

Applies a matrix transformation to a collection of contiguous OCADPoints.

Typically one or both of the point arrays would be part of an OCADPath. All flags within the OCADPoints are preserved; only the positions are modified. The arrays may point to the same location in order to map a set of points in-place.

◆ ocad_path_unmap()

bool ocad_path_unmap ( const Transform matrix,
const OCADPoint *  pts,
OCADPoint *  opts,
u32  npts 
)

Applies the inverse of a matrix transformation to a collection of contiguous OCADPoints.

This is done by inverting the matrix and then calling ocad_path_map. Returns TRUE if the call was successful, or FALSE if the supplied matrix was not invertible.

◆ ocad_rect_grow()

bool ocad_rect_grow ( OCADRect *  prect,
s32  amount 
)

Grows the boundaries of an OCADRect by the given amount, in map units.

Grows the given rectangle by the given amount, which may be negative.

The flags in the OCADRect are unaffected. This function always returns TRUE.

◆ ocad_rect_intersects()

bool ocad_rect_intersects ( const OCADRect *  r1,
const OCADRect *  r2 
)

Calculates the intersection of r2 with r1.

Returns true if the two rectangle intersect, FALSE otherwise.

If the result is empty, r1 is unchanged and FALSE is returned. Otherwise, the result is stored in r1 and TRUE is returned.

◆ ocad_rect_union()

void ocad_rect_union ( OCADRect *  r1,
const OCADRect *  r2 
)

Merges the second rectangle into the first.

Combines two OCADRects.

The flags in the OCADRect are unaffected. This function always returns TRUE.