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 3349 - (download) (as text) (annotate)
Tue Oct 27 15:16:36 2015 UTC (4 years, 11 months ago) by jhr
File size: 2369 byte(s)
making copyrights consistent for all code in the repository
/*! \file grid.h
 * \author Lamont Samuels
 * This is includes the structure of and functions for the KDTree. 

 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 * COPYRIGHT (c) 2015 The University of Chicago
 * 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
    struct struct_kdnode 	*left; 
    struct struct_kdnode     *right;	// the left and right hand sides of the node  
     /* Tree Building Info */ 
    uint32_t len;              // the len of the array 
    uint32_t axis;             // the axis of the node 
    uint32_t start;            // the starting parameter   

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