79 #ifndef CGAL_KDTREE_D_H
80 #define CGAL_KDTREE_D_H
86 #define CGAL_BEGIN_NAMESPACE namespace CGAL {
87 #define CGAL_END_NAMESPACE }
110 return pnt.dimension();
113 static int compare(
int d,
const PT & a,
const PT & b )
115 if ( a[ d ] < b[ d ] )
117 if ( a[ d ] > b[ d ] )
137 template <
class Traits>
142 typedef typename Traits::Point
Point;
175 assert(
p_arr != NULL );
188 for (
int ind = 0; ind <
dim; ind++ )
189 p_arr[ ind ].type = _type;
203 for (
int ind = 0; ind <
dim; ind++ ) {
217 for (
int ind = 0; ind <
dim; ind++ ) {
231 for (
int ind = 0; ind <
dim; ind++ ) {
239 if (
p_arr != NULL ) {
255 assert( 0 <= k && k <
dim );
260 Traits::copy_coord( k,
def_pnt, point );
266 assert( 0 <= k && k <
dim );
267 assert( 0 <= k && k < point.
dim );
278 assert( 0 <= k && k <
dim );
304 for ( ind = 0; ind <
dim; ind++ ) {
315 assert( 0 <= k && k <
dim );
333 assert( 0 <= d && d <
dim );
341 assert( 0 <= d && d <
dim );
429 for (
int i = 0;
i <
dim;
i++)
444 for (
int i = 0;
i <
dim;
i++)
466 for (
int i = 0;
i <
dim;
i++)
499 for (
int i = 0;
i <
dim;
i++)
516 for (
int i = 0;
i <
dim;
i++)
528 for (
int i = 0;
i <
dim;
i++)
578 std::cout <<
"(" <<
coord <<
": " << *
normal <<
")";
674 for ( ind = 0; ind < depth; ind++ )
678 std::cout << *
pnt <<
"\n";
685 for ( ind = 0; ind < depth; ind++ )
688 std::cout <<
"!!!!!!!!!!!!\n";
694 return ((
left == NULL) && (
right == NULL));
697 typedef std::back_insert_iterator<List_points>
back_iter;
727 Box * p_r =
new Box( _region );
732 plane.
split( *p_r, f_split_plus );
736 assert( node != NULL );
740 if ( rect.
is_in( *p_r ) )
756 node->
search( result, rect, *p_r );
762 void search( std::back_insert_iterator<List_points> result,
763 const Box &rect,
Box ®ion )
774 region,
plane,
true );
777 region,
plane,
false );
825 if (
comp( *(arr[ i ]), *(arr[ j ]), dim ) > 0 ) {
830 if (
comp( *(arr[ i ]), *p_pivot, dim ) < 0 ) {
833 if (
comp( *p_pivot, *(arr[ j ]), dim ) <= 0 )
837 return (i > left)? i - 1 : left;
856 pos =
partition( arr, left, right, arr[ (left + right ) / 2 ],
858 if ( pos == pos_mid )
862 split_arr( arr, pos+1, right, pos_mid, dim );
864 split_arr( arr, left, pos, pos_mid, dim );
869 int left,
int right,
int d )
872 Point mx = *(arr[ max_pos ]);
874 for (
int ind = left + 1; ind <= right; ind++ )
875 if (
comp( mx, *(arr[ ind ]), d ) < 0 ) {
880 return arr[ max_pos ];
886 int num, pos, next_d;
889 num = right - left + 1;
899 n->
pnt = arr[ left ];
906 pos = (left + right) / 2;
949 bool is_valid(
bool verbose =
false,
int level = 0 )
const
978 void search( std::back_insert_iterator<list_points> result,
999 assert( p_arr != NULL );
1008 for (
typename std::vector<Point>::iterator
j = v.begin();
static Point_ptr get_max_element(Point_ptr *arr, int left, int right, int d)
ExtPoint & get_vertex(bool f_left)
Node * build_r(Point_ptr *arr, int left, int right, int d)
void orient_half_space(bool f_neg_side)
int comp(const Box &o) const
void build(std::vector< Point > &v)
bool is_valid(bool verbose=false, int level=0) const
static void split_arr(Point_ptr *arr, int left, int right, int pos_mid, int dim)
void set_coord(int k, const ExtPoint &point)
const Point * get_coord_point(int d) const
const ExtPoint & get_left() const
int compare(int k, const Point &point) const
static int compare(int d, const PT &a, const PT &b)
void search(std::back_insert_iterator< List_points > result, const Box &rect, Box ®ion)
ExtPoint(const Point &point, int dim)
int compare(int k, const ExtPoint &point) const
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Point object that represents a single point.
int compare_vector(const ExtPoint &point) const
bool is_coord_in_range(int k, const Point &o) const
static void copy_coord(int d, PT &a, const PT &b)
Box(const Point &l, const Point &r, int _dim)
void set_coord(int k, Point &point)
std::vector< Point > List_points
int get_coord_status(int d) const
bool is_points_in_hs(const Plane &pl) const
static int comp(const Point &a, const Point &b, int dim)
ExtPoint(int _type, int _dim)
bool is_in(const Point &p) const
void copy_subtree_points(back_iter &result, const Box &rect)
void set_plane(int k, Point &p)
void set_coord_left(int k, Point &p)
ExtPoint(const ExtPoint &p)
static int partition(Point_ptr *arr, int left, int right, Point *p_pivot, int dim)
bool is_intersect_in_dim(int d, const Box &o) const
static void search_recursive(back_iter &result, Node *node, const Box &rect, Box &_region, Plane &plane, bool f_split_plus)
void split(Box ®ion, bool f_neg)
bool is_empty_open() const
static int dimension(const PT &pnt)
#define CGAL_BEGIN_NAMESPACE
ExtPoint & operator=(const ExtPoint &p)
void search(std::back_insert_iterator< list_points > result, Box &rect)
CGAL_KERNEL_INLINE Comparison_result compare(const NT &n1, const NT &n2)
std::back_insert_iterator< List_points > back_iter
bool is_in(const Box &o) const
bool is_intersect(const Box &o) const
const ExtPoint & get_right() const
bool is_in(const Point &o) const
const Plane & get_hs(int side) const
#define CGAL_END_NAMESPACE
std::vector< Point > list_points
void set_coord_right(int k, Point &p)
bool is_intersect_in_dim_closed(int d, const Box &o) const