00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef pfs_PFS3tree_h
00012 #define pfs_PFS3tree_h
00013
00014 #include <math.h>
00015 #define RT3_MAX_NUM_NODES 100
00016
00017 #ifndef ABS
00018 #define ABS(x) (((x)>= 0)?(x): -(x))
00019 #endif
00020
00021 #ifndef MIN
00022 #define MIN(x,y) (((x)<(y))?(x):(y))
00023 #endif
00024
00025 #ifndef MAX
00026 #define MAX(x,y) (((x)>(y))?(x):(y))
00027 #endif
00028
00029 #ifndef double_MAX
00030 #define double_MAX 1.6e+300
00031 #endif
00032
00033 #ifndef double_MIN
00034 #define double_MIN 1.6e-300
00035 #endif
00036
00037 class PFS3Box
00038 {
00039 public:
00040 double Xmin,Ymin,Zmin,Xmax,Ymax,Zmax;
00041 void Dup(PFS3Box *B);
00042 int Equal(PFS3Box *);
00043 int Disjoint(PFS3Box *);
00044 double Volume();
00045 void ExtendVolume(PFS3Box *);
00046 };
00047
00048 class PFS3BoxId:public PFS3Box
00049 {
00050 public:
00051 void *P;
00052 };
00053
00054 class PFS3NodeBoxId
00055 {
00056 int Num;
00057 int Max;
00058 int Min;
00059 protected:
00060 PFS3BoxId *Vet;
00061 public:
00062 PFS3NodeBoxId(int Pmin, int Pmax);
00063 virtual ~PFS3NodeBoxId();
00064 int Number () {return Num;};
00065 void Start () {Num=0;};
00066 void Dup(PFS3NodeBoxId *Fromn);
00067 void BBox (PFS3Box *B);
00068 void MakeBoxId(PFS3BoxId *Node);
00069 void GetPos(PFS3BoxId *E,int i);
00070 void PutPos(PFS3BoxId *E,int i);
00071 void Insert(PFS3BoxId *E,int Posit);
00072 void Append(PFS3BoxId *E);
00073 void Remove(int i);
00074 void Remove(PFS3BoxId *E,int Cont);
00075 void Remove(PFS3BoxId *E);
00076 void ChooseBoxId(PFS3BoxId *ebox,PFS3BoxId *Out,int *Posit);
00077 void UpdateBox(PFS3Box *B,int Posit);
00078 int LocateBoxId(PFS3BoxId *In,int *Posit);
00079 void SplitNodeR3tree(PFS3NodeBoxId *Newnode);
00080 };
00081
00082 class PFS3Rtree
00083 {
00084 protected:
00085 int Max;
00086 int Min;
00087 int Level;
00088 PFS3NodeBoxId *Root;
00089
00090
00091
00092
00093
00094 PFS3NodeBoxId *Vnode[RT3_MAX_NUM_NODES];
00095 int Vpos[RT3_MAX_NUM_NODES];
00096 int NumL;
00097 PFS3Box SearchVal;
00098
00099 int Remove(PFS3NodeBoxId *Node,PFS3BoxId *In,int Lev);
00100 void Delete(PFS3NodeBoxId *Node,int Lev);
00101 void Number(PFS3NodeBoxId *Node,int *num,int Lev);
00102 void MergeRoot();
00103 void Merge(PFS3NodeBoxId *Father,PFS3NodeBoxId *Node,short Posit);
00104 int Insert(PFS3NodeBoxId *Node,PFS3BoxId *In,PFS3BoxId *Out,int Lev);
00105 void SplitNodeR3tree(PFS3NodeBoxId *Node, PFS3BoxId *Out);
00106 void Print( PFS3NodeBoxId *Node, int ident, int *num, int Lev);
00107
00108 public:
00109 PFS3Rtree(int Nmin,int Nmax);
00110 virtual ~PFS3Rtree();
00111 void Insert(PFS3BoxId *newentry);
00112 int Remove(PFS3BoxId *newentry);
00113
00114 void Print();
00115 void Create();
00116 void Delete();
00117 int Number();
00118 void BBox(PFS3Box *B);
00119 void Search(PFS3Box *B);
00120 int Result(PFS3BoxId *B);
00121 void SearchAll();
00122 int ResultAll(PFS3BoxId *B);
00123 };
00124
00125 #endif