示例#1
0
/*===========================================================================*/
bool WriteColorData(
    kvs::XMLNode::SuperClass* parent,
    const kvs::kvsml::WritingDataType writing_type,
    const std::string& filename,
    const kvs::ValueArray<kvs::UInt8>& colors )
{
    // <Color>
    if ( colors.size() > 0 )
    {
        kvs::kvsml::ColorTag color_tag;
        if ( !color_tag.write( parent ) )
        {
            kvsMessageError( "Cannot write <%s>.", color_tag.name().c_str() );
            return false;
        }

        // <DataValue>
        if ( colors.size() == 3 )
        {
            kvs::kvsml::DataValueTag data_tag;
            if ( !data_tag.write( color_tag.node(), colors ) )
            {
                kvsMessageError( "Cannot write <%s> for <%s>.",
                                 data_tag.name().c_str(),
                                 color_tag.name().c_str() );
                return false;
            }
        }
        // <DataArray>
        else
        {
            kvs::kvsml::DataArrayTag data_tag;
            if ( writing_type == kvs::kvsml::ExternalAscii )
            {
                data_tag.setFile( kvs::kvsml::DataArray::GetDataFilename( filename, "color" ) );
                data_tag.setFormat( "ascii" );
            }
            else if ( writing_type == kvs::kvsml::ExternalBinary )
            {
                data_tag.setFile( kvs::kvsml::DataArray::GetDataFilename( filename, "color" ) );
                data_tag.setFormat( "binary" );
            }

            const std::string pathname = kvs::File( filename ).pathName();
            if ( !data_tag.write( color_tag.node(), colors, pathname ) )
            {
                kvsMessageError( "Cannot write <%s> for <%s>.",
                                 data_tag.name().c_str(),
                                 color_tag.name().c_str() );
                return false;
            }
        }
    }

    return true;
}
示例#2
0
/*===========================================================================*/
bool WriteSizeData(
    kvs::XMLNode::SuperClass* parent,
    const kvs::kvsml::WritingDataType writing_type,
    const std::string& filename,
    const kvs::ValueArray<kvs::Real32>& sizes )
{
    // <Size>
    if ( sizes.size() > 0 )
    {
        kvs::kvsml::SizeTag size_tag;
        if ( !size_tag.write( parent ) )
        {
            kvsMessageError( "Cannot write <%s>.", size_tag.name().c_str() );
            return false;
        }

        // <DataValue>
        if ( sizes.size() == 1 )
        {
            kvs::kvsml::DataValueTag data_tag;
            if ( !data_tag.write( size_tag.node(), sizes ) )
            {
                kvsMessageError( "Cannot write <%s> for <%s>.",
                                 data_tag.name().c_str(),
                                 size_tag.name().c_str() );
                return false;
            }
        }
        // <DataArray>
        else
        {
            kvs::kvsml::DataArrayTag data_tag;
            if ( writing_type == kvs::kvsml::ExternalAscii )
            {
                data_tag.setFile( kvs::kvsml::DataArray::GetDataFilename( filename, "size" ) );
                data_tag.setFormat( "ascii" );
            }
            else if ( writing_type == kvs::kvsml::ExternalBinary )
            {
                data_tag.setFile( kvs::kvsml::DataArray::GetDataFilename( filename, "size" ) );
                data_tag.setFormat( "binary" );
            }

            const std::string pathname = kvs::File( filename ).pathName();
            if ( !data_tag.write( size_tag.node(), sizes, pathname ) )
            {
                kvsMessageError( "Cannot write <%s> for <%s>.",
                                 data_tag.name().c_str(),
                                 size_tag.name().c_str() );
                return false;
            }
        }
    }

    return true;
}
/*===========================================================================*/
void StochasticUniformGridRenderer::Engine::create_transfer_function_texture()
{
    const size_t width = m_transfer_function.resolution();
    const kvs::ValueArray<kvs::Real32> table = m_transfer_function.table();
    m_transfer_function_texture.setWrapS( GL_CLAMP_TO_EDGE );
    m_transfer_function_texture.setMagFilter( GL_LINEAR );
    m_transfer_function_texture.setMinFilter( GL_LINEAR );
    m_transfer_function_texture.setPixelFormat( GL_RGBA32F_ARB, GL_RGBA, GL_FLOAT  );
    m_transfer_function_texture.create( width, table.data() );
    m_transfer_function_changed = false;
}
示例#4
0
/*==========================================================================*/
bool ImageBase::create(
    const size_t width,
    const size_t height,
    const ImageType type,
    const kvs::ValueArray<kvs::UInt8>& pixels )
{
    m_width = width;
    m_height = height;
    m_npixels = width * height;

    if ( type == Bit )
    {
        m_padding = ::ByteToBit( ::BitToByte( width + 7 ) ) - width;
        m_bpp = 1;
        m_bpl = ::BitToByte( width + 7 );
    }
    else
    {
        const size_t ncomponents = static_cast<size_t>( type );
        m_padding = 0;
        m_bpp = ::ByteToBit( sizeof( kvs::UInt8 ) ) * ncomponents;
        m_bpl = width * ::BitToByte( m_bpp );
    }

    m_size = height * m_bpl;
    if ( m_size != pixels.size() ) return( false );

    m_pixels = pixels;

    return( true );
}
示例#5
0
文件: Ply.cpp 项目: digirea/KVS
void Ply::setConnections( const kvs::ValueArray<kvs::UInt32>& connections )
{
    m_nfaces = connections.size() / 3;
    m_has_connections = true;
    m_connections = connections;
}
示例#6
0
文件: Ply.cpp 项目: digirea/KVS
void Ply::setCoords( const kvs::ValueArray<kvs::Real32>& coords )
{
    m_nverts = coords.size() / 3;
    m_coords = coords;
}