Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

geomlib/item.h File Reference

GEOMLIB - Base class for "items" in GEOMLIB. More...

#include "geomlib/vector.h"
#include "geomlib/cache.h"

Go to the source code of this file.

Defines

#define GEOM_DUMP_CLASS   0x1
#define GEOM_DUMP_OWNER   0x2
#define GEOM_DUMP_ITEMS   0x4
#define GEOM_DUMP_RECURSIVE   0x8
#define GEOM_DUMP_ALL   0xffffffff
#define GEOM_ITEM_FLAGS(i)   GEOM_INSTANCE_FLAGS2(i)
#define GEOM_ITEM_CLOSED   0x01
#define GEOM_ITEM_GROUP   0x02
#define GEOM_ITEM_PATH   0x04
#define GEOM_ITEM_ZERO_FLAG   0x80
#define GEOM_ITEM_EXPANSION_VALID   0x08
#define geom_item_VMT
#define geom_item_INIT
#define GEOM_ITEM_CALL(method)   GEOM_INSTANCE_VMT(item, item, method)(item)
#define GEOM_ITEM_CALL2(method,)   GEOM_INSTANCE_VMT(item, item, method)(item, __VA_ARGS__)
#define GEOM_ITEM_CALL_RET(method)   return GEOM_INSTANCE_VMT(item, item, method)(item)
#define GEOM_ITEM_CALL2_RET(method,)   return GEOM_INSTANCE_VMT(item, item, method)(item, __VA_ARGS__)
#define GEOM_ITEM_EDEF(method)   static inline int geom_item_##method##__invalid(void UNUSED *item) { GEOM_FUNC; GEOM_ERET(GEOM_ERR_ITEM_INVALID); }
#define GEOM_ITEM_EDEF2(method,)   static inline int geom_item_##method##__invalid(void UNUSED *item, __VA_ARGS__) { GEOM_FUNC; GEOM_ERET(GEOM_ERR_ITEM_INVALID); }
#define GEOM_ITEM_RDEF(method)   static inline real geom_item_##method##__invalid(void UNUSED *item) { GEOM_FUNC; geom_errno = GEOM_ERR_ITEM_INVALID; GEOM_RRET(NAN); }
#define GEOM_ITEM_RDEF2(method,)   static inline real geom_item_##method##__invalid(void UNUSED *item, __VA_ARGS__) { GEOM_FUNC; geom_errno = GEOM_ERR_ITEM_INVALID; GEOM_RRET(NAN); }
#define GEOM_ITEM_ASSERT(nclass, i)   GEOM_ASSERT2(item_call,(void *)i,GEOM_CLASS(nclass))
#define GEOM_ITEM_ASSERTX(nclass, i)   GEOM_ASSERTX2(item_call,(void *)i,GEOM_CLASS(nclass))
#define GEOM_ITEM_INIT(item, nclass)   GEOM_INSTANCE_INIT(item, nclass)
#define GEOM_ITEM_ZERO_INIT(item, nclass)   GEOM_INSTANCE_ZERO_INIT(item, nclass)
#define GEOM_ITEM_CREATE(item, nclass)   do{GEOM_INSTANCE_CREATE(item, nclass, geom_##nclass##_create);}while(0)
#define GEOM_ITEM_ZERO_CREATE(item, nclass)   do{GEOM_INSTANCE_ZERO_CREATE(item, nclass, geom_##nclass##_create);}while(0)
#define GEOM_ITEM_DESTROY(item)   GEOM_INSTANCE_DESTROY(item)

Functions

 GEOM_CLASS_HEAD (item, o)
void geom_item_create (struct geom_item UNUSED *item)
 Item constructor.

void geom_item_destroy (struct geom_item UNUSED *item)
 Item destructor.

const void * geom_item_assert (const void *item, GEOM_ASSERT_DEF)
const void * geom_item_call_assert (GEOM_ASSERT_DEF, const void *item, struct geom_class *pclass)
int geom_item_valid (const void *item)
 Item validation.

int geom_item_valid__default (const void UNUSED *item)
void geom_item_dump (const void *item, uns flags)
 Dump a given item.

void geom_item_subdump (const struct geom_item UNUSED *item, uns UNUSED flags)
void geom_item_copy (void *item, void *src)
 Makes an exact copy of another item.

void geom_item_copy__default (void *item, void *src)
void geom_item_copy__fail (void *item, void *src)
void * geom_item_duplicate (void *item)
 Allocate a new item of same class type and copy data.

void geom_item_after_change (void *item)
 Should be called after any manual change to item's data.

void geom_item_after_change__empty (void UNUSED *item)
real geom_item_tlength (void *item)
 Returns TIME parametrization length (1 for elementary curves).

real geom_item_alength (void *item)
 Returns Euclidean arc length (ATIME parametrization).

int geom_item_blength (void *item)
 Returns BTIME parametrization length.

real geom_item_time_to_atime (void *item, real time)
 Conversion from TIME to ATIME parametrization.

int geom_item_times_to_atimes (void *item, uns count, real *times, real *atimes)
 Converstion from TIME to ATIME parametrization.

real geom_item_atime_to_time (void *item, real atime)
 Conversion from ATIME to TIME parametrization.

int geom_item_atimes_to_times (void *item, uns count, real *atimes, real *times)
 Converstion from ATIME to TIME parametrization.

real geom_item_time_to_ratime (void *item, real time)
 Conversion from TIME to RATIME parametrization.

int geom_item_times_to_ratimes (void *item, uns count, real *times, real *ratimes)
 Converstion from TIME to RATIME parametrization.

real geom_item_ratime_to_time (void *item, real ratime)
 Conversion from RATIME to TIME parametrization.

int geom_item_ratimes_to_times (void *item, uns count, real *ratimes, real *times)
 Converstion from RATIME to TIME parametrization.

int geom_item_time_dif_btime (void *item)
 Returns whether TIME and BTIME are different.

real geom_item_time_to_btime (void *item, struct geom_expansion *expansion, real time)
 Conversion from TIME to BTIME parametrization.

int geom_item_times_to_btimes (void *item, struct geom_expansion *expansion, uns count, real *times, real *btimes)
 Converstion from TIME to BTIME parametrization.

real geom_item_btime_to_time (void *item, struct geom_expansion *expansion, real btime)
 Conversion from BTIME to TIME parametrization.

int geom_item_btimes_to_times (void *item, struct geom_expansion *expansion, uns count, real *btimes, real *times)
 Converstion from BTIME to TIME parametrization.

const struct geom_expansion * geom_expansion_assert (GEOM_ASSERT_DEF, const struct geom_expansion *expansion)
int geom_item_expansion_append (void *item, struct geom_fpath *expansion)
 Expand curve to tail of expansion path.

geom_expansion * geom_item_expand (void *item)
 Makes one reference to item expansion.

void geom_expansion_unref (struct geom_expansion *ref)
 Unref one reference to expansion structure.

int geom_item_to_bezier (void *item, struct geom_bezier *bezier)
 Convert curve to single Bezier curve, if possible.

int geom_item_conversion_append (void *item, uns flags, struct geom_fpath *result)
int geom_item_convert (void *item, uns flags, struct geom_fpath *result)
int geom_old_expand (void *item, struct geom_path *path)
int geom_item_split (void *item, real time, void *left, void *right)
int geom_item_split_middle (void *item, void *left, void *right)
int geom_item_reverse (void *item, void UNUSED *result)
int geom_item_part (void *item, real left_time, real right_time, void UNUSED *result)
int geom_item_transform (void *item, struct geom_transform *transform, void *dest)
 Apply affine transformation to a given curve.

int geom_item_is_closed (void *item)
 Returns whether item is a closed curve.

int geom_item_point_start (void *item, struct geom_point *result)
 Returns starting point of given curve.

int geom_item_point_end (void *item, struct geom_point *result)
 Returns ending point of given curve.

int geom_item_point_at_time (void *item, real time, struct geom_point *result)
 Returns curve point at given parameter.

int geom_item_derivation_start (void *item, struct geom_vector *result)
 Returns first derivation in curve starting point.

int geom_item_derivation_end (void *item, struct geom_vector *result)
 Returns first derivation in curve ending point.

int geom_item_derivation_at_time (void *item, real time, struct geom_vector *result)
 Returns first derivation in a given curve point.

int geom_item_bbox (void *item, struct geom_rectangle *bbox)
 Returns bounding box of a given curve.

int geom_item_nearest_to_point (void *item, struct geom_point *point, uns flags, struct geom_nearest *nearest)
 Finds nearest point on curve to a given point.

int geom_item_direction_times (void *item, struct geom_vector *dir, struct garr *result)
 Find TIME parameters, with derivation vector parallel to a given vector.

int geom_item_horizontal_times (void *item, struct garr *result)
 Find TIME parameters, with derivation vector parallel to X-axis.

int geom_item_distance_times (void *item, struct geom_point *point, real dist, struct garr *result)
int geom_items_intersections (void *item, void *item2, uns flags, struct garr *result)
 Finds intersections of two given curves.


Detailed Description

GEOMLIB - Base class for "items" in GEOMLIB.

Copyright (c) 2004-2005 The VRR Team <vrr@ucw.cz> This program is distributed under GNU General Public License, see COPYING.


Function Documentation

void geom_expansion_unref struct geom_expansion *  ref  ) 
 

Unref one reference to expansion structure.

If number of references decreased to zero, expansion can be destroyed anytime.

void geom_item_after_change void *  item  )  [inline, static]
 

Should be called after any manual change to item's data.

Invalidates cache of item and derived groups.

Parameters:
item Item pointer.

real geom_item_alength void *  item  )  [inline, static]
 

Returns Euclidean arc length (ATIME parametrization).

Parameters:
item Item pointer.
Return values:
finite Euclidean arc length.
otherwise Failed.

real geom_item_atime_to_time void *  item,
real  atime
[inline, static]
 

Conversion from ATIME to TIME parametrization.

Parameters:
item Item pointer.
atime Source parametrization value.
Return values:
finite Destination parametrization value.
otherwise Failed.

int geom_item_atimes_to_times void *  item,
uns  count,
real *  atimes,
real *  times
[inline, static]
 

Converstion from ATIME to TIME parametrization.

Parameters:
item Item pointer.
count Number of parameters to convert.
atimes Sorted array of source parametrization values.
times Buffer for sorted destination parametrization values.
Return values:
zero Success.
GEOM_ERR_NUMERIC Numeric error.
GEOM_ERR_ITEM_INVALID Invalid type of item for this function.

int geom_item_bbox void *  item,
struct geom_rectangle bbox
[inline, static]
 

Returns bounding box of a given curve.

Parameters:
item Item pointer.
bbox Resulting bounding box.
Return values:
zero Success.
GEOM_ERR_NUMERIC Numeric error.
GEOM_ERR_ITEM_INVALID Invalid type of item for this function.
GEOM_ERR_PATH_EMPTY Path is empty.

int geom_item_blength void *  item  )  [inline, static]
 

Returns BTIME parametrization length.

Parameters:
item Item pointer.
Return values:
non-negative Number of Bezier curves in expansion.
negative Failed.

real geom_item_btime_to_time void *  item,
struct geom_expansion *  expansion,
real  btime
[inline, static]
 

Conversion from BTIME to TIME parametrization.

Parameters:
item Item pointer.
btime Source parametrization value.
Return values:
finite Destination parametrization value.
otherwise Failed.

int geom_item_btimes_to_times void *  item,
struct geom_expansion *  expansion,
uns  count,
real *  btimes,
real *  times
[inline, static]
 

Converstion from BTIME to TIME parametrization.

Parameters:
item Item pointer.
count Number of parameters to convert.
btimes Sorted array of source parametrization values.
times Buffer for sorted destination parametrization values.
Return values:
zero Success.
GEOM_ERR_NUMERIC Numeric error.
GEOM_ERR_ITEM_INVALID Invalid type of item for this function.

void geom_item_copy void *  item,
void *  src
[inline, static]
 

Makes an exact copy of another item.

Owner of destination item is not changed. Can be used as item constructor.

Parameters:
item Destination item.
src Source item.

int geom_item_derivation_at_time void *  item,
real  time,
struct geom_vector result
[inline, static]
 

Returns first derivation in a given curve point.

Parameters:
item Item pointer.
time TIME parameter.
result Resulting vector.
Return values:
zero Success.
GEOM_ERR_NUMERIC Numeric error.
GEOM_ERR_ITEM_INVALID Invalid type of item for this function.
GEOM_ERR_PATH_EMPTY Path is empty.

int geom_item_derivation_end void *  item,
struct geom_vector result
[inline, static]
 

Returns first derivation in curve ending point.

Parameters:
item Item pointer.
result Resulting vector.
Return values:
zero Success.
GEOM_ERR_NUMERIC Numeric error.
GEOM_ERR_ITEM_INVALID Invalid type of item for this function.
GEOM_ERR_PATH_EMPTY Path is empty.

int geom_item_derivation_start void *  item,
struct geom_vector result
[inline, static]
 

Returns first derivation in curve starting point.

Parameters:
item Item pointer.
result Resulting vector.
Return values:
zero Success.
GEOM_ERR_NUMERIC Numeric error.
GEOM_ERR_ITEM_INVALID Invalid type of item for this function.
GEOM_ERR_PATH_EMPTY Path is empty.

int geom_item_direction_times void *  item,
struct geom_vector dir,
struct garr *  result
[inline, static]
 

Find TIME parameters, with derivation vector parallel to a given vector.

Parameters (reals) are added to current garr position.

Parameters:
item Item pointer.
dir Direction vector.
result Growing array, where to store parameters.
Return values:
>=0 Success - number of found parameters.
GEOM_ERR_NUMERIC Numeric error.
GEOM_ERR_ITEM_INVALID Invalid type of item for this function.

void geom_item_dump const void *  item,
uns  flags
 

Dump a given item.

Parameters:
item Item pointer.
flags Dump options (see GEOM_DUMP_x definitions).

void* geom_item_duplicate void *  item  ) 
 

Allocate a new item of same class type and copy data.

Resulting item should be destroyed by GEOM_INSTANCE_FREE or equivalent routine.

Parameters:
item Item pointer.
Returns:
Duplicated item.

struct geom_expansion* geom_item_expand void *  item  ) 
 

Makes one reference to item expansion.

If item cannot be expanded to Bezier path, result is NULL and no reference is made.

Return values:
NULL Cannot expand. Error code is stored in geom_errno.
otherwise Pointer to referenced expansion.

int geom_item_expansion_append void *  item,
struct geom_fpath *  expansion
[inline, static]
 

Expand curve to tail of expansion path.

If curve is closed, input path should be empty and function should close resulting path.

Parameters:
item Item pointer.
bpath Bezier path, where to append Bezier curves.
Return values:
zero Success.
GEOM_ERR_NUMERIC Numeric error.
GEOM_ERR_ITEM_INVALID Invalid type of item for this function.

int geom_item_horizontal_times void *  item,
struct garr *  result
[inline, static]
 

Find TIME parameters, with derivation vector parallel to X-axis.

Parameters (reals) are added to current garr position.

Parameters:
item Item pointer.
result Growing array, where to store parameters.
Return values:
>=0 Success - number of found parameters.
GEOM_ERR_NUMERIC Numeric error.
GEOM_ERR_ITEM_INVALID Invalid type of item for this function.

int geom_item_is_closed void *  item  )  [inline, static]
 

Returns whether item is a closed curve.

Parameters:
item Item pointer.
Return values:
1 Item is a closed curve.
0 Item is not a closed curve.
GEOM_ERR_ITEM_INVALID Invalid type of item for this function.
GEOM_ERR_ITEM_NOT_IMPLEMENTED Function not implemented, yet.

int geom_item_nearest_to_point void *  item,
struct geom_point point,
uns  flags,
struct geom_nearest *  nearest
[inline, static]
 

Finds nearest point on curve to a given point.

Parameters:
item Item pointer.
flags Wanted entries in resulting structure (see GEOM_NEAREST_x flags).
nearest Resulting structure.
Return values:
zero Success.
GEOM_ERR_NUMERIC Numeric error.
GEOM_ERR_ITEM_INVALID Invalid type of item for this function.
GEOM_ERR_PATH_EMPTY Path is empty.

int geom_item_point_at_time void *  item,
real  time,
struct geom_point result
[inline, static]
 

Returns curve point at given parameter.

Parameters:
item Item pointer.
time TIME parameter.
result Resulting point.
Return values:
zero Success.
GEOM_ERR_NUMERIC Numeric error.
GEOM_ERR_ITEM_INVALID Invalid type of item for this function.
GEOM_ERR_PATH_EMPTY Path is empty.

int geom_item_point_end void *  item,
struct geom_point result
[inline, static]
 

Returns ending point of given curve.

Parameters:
item Item pointer.
result Resulting point.
Return values:
zero Success.
GEOM_ERR_NUMERIC Numeric error.
GEOM_ERR_ITEM_INVALID Invalid type of item for this function.
GEOM_ERR_PATH_EMPTY Path is empty.

int geom_item_point_start void *  item,
struct geom_point result
[inline, static]
 

Returns starting point of given curve.

Parameters:
item Item pointer.
result Resulting point.
Return values:
zero Success.
GEOM_ERR_NUMERIC Numeric error.
GEOM_ERR_ITEM_INVALID Invalid type of item for this function.
GEOM_ERR_PATH_EMPTY Path is empty.

real geom_item_ratime_to_time void *  item,
real  ratime
[inline, static]
 

Conversion from RATIME to TIME parametrization.

Parameters:
item Item pointer.
ratime Source parametrization value.
Return values:
finite Destination parametrization value.
otherwise Failed.

int geom_item_ratimes_to_times void *  item,
uns  count,
real *  ratimes,
real *  times
[inline, static]
 

Converstion from RATIME to TIME parametrization.

Parameters:
item Item pointer.
count Number of parameters to convert.
ratimes Sorted array of source parametrization values.
times Buffer for sorted destination parametrization values.
Return values:
zero Success.
GEOM_ERR_NUMERIC Numeric error.
GEOM_ERR_ITEM_INVALID Invalid type of item for this function.

int geom_item_time_dif_btime void *  item  )  [inline, static]
 

Returns whether TIME and BTIME are different.

Parameters:
item Item pointer.
Return values:
nonzero Parametrizations are different.
zero Parametrizations are the same.

real geom_item_time_to_atime void *  item,
real  time
[inline, static]
 

Conversion from TIME to ATIME parametrization.

Parameters:
item Item pointer.
time Source parametrization value.
Return values:
finite Destination parametrization value.
otherwise Failed.

real geom_item_time_to_btime void *  item,
struct geom_expansion *  expansion,
real  time
[inline, static]
 

Conversion from TIME to BTIME parametrization.

Parameters:
item Item pointer.
time Source parametrization value.
Return values:
finite Destination parametrization value.
otherwise Failed.

real geom_item_time_to_ratime void *  item,
real  time
[inline, static]
 

Conversion from TIME to RATIME parametrization.

Parameters:
item Item pointer.
time Source parametrization value.
Return values:
finite Destination parametrization value.
otherwise Failed.

int geom_item_times_to_atimes void *  item,
uns  count,
real *  times,
real *  atimes
[inline, static]
 

Converstion from TIME to ATIME parametrization.

Parameters:
item Item pointer.
count Number of parameters to convert.
times Sorted array of source parametrization values.
atimes Buffer for sorted destination parametrization values.
Return values:
zero Success.
GEOM_ERR_NUMERIC Numeric error.
GEOM_ERR_ITEM_INVALID Invalid type of item for this function.

int geom_item_times_to_btimes void *  item,
struct geom_expansion *  expansion,
uns  count,
real *  times,
real *  btimes
[inline, static]
 

Converstion from TIME to BTIME parametrization.

Parameters:
item Item pointer.
count Number of parameters to convert.
times Sorted array of source parametrization values.
btimes Buffer for sorted destination parametrization values.
Return values:
zero Success.
GEOM_ERR_NUMERIC Numeric error.
GEOM_ERR_ITEM_INVALID Invalid type of item for this function.

int geom_item_times_to_ratimes void *  item,
uns  count,
real *  times,
real *  ratimes
[inline, static]
 

Converstion from TIME to RATIME parametrization.

Parameters:
item Item pointer.
count Number of parameters to convert.
times Sorted array of source parametrization values.
ratimes Buffer for sorted destination parametrization values.
Return values:
zero Success.
GEOM_ERR_NUMERIC Numeric error.
GEOM_ERR_ITEM_INVALID Invalid type of item for this function.

real geom_item_tlength void *  item  )  [inline, static]
 

Returns TIME parametrization length (1 for elementary curves).

Parameters:
item Item pointer.
Return values:
finite TIME parametrization length.
otherwise Failed.

int geom_item_to_bezier void *  item,
struct geom_bezier bezier
[inline, static]
 

Convert curve to single Bezier curve, if possible.

Parameters:
item Item pointer.
bezier Resulting bezier curve (initialized).
Return values:
zero Success.
GEOM_ERR_NUMERIC Numeric error.
GEOM_ERR_ITEM_INVALID Invalid type of item for this function.
... 

int geom_item_transform void *  item,
struct geom_transform transform,
void *  dest
[inline, static]
 

Apply affine transformation to a given curve.

Parameters:
item Item pointer.
transform Transformation matrix.
dest Item of same type (possibly item=dest).
Return values:
zero Success.
GEOM_ERR_NUMERIC Numeric error.
GEOM_ERR_ITEM_INVALID Invalid type of item for this function.

int geom_item_valid const void *  item  )  [inline, static]
 

Item validation.

Parameters:
item Item pointer.
Return values:
nonzero Item is valid.
zero Item is invalid.

int geom_items_intersections void *  item,
void *  item2,
uns  flags,
struct garr *  result
 

Finds intersections of two given curves.

Intersections (geom_intersection structures) are added to current garr position.

Parameters:
item First item pointer.
item2 Second item pointer.
flags Wanted entries in resulting structure (see GEOM_INTERSECTION_x flags).
result Growing array, where to store intersections.
Return values:
>=0 Success - number of found intersections.
GEOM_ERR_NUMERIC Numeric error.
GEOM_ERR_ITEM_INVALID Invalid type of item for this function.


Generated on Tue Dec 9 16:30:09 2008 for Vrr by doxygen 1.3.5