本文整理汇总了C++中IArchive::getTop方法的典型用法代码示例。如果您正苦于以下问题:C++ IArchive::getTop方法的具体用法?C++ IArchive::getTop怎么用?C++ IArchive::getTop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IArchive
的用法示例。
在下文中一共展示了IArchive::getTop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getABCTimeSpan
//-*****************************************************************************
void getABCTimeSpan(IArchive archive, chrono_t& first, chrono_t& last)
{
// TO DO: Is the childBounds property reliable to get the full archive's span?
if (!archive.valid())
return;
IObject archiveTop = archive.getTop();
if ( archiveTop.getProperties().getPropertyHeader( ".childBnds" ) != NULL ) { // Try to get timing from childBounds first
IBox3dProperty childbnds = Alembic::Abc::IBox3dProperty( archive.getTop().getProperties(),
".childBnds", ErrorHandler::kQuietNoopPolicy);
TimeSamplingPtr ts = childbnds.getTimeSampling();
first = std::min(first, ts->getSampleTime(0) );
last = std::max(last, ts->getSampleTime(childbnds.getNumSamples()-1) );
return;
}
unsigned int numChildren = archiveTop.getNumChildren();
for (unsigned i=0; i<numChildren; ++i) // Visit every object to get its first and last sample
{
IObject obj( archiveTop.getChild( i ));
getObjectTimeSpan(obj, first, last, true);
}
}
示例2: layerTest
//-*****************************************************************************
void layerTest()
{
std::string fileName = "objectLayer1.abc";
std::string fileName2 = "objectLayer2.abc";
{
OArchive archive( Alembic::AbcCoreOgawa::WriteArchive(), fileName );
OObject child( archive.getTop(), "child" );
OObject childCool( child, "cool" );
OObject childGuy( child, "guy" );
OObject childA( archive.getTop(), "childA" );
OObject childAA( childA, "A" );
}
{
OArchive archive( Alembic::AbcCoreOgawa::WriteArchive(), fileName2 );
OObject child( archive.getTop(), "child" );
OObject childCool( child, "cool" );
OObject childGal( child, "gal" );
OObject childA( archive.getTop(), "childB" );
OObject childAA( childA, "B" );
}
{
std::vector< std::string > files;
files.push_back( fileName );
files.push_back( fileName2 );
Alembic::AbcCoreFactory::IFactory factory;
IArchive archive = factory.getArchive( files );
// child, childA, childB
TESTING_ASSERT( archive.getTop().getNumChildren() == 3 );
IObject child = archive.getTop().getChild("child");
TESTING_ASSERT( child.getNumChildren() == 3 );
TESTING_ASSERT( child.getChild("cool").valid() );
TESTING_ASSERT( child.getChild("cool").getNumChildren() == 0 );
TESTING_ASSERT( child.getChild("guy").valid() );
TESTING_ASSERT( child.getChild("guy").getNumChildren() == 0 );
TESTING_ASSERT( child.getChild("gal").valid() );
TESTING_ASSERT( child.getChild("gal").getNumChildren() == 0 );
IObject childA = archive.getTop().getChild("childA");
TESTING_ASSERT( childA.getNumChildren() == 1 );
TESTING_ASSERT( childA.getChild("A").valid() );
TESTING_ASSERT( childA.getChild("A").getNumChildren() == 0 );
IObject childB = archive.getTop().getChild("childB");
TESTING_ASSERT( childB.getNumChildren() == 1 );
TESTING_ASSERT( childB.getChild("B").valid() );
TESTING_ASSERT( childB.getChild("B").getNumChildren() == 0 );
}
}
示例3: pruneTest
//-*****************************************************************************
void pruneTest()
{
std::string fileName = "objectPrune1.abc";
std::string fileName2 = "objectPrune2.abc";
{
OArchive archive( Alembic::AbcCoreOgawa::WriteArchive(), fileName );
OObject child( archive.getTop(), "child" );
OObject childCool( child, "cool" );
OObject childGuy( child, "guy" );
OObject childA( archive.getTop(), "childA" );
OObject childAA( childA, "A" );
OObject childB( archive.getTop(), "childB" );
OObject childBB( childB, "B" );
}
{
MetaData md;
Alembic::AbcCoreLayer::SetPrune( md, true );
OArchive archive( Alembic::AbcCoreOgawa::WriteArchive(), fileName2 );
OObject child( archive.getTop(), "child" );
OObject childGuy( child, "guy", md );
OObject childA( archive.getTop(), "childA" );
OObject childAA( childA, "A", md );
OObject childAB( childA, "B", md );
OObject childB( archive.getTop(), "childB", md );
}
{
std::vector< std::string > files;
files.push_back( fileName );
files.push_back( fileName2 );
Alembic::AbcCoreFactory::IFactory factory;
IArchive archive = factory.getArchive( files );
// child, childA, childB
TESTING_ASSERT( archive.getTop().getNumChildren() == 2 );
IObject child = archive.getTop().getChild("child");
TESTING_ASSERT( child.getNumChildren() == 1 );
TESTING_ASSERT( child.getChild("cool").valid() );
TESTING_ASSERT( child.getChild("cool").getNumChildren() == 0 );
IObject childA = archive.getTop().getChild("childA");
TESTING_ASSERT( childA.getNumChildren() == 0 );
}
}
示例4: updateTableKnob
void ABCReadGeo::updateTableKnob()
{
p_tableKnobI->deleteAllItems();
p_tableKnobI->reset();
if (filename()[0] == '\0') {
return;
}
IArchive archive( Alembic::AbcCoreHDF5::ReadArchive(),
filename(),
Abc::ErrorHandler::kQuietNoopPolicy );
if (!archive.valid()) {
return;
}
IObject archiveTop = archive.getTop();
std::vector<Alembic::AbcGeom::IObject> _objs;
getABCGeos(archiveTop, _objs);
int obj = 0;
for( std::vector<Alembic::AbcGeom::IObject>::const_iterator iObj( _objs.begin() ); iObj != _objs.end(); ++iObj ) {
p_tableKnobI->addRow(obj);
p_tableKnobI->setCellString(obj,0,iObj->getName());
p_tableKnobI->setCellBool(obj,1,true);
obj++;
}
}
示例5: readEmptyCompoundProperties
void readEmptyCompoundProperties(const std::string &archiveName)
{
// Open an existing archive for reading. Indicate that we want
// Alembic to throw exceptions on errors.
AbcF::IFactory factory;
factory.setPolicy( ErrorHandler::kThrowPolicy );
AbcF::IFactory::CoreType coreType;
IArchive archive = factory.getArchive(archiveName, coreType);
IObject archiveTop = archive.getTop();
// Determine the number of (top level) children the archive has
const int numChildren = archiveTop.getNumChildren();
ABCA_ASSERT( numChildren == 2, "Wrong number of children (expected 2)");
std::cout << "The archive has " << numChildren << " children:"
<< std::endl;
// Iterate through them, print out their names
for (int ii=0; ii<numChildren; ii++)
{
IObject child( archiveTop, archiveTop.getChildHeader(ii).getName() );
std::cout << " " << child.getName();
std::cout << " has " << child.getNumChildren() << " children"
<< std::endl;
// Properties
ICompoundProperty props = child.getProperties();
int numProperties = props.getNumProperties();
std::cout << " ..and " << numProperties << " properties"
<< std::endl;
std::vector<std::string> propNames;
for (int pp=0; pp<numProperties; pp++)
propNames.push_back( props.getPropertyHeader(pp).getName() );
for (int jj=0; jj<numProperties; jj++)
{
std::cout << " ..named " << propNames[jj] << std::endl;
std::cout << " ..with type: ";
PropertyType pType = props.getPropertyHeader(jj).getPropertyType();
if (pType == kCompoundProperty)
{
std::cout << "compound" << std::endl;
}
else if (pType == kScalarProperty)
{
std::cout << "scalar" << std::endl;
}
else if (pType == kArrayProperty)
{
std::cout << "array" << std::endl;
}
}
}
// Done - the archive closes itself
}
示例6: readDeepHierarchy
void readDeepHierarchy(const std::string &archiveName)
{
// Open an existing archive for reading. Indicate that we want
// Alembic to throw exceptions on errors.
AbcF::IFactory factory;
factory.setPolicy( ErrorHandler::kThrowPolicy );
AbcF::IFactory::CoreType coreType;
IArchive archive = factory.getArchive(archiveName, coreType);
IObject archiveTop = archive.getTop();
// Determine the number of (top level) children the archive has
const unsigned int numChildren = archiveTop.getNumChildren();
std::cout << "The archive has " << numChildren << " children:"
<< std::endl;
ABCA_ASSERT( numChildren == 2,
"Expected 2 children, found " << numChildren );
// Iterate through them, print out their names
for (unsigned int ii=0; ii<numChildren; ii++)
{
IObject child( archiveTop, archiveTop.getChildHeader(ii).getName() );
std::cout << " " << child.getName();
recursivelyReadChildren( child );
}
// do it again to make sure we clean up after ourselves properly
IArchive archive2 = factory.getArchive(archiveName, coreType);
IObject archiveTop2 = archive2.getTop();
// Done - the archive closes itself
}
示例7: scopingTest
void scopingTest(bool useOgawa)
{
{
OObject top;
{
OArchive archive;
if (useOgawa)
{
archive = CreateArchiveWithInfo(
Alembic::AbcCoreOgawa::WriteArchive(),
"archiveScopeTest.abc",
"Alembic test", "", MetaData() );
}
else
{
archive = CreateArchiveWithInfo(
Alembic::AbcCoreHDF5::WriteArchive(),
"archiveScopeTest.abc",
"Alembic test", "", MetaData() );
}
top = archive.getTop();
}
OObject childA( top, "a");
OObject childB( top, "b");
ODoubleProperty prop(top.getProperties(), "prop", 0);
TESTING_ASSERT(prop.getObject().getArchive().getName() ==
"archiveScopeTest.abc");
}
{
IObject top;
{
AbcF::IFactory factory;
AbcF::IFactory::CoreType coreType;
IArchive archive = factory.getArchive("archiveScopeTest.abc",
coreType);
TESTING_ASSERT( (useOgawa && coreType == AbcF::IFactory::kOgawa) ||
(!useOgawa && coreType == AbcF::IFactory::kHDF5) );
top = archive.getTop();
double start, end;
GetArchiveStartAndEndTime( archive, start, end );
TESTING_ASSERT( start == DBL_MAX && end == -DBL_MAX );
}
TESTING_ASSERT(top.getNumChildren() == 2 );
TESTING_ASSERT(top.getChildHeader("a") != NULL);
TESTING_ASSERT(top.getChildHeader("b") != NULL);
TESTING_ASSERT( ! top.getParent().valid() );
TESTING_ASSERT( top.getArchive().getName() ==
"archiveScopeTest.abc");
IScalarProperty prop(top.getProperties(), "prop");
TESTING_ASSERT(prop.valid());
TESTING_ASSERT(prop.getObject().getArchive().getName() ==
"archiveScopeTest.abc");
}
}
示例8: getABCTimeSpan
//-*****************************************************************************
void getABCTimeSpan(IArchive archive, chrono_t& first, chrono_t& last)
{
// TO DO: Is the childBounds property reliable to get the full archive's span?
if (!archive.valid())
return;
IObject archiveTop = archive.getTop();
unsigned int numChildren = archiveTop.getNumChildren();
for (unsigned i=0; i<numChildren; ++i)
{
IObject obj( archiveTop.getChild( i ));
getObjectTimeSpan(obj, first, last, true);
}
}
示例9: simpleTestIn
//-*****************************************************************************
void simpleTestIn( const std::string &iArchiveName )
{
AbcF::IFactory factory;
factory.setPolicy( ErrorHandler::kThrowPolicy );
AbcF::IFactory::CoreType coreType;
IArchive archive = factory.getArchive(iArchiveName, coreType);
IObject archiveTop = archive.getTop();
TESTING_ASSERT( archiveTop.getNumChildren() == ( size_t )NUM_TOP_CHILDREN );
for ( int i = 0 ; i < NUM_TOP_CHILDREN ; i++ )
{
std::ostringstream strm;
strm << i;
std::string cname = strm.str();
IObject obj( archiveTop, cname );
readDeepHierarchy( obj, 0, obj );
}
TESTING_ASSERT( PATHS.size() == ( size_t ) NUM_TOP_CHILDREN );
}
示例10: readFlatHierarchy
void readFlatHierarchy(const std::string &archiveName)
{
// Open an existing archive for reading. Indicate that we want
// Alembic to throw exceptions on errors.
AbcF::IFactory factory;
factory.setPolicy( ErrorHandler::kThrowPolicy );
AbcF::IFactory::CoreType coreType;
IArchive archive = factory.getArchive(archiveName, coreType);
IObject archiveTop = archive.getTop();
// Determine the number of (top level) children the archive has
const int numChildren = archiveTop.getNumChildren();
ABCA_ASSERT( numChildren == 10,
"Expected 10 children, found " << numChildren );
std::cout << "The archive has " << numChildren << " children:"
<< std::endl;
// Iterate through them, print out their names
for (int ii=0; ii<numChildren; ii++)
{
IObject child( archiveTop,
archiveTop.getChildHeader(ii).getName() );
std::cout << " " << child.getName();
const unsigned int children = child.getNumChildren();
std::cout << " has " << children << " children"
<< std::endl;
ABCA_ASSERT( children == 0,
"Expected no children, found " << children );
}
// Done - the archive closes itself
}
示例11: readSimpleProperties
void readSimpleProperties(const std::string &archiveName)
{
// Open an existing archive for reading. Indicate that we want
// Alembic to throw exceptions on errors.
AbcF::IFactory factory;
factory.setPolicy( ErrorHandler::kThrowPolicy );
AbcF::IFactory::CoreType coreType;
IArchive archive = factory.getArchive(archiveName, coreType);
IObject archiveTop = archive.getTop();
// Determine the number of (top level) children the archive has
const int numChildren = archiveTop.getNumChildren();
TESTING_ASSERT( numChildren == 4 );
std::cout << "The archive has " << numChildren << " children:"
<< std::endl;
// Iterate through them, print out their names
for (int ii=0; ii<numChildren; ii++)
{
IObject child( archiveTop, archiveTop.getChildHeader( ii ).getName() );
std::cout << " " << child.getName();
std::cout << " has " << child.getNumChildren() << " children"
<< std::endl;
// Properties
ICompoundProperty props = child.getProperties();
int numProperties = props.getNumProperties();
std::cout << " ..and " << numProperties << " simple properties"
<< std::endl;
std::vector<std::string> propNames;
for (int pp=0; pp<numProperties; pp++)
propNames.push_back( props.getPropertyHeader(pp).getName() );
for (int jj=0; jj<numProperties; jj++)
{
std::cout << " ..named " << propNames[jj] << std::endl;
std::cout << " ..with type: ";
PropertyType pType = props.getPropertyHeader(jj).getPropertyType();
if (pType == kCompoundProperty)
{
std::cout << "compound" << std::endl;
}
else if (pType == kScalarProperty)
{
std::cout << "scalar" << std::endl;
}
else if (pType == kArrayProperty)
{
std::cout << "array" << std::endl;
}
DataType dType = props.getPropertyHeader(jj).getDataType();
std::cout << " ..with POD-type: ";
switch (dType.getPod())
{
case kBooleanPOD:
std::cout << "boolean" << std::endl;
break;
// Char/UChar
case kUint8POD:
std::cout << "unsigned char" << std::endl;
break;
case kInt8POD:
std::cout << "char" << std::endl;
break;
// Short/UShort
case kUint16POD:
std::cout << "short unsigned int" << std::endl;
break;
case kInt16POD:
std::cout << "short int" << std::endl;
break;
// Int/UInt
case kUint32POD:
std::cout << "unsigned int" << std::endl;
break;
case kInt32POD:
std::cout << "int" << std::endl;
break;
// Long/ULong
case kUint64POD:
std::cout << "unsigned long int" << std::endl;
break;
case kInt64POD:
std::cout << "long int" << std::endl;
break;
// Half/Float/Double
case kFloat16POD:
std::cout << "half" << std::endl;
break;
//.........这里部分代码省略.........
示例12: errorHandlerTest
void errorHandlerTest(bool useOgawa)
{
{
OArchive archive;
if (useOgawa)
{
archive = OArchive( Alembic::AbcCoreOgawa::WriteArchive(),
"throwTest.abc", ErrorHandler::kThrowPolicy );
}
else
{
archive = OArchive( Alembic::AbcCoreHDF5::WriteArchive(),
"throwTest.abc", ErrorHandler::kThrowPolicy );
}
OObject archiveTop = archive.getTop();
ABCA_ASSERT( archiveTop.getErrorHandler().getPolicy() ==
ErrorHandler::kThrowPolicy, "Error: Not kThrowPolicy" );
OObject childQuiet(archiveTop, "childQuiet",
ErrorHandler::kQuietNoopPolicy );
OObject childNoisy(archiveTop, "childNoisy",
ErrorHandler::kNoisyNoopPolicy );
OObject grandchildQuiet(childQuiet, "grandchildQuiet" );
OObject grandchildNoisy(childNoisy, "grandchildNoisy" );
ABCA_ASSERT( childQuiet.getErrorHandler().getPolicy() ==
ErrorHandler::kQuietNoopPolicy, "Error: Not kQuietNoopPolicy" );
ABCA_ASSERT( childNoisy.getErrorHandler().getPolicy() ==
ErrorHandler::kNoisyNoopPolicy, "Error: Not kNoisyNoopPolicy" );
ABCA_ASSERT( grandchildQuiet.getErrorHandler().getPolicy() ==
ErrorHandler::kQuietNoopPolicy, "Error: Not kQuietNoopPolicy" );
ABCA_ASSERT( grandchildNoisy.getErrorHandler().getPolicy() ==
ErrorHandler::kNoisyNoopPolicy, "Error: Not kNoisyNoopPolicy" );
}
{
AbcF::IFactory factory;
factory.setPolicy( ErrorHandler::kThrowPolicy );
AbcF::IFactory::CoreType coreType;
IArchive archive = factory.getArchive("throwTest.abc", coreType);
IObject archiveTop = archive.getTop();
ABCA_ASSERT( archiveTop.getErrorHandler().getPolicy() ==
ErrorHandler::kThrowPolicy, "Error: Not kThrowPolicy" );
IObject childQuiet(archiveTop, "childQuiet",
ErrorHandler::kQuietNoopPolicy );
IObject childNoisy(archiveTop, "childNoisy",
ErrorHandler::kNoisyNoopPolicy );
IObject grandchildQuiet(childQuiet, "grandchildQuiet" );
IObject grandchildNoisy(childNoisy, "grandchildNoisy" );
ABCA_ASSERT( childQuiet.getErrorHandler().getPolicy() ==
ErrorHandler::kQuietNoopPolicy, "Error: Not kQuietNoopPolicy" );
ABCA_ASSERT( childNoisy.getErrorHandler().getPolicy() ==
ErrorHandler::kNoisyNoopPolicy, "Error: Not kNoisyNoopPolicy" );
ABCA_ASSERT( grandchildQuiet.getErrorHandler().getPolicy() ==
ErrorHandler::kQuietNoopPolicy, "Error: Not kQuietNoopPolicy" );
ABCA_ASSERT( grandchildNoisy.getErrorHandler().getPolicy() ==
ErrorHandler::kNoisyNoopPolicy, "Error: Not kNoisyNoopPolicy" );
}
}
示例13: main
//-*****************************************************************************
//-*****************************************************************************
// DO IT.
//-*****************************************************************************
//-*****************************************************************************
int main( int argc, char *argv[] )
{
if (argc < 4)
{
std::cerr << "USAGE: " << argv[0] << " outFile.abc inFile1.abc"
<< " inFile2.abc (inFile3.abc ...)" << std::endl;
return -1;
}
{
size_t numInputs = argc - 2;
std::vector< chrono_t > minVec;
minVec.reserve(numInputs);
std::vector< IArchive > iArchives;
iArchives.reserve(numInputs);
std::map< chrono_t, size_t > minIndexMap;
size_t rootChildren = 0;
Alembic::AbcCoreFactory::IFactory factory;
factory.setPolicy(ErrorHandler::kThrowPolicy);
Alembic::AbcCoreFactory::IFactory::CoreType coreType;
for (int i = 2; i < argc; ++i)
{
IArchive archive = factory.getArchive(argv[i], coreType);
if (!archive.valid() || archive.getTop().getNumChildren() < 1)
{
std::cerr << "ERROR: " << argv[i] <<
" not a valid Alembic file" << std::endl;
return 1;
}
IObject iRoot = archive.getTop();
size_t numChildren = iRoot.getNumChildren();
if (i == 2)
{
rootChildren = numChildren;
}
else if (rootChildren != numChildren)
{
std::cerr << "ERROR: " << argv[i] <<
" doesn't have the same number of children as: " <<
argv[i-1] << std::endl;
}
// reorder the input files according to their mins
chrono_t min = DBL_MAX;
Alembic::Util::uint32_t numSamplings = archive.getNumTimeSamplings();
if (numSamplings > 1)
{
// timesampling index 0 is special, so it will be skipped
//
// make sure all the other timesampling objects start at
// the same time or throw here
//
min = archive.getTimeSampling(1)->getSampleTime(0);
for (Alembic::Util::uint32_t s = 2; s < numSamplings; ++s)
{
chrono_t thisMin =
archive.getTimeSampling(s)->getSampleTime(0);
if (fabs(thisMin - min) > 1e-5)
{
std::cerr << "ERROR: " << argv[i]
<< " has non-default TimeSampling objects"
<< " that don't start at the same time."
<< std::endl;
return 1;
}
}
minVec.push_back(min);
if (minIndexMap.count(min) == 0)
{
minIndexMap.insert(std::make_pair(min, i-2));
}
else if (argv[2] != argv[i])
{
std::cerr << "ERROR: overlapping frame range between "
<< argv[2] << " and " << argv[i] << std::endl;
return 1;
}
}
else
{
std::cerr << "ERROR: " << archive.getName() <<
" only has default (static) TimeSampling." << std::endl;
return 1;
}
//.........这里部分代码省略.........
示例14: simpleTestIn
//-*****************************************************************************
void simpleTestIn( const std::string& iArchiveName )
{
AbcF::IFactory factory;
factory.setPolicy( ErrorHandler::kThrowPolicy );
AbcF::IFactory::CoreType coreType;
IArchive archive = factory.getArchive( iArchiveName, coreType );
/*
x1
/ | \
x2 x3 x2a (x2a is an instance targeting x2)
| |
x4 x5 (x5 is an instance targeting x4)
/ |
g1 g2
|
g5
*/
// an archive has a single top object which contains all its children
IObject topObject = archive.getTop();
IObject x1( topObject, "x1" );
TESTING_ASSERT( x1 != 0 );
//
// Verify the target path
IObject x2( x1, "x2" );
TESTING_ASSERT( x2.valid() );
TESTING_ASSERT( !x2.isInstanceDescendant() );
IObject x4( x2, "x4" );
TESTING_ASSERT( x4.valid() );
TESTING_ASSERT( !x4.isInstanceDescendant() );
int numChildren = x4.getNumChildren();
TESTING_ASSERT( numChildren == 2 );
TESTING_ASSERT( x4.getParent().getFullName() == x2.getFullName() );
IObject g1( x4.getChild(0) );
TESTING_ASSERT( g1 != 0 );
TESTING_ASSERT( g1.getName() == "g1" );
TESTING_ASSERT( !g1.isInstanceDescendant() );
TESTING_ASSERT( g1.getParent() != 0 );
TESTING_ASSERT( g1.getParent().getFullName() == x4.getFullName() );
IObject g2( x4.getChild(1) );
TESTING_ASSERT( g2 != 0 );
TESTING_ASSERT( g2.getName() == "g2" );
TESTING_ASSERT( !g2.isInstanceDescendant() );
TESTING_ASSERT( g2.getParent() != 0 );
TESTING_ASSERT( g2.getParent().getFullName() == x4.getFullName() );
IObject g5( g2.getChild(0) );
TESTING_ASSERT( g5 != 0 );
TESTING_ASSERT( g5.getName() == "g5" );
TESTING_ASSERT( !g5.isInstanceDescendant() );
TESTING_ASSERT( g5.getParent() != 0 );
TESTING_ASSERT( g5.getParent().getFullName() == g2.getFullName() );
//
// Verify the instance path
IObject x3( x1, "x3" );
TESTING_ASSERT( x3 != 0 );
IObject x5( x3, "x5" );
TESTING_ASSERT( x5 != 0 );
TESTING_ASSERT( x5.isInstanceDescendant() );
TESTING_ASSERT( x5.isInstanceRoot() );
TESTING_ASSERT( x5.instanceSourcePath() == x4.getFullName() );
numChildren = x5.getNumChildren();
TESTING_ASSERT( numChildren == 2 );
TESTING_ASSERT( x5.getParent().getFullName() == x3.getFullName() );
IObject g1p( x5.getChild(0) );
TESTING_ASSERT( g1p != 0 );
TESTING_ASSERT( g1p.getName() == "g1" );
TESTING_ASSERT( g1p.isInstanceDescendant() );
TESTING_ASSERT( !g1p.isInstanceRoot() );
TESTING_ASSERT( g1p.getParent() != 0 );
TESTING_ASSERT( g1p.getParent().getFullName() == x5.getFullName() );
IObject g2p( x5.getChild(1) );
TESTING_ASSERT( g2p != 0 );
TESTING_ASSERT( g2p.getName() == "g2" );
TESTING_ASSERT( g2p.isInstanceDescendant() );
TESTING_ASSERT( !g2p.isInstanceRoot() );
TESTING_ASSERT( g2p.getParent() != 0 );
TESTING_ASSERT( g2p.getParent().getFullName() == x5.getFullName() );
IObject g5p( g2p.getChild(0) );
TESTING_ASSERT( g5p != 0 );
TESTING_ASSERT( g5p.getName() == "g5" );
TESTING_ASSERT( g5p.isInstanceDescendant() );
TESTING_ASSERT( !g5p.isInstanceRoot() );
TESTING_ASSERT( g5p.getParent() != 0 );
//.........这里部分代码省略.........
示例15: create_geometry
/*virtual*/
void ABCReadGeo::create_geometry(Scene& scene, GeometryList& out)
{
if (filename()[0] == '\0') {
out.delete_objects();
return;
}
IArchive archive( Alembic::AbcCoreHDF5::ReadArchive(),
filename(),//archiveName,
Abc::ErrorHandler::kQuietNoopPolicy );
if (!archive.valid()) {
std::cout << "error reading archive" << std::endl;
error("Unable to read file");
return;
}
IObject archiveTop = archive.getTop();
std::vector<Alembic::AbcGeom::IObject> _objs;
getABCGeos(archiveTop, _objs);
// current Time to sample from
chrono_t curTime = m_sampleFrame / _FPS;
if ( rebuild(Mask_Primitives)) {
out.delete_objects();
}
int obj = 0;
for( std::vector<Alembic::AbcGeom::IObject>::const_iterator iObj( _objs.begin() ); iObj != _objs.end(); ++iObj ) {
// Leave an empty obj if knob is unchecked
if (!active_objs[obj] ) {
out.add_object(obj);
PointList& points = *out.writable_points(obj);
points.resize(0);
out[obj].delete_group_attribute(Group_Vertices,kUVAttrName, VECTOR4_ATTRIB);
obj++;
continue;
}
if ( rebuild(Mask_Primitives)) {
out.add_object(obj);
if (bbox_objs[obj]) { //(bbox_mode) {
buildBboxPrimitives(out, obj);
}
else {
buildABCPrimitives(out, obj, *iObj, curTime);
}
}
if ( rebuild(Mask_Points)) {
PointList& points = *out.writable_points(obj);
if (bbox_objs[obj]) { //(bbox_mode) {
Imath::Box3d bbox = getBounds(*iObj, curTime);
points.resize(8);
IObject iObj_copy(*iObj);
Matrix4 xf = getConcatMatrix(iObj_copy,curTime, interpolate !=0); // for some reason getParent() won't take a const IObject, hence the copy...
// Add bbox corners
for (unsigned i = 0; i < 8; i++) {
Vector3 pt((i&4)>>2 ? bbox.max.x : bbox.min.x, (i&2)>>1 ? bbox.max.y : bbox.min.y, (i%2) ? bbox.max.z : bbox.min.z );
points[i] = xf.transform(pt);
}
}
else{
writePoints(*iObj, points, curTime, interpolate !=0);
}
}
if ( rebuild(Mask_Attributes)) {
if (bbox_objs[obj]) { //(bbox_mode)
out[obj].delete_group_attribute(Group_Vertices,kUVAttrName, VECTOR4_ATTRIB);
}
else {
// set UVs
Attribute* UV = out.writable_attribute(obj, Group_Vertices, kUVAttrName, VECTOR4_ATTRIB);
IV2fGeomParam uvParam = getUVsParam(*iObj);
setUVs(out[obj], uvParam, UV, curTime);
// set Normals
IN3fGeomParam nParam = getNsParam(*iObj);
if (nParam.valid()) {
//.........这里部分代码省略.........