rwlogo
Rogue Wave Views 5.6

Rogue Wave Views
Foundation Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

Functions
util.h File Reference

Utility functions. More...

#include <ilviews/ilv.h>
#include <ilviews/base/array.h>
#include <ilviews/base/iostream.h>

Functions

void IlvComputeArcBBox (const IlvRect &rect, IlFloat start, IlFloat range, IlvRect &bbox)
 Computes the bounding box of a portion of an ellipse. More...
 
void IlvComputeArrow (const IlvPoint &from, const IlvPoint &to, IlFloat atpos, IlvPoint *points, IlvDim arrowBase=4, IlvDim arrowLength=8)
 Computes the points that define an arrow on a segment. More...
 
IlvPointIlvCreateClosedSpline (IlUInt count, const IlvPoint *p, IlUInt &totalCount)
 Creates an array of points defining a closed Bézier spline. More...
 
IlvPointIlvCreateOpenSpline (IlUInt count, const IlvPoint *points, IlUInt &totalCount)
 Creates an array of points defining an open Bézier spline. More...
 
IlBoolean IlvIntersectHorizontal (const IlvPoint &point, const IlvPoint &from, const IlvPoint &to, IlInt *dir=0)
 Returns IlTrue if the horizontal line intercepts the segment. More...
 
IlBoolean IlvLinesIntersect (const IlvPoint &from1, const IlvPoint &to1, const IlvPoint &from2, const IlvPoint &to2, IlvPoint *result=0)
 Returns IlTrue if there is an intersection point between two lines. More...
 
IlBoolean IlvPointInClosedSpline (const IlvPoint &p, IlUInt count, const IlvPoint *points)
 Returns IlTrue if the point is in a closed spline. More...
 
IlBoolean IlvPointInFilledSpline (const IlvPoint &p, IlUInt count, const IlvPoint *points, IlBoolean windingRule=IlFalse)
 Returns IlTrue if the point is in a filled spline. More...
 
IlBoolean IlvPointInLine (const IlvPoint &p, const IlvPoint &from, const IlvPoint &to)
 Returns IlTrue if the point is in a line. More...
 
IlBoolean IlvPointInPolygon (const IlvPoint &p, IlUInt count, const IlvPoint *poly, IlBoolean windingRule=IlFalse)
 Returns IlTrue if the point is in a polygon. More...
 
IlBoolean IlvPointInPolyline (const IlvPoint &p, IlUInt count, const IlvPoint *poly)
 Returns IlTrue if the point is in a polyline. More...
 
IlBoolean IlvPointInSpline (const IlvPoint &p, IlUInt count, const IlvPoint *points)
 Returns IlTrue if the point is in a spline. More...
 
char * IlvReadString (istream &is, char *buffer=0)
 Reads a string from an input stream. More...
 
istream & IlvSkipSpaces ()
 Skip spaces in a stream. More...
 
istream & IlvSkipTo (int character)
 Skip to a given character in a stream. More...
 
const char * IlvSpc ()
 Gets a 'space.'. More...
 
void IlvWriteString (ostream &stream, const char *string)
 Writes a string to an output stream. More...
 

Detailed Description

Utility functions.

[library display ilviews/util/util.h]

Function Documentation

IlvComputeArcBBox ( const IlvRect rect,
IlFloat  start,
IlFloat  range,
IlvRect bbox 
)

Computes the bounding box of a portion of an ellipse.

Use this global function to compute the bounding box of an arc.

Parameters
rectThe rectangle that defines the size of the complete ellipse.
startThe start angle of the desired arc in degrees.
rangeThe angle range, in degrees, of the desired arc.
bboxThe return value of this function.
See Also
IlvArc.
IlvComputeArrow ( const IlvPoint from,
const IlvPoint to,
IlFloat  atpos,
IlvPoint points,
IlvDim  arrowBase = 4,
IlvDim  arrowLength = 8 
)

Computes the points that define an arrow on a segment.

Use this global function to compute the polygon points that define an arrow located on a line segment.

Parameters
fromThe starting point of the line segment.
toThe ending point of the line segment.
atposThe position of the arrow on the segment:
  • 0 = arrow head on the from point.
  • 1 = arrow head on the to point.
pointsAn array of at least three points that will be set to the computed coordinates that define the arrow.
arrowBaseHalf the size of the arrow base.
arrowLengthThe length of the arrow head.
See Also
IlvArrowLine.
IlvCreateClosedSpline ( IlUInt  count,
const IlvPoint p,
IlUInt totalCount 
)

Creates an array of points defining a closed Bézier spline.

This function creates the point arrays defining the edges of a closed shape that closely corresponds to the Bezier curve defined by the count points given in the points array.

Parameters
countThe number of control points stored in points.
pointsThe array of control points.
totalCountIs set to the number of output definition points.
Returns
An array of points that define the shape of the output spline. This array is allocated by an IlPoolOf(IlvPoint).
See Also
IlvClosedSpline, IlvCreateOpenSpline, IlvSpline.
IlvCreateOpenSpline ( IlUInt  count,
const IlvPoint points,
IlUInt totalCount 
)

Creates an array of points defining an open Bézier spline.

This function creates the point arrays defining the edges of an open shape that closely corresponds to the Bezier curve defined by the count points given in the points array.

Parameters
countThe number of control points stored in points.
pointsThe array of control points.
totalCountIs set to the number of output definition points.
Returns
An array of points that define the shape of the output spline. This array is allocated by an IlPoolOf(IlvPoint).
See Also
IlvClosedSpline, IlvCreateClosedSpline, IlvSpline.
IlBoolean IlvIntersectHorizontal ( const IlvPoint point,
const IlvPoint from,
const IlvPoint to,
IlInt dir = 0 
)

Returns IlTrue if the horizontal line intercepts the segment.

Parameters
pointA point of the horizontal line.
fromFirst point of the segment.
toLast point of the segment.
dirIndicates how the horizontal line crosses the segment. If the returned value is IlTrue and dir is not null, this function will increment or decrement *dir, whether the segment crosses the horizontal ray from right-to-left (+1) or from left-to-right (-1). If the segment is included in the horizontal ray, *dir is not modified.
Returns
IlTrue if the horizontal line intercepts the segment.
IlBoolean IlvLinesIntersect ( const IlvPoint from1,
const IlvPoint to1,
const IlvPoint from2,
const IlvPoint to2,
IlvPoint result = 0 
)

Returns IlTrue if there is an intersection point between two lines.

Parameters
from1First point of the first line.
to1Last point of the first line.
from2First point of the second line.
to2Last point of the second line.
resultContains the coordinates of the intersection point if there is an intersection between the two lines.
Returns
IlTrue if there is an intersection point between the two lines.
IlBoolean IlvPointInClosedSpline ( const IlvPoint p,
IlUInt  count,
const IlvPoint points 
)

Returns IlTrue if the point is in a closed spline.

Parameters
pThe point.
countPoint count of the closed spline.
pointsThe points of the closed spline.
Returns
IlTrue if the point is in the closed spline.
IlBoolean IlvPointInFilledSpline ( const IlvPoint p,
IlUInt  count,
const IlvPoint points,
IlBoolean  windingRule = IlFalse 
)

Returns IlTrue if the point is in a filled spline.

The algorithm of this function considers an infinite horizontal ray starting at the point and determines the intersections of this ray with the spline outline path. The results depend on the spline fill-rule: Odd-Even rule: the point is "in" if there is and odd number of intersections and "out" if it's an even number. Winding rule: the point is "in" if there is an unequal number of intersections from left to right and from right to left, as observed from the point. The point is "out" if these numbers are equal.

Parameters
pThe point.
countPoint count of the filled spline.
pointsThe points of the filled spline.
windingRuleIf the value is IlTrue, the rule used is Winding, otherwise it is the Odd-Even rule.
Returns
IlTrue if the point is in the filled spline.
IlBoolean IlvPointInLine ( const IlvPoint p,
const IlvPoint from,
const IlvPoint to 
)

Returns IlTrue if the point is in a line.

Parameters
pThe point.
fromFirst point of the line.
toLast point of the line.
Returns
IlTrue if the point is in the line.
IlBoolean IlvPointInPolygon ( const IlvPoint p,
IlUInt  count,
const IlvPoint poly,
IlBoolean  windingRule = IlFalse 
)

Returns IlTrue if the point is in a polygon.

The algorithm of this function considers an infinite horizontal ray starting at the point and determines the intersections of this ray with the polygon outline path. The results depend on the polygon fill-rule : Odd-Even rule: the point is "in" if there is and odd number of intersections and "out" if it's an even number. Winding rule: the point is "in" if there is an unequal number of intersections from left to right and from right to left, as observed from the point. The point is "out" if these numbers are equal.

Parameters
pThe point.
countPoint count of the polygon.
polyThe points of the polygon.
windingRuleIf the value is IlTrue, the rule used is Winding, otherwise it is the Odd-Even rule.
Returns
IlTrue if the point is in the polygon.
IlBoolean IlvPointInPolyline ( const IlvPoint p,
IlUInt  count,
const IlvPoint poly 
)

Returns IlTrue if the point is in a polyline.

Parameters
pThe point.
countPoint count of the polyline.
polyThe points of the polyline.
Returns
IlTrue if the point is in the polyline.
IlBoolean IlvPointInSpline ( const IlvPoint p,
IlUInt  count,
const IlvPoint points 
)

Returns IlTrue if the point is in a spline.

Parameters
pThe point.
countPoint count of the spline.
pointsThe points of the spline.
Returns
IlTrue if the point is in the spline.
char* IlvReadString ( istream &  is,
char *  buffer = 0 
)

Reads a string from an input stream.

Reads a complete description of a string from the input stream designated by stream and returns a pointer to the read character array.
You can specify a buffer where the returned string is stored. It must be large enough to hold the incoming data.
When reading a string, IlvReadString expects an opening double quote character to start loading the data. It will convert C character escape sequences to regular characters, and will return when the closing double quote is reached.

Parameters
streamThe input steam.
bufferIf not 0, this designates the buffer where the string is stored. If buffer is 0, an internal buffer is allocated.
Warning
[code] When this function uses an internal buffer to store the returned string (buffer is 0), this buffer may be overwritten by another call in the library. It uses an IlPoolOf(Char). If you need to keep this buffer, lock the data (see IlPoolOf(NAME)) or copy this string before you call another function of Rogue Wave Views. You must never try to delete this array.
See Also
IlvWriteString, IlvSkipSpaces, IlvSkipTo, ostream::operator>>.
istream& IlvSkipSpaces ( )

Skip spaces in a stream.

This function actually is manipulator that is, a class that acts like a function in a stream context.
Use it to skip unwanted space characters when reading from istreams.
This function moves the current read pointer of the stream to the character located after any space character. A character is considered to be a space character if it has one of the ASCII codes: 32 (space), 10 (line feed), 13 (carriage return) or 7 (tab). The stream is in an eof state on return if the function cannot locate any space character in this input stream.
A common usage is to skip space areas before checking an incoming value:

istream stream;
...
stream << IlvSkipSpaces();
if (stream.get() != ':')
Error(ColonExpected);
See Also
IlvSpc, IlvSkipTo, IlvReadString.
istream& IlvSkipTo ( int  character)

Skip to a given character in a stream.

This function actually is manipulator that is, a class that acts like a function in a stream context.
It moves the current read pointer of the stream to the character located just after the next character character. The stream is in eof state on return if the given character cannot be located in this input stream.
A common use is to skip the closing delimiter of a block descriptor:

stream >> IlvSkipto(CloseDelimiter);
if (stream.eof())
Error(NoOpenDelimiter);
// read the delimited part
stream >> IlvSkipto(CloseDelimiter);
if (stream.eof())
Error(NoCloseDelimiter);
Parameters
characterThe character after which to move the read pointer.
const char* IlvSpc ( )

Gets a 'space.'.

This global function returns a static string that contains only a white space, followed by the ending 0. This is used internally to save static data space.
A common usage is to output spaces in output streams:

stream << someValue << IlvSpc() << someOtherValue;

You must not modify nor delete the returned string.

See Also
IlvWriteString, IlvSkipTo, IlvSkipSpaces.
void IlvWriteString ( ostream &  stream,
const char *  string 
)

Writes a string to an output stream.

This function writes a complete description of the string parameter into the indicated output stream. The output is made of an opening double quote character (") followed by the string contents, where each special character is replaced by its C escape sequence. A closing double quote is added at the end of the output.

Parameters
streamThe output stream.
stringThe string to be saved.
See Also
IlvReadString, IlvSpc, ostream::operator<<.

© Copyright 2012, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.