plot3d.h File Reference

Detailed Description

Module to generate 3d plots. Right now the output is in geomview format.

See Also
Tplot3d, plot3d.c, Tplot, plot.h.

Definition in file plot3d.h.

Data Structures

struct  Tplot3d
 A 3D plot. More...
 

Macros

#define DCP3D_R   0
 Red component of the default color of 3d objects. More...
 
#define DCP3D_G   0
 Green component of the default color of 3d objects. More...
 
#define DCP3D_B   1
 Blue component of the default color of 3d objects. More...
 

Functions

void InitPlot3d (char *name, boolean axes, int argc, char **arg, Tplot3d *p)
 Constructor. More...
 
unsigned int StartNew3dObject (Tcolor *c, Tplot3d *p)
 Start a composed object. More...
 
void Close3dObjectNoColor (Tplot3d *p)
 Closes a composed object without assigning any color. More...
 
void Close3dObject (Tplot3d *p)
 Closes a composed object. More...
 
void Delete3dObject (unsigned int nobj, Tplot3d *p)
 Deletes a previously created geometric object. More...
 
void Start3dBlock (Tplot3d *p)
 Starts a block of commands. More...
 
void Close3dBlock (Tplot3d *p)
 Ends a block of commands. More...
 
void SetColor3dObject (unsigned int nobj, Tcolor *c, Tplot3d *p)
 Changes the color of an object. More...
 
void Delay3dObject (double t, Tplot3d *p)
 Introduces a delay in the generation of the geometry. More...
 
void Move3dObject (unsigned int nobj, THTransform *t, Tplot3d *p)
 Moves a 3d object. More...
 
void PlotBox3d (double min_x, double max_x, double min_y, double max_y, double min_z, double max_z, Tplot3d *p)
 Adds an axis aligned box to the current object. More...
 
void PlotTriangle3d (double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3, Tplot3d *p)
 Adds a triangle to the current object. More...
 
void Plot3dObject (unsigned int nv, unsigned int nf, unsigned int ne, double **v, unsigned int *nvf, unsigned int **fv, Tplot3d *p)
 Adds a polytope to the current object. More...
 
void Plot3dObjectWithColor (unsigned int nv, unsigned int nf, unsigned int ne, double **v, unsigned int *nvf, unsigned int **fv, Tcolor *c, Tplot3d *p)
 Adds a colored polytope to the current object. More...
 
void Plot3dObjectWithColors (unsigned int nv, unsigned int nf, unsigned int ne, double **v, Tcolor *c, unsigned int *nvf, unsigned int **fv, Tplot3d *p)
 Adds a colored polytope to the current object. More...
 
void PlotSphere (double r, double x, double y, double z, Tplot3d *p)
 Adds a sphere to the current object. More...
 
void PlotCylinder (double r, double *p1, double *p2, Tplot3d *p)
 Adds a cylinder to the current object. More...
 
void PlotLine (double *p1, double *p2, Tplot3d *p)
 Adds a line to the current object. More...
 
void PlotSegments (unsigned int n, double **pt, Tplot3d *p)
 Adds a collecion of segments to the current object. More...
 
void PlotVect3d (unsigned int n, double *x, double *y, double *z, Tplot3d *p)
 Adds a polyline to the current object. More...
 
void Take3dSnapshot (char *file, Tplot3d *p)
 Takes a screenshot of the geometry. More...
 
void ClosePlot3d (boolean quit, double average_x, double average_y, double average_z, Tplot3d *p)
 Destructor. More...
 

Macro Definition Documentation

#define DCP3D_R   0

Red component of the default color of 3d objects.

See Also
Tplot3d

Definition at line 30 of file plot3d.h.

Referenced by InitPlot3d(), main(), and PlotEnvironment().

#define DCP3D_G   0

Green component of the default color of 3d objects.

See Also
Tplot3d

Definition at line 38 of file plot3d.h.

Referenced by InitPlot3d(), main(), and PlotEnvironment().

#define DCP3D_B   1

Blue component of the default color of 3d objects.

See Also
Tplot3d

Definition at line 46 of file plot3d.h.

Referenced by main().

Function Documentation

void InitPlot3d ( char *  name,
boolean  axes,
int  argc,
char **  arg,
Tplot3d p 
)

Initializes a 3d plot.

Parameters
nameName of the file where to store the geometry.
axesTRUE if we have to add the axes.
argcNumber of strings to be added to the geometry file header as comments.
argStrings to be added to the geometry file header as comments. Right now, this is used to store in the geometry file the command line used to create it.
pThe plot to initialize.

Definition at line 41 of file plot3d.c.

References Tplot3d::color, DCP3D_G, DCP3D_R, Error(), Tplot3d::f, FALSE, Tplot3d::fileName, Tplot3d::inObject, NEW, NewColor(), and Tplot3d::nobj.

Referenced by AnimateWorld(), main(), PlotAtlas(), PlotAtlasRRT(), PlotConnection(), PlotQrand(), PlotRRT(), and TriangulateAtlas().

unsigned int StartNew3dObject ( Tcolor c,
Tplot3d p 
)

Start the definition of a geometric object composed by one or more basic geometric elements.

Parameters
cColor for the object. Use a null color (see NullColor) for objects whose color does not need to be defined globally, i.e., whose color is already defined inside the elements included in the 3d object (see Plot3dObjectWithColors).
pThe plot to update.
Returns
The identifier of the started object.

Definition at line 157 of file plot3d.c.

References Close3dObject(), Tplot3d::color, CopyColor(), Tplot3d::f, Tplot3d::fileName, Tplot3d::inObject, Tplot3d::nobj, and TRUE.

Referenced by main(), PlotAtlas(), PlotAtlasRRT(), PlotBifurcations(), PlotConnection(), PlotEnvironment(), PlotForceField(), PlotLink(), PlotPolyhedron(), PlotQrand(), PlotRRT(), PlotSamples(), and TriangulateAtlas().

void Close3dObjectNoColor ( Tplot3d p)

Ends the definition of a geometric object composed by many basic geometric elements. In this case the object is not colored but we assume that each individual element has it own color.

Parameters
pThe plot to update.

Definition at line 184 of file plot3d.c.

References Tplot3d::f, FALSE, Tplot3d::fileName, Tplot3d::inObject, and Tplot3d::nobj.

Referenced by PlotAtlas().

void Close3dObject ( Tplot3d p)

Ends the definition of a geometric object composed by many basic geometric elements.

Parameters
pThe plot to update.

Definition at line 171 of file plot3d.c.

References Tplot3d::color, Tplot3d::f, FALSE, Tplot3d::fileName, Tplot3d::inObject, Tplot3d::nobj, and SetColor3dObject().

Referenced by ClosePlot3d(), main(), PlotAtlas(), PlotAtlasRRT(), PlotBifurcations(), PlotConnection(), PlotEnvironment(), PlotForceField(), PlotLink(), PlotPolyhedron(), PlotQrand(), PlotRRT(), PlotSamples(), StartNew3dObject(), and TriangulateAtlas().

void Delete3dObject ( unsigned int  nobj,
Tplot3d p 
)

Deletes a previously created geometric object. This is used when creating animations.

Parameters
nobjThe identifier of the object to be deleted (i.e., the return of StartNew3dObject when the object was created).
pThe plot to update.

Definition at line 152 of file plot3d.c.

References Tplot3d::f, and Tplot3d::fileName.

Referenced by PlotAtlas().

void Start3dBlock ( Tplot3d p)

Starts a block of commands that have to be executed simultaneously. Commands are, for instance, the generation of new geometry of the transformation/deletion of existing objects.

Parameters
pThe plot to update.

Definition at line 141 of file plot3d.c.

References Tplot3d::f.

Referenced by AnimateWorld(), main(), MoveMechanismFromTransforms(), PlotMechanism(), and PlotWorld().

void Close3dBlock ( Tplot3d p)

Ends a block of commands that have to be executed simultaneously.

Parameters
pThe plot to update.

Definition at line 146 of file plot3d.c.

References Tplot3d::f.

Referenced by AnimateWorld(), main(), MoveMechanismFromTransforms(), PlotMechanism(), and PlotWorld().

void SetColor3dObject ( unsigned int  nobj,
Tcolor c,
Tplot3d p 
)

Changes the color of an object.

Parameters
nobjThe object identifier as returned by StartNew3dObject.
cColor for the object.
pThe plot to update.

Definition at line 196 of file plot3d.c.

References Tplot3d::f, Tplot3d::fileName, Tplot3d::inObject, NullColor(), and PrintColor().

Referenced by Close3dObject().

void Delay3dObject ( double  t,
Tplot3d p 
)

Introduces a delay in the generation of the geometry. Used for animations.

Parameters
tLength in seconds of the delay.
pThe plot to update.

Definition at line 211 of file plot3d.c.

References Tplot3d::f.

Referenced by AnimateWorld().

void Move3dObject ( unsigned int  nobj,
THTransform t,
Tplot3d p 
)

Moves a 3d object.

Parameters
nobjThe identifier of the object to move, as returned by StartNew3dObject.
tThe homogenous transoform to apply to the object.
pThe plot to update.

Definition at line 217 of file plot3d.c.

References Tplot3d::f, Tplot3d::fileName, and HTransformPrintT().

Referenced by MoveLinkFromTransform(), and MovePolyhedron().

void PlotBox3d ( double  min_x,
double  max_x,
double  min_y,
double  max_y,
double  min_z,
double  max_z,
Tplot3d p 
)

Adds an axis aligned box to the current object. This command can only be used in between a call to StartNew3dObject and the corresponding call to Close3dObject.

Parameters
min_xLower limit for the box along the X axis.
max_xUpper limit for the box along the X axis.
min_yLower limit for the box along the Y axis.
max_yUpper limit for the box along the Y axis.
min_zLower limit for the box along the Z axis.
max_zUpper limit for the box along the Z axis.
pThe plot to update.

Definition at line 224 of file plot3d.c.

References Error(), Tplot3d::f, and Tplot3d::inObject.

Referenced by main(), and PlotChartAsBox().

void PlotTriangle3d ( double  x1,
double  y1,
double  z1,
double  x2,
double  y2,
double  z2,
double  x3,
double  y3,
double  z3,
Tplot3d p 
)

Adds triangle to the current object. This command can only be used in between a call to StartNew3dObject and the corresponding call to Close3dObject.

Parameters
x1X coordinate for the first point of the triangle.
y1Y coordinate for the first point of the triangle.
z1Z coordinate for the first point of the triangle.
x2X coordinate for the second point of the triangle.
y2Y coordinate for the second point of the triangle.
z2Z coordinate for the second point of the triangle.
x3X coordinate for the third point of the triangle.
y3Y coordinate for the third point of the triangle.
z3Z coordinate for the third point of the triangle.
pThe plot to update.

Definition at line 256 of file plot3d.c.

References Error(), Tplot3d::f, and Tplot3d::inObject.

void Plot3dObject ( unsigned int  nv,
unsigned int  nf,
unsigned int  ne,
double **  v,
unsigned int *  nvf,
unsigned int **  fv,
Tplot3d p 
)

Adds polytope to the current object. This command can only be used in between a call to StartNew3dObject and the corresponding call to Close3dObject.

What we denote as polytope are geomview OFFs.

Parameters
nvNumber of vertexes of the polytope.
nfNumber of faces of the polytope.
neNumber of edges of the polytope (not used).
vPointer to 3d array with the (x,y,z) coordinates of the vertexes.
nvfPointer to an array with the number of vertexes for each face.
fvPointer to an array with the vertexes for each face.
pThe plot to update.

Definition at line 276 of file plot3d.c.

References Error(), Tplot3d::f, and Tplot3d::inObject.

Referenced by PlotChartAsPolygon(), PlotPolyhedron(), and TriangulateAtlas().

void Plot3dObjectWithColor ( unsigned int  nv,
unsigned int  nf,
unsigned int  ne,
double **  v,
unsigned int *  nvf,
unsigned int **  fv,
Tcolor c,
Tplot3d p 
)

Adds colored polytope to the current object.

This command can only be used in between a call to StartNew3dObject and the corresponding call to Close3dObject.

What we denote as polytope are geomview OFFs.

Parameters
nvNumber of vertexes of the polytope.
nfNumber of faces of the polytope.
neNumber of edges of the polytope (not used).
vPointer to 3d array with the (x,y,z) coordinates of the vertexes.
nvfPointer to an array with the number of vertexes for each face.
fvPointer to an array with the vertexes for each face.
cThe color.
pThe plot to update.

Definition at line 304 of file plot3d.c.

References Error(), Tplot3d::f, Tplot3d::inObject, and PrintColor().

Referenced by PlotChartAsPolygon().

void Plot3dObjectWithColors ( unsigned int  nv,
unsigned int  nf,
unsigned int  ne,
double **  v,
Tcolor c,
unsigned int *  nvf,
unsigned int **  fv,
Tplot3d p 
)

Adds colored polytope to the current object. The difference with respect to Plot3dObjectWithColor is that here we have a color for each vertex of the polytope. Thus, the renderer takes care of interpolating the color inside each face. This typically produces smoother figures.

This command can only be used in between a call to StartNew3dObject and the corresponding call to Close3dObject.

Note that if this function is used, the global color of the 3d object is set to null (see NullColor) so that the colors defined inside this object are not overriden by the global color.

What we denote as polytope are geomview COFFs.

Parameters
nvNumber of vertexes of the polytope.
nfNumber of faces of the polytope.
neNumber of edges of the polytope (not used).
vPointer to 3d array with the (x,y,z) coordinates of the vertexes.
cThe colors. One for each vertex.
nvfPointer to an array with the number of vertexes for each face.
fvPointer to an array with the vertexes for each face.
pThe plot to update.

Definition at line 334 of file plot3d.c.

References Tplot3d::color, Error(), Tplot3d::f, Tplot3d::inObject, NewColor(), and PrintColor().

Referenced by TriangulateAtlas().

void PlotSphere ( double  r,
double  x,
double  y,
double  z,
Tplot3d p 
)

Adds sphere to the current object. This command can only be used in between a call to StartNew3dObject and the corresponding call to Close3dObject.

Parameters
rThe radius of the sphere.
xThe X component of the center of the sphere.
yThe Y component of the center of the sphere.
zThe Z component of the center of the sphere.
pThe plot to update.

Definition at line 369 of file plot3d.c.

References Error(), Tplot3d::f, and Tplot3d::inObject.

Referenced by PlotPolyhedron().

void PlotCylinder ( double  r,
double *  p1,
double *  p2,
Tplot3d p 
)

Adds cylinder to the current object. This command can only be used in between a call to StartNew3dObject and the corresponding call to Close3dObject.

Parameters
rThe radius of the cylinder.
p1Array with the (x,y,z) point where the cylinder has to start.
p2Array with the (x,y,z) point where the cylinder has to end.
pThe plot to update.

Definition at line 377 of file plot3d.c.

References Error(), Tplot3d::f, HTransformDelete(), HTransformPrintT(), HTransformX2Vect(), and Tplot3d::inObject.

void PlotLine ( double *  p1,
double *  p2,
Tplot3d p 
)

Adds line to the current object. This command can only be used in between a call to StartNew3dObject and the corresponding call to Close3dObject.

Parameters
p1Origin of the line (3D point).
p2End of the line (3D point).
pThe plot to update.

Definition at line 395 of file plot3d.c.

References Tplot3d::color, Error(), Tplot3d::f, Tplot3d::inObject, and PrintColor().

void PlotSegments ( unsigned int  n,
double **  pt,
Tplot3d p 
)

Adds a collection of segments to the current object. This command can only be used in between a call to StartNew3dObject and the corresponding call to Close3dObject.

Parameters
nNumber of points defining the polyline.
ptArray of 3D points defining the segments (a pair of entries for each segment).
pThe plot to update.

Definition at line 412 of file plot3d.c.

References Tplot3d::color, Error(), Tplot3d::f, Tplot3d::inObject, and PrintColor().

Referenced by PlotPolyhedron().

void PlotVect3d ( unsigned int  n,
double *  x,
double *  y,
double *  z,
Tplot3d p 
)

Adds polyline (i.e., a collection of concatenated lines) to the current object. This command can only be used in between a call to StartNew3dObject and the corresponding call to Close3dObject.

Parameters
nNumber of points defining the polyline.
xArray with the x component for the points in the polyline.
yArray with the y component for the points in the polyline.
zArray with the z component for the points in the polyline.
pThe plot to update.

Definition at line 447 of file plot3d.c.

References Tplot3d::color, Error(), Tplot3d::f, Tplot3d::inObject, and PrintColor().

Referenced by main(), PlotAtlas(), PlotAtlasRRT(), PlotBifurcations(), PlotChart(), PlotConnection(), PlotLink(), PlotQrand(), PlotRRT(), and PlotSamples().

void Take3dSnapshot ( char *  file,
Tplot3d p 
)

Takes a screenshot of the geometry. Used to create videos from animations.

The screenshot format are .ppm files that can be browsed/manipulated easily.

Parameters
fileName of the file where to store the snapshot.
pThe plot to update.

Definition at line 467 of file plot3d.c.

References Tplot3d::f.

Referenced by main().

void ClosePlot3d ( boolean  quit,
double  average_x,
double  average_y,
double  average_z,
Tplot3d p 
)

Closes a 3d plot. Before closing the file, all geometric objects are offset by (average_x,average_y,average_z). This is used to center the scene in the (0,0,0) and facilitates the on-line manipulation (rotations, translations,...) using geomview.

Parameters
quitTRUE if we want to quit geomview right after displaying the geometry. Used to quit after an animation.
average_xX translation to apply to all objects in the scene before closing the plot.
average_yY translation to apply to all objects in the scene before closing the plot.
average_zZ translation to apply to all objects in the scene before closing the plot.
pThe plot to update.

Definition at line 473 of file plot3d.c.

References Close3dObject(), Tplot3d::f, Tplot3d::fileName, and Tplot3d::nobj.

Referenced by AnimateWorld(), main(), PlotAtlas(), PlotAtlasRRT(), PlotConnection(), PlotQrand(), PlotRRT(), and TriangulateAtlas().