Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /branches/lamont/src/include/Diderot/kdtree.h
ViewVC logotype

View of /branches/lamont/src/include/Diderot/kdtree.h

Parent Directory Parent Directory | Revision Log Revision Log

Revision 2418 - (download) (as text) (annotate)
Tue Sep 3 15:10:19 2013 UTC (7 years ago) by jhr
File size: 2033 byte(s)
/*! \file grid.h
 * \author Lamont Samuels
 * This is includes the structure of and functions for the KDTree. 

 * COPYRIGHT (c) 2013 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.

#ifndef _KDTREE_H_
#define _KDTREE_H_

#  include "Diderot/types.h"
#  include "Diderot/inline-vec2.h"
#  include "Diderot/inline-vec3.h"

#define MAX_KD_DIM 3 
#define POOL_INCR_SIZE 100

typedef struct struct_kdnode KDNode_t;
struct struct_kdnode {
    uint32_t	strandId;		// the unique identification number for a strand  
    KDNode_t	*left, *right;		// the left and right hand sides of the node  

typedef struct { 
    uint32_t	handle;			// the index into of the next free grid item in the pool; 
    uint32_t	poolSize;		// the number of elements in the pool; 
    KDNode_t	*pool;			// the pool of grid nodes. 
} KDPool_t;

//KDTree_t -> Information about the tree 
typedef struct{
    uint32_t	*numOfStrands;		// The nuber of strands in execution
    uint32_t	dim;			// the dimension of the tree 
    KDPool_t	treePool;		// The pool of KDNodes for the grid. 
    KDNode_t	*root;			// The root of the tree. 
} KDTree_t; 

STATIC_INLINE bool isWithinRadius1D (Diderot_real_t particle, Diderot_real_t neighbor, Diderot_real_t radius)
    return ABS(particle - neighbor) <= radius; 

STATIC_INLINE bool isWithinRadius2D (Diderot_vec2_t particle, Diderot_vec2_t neighbor, Diderot_real_t radius)
    return lengthSq2(particle - neighbor) <= (radius * radius); 

STATIC_INLINE bool isWithinRadius3D (Diderot_vec3_t particle, Diderot_vec3_t neighbor, Diderot_real_t radius)
    return lengthSq3(particle - neighbor) <= (radius * radius); 

void Diderot_KDTree_Alloc (KDTree_t ** tree,  uint32_t * numOfStrands, uint32_t dim); 
KDNode_t * Diderot_KDTree_GrabNode (KDTree_t * tree); 
void Diderot_KDTree_PoolClear (KDTree_t * tree); 

#endif /* _KDTREE_H_ */ 

ViewVC Help
Powered by ViewVC 1.0.0