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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : jhr 710 /*! \file inline-image.h
2 :     *
3 :     * \author John Reppy
4 :     */
5 :    
6 :     /*
7 :     * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
8 :     * All rights reserved.
9 :     */
10 :    
11 :     #ifndef _DIDEROT_INLINE_IMAGE_H_
12 :     #define _DIDEROT_INLINE_IMAGE_H_
13 :    
14 :     #ifndef _DIDEROT_TYPES_H_
15 :     #include "types.h"
16 :     #endif
17 :    
18 :     // check if pos is inside the img, assuming that we have a border of width s.
19 :     //
20 : glk 724 STATIC_INLINE bool Diderot_Inside2f (vec2f_t posArg, Diderot_image2D_t *img, int s)
21 : jhr 710 {
22 :     // NOTE: there might be a vectorized way to do this compare!
23 :     // cvtps2pi -- converts vector of floats to vector of int32_t values
24 :    
25 :     union2f_t pos;
26 :     pos.v = posArg;
27 :     return ((s-1 < pos.r[0]) && (pos.r[0] < (img->size[0] - s))
28 :     && (s-1 < pos.r[1]) && (pos.r[1] < (img->size[1] - s)));
29 :     }
30 :    
31 : glk 724 STATIC_INLINE vec2f_t Diderot_ToImageSpace2f (Diderot_image2D_t *img, vec2f_t posArg)
32 :     {
33 :     vec3f_t p = __extension__ vec3f(
34 :     ((union2f_t)posArg).r[0],
35 :     ((union2f_t)posArg).r[1],
36 :     1.0f);
37 :    
38 :     return vec2f(
39 :     dot3f(img->mInv[0].v, p),
40 :     dot3f(img->mInv[1].v, p));
41 :     }
42 :    
43 : jhr 710 // check if pos is inside the img, assuming that we have a border of width s.
44 :     //
45 :     STATIC_INLINE bool Diderot_Inside3f (vec3f_t posArg, Diderot_image3D_t *img, int s)
46 :     {
47 :     // NOTE: there might be a vectorized way to do this compare!
48 :     // cvtps2pi -- converts vector of floats to vector of int32_t values
49 :    
50 :     union3f_t pos;
51 :     pos.v = posArg;
52 :     return ((s-1 < pos.r[0]) && (pos.r[0] < (img->size[0] - s))
53 :     && (s-1 < pos.r[1]) && (pos.r[1] < (img->size[1] - s))
54 :     && (s-1 < pos.r[2]) && (pos.r[2] < (img->size[2] - s)));
55 :     }
56 :    
57 :     STATIC_INLINE vec3f_t Diderot_ToImageSpace3f (Diderot_image3D_t *img, vec3f_t posArg)
58 :     {
59 :     vec4f_t p = __extension__ vec4f(
60 :     ((union3f_t)posArg).r[0],
61 :     ((union3f_t)posArg).r[1],
62 :     ((union3f_t)posArg).r[2],
63 :     1.0f);
64 :    
65 :     // return vec3f(
66 :     // dot4f(vec4f(m->m[0], m->m[1], m->m[2], m->m[3]), p),
67 :     // dot4f(vec4f(m->m[4], m->m[5], m->m[6], m->m[7]), p),
68 :     // dot4f(vec4f(m->m[8], m->m[9], m->m[10], m->m[11]), p));
69 :     return vec3f(
70 :     dot4f(img->mInv[0].v, p),
71 :     dot4f(img->mInv[1].v, p),
72 :     dot4f(img->mInv[2].v, p));
73 :     }
74 :    
75 :    
76 :     #endif /* !_DIDEROT_INLINE_IMAGE_H_ */

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