00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00038 #ifndef BOX_SYSTEM_HEADER
00039 #define BOX_SYSTEM_HEADER
00040
00041
00042 #include "realtype.h"
00043
00044
00045 typedef struct
00046 {
00047 ergo_real centerCoords[3];
00048 int originalIndex;
00049 } box_item_struct;
00050
00051
00052 typedef struct
00053 {
00054 ergo_real centerCoords[3];
00055 ergo_real width;
00056 int noOfItems;
00057 int firstItemIndex;
00058 int noOfChildBoxes;
00059 int firstChildBoxIndex;
00060 } box_struct_basic;
00061
00062 typedef struct
00063 {
00064 int noOfBoxes;
00065 int startIndexInBoxList;
00066 } box_level_struct;
00067
00068 #define MAX_NO_OF_BOX_LEVELS 30
00069
00070 class BoxSystem
00071 {
00072 public:
00073 int totNoOfBoxes;
00074 int noOfLevels;
00075 box_level_struct levelList[MAX_NO_OF_BOX_LEVELS];
00076 box_struct_basic* boxList;
00077 BoxSystem();
00078 ~BoxSystem();
00079 int create_box_system(box_item_struct* itemList,
00080 int noOfItems,
00081 ergo_real toplevelBoxSize);
00082 int get_items_near_point(const box_item_struct* itemList,
00083 const ergo_real* coords,
00084 ergo_real distance,
00085 int* resultOrgIndexList) const;
00086 private:
00087 int get_items_near_point_recursive(const box_item_struct* itemList,
00088 const ergo_real* coords,
00089 ergo_real distance,
00090 int* resultOrgIndexList,
00091 int level,
00092 int boxIndex) const;
00093 };
00094
00095 ergo_real
00096 get_min_distance_from_point_to_box(const ergo_real* boxCenterCoords,
00097 ergo_real halfwidth,
00098 const ergo_real* point);
00099
00100
00101
00102 #endif