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

SCM Repository

[diderot] View of /branches/vis12-cl/src/include/Diderot/cl-inline-image.h
ViewVC logotype

View of /branches/vis12-cl/src/include/Diderot/cl-inline-image.h

Parent Directory Parent Directory | Revision Log Revision Log

Revision 3118 - (download) (as text) (annotate)
Mon Mar 23 18:05:45 2015 UTC (3 years, 11 months ago) by jhr
File size: 4842 byte(s)
  working on OpenCL issues
/*! \file cl-inline-image.h
 * \author Lamont Samuels

 * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.

#  include "cl-types.h"
#  include "cl-inline-matrix.h"

/***** 1D Image functions *****/

// check if pos is inside the img, assuming that we have a border of width s.
inline bool Inside1 (Diderot_real_t pos, __global Diderot_image1D_t *img, int s)
    return ((s-1 < pos) && (pos < (img->size[0] - s)));

inline Diderot_real_t ToImageSpace1 ( __global Diderot_image1D_t *img, Diderot_real_t pos)
    return img->s * pos + img->t;

/***** 2D Image functions *****/

// check if pos is inside the img, assuming that we have a border of width s.
inline bool Inside2 (Diderot_vec2_t posArg, __global Diderot_image2D_t *img, int s)
    return ((s-1 < posArg.s0) && (posArg.s0 < (img->size[0] - s))
        &&  (s-1 < posArg.s1) && (posArg.s1 < (img->size[1] - s)));

inline Diderot_vec2_t ToImageSpace2 (__global Diderot_image2D_t *img, Diderot_vec2_t p)
    return (Diderot_vec2_t)(dot(img->w2i[0], p), dot(img->w2i[1], p)) + img->tVec;

inline Diderot_vec2_t ToWorldSpace2 (__global Diderot_image2D_t *img, Diderot_vec2_t g)
    return (Diderot_vec2_t)(
        dot(img->w2iT[0], g),
        dot(img->w2iT[1], g));

inline void ToWorldSpace2x2 ( Diderot_Mat2x2_t dst, __global Diderot_image2D_t *img,  Diderot_Mat2x2_t src)
    /* Diderot_Mat2x2_t tmp;
    mulMat2x2Mat2x2f (tmp, img->w2iT, src);
    mulMat2x2Mat2x2f (dst, tmp, img->w2i); */ 
    Diderot_Mat2x2_t tmp;
    tmp[0] = (Diderot_vec2_t)(
        dot(img->w2iT[0], (Diderot_vec2_t)(src[0].s0, src[1].s0)),
        dot(img->w2iT[0], (Diderot_vec2_t)(src[0].s1, src[1].s1)));
    tmp[1] = (Diderot_vec2_t)(
        dot(img->w2iT[1], (Diderot_vec2_t)(src[0].s0, src[1].s0)),
        dot(img->w2iT[1], (Diderot_vec2_t)(src[0].s1, src[1].s1)));
    dst[0] = (Diderot_vec2_t)(
        dot(tmp[0], (Diderot_vec2_t)(img->w2i[0].s0, img->w2i[1].s0)),
        dot(tmp[0], (Diderot_vec2_t)(img->w2i[0].s1, img->w2i[1].s1)));
    dst[1] = (Diderot_vec2_t)(
        dot(tmp[1], (Diderot_vec2_t)(img->w2i[0].s0, img->w2i[1].s0)),
        dot(tmp[1], (Diderot_vec2_t)(img->w2i[0].s1, img->w2i[1].s1)));


/***** 3D Image functions *****/

// check if pos is inside the img, assuming that we have a border of width s.
inline bool Inside3f (Diderot_vec3_t posArg, __global Diderot_image3D_t *img, int s)
    return ((s-1 < posArg.s0) && (posArg.s0 < (img->size[0] - s))
        &&  (s-1 < posArg.s1) && (posArg.s1 < (img->size[1] - s))
        &&  (s-1 < posArg.s2) && (posArg.s2 < (img->size[2] - s)));

inline Diderot_vec3_t ToImageSpace3f (__global Diderot_image3D_t *img, Diderot_vec3_t p)
    return VEC3(dot(img->w2i[0], p), dot(img->w2i[1], p), dot(img->w2i[2], p)) + img->tVec;

inline Diderot_vec3_t ToWorldSpace3f (__global Diderot_image3D_t *img, Diderot_vec3_t g)
    return VEC3(
        dot(img->w2iT[0], g),
        dot(img->w2iT[1], g),
        dot(img->w2iT[2], g));

inline void ToWorldSpace3x3f ( Diderot_Mat3x3_t dst, __global Diderot_image3D_t *img,  Diderot_Mat3x3_t src)
    Diderot_Mat3x3_t tmp;
    tmp[0] = VEC3(
          dot(img->w2iT[0], VEC3(src[0].s0, src[1].s0, src[2].s0)),
          dot(img->w2iT[0], VEC3(src[0].s1, src[1].s1, src[2].s1)),
          dot(img->w2iT[0], VEC3(src[0].s2, src[1].s2, src[2].s2)));
    tmp[1] = VEC3(
          dot(img->w2iT[1], VEC3(src[0].s0, src[1].s0, src[2].s0)),
          dot(img->w2iT[1], VEC3(src[0].s1, src[1].s1, src[2].s1)),
          dot(img->w2iT[1], VEC3(src[0].s2, src[1].s2, src[2].s2)));
    tmp[2] = VEC3(
          dot(img->w2iT[2], VEC3(src[0].s0, src[1].s0, src[2].s0)),
          dot(img->w2iT[2], VEC3(src[0].s1, src[1].s1, src[2].s1)),
          dot(img->w2iT[2], VEC3(src[0].s2, src[1].s2, src[2].s2)));
    dst[0] = VEC3(
          dot(tmp[0], VEC3(img->w2i[0].s0, img->w2i[1].s0, img->w2i[2].s0)),
          dot(tmp[0], VEC3(img->w2i[0].s1, img->w2i[1].s1, img->w2i[2].s1)),
          dot(tmp[0], VEC3(img->w2i[0].s2, img->w2i[1].s2, img->w2i[2].s2)));
    dst[1] = VEC3(
          dot(tmp[1], VEC3(img->w2i[0].s0, img->w2i[1].s0, img->w2i[2].s0)),
          dot(tmp[1], VEC3(img->w2i[0].s1, img->w2i[1].s1, img->w2i[2].s1)),
          dot(tmp[1], VEC3(img->w2i[0].s2, img->w2i[1].s2, img->w2i[2].s2)));
    dst[2] = VEC3(
          dot(tmp[2], VEC3(img->w2i[0].s0, img->w2i[1].s0, img->w2i[2].s0)),
          dot(tmp[2], VEC3(img->w2i[0].s1, img->w2i[1].s1, img->w2i[2].s1)),
          dot(tmp[2], VEC3(img->w2i[0].s2, img->w2i[1].s2, img->w2i[2].s2)));



ViewVC Help
Powered by ViewVC 1.0.0