box.h
Go to the documentation of this file.
1 #ifndef BOXH
2 #define BOXH
3 
4 #include "interval.h"
5 #include "boolean.h"
6 #include "variable_set.h"
7 #include "vector.h"
8 
9 #include <stdio.h>
10 
11 
20 /************************************************************************************/
25 #define EMPTY_BOX 0
26 
32 #define ERROR_IN_PROCESS 1
33 
38 #define REDUCED_BOX 2
39 
45 #define UNBOUNDED_BOX 3
46 
52 #define REDUCED_BOX_WITH_SOLUTION 4
53 
59 #define NOT_REDUCED_BOX 5
60 
65 #define BOX_OK 6
66 /************************************************************************************/
67 
83 typedef struct {
84  unsigned int level;
85  unsigned int n;
87 } Tbox;
88 
99 void InitBox(unsigned int dim,Tinterval *is,Tbox *b);
100 
110 void InitBoxFromPoint(unsigned int dim,double *p,Tbox *b);
111 
124 void EnlargeBox(double lo,double uo,Tbox *b);
125 
136 void ExpandBox(double *p,Tbox *b);
137 
152 unsigned int GetBoxBufferSize(Tbox *b);
153 
169 void Box2Buffer(unsigned int c,unsigned int n,double *buffer,Tbox *b);
170 
190 void Buffer2Box(unsigned int *c,unsigned int *n,double *buffer,Tbox *b);
191 
206 void CopyBox(void *b_out,void *b_in);
207 
217 void MergeBoxes(Tbox *b1,Tbox *b2,Tbox *bout);
218 
235 void CopyBoxSubset(boolean *used,void *b_out,void *b_in);
236 
253 void SetBoxSubset(boolean *used,Tbox *bset,Tbox *b);
254 
266 void SetBoxIntervals(Tinterval *is,Tbox *b);
267 
268 
279 void SetBoxInterval(unsigned int n,Tinterval *is,Tbox *b);
280 
281 
304 boolean BoxesIntersection(boolean *used,Tbox *b1,Tbox *b2,Tbox *bout);
305 
327 void BoxUnion(boolean *used,Tbox *b1,Tbox *b2,Tbox *b_out);
328 
329 
343 void Crop2Box(boolean *used,unsigned int n,double *p,Tbox *b);
344 
362 boolean PointInBox(boolean *used,unsigned int n,double *v,double tol,Tbox *b);
363 
388 boolean PointInBoxTopology(boolean *used,boolean update,
389  unsigned int n,double *v,double tol,unsigned int *tp,Tbox *b);
390 
413 unsigned int OutOfBoxTopology(boolean *used,unsigned int n,double *v,
414  unsigned int *tp,signed int *s,Tbox *b);
415 
439 boolean PointInSubBox(boolean *used,Tvector *v,double tol,Tbox *b);
440 
463 double DistanceToSubBoxCenter(boolean *used,Tvector *v,Tbox *b);
464 
482 boolean IsPunctualBox(boolean *used,double epsilon,Tbox *b);
483 
499 boolean BoxInclusion(boolean *used,Tbox *b1,Tbox *b2);
500 
501 
515 unsigned int GetDistanceWeightsFromBox(double **w,Tbox *b);
516 
531 Tinterval *GetBoxInterval(unsigned int n,Tbox *b);
532 
548 
563 double GetBoxSize(boolean *used,Tbox *b);
564 
579 double GetBoxMaxSizeVarSet(Tvariable_set *vars,Tbox *b);
580 
595 double GetBoxMinSizeVarSet(Tvariable_set *vars,Tbox *b);
596 
610 double GetBoxDiagonal(boolean *used,Tbox *b);
611 
622 unsigned int GetBoxLevel(Tbox *b);
623 
636 void RandomPointInBox(boolean *used,double *c,Tbox *b);
637 
650 void GetBoxCenter(boolean *used,double *c,Tbox *b);
651 
666 double GetBoxCenterDistance(boolean *used,Tbox *b1,Tbox *b2);
667 
683 double SquaredDistancePointToBox(double t2,double *p,Tbox *b);
684 
697 double DistancePointToBox(double *p,Tbox *b);
698 
712 double SquaredDistanceToBoxDimensionTopology(unsigned int dim,double p,unsigned int *tp,Tbox *b);
713 
730 double SquaredDistancePointToBoxTopology(double t,double *p,unsigned int *tp,Tbox *b);
731 
747 double DistancePointToBoxTopology(double *p,unsigned int *tp,Tbox *b);
748 
763 double GetBoxVolume(boolean *used,Tbox *b);
764 
784 double GetBoxSumSide(boolean *used,Tbox *b);
785 
795 unsigned int GetBoxNIntervals(Tbox *b);
796 
810 unsigned int GetBoxMaxDim(boolean *used,Tbox *b);
811 
827 unsigned int GetBoxSplitDim(boolean *used,Tbox *b);
828 
851 void SplitBox(unsigned int n,double r,Tbox *b1,Tbox *b2,Tbox *b);
852 
862 void ScaleBox(double max_upper,Tbox *b);
863 
872 void AddMargin2Box(double m,Tbox *b);
873 
874 
893 boolean CmpBoxDepthFirst(void *b1,void *b2,void *userData);
894 
913 boolean CmpBoxBreadthFirst(void *b1,void *b2,void *userData);
914 
930 void PrintBox(FILE *f,Tbox *b);
931 
953 void PrintBoxSubset(FILE *f,boolean *used,char **varNames,Tbox *b);
954 
969 int ReadBox(FILE *f,Tbox *b);
970 
971 
981 void SaveBox(FILE *f,Tbox *b);
982 
993 void LoadBox(FILE *f,Tbox *b);
994 
1003 void DeleteBox(void *b);
1004 
1005 #endif