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 /************************************************************************************/
103 
124 typedef struct {
125  unsigned int type;
127  unsigned int status;
133  unsigned int obj3d;
135  unsigned int nv;
136  unsigned int nf;
137  unsigned int ne;
138  double **v;
139  unsigned int *nvf;
140  unsigned int **fv;
142  double rad;
144  double center[3];
146  double p1[3];
147  double p2[3];
149  double maxCoord;
153 } Tpolyhedron;
154 
181  unsigned int gr,unsigned int bs,Tpolyhedron *p);
182 
196 void InitPolyhedronFromTriangles(unsigned int nv,double **v,
197  unsigned int nt,unsigned int **t,
198  Tcolor *c,unsigned int bs,Tpolyhedron *p);
199 
217 void NewBox(double xl,double yl,double zl,
218  double xu,double yu,double zu,
219  Tcolor *c,unsigned int bs,Tpolyhedron *p);
220 
233 void NewSphere(double r,double *center,Tcolor *c,
234  unsigned int gr,unsigned int bs,Tpolyhedron *p);
235 
249 void NewCylinder(double r,double *p1,double *p2,Tcolor *c,
250  unsigned int gr,unsigned int bs,Tpolyhedron *p);
251 
263 void NewLine(double *p1,double *p2,Tcolor *c,
264  unsigned int bs,Tpolyhedron *p);
265 
278 void NewSegments(unsigned int n,double *x,double *y,double *z,Tcolor *c,
279  Tpolyhedron *p);
280 
289 void CopyPolyhedron(Tpolyhedron *p_dst,Tpolyhedron *p_src);
290 
301 
311 void GetPolyhedronCenter(double *c,Tpolyhedron *p);
312 
322 unsigned int GetPolyhedronType(Tpolyhedron *p);
323 
333 
343 
353 unsigned int GetPolyhedronStatus(Tpolyhedron *p);
354 
373 void GetOFFInfo(unsigned int *nv,double ***v,unsigned int *nf,
374  unsigned int **nvf,unsigned int ***fv,Tpolyhedron *p);
375 
385 unsigned int GetPolyhedronNVertex(Tpolyhedron *p);
386 
412 void GetPolyhedronDefiningPoint(unsigned int i,double *point,Tpolyhedron *p);
413 
424 
440 void GetPolyhedronVertex(unsigned int i,double *point,Tpolyhedron *p);
441 
455 
466 void PlotPolyhedron(Tplot3d *pt,Tpolyhedron *p);
467 
489 void PolyhedronPrintCenter(FILE *f,THTransform *t,Tpolyhedron *p);
490 
504 
515 
526 void SavePolyhedron(char *fileName,Tpolyhedron *p);
527 
543 void PrintPolyhedron(FILE *f,char *path,char *label,
544  unsigned int n,Tpolyhedron *p);
545 
554 
555 #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:1232
unsigned int ** fv
Definition: polyhedron.h:140
void NewSegments(unsigned int n, double *x, double *y, double *z, Tcolor *c, Tpolyhedron *p)
Constructor.
Definition: polyhedron.c:1004
double maxCoord
Definition: polyhedron.h:149
unsigned int obj3d
Definition: polyhedron.h:133
unsigned int GetPolyhedronNVertex(Tpolyhedron *p)
Gets the number of vertexes of a polyhedron.
Definition: polyhedron.c:1185
void GetPolyhedronCenter(double *c, Tpolyhedron *p)
Gets the center of the spheres.
Definition: polyhedron.c:1145
Data structure to hold the information about the name of a file.
Definition: filename.h:248
A homgeneous transform in R^3.
void PlotPolyhedron(Tplot3d *pt, Tpolyhedron *p)
Adds the polyhedron to a 3D geometry.
Definition: polyhedron.c:1255
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:926
void PrintPolyhedron(FILE *f, char *path, char *label, unsigned int n, Tpolyhedron *p)
Stores the polyhedron information into a file.
Definition: polyhedron.c:1366
A color.
Definition: color.h:23
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:857
A polyhedron.
Definition: polyhedron.h:124
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:1239
double ** v
Definition: polyhedron.h:138
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:1175
unsigned int status
Definition: polyhedron.h:127
double rad
Definition: polyhedron.h:142
void NewCylinder(double r, double *p1, double *p2, Tcolor *c, unsigned int gr, unsigned int bs, Tpolyhedron *p)
Constructor.
Definition: polyhedron.c:950
Definition of the THTransform type and the associated functions.
void GetPolyhedronColor(Tcolor *c, Tpolyhedron *p)
Gets the color of a polyhedron.
Definition: polyhedron.c:1165
unsigned int * nvf
Definition: polyhedron.h:139
double GetPolyhedronMaxCoordinate(Tpolyhedron *p)
Returns the maximum coordinate value used in a polyhedron.
Definition: polyhedron.c:1250
void InitPolyhedronFromFile(Tfilename *fname, Tcolor *c, unsigned int gr, unsigned int bs, Tpolyhedron *p)
Constructor.
Definition: polyhedron.c:727
void PolyhedronPrintCenterAndCenter(FILE *f, THTransform *t, Tpolyhedron *p)
Prints the center and the radius of a sphere to a file.
Definition: polyhedron.c:1297
void SetPolyhedronColor(Tcolor *c, Tpolyhedron *p)
Changes the color of a polyhedron.
Definition: polyhedron.c:1160
Tcolor color
Definition: polyhedron.h:131
unsigned int GetPolyhedronStatus(Tpolyhedron *p)
Gets the status of a polyhedron (NORMAL, HIDDEN, DECOR).
Definition: polyhedron.c:1170
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:1309
void SavePolyhedron(char *fileName, Tpolyhedron *p)
Stores the geometic information of a polyhedron into a file.
Definition: polyhedron.c:1315
unsigned int nf
Definition: polyhedron.h:136
void GetPolyhedronDefiningPoint(unsigned int i, double *point, Tpolyhedron *p)
Gets a point defining a a object.
Definition: polyhedron.c:1190
void DeletePolyhedron(Tpolyhedron *p)
Destructor.
Definition: polyhedron.c:1484
unsigned int ne
Definition: polyhedron.h:137
void TransformPolyhedron(THTransform *t, Tpolyhedron *p)
Applies a homogenoeus transform to a polyhedron.
Definition: polyhedron.c:1113
unsigned int nv
Definition: polyhedron.h:135
void CopyPolyhedron(Tpolyhedron *p_dst, Tpolyhedron *p_src)
Copy constructor.
Definition: polyhedron.c:1051
void PolyhedronPrintCenter(FILE *f, THTransform *t, Tpolyhedron *p)
Prints the center of a sphere to a file.
Definition: polyhedron.c:1285
unsigned int GetPolyhedronType(Tpolyhedron *p)
Retrives the type of a polyhedron.
Definition: polyhedron.c:1155
unsigned int type
Definition: polyhedron.h:125
void NewLine(double *p1, double *p2, Tcolor *c, unsigned int bs, Tpolyhedron *p)
Constructor.
Definition: polyhedron.c:977