class HT_Contour_Set


An HT_Contour_Set object specifies connected loops of vertices making up a set of polygons. The contour set description is used by methods of class HT_Font_Engine to provide the character outline of filled polygons which describe letters for various fonts.

For further examples of contours using these methods, see the Contour sample program in the \samples directory.

See Also HT_Font_Engine, HT_Font, HT_Rendition::complex_clip and the Contour sample program

For information on the use of HT_Countour_Set to implement polygonal clipping of polygons and polylines, see the section "Polygonal clipping," in chapter 2, "Heidi Architecture, The Transformation Pipeline."

Access methods
area_difference
Applies a Boolean operation that determines the remaining region after one overlapping loop is subtracted from another  
area_intersection
Applies a Boolean operation that determines the common intersecting region between two overlapping loops.
area_union
Applies a Boolean operation that determines the region resulting from the combining of two overlapping loops.
contours
The number of contours or loops in this set.
counts
An array of ints, which are x contours in length, that indicate the number of points in each loop.
fill_rule, set_fill_rule
Determines or sets which regions described by the loops are considered interior and are thus to be filled.

 

force_projection

 

Forces the projection of a 3D polygon to the 2D plane, especially when the Z buffer is large.
point_inside
Determines if a given point is inside a contour set.
points
Pointer to an array of points which describes the loops in consecutive order.
polygonize
Breaks a contour set into simpler polygonal pieces.
polyline_difference
Figures which parts of a polyline are outside the area of a contour set.
polyline_intersection
Figures which parts of a polyline are inside the area of a contour set..
triangulate
Breaks a contour set into simpler triangular pieces.
unwind
Changes the contour set fill rule from a non-zero winding rule to an even-odd rule.  
Operators
Operator ==
Compares contour set data
Operator !=
Compares the data of two contour set objects to see if they
are equal.
Operator =
Assigns contour set data.
Constructor
HT_Contour_Set
Creates an HT_Contour_Set object.  


HT_Contour_Set::area_difference

Purpose

Applies a Boolean operation that determines the remaining region after one overlapping loop is subtracted from another Synopsis
HT_Contour_Set area_difference (HT_Contour_Set const & second) alter
 Details This method subtracts one overlapping contour set region from another, leaving a remaining region to be filled. Figure 1 shows the 2 overlapping regions of a Kanji character and the resulting contour set from the application of an area difference Boolean method.
 
Figure 1.  area_difference
 


HT_Contour_Set::area_intersection

Purpose

Synopsis
HT_Contour_Set area_intersection (HT_Contour_Set const & second) alter
 Details This method combines one overlapping contour set with another so as to form a new region with common intersecting boundaries. Figure 2 shows the 2 overlapping regions of a Kanji character and the resulting contour set from the application of an area_intersection.
Figure 2.  area_intersection


HT_Contour_Set::area_union

Purpose

Applies a Boolean operation that determines the region  resulting from the combining of two overlapping loops. Synopsis  Details This method combines one overlapping contour set with another so as to form a new region with the common boundaries of both. Figure 3 shows the 2 overlapping regions of a Kanji character and the resulting contour set from the application of an area_union.
Figure 3.  area_union
 

HT_Contour_Set::contours

Purpose

The number of contours or loops in this set. Synopsis
int                 contours () const   {return m_data->m_contours;}
 

HT_Contour_Set::counts

Purpose

An array of ints, which are x contours in length, that indicate the number of points in each loop. Synopsis
int const *         counts () const     {return m_data->m_counts;}

HT_Contour_Set::fill_rule, set_fill_rule

Purpose

Determines or sets which regions described by the loops are considered interior and are thus to be filled. Synopsis
HT_Fill_Rule        fill_rule () const
void                set_fill_rule (HT_Fill_Rule fill) alter
Details This method determines and sets how a set of contours or loops is to be filled by encapsulating an enum, so as to establish the correct description for various font characters that contain holes or overlapping strokes. Examples are the letters "A" and "O", and various Kanji characters with overlapping strokes and voids.

Presently, one of three rules may be applied: even-odd, winding and quick font winding.

even-odd rule

The even-odd rule covers the usual situation where the filled area toggles between inside and outside closed loops such as is the case with the letter "O." This is shown in figure 4.

Figure 4. Even-odd rule
winding rule

The winding rule allows you to add or subtract based on the direction of the line that your stroke is crossing as opposed to the on or off situation as is the case with the even odd rule. This is shown in figure 5 and figure 6. The winding rule defaults to inside if its value is not 0.

Figure 5. Winding rule - character overlapping strokes
 
Figure 6.  Winding rule - case with holes
 

quick font winding rule

The quick font winding rule looks at the orientation of all loops. If they are all the same then it assumes character overlapping strokes and draws each individually; otherwise, if there are holes, it defaults to the even-odd rule. Consider this functionality in the fill pattern of the Kanji letter shown in figure 7.

Figure 7. Quick font winding rule
 

(Note: that winding rule fills do not operate perfectly in all cases at this time and should be thoroughly tested.)

For further examples of contours using these methods, see the Contour sample program in the \samples directory.
 


HT_Contour_Set::force_projection

Purpose

Forces the projection of a 3D polygon to 2D, especially when the Z buffer is large. Synopsis
void                force_projection (HT_Vector const & normal) alter
Details Most contour set projections are easily computed from 2D, however, some 3D polygons with large Z buffers could fail to properly project points to 2D.   force_projection assures that these 3D points are projected in 2D in spite of a large Z buffer.  

HT_Contour_Set::HT_Contour_Set

Purpose

Constructor to initialize a new contour set object. Synopsis
HT_Contour_Set::HT_Contour_Set (int count,
                                HT_Point const * points,
                                HT_Boolean copy)
HT_Contour_Set::HT_Contour_Set (int contours,
                                int const * counts,
                                HT_Point const * points,
                                HT_Boolean copy)
HT_Contour_Set ()
Details The first is a convenient form for the case where you have only one polygon, where an array is obviously not needed for just one number.

The second form is the normal case and the third form is the empty handle to declare a variable.
 

 

HT_Contour_Set::point_inside

Purpose

Determines if a given point is inside a contour set. Synopsis
HT_Boolean point_inside (HT_Point const & point)
Details Determines whether the point is inside the area of the contour set, based on the applicable fill rule.  


HT_Contour_Set::points

Purpose

Pointer to an array of points which describes the loops in consecutive order. Synopsis
HT_Point const *    points () const     {return m_data->m_points;}
Details The simple drawing in figure 8 is made up of 2 contours¾a rectangle and an interior triangle. In this case, counts is the array of ints describing the number of points in each contour. Thus, the counts array contains 4 and 3, and points is just an array of 7 points.
 
Figure 8. Example of points

HT_Contour_Set::polygonize

Purpose

Breaks a contour set into simpler polygonal pieces. Synopsis
void polygonize (HT_Polygonize_Action action, void * info = null)
Details The polygonize method breaks a contour set into simpler pieces so that the resulting polygons have no holes or self intersects. For example in figure 9, the letter "O", originally made up of 2 concentric circles, is broken up into 2 sets of concentric arcs wherein each set is connected so as to form a continuous loop. The figure is exaggerated to show that the resulting polygons have no holes or self intersects.
Figure 9. Example of polygonize
 
 
 

HT_Contour_Set::polyline_difference

Purpose

Figures which parts of a polyline are outside the area of a contour set. Synopsis
HT_Contour_Set polyline_difference (HT_Contour_Set const & second) alter
Details When using HT_Contour_Set for implementing polyline clipping, this method determines which parts of the clipped polyline are outside the area of the contour set.

For more information on the use of HT_Countour_Set to implement polygonal clipping of polygons and polylines, see the section "Polygonal clipping," in chapter 2, "Heidi Architecture, The Transformation Pipeline."
 


HT_Contour_Set::polyline_intersection

Purpose

Figures which parts of a polyline are inside the area of a contour set. Synopsis
HT_Contour_Set polyline_intersection (HT_Contour_Set const & second) alter
Details When using HT_Contour_Set for implementing polyline clipping, this method determines which parts of the clipped polyline are inside the area of the contour set. For more information on the use of HT_Countour_Set to implement polygonal clipping of polygons and polylines, see the section "Polygonal clipping," in chapter 2, "Heidi Architecture, The Transformation Pipeline."
 

HT_Contour_Set::triangulate

Purpose

Breaks a contour set into simpler triangular pieces. Synopsis
void triangulate (HT_Triangulate_Action action, void * info = null)
Details The triangulate method is similar to polygonize but breaks the contour set into triangles instead of polygons. For an example see figure 9.
 
 
 

HT_Contour_Set::unwind

Purpose

Changes the contour set fill rule from a non-zero winding rule to an even-odd fill rule. Synopsis
HT_Contour_Set unwind ()