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

SCM Repository

[diderot] Diff of /branches/lamont/src/compiler/c-target/fragments/kdtree.in
ViewVC logotype

Diff of /branches/lamont/src/compiler/c-target/fragments/kdtree.in

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

revision 3281, Tue Oct 13 17:05:21 2015 UTC revision 3282, Tue Oct 13 19:46:34 2015 UTC
# Line 33  Line 33 
33          return isWithinRadius@SPATIAL_DIMENSION@D(qPos, neighbor->pos, radius);          return isWithinRadius@SPATIAL_DIMENSION@D(qPos, neighbor->pos, radius);
34  }  }
35    
36  void sphereSearch(@STRANDTY@ ** strands,  void sphereSearch(@PREFIX@World_t * wrld,
37                                    KDNode_t * curr,                                    KDNode_t * curr,
38                                    Diderot_vec@SPATIAL_DIMENSION@_t qPos,                                    Diderot_vec@SPATIAL_DIMENSION@_t qPos,
39                                    uint32_t qStrandId,                                    uint32_t qStrandId,
# Line 43  Line 43 
43                                    uint32_t dim,                                    uint32_t dim,
44                                    uint32_t * neighborCount)                                    uint32_t * neighborCount)
45  {  {
46    
47          if (!curr) return;          if (!curr) return;
48    
49          if( Diderot_KDTree_isWithinRadius(qPos,strands[curr->strandId],radius,dim) && (qStrandId != curr->strandId)) {          @STRANDTY@ ** strands = wrld->inState;
50            bool shouldInclude = (qStrandId != curr->strandId) &&
51                                                     (wrld->status[curr->strandId] == DIDEROT_ACTIVE ||
52                                                      wrld->status[curr->strandId] == DIDEROT_STABLE);
53    
54            if(shouldInclude && Diderot_KDTree_isWithinRadius(qPos,strands[curr->strandId],radius,dim)) {
55    
56                  Diderot_QueryList_Add(strands[curr->strandId],qList);                  Diderot_QueryList_Add(strands[curr->strandId],qList);
57                  *neighborCount +=1;                  *neighborCount +=1;
# Line 58  Line 64 
64    
65          if ( Diderot_Query_GetPosValue(strands[curr->strandId]->pos,oldI) >= (Diderot_Query_GetPosValue(qPos,oldI) - radius)  &&          if ( Diderot_Query_GetPosValue(strands[curr->strandId]->pos,oldI) >= (Diderot_Query_GetPosValue(qPos,oldI) - radius)  &&
66                  (Diderot_Query_GetPosValue(strands[curr->strandId]->pos,oldI) <= (Diderot_Query_GetPosValue(qPos,oldI) + radius))) {                  (Diderot_Query_GetPosValue(strands[curr->strandId]->pos,oldI) <= (Diderot_Query_GetPosValue(qPos,oldI) + radius))) {
67                  sphereSearch(strands,curr->left,qPos,qStrandId,qList, radius, i, dim,neighborCount);                  sphereSearch(wrld,curr->left,qPos,qStrandId,qList, radius, i, dim,neighborCount);
68                  sphereSearch(strands,curr->right,qPos,qStrandId, qList,radius, i, dim,neighborCount);                  sphereSearch(wrld,curr->right,qPos,qStrandId, qList,radius, i, dim,neighborCount);
69    
70          }else if(Diderot_Query_GetPosValue(strands[curr->strandId]->pos,oldI) <= (Diderot_Query_GetPosValue(qPos,oldI) - radius)){          }else if(Diderot_Query_GetPosValue(strands[curr->strandId]->pos,oldI) <= (Diderot_Query_GetPosValue(qPos,oldI) - radius)){
71                  sphereSearch(strands,curr->right,qPos,qStrandId, qList,radius, i, dim,neighborCount);                  sphereSearch(wrld,curr->right,qPos,qStrandId, qList,radius, i, dim,neighborCount);
72          }else {          }else {
73                  sphereSearch(strands,curr->left, qPos,qStrandId, qList,radius, i, dim,neighborCount);                  sphereSearch(wrld,curr->left, qPos,qStrandId, qList,radius, i, dim,neighborCount);
74          }          }
75    
76  }  }
77    
78    
79  STATIC_INLINE Diderot_DynSeq_t * spherical_query(@STRANDTY@ ** strands,  STATIC_INLINE Diderot_DynSeq_t * spherical_query(
80                                     @PREFIX@World_t * wrld,
81                                   Diderot_vec@SPATIAL_DIMENSION@_t qPos,                                   Diderot_vec@SPATIAL_DIMENSION@_t qPos,
82                                   uint32_t qStrandId,                                   @STRANDTY@ * qStrand,
                                  KDTree_t * tree,  
83                                   QueryListPool_t * queryPool,                                   QueryListPool_t * queryPool,
84                                   Diderot_real_t radius)                                   Diderot_real_t radius)
85  {  {
86    
87          uint32_t neighborCount=0;          uint32_t neighborCount=0;
88            @STRANDTY@ ** strands = wrld->inState;
89            KDTree_t * tree = wrld->spatialTree;
90            uint32_t qStrandId = qStrand->strandId;
91          QueryList_t * qList = Diderot_Grab_QueryList(queryPool);          QueryList_t * qList = Diderot_Grab_QueryList(queryPool);
92          sphereSearch(strands,tree->root,qPos,qStrandId,qList,radius,0,tree->dim,&neighborCount);          sphereSearch(wrld,tree->root,qPos,qStrandId,qList,radius,0,tree->dim,&neighborCount);
93          Diderot_DynSeq_t * seq = Diderot_DynSeqAlloc(sizeof(@STRANDTY@ *), neighborCount);          Diderot_DynSeq_t * seq = Diderot_DynSeqAlloc(sizeof(@STRANDTY@ *), neighborCount);
94      seq->data = qList->pool;      seq->data = qList->pool;
95          return seq;          return seq;

Legend:
Removed from v.3281  
changed lines
  Added in v.3282

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