polyhedron.h
Go to the documentation of this file.
1 #ifndef POLYHEDRONH
2 #define POLYHEDRONH
3 
4 #include "plot3d.h"
5 #include "htransform.h"
6 #include "filename.h"
7 #include "color.h"
8 
9 #include <stdlib.h>
10 
20 /************************************************************************************/
28 #define NORMAL_SHAPE 0
29 
37 #define HIDDEN_SHAPE 1
38 
46 #define DECOR_SHAPE 2
47 
48 /************************************************************************************/
49 /************************************************************************************/
59 #define OFF 0
60 
70 #define SPHERE 1
71 
80 #define CYLINDER 2
81 
90 #define LINE 3
91 
100 #define SEGMENTS 4
101 
102 
110 #define EMPTY_BODY 5
111 
112 /************************************************************************************/
113 
134 typedef struct {
135  unsigned int type;
137  unsigned int status;
143  unsigned int obj3d;
145  unsigned int nv;
146  unsigned int nf;
147  unsigned int ne;
148  double **v;
149  unsigned int *nvf;
150  unsigned int **fv;
152  double rad;
154  double center[3];
156  double p1[3];
157  double p2[3];
159  double maxCoord;
163 } Tpolyhedron;
164 
191  unsigned int gr,unsigned int bs,Tpolyhedron *p);
192 
206 void InitPolyhedronFromTriangles(unsigned int nv,double **v,
207  unsigned int nt,unsigned int **t,
208  Tcolor *c,unsigned int bs,Tpolyhedron *p);
209 
221 boolean EmptyPolyhedron(Tpolyhedron *p);
222 
237 void NewTriangularPrism(double *p1,double *p2,double *p3,
238  double h,
239  Tcolor *c,unsigned int bs,Tpolyhedron *p);
257 void NewBox(double xl,double yl,double zl,
258  double xu,double yu,double zu,
259  Tcolor *c,unsigned int bs,Tpolyhedron *p);
260 
273 void NewSphere(double r,double *center,Tcolor *c,
274  unsigned int gr,unsigned int bs,Tpolyhedron *p);
275 
289 void NewCylinder(double r,double *p1,double *p2,Tcolor *c,
290  unsigned int gr,unsigned int bs,Tpolyhedron *p);
291 
303 void NewLine(double *p1,double *p2,Tcolor *c,
304  unsigned int bs,Tpolyhedron *p);
305 
318 void NewSegments(unsigned int n,double *x,double *y,double *z,Tcolor *c,
319  Tpolyhedron *p);
320 
340 void NewSpring(double length,double start,double rad,unsigned int lps,
341  Tcolor *c,Tpolyhedron *p);
342 
351 void CopyPolyhedron(Tpolyhedron *p_dst,Tpolyhedron *p_src);
352 
363 
373 void GetPolyhedronCenter(double *c,Tpolyhedron *p);
374 
384 unsigned int GetPolyhedronType(Tpolyhedron *p);
385 
395 
405 
415 unsigned int GetPolyhedronStatus(Tpolyhedron *p);
416 
435 void GetOFFInfo(unsigned int *nv,double ***v,unsigned int *nf,
436  unsigned int **nvf,unsigned int ***fv,Tpolyhedron *p);
437 
447 unsigned int GetPolyhedronNVertex(Tpolyhedron *p);
448 
474 void GetPolyhedronDefiningPoint(unsigned int i,double *point,Tpolyhedron *p);
475 
486 
502 void GetPolyhedronVertex(unsigned int i,double *point,Tpolyhedron *p);
503 
517 
528 void PlotPolyhedron(Tplot3d *pt,Tpolyhedron *p);
529 
551 void PolyhedronPrintCenter(FILE *f,THTransform *t,Tpolyhedron *p);
552 
566 
577 
588 void SavePolyhedron(char *fileName,Tpolyhedron *p);
589 
605 void PrintPolyhedron(FILE *f,char *path,char *label,
606  unsigned int n,Tpolyhedron *p);
607 
616 
617 #endif
void InitPolyhedronFromTriangles(unsigned int nv, double **v, unsigned int nt, unsigned int **t, Tcolor *c, unsigned int bs, Tpolyhedron *p)
Constructor.
Definition: polyhedron.c:801
double GetPolyhedronRadius(Tpolyhedron *p)
Returns the radius used in the definition of the object.
Definition: polyhedron.c:1440
unsigned int ** fv
Definition: polyhedron.h:150
void NewSegments(unsigned int n, double *x, double *y, double *z, Tcolor *c, Tpolyhedron *p)
Constructor.
Definition: polyhedron.c:1098
double maxCoord
Definition: polyhedron.h:159
boolean EmptyPolyhedron(Tpolyhedron *p)
Used for objects that failed to initialize.
Definition: polyhedron.c:856
unsigned int obj3d
Definition: polyhedron.h:143
unsigned int GetPolyhedronNVertex(Tpolyhedron *p)
Gets the number of vertexes of a polyhedron.
Definition: polyhedron.c:1393
void GetPolyhedronCenter(double *c, Tpolyhedron *p)
Gets the center of the spheres.
Definition: polyhedron.c:1353
Data structure to hold the information about the name of a file.
Definition: filename.h:271
void PolyhedronPrintCenterAndRadius(FILE *f, THTransform *t, Tpolyhedron *p)
Prints the center and the radius of a sphere to a file.
Definition: polyhedron.c:1505
A homgeneous transform in R^3.
void PlotPolyhedron(Tplot3d *pt, Tpolyhedron *p)
Adds the polyhedron to a 3D geometry.
Definition: polyhedron.c:1463
void NewTriangularPrism(double *p1, double *p2, double *p3, double h, Tcolor *c, unsigned int bs, Tpolyhedron *p)
Constructor.
Definition: polyhedron.c:861
Definition of the Tfilename type and the associated functions.
Definition of the Tplot3d type and the associated functions.
void NewSphere(double r, double *center, Tcolor *c, unsigned int gr, unsigned int bs, Tpolyhedron *p)
Constructor.
Definition: polyhedron.c:1020
void PrintPolyhedron(FILE *f, char *path, char *label, unsigned int n, Tpolyhedron *p)
Stores the polyhedron information into a file.
Definition: polyhedron.c:1574
A color.
Definition: color.h:86
void NewBox(double xl, double yl, double zl, double xu, double yu, double zu, Tcolor *c, unsigned int bs, Tpolyhedron *p)
Constructor.
Definition: polyhedron.c:946
void NewSpring(double length, double start, double rad, unsigned int lps, Tcolor *c, Tpolyhedron *p)
Defines a spring.
Definition: polyhedron.c:1145
A polyhedron.
Definition: polyhedron.h:134
A 3D plot.
Definition: plot3d.h:54
void GetPolyhedronVertex(unsigned int i, double *point, Tpolyhedron *p)
Gets a vertex of a polyhedron.
Definition: polyhedron.c:1447
double ** v
Definition: polyhedron.h:148
void GetOFFInfo(unsigned int *nv, double ***v, unsigned int *nf, unsigned int **nvf, unsigned int ***fv, Tpolyhedron *p)
Gets the OFF information.
Definition: polyhedron.c:1383
unsigned int status
Definition: polyhedron.h:137
double rad
Definition: polyhedron.h:152
void NewCylinder(double r, double *p1, double *p2, Tcolor *c, unsigned int gr, unsigned int bs, Tpolyhedron *p)
Constructor.
Definition: polyhedron.c:1044
Definition of the THTransform type and the associated functions.
void GetPolyhedronColor(Tcolor *c, Tpolyhedron *p)
Gets the color of a polyhedron.
Definition: polyhedron.c:1373
unsigned int * nvf
Definition: polyhedron.h:149
double GetPolyhedronMaxCoordinate(Tpolyhedron *p)
Returns the maximum coordinate value used in a polyhedron.
Definition: polyhedron.c:1458
void InitPolyhedronFromFile(Tfilename *fname, Tcolor *c, unsigned int gr, unsigned int bs, Tpolyhedron *p)
Constructor.
Definition: polyhedron.c:727
void SetPolyhedronColor(Tcolor *c, Tpolyhedron *p)
Changes the color of a polyhedron.
Definition: polyhedron.c:1368
Tcolor color
Definition: polyhedron.h:141
unsigned int GetPolyhedronStatus(Tpolyhedron *p)
Gets the status of a polyhedron (NORMAL, HIDDEN, DECOR).
Definition: polyhedron.c:1378
Definition of the Tcolor type and the associated functions.
void MovePolyhedron(Tplot3d *pt, THTransform *t, Tpolyhedron *p)
Moves an object previously added to a 3D scene.
Definition: polyhedron.c:1517
void SavePolyhedron(char *fileName, Tpolyhedron *p)
Stores the geometic information of a polyhedron into a file.
Definition: polyhedron.c:1523
unsigned int nf
Definition: polyhedron.h:146
void GetPolyhedronDefiningPoint(unsigned int i, double *point, Tpolyhedron *p)
Gets a point defining a a object.
Definition: polyhedron.c:1398
void DeletePolyhedron(Tpolyhedron *p)
Destructor.
Definition: polyhedron.c:1692
unsigned int ne
Definition: polyhedron.h:147
void TransformPolyhedron(THTransform *t, Tpolyhedron *p)
Applies a homogenoeus transform to a polyhedron.
Definition: polyhedron.c:1321
unsigned int nv
Definition: polyhedron.h:145
void CopyPolyhedron(Tpolyhedron *p_dst, Tpolyhedron *p_src)
Copy constructor.
Definition: polyhedron.c:1259
void PolyhedronPrintCenter(FILE *f, THTransform *t, Tpolyhedron *p)
Prints the center of a sphere to a file.
Definition: polyhedron.c:1493
unsigned int GetPolyhedronType(Tpolyhedron *p)
Retrives the type of a polyhedron.
Definition: polyhedron.c:1363
unsigned int type
Definition: polyhedron.h:135
void NewLine(double *p1, double *p2, Tcolor *c, unsigned int bs, Tpolyhedron *p)
Constructor.
Definition: polyhedron.c:1071