Skip to content

ExamplesCppCompoundObject

Ben Toogood edited this page Jun 13, 2013 · 5 revisions

Overview

This example creates a CompoundObject, assigns some data to it and then saves the object to disk as an attribute cache.

Provided the data contained within a CompoundObject is interpolatable itself, then using an InterpolatedCache object to read the object back in will give the expected, interpolated, CompoundObject.

Code

#include <OpenEXR/ImathVec.h>;#include <IECore/CompoundObject.h>;#include <IECore/VectorTypedData.h>;#include <IECore/AttributeCache.h>;usingnamespaceIECore;
intmain( intargc, char*argv[] )
{
//createourcontainerCompoundObjectPtrcontainer( newCompoundObject() );
//createanarrayofintsIntVectorDataPtrint_data( newIntVectorData() );
int_data->writable().push_back( 1 );
int_data->writable().push_back( 2 );
int_data->writable().push_back( 3 );
//createanarrayofV3fsV3fVectorDataPtrvec_data( newV3fVectorData() );
vec_data->writable().push_back( Imath::V3f(1,1,1) );
vec_data->writable().push_back( Imath::V3f(2,2,2) );
vec_data->writable().push_back( Imath::V3f(3,3,3) );
//addthedatatoourcontainercontainer->members()["our_int_data"] =int_data;
container->members()["our_vec_data"] =vec_data;
//createanewattributecacheAttributeCachePtrcache( newAttributeCache( "test.0001.fio", IndexedIO::Write ) );
//writeourcontainertodiskcache->write( "our_object", "our_attribute", container );
//wediscardthecacheobjecttocompletewriting.
//notactuallynecessaryasit'sabouttogooutofscope//anyhow, butlefttomakethisexampleclear.
cache.reset();
return0;
}

Compile

 g++ -o CompoundObjectExample \
-I$CORTEX_ROOT/include \
-I$BOOST_ROOT/include/boost-1_38 \
-I$ILMBASE_ROOT/include \
-I$OPENEXR_ROOT/include/OpenEXR \
-L$CORTEX_ROOT/lib \
CompoundObjectExample.cpp -lIECore

Clone this wiki locally