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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2416, Mon Aug 19 12:57:45 2013 UTC revision 2418, Tue Sep 3 15:10:19 2013 UTC
# Line 16  Line 16 
16  #ifndef _DIDEROT_TYPES_H_  #ifndef _DIDEROT_TYPES_H_
17  #  include "Diderot/types.h"  #  include "Diderot/types.h"
18  #endif  #endif
19    #ifndef _DIDEROT_INLINE_VEC2_H_
20    #  include "Diderot/inline-vec2.h"
21    #endif
22    #ifndef _DIDEROT_INLINE_VEC3_H_
23    #  include "Diderot/inline-vec3.h"
24    #endif
25    
26  #define MAX_KD_DIM 3  #define MAX_KD_DIM 3
27  #define POOL_INCR_SIZE 100  #define POOL_INCR_SIZE 100
28    
29  //KDNode_t  //KDNode_t
30  typedef struct KDNode {  typedef struct struct_kdnode KDNode_t;
31    struct struct_kdnode {
32      uint32_t        strandId;                   // the unique identification number for a strand      uint32_t        strandId;                   // the unique identification number for a strand
33      struct KDNode   *left, *right;       // the left and right hand sides of the node      KDNode_t    *left, *right;          // the left and right hand sides of the node
34  } KDNode_t;  };
35    
36  typedef struct {  typedef struct {
37      uint32_t handle;                   // the index into of the next free grid item in the pool;      uint32_t handle;                   // the index into of the next free grid item in the pool;
# Line 40  Line 47 
47      KDNode_t  *root;                  // The root of the tree.      KDNode_t  *root;                  // The root of the tree.
48  }KDTree_t;  }KDTree_t;
49    
50  STATIC_INLINE bool isWithinRadius1D( Diderot_real_t  particle,  Diderot_real_t neighbor, Diderot_real_t radius, uint32_t dim)  STATIC_INLINE bool isWithinRadius1D (Diderot_real_t particle, Diderot_real_t neighbor, Diderot_real_t radius)
51  {  {
52      Diderot_real_t squared_r = radius * radius;      return ABS(particle - neighbor) <= radius;
         Diderot_real_t squared_dist = (particle-neighbor) * (particle-neighbor);  
   
         return squared_dist <= squared_r;  
53  }  }
 STATIC_INLINE bool isWithinRadius2D( Diderot_vec2_t  particle,  Diderot_vec2_t neighbor, Diderot_real_t radius) {  
   
     Diderot_real_t squared_r = radius * radius;  
   
         Diderot_union2_t uv = __extension__ (Diderot_union2_t)(((particle-neighbor) * (particle-neighbor)));  
     Diderot_real_t squared_dist = uv.r[0] + uv.r[1];  
54    
55          return squared_dist <= squared_r;  STATIC_INLINE bool isWithinRadius2D (Diderot_vec2_t particle, Diderot_vec2_t neighbor, Diderot_real_t radius)
56    {
57        return lengthSq2(particle - neighbor) <= (radius * radius);
58  }  }
 STATIC_INLINE bool isWithinRadius3D(Diderot_vec3_t  particle,  Diderot_vec3_t neighbor, Diderot_real_t radius) {  
   
     Diderot_real_t squared_r = radius * radius;  
   
         Diderot_union3_t uv = __extension__ (Diderot_union3_t)((particle-neighbor) * (particle-neighbor));  
     Diderot_real_t squared_dist = uv.r[0] + uv.r[1] + uv.r[2];  
59    
60          return squared_dist <= squared_r;  STATIC_INLINE bool isWithinRadius3D (Diderot_vec3_t particle, Diderot_vec3_t neighbor, Diderot_real_t radius)
61    {
62        return lengthSq3(particle - neighbor) <= (radius * radius);
63  }  }
64    
   
65  void Diderot_KDTree_Alloc(KDTree_t ** tree,  uint32_t * numOfStrands, uint32_t dim);  void Diderot_KDTree_Alloc(KDTree_t ** tree,  uint32_t * numOfStrands, uint32_t dim);
66  KDNode_t * Diderot_KDTree_GrabNode( KDTree_t * tree);  KDNode_t * Diderot_KDTree_GrabNode( KDTree_t * tree);
67  void Diderot_KDTree_PoolClear( KDTree_t * tree);  void Diderot_KDTree_PoolClear( KDTree_t * tree);

Legend:
Removed from v.2416  
changed lines
  Added in v.2418

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