|
CartoType API
|
#include <cartotype_graphics.h>
Public Member Functions | |
| TContour () | |
| TContour (const TOutlinePoint *aPoint, int32 aPoints, bool aClosed) | |
| int32 | Contours () const |
| void | GetContour (int32, TContour &aContour) const |
| CT_IMPORT TResult | Traverse (MPathTraverser &aTraverser, const TRect *aClip=NULL) const |
| const TOutlinePoint * | Point () const |
| const TOutlinePoint & | Point (int32 aIndex) const |
| int32 | Points () const |
| bool | Closed () const |
| CT_IMPORT bool | ClockwiseOrientation () const |
| CT_IMPORT bool | VertexClockwiseOrientation (int32 aIndex) const |
| CT_IMPORT bool | Contains (const TPoint &aPoint) const |
| CT_IMPORT const MPath * | ClippedContour (TResult &aError, const TRect &aClip, bool aAlwaysCreateNewPath=false) const |
| CT_IMPORT TResult | AppendClippedContour (COutline *aDest, const TRect &aClip) const |
| CT_IMPORT CContour * | TruncatedContour (TResult &aError, double aStart, double aEnd) const |
| CT_IMPORT CContour * | TransformedContour (TResult &aError, const TTransform &aTransform) const |
| CT_IMPORT CContour * | CentralPath (TResult &aError, CEngine &aEngine, const TRect &aClip, bool aFractionalPixels, TLine &aFallbackLine, bool aFallbackMustBeHorizontal) const |
| CT_IMPORT CContour * | Smooth (TResult &aError, double aRadius) |
| CT_IMPORT TResult | GetHorizontalPath (const TRect &aClip, bool aFractionalPixels, TLine &aLine) const |
| CT_IMPORT int32 | TopLeftIndex () const |
| CT_IMPORT bool | MayIntersect (const TRect &aRect) const |
| CT_IMPORT bool | Intersects (const TRect &aRect) const |
| CT_IMPORT void | GetCenterOfGravity (TPoint &aCenter) const |
| CT_IMPORT void | GetOrientation (const TPoint &aCenter, TPoint &aOrientation) const |
A contour that doesn't own its data. Contours are sequences of lines and curves.
| CartoType::TContour::TContour | ( | ) | [inline] |
Create an empty contour.
| CartoType::TContour::TContour | ( | const TOutlinePoint * | aPoint, |
| int32 | aPoints, | ||
| bool | aClosed | ||
| ) | [inline] |
Create a contour from a supplied array of points.
| CT_EXPORT CContour * TContour::CentralPath | ( | TResult & | aError, |
| CEngine & | aEngine, | ||
| const TRect & | aClip, | ||
| bool | aFractionalPixels, | ||
| TLine & | aFallbackLine, | ||
| bool | aFallbackMustBeHorizontal | ||
| ) | const |
Create a central path for a contour. The user of this function assumes ownership of the path.
As a fallback to be used if the central path is too short for a label, return a straight line intersecting the polygon in aFallbackLine; if the fallback line is (0,0) - (0,0), no fallback line could be created.
If aFallbackMustBeHorizontal is true force the fallback line to be horizontal.
| CT_EXPORT const MPath * TContour::ClippedContour | ( | TResult & | aError, |
| const TRect & | aClip, | ||
| bool | aAlwaysCreateNewPath = false |
||
| ) | const |
Clip the contour to the specified rectangle. If the contour is inside the clip rectangle and aAlwaysCreateNewPath is false return this contour, otherwise return a new one.
All generated points are within or on the edge of the the rectangle, using the Sutherland Hodgman polygon clipping algorithm (http://www.cs.fit.edu/~wds/classes/graphics/Clip/clip/clip.html) This version is slightly modified for efficiency and considers two edges at the same time, in order to save creation of intermediate contours on the heap.
| CT_EXPORT bool TContour::ClockwiseOrientation | ( | ) | const |
Return whether the contour has clockwise orientation. Algorithm from comp.graphics.algorithms FAQ 2.07.
| bool CartoType::TContour::Closed | ( | ) | const [inline] |
Return true if the contour is closed.
| CT_EXPORT bool TContour::Contains | ( | const TPoint & | aPoint | ) | const |
Return whether the contour contains the point. Algorithm from comp.graphics.algorithms FAQ 2.03.
| int32 CartoType::TContour::Contours | ( | ) | const [inline, virtual] |
Return the number of contours.
Implements CartoType::MPath.
| CT_EXPORT void TContour::GetCenterOfGravity | ( | TPoint & | aCenter | ) | const |
Return the center of gravity of the contour. Algorithm from comp.graphics.algorithms FAQ 2.02, based on weighted average of points of gravity of triangulation. The weight is based on the signed area of the triangle.
| void CartoType::TContour::GetContour | ( | int32 | aIndex, |
| TContour & | aContour | ||
| ) | const [inline, virtual] |
Return the contour indexed by aIndex.
Implements CartoType::MPath.
| CT_EXPORT TResult TContour::GetHorizontalPath | ( | const TRect & | aClip, |
| bool | aFractionalPixels, | ||
| TLine & | aLine | ||
| ) | const |
Return a horizontal line inside a polygon, suitable for drawing a label.
Return the orientation of the contour, given the center of gravity. This is also called the Principal axis transformation of the polygon. Algorithm based on the following quote from comp.graphics.algorithms (slightly edited), full thread called "polygon major axis anyone", by Hans-Bernard Broeker : The calculation of the (centered) second moments is what gives you the angle. There are actually 3 independent second moments: Ixx, Iyy, and Ixy. These form a symmetric 2x2 matrix:
(Ixx Ixy) (Ixy Iyy)
The "second moments" are actually the _principal_ second moments, i.e. the second moments in a coordinate system (x', y') that has been rotated relative to the present one such that Ix'y' is zero, and optionally also Ix'x' >= Iy'y'.
They're found by doing an eigenvector/eigenvalue analysis on that 2x2 matrix, also known as the 'principal axis transformation' in this context. -end of quote
Also refer to: http://kwon3d.com/theory/moi/prin.html for an explanation of principal axis.
| CT_EXPORT bool TContour::Intersects | ( | const TRect & | aRect | ) | const |
Return true if the path intersects a specified rectangle. For single points, this is true if the point is inside the rectangle. For open paths, this is true if at least one line intersects the rectangle. For closed paths, the polygon defined by the control points must intersect the rectangle.
Reimplemented from CartoType::MPath.
| CT_EXPORT bool TContour::MayIntersect | ( | const TRect & | aRect | ) | const |
Return true if the contour may possibly intersect the specified rectangle.
Return false if there is definitely no intersection. For contours with a single point, the return value is whether the point is in the rectangle.
A closed contour is treated as a polygon. The return value indicates whether the bounding box of the path's control points intersects the rectangle.
An unclosed contour is treated as a point or a line. The return value indicates whether the bounding box of the control points of the line segments and curves making up the line intersects the rectangle.
Reimplemented from CartoType::MPath.
| const TOutlinePoint* CartoType::TContour::Point | ( | ) | const [inline] |
Return a constant pointer to the start of the array of points.
| const TOutlinePoint& CartoType::TContour::Point | ( | int32 | aIndex | ) | const [inline] |
Return a point selected by its index.
| int32 CartoType::TContour::Points | ( | ) | const [inline] |
Return the number of points in the contour.
Create a smoothed version of a contour, such that no two points are closer than aRadius, except when the start and end are closer.
| CT_EXPORT int32 TContour::TopLeftIndex | ( | ) | const |
Return the index of the top left point of the contour.
| CT_EXPORT CContour * TContour::TransformedContour | ( | TResult & | aError, |
| const TTransform & | aTransform | ||
| ) | const |
Generate a new transformed contour.
| CT_EXPORT TResult TContour::Traverse | ( | MPathTraverser & | aTraverser, |
| const TRect * | aClip = NULL |
||
| ) | const |
Traverse a contour, extracting lines and curves and calling the virtual functions in aTraverser to process them.
Reimplemented from CartoType::MPath.
| CT_EXPORT CContour * TContour::TruncatedContour | ( | TResult & | aError, |
| double | aStart, | ||
| double | aEnd | ||
| ) | const |
Return a version of the contour truncated by removing a length equal to aStart at the start, and a length equal to aEnd at the end.
Either aStart or aEnd may be zero or negative; negative values cause extension instead of truncation.
This function treats all points as on-curve points, and therefore does not work properly for contours containing curves.
| CT_EXPORT bool TContour::VertexClockwiseOrientation | ( | int32 | aIndex | ) | const |
Return whether the given vertex has clockwise orientation.
1.7.5.1