Esempio n. 1
0
tgt::ivec2 Flow2D::slicePosToFlowPos(const tgt::ivec2& vp, const tgt::ivec2& sliceSize,
                                        tgt::ivec2* const error) const
{
    tgt::vec2 p(static_cast<float>(vp.x % sliceSize.x) / sliceSize.x,
        static_cast<float>(vp.y % sliceSize.y) / sliceSize.y);

    tgt::ivec2 r = getNearestCellPos(p * static_cast<tgt::vec2>(dimensions_));
    if (error != 0)
        *error = (vp - flowPosToSlicePos(r, sliceSize));
    return r;
}
Esempio n. 2
0
tgt::ivec3 Flow3D::slicePosToFlowPos(const tgt::ivec2& vp, const tgt::ivec2& sliceSize,
                                        const tgt::ivec3& components, const size_t sliceNo,
                                        tgt::ivec2* const error) const
{
    tgt::vec2 c(static_cast<float>(vp.x % sliceSize.x),
        static_cast<float>(vp.y % sliceSize.y));

    const int& i = components.x;
    const int& j = components.y;
    const int& k = components.z;

    tgt::vec3 p(0, 0, 0);
    p[i] = (c.x / sliceSize.x);
    p[j] = (c.y / sliceSize.y);
    p[k] = float(sliceNo) / dimensions_[k];
    tgt::ivec3 r = getNearestVoxelPos(p * static_cast<tgt::vec3>(dimensions_));

    if (error != 0)
        *error = (vp - flowPosToSlicePos(r, sliceSize, components));

    return r;
}