environment.h File Reference

Detailed Description

Definition of the Tenvironment type and the associated functions.

See Also
Tenvironment, environment.c.

Definition in file environment.h.

Data Structures

struct  Tenvironment
 A collection of obstacles (convex polyhedrons) with their names. More...
 

Macros

#define INIT_NUM_OBSTACLES   10
 Initial room for obstacles. More...
 

Functions

void InitEnvironment (Tenvironment *e)
 Constructor. More...
 
void AddShape2Environment (char *name, Tpolyhedron *o, Tenvironment *e)
 Adds an obstacle (i.e., a convex polyhedron) to the environment. More...
 
unsigned int GetEnvironmentNObstacles (Tenvironment *e)
 Gets the number of obstacles in the environment. More...
 
unsigned int GetObstacleID (char *name, Tenvironment *e)
 Gets the idetifier of an obstacles given its name. More...
 
char * GetObstacleName (unsigned int i, Tenvironment *e)
 Gets the name of an obstacle given its identifier. More...
 
TpolyhedronGetObstacleShape (unsigned int i, Tenvironment *e)
 Gets the convex polyhedron of an obstacle given its identifier. More...
 
unsigned int GetObstacleShapeStatus (unsigned int i, Tenvironment *e)
 Gets the status (NORMAL, HIDDEN, DECOR) of an obstacle given its identifier. More...
 
void GetObstacleColor (unsigned int i, Tcolor *c, Tenvironment *e)
 Gets the color of an obstacle given its identifier. More...
 
double GetEnvironmentMaxCoordinate (Tenvironment *e)
 Returns the sum of the maximum coordinate value for all the convex polyhedrons in the environment. More...
 
void PrintEnvironment (FILE *f, char *path, Tenvironment *e)
 Stores the environment information into a file. More...
 
void PlotEnvironment (Tplot3d *pt, Tenvironment *e)
 Displays the obstacles in the environment in a 3D geometry. More...
 
void DeleteEnvironment (Tenvironment *e)
 Destructor. More...
 

Macro Definition Documentation

#define INIT_NUM_OBSTACLES   10

Initial room for obstacles. It will be enlarged if necessary.

See Also
Tenvironment

Definition at line 29 of file environment.h.

Referenced by InitEnvironment().

Function Documentation

void InitEnvironment ( Tenvironment e)

Creates an empty environment.

Parameters
eThe environment to intialize.

Definition at line 13 of file environment.c.

References CopyVoidPtr(), DeleteVoidPtr(), INIT_NUM_OBSTACLES, InitVector(), Tenvironment::maxCoord, Tenvironment::names, and Tenvironment::obstacles.

Referenced by InitWorld().

void AddShape2Environment ( char *  name,
Tpolyhedron o,
Tenvironment e 
)

Adds an obstacle (i.e., a convex polyhedron) to the environment.

Parameters
nameThe name of the obstacle.
oThe obstacle to add to the environment.
eThe environment where to add the new obstacle.
See Also
Tpolyhedron, InitPolyhedronFromFile.

Definition at line 20 of file environment.c.

References CopyPolyhedron(), EmptyPolyhedron(), GetPolyhedronMaxCoordinate(), Tenvironment::maxCoord, Tenvironment::names, NEW, NewVectorElement(), Tenvironment::obstacles, and SetVectorElement().

Referenced by AddObstacle2World().

unsigned int GetEnvironmentNObstacles ( Tenvironment e)

Gets the number of obstacles in the environment.

Parameters
eThe environment to query.
Returns
The number of obstacles in the environment.

Definition at line 43 of file environment.c.

References Tenvironment::obstacles, and VectorSize().

Referenced by DeleteEnvironment(), InitPQPCD(), InitSolidCD(), InitVcollideCD(), PlotEnvironment(), PrintEnvironment(), WorldPrintAtoms(), and WorldStoreRigidGroups().

unsigned int GetObstacleID ( char *  name,
Tenvironment e 
)

Gets the idetifier of an obstacles given its name. The identifier of an obstacle is its position in the vectors name/obstacles of included in the Tenvironment structure.

Parameters
nameThe name of the obstacle.
eThe environment to query.
Returns
The idetifier of an obstacles given its name or NO_UINT if there is no obstacle with the given name.

Definition at line 48 of file environment.c.

References FALSE, GetVectorElement(), Tenvironment::names, NO_UINT, TRUE, and VectorSize().

Referenced by GetWorldObstacleID().

char* GetObstacleName ( unsigned int  i,
Tenvironment e 
)

Gets the name of an obstacle given its identifier.

Parameters
iThe identifier of the object to query.
eThe environment to query.
Returns
A pointer to the name of the requested obstacle or NULL if there is no obstacle with the given identifier.

Definition at line 74 of file environment.c.

References GetVectorElement(), and Tenvironment::names.

Referenced by DeleteEnvironment(), PrintCollisionInfoInt(), PrintCollisions(), and PrintEnvironment().

Tpolyhedron* GetObstacleShape ( unsigned int  i,
Tenvironment e 
)

Gets the convex polyhedron of an obstacle given its identifier.

Parameters
iThe identifier of the object to query.
eThe environment to query.
Returns
A pointer to the convex polyhedron of the requested obstacle or NULL if there is no obstacle with the given identifier.

Definition at line 85 of file environment.c.

References GetVectorElement(), and Tenvironment::obstacles.

Referenced by DeleteEnvironment(), InitPQPCD(), InitSolidCD(), InitVcollideCD(), PlotEnvironment(), and PrintEnvironment().

unsigned int GetObstacleShapeStatus ( unsigned int  i,
Tenvironment e 
)

Gets the status (NORMAL, HIDDEN, DECOR) of an obstacle given its identifier.

Parameters
iThe identifier of the object to query.
eThe environment to query.
Returns
A the status (NORMAL, HIDDEN, DECOR) of the requested obstacle or NO_UINT if there is no obstacle with the given identifier.

Definition at line 96 of file environment.c.

References GetPolyhedronStatus(), GetVectorElement(), NO_UINT, and Tenvironment::obstacles.

Referenced by CheckAllCollisions(), InitPQPCD(), InitSolidCD(), and InitVcollideCD().

void GetObstacleColor ( unsigned int  i,
Tcolor c,
Tenvironment e 
)

Gets the color of an obstacle given its identifier.

Parameters
iThe identifier of the object to query.
cThe color of the requested obstacle.
eThe environment to query.

Definition at line 107 of file environment.c.

References Error(), GetPolyhedronColor(), GetVectorElement(), and Tenvironment::obstacles.

double GetEnvironmentMaxCoordinate ( Tenvironment e)

Returns the sum of the maximum coordinate value (either for X,Y or Z) for all the convex polyhedrons in the environment. This is used in higher levels to define an over-estimate bounding-box of the world. This bounding box is used to define the ranges for some of the coordinate and separating planes variables.

Parameters
eThe environment to query.
Returns
The sum of the maximum coordinate values for all bodies in the environment.

Definition at line 118 of file environment.c.

References Tenvironment::maxCoord.

Referenced by GenerateWorldEquations().

void PrintEnvironment ( FILE *  f,
char *  path,
Tenvironment e 
)

Stores the environment information into a file in the format valid to be read by InitWorldFromFile.

Parameters
fThe file where to store the information.
pathThe working folder.
eThe environment to print.

Definition at line 123 of file environment.c.

References GetEnvironmentNObstacles(), GetObstacleName(), GetObstacleShape(), and PrintPolyhedron().

Referenced by PrintWorld().

void PlotEnvironment ( Tplot3d pt,
Tenvironment e 
)

Displays the obstacles in the environment in a 3D geometry.

Parameters
ptThe 3D geometry where the to plot the environment.
eThe environment to plot.

Definition at line 146 of file environment.c.

References Close3dObject(), DCP3D_G, DCP3D_R, DeleteColor(), GetEnvironmentNObstacles(), GetObstacleShape(), NewColor(), PlotPolyhedron(), and StartNew3dObject().

Referenced by PlotWorld().

void DeleteEnvironment ( Tenvironment e)

Deletes the information stored in a Tenvironment and frees the allocated memory.

Parameters
eThe environment to delete.

Definition at line 169 of file environment.c.

References DeletePolyhedron(), DeleteVector(), GetEnvironmentNObstacles(), GetObstacleName(), GetObstacleShape(), Tenvironment::names, and Tenvironment::obstacles.

Referenced by DeleteWorld().