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

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/include/Diderot/cl-inline-image.h
ViewVC logotype

Diff of /branches/pure-cfg/src/include/Diderot/cl-inline-image.h

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

revision 1340, Mon Jun 13 19:57:19 2011 UTC revision 1341, Tue Jun 14 07:05:07 2011 UTC
# Line 23  Line 23 
23    
24  // check if pos is inside the img, assuming that we have a border of width s.  // check if pos is inside the img, assuming that we have a border of width s.
25  //  //
26  STATIC_INLINE bool Inside1f (float pos, Diderot_image1D_t *img, int s)  inline bool Inside1f (float pos, __global Diderot_image1D_t *img, int s)
27  {  {
28      return ((s-1 < pos) && (pos < (img->size[0] - s)));      return ((s-1 < pos) && (pos < (img->size[0] - s)));
29  }  }
30    
31  STATIC_INLINE float ToImageSpace1f (Diderot_image1D_t *img, float pos)  inline float ToImageSpace1f ( __global Diderot_image1D_t *img, float pos)
32  {  {
33      return img->s * pos + img->t;      return img->s * pos + img->t;
34  }  }
# Line 37  Line 37 
37    
38  // check if pos is inside the img, assuming that we have a border of width s.  // check if pos is inside the img, assuming that we have a border of width s.
39  //  //
40  STATIC_INLINE bool Inside2f (float2 posArg, Diderot_image2D_t *img, int s)  inline bool Inside2f (float2 posArg, __global Diderot_image2D_t *img, int s)
41  {  {
42      return ((s-1 < posArg.s0) && (posArg.s0 < (img->size[0] - s))      return ((s-1 < posArg.s0) && (posArg.s0 < (img->size[0] - s))
43          &&  (s-1 < posArg.s1) && (posArg.s1 < (img->size[1] - s)));          &&  (s-1 < posArg.s1) && (posArg.s1 < (img->size[1] - s)));
44  }  }
45    
46  STATIC_INLINE float2 ToImageSpace2f (Diderot_image2D_t *img, float2 p)  inline float2 ToImageSpace2f (__global Diderot_image2D_t *img, float2 p)
47  {  {
48      return (float2)(dot(img->w2i[0], p), dot(img->w2i[1], p)) + img->tVec;      return (float2)(dot(img->w2i[0], p), dot(img->w2i[1], p)) + img->tVec;
49  }  }
50    
51  STATIC_INLINE float2 ToWorldSpace2f (Diderot_image2D_t *img, float2 g)  inline float2 ToWorldSpace2f (__global Diderot_image2D_t *img, float2 g)
52  {  {
53      return (float2)(      return (float2)(
54          dot(img->w2iT[0], g),          dot(img->w2iT[0], g),
55          dot(img->w2iT[1], g));          dot(img->w2iT[1], g));
56  }  }
57    
58  STATIC_INLINE void ToWorldSpace2x2f (Diderot_Mat2x2_t dst, Diderot_image2D_t *img, Diderot_Mat2x2_t src)  inline void ToWorldSpace2x2f ( Diderot_Mat2x2_t dst, __global Diderot_image2D_t *img,  Diderot_Mat2x2_t src)
59  {  {
60      Diderot_Mat2x2_t tmp;      /* Diderot_Mat2x2_t tmp;
61      mulMat2x2Mat2x2f (tmp, img->w2iT, src);      mulMat2x2Mat2x2f (tmp, img->w2iT, src);
62      mulMat2x2Mat2x2f (dst, tmp, img->w2i);      mulMat2x2Mat2x2f (dst, tmp, img->w2i); */
63    
64        Diderot_Mat2x2_t tmp;
65    
66        tmp[0] = (float2)(
67                          dot(img->w2iT[0], (float2)(src[0].s0, src[1].s0)),
68                          dot(img->w2iT[0], (float2)(src[0].s1, src[1].s1)));
69        tmp[1] = (float2)(
70                          dot(img->w2iT[1], (float2)(src[0].s0, src[1].s0)),
71                          dot(img->w2iT[1], (float2)(src[0].s1, src[1].s1)));
72    
73        dst[0] = (float2)(
74                          dot(tmp[0], (float2)(img->w2i[0].s0, img->w2i[1].s0)),
75                          dot(tmp[0], (float2)(img->w2i[0].s1, img->w2i[1].s1)));
76        dst[1] = (float2)(
77                          dot(tmp[1], (float2)(img->w2i[0].s0, img->w2i[1].s0)),
78                          dot(tmp[1], (float2)(img->w2i[0].s1, img->w2i[1].s1)));
79    
80    
81  }  }
82    
83  /***** 3D Image functions *****/  /***** 3D Image functions *****/
84    
85  // check if pos is inside the img, assuming that we have a border of width s.  // check if pos is inside the img, assuming that we have a border of width s.
86  //  //
87  STATIC_INLINE bool Inside3f (float3 posArg, Diderot_image3D_t *img, int s)  inline bool Inside3f (float3 posArg, __global Diderot_image3D_t *img, int s)
88  {  {
89      return ((s-1 < posArg.s0) && (posArg.s0 < (img->size[0] - s))      return ((s-1 < posArg.s0) && (posArg.s0 < (img->size[0] - s))
90          &&  (s-1 < posArg.s1) && (posArg.s1 < (img->size[1] - s))          &&  (s-1 < posArg.s1) && (posArg.s1 < (img->size[1] - s))
91          &&  (s-1 < posArg.s2) && (posArg.s2 < (img->size[2] - s)));          &&  (s-1 < posArg.s2) && (posArg.s2 < (img->size[2] - s)));
92  }  }
93    
94  STATIC_INLINE float3 ToImageSpace3f (Diderot_image3D_t *img, float3 p)  inline float3 ToImageSpace3f (__global Diderot_image3D_t *img, float3 p)
95  {  {
96      return VEC3(dot(img->w2i[0], p), dot(img->w2i[1], p), dot(img->w2i[2], p)) + img->tVec;      return VEC3(dot(img->w2i[0], p), dot(img->w2i[1], p), dot(img->w2i[2], p)) + img->tVec;
97  }  }
98    
99  STATIC_INLINE float3 ToWorldSpace3f (Diderot_image3D_t *img, float3 g)  inline float3 ToWorldSpace3f (__global Diderot_image3D_t *img, float3 g)
100  {  {
101      return VEC3(      return VEC3(
102          dot(img->w2iT[0], g),          dot(img->w2iT[0], g),
# Line 86  Line 104 
104          dot(img->w2iT[2], g));          dot(img->w2iT[2], g));
105  }  }
106    
107  STATIC_INLINE void ToWorldSpace3x3f (Diderot_Mat3x3_t dst, Diderot_image3D_t *img, Diderot_Mat3x3_t src)  inline void ToWorldSpace3x3f ( Diderot_Mat3x3_t dst, __global Diderot_image3D_t *img,  Diderot_Mat3x3_t src)
108  {  {
109      Diderot_Mat3x3_t tmp;      /*Diderot_Mat3x3_t tmp;
110      mulMat3x3Mat3x3f (tmp, img->w2iT, src);      mulMat3x3Mat3x3f (tmp, img->w2iT, src);
111      mulMat3x3Mat3x3f (dst, tmp, img->w2i);      mulMat3x3Mat3x3f (dst, tmp, img->w2i);*/
112    
113        Diderot_Mat3x3_t tmp;
114    
115        tmp[0] = VEC3(
116                      dot(img->w2iT[0], VEC3(src[0].s0, src[1].s0, src[2].s0)),
117                      dot(img->w2iT[0], VEC3(src[0].s1, src[1].s1, src[2].s1)),
118                      dot(img->w2iT[0], VEC3(src[0].s2, src[1].s2, src[2].s2)));
119        tmp[1] = VEC3(
120                      dot(img->w2iT[1], VEC3(src[0].s0, src[1].s0, src[2].s0)),
121                      dot(img->w2iT[1], VEC3(src[0].s1, src[1].s1, src[2].s1)),
122                      dot(img->w2iT[1], VEC3(src[0].s2, src[1].s2, src[2].s2)));
123        tmp[2] = VEC3(
124                      dot(img->w2iT[2], VEC3(src[0].s0, src[1].s0, src[2].s0)),
125                      dot(img->w2iT[2], VEC3(src[0].s1, src[1].s1, src[2].s1)),
126                      dot(img->w2iT[2], VEC3(src[0].s2, src[1].s2, src[2].s2)));
127    
128        dst[0] = VEC3(
129                      dot(tmp[0], VEC3(img->w2i[0].s0, img->w2i[1].s0, img->w2i[2].s0)),
130                      dot(tmp[0], VEC3(img->w2i[0].s1, img->w2i[1].s1, img->w2i[2].s1)),
131                      dot(tmp[0], VEC3(img->w2i[0].s2, img->w2i[1].s2, img->w2i[2].s2)));
132        dst[1] = VEC3(
133                      dot(tmp[1], VEC3(img->w2i[0].s0, img->w2i[1].s0, img->w2i[2].s0)),
134                      dot(tmp[1], VEC3(img->w2i[0].s1, img->w2i[1].s1, img->w2i[2].s1)),
135                      dot(tmp[1], VEC3(img->w2i[0].s2, img->w2i[1].s2, img->w2i[2].s2)));
136        dst[2] = VEC3(
137                      dot(tmp[2], VEC3(img->w2i[0].s0, img->w2i[1].s0, img->w2i[2].s0)),
138                      dot(tmp[2], VEC3(img->w2i[0].s1, img->w2i[1].s1, img->w2i[2].s1)),
139                      dot(tmp[2], VEC3(img->w2i[0].s2, img->w2i[1].s2, img->w2i[2].s2)));
140    
141    
142  }  }
143    
144  #endif /* !_DIDEROT_CL_INLINE_IMAGE_H_ */  #endif /* !_DIDEROT_CL_INLINE_IMAGE_H_ */

Legend:
Removed from v.1340  
changed lines
  Added in v.1341

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