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 726 - (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 : jhr 726 # include "types.h"
16 : jhr 710 #endif
17 : jhr 726 #ifndef _DIDEROT_INLINE_VEC2_H_
18 :     # include "inline-vec2.h"
19 :     #endif
20 :     #ifndef _DIDEROT_INLINE_VEC3_H_
21 :     # include "inline-vec3.h"
22 :     #endif
23 :     #ifndef _DIDEROT_INLINE_VEC4_H_
24 :     # include "inline-vec4.h"
25 :     #endif
26 : jhr 710
27 : jhr 726 /***** 2D Image functions *****/
28 :    
29 : jhr 710 // check if pos is inside the img, assuming that we have a border of width s.
30 :     //
31 : glk 724 STATIC_INLINE bool Diderot_Inside2f (vec2f_t posArg, Diderot_image2D_t *img, int s)
32 : jhr 710 {
33 :     // NOTE: there might be a vectorized way to do this compare!
34 :     // cvtps2pi -- converts vector of floats to vector of int32_t values
35 :    
36 :     union2f_t pos;
37 :     pos.v = posArg;
38 :     return ((s-1 < pos.r[0]) && (pos.r[0] < (img->size[0] - s))
39 :     && (s-1 < pos.r[1]) && (pos.r[1] < (img->size[1] - s)));
40 :     }
41 :    
42 : glk 724 STATIC_INLINE vec2f_t Diderot_ToImageSpace2f (Diderot_image2D_t *img, vec2f_t posArg)
43 :     {
44 :     vec3f_t p = __extension__ vec3f(
45 :     ((union2f_t)posArg).r[0],
46 :     ((union2f_t)posArg).r[1],
47 :     1.0f);
48 :    
49 :     return vec2f(
50 :     dot3f(img->mInv[0].v, p),
51 :     dot3f(img->mInv[1].v, p));
52 :     }
53 :    
54 : jhr 726 /***** 3D Image functions *****/
55 :    
56 : jhr 710 // check if pos is inside the img, assuming that we have a border of width s.
57 :     //
58 :     STATIC_INLINE bool Diderot_Inside3f (vec3f_t posArg, Diderot_image3D_t *img, int s)
59 :     {
60 :     // NOTE: there might be a vectorized way to do this compare!
61 :     // cvtps2pi -- converts vector of floats to vector of int32_t values
62 :    
63 :     union3f_t pos;
64 :     pos.v = posArg;
65 :     return ((s-1 < pos.r[0]) && (pos.r[0] < (img->size[0] - s))
66 :     && (s-1 < pos.r[1]) && (pos.r[1] < (img->size[1] - s))
67 :     && (s-1 < pos.r[2]) && (pos.r[2] < (img->size[2] - s)));
68 :     }
69 :    
70 :     STATIC_INLINE vec3f_t Diderot_ToImageSpace3f (Diderot_image3D_t *img, vec3f_t posArg)
71 :     {
72 :     vec4f_t p = __extension__ vec4f(
73 :     ((union3f_t)posArg).r[0],
74 :     ((union3f_t)posArg).r[1],
75 :     ((union3f_t)posArg).r[2],
76 :     1.0f);
77 :    
78 :     return vec3f(
79 :     dot4f(img->mInv[0].v, p),
80 :     dot4f(img->mInv[1].v, p),
81 :     dot4f(img->mInv[2].v, p));
82 :     }
83 :    
84 :     #endif /* !_DIDEROT_INLINE_IMAGE_H_ */

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