----------------------------------------------------------------------------- Public Code -----------------------------------------------------------------------------*/ @return a new KDTREE based on the specified parameters. @param KeySize # of dimensions in the K-D tree @param KeyDesc array of params to describe key dimensions
| 181 | /// @param KeySize # of dimensions in the K-D tree |
| 182 | /// @param KeyDesc array of params to describe key dimensions |
| 183 | KDTREE *MakeKDTree(inT16 KeySize, const PARAM_DESC KeyDesc[]) { |
| 184 | KDTREE *KDTree = (KDTREE *) Emalloc( |
| 185 | sizeof(KDTREE) + (KeySize - 1) * sizeof(PARAM_DESC)); |
| 186 | for (int i = 0; i < KeySize; i++) { |
| 187 | KDTree->KeyDesc[i].NonEssential = KeyDesc[i].NonEssential; |
| 188 | KDTree->KeyDesc[i].Circular = KeyDesc[i].Circular; |
| 189 | if (KeyDesc[i].Circular) { |
| 190 | KDTree->KeyDesc[i].Min = KeyDesc[i].Min; |
| 191 | KDTree->KeyDesc[i].Max = KeyDesc[i].Max; |
| 192 | KDTree->KeyDesc[i].Range = KeyDesc[i].Max - KeyDesc[i].Min; |
| 193 | KDTree->KeyDesc[i].HalfRange = KDTree->KeyDesc[i].Range / 2; |
| 194 | KDTree->KeyDesc[i].MidRange = (KeyDesc[i].Max + KeyDesc[i].Min) / 2; |
| 195 | } else { |
| 196 | KDTree->KeyDesc[i].Min = MINSEARCH; |
| 197 | KDTree->KeyDesc[i].Max = MAXSEARCH; |
| 198 | } |
| 199 | } |
| 200 | KDTree->KeySize = KeySize; |
| 201 | KDTree->Root.Left = NULL; |
| 202 | KDTree->Root.Right = NULL; |
| 203 | return KDTree; |
| 204 | } |
| 205 | |
| 206 | |
| 207 | /** |
no test coverage detected