예제 #1
0
void Example1_CurvesIn()
{
    IArchive archive( Alembic::AbcCoreHDF5::ReadArchive(), "curves1.abc" );
    std::cout << "Reading: " << archive.getName() << std::endl;

    std::cout <<"constructing curves" << std::endl;
    ICurves myCurves( IObject( archive, kTop) , "reallly_long_curves_name");
    std::cout << "getting schema" << std::endl;
    ICurvesSchema &curves = myCurves.getSchema();
    std::cout << "done getting schema" << std::endl;

    // get the samples from the curves
    ICurvesSchema::Sample curvesSample;
    curves.get( curvesSample );

    // test the bounding box
    TESTING_ASSERT( curvesSample.getSelfBounds().min == V3d( -1.0, -1.0, -1.0 ) );
    std::cout << "bounds max " << curvesSample.getSelfBounds().max << std::endl;
    TESTING_ASSERT( curvesSample.getSelfBounds().max == V3d( 1.0, 1.0, 1.0 ) );

    // test other attributes
    TESTING_ASSERT( curvesSample.getPositions() -> size() == 12);

    IFloatGeomParam::Sample widthSample;
    curves.getWidthsParam().getExpanded( widthSample );
    TESTING_ASSERT( widthSample.getVals()->size() == 12);
    TESTING_ASSERT( curves.getWidthsParam().valid() );
    TESTING_ASSERT( widthSample.getScope() == kVertexScope );


}
예제 #2
0
void Example2_CurvesIn()
{
    IArchive archive( Alembic::AbcCoreOgawa::ReadArchive(), "curves2.abc" );

    ICurves myCurves( IObject( archive, kTop) , "nurbsCurve");
    ICurvesSchema &curves = myCurves.getSchema();

    // get the samples from the curves
    ICurvesSchema::Sample curvesSample;
    curves.get( curvesSample );

    // test the bounding box
    TESTING_ASSERT( curvesSample.getSelfBounds().min == V3d( -1.0, -1.0, -1.0 ) );
    TESTING_ASSERT( curvesSample.getSelfBounds().max == V3d( 1.0, 1.0, 1.0 ) );

    // test other attributes
    TESTING_ASSERT( curvesSample.getPositions() -> size() == 12);

    TESTING_ASSERT( curvesSample.getType() == kVariableOrder );
    TESTING_ASSERT( curvesSample.getWrap() == kNonPeriodic );
    TESTING_ASSERT( curvesSample.getBasis() == kBezierBasis );
    TESTING_ASSERT( ( *curvesSample.getOrders() )[0] == 4 );
    TESTING_ASSERT( ( *curvesSample.getOrders() )[1] == 2 );
    TESTING_ASSERT( curvesSample.getPositionWeights()->size() == 12 );
    TESTING_ASSERT( curvesSample.getKnots()->size() == 18 );

    IFloatGeomParam::Sample widthSample;
    curves.getWidthsParam().getExpanded( widthSample );
    TESTING_ASSERT( widthSample.getVals()->size() == 12);
    TESTING_ASSERT( curves.getWidthsParam().valid() );
    TESTING_ASSERT( widthSample.getScope() == kVertexScope );

    IFloatArrayProperty knotsProp = curves.getKnotsProperty();
    TESTING_ASSERT( knotsProp.getNumSamples() == 2 );
    ArraySampleKey keyA, keyB;
    knotsProp.getKey( keyA, 0 );
    knotsProp.getKey( keyB, 1 );
    TESTING_ASSERT( keyA == keyB );
}
예제 #3
0
void pointTestReadWrite()
{
    {
        OArchive archive( Alembic::AbcCoreOgawa::WriteArchive(),
            "particlesOut2.abc" );
        OObject topObj( archive, kTop );
        OPoints ptsObj(topObj, "somePoints");

        std::vector< V3f > positions;
        std::vector< V3f > velocities;
        std::vector< Alembic::Util::uint64_t > ids;
        std::vector< Alembic::Util::float32_t > widths;
        for (int i = 0; i < 100; ++i)
        {
            OFloatGeomParam::Sample widthSamp;
            widthSamp.setScope(kVertexScope);
            widthSamp.setVals(FloatArraySample(widths));

            OPointsSchema::Sample psamp(V3fArraySample( positions ),
                UInt64ArraySample( ids ), V3fArraySample( velocities ),
                widthSamp );

            ptsObj.getSchema().set(psamp);

            positions.push_back(V3f(i, i, i));
            velocities.push_back(V3f(100.0-i, 0, 0));
            ids.push_back(i*10);
            widths.push_back(0.1 + i * 0.05);
        }
    }

    {
        IArchive archive( Alembic::AbcCoreOgawa::ReadArchive(),
                          "particlesOut2.abc" );

        IObject topObj = archive.getTop();
        IPoints points( topObj, "somePoints" );
        IPointsSchema& pointsSchema = points.getSchema();
        IFloatGeomParam widthProp = pointsSchema.getWidthsParam();
        TESTING_ASSERT( widthProp.getScope() == kVertexScope );
        for ( size_t i = 0; i < 100; ++i )
        {
            IPointsSchema::Sample pointSamp;
            pointsSchema.get(pointSamp, i);

            IFloatGeomParam::Sample widthSamp;
            widthProp.getExpanded(widthSamp, i);
            TESTING_ASSERT( pointSamp.getPositions()->size() == i );
            TESTING_ASSERT( pointSamp.getVelocities()->size() == i );
            TESTING_ASSERT( pointSamp.getIds()->size() == i );
            TESTING_ASSERT( widthSamp.getVals()->size() == i );
            for ( size_t j = 0; j < i; ++j )
            {
                TESTING_ASSERT( (*pointSamp.getPositions())[j] ==
                                V3f(j, j, j) );

                TESTING_ASSERT( (*pointSamp.getVelocities())[j] ==
                                V3f(100-j, 0, 0) );

                TESTING_ASSERT( (*pointSamp.getIds())[j] == j * 10 );

                TESTING_ASSERT( almostEqual( (*widthSamp.getVals())[j],
                                0.1 + j * 0.05, 7 ) );
            }
        }
    }
}