//-*****************************************************************************
void veryVerySimpleTest()
{
    Alembic::AbcCoreHDF5::WriteArchive w;
    ArchiveWriterPtr archive = w( "misterBigStuffSimp.abc", MetaData() );

    ObjectWriterPtr top = archive->getTop();

    ObjectWriterPtr objectLayer1 =
        top->createChild( ObjectHeader( "layer1", MetaData() ) );

    CompoundPropertyWriterPtr layer1Props = objectLayer1->getProperties();

    {
        ScalarPropertyWriterPtr spuds =
            layer1Props->createScalarProperty("spuds", MetaData(),
                DataType( kFloat32POD, 5 ), 0);

        float blah[] = { 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f };

        spuds->setSample( ( const void * )blah );
        float blah2[] = { 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f };
        spuds->setSample( ( const void * )blah2 );
    }


    std::cout << "B" << std::endl;

    {
        ScalarPropertyWriterPtr pancake =
            layer1Props->createScalarProperty( "pancake", MetaData(),
                                DataType( kUint8POD, 1 ), 0 );

        std::cout << "C" << std::endl;
    }

}
Esempio n. 2
0
//-*****************************************************************************
void veryVerySimpleTest()
{
    Alembic::AbcCoreHDF5::WriteArchive w;
    ArchiveWriterPtr archive = w( "misterBigStuffSimp.abc", MetaData() );

    ObjectWriterPtr top = archive->getTop();
    
    ObjectWriterPtr objectLayer1 =
        top->createChild( ObjectHeader( "layer1", MetaData() ) );
    
    CompoundPropertyWriterPtr layer1Props = objectLayer1->getProperties();

#if 0
    {
        ArrayPropertyWriterPtr spuds =
            layer1Props->createArrayProperty(
                PropertyHeader( "spuds", kArrayProperty, MetaData(),
                                DataType( kFloat32POD, 5 ),
                                TimeSamplingType() ) );
        
        std::cout << "A" << std::endl;
        
        float blah[] = { 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f };
        std::cout << "SPUDS: " << spuds << std::endl;

        ArraySample asamp( ( const void * )blah,
                           DataType( kFloat32POD, 5 ),
                           Dimensions( 1 ) );
        
        spuds->setSample( 0, 0.0, asamp );

        std::cout << "SPUDS: " << spuds << std::endl;
    }
#else
    {
        ScalarPropertyWriterPtr spuds =
            layer1Props->createScalarProperty(
                PropertyHeader( "spuds", kScalarProperty, MetaData(),
                                DataType( kFloat32POD, 5 ),
                                TimeSamplingType() ) );
        
        float blah[] = { 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f };

        spuds->setSample( 0, 0.0, ( const void * )blah );
        float blah2[] = { 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f };
        spuds->setSample( 1, 1.0, ( const void * )blah2 );
    }
#endif

    std::cout << "B" << std::endl;

    {
        ScalarPropertyWriterPtr pancake =
            layer1Props->createScalarProperty(
                PropertyHeader( "pancake", kScalarProperty, MetaData(),
                                DataType( kUint8POD, 1 ),
                                TimeSamplingType() ) );
        
        std::cout << "C" << std::endl;
    }

    //uint8_t pancakeVal = true;
    //pancake->setSample( 0, 0.0, ( const void * )&pancakeVal );

}
//-*****************************************************************************
void testProps()
{
    Alembic::Util::int32_t intVal = 15;

    float32_t f0 = 67.3f;

    size_t floatArraySize = 14;

    chrono_t t0 = 0.25;

    chrono_t dt = 1.0 / 24.0;

    DataType floatDT( kFloat32POD, 1 );

    Dimensions dims( floatArraySize );

    std::string archiveName = "constantPropsTest.abc";

    std::vector<float32_t> fvals;

    for ( size_t i = 0 ; i < floatArraySize ; i++ )
    {
        fvals.push_back( f0 + i );
    }


    {
        AO::WriteArchive w;
        ArchiveWriterPtr a = w(archiveName, AbcA::MetaData());
        std::vector < chrono_t > samps(1, t0);
        AbcA::TimeSampling ts(TimeSamplingType(dt), samps);
        a->addTimeSampling(ts);

        ObjectWriterPtr top = a->getTop();
        ObjectWriterPtr child = top->createChild(
            ObjectHeader( "wow", MetaData() ) );

        CompoundPropertyWriterPtr props = child->getProperties();

        ScalarPropertyWriterPtr intProp = props->createScalarProperty("intProp",
            MetaData(), DataType( kInt32POD, 1 ), 1);

        ArrayPropertyWriterPtr floatArrayProp = props->createArrayProperty(
            "floatArrayProp", MetaData(), DataType( kFloat32POD, 1 ), 1);

        intProp->setSample( &intVal );

        for ( size_t i = 0 ; i < 500 ; i++ )
        {
            floatArrayProp->setSample(ArraySample( &(fvals.front()), floatDT,
                dims ) );
        }

    }

    {
        AO::ReadArchive r;
        ArchiveReaderPtr a = r( archiveName );
        ObjectReaderPtr top = a->getTop();
        TESTING_ASSERT( top->getNumChildren() == 1 );

        AbcA::ObjectReaderPtr child = top->getChild(0);
        TESTING_ASSERT( child->getName() == "wow" );

        CompoundPropertyReaderPtr props = child->getProperties();

        TESTING_ASSERT( props->getNumProperties() == 2 );

        ScalarPropertyReaderPtr intProp = props->getScalarProperty( "intProp" );
        TESTING_ASSERT( intProp->isConstant() );
        TESTING_ASSERT( intProp->getNumSamples() == 1 );

        ArrayPropertyReaderPtr floatArrayProp = \
            props->getArrayProperty( "floatArrayProp" );

        TESTING_ASSERT( floatArrayProp->getNumSamples() == 500 );
        TESTING_ASSERT( floatArrayProp->isConstant() );

    }
}