当前位置: 首页>>代码示例>>C++>>正文


C++ tgt::col4方法代码示例

本文整理汇总了C++中tgt::col4方法的典型用法代码示例。如果您正苦于以下问题:C++ tgt::col4方法的具体用法?C++ tgt::col4怎么用?C++ tgt::col4使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tgt的用法示例。


在下文中一共展示了tgt::col4方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createTex

void TransFunc1DKeys::updateTexture() {

    if (!tex_ || (tex_->getDimensions() != dimensions_))
        createTex();
    tgtAssert(tex_, "No texture");

    //get tresholds of the transfer function
    int front_end = tgt::iround(lowerThreshold_*dimensions_.x);
    int back_start = tgt::iround(upperThreshold_*dimensions_.x);
    //all values before front_end and after back_start are set to zero
    //all other values are taken from the TF
    for (int x = 0; x < front_end; ++x)
        tex_->texel<col4>(x) = col4(0, 0, 0, 0);

    for (int x = front_end; x < back_start; ++x)
        tex_->texel<col4>(x) = col4(getMappingForValue(static_cast<float>(x) / dimensions_.x));

    for (int x = back_start; x < dimensions_.x; ++x)
        tex_->texel<col4>(x) = col4(0, 0, 0, 0);

    tex_->uploadTexture();
    LGL_ERROR;

    textureInvalid_ = false;
}
开发者ID:emmaai,项目名称:fractalM,代码行数:25,代码来源:transfunc1dkeys.cpp

示例2: clearKeys

void TransFunc1DKeys::setToStandardFunc() {
    clearKeys();
    keys_.push_back(new TransFuncMappingKey(0.f, col4(0, 0, 0, 0)));
    keys_.push_back(new TransFuncMappingKey(1.f, col4(255)));

    textureInvalid_ = true;
    preIntegrationTableMap_.clear();
}
开发者ID:emmaai,项目名称:fractalM,代码行数:8,代码来源:transfunc1dkeys.cpp

示例3: if

col4 TransFunc1DKeys::getMappingForValue(float value) const {
    // If there are no keys, any further calculation is meaningless
    if (keys_.empty())
        return col4(0, 0, 0, 0);

    // Restrict value to [0,1]
    value = (value < 0.f) ? 0.f : value;
    value = (value > 1.f) ? 1.f : value;

    // iterate through all keys until we get to the correct position
    std::vector<TransFuncMappingKey*>::const_iterator keyIterator = keys_.begin();

    while ((keyIterator != keys_.end()) && (value > (*keyIterator)->getIntensity()))
        keyIterator++;

    if (keyIterator == keys_.begin())
        return keys_[0]->getColorL();
    else if (keyIterator == keys_.end())
        return (*(keyIterator-1))->getColorR();
    else{
        // calculate the value weighted by the destination to the next left and right key
        TransFuncMappingKey* leftKey = *(keyIterator-1);
        TransFuncMappingKey* rightKey = *keyIterator;
        float fraction = (value - leftKey->getIntensity()) / (rightKey->getIntensity() - leftKey->getIntensity());
        col4 leftDest = leftKey->getColorR();
        col4 rightDest = rightKey->getColorL();
        col4 result = leftDest;
        result.r += static_cast<uint8_t>((rightDest.r - leftDest.r) * fraction);
        result.g += static_cast<uint8_t>((rightDest.g - leftDest.g) * fraction);
        result.b += static_cast<uint8_t>((rightDest.b - leftDest.b) * fraction);
        result.a += static_cast<uint8_t>((rightDest.a - leftDest.a) * fraction);
        return result;
    }
}
开发者ID:molsimmsu,项目名称:3mview,代码行数:34,代码来源:transfunc1dkeys.cpp

示例4: getKey

bool TransFunc1DKeys::isStandardFunc() const {
    if(getDomain() == tgt::vec2(0.0f, 1.0f) && (getNumKeys() == 2)) {
        const TransFuncMappingKey* k0 = getKey(0);
        if((k0->getIntensity() == 0.0f) && !(k0->isSplit()) && (k0->getColorL() == col4(0, 0, 0, 0))) {
            const TransFuncMappingKey* k1 = getKey(1);
            if((k1->getIntensity() == 1.0f) && !(k1->isSplit()) && (k1->getColorL() == col4(255)))
                return true;
        }
    }
    return false;
}
开发者ID:emmaai,项目名称:fractalM,代码行数:11,代码来源:transfunc1dkeys.cpp

示例5: peaks

void TransFunc1DKeys::generateKeys(unsigned char* data) {
    /* A short overview about the idea behind this method. For the sake of simplicity this is
    demonstrated with only one color channel, say 'Red'. It is generalized in the code below:

    We want to detect the peaks(=extrema) in the graph containing all the 'red'-values.
    In order to do this, we look at one 1/width-th at a time and compare the difference between
    the (i-2)th and (i-1)th point (= oldDelta_x) to the difference between the (i-1)th and ith point
    (stored in newDelta_x). Several possible things can happen:
    i) The difference doesn't change at all. This means that the difference between the points is
       linearly dependent and in this case, we don't have to add another key because we get linear
       interpolation from the the methods
    ii) The difference might be not-zero. This means the graph is discontinuous at this point and
        we have to insert a splitted point. On the left side we take the color from the
        (i-1)th point and on the right side from the ith point. The discontinuity is represented
        by the "jump" between the two parts of the splitted mapping key.
    iii) The difference could have changed by a factor of -1. In this case, we have to insert a
         mapping key right at the peak (i.e. at the ith point).

    If a key is placed, we don't want to place a key at the next location, because the difference
    will change not matter if there is a peak or not. There are a lot of cases, in this
    redundant keys will be generated and we don't want that


    In the code below, we generate a key whenever any of the colorchannels meets a criterion above.
    */

    // Storage for the old values
    int oldDeltaRed;
    int oldDeltaGreen;
    int oldDeltaBlue;
    int oldDeltaAlpha;

    // Storage for the new values
    int newDeltaRed;
    int newDeltaGreen;
    int newDeltaBlue;
    int newDeltaAlpha;

    // We want at least 2 values in the data array
    if (dimensions_.x < 2)
        return;

    clearKeys();

    addKey(new TransFuncMappingKey(0.f,
           col4(data[0], data[1], data[2], data[3])));
    addKey(new TransFuncMappingKey(1.f,
           col4(data[4*(dimensions_.x-1)+0], data[4*(dimensions_.x-1)+1], data[4*(dimensions_.x-1)+2], data[4*(dimensions_.x-1)+3])));

    // Calculate the starting point
    newDeltaRed   = data[4*1 + 0] - data[4*0 + 0];
    newDeltaGreen = data[4*1 + 1] - data[4*0 + 1];
    newDeltaBlue  = data[4*1 + 2] - data[4*0 + 2];
    newDeltaAlpha = data[4*1 + 3] - data[4*0 + 3];

    // The main loop. We start at 2 because the value for 1 already has been calculated.
    for (int iter = 2; iter < dimensions_.x; ++iter) {
        // Backup the old values and generate the new ones.
        oldDeltaRed = newDeltaRed;
        oldDeltaGreen = newDeltaGreen;
        oldDeltaBlue = newDeltaBlue;
        oldDeltaAlpha = newDeltaAlpha;

        newDeltaRed   = data[4*iter + 0] - data[4*(iter-1) + 0];
        newDeltaGreen = data[4*iter + 1] - data[4*(iter-1) + 1];
        newDeltaBlue  = data[4*iter + 2] - data[4*(iter-1) + 2];
        newDeltaAlpha = data[4*iter + 3] - data[4*(iter-1) + 3];

        // Has the difference quotient changed in any color channel?
        bool differenceQuotientChanged = (
            (oldDeltaRed   != newDeltaRed)   ||
            (oldDeltaGreen != newDeltaGreen) ||
            (oldDeltaBlue  != newDeltaBlue)  ||
            (oldDeltaAlpha != newDeltaAlpha));

        // Is the difference quotient different from zero in any channel?
        bool differenceQuotientNotZero = (
            (newDeltaRed   != 0) ||
            (newDeltaGreen != 0) ||
            (newDeltaBlue  != 0) ||
            (newDeltaAlpha != 0));

        // Has the difference quotient tilted in all channel's?
        // Mind the & instead of |
        bool differenceQuotientTilted = (
            (oldDeltaRed   == -newDeltaRed)   &&
            (oldDeltaGreen == -newDeltaGreen) &&
            (oldDeltaBlue  == -newDeltaBlue)  &&
            (oldDeltaAlpha == -newDeltaAlpha));

        if (differenceQuotientChanged) {
            if (differenceQuotientNotZero) {
                // We want to put a splitted key here (see ii above)
                TransFuncMappingKey* newkey = new TransFuncMappingKey(iter/static_cast<float>(dimensions_.x-1) ,
                    col4( data[4*(iter-1) + 0], data[4*(iter-1) + 1], data[4*(iter-1) + 2], data[4*(iter-1) + 3] )
                    );
                newkey->setSplit(true);
                newkey->setColorR(tgt::col4(data[4*iter + 0], data[4*iter + 1], data[4*iter + 2], data[4*iter + 3]));
                addKey(newkey);
            }
//.........这里部分代码省略.........
开发者ID:molsimmsu,项目名称:3mview,代码行数:101,代码来源:transfunc1dkeys.cpp


注:本文中的tgt::col4方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。