Class Reference pointArray

An array of points to store polygon or path data. More...

Member

pointArray( )
pointArray(pointArray array)
pointArray(int size)
void addCornerArea(double value1,double value2,int angleInt=0)
void append(point p)
void attach(int x, int y)
void attachPoint(point p)
pointArray bezier2(point pstart, point pend, point pbezier,int maxDepth=-2)
pointArray bezier3(point pstart, point pend, point pbezierstart, point pbezierend, int maxDepth=-2)
pointArray BSpline()
point center()
point centerOfGravity()
void chamfer(double value,int type,int angleInt=0)
pointArray circle(point center,int radius,double angelstep)
void clear()
pointArray coil(point center,point p1,point p2,int turns, double angelstep)
pointArray ellipse(point center,int rx,int ry,double angelstep)
void filletBezier(double value,int type,int angleInt=0)
void filletRound(double value,int type,int angleInt=0)
void flip()
void insert(uint i, point p)
double length()
point maximum()
point minimum()
point point(int i)
void prepend(point value)
void resize(int size)
void set(int i, int x, int y)
void setPoint(int i,point p)
int size()
pointArray spirale(point center,point p1,point p2,double angelstep)

Detailed Description

graph LR e(element)--getPoints-->pa(pointArray) pa--point-->p(point) click e "/layoutscript/api/element" click pa "/layoutscript/api/pointarray" click p "/layoutscript/api/point" classDef thisClas fill:#eaf5fc,stroke:#3c7faa,stroke-width:4px; classDef clas fill:#eaf5fc,stroke:#3c7faa,stroke-width:1px; class pa thisClas class e,p clas

A pointArray is a variable-length list of point vertices for paths, polygons, and similar shapes. The usual source is getPoints on an element: a box yields two corners, a polygon or path yields every vertex, a cellref or text yields the origin. You can also grow a list with append, attach, or attachPoint, or call static helpers such as circle, bezier2, coil, and spirale. Pass the array to addBox or addPolygon on cell, or read point(i) in a loop. size is the count; minimum and maximum are the bounding-box corners; length is the path length in database units. Chamfer, fillet, flip, and BSpline edit or derive geometry. drawingField getPoints returns the points entered with point or the mouse before box or path.

Example:

element *e = layout->drawing->currentCell->firstElement->thisElement;
if (e == NULL)
 return 1;
pointArray pa = e->getPoints();
for (int i = 0; i < pa.size(); i++) {
 point p = pa.point(i);
 string sx, sy;
 sx.setNum(p.x());
 sy.setNum(p.y());
}

Member Function Documentation


pointArray::pointArray( )

Creates an empty array of points.


pointArray::pointArray(pointArray array)

Creates an array of points containing a copy of array.


pointArray::pointArray(int size)

Creates an array of points with the given size. New vertices start at the origin.


void pointArray::addCornerArea(double value1,double value2,int angleInt=0)

Modifies this array the same way cell addCornerAreaSelect does for selected polygons.

Parameter:
value1 first corner-area value
value2 second corner-area value
angleInt optional angle mode; 0 is the default

void pointArray::append(point p)

Adds p at the end of the array. The size increases by one. Identical to attachPoint. (introduced with release 20210215)


void pointArray::attach(int x, int y)

Adds a point with coordinates x, y at the end of the array. The size increases by one.


void pointArray::attachPoint(point p)

Adds p at the end of the array. The size increases by one.


static pointArray pointArray::bezier2(point pstart, point pend, point pbezier,int maxDepth=-2)

Builds a second-order Bezier curve from pstart to pend with control point pbezier. maxDepth sets the iterations: each increase of one doubles the number of points. -2 uses the defaults from the setup.

Parameter:
pstart start point
pend end point
pbezier control point
maxDepth iteration depth; -2 uses the setup default

Returns: a pointArray of the curve.

bezier 2nd order


static pointArray pointArray::bezier3(point pstart, point pend, point pbezierstart, point pbezierend, int maxDepth=-2)

Builds a third-order Bezier curve from pstart to pend with control points pbezierstart and pbezierend. maxDepth sets the iterations. -2 uses the defaults from the setup.

Parameter:
pstart start point
pend end point
pbezierstart first control point
pbezierend second control point
maxDepth iteration depth; -2 uses the setup default

Returns: a pointArray of the curve.

bezier 3rd order


pointArray pointArray::BSpline()

Builds a B-Spline through the current vertices. If the first point is identical with the last point, a closed B-Spline is assumed.

Returns: a pointArray of the spline.

B-Spine open and closed B-Spline, red entered pointArray, blue resulting path/polygon


point pointArray::center()

Returns: the centre of the bounding box of the polygon.


point pointArray::centerOfGravity()

Returns: the centre of gravity of the polygon.


void pointArray::chamfer(double value,int type,int angleInt=0)

Modifies this array the same way cell chamferSelect does for selected polygons.

Parameter:
value chamfer length or resulting edge length, depending on type
type 0 or 1, see the table below
angleInt optional angle mode; 0 is the default
Option Result
type 0
chamfer length is always the same value
Chamfer0
type 1
chamfer size differ on angle
resulting length of edge is the same value
Chamfer1

static pointArray pointArray::circle(point center,int radius,double angelstep)

Builds a circle around center with radius. angelstep is the resolution in degrees per point. Zero uses the default circle resolution from the setup.

Parameter:
center centre of the circle
radius radius in database units
angelstep degrees per point; 0 uses the setup default

Returns: a pointArray of the circle.


void pointArray::clear()

Removes all items from the list. (introduced with release 20230121)


static pointArray pointArray::coil(point center,point p1,point p2,int turns, double angelstep)

Builds a coil from p1 to p2 around center. angelstep is the resolution in degrees per point. Zero uses the default circle resolution from the setup. (introduced with release 20211010)

Parameter:
center centre of the coil
p1 start point
p2 end point
turns number of turns
angelstep degrees per point; 0 uses the setup default

Returns: a pointArray of the coil.

coil


static pointArray pointArray::ellipse(point center,int rx,int ry,double angelstep)

Builds an ellipse around center. rx and ry are the radii along x and y. angelstep is the resolution in degrees per point. Zero uses the default circle resolution from the setup.

Parameter:
center centre of the ellipse
rx radius along x
ry radius along y
angelstep degrees per point; 0 uses the setup default

Returns: a pointArray of the ellipse.


void pointArray::filletBezier(double value,int type,int angleInt=0)

Modifies this array the same way cell filletBezierSelect does for selected polygons. Corners are replaced by Bezier curves. type influences the size the same way chamfer does.

Parameter:
value fillet size
type size mode, same meaning as for chamfer
angleInt optional angle mode; 0 is the default

filletBezier


void pointArray::filletRound(double value,int type,int angleInt=0)

Modifies this array the same way cell filletRoundSelect does for selected polygons. Corners are replaced by circular curves. type influences the size the same way chamfer does.

Parameter:
value fillet size
type size mode, same meaning as for chamfer
angleInt optional angle mode; 0 is the default

filletRound


void pointArray::flip()

Reverses the order of the points. The first point becomes the last, and so on.


void pointArray::insert(uint i, point p)

Inserts p at index i. The size increases by one.

Parameter:
i i
p p

double pointArray::length()

Returns: the length of the polyline in database units. (introduced with release 20231231)


point pointArray::maximum()

Returns: the upper-right corner of the bounding box.


point pointArray::minimum()

Returns: the lower-left corner of the bounding box.


point pointArray::point(int i)

Returns: the point at index i.


void pointArray::prepend(point value)

Inserts value at the beginning of the list. (introduced with release 20260724)


void pointArray::resize(int size)

Changes the size of the array. If size is larger than the current size, new points are added at the end. If it is smaller, points at the end are deleted.


void pointArray::set(int i, int x, int y)

Sets the coordinates of the point at index i to x and y.

Parameter:
i index of the point
x new x coordinate
y new y coordinate

void pointArray::setPoint(int i,point p)

Sets index i to p.

Parameter:
i i
p p

int pointArray::size()

Returns: the number of points in the array.


static pointArray pointArray::spirale(point center,point p1,point p2,double angelstep)

Builds a spiral from p1 to p2 around center. angelstep is the resolution in degrees per point. Zero uses the default circle resolution from the setup. The spiral always has a single turn; for several turns use coil.

Parameter:
center centre of the spiral
p1 start point
p2 end point
angelstep degrees per point; 0 uses the setup default

Returns: a pointArray of the spiral.

spiral