예제 #1
0
// TODO : a templated initTF function for different kinds of tf ( float, short, etc )
void RayCastRenderer::initTransferFunction( const TransferFunction1D< uint8_t >& transferFunction )
{
    const UInt8Vector& transferFunctionData = transferFunction.getData();

    assert( transferFunction.getNumChannels() == 4u );

    if( transferFunctionTexture_ == 0 )
    {
        GLuint tfTexture = 0;
        glGenTextures( 1, &tfTexture );
        glBindTexture( GL_TEXTURE_1D, tfTexture );

        glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
        glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
        glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );

        glBindTexture( GL_TEXTURE_1D, tfTexture);
        glTexImage1D(  GL_TEXTURE_1D, 0, GL_RGBA, transferFunctionData.size( )/4u, 0,
                       GL_RGBA, GL_UNSIGNED_BYTE, &transferFunctionData[ 0 ] );

        transferFunctionTexture_  = tfTexture;
    }
    else
    {
        glBindTexture( GL_TEXTURE_1D, transferFunctionTexture_ );
        glTexImage1D(  GL_TEXTURE_1D, 0, GL_RGBA, transferFunctionData.size( )/4u, 0,
                       GL_RGBA, GL_UNSIGNED_BYTE, &transferFunctionData[ 0 ] );
    }
}
예제 #2
0
float
scale_bit_width(const Dataset& ds, bool downsample,
                const TransferFunction1D& tf)
{
  size_t max_value = (ds.GetBitWidth() != 8 && downsample)
                      ? 65536 : tf.GetSize();
  uint32_t max_range = static_cast<uint32_t>(1 << ds.GetBitWidth());

  return (ds.GetBitWidth() != 8 && downsample)
          ? 1.0f : static_cast<float>(max_range) /
                   static_cast<float>(max_value);
}
void
TransferFunctionEditor1D::setTransferFunction(TransferFunction1D &aTransferFunction)
{
	mTransferFunction = &aTransferFunction;
	QRectF rect = QRectF(aTransferFunction.range().first, 0.0, aTransferFunction.range().second, 1.0);
	for (size_t i = 0; i < cChannelCount; ++i) {
		mCurves[i].setBoundingRect(rect);
		mCurves[i].clear();

		for (auto it = mTransferFunction->channelBegin(i); it != mTransferFunction->channelEnd(i); ++it) {
			mCurves[i].appendPoint(QPointF(it->first, it->second));
		}
	}



	ui->mTransferFunctionView->setTransferFunction(aTransferFunction);

	mBoundingRect->setRect(rect);
	ui->mTransferFunctionView->setSceneRect(rect);
	ui->mTransferFunctionView->fitInView(rect);
}
예제 #4
0
    void initTransferFunction( const TransferFunction1D& transferFunction )
    {
        assert( transferFunction.getNumChannels() == 4u );

        if( _transferFunctionTexture == 0 )
        {
            GLuint tfTexture = 0;
            glGenTextures( 1, &tfTexture );
            glBindTexture( GL_TEXTURE_1D, tfTexture );

            glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
            glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
            glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
            _transferFunctionTexture  = tfTexture;
        }
        glBindTexture( GL_TEXTURE_1D, _transferFunctionTexture );

        const uint8_t* transferFunctionData = transferFunction.getLut();
        glTexImage1D(  GL_TEXTURE_1D, 0, GL_RGBA,
                       GLsizei( transferFunction.getLutSize() / 4u ), 0,
                       GL_RGBA, GL_UNSIGNED_BYTE, transferFunctionData );
    }
TransferFunction1D::TransferFunction1D(const TransferFunction1D &tf, const CopyOp &copyop) :
    TransferFunction(tf, copyop)
{
    allocate(tf.getNumberImageCells());
    assign(tf._colorMap);
}