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 3349 - (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 : jhr 3349 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
10 :     *
11 :     * COPYRIGHT (c) 2015 The University of Chicago
12 : lamonts 2416 * All rights reserved.
13 :     */
14 :    
15 :     #ifndef _KDTREE_H_
16 :     #define _KDTREE_H_
17 :    
18 :     #ifndef _DIDEROT_TYPES_H_
19 :     # include "Diderot/types.h"
20 :     #endif
21 : jhr 2418 #ifndef _DIDEROT_INLINE_VEC2_H_
22 :     # include "Diderot/inline-vec2.h"
23 :     #endif
24 :     #ifndef _DIDEROT_INLINE_VEC3_H_
25 :     # include "Diderot/inline-vec3.h"
26 :     #endif
27 : lamonts 2416
28 :     #define MAX_KD_DIM 3
29 :     #define POOL_INCR_SIZE 100
30 : lamonts 2848 //#define SPATIAL_SEQ_THERSHOLD 2048
31 : lamonts 2416
32 :     //KDNode_t
33 : jhr 2418 typedef struct struct_kdnode KDNode_t;
34 :     struct struct_kdnode {
35 : lamonts 2571 uint32_t strandId; // the unique identification number for a strand
36 :     struct struct_kdnode *left;
37 :     struct struct_kdnode *right; // the left and right hand sides of the node
38 :     /* Tree Building Info */
39 :     uint32_t len; // the len of the array
40 :     uint32_t axis; // the axis of the node
41 :     uint32_t start; // the starting parameter
42 : jhr 2418 };
43 : lamonts 2416
44 :     typedef struct {
45 : lamonts 2453 uint32_t handle; // the index into of the next free grid item in the pool;
46 :     uint32_t poolSize; // the number of elements in the pool;
47 : jhr 2418 KDNode_t *pool; // the pool of grid nodes.
48 : lamonts 2416 } KDPool_t;
49 :    
50 :     //KDTree_t -> Information about the tree
51 :     typedef struct{
52 : lamonts 2453 uint32_t *numOfStrands; // The nuber of strands in execution
53 :     uint32_t dim; // the dimension of the tree
54 :     KDPool_t treePool; // The pool of KDNodes for the grid.
55 : jhr 2418 KDNode_t *root; // The root of the tree.
56 :     } KDTree_t;
57 : lamonts 2416
58 : jhr 2418 STATIC_INLINE bool isWithinRadius1D (Diderot_real_t particle, Diderot_real_t neighbor, Diderot_real_t radius)
59 : lamonts 2416 {
60 : jhr 2418 return ABS(particle - neighbor) <= radius;
61 :     }
62 : lamonts 2416
63 : jhr 2418 STATIC_INLINE bool isWithinRadius2D (Diderot_vec2_t particle, Diderot_vec2_t neighbor, Diderot_real_t radius)
64 :     {
65 :     return lengthSq2(particle - neighbor) <= (radius * radius);
66 : lamonts 2416 }
67 :    
68 : jhr 2418 STATIC_INLINE bool isWithinRadius3D (Diderot_vec3_t particle, Diderot_vec3_t neighbor, Diderot_real_t radius)
69 :     {
70 :     return lengthSq3(particle - neighbor) <= (radius * radius);
71 :     }
72 : lamonts 2416
73 : jhr 2418 void Diderot_KDTree_Alloc (KDTree_t ** tree, uint32_t * numOfStrands, uint32_t dim);
74 :     KDNode_t * Diderot_KDTree_GrabNode (KDTree_t * tree);
75 :     void Diderot_KDTree_PoolClear (KDTree_t * tree);
76 : lamonts 2416
77 :     #endif /* _KDTREE_H_ */

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