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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1290 - (download) (as text) (annotate)
Tue Jun 7 16:22:05 2011 UTC (10 years, 3 months ago) by jhr
File size: 2629 byte(s)
Editing CL header files
/*! \file cl-inline-image.h
 *
 * \author Lamont Samuels
 */

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

#ifndef _DIDEROT_CL_INLINE_IMAGE_H_
#define _DIDEROT_CL_INLINE_IMAGE_H_
 
#ifndef _DIDEROT_CL_TYPES_H_
#  include "cl-types.h"
#endif
#ifndef _DIDEROT_CL_INLINE_MATRIX_H_
#  include "cl-inline-matrix.h"
#endif


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

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

STATIC_INLINE float ToImageSpace1f (Diderot_image1D_t *img, float 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.
//
STATIC_INLINE bool Inside2f (float2 posArg, 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)));
}

STATIC_INLINE float2 ToImageSpace2f (Diderot_image2D_t *img, float2 p)
{
    return (float2)(dot(img->w2i[0], p), dot(img->w2i[1], p)) + img->tVec;
}

STATIC_INLINE float2 ToWorldSpace2f (Diderot_image2D_t *img, float2 g)
{
    return (float2)(
        dot(img->w2iT[0], g),
        dot(img->w2iT[1], g));
}

STATIC_INLINE void ToWorldSpace2x2f (Diderot_Mat2x2_t dst, Diderot_image2D_t *img, Diderot_Mat2x2_t src)
{
    Diderot_Mat2x2_t tmp;
    mulMat2x2Mat2x2f (tmp, img->w2iT, src);
    mulMat2x2Mat2x2f (dst, tmp, img->w2i);
}

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

// check if pos is inside the img, assuming that we have a border of width s.
//
STATIC_INLINE bool Inside3f (float3 posArg, 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)));
}

STATIC_INLINE float3 ToImageSpace3f (Diderot_image3D_t *img, float3 p)
{
    return (float3)(dot(img->w2i[0], p), dot(img->w2i[1], p), dot(img->w2i[2], p)) + img->tVec;
}

STATIC_INLINE float3 ToWorldSpace3f (Diderot_image3D_t *img, float3 g)
{
    return (float3)(
        dot(img->w2iT[0], g),
        dot(img->w2iT[1], g),
        dot(img->w2iT[2], g));
}

STATIC_INLINE void ToWorldSpace3x3f (Diderot_Mat3x3_t dst, Diderot_image3D_t *img, Diderot_Mat3x3_t src)
{
    Diderot_Mat3x3_t tmp;
    mulMat3x3Mat3x3f (tmp, img->w2iT, src);
    mulMat3x3Mat3x3f (dst, tmp, img->w2i);
}

#endif /* !_DIDEROT_CL_INLINE_IMAGE_H_ */
 

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