本文整理汇总了C++中alembic::abccoreabstract::ArchiveReaderPtr类的典型用法代码示例。如果您正苦于以下问题:C++ ArchiveReaderPtr类的具体用法?C++ ArchiveReaderPtr怎么用?C++ ArchiveReaderPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArchiveReaderPtr类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: readArchive
void readArchive( const ABCA::ArchiveReaderPtr& iArchiveReader)
{
std::vector< ABCA::ObjectReaderPtr > objs;
objs.push_back( iArchiveReader->getTop() );
TESTING_ASSERT( objs[0]->getNumChildren() == 2 );
objs.push_back( objs[0]->getChild(0) );
objs.push_back( objs[0]->getChild(1) );
std::size_t numObjs = objs.size();
for (std::size_t i = 1; i < numObjs; ++i)
{
TESTING_ASSERT( objs[i]->getNumChildren() == 3 );
for (std::size_t j = 0; j < numObjs; ++j)
{
objs.push_back( objs[i]->getChild(j) );
}
}
for (std::size_t i = 0; i < objs.size(); ++i)
{
TESTING_ASSERT( objs[i]->getProperties()->getNumProperties() == 3 );
ABCA::CompoundPropertyReaderPtr cpr = objs[i]->getProperties();
ABCA::ArrayPropertyReaderPtr apr = cpr->getArrayProperty("a");
TESTING_ASSERT( 0 ==
objs[i]->getProperties()->getArrayProperty("a")->getNumSamples() );
TESTING_ASSERT( 1 ==
objs[i]->getProperties()->getArrayProperty("b")->getNumSamples() );
TESTING_ASSERT( 2 ==
objs[i]->getProperties()->getArrayProperty("c")->getNumSamples() );
}
TESTING_ASSERT( iArchiveReader->getMaxNumSamplesForTimeSamplingIndex(0) == 2 );
}
开发者ID:alembic,项目名称:alembic,代码行数:35,代码来源:ArchiveTests.cpp
示例2: testReadWriteEmptyArchive
void testReadWriteEmptyArchive()
{
std::string archiveName = "emptyArchive.abc";
{
AO::WriteArchive w;
ABCA::MetaData m;
m.set("Bleep", "bloop");
m.set("eep", "");
m.set("potato", "salad");
m.set("geoScope", "tasty");
ABCA::ArchiveWriterPtr a = w(archiveName, m);
ABCA::ObjectWriterPtr archive = a->getTop();
TESTING_ASSERT(archive->getFullName() == "/");
Alembic::AbcCoreOgawa::ReadArchive r;
// can't read an already open archive (for now)
TESTING_ASSERT_THROW(r( archiveName ), Alembic::Util::Exception);
}
{
AO::ReadArchive r;
ABCA::ArchiveReaderPtr a = r( archiveName );
ABCA::ObjectReaderPtr archive = a->getTop();
ABCA::MetaData m = archive->getHeader().getMetaData();
TESTING_ASSERT(m.get("Bleep") == "bloop");
TESTING_ASSERT(m.get("eep") == "");
TESTING_ASSERT(m.get("potato") == "salad");
TESTING_ASSERT(m.get("geoScope") == "tasty");
TESTING_ASSERT(archive->getName() == "ABC");
TESTING_ASSERT(archive->getFullName() == "/");
TESTING_ASSERT(archive->getParent() == NULL);
TESTING_ASSERT(archive->getNumChildren() == 0);
// even though we didn't write anything make sure we intrincially have
// the default sampling
TESTING_ASSERT(a->getNumTimeSamplings() == 1);
TESTING_ASSERT(*(a->getTimeSampling(0)) == ABCA::TimeSampling());
TESTING_ASSERT(a->getMaxNumSamplesForTimeSamplingIndex(0) == 0);
ABCA::CompoundPropertyReaderPtr parent = archive->getProperties();
TESTING_ASSERT(parent->getNumProperties() == 0);
// get it again to make sure we clean ourselves up properly
AO::ReadArchive r2;
ABCA::ArchiveReaderPtr a2 = r2( archiveName );
ABCA::ObjectReaderPtr archive2 = a2->getTop();
ABCA::CompoundPropertyReaderPtr p2 = archive2->getProperties();
TESTING_ASSERT(p2->getNumProperties() == 0);
}
}
开发者ID:AWhetter,项目名称:alembic,代码行数:55,代码来源:ArchiveTests.cpp
示例3: readArchive
void readArchive( const std::string & iName, std::istream * iStream )
{
std::vector< std::istream * > streamVec;
if (iStream)
{
streamVec.push_back(iStream);
}
Alembic::AbcCoreOgawa::ReadArchive r(streamVec);
ABCA::ArchiveReaderPtr a = r( iName );
std::vector< ABCA::ObjectReaderPtr > objs;
objs.push_back( a->getTop() );
TESTING_ASSERT( objs[0]->getNumChildren() == 2 );
objs.push_back( objs[0]->getChild(0) );
objs.push_back( objs[0]->getChild(1) );
std::size_t numObjs = objs.size();
for (std::size_t i = 1; i < numObjs; ++i)
{
TESTING_ASSERT( objs[i]->getNumChildren() == 3 );
for (std::size_t j = 0; j < numObjs; ++j)
{
objs.push_back( objs[i]->getChild(j) );
}
}
for (std::size_t i = 0; i < objs.size(); ++i)
{
TESTING_ASSERT( objs[i]->getProperties()->getNumProperties() == 3 );
ABCA::CompoundPropertyReaderPtr cpr = objs[i]->getProperties();
ABCA::ArrayPropertyReaderPtr apr = cpr->getArrayProperty("a");
TESTING_ASSERT( 0 ==
objs[i]->getProperties()->getArrayProperty("a")->getNumSamples() );
TESTING_ASSERT( 1 ==
objs[i]->getProperties()->getArrayProperty("b")->getNumSamples() );
TESTING_ASSERT( 2 ==
objs[i]->getProperties()->getArrayProperty("c")->getNumSamples() );
}
TESTING_ASSERT( a->getMaxNumSamplesForTimeSamplingIndex(0) == 2 );
}
开发者ID:AWhetter,项目名称:alembic,代码行数:42,代码来源:ArchiveTests.cpp
示例4: testReadWriteEmptyArchive
void testReadWriteEmptyArchive()
{
std::string archiveName = "emptyArchive.abc";
{
A5::WriteArchive w;
ABCA::MetaData m;
m.set("Bleep", "bloop");
m.set("eep", "");
m.set("potato", "salad");
m.set("geoScope", "tasty");
ABCA::ArchiveWriterPtr a = w(archiveName, m);
ABCA::ObjectWriterPtr archive = a->getTop();
TESTING_ASSERT(archive->getFullName() == "/");
// use this to get current reporting mechanism, then supress it
// since we expect to see H5F errors because we will be trying to open
// a file that is already open for writing.
H5E_auto_t func;
void * client_data;
H5Eget_auto2(H5E_DEFAULT, &func, &client_data);
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
// can't write an already open archive
TESTING_ASSERT_THROW(w(archiveName, ABCA::MetaData()),
Alembic::Util::Exception);
Alembic::AbcCoreHDF5::ReadArchive r;
// can't read an already open archive
TESTING_ASSERT_THROW(r( archiveName ), Alembic::Util::Exception);
// turn the error reporting back on for later tests
H5Eset_auto2(H5E_DEFAULT, func, client_data);
}
{
A5::ReadArchive r;
ABCA::ArchiveReaderPtr a = r( archiveName );
ABCA::ObjectReaderPtr archive = a->getTop();
ABCA::MetaData m = archive->getHeader().getMetaData();
TESTING_ASSERT(m.get("Bleep") == "bloop");
TESTING_ASSERT(m.get("eep") == "");
TESTING_ASSERT(m.get("potato") == "salad");
TESTING_ASSERT(m.get("geoScope") == "tasty");
TESTING_ASSERT(archive->getName() == "ABC");
TESTING_ASSERT(archive->getFullName() == "/");
TESTING_ASSERT(archive->getParent() == NULL);
TESTING_ASSERT(archive->getNumChildren() == 0);
// even though we didn't write anything make sure we intrincially have
// the default sampling
TESTING_ASSERT(a->getNumTimeSamplings() == 1);
TESTING_ASSERT(*(a->getTimeSampling(0)) == ABCA::TimeSampling());
TESTING_ASSERT(a->getMaxNumSamplesForTimeSamplingIndex(0) == 0);
ABCA::CompoundPropertyReaderPtr parent = archive->getProperties();
TESTING_ASSERT(parent->getNumProperties() == 0);
// get it again to make sure we clean ourselves up properly
A5::ReadArchive r2;
ABCA::ArchiveReaderPtr a2 = r2( archiveName );
ABCA::ObjectReaderPtr archive2 = a2->getTop();
ABCA::CompoundPropertyReaderPtr p2 = archive2->getProperties();
TESTING_ASSERT(p2->getNumProperties() == 0);
}
}
开发者ID:BlackGinger,项目名称:ExocortexCrate,代码行数:70,代码来源:ArchiveTests.cpp
示例5: readVeryEmptyArchive
void readVeryEmptyArchive( const std::string & iName, bool iCache )
{
Alembic::AbcCoreHDF5::ReadArchive r( iCache );
ABCA::ArchiveReaderPtr a = r( iName );
TESTING_ASSERT(a->getTop()->getNumChildren() == 0);
}
开发者ID:BlackGinger,项目名称:ExocortexCrate,代码行数:6,代码来源:ArchiveTests.cpp
示例6: testReadWriteMaxNumSamplesArchive
void testReadWriteMaxNumSamplesArchive()
{
std::string archiveName = "timeMaxNumSampsArchive.abc";
{
A5::WriteArchive w;
ABCA::ArchiveWriterPtr a = w(archiveName, ABCA::MetaData());
// we always have 1
TESTING_ASSERT(a->getNumTimeSamplings() == 1);
std::vector< double > samps;
// uniform sampling starts at second 34, 24fps
samps.push_back(34.0);
ABCA::TimeSampling ts(ABCA::TimeSamplingType(1.0/24.0), samps);
uint32_t index = a->addTimeSampling(ts);
TESTING_ASSERT(index == 1);
// uniform sampling starts at second 72, 24fps
samps[0] = 72.0;
ABCA::TimeSampling ts2(ABCA::TimeSamplingType(1.0/24.0), samps);
index = a->addTimeSampling(ts2);
TESTING_ASSERT(index == 2);
std::string testStr = "test";
ABCA::ScalarPropertyWriterPtr propPtr =
a->getTop()->getProperties()->createScalarProperty("test",
ABCA::MetaData(),
ABCA::DataType(Alembic::Util::kStringPOD, 1), 1);
// set the same thing 3 times
propPtr->setSample(&testStr);
propPtr->setSample(&testStr);
propPtr->setSample(&testStr);
propPtr =
a->getTop()->getProperties()->createScalarProperty("test2",
ABCA::MetaData(),
ABCA::DataType(Alembic::Util::kStringPOD, 1), 2);
propPtr->setSample(&testStr);
propPtr->setSample(&testStr);
std::string test2Str = "test2";
propPtr->setSample(&test2Str);
}
{
A5::ReadArchive r;
ABCA::ArchiveReaderPtr a = r( archiveName );
std::vector< double > samps;
// uniform sampling starts at second 34, 24fps
samps.push_back(34.0);
ABCA::TimeSampling ts(ABCA::TimeSamplingType(1.0/24.0), samps);
TESTING_ASSERT( ts == *(a->getTimeSampling(1)) );
TESTING_ASSERT( a->getMaxNumSamplesForTimeSamplingIndex(0) == 0 );
TESTING_ASSERT( a->getMaxNumSamplesForTimeSamplingIndex(1) == 1 );
TESTING_ASSERT( a->getMaxNumSamplesForTimeSamplingIndex(2) == 3 );
}
}
开发者ID:BlackGinger,项目名称:ExocortexCrate,代码行数:63,代码来源:ArchiveTests.cpp
示例7: testReadWriteTimeSamplingArchive
void testReadWriteTimeSamplingArchive()
{
std::string archiveName = "timeSampsArchive.abc";
{
A5::WriteArchive w;
ABCA::ArchiveWriterPtr a = w(archiveName, ABCA::MetaData());
// we always have 1
TESTING_ASSERT(a->getNumTimeSamplings() == 1);
// getting a time sampling that doesn't exist should throw
TESTING_ASSERT_THROW(a->getTimeSampling(43),
Alembic::Util::Exception);
TESTING_ASSERT(
a->getMaxNumSamplesForTimeSamplingIndex(43) == INDEX_UNKNOWN);
// first one is the default time sampling
TESTING_ASSERT(*(a->getTimeSampling(0)) == ABCA::TimeSampling());
TESTING_ASSERT(a->getMaxNumSamplesForTimeSamplingIndex(0) == 0);
std::vector< double > samps;
// uniform sampling starts at second 34, 24fps
samps.push_back(34.0);
ABCA::TimeSampling ts(ABCA::TimeSamplingType(1.0/24.0), samps);
uint32_t index = a->addTimeSampling(ts);
TESTING_ASSERT(index == 1);
// even though we add the same thing, we get the same index back
index = a->addTimeSampling(ts);
TESTING_ASSERT(index == 1);
// cyclic sampling example
samps.push_back(34.25);
samps.push_back(34.5);
ts = ABCA::TimeSampling(ABCA::TimeSamplingType(3, 1.0), samps);
index = a->addTimeSampling(ts);
TESTING_ASSERT(index == 2);
// normally we wouldn't ever call this directly, call it here
// for testing purposes only
a->setMaxNumSamplesForTimeSamplingIndex(2, 42);
// really weird acyclic example
samps.push_back(300.0);
samps.push_back(500.0);
ts = ABCA::TimeSampling(
ABCA::TimeSamplingType(ABCA::TimeSamplingType::kAcyclic), samps);
index = a->addTimeSampling(ts);
TESTING_ASSERT(index == 3);
// now we should have 4
TESTING_ASSERT(a->getNumTimeSamplings() == 4);
}
{
A5::ReadArchive r;
ABCA::ArchiveReaderPtr a = r( archiveName );
TESTING_ASSERT(a->getNumTimeSamplings() == 4);
// first one is the default time sampling
TESTING_ASSERT(*(a->getTimeSampling(0)) == ABCA::TimeSampling());
std::vector< double > samps;
// uniform sampling starts at second 34, 24fps
samps.push_back(34.0);
ABCA::TimeSampling ts(ABCA::TimeSamplingType(1.0/24.0), samps);
TESTING_ASSERT( ts == *(a->getTimeSampling(1)) );
TESTING_ASSERT( a->getMaxNumSamplesForTimeSamplingIndex(1) == 0 );
// cyclic sampling example
samps.push_back(34.25);
samps.push_back(34.5);
ts = ABCA::TimeSampling(ABCA::TimeSamplingType(3, 1.0), samps);
TESTING_ASSERT( ts == *(a->getTimeSampling(2)) );
TESTING_ASSERT( a->getMaxNumSamplesForTimeSamplingIndex(2) == 42 );
// really weird acyclic example
samps.push_back(300.0);
samps.push_back(500.0);
ts = ABCA::TimeSampling(
ABCA::TimeSamplingType(ABCA::TimeSamplingType::kAcyclic), samps);
TESTING_ASSERT( ts == *(a->getTimeSampling(3)) );
TESTING_ASSERT( a->getMaxNumSamplesForTimeSamplingIndex(3) == 0 );
}
}
开发者ID:BlackGinger,项目名称:ExocortexCrate,代码行数:89,代码来源:ArchiveTests.cpp
示例8: ReadTestArchive
//-*****************************************************************************
void ReadTestArchive( const std::string &iArchiveName )
{
// When opening an archive for reading, you can pass in a pointer to
// an AbcA::ReadArraySampleCache, but if you don't, it will construct one
// for you by default. If you don't want to cache, just pass in NULL
// as the second argument.
Alembic::AbcCoreHDF5::ReadArchive ar;
AbcA::ArchiveReaderPtr arkive = ar( iArchiveName );
// Just stashing away a compound property reader pointer; we know the last
// child object in our hierarchy has all the properties, because we created
// it in the WriteTestArchive function.
AbcA::CompoundPropertyReaderPtr fcProps;
// Now do a depth-first traversal of our archive; this is a little ugly
AbcA::ObjectReaderPtr tmpOrp1;
AbcA::ObjectReaderPtr tmpOrp2 = arkive->getTop();
while ( true )
{
tmpOrp1 = tmpOrp2;
if ( tmpOrp1->getNumChildren() < 1 )
{
std::cout << "Found my last lonely child, named "
<< tmpOrp1->getFullName() << std::endl;
fcProps = tmpOrp1->getProperties();
std::cout << "It has " << fcProps->getNumProperties()
<< " sub-properties." << std::endl;
break;
}
tmpOrp2 = tmpOrp1->getChild( 0 );
}
// OK, fcProps is a shared pointer to the compound property reader that
// was in the last child object of the archive. Let's get the simple
// properties out of it.
AbcA::ScalarPropertyReaderPtr sProp;
AbcA::ArrayPropertyReaderPtr aProp0;
AbcA::ArrayPropertyReaderPtr aProp1;
for ( size_t i = 0 ; i < fcProps->getNumProperties() ; ++i )
{
AbcA::BasePropertyReaderPtr bp = fcProps->getProperty( i );
std::cout << "Found " << bp->getName() << std::endl;
if ( bp->isScalar() )
{
sProp = bp->asScalarPtr();
std::cout << "sProp has " << sProp->getNumSamples()
<< " samples." << std::endl;
}
if ( bp->isArray() && bp->getName() == "secondInt32ArrayProp" )
{
aProp1 = bp->asArrayPtr();
std::cout << "aProp1 has " << aProp1->getNumSamples()
<< " samples." << std::endl;
}
if ( bp->isArray() && bp->getName() == "firstInt32ArrayProp" )
{
aProp0 = bp->asArrayPtr();
std::cout << "aProp0 has " << aProp0->getNumSamples()
<< " samples." << std::endl;
}
}
// OK, now we have pointers to the two properties, one scalar, the other
// array. Let's read the scalar one first.
for ( size_t i = 0 ; i < sProp->getNumSamples() ; ++i )
{
float32_t sVal = 0;
sProp->getSample( i, (void*)(&sVal) );
TESTING_ASSERT( sVal == 42.0 );
std::cout << sProp->getName() << " at sample " << i << " has the value "
<< sVal << std::endl << std::endl;
}
// OK, now the first int array property.
AbcA::ArraySamplePtr samp;
std::cout << "FIRST INT ARRAY PROPERTY (Cyclic time sampling)"
<< std::endl;
for ( size_t i = 0 ; i < aProp0->getNumSamples() ; ++i )
{
aProp0->getSample( i, samp );
const AbcA::TimeSampling ts = aProp0->getTimeSampling();
size_t numPoints = samp->getDimensions().numPoints();
TESTING_ASSERT( (AbcA::chrono_t)i == ts.getSampleTime( i ) );
std::cout << "At Sample " << i << ", " << aProp0->getName()
<< " is at time " << ts.getSampleTime( i )
<< " and has " << numPoints << " points, with the values: "
<< std::endl;
int32_t *vals = (int32_t*)(samp->getData());
for ( size_t j = 0 ; j < numPoints ; ++j )
//.........这里部分代码省略.........
开发者ID:PonyDeluxe,项目名称:alembic,代码行数:101,代码来源:OctessenceBug38.cpp
示例9: testWeirdStringScalar
//-*****************************************************************************
void testWeirdStringScalar()
{
std::string archiveName = "weirdStr.abc";
Alembic::Util::string weirdStr = "Total failure";
weirdStr[5] = '\0';
Alembic::Util::wstring weirdWstr = L"Failure is always an option";
weirdWstr[5] = L'\0';
std::vector < Alembic::Util::string > weirdStrArray(3);
weirdStrArray[0] = "watch";
weirdStrArray[1] = "this";
weirdStrArray[2] = "please";
weirdStrArray[2][3] = '\0';
Alembic::Util::string empty;
Alembic::Util::wstring wempty;
std::vector < Alembic::Util::string > allEmptyStr(3);
std::vector < Alembic::Util::string > partEmptyStr(6);
partEmptyStr[0] = "";
partEmptyStr[1] = "";
partEmptyStr[2] = "notEmpty!";
partEmptyStr[3] = "";
partEmptyStr[4] = "also not empty";
partEmptyStr[5] = "";
{
A5::WriteArchive w;
AbcA::ArchiveWriterPtr a = w(archiveName, AbcA::MetaData());
AbcA::ObjectWriterPtr archive = a->getTop();
AbcA::CompoundPropertyWriterPtr props = archive->getProperties();
{
AbcA::ScalarPropertyWriterPtr emptyWrtPtr =
props->createScalarProperty("empty", AbcA::MetaData(),
AbcA::DataType(Alembic::Util::kStringPOD, 1), 0);
// this should fail because of the NULL char in the string
TESTING_ASSERT_THROW(emptyWrtPtr->setSample(&weirdStr),
Alembic::Util::Exception);
emptyWrtPtr->setSample(&empty);
AbcA::ScalarPropertyWriterPtr wemptyWrtPtr =
props->createScalarProperty("wempty", AbcA::MetaData(),
AbcA::DataType(Alembic::Util::kWstringPOD, 1), 0);
// this should fail because of the NULL char in the string
TESTING_ASSERT_THROW(wemptyWrtPtr->setSample(&weirdWstr),
Alembic::Util::Exception);
wemptyWrtPtr->setSample(&wempty);
AbcA::ScalarPropertyWriterPtr allEmptyWrtPtr =
props->createScalarProperty("allEmpty", AbcA::MetaData(),
AbcA::DataType(Alembic::Util::kStringPOD, 3), 0);
// one of the strings has a NULL char in it
TESTING_ASSERT_THROW(
allEmptyWrtPtr->setSample(&(weirdStrArray.front())),
Alembic::Util::Exception);
allEmptyWrtPtr->setSample(&(allEmptyStr.front()));
AbcA::ScalarPropertyWriterPtr partEmptyStrPtr =
props->createScalarProperty("partEmpty", AbcA::MetaData(),
AbcA::DataType(Alembic::Util::kStringPOD, 6), 0);
partEmptyStrPtr->setSample(&(partEmptyStr.front()));
}
}
{
A5::ReadArchive r;
AbcA::ArchiveReaderPtr a = r( archiveName );
AbcA::ObjectReaderPtr archive = a->getTop();
AbcA::CompoundPropertyReaderPtr parent = archive->getProperties();
for (size_t i = 0; i < parent->getNumProperties(); ++i)
{
AbcA::BasePropertyReaderPtr bp = parent->getProperty( i );
if (bp->getName() == "partEmpty")
{
std::vector < Alembic::Util::string > val (6);
AbcA::ScalarPropertyReaderPtr sp = bp->asScalarPtr();
TESTING_ASSERT(sp->getDataType().getExtent() == 6);
sp->getSample(0, &(val.front()));
TESTING_ASSERT(val == partEmptyStr);
}
else if (bp->getName() == "allEmpty")
{
std::vector < Alembic::Util::string > val (3);
AbcA::ScalarPropertyReaderPtr sp = bp->asScalarPtr();
//.........这里部分代码省略.........
开发者ID:GameFusion,项目名称:alembic,代码行数:101,代码来源:ScalarPropertyTests.cpp
示例10: testRepeatedScalarData
//-*****************************************************************************
void testRepeatedScalarData()
{
std::string archiveName = "repeatScalarData.abc";
{
A5::WriteArchive w;
AbcA::ArchiveWriterPtr a = w(archiveName, AbcA::MetaData());
AbcA::ObjectWriterPtr archive = a->getTop();
AbcA::CompoundPropertyWriterPtr parent = archive->getProperties();
AbcA::ScalarPropertyWriterPtr swp =
parent->createScalarProperty("int32", AbcA::MetaData(),
AbcA::DataType(Alembic::Util::kInt32POD, 3), 0);
std::vector <Alembic::Util::uint32_t> ui(3);
ui[0] = 0;
ui[1] = 1;
ui[2] = 2;
std::vector <Alembic::Util::uint32_t> ui2(3);
ui2[0] = 41;
ui2[1] = 43;
ui2[2] = 47;
swp->setSample(&(ui.front()));
swp->setSample(&(ui.front()));
swp->setSample(&(ui2.front()));
swp->setSample(&(ui.front()));
swp->setSample(&(ui2.front()));
swp->setSample(&(ui2.front()));
swp->setSample(&(ui2.front()));
swp->setSample(&(ui.front()));
swp->setSample(&(ui.front()));
swp->setSample(&(ui.front()));
AbcA::ScalarPropertyWriterPtr swp2 =
parent->createScalarProperty("float32", AbcA::MetaData(),
AbcA::DataType(Alembic::Util::kFloat32POD, 1), 0);
Alembic::Util::float32_t f = 42.0;
Alembic::Util::float32_t f2 = -3.0;
swp2->setSample(&f);
swp2->setSample(&f);
swp2->setSample(&f);
swp2->setSample(&f2);
swp2->setSample(&f2);
swp2->setSample(&f2);
AbcA::ScalarPropertyWriterPtr swp3 =
parent->createScalarProperty("uint16", AbcA::MetaData(),
AbcA::DataType(Alembic::Util::kUint16POD, 1), 0);
Alembic::Util::uint16_t ui16 = 17;
swp3->setSample(&ui16);
swp3->setSample(&ui16);
swp3->setSample(&ui16);
swp3->setSample(&ui16);
AbcA::ScalarPropertyWriterPtr swp4 =
parent->createScalarProperty("str", AbcA::MetaData(),
AbcA::DataType(Alembic::Util::kStringPOD, 3), 0);
std::vector < Alembic::Util::string > strVec(3);
strVec[0] = "Please";
strVec[1] = "";
strVec[2] = "work";
std::vector < Alembic::Util::string > strVec2(3);
strVec2[0] = "Whats";
strVec2[1] = "going";
strVec2[2] = "on?";
swp4->setSample(&(strVec.front()));
swp4->setSample(&(strVec.front()));
swp4->setSample(&(strVec2.front()));
swp4->setSample(&(strVec2.front()));
}
{
A5::ReadArchive r;
AbcA::ArchiveReaderPtr a = r( archiveName );
AbcA::ObjectReaderPtr archive = a->getTop();
AbcA::CompoundPropertyReaderPtr parent = archive->getProperties();
TESTING_ASSERT(parent->getNumProperties() == 4);
for (size_t i = 0; i < parent->getNumProperties(); ++i)
{
AbcA::BasePropertyReaderPtr bp = parent->getProperty( i );
AbcA::ScalarPropertyReaderPtr sp = bp->asScalarPtr();
switch (sp->getDataType().getPod())
{
case Alembic::Util::kUint16POD:
{
TESTING_ASSERT( sp->getNumSamples() == 4 );
const AbcA::TimeSamplingPtr t = sp->getTimeSampling();
//.........这里部分代码省略.........
开发者ID:GameFusion,项目名称:alembic,代码行数:101,代码来源:ScalarPropertyTests.cpp
示例11: testReadWriteScalars
//.........这里部分代码省略.........
AbcA::ScalarPropertyWriterPtr doubleWrtPtr =
props->createScalarProperty("double", AbcA::MetaData(),
AbcA::DataType(Alembic::Util::kFloat64POD, 1), 0);
Alembic::Util::float64_t d = 32768.0;
TESTING_ASSERT(doubleWrtPtr->getNumSamples() == 0);
doubleWrtPtr->setSample(&d);
TESTING_ASSERT(doubleWrtPtr->getNumSamples() == 1);
}
{
AbcA::ScalarPropertyWriterPtr strWrtPtr =
props->createScalarProperty("str", AbcA::MetaData(),
AbcA::DataType(Alembic::Util::kStringPOD, 1), 0);
Alembic::Util::string c = "This was a triumph!";
strWrtPtr->setSample(&c);
}
{
AbcA::ScalarPropertyWriterPtr wstrWrtPtr =
props->createScalarProperty("wstr", AbcA::MetaData(),
AbcA::DataType(Alembic::Util::kWstringPOD, 1), 0);
Alembic::Util::wstring c( L"Matt Lauer can suck it! \u2697" );
wstrWrtPtr->setSample(&c);
}
}
// now we read what we've written
{
A5::ReadArchive r;
AbcA::ArchiveReaderPtr a = r( archiveName );
AbcA::ObjectReaderPtr archive = a->getTop();
AbcA::CompoundPropertyReaderPtr parent = archive->getProperties();
TESTING_ASSERT(parent->getNumProperties() == 14);
for ( size_t i = 0; i < parent->getNumProperties(); ++i )
{
AbcA::BasePropertyReaderPtr bp = parent->getProperty( i );
// they are all supposed to be scalar
TESTING_ASSERT( bp->isScalar() );
AbcA::ScalarPropertyReaderPtr sp = bp->asScalarPtr();
TESTING_ASSERT( sp->getNumSamples() == 1 );
TESTING_ASSERT( sp->isConstant() );
TESTING_ASSERT( sp->getParent() == parent);
TESTING_ASSERT( sp->getDataType().getExtent() == 1);
switch (sp->getDataType().getPod())
{
case Alembic::Util::kBooleanPOD:
{
TESTING_ASSERT(sp->getName() == "bool");
Alembic::Util::bool_t val = false;
sp->getSample(0, &val);
TESTING_ASSERT(val == true);
}
break;
case Alembic::Util::kUint8POD:
{
TESTING_ASSERT(sp->getName() == "uchar");
Alembic::Util::uint8_t val = 0;
sp->getSample(0, &val);
开发者ID:GameFusion,项目名称:alembic,代码行数:67,代码来源:ScalarPropertyTests.cpp
示例12: testObjectHashes
void testObjectHashes()
{
std::string archiveName = "objectHashTest.abc";
{
AO::WriteArchive w;
ABCA::ArchiveWriterPtr a = w(archiveName, ABCA::MetaData());
ABCA::ObjectWriterPtr archive = a->getTop();
ABCA::ObjectWriterPtr child;
// 2 objects without any children whatsoever
archive->createChild(ABCA::ObjectHeader("emptyA", ABCA::MetaData()));
archive->createChild(ABCA::ObjectHeader("emptyB", ABCA::MetaData()));
// 2 objects with one child object
child = archive->createChild(ABCA::ObjectHeader("1ChildA",
ABCA::MetaData()));
child->createChild(ABCA::ObjectHeader("child", ABCA::MetaData()));
child = archive->createChild(ABCA::ObjectHeader("1ChildB",
ABCA::MetaData()));
child->createChild(ABCA::ObjectHeader("child", ABCA::MetaData()));
// 2 objects with one child object with a different name
child = archive->createChild(ABCA::ObjectHeader("1ChildAName",
ABCA::MetaData()));
child->createChild(ABCA::ObjectHeader("empty", ABCA::MetaData()));
child = archive->createChild(ABCA::ObjectHeader("1ChildBName",
ABCA::MetaData()));
child->createChild(ABCA::ObjectHeader("empty", ABCA::MetaData()));
// 2 objects with one child object with different MetaData
ABCA::MetaData m;
m.set("Bleep", "bloop");
child = archive->createChild(ABCA::ObjectHeader("1ChildAMeta",
ABCA::MetaData()));
child->createChild(ABCA::ObjectHeader("child", m));
child = archive->createChild(ABCA::ObjectHeader("1ChildBMeta",
ABCA::MetaData()));
child->createChild(ABCA::ObjectHeader("child", m));
// 2 objects with one child object additional prop
child = archive->createChild(ABCA::ObjectHeader("1ChildAProp",
ABCA::MetaData()));
child->createChild(ABCA::ObjectHeader("child", ABCA::MetaData())
)->getProperties()->createCompoundProperty("child",
ABCA::MetaData());
child = archive->createChild(ABCA::ObjectHeader("1ChildBProp",
ABCA::MetaData()));
child->createChild(ABCA::ObjectHeader("child", ABCA::MetaData())
)->getProperties()->createCompoundProperty("child",
ABCA::MetaData());
// 2 objects with one child object with additional grand child
child = archive->createChild(ABCA::ObjectHeader("1ChildAChild",
ABCA::MetaData()));
child->createChild(ABCA::ObjectHeader("child", ABCA::MetaData())
)->createChild(ABCA::ObjectHeader("grandchild", ABCA::MetaData()));
child = archive->createChild(ABCA::ObjectHeader("1ChildBChild",
ABCA::MetaData()));
child->createChild(ABCA::ObjectHeader("child", ABCA::MetaData())
)->createChild(ABCA::ObjectHeader("grandchild", ABCA::MetaData()));
// 2 objects with two children objects
child = archive->createChild(ABCA::ObjectHeader("2ChildA",
ABCA::MetaData()));
child->createChild(ABCA::ObjectHeader("childA", ABCA::MetaData()));
child->createChild(ABCA::ObjectHeader("childB", ABCA::MetaData()));
child = archive->createChild(ABCA::ObjectHeader("2ChildB",
ABCA::MetaData()));
child->createChild(ABCA::ObjectHeader("childA", ABCA::MetaData()));
child->createChild(ABCA::ObjectHeader("childB", ABCA::MetaData()));
// 2 objects with two children objects with swapped children
child = archive->createChild(ABCA::ObjectHeader("2ChildASwap",
ABCA::MetaData()));
child->createChild(ABCA::ObjectHeader("childB", ABCA::MetaData()));
child->createChild(ABCA::ObjectHeader("childA", ABCA::MetaData()));
child = archive->createChild(ABCA::ObjectHeader("2ChildBSwap",
ABCA::MetaData()));
child->createChild(ABCA::ObjectHeader("childB", ABCA::MetaData()));
child->createChild(ABCA::ObjectHeader("childA", ABCA::MetaData()));
}
{
AO::ReadArchive r;
ABCA::ArchiveReaderPtr a = r( archiveName );
ABCA::ObjectReaderPtr archive = a->getTop();
TESTING_ASSERT(archive->getNumChildren() == 16);
// every 2 hashes should be the same
for (size_t i = 0; i < archive->getNumChildren(); i += 2)
{
Alembic::Util::Digest dA, dB;
//.........这里部分代码省略.........
开发者ID:BlackGinger,项目名称:ExocortexCrate,代码行数:101,代码来源:HashesTests.cpp
示例13: testArrayPropHashes
//.........这里部分代码省略.........
awp->setSample(ABCA::ArraySample(&(valiB.front()), i32d, dims));
// 2 objects with 4 samples, with repeats
child = archive->createChild(ABCA::ObjectHeader(
"1propA4Samp", ABCA::MetaData()));
awp = child->getProperties()->createArrayProperty("int",
ABCA::MetaData(), ABCA::DataType(Alembic::Util::kInt32POD, 1), 0);
awp->setSample(ABCA::ArraySample(&(vali.front()), i32d, dims));
awp->setSample(ABCA::ArraySample(&(vali.front()), i32d, dims));
awp->setSample(ABCA::ArraySample(&(valiB.front()), i32d, dims));
awp->setSample(ABCA::ArraySample(&(valiB.front()), i32d, dims));
child = archive->createChild(ABCA::ObjectHeader(
"1propB4Samp", ABCA::MetaData()));
awp = child->getProperties()->createArrayProperty("int",
ABCA::MetaData(), ABCA::DataType(Alembic::Util::kInt32POD, 1), 0);
awp->setSample(ABCA::ArraySample(&(vali.front()), i32d, dims));
awp->setSample(ABCA::ArraySample(&(vali.front()), i32d, dims));
awp->setSample(ABCA::ArraySample(&(valiB.front()), i32d, dims));
awp->setSample(ABCA::ArraySample(&(valiB.front()), i32d, dims));
// 2 objects with 1 samplem different dimensions
Alembic::Util::Dimensions dimsB;
dimsB.setRank(2);
dimsB[0] = 2;
dimsB[1] = 2;
child = archive->createChild(ABCA::ObjectHeader(
"1propA1Dims", ABCA::MetaData()));
awp = child->getProperties()->createArrayProperty("int",
ABCA::MetaData(), ABCA::DataType(Alembic::Util::kInt32POD, 1), 0);
awp->setSample(ABCA::ArraySample(&(vali.front()), i32d, dimsB));
child = archive->createChild(ABCA::ObjectHeader(
"1propB1Dims", ABCA::MetaData()));
awp = child->getProperties()->createArrayProperty("int",
ABCA::MetaData(), ABCA::DataType(Alembic::Util::kInt32POD, 1), 0);
awp->setSample(ABCA::ArraySample(&(vali.front()), i32d, dimsB));
// 2 objects with with the same 2 properties with no samples
child = archive->createChild(ABCA::ObjectHeader(
"2propA", ABCA::MetaData()));
child->getProperties()->createArrayProperty("empty", ABCA::MetaData(),
ABCA::DataType(Alembic::Util::kInt32POD, 1), 0);
child->getProperties()->createArrayProperty("null", ABCA::MetaData(),
ABCA::DataType(Alembic::Util::kInt32POD, 1), 0);
child = archive->createChild(ABCA::ObjectHeader(
"2propB", ABCA::MetaData()));
child->getProperties()->createArrayProperty("empty", ABCA::MetaData(),
ABCA::DataType(Alembic::Util::kInt32POD, 1), 0);
child->getProperties()->createArrayProperty("null", ABCA::MetaData(),
ABCA::DataType(Alembic::Util::kInt32POD, 1), 0);
// 2 objects with with the same 2 properties created in opposite order
child = archive->createChild(ABCA::ObjectHeader(
"2propASwap", ABCA::MetaData()));
child->getProperties()->createArrayProperty("null", ABCA::MetaData(),
ABCA::DataType(Alembic::Util::kInt32POD, 1), 0);
child->getProperties()->createArrayProperty("empty", ABCA::MetaData(),
ABCA::DataType(Alembic::Util::kInt32POD, 1), 0);
child = archive->createChild(ABCA::ObjectHeader(
"2propBSwap", ABCA::MetaData()));
child->getProperties()->createArrayProperty("null", ABCA::MetaData(),
ABCA::DataType(Alembic::Util::kInt32POD, 1), 0);
child->getProperties()->createArrayProperty("empty", ABCA::MetaData(),
ABCA::DataType(Alembic::Util::kInt32POD, 1), 0);
}
{
AO::ReadArchive r;
ABCA::ArchiveReaderPtr a = r( archiveName );
ABCA::ObjectReaderPtr archive = a->getTop();
TESTING_ASSERT(archive->getNumChildren() == 26);
// every 2 hashes should be the same
for (size_t i = 0; i < archive->getNumChildren(); i += 2)
{
Alembic::Util::Digest dA, dB;
TESTING_ASSERT(archive->getChild(i)->getPropertiesHash(dA) &&
archive->getChild(i+1)->getPropertiesHash(dB));
TESTING_ASSERT(dA == dB);
}
// make sure that every 2 child objects have different properties hashes
for (size_t i = 0; i < archive->getNumChildren() / 2; ++i)
{
Alembic::Util::Digest dA;
archive->getChild(i*2)->getPropertiesHash(dA);
for (size_t j = i + 1; j < archive->getNumChildren() / 2; ++j)
{
Alembic::Util::Digest dB;
archive->getChild(j*2)->getPropertiesHash(dB);
TESTING_ASSERT(dA != dB);
}
}
}
}
开发者ID:BlackGinger,项目名称:ExocortexCrate,代码行数:101,代码来源:HashesTests.cpp
示例14: testCompoundPropHashes
//.........这里部分代码省略.........
// 2 objects with with the same property with a different MetaData
ABCA::MetaData m;
m.set("Bleep", "bloop");
child = archive->createChild(ABCA::ObjectHeader(
"1propAMeta", ABCA::MetaData()));
child->getProperties()->createCompoundProperty("empty", m);
child = archive->createChild(ABCA::ObjectHeader(
"1propBMeta", ABCA::MetaData()));
child->getProperties()->createCompoundProperty("empty", m);
// 2 objects with compound that has a child compound
child = archive->createChild(ABCA::ObjectHeader(
"1propAChild", ABCA::MetaData()));
child->getProperties()->createCompoundProperty("withChild",
ABCA::MetaData())->createCompoundProperty("child",
ABCA::MetaData());
child = archive->createChild(ABCA::ObjectHeader(
"1propBChild", ABCA::MetaData()));
child->getProperties()->createCompoundProperty("withChild",
ABCA::MetaData())->createCompoundProperty("child",
ABCA::MetaData());
// 2 objects with compound that has various children
ABCA::CompoundPropertyWriterPtr childProp;
child = archive->createChild(ABCA::ObjectHeader(
"1propAProps", ABCA::MetaData()));
childProp = child->getProperties()->createCompoundProperty("child",
ABCA::MetaData());
childProp->createCompoundProperty("child", ABCA::MetaData());
childProp->createScalarProperty("empty", ABCA::MetaData(),
ABCA::DataType(Alembic::Util::kInt32POD, 1), 0);
child = archive->createChild(ABCA::ObjectHeader(
"1propBProps", ABCA::MetaData()));
childProp = child->getProperties()->createCompoundProperty("child",
ABCA::MetaData());
childProp->createCompoundProperty("child", ABCA::MetaData());
childProp->createScalarProperty("empty", ABCA::MetaData(),
ABCA::DataType(Alembic::Util::kInt32POD, 1), 0);
// 2 objects with compound that has hierarchy
ABCA::CompoundPropertyWriterPtr grandChildProp;
child = archive->createChild(ABCA::ObjectHeader(
"1propAHier", ABCA::MetaData()));
childProp = child->getProperties()->createCompoundProperty("child",
ABCA::MetaData());
grandChildProp = childProp->createCompoundProperty("child",
ABCA::MetaData());
childProp->createScalarProperty("empty", ABCA::MetaData(),
ABCA::DataType(Alembic::Util::kInt32POD, 1), 0);
grandChildProp->createScalarProperty("empty", ABCA::MetaData(),
ABCA::DataType(Alembic::Util::kInt32POD, 1), 0);
grandChildProp->createCompoundProperty("child", ABCA::MetaData());
child = archive->createChild(ABCA::ObjectHeader(
"1propBHier", ABCA::MetaData()));
childProp = child->getProperties()->createCompoundProperty("child",
ABCA::MetaData());
grandChildProp = childProp->createCompoundProperty("child",
ABCA::MetaData());
childProp->createScalarProperty("empty", ABCA::MetaData(),
ABCA::DataType(Alembic::Util::kInt32POD, 1), 0);
grandChildProp->createScalarProperty("empty", ABCA::MetaData(),
ABCA::DataType(Alembic::Util::kInt32POD, 1), 0);
grandChildProp->createCompoundProperty("child", ABCA::MetaData());
}
{
AO::ReadArchive r;
ABCA::ArchiveReaderPtr a = r( archiveName );
ABCA::ObjectReaderPtr archive = a->getTop();
TESTING_ASSERT(archive->getNumChildren() == 14);
// every 2 hashes should be the same
for (size_t i = 0; i < archive->getNumChildren(); i += 2)
{
Alembic::Util::Digest dA, dB;
TESTING_ASSERT(archive->getChild(i)->getPropertiesHash(dA) &&
archive->getChild(i+1)->getPropertiesHash(dB));
TESTING_ASSERT(dA == dB);
}
// make sure that every 2 child objects have different properties hashes
for (size_t i = 0; i < archive->getNumChildren() / 2; ++i)
{
Alembic::Util::Digest dA;
archive->getChild(i*2)->getPropertiesHash(dA);
for (size_t j = i + 1; j < archive->getNumChildren() / 2; ++j)
{
Alembic::Util::Digest dB;
archive->getChild(j*2)->getPropertiesHash(dB);
TESTING_ASSERT(dA != dB);
}
}
}
}
开发者ID:BlackGinger,项目名称:ExocortexCrate,代码行数:101,代码来源:Hash |
请发表评论