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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2416 - (view) (download) (as text)

1 : lamonts 2416 /*! \file grid.h
2 :     *
3 :     * \author Lamont Samuels
4 :     *
5 :     * This is includes the structure of and functions for the KDTree.
6 :     */
7 :    
8 :     /*
9 :     * COPYRIGHT (c) 2013 The Diderot Project (http://diderot-language.cs.uchicago.edu)
10 :     * All rights reserved.
11 :     */
12 :    
13 :     #ifndef _KDTREE_H_
14 :     #define _KDTREE_H_
15 :    
16 :     #ifndef _DIDEROT_TYPES_H_
17 :     # include "Diderot/types.h"
18 :     #endif
19 :    
20 :     #define MAX_KD_DIM 3
21 :     #define POOL_INCR_SIZE 100
22 :    
23 :     //KDNode_t
24 :     typedef struct KDNode {
25 :     uint32_t strandId; // the unique identification number for a strand
26 :     struct KDNode *left, *right; // the left and right hand sides of the node
27 :     } KDNode_t;
28 :    
29 :     typedef struct {
30 :     uint32_t handle; // the index into of the next free grid item in the pool;
31 :     uint32_t poolSize; // the number of elements in the pool;
32 :     KDNode_t *pool; // the pool of grid nodes.
33 :     } KDPool_t;
34 :    
35 :     //KDTree_t -> Information about the tree
36 :     typedef struct{
37 :     uint32_t *numOfStrands; // The nuber of strands in execution
38 :     uint32_t dim; // the dimension of the tree
39 :     KDPool_t treePool; // The pool of KDNodes for the grid.
40 :     KDNode_t *root; // The root of the tree.
41 :     }KDTree_t;
42 :    
43 :     STATIC_INLINE bool isWithinRadius1D( Diderot_real_t particle, Diderot_real_t neighbor, Diderot_real_t radius, uint32_t dim)
44 :     {
45 :     Diderot_real_t squared_r = radius * radius;
46 :     Diderot_real_t squared_dist = (particle-neighbor) * (particle-neighbor);
47 :    
48 :     return squared_dist <= squared_r;
49 :     }
50 :     STATIC_INLINE bool isWithinRadius2D( Diderot_vec2_t particle, Diderot_vec2_t neighbor, Diderot_real_t radius) {
51 :    
52 :     Diderot_real_t squared_r = radius * radius;
53 :    
54 :     Diderot_union2_t uv = __extension__ (Diderot_union2_t)(((particle-neighbor) * (particle-neighbor)));
55 :     Diderot_real_t squared_dist = uv.r[0] + uv.r[1];
56 :    
57 :     return squared_dist <= squared_r;
58 :     }
59 :     STATIC_INLINE bool isWithinRadius3D(Diderot_vec3_t particle, Diderot_vec3_t neighbor, Diderot_real_t radius) {
60 :    
61 :     Diderot_real_t squared_r = radius * radius;
62 :    
63 :     Diderot_union3_t uv = __extension__ (Diderot_union3_t)((particle-neighbor) * (particle-neighbor));
64 :     Diderot_real_t squared_dist = uv.r[0] + uv.r[1] + uv.r[2];
65 :    
66 :     return squared_dist <= squared_r;
67 :     }
68 :    
69 :    
70 :     void Diderot_KDTree_Alloc(KDTree_t ** tree, uint32_t * numOfStrands, uint32_t dim);
71 :     KDNode_t * Diderot_KDTree_GrabNode( KDTree_t * tree);
72 :     void Diderot_KDTree_PoolClear( KDTree_t * tree);
73 :    
74 :     #endif /* _KDTREE_H_ */

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0