本文整理汇总了C++中IObject::getNumChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ IObject::getNumChildren方法的具体用法?C++ IObject::getNumChildren怎么用?C++ IObject::getNumChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IObject
的用法示例。
在下文中一共展示了IObject::getNumChildren方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: recursivelyReadChildren
void recursivelyReadChildren( IObject& parent )
{
unsigned int numChildren = parent.getNumChildren();
std::cout << " has " << numChildren << " children"
<< std::endl;
for (unsigned int ii=0; ii<numChildren; ii++)
{
IObject child = parent.getChild(ii);
std::cout << " " << child.getName();
unsigned int expectedChildren = 2;
if (child.getName().substr(6,1) == "2")
// bottom of the hierarchy
expectedChildren = 0;
unsigned int children = child.getNumChildren();
ABCA_ASSERT( children == expectedChildren,
"Expected " << expectedChildren << " children " <<
"but found " << children );
recursivelyReadChildren( child );
}
return;
}
示例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: readFlatHierarchy
void readFlatHierarchy(const std::string &archiveName)
{
// Open an existing archive for reading. Indicate that we want
// Alembic to throw exceptions on errors.
IArchive archive( Alembic::AbcCoreHDF5::ReadArchive(),
archiveName, ErrorHandler::kThrowPolicy );
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
}
示例5: 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
}
示例6: 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
}
示例7: getObjectTimeSpan
void getObjectTimeSpan(IObject obj, chrono_t& first, chrono_t& last, bool doChildren)
{
if ( Alembic::AbcGeom::IPolyMesh::matches(obj.getHeader()) ) {
IPolyMesh iPoly(obj, Alembic::Abc::kWrapExisting);
getPolyMeshTimeSpan(iPoly, first, last);
}
else if ( Alembic::AbcGeom::ISubD::matches(obj.getHeader()) ) {
ISubD iSub(obj, Alembic::Abc::kWrapExisting);
getSubDTimeSpan(iSub, first, last);
}
else if ( Alembic::AbcGeom::IXform::matches(obj.getHeader()) ) {
IXform iXf(obj, Alembic::Abc::kWrapExisting);
getXformTimeSpan(iXf, first, last, false);
}
else if ( Alembic::AbcGeom::ICamera::matches(obj.getHeader()) ) {
ICamera iCam(obj, Alembic::Abc::kWrapExisting);
getCameraTimeSpan(iCam, first, last);
}
if (doChildren) {
// do this object's children too
for (unsigned i=0; i < obj.getNumChildren(); ++i)
{
IObject child( obj.getChild( i ));
getObjectTimeSpan(child, first, last, doChildren);
}
}
}
示例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();
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);
}
}
示例9: 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");
}
}
示例10: visitObject
//-*****************************************************************************
void visitObject( IObject iObj )
{
std::string path = iObj.getFullName();
const MetaData &md = iObj.getMetaData();
if ( IPolyMeshSchema::matches( md ) || ISubDSchema::matches( md ) )
{
Box3d bnds = getBounds( iObj );
std::cout << path << " " << bnds.min << " " << bnds.max << std::endl;
}
// now the child objects
for ( size_t i = 0 ; i < iObj.getNumChildren() ; i++ )
{
visitObject( IObject( iObj, iObj.getChildHeader( i ).getName() ) );
}
}
示例11: simpleTestIn
//-*****************************************************************************
void simpleTestIn( const std::string &iArchiveName )
{
IArchive archive( Alembic::AbcCoreHDF5::ReadArchive(),
iArchiveName, ErrorHandler::kThrowPolicy );
IObject archiveTop = archive.getTop();
TESTING_ASSERT( archiveTop.getNumChildren() == NUM_TOP_CHILDREN );
for ( int i = 0 ; i < NUM_TOP_CHILDREN ; i++ )
{
std::string cname = boost::lexical_cast<std::string>( i );
IObject obj( archiveTop, cname );
readDeepHierarchy( obj, 0, obj );
}
TESTING_ASSERT( PATHS.size() == NUM_TOP_CHILDREN );
}
示例12: 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);
}
}
示例13: getNamedCamera
bool getNamedCamera( IObject iObjTop, const std::string &iName, ICamera &iCam )
{
// Return true if found
const Alembic::AbcGeom::MetaData &md = iObjTop.getMetaData();
if ( (iObjTop.getName() == iName) && (ICamera::matches( md )) )
{
iCam = ICamera(iObjTop, kWrapExisting );
return true;
}
// now the child objects
for ( size_t i = 0 ; i < iObjTop.getNumChildren() ; i++ )
{
if (getNamedCamera(IObject( iObjTop, iObjTop.getChildHeader( i ).getName() ), iName, iCam ))
return true;
}
return false;
}
示例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);
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 );
}
示例15: visitObject
//-*****************************************************************************
void visitObject( IObject iObj,
std::string iIndent )
{
// Object has a name, a full name, some meta data,
// and then it has a compound property full of properties.
std::string path = iObj.getFullName();
if ( path != "/" )
{
std::cout << "Object " << "name=" << path << std::endl;
}
// Get the properties.
ICompoundProperty props = iObj.getProperties();
visitProperties( props, iIndent );
// now the child objects
for ( size_t i = 0 ; i < iObj.getNumChildren() ; i++ )
{
visitObject( IObject( iObj, iObj.getChildHeader( i ).getName() ),
iIndent );
}
}