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/inline-image.h
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 710 - (download) (as text) (annotate)
Wed Mar 30 16:56:13 2011 UTC (10 years, 4 months ago) by jhr
File size: 1844 byte(s)
  Split up diderot header file into multiple files.
/*! \file inline-image.h
 *
 * \author John Reppy
 */

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

#ifndef _DIDEROT_INLINE_IMAGE_H_
#define _DIDEROT_INLINE_IMAGE_H_

#ifndef _DIDEROT_TYPES_H_
#include "types.h"
#endif

// check if pos is inside the img, assuming that we have a border of width s.
//
STATIC_INLINE bool Diderot_Inside2f (vec2f_t posArg, Diderot_image3D_t *img, int s)
{
// NOTE: there might be a vectorized way to do this compare!
// cvtps2pi -- converts vector of floats to vector of int32_t values

    union2f_t pos;
    pos.v = posArg;
    return ((s-1 < pos.r[0]) && (pos.r[0] < (img->size[0] - s))
        &&  (s-1 < pos.r[1]) && (pos.r[1] < (img->size[1] - s)));
}

// check if pos is inside the img, assuming that we have a border of width s.
//
STATIC_INLINE bool Diderot_Inside3f (vec3f_t posArg, Diderot_image3D_t *img, int s)
{
// NOTE: there might be a vectorized way to do this compare!
// cvtps2pi -- converts vector of floats to vector of int32_t values

    union3f_t pos;
    pos.v = posArg;
    return ((s-1 < pos.r[0]) && (pos.r[0] < (img->size[0] - s))
        &&  (s-1 < pos.r[1]) && (pos.r[1] < (img->size[1] - s))
        &&  (s-1 < pos.r[2]) && (pos.r[2] < (img->size[2] - s)));
}

STATIC_INLINE vec3f_t Diderot_ToImageSpace3f (Diderot_image3D_t *img, vec3f_t posArg)
{
    vec4f_t p = __extension__ vec4f(
	((union3f_t)posArg).r[0],
	((union3f_t)posArg).r[1],
	((union3f_t)posArg).r[2],
	1.0f);

//    return vec3f(
//	dot4f(vec4f(m->m[0], m->m[1], m->m[2], m->m[3]), p),
//	dot4f(vec4f(m->m[4], m->m[5], m->m[6], m->m[7]), p),
//	dot4f(vec4f(m->m[8], m->m[9], m->m[10], m->m[11]), p));
    return vec3f(
	dot4f(img->mInv[0].v, p),
	dot4f(img->mInv[1].v, p),
	dot4f(img->mInv[2].v, p));
}


#endif /* !_DIDEROT_INLINE_IMAGE_H_ */

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