PointObj, LineObj, BoxObj, MultiLineObj, FillPolygonObj, Extent -
helper classes that manage geometric information for structured graphics
#include <Unidraw/Graphic/geomobjs.h>
Unidraw defines several helper classes that store and manage
geometric information. Structured graphics objects may use these helper
classes to support their semantics. PointObj stores a point, LineObj stores
two points, and MultiLineObj stores any number of points. BoxObj and
FillPolygonObj define rectangular and polygonal areas, respectively. Extent
stores extent information, that is, the lower left corner and center of a
bounding box plus a fixed amount of extra space around the bounding box. All
these classes provide operations for computing geometric information.
- BoxObj(Coord
= 0, Coord = 0, Coord = 0, Coord = 0)
- BoxObj(BoxObj*)
- Construct a BoxObj, supplying either two coordinate pairs or another
BoxObj to specify the instance's bottom-left and top-right corners, which
are stored in its _left, _bottom, _right, and
_top public members.
- boolean
Contains(PointObj&)
- boolean
Intersects(BoxObj&)
- boolean
Intersects(LineObj&)
- Return whether this contains the given point and intersects the
given box or line, respectively.
- BoxObj operator -
(BoxObj&)
- BoxObj operator +
(BoxObj&)
- Compute the intersection (-) or union (+) of this and the given
box, returning the result. These operations do not affect this or
their argument.
- boolean
Within(BoxObj&)
- Return true if this falls completely within the given box.
Within will also return true if the boxes are identical.
- MultiLineObj(Coord*
= nil, Coord* = nil, int = 0)
- Create a MultiLineObj, optionally supplying coordinate arrays (and their
size) that define the vertices of the multiline. The MultiLineObj does
not copy these arrays but stores them directly. The MultiLineObj
stores this information in its _x, _y, and _count
public members.
- void
GetBox(BoxObj&)
- Calculate the bounding box circumscribing the MultiLineObj's vertices and
store it in the argument.
- boolean
Contains(PointObj&)
- boolean
Intersects(BoxObj&)
- boolean
Intersects(LineObj&)
- Return whether this contains the given point and intersects the
given box or line, respectively.
- boolean
Within(BoxObj&)
- Return true if this falls completely within the
MultiLineObj's bounding box. Within will also return true if the
boxes are identical.
- void
SplineToMultiLine(Coord* cpx, Coord* cpy, int count)
- void
ClosedSplineToMultiLine(Coord* cpx, Coord* cpy, int count)
- Linearize the open or closed B-Spline defined by the given set of control
points and store the result in this. These operations store the
linearized result in internal buffers and assign the addresses of these
buffers to _x and _y; they do not delete _x
and _y if they are non-nil prior to assignment.
- void
GrowBuf()
- Increase the size of the internal buffers used to store linearized
splines.
- boolean
CanApproxWithLine(
- double x0, double,
y0,
- double x1, double
y1,
- double x2, double
y2
- )
-
Return whether two connected line segments defined by the given three points
can be approximated visually with a single line between the
endpoints.
- void AddLine(double x0,
double y0, double x1, double y1)
- Add a line to the internal buffer of vertices.
- void
AddBezierArc(
- double x0, double
y0, double x1, double y1,
- double x2, double
y2, double x3, double y3
- )
-
Add lines approximating the appearance of a Bezier arc defined by the given
points to the internal buffer of vertices.
- void
CalcSection(
- Coord cminus1x, Coord
cminus1y, Coord cx, Coord cy,
- Coord cplus1x, Coord
cplus1y, Coord cplus2x, Coord cplus2y
- )
-
Add a Bezier arc to the internal buffer of vertices based on a series of
four B-spline control points, the one before and the two after (cx,
cy).
- void
Normalize()
- Copy the vertices defined by _x, _y, and _count into
_normx, _normy, and _normCount such that
(_normx[0], _normy[0]) is the lower-leftmost vertex and there are
no redundant vertices.
- Extent(
- float left = 0,
float bottom = 0,
- float cx = 0, float
cy = 0, float tol = 0
- )
- Extent(Extent&)
- Construct a new Extent, optionally supplying its parameters explicitly or
providing a existing Extent to copy. The parameters are stored in the
Extent's _left, _bottom, _cx, _cy, and
_tol public members.
- boolean
Undefined()
- Return whether the extent is undefined, that is, if (_left,
_bottom) and (_cx, _cy) are the same point.
- boolean
Within(Extent&)
- Return true if the given extent circumscribes this. Within
will also return true if the extents are identical.
- void
Merge(Extent&)
- Enlarge this extent to subsume area of the given extent.