cpolytope.h
Go to the documentation of this file.
1 #ifndef CPOLYTOPE
2 #define CPOLYTOPE
3 
4 
5 #include "boolean.h"
6 #include "box.h"
7 #include "parameters.h"
8 #include "scpolytope.h" /* To get some common constants */
9 #include "wcs.h"
10 
32 #define POLYTOPE_R_ENLARGEMENT 1.01
33 
52 typedef struct {
53  unsigned int k;
54  double r;
57  double v;
59  boolean emptyPolytope;
65  unsigned int nFaces;
66  unsigned int maxFaces;
67  double **face;
69  unsigned int *ID;
71  unsigned int maxVertices;
72  unsigned int nVertices;
73  double **vertex;
74  boolean *expandible;
76  unsigned int nExpandible;
78  unsigned int freeVertex;
80  unsigned int *nIndices;
81  unsigned int *maxIndices;
82  unsigned int **indices;
86  Tbox bb;
88  boolean open;
91 } Tcpolytope;
92 
93 
103 void InitEmptyPolytope(unsigned int k,double r,Tcpolytope *mp);
104 
116 void DefinePolytope(Tcpolytope *mp);
117 
128 
129 
140 
141 
154 void CopyPolytope(Tcpolytope *mp_dst,Tcpolytope *mp_src);
155 
183 boolean CutPolytope(Tparameters *pr,double *t,double r,unsigned int id,void *wcs,void *c,
184  unsigned int m,unsigned int *tp,Tbox *ambient,Tcpolytope *mp);
185 
212 boolean CutPolytopeWithFace(Tparameters *pr,double *t,double offset,unsigned int id,void *wcs,
213  void *c,unsigned int m,unsigned int *tp,Tbox *ambient,Tcpolytope *mp);
214 
223 void PolytopeCenter(double *t,Tcpolytope *mp);
224 
235 boolean InsidePolytope(double *t,Tcpolytope *mp);
236 
237 
247 double GetPolytopeRadius(Tcpolytope *mp);
248 
258 unsigned int GetPolytopeDim(Tcpolytope *mp);
259 
270 
281 void SetPolytopeBB(Tbox *bb,Tcpolytope *mp);
282 
283 
294 boolean ExpandiblePolytope(Tcpolytope *mp);
295 
308 void WrongPolytopeCorner(unsigned int nv,Tcpolytope *mp);
309 
324 boolean GetPolytopeInteriorPoint(double rSample,double *t,Tcpolytope *mp);
325 
346 boolean PolytopeBoundaryPointFromExternalCorner(double rSample,boolean rand,
347  unsigned int *nv,double *t,Tcpolytope *mp);
348 
349 
364 void PolytopeBoundaryPointsFromExternalCorners(double rSample,unsigned int *n,unsigned int **nv,
365  double ***t,Tcpolytope *mp);
366 
393 boolean PolytopeRandomPointOnBoundary(double rSample,double *t,Tcpolytope *mp);
394 
407 boolean RandomPointInPolytope(double *t,Tcpolytope *mp);
408 
421 double PolytopeMaxVolume(Tcpolytope *mp);
422 
434 double PolytopeVolume(Tcpolytope *mp);
435 
457 unsigned int PolytopeNumNeighbours(Tcpolytope *mp);
458 
473 unsigned int PolytopeNeighbourID(unsigned int n,Tcpolytope *mp);
474 
485 void GetPolytopeVertices(unsigned int *nv,double ***v,Tcpolytope *mp);
486 
503 void GetPolytopeNeighboursFromVertices(unsigned int *nv,unsigned int **cID1,unsigned int **cID2,Tcpolytope *mp);
504 
518 void GetPolytopeEdges(unsigned int *ne,unsigned int **vID1,unsigned int **vID2,
519  Tcpolytope *mp);
520 
521 
531 unsigned int PolytopeMemSize(Tcpolytope *mp);
532 
542 void SavePolytope(FILE *f,Tcpolytope *mp);
543 
553 void LoadPolytope(FILE *f,Tcpolytope *mp);
554 
560 void PrintPolytopeInfo(Tcpolytope *mp);
561 
569 void DeletePolytope(Tcpolytope *mp);
570 
571 #endif
Definition of the boolean type.
boolean open
Definition: cpolytope.h:88
unsigned int freeVertex
Definition: cpolytope.h:78
void WrongPolytopeCorner(unsigned int nv, Tcpolytope *mp)
Mark a vertex as wrong.
Definition: cpolytope.c:684
unsigned int nExpandible
Definition: cpolytope.h:76
unsigned int maxVertices
Definition: cpolytope.h:71
double GetPolytopeRadius(Tcpolytope *mp)
Returns the simple polytope radius.
Definition: cpolytope.c:654
Tbox * GetPolytopeBB(Tcpolytope *mp)
Returns the simple polytope bounding box.
Definition: cpolytope.c:664
unsigned int GetPolytopeDim(Tcpolytope *mp)
Returns the simple polytope dimensionality.
Definition: cpolytope.c:659
unsigned int nFaces
Definition: cpolytope.h:65
boolean PolytopeRandomPointOnBoundary(double rSample, double *t, Tcpolytope *mp)
Random point on the boundary of the chart.
Definition: cpolytope.c:908
boolean InsidePolytope(double *t, Tcpolytope *mp)
Identifies points inside a chart polytope.
Definition: cpolytope.c:329
double ** vertex
Definition: cpolytope.h:73
double PolytopeMaxVolume(Tcpolytope *mp)
Maximum volume of the polytope.
Definition: cpolytope.c:943
unsigned int * ID
Definition: cpolytope.h:69
unsigned int * maxIndices
Definition: cpolytope.h:81
boolean * expandible
Definition: cpolytope.h:74
boolean emptyPolytope
Definition: cpolytope.h:59
void SPolytope2Polytope(Tparameters *pr, Tscpolytope *sp, Tcpolytope *p)
Defines a chart polytope from a simple chart polytope.
Definition: cpolytope.c:188
void GetPolytopeNeighboursFromVertices(unsigned int *nv, unsigned int **cID1, unsigned int **cID2, Tcpolytope *mp)
Identifiy the three charts coincident at a vertex.
Definition: cpolytope.c:1061
double ** face
Definition: cpolytope.h:67
void SetPolytopeBB(Tbox *bb, Tcpolytope *mp)
Modifies the bounding box of the polytope.
Definition: cpolytope.c:672
A simpleifed polytope associated with chart on a manifold.
Definition: scpolytope.h:45
unsigned int k
Definition: cpolytope.h:53
Definition of the Tbox type and the associated functions.
void Polytope2SPolytope(Tparameters *pr, Tcpolytope *p, Tscpolytope *sp)
Defines a simple chart polytope from a normal/full chart polytope.
Definition: cpolytope.c:212
void InitEmptyPolytope(unsigned int k, double r, Tcpolytope *mp)
Defines an empty chart polytope.
Definition: cpolytope.c:65
void SavePolytope(FILE *f, Tcpolytope *mp)
Saves the chart polytope to a file.
Definition: cpolytope.c:1187
void GetPolytopeEdges(unsigned int *ne, unsigned int **vID1, unsigned int **vID2, Tcpolytope *mp)
Gets the set of edges of the polytope.
Definition: cpolytope.c:1126
A table of parameters.
unsigned int maxFaces
Definition: cpolytope.h:66
boolean GetPolytopeInteriorPoint(double rSample, double *t, Tcpolytope *mp)
Returns a point inside the ball and the polytope.
Definition: cpolytope.c:693
boolean PolytopeBoundaryPointFromExternalCorner(double rSample, boolean rand, unsigned int *nv, double *t, Tcpolytope *mp)
Random point on the boundary from the polytope vetices.
Definition: cpolytope.c:847
unsigned int PolytopeNumNeighbours(Tcpolytope *mp)
Number of neighbours of the polytope.
Definition: cpolytope.c:974
double v
Definition: cpolytope.h:57
void DeletePolytope(Tcpolytope *mp)
Deletes the structure allocated by DefinePolytope.
Definition: cpolytope.c:1380
A box.
Definition: box.h:83
Tbox bb
Definition: cpolytope.h:86
unsigned int PolytopeNeighbourID(unsigned int n, Tcpolytope *mp)
Returns the identifier of one of the neighbours of a polytope.
Definition: cpolytope.c:992
Definition of a smple polytope associated to a chart.
boolean CutPolytope(Tparameters *pr, double *t, double r, unsigned int id, void *wcs, void *c, unsigned int m, unsigned int *tp, Tbox *ambient, Tcpolytope *mp)
Crops the polytope bounding chart with a plane.
Definition: cpolytope.c:396
unsigned int * nIndices
Definition: cpolytope.h:80
unsigned int PolytopeMemSize(Tcpolytope *mp)
Computes the memory used by the polytope.
Definition: cpolytope.c:1169
A polytope associated with chart on a manifold.
Definition: cpolytope.h:52
boolean RandomPointInPolytope(double *t, Tcpolytope *mp)
Random point on the polytope with uniform distribution.
Definition: cpolytope.c:914
void PolytopeBoundaryPointsFromExternalCorners(double rSample, unsigned int *n, unsigned int **nv, double ***t, Tcpolytope *mp)
Points on boundary from all the polytope vertexes.
Definition: cpolytope.c:876
Macros and functions to operate on worlds/cuiksystems.
void GetPolytopeVertices(unsigned int *nv, double ***v, Tcpolytope *mp)
Gets the set of vertices of the polytope.
Definition: cpolytope.c:1027
void PrintPolytopeInfo(Tcpolytope *mp)
Prints information about the polytope.
Definition: cpolytope.c:1350
void LoadPolytope(FILE *f, Tcpolytope *mp)
Reads the chart polytope from a file.
Definition: cpolytope.c:1252
void DefinePolytope(Tcpolytope *mp)
Initial definition of the polytope bounding the local chart.
Definition: cpolytope.c:77
void CopyPolytope(Tcpolytope *mp_dst, Tcpolytope *mp_src)
Copies the polytope from one chart to another.
Definition: cpolytope.c:229
Definition of the Tparameters type and the associated functions.
double PolytopeVolume(Tcpolytope *mp)
Polytope volume.
Definition: cpolytope.c:951
boolean ExpandiblePolytope(Tcpolytope *mp)
Identifies polytopes not fully bounded.
Definition: cpolytope.c:679
double r
Definition: cpolytope.h:54
boolean CutPolytopeWithFace(Tparameters *pr, double *t, double offset, unsigned int id, void *wcs, void *c, unsigned int m, unsigned int *tp, Tbox *ambient, Tcpolytope *mp)
Cuts a polytope with a given plane.
Definition: cpolytope.c:412
void PolytopeCenter(double *t, Tcpolytope *mp)
Computes the center of the polytope.
Definition: cpolytope.c:301
unsigned int ** indices
Definition: cpolytope.h:82
unsigned int nVertices
Definition: cpolytope.h:72