|
Blender
V2.59
|
00001 /* 00002 * $Id: BLI_kdtree.h 34966 2011-02-18 13:58:08Z jesterking $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00021 * All rights reserved. 00022 * 00023 * The Original Code is: none of this file. 00024 * 00025 * Contributor(s): Janne Karhu 00026 * Brecht Van Lommel 00027 * 00028 * ***** END GPL LICENSE BLOCK ***** 00029 */ 00030 00031 #ifndef BLI_KDTREE_H 00032 #define BLI_KDTREE_H 00033 00041 struct KDTree; 00042 typedef struct KDTree KDTree; 00043 00044 typedef struct KDTreeNearest { 00045 int index; 00046 float dist; 00047 float co[3]; 00048 } KDTreeNearest; 00049 00050 /* Creates or free a kdtree */ 00051 KDTree* BLI_kdtree_new(int maxsize); 00052 void BLI_kdtree_free(KDTree *tree); 00053 00054 /* Construction: first insert points, then call balance. Normal is optional. */ 00055 void BLI_kdtree_insert(KDTree *tree, int index, float *co, float *nor); 00056 void BLI_kdtree_balance(KDTree *tree); 00057 00058 /* Find nearest returns index, and -1 if no node is found. 00059 * Find n nearest returns number of points found, with results in nearest. 00060 * Normal is optional, but if given will limit results to points in normal direction from co. */ 00061 int BLI_kdtree_find_nearest(KDTree *tree, float *co, float *nor, KDTreeNearest *nearest); 00062 int BLI_kdtree_find_n_nearest(KDTree *tree, int n, float *co, float *nor, KDTreeNearest *nearest); 00063 00064 /* Range search returns number of points found, with results in nearest */ 00065 /* Normal is optional, but if given will limit results to points in normal direction from co. */ 00066 /* Remember to free nearest after use! */ 00067 int BLI_kdtree_range_search(KDTree *tree, float range, float *co, float *nor, KDTreeNearest **nearest); 00068 #endif 00069