rwlogo
Rogue Wave Views 5.6

Rogue Wave Views
Foundation Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

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.
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.
IlvPointIlvCreateClosedSpline (IlUInt count, const IlvPoint *p, IlUInt &totalCount)
 Creates an array of points defining a closed Bézier spline.
IlvPointIlvCreateOpenSpline (IlUInt count, const IlvPoint *points, IlUInt &totalCount)
 Creates an array of points defining an open Bézier spline.
IlBoolean IlvIntersectHorizontal (const IlvPoint &point, const IlvPoint &from, const IlvPoint &to, IlInt *dir=0)
 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.
IlBoolean IlvPointInClosedSpline (const IlvPoint &p, IlUInt count, const IlvPoint *points)
 Returns IlTrue if the point is in a closed spline.
IlBoolean IlvPointInFilledSpline (const IlvPoint &p, IlUInt count, const IlvPoint *points, IlBoolean windingRule=((IlBoolean) 0))
 Returns IlTrue if the point is in a filled spline.
IlBoolean IlvPointInLine (const IlvPoint &p, const IlvPoint &from, const IlvPoint &to)
 Returns IlTrue if the point is in a line.
IlBoolean IlvPointInPolygon (const IlvPoint &p, IlUInt count, const IlvPoint *poly, IlBoolean windingRule=((IlBoolean) 0))
 Returns IlTrue if the point is in a polygon.
IlBoolean IlvPointInPolyline (const IlvPoint &p, IlUInt count, const IlvPoint *poly)
 Returns IlTrue if the point is in a polyline.
IlBoolean IlvPointInSpline (const IlvPoint &p, IlUInt count, const IlvPoint *points)
 Returns IlTrue if the point is in a spline.
char * IlvReadString (istream &is, char *buffer=0)
 Reads a string from an input stream.
istream & IlvSkipSpaces ()
 Skip spaces in a stream.
istream & IlvSkipTo (int character)
 Skip to a given character in a stream.
const char * IlvSpc ()
 Gets a 'space.'.
void IlvWriteString (ostream &stream, const char *string)
 Writes a string to an output stream.

Detailed Description

Utility functions.

[library display ilviews/util/util.h]


Function Documentation

void 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:
rect The rectangle that defines the size of the complete ellipse.
start The start angle of the desired arc in degrees.
range The angle range, in degrees, of the desired arc.
bbox The return value of this function.
See also:
IlvArc.
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.

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

Parameters:
from The starting point of the line segment.
to The ending point of the line segment.
atpos The position of the arrow on the segment:

  • 0 = arrow head on the from point.
  • 1 = arrow head on the to point.
points An array of at least three points that will be set to the computed coordinates that define the arrow.
arrowBase Half the size of the arrow base.
arrowLength The length of the arrow head.
See also:
IlvArrowLine.
IlvPoint * 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:
count The number of control points stored in points.
points The array of control points.
totalCount Is 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.
IlvPoint * 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:
count The number of control points stored in points.
points The array of control points.
totalCount Is 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:
point A point of the horizontal line.
from First point of the segment.
to Last point of the segment.
dir Indicates 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:
from1 First point of the first line.
to1 Last point of the first line.
from2 First point of the second line.
to2 Last point of the second line.
result Contains 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:
p The point.
count Point count of the closed spline.
points The 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 = ((IlBoolean) 0) 
)

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:
p The point.
count Point count of the filled spline.
points The points of the filled spline.
windingRule If 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:
p The point.
from First point of the line.
to Last 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 = ((IlBoolean) 0) 
)

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:
p The point.
count Point count of the polygon.
poly The points of the polygon.
windingRule If 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:
p The point.
count Point count of the polyline.
poly The 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:
p The point.
count Point count of the spline.
points The 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:
stream The input steam.
buffer If 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:
character The 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:
stream The output stream.
string The string to be saved.
See also:
IlvReadString, IlvSpc, ostream::operator<<.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

© 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.