• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ abccorefactory::IFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中alembic::abccorefactory::IFactory的典型用法代码示例。如果您正苦于以下问题:C++ IFactory类的具体用法?C++ IFactory怎么用?C++ IFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了IFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: 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
}
开发者ID:BlackGinger,项目名称:ExocortexCrate,代码行数:35,代码来源:ObjectTests.cpp


示例2: 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

}
开发者ID:BlackGinger,项目名称:ExocortexCrate,代码行数:60,代码来源:PropertyTests.cpp


示例3: 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");
    }
}
开发者ID:BlackGinger,项目名称:ExocortexCrate,代码行数:58,代码来源:ArchiveTest.cpp


示例4: archiveInfoTest

void archiveInfoTest(bool useOgawa)
{
    std::string appWriter = "Alembic unit tests";
    std::string userStr = "abcdefg";
    {
        Alembic::AbcCoreAbstract::MetaData md;
        md.set("potato", "salad");
        md.set("taco", "bar");
        OArchive archive;
        if (useOgawa)
        {
            archive = CreateArchiveWithInfo(
                Alembic::AbcCoreOgawa::WriteArchive(), "archiveInfo.abc",
                appWriter, userStr, md );
        }
        else
        {
            archive = CreateArchiveWithInfo(
                Alembic::AbcCoreHDF5::WriteArchive(), "archiveInfo.abc",
                appWriter, userStr, md );
        }

        TESTING_ASSERT( archive.getPtr()->getMetaData().get("taco") == "bar" );
    }

    {
        AbcF::IFactory factory;
        AbcF::IFactory::CoreType coreType;
        IArchive archive = factory.getArchive("archiveInfo.abc", coreType);
        TESTING_ASSERT( (useOgawa && coreType == AbcF::IFactory::kOgawa) ||
                        (!useOgawa && coreType == AbcF::IFactory::kHDF5) );

        TESTING_ASSERT( archive.getPtr()->getMetaData().get("taco") == "bar" );
        TESTING_ASSERT( archive.getPtr()->getMetaData().get("potato") ==
            "salad" );
        TESTING_ASSERT( archive.getArchiveVersion() ==
                        ALEMBIC_LIBRARY_VERSION );

        std::string appInfo;
        std::string abcVersionStr;
        Alembic::Util::uint32_t abcVersion = 0;
        std::string dateWritten;
        std::string userInfo;
        GetArchiveInfo( archive, appInfo, abcVersionStr, abcVersion,
            dateWritten, userInfo );
        TESTING_ASSERT( appWriter ==  appInfo );
        TESTING_ASSERT( userStr ==  userInfo );
        TESTING_ASSERT( abcVersion ==  ALEMBIC_LIBRARY_VERSION );
        std::cout << "Alembic version: " << abcVersionStr << std::endl;
        std::cout << "Date written: " << dateWritten << std::endl;
        TESTING_ASSERT( dateWritten != "" );
        TESTING_ASSERT( abcVersionStr != "" );

        double start, end;
        GetArchiveStartAndEndTime( archive, start, end );
        TESTING_ASSERT( start == DBL_MAX && end == -DBL_MAX );
    }
}
开发者ID:BlackGinger,项目名称:ExocortexCrate,代码行数:58,代码来源:ArchiveTest.cpp


示例5: 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 );
    }
}
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:56,代码来源:ObjectTests.cpp


示例6: IObject

//-*****************************************************************************
// SCENE CLASS
//-*****************************************************************************
Scene::Scene( const std::string &fileName, bool verbose )
  : m_fileName( fileName )
  , m_minTime( ( chrono_t )FLT_MAX )
  , m_maxTime( ( chrono_t )-FLT_MAX )
{
    Timer playbackTimer;

    Alembic::AbcCoreFactory::IFactory factory;
    m_archive = factory.getArchive( fileName );

    m_topObject = IObject( m_archive, kTop );

    if ( verbose )
        std::cout << "Opened archive and top object, creating drawables."
                  << std::endl;

    m_drawable.reset( new IObjectDrw( m_topObject, false ) );
    ABCA_ASSERT( m_drawable->valid(),
                 "Invalid drawable for archive: " << fileName );

    if ( verbose )
        std::cout << "Created drawables, getting time range." << std::endl;
    
    m_minTime = m_drawable->getMinTime();
    m_maxTime = m_drawable->getMaxTime();

    if ( m_minTime <= m_maxTime ) {
        if ( verbose )
            std::cout << "\nMin Time: " << m_minTime << " seconds " << std::endl
                      << "Max Time: " << m_maxTime << " seconds " << std::endl
                      << "\nLoading min time." << std::endl;
        m_drawable->setTime( m_minTime );
    }
    else {
        if ( verbose )
            std::cout << "\nConstant Time." << std::endl
                      << "\nLoading constant sample." << std::endl;
        m_minTime = m_maxTime = 0.0;
        m_drawable->setTime( 0.0 );
    }

    ABCA_ASSERT( m_drawable->valid(),
                 "Invalid drawable after reading start time" );

    if ( verbose )
        std::cout << "Done opening archive. Elapsed CPU time: "
                  << ((float)playbackTimer.elapsed()) / CLOCKS_PER_SEC << " seconds." << std::endl;

    // Bounds have been formed!
    m_bounds = m_drawable->getBounds();
    
    if ( verbose )
        std::cout << "Bounds at min time: " << m_bounds.min << " to "
                  << m_bounds.max << std::endl;
}
开发者ID:hallLong,项目名称:bb_alembic,代码行数:58,代码来源:Scene.cpp


示例7: 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 );
    }
}
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:53,代码来源:ObjectTests.cpp


示例8: Exception

AlembicInput::AlembicInput( const std::string &fileName )
{
	m_data = boost::shared_ptr<DataMembers>( new DataMembers );
	
#ifdef IECOREALEMBIC_WITH_OGAWA
	Alembic::AbcCoreFactory::IFactory factory;
	m_data->archive = boost::shared_ptr<IArchive>( new IArchive( factory.getArchive( fileName ) ) );
	if( !m_data->archive->valid() )
	{
		// even though the default policy for IFactory is kThrowPolicy, this appears not to
		// be applied when it fails to load an archive - instead it returns an invalid archive.
		throw IECore::Exception( boost::str( boost::format( "Unable to open file \"%s\"" ) % fileName ) );
	}
#else
	m_data->archive = boost::shared_ptr<IArchive>( new IArchive( ::Alembic::AbcCoreHDF5::ReadArchive(), fileName ) );
#endif
	
	m_data->object = m_data->archive->getTop();
}
开发者ID:AtomicFiction,项目名称:cortex,代码行数:19,代码来源:AlembicInput.cpp


示例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 );
}
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:23,代码来源:RedundantDataTest.cpp


示例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
}
开发者ID:BlackGinger,项目名称:ExocortexCrate,代码行数:36,代码来源:ObjectTests.cpp


示例11: compute

MStatus AlembicNode::compute(const MPlug & plug, MDataBlock & dataBlock)
{
    MStatus status;

    // update the frame number to be imported
    MDataHandle speedHandle = dataBlock.inputValue(mSpeedAttr, &status);
    double speed = speedHandle.asDouble();

    MDataHandle offsetHandle = dataBlock.inputValue(mOffsetAttr, &status);
    double offset = offsetHandle.asDouble();

    MDataHandle timeHandle = dataBlock.inputValue(mTimeAttr, &status);
    MTime t = timeHandle.asTime();
    double inputTime = t.as(MTime::kSeconds);

    double fps = getFPS();

    // scale and offset inputTime.
    inputTime = computeAdjustedTime(inputTime, speed, offset/fps);

    // this should be done only once per file
	if (mFileInitialized == false)
	{
		mFileInitialized = true;

		//Get list of input filenames
		MFnDependencyNode depNode(thisMObject());
		MPlug layerFilesPlug = depNode.findPlug("abc_layerFiles");
		MFnStringArrayData fnSAD( layerFilesPlug.asMObject() );
		MStringArray storedFilenames = fnSAD.array();

		//Legacy support for single-filename input
		if( storedFilenames.length() == 0 )
		{
			MFileObject fileObject;
			MDataHandle dataHandle = dataBlock.inputValue(mAbcFileNameAttr);
			fileObject.setRawFullName(dataHandle.asString());
			MString fileName = fileObject.resolvedFullName();
			storedFilenames.append( fileName );
		}

		std::vector<std::string> abcFilenames;
		for(unsigned int i = 0; i < storedFilenames.length(); i++)
			abcFilenames.push_back( storedFilenames[i].asChar() );

		Alembic::Abc::IArchive archive;
		Alembic::AbcCoreFactory::IFactory factory;
		factory.setPolicy(Alembic::Abc::ErrorHandler::kQuietNoopPolicy);

		archive = factory.getArchive( abcFilenames );

		if (!archive.valid())
		{
			MString theError = "Error opening these alembic files: ";

			const unsigned int numFilenames = storedFilenames.length();
			for( unsigned int i = 0; i < numFilenames; i++ )
			{
				theError += storedFilenames[ i ];

				if( i != (numFilenames - 1) )
					theError += ", ";
			}

			printError(theError);
		}

		// initialize some flags for plug update
		mSubDInitialized = false;
		mPolyInitialized = false;

		// When an alembic cache will be imported at the first time using
		// AbcImport, we need to set mIncludeFilterAttr (filterHandle) to be
		// mIncludeFilterString for later use. When we save a maya scene(.ma)
		// mIncludeFilterAttr will be saved. Then when we load the saved
		// .ma file, mIncludeFilterString will be set to be mIncludeFilterAttr.
		MDataHandle includeFilterHandle =
						dataBlock.inputValue(mIncludeFilterAttr, &status);
		MString& includeFilterString = includeFilterHandle.asString();

	   if (mIncludeFilterString.length() > 0)
		{
			includeFilterHandle.set(mIncludeFilterString);
			dataBlock.setClean(mIncludeFilterAttr);
		}
		else if (includeFilterString.length() > 0)
		{
			mIncludeFilterString = includeFilterString;
		}

		MDataHandle excludeFilterHandle =
						dataBlock.inputValue(mExcludeFilterAttr, &status);
		MString& excludeFilterString = excludeFilterHandle.asString();

	   if (mExcludeFilterString.length() > 0)
		{
			excludeFilterHandle.set(mExcludeFilterString);
			dataBlock.setClean(mExcludeFilterAttr);
		}
		else if (excludeFilterString.length() > 0)
//.........这里部分代码省略.........
开发者ID:poparteu,项目名称:alembic,代码行数:101,代码来源:AlembicNode.cpp


示例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" );
    }
}
开发者ID:BlackGinger,项目名称:ExocortexCrate,代码行数:64,代码来源:ObjectTests.cpp


示例13: readV3fArrayProperty

void readV3fArrayProperty(const std::string &archiveName, bool useOgawa)
{
    // Open an existing archive for reading. Indicate that we want
    //   Alembic to throw exceptions on errors.
    std::cout  << "Reading " << archiveName << std::endl;
    AbcF::IFactory factory;
    factory.setPolicy(  ErrorHandler::kThrowPolicy );
    AbcF::IFactory::CoreType coreType;
    IArchive archive = factory.getArchive(archiveName, coreType);
    TESTING_ASSERT( (useOgawa && coreType == AbcF::IFactory::kOgawa) ||
                    (!useOgawa && coreType == AbcF::IFactory::kHDF5) );

    IObject archiveTop = archive.getTop();

    // Determine the number of (top level) children the archive has
    const unsigned int numChildren =  archiveTop.getNumChildren();
    ABCA_ASSERT( numChildren == 1, "Wrong number of children (expected 1)");
    std::cout << "The archive has " << numChildren << " children:"
              << std::endl;

    // Iterate through them, print out their names
    IObject child( archiveTop, archiveTop.getChildHeader(0).getName() );
    std::cout << "  named '" << child.getName() << "'";

    // Properties
    ICompoundProperty props = child.getProperties();
    size_t numProperties = props.getNumProperties();  // only top-level props
    ABCA_ASSERT( numProperties == 1,
                 "Expected 1 property, found " << numProperties);
    std::cout << " with one property";

    std::vector<std::string> propNames(1);
    propNames[0] = props.getPropertyHeader(0).getName();
    std::cout << " named '" << propNames[0] << "'" << std::endl;


    PropertyType pType = props.getPropertyHeader(0).getPropertyType();
    ABCA_ASSERT( pType == kArrayProperty,
                 "Expected an array property, but didn't find one" );

    std::cout << " which is an array property";

    DataType dType = props.getPropertyHeader(0).getDataType();
    ABCA_ASSERT( dType.getPod() == kFloat32POD,
                 "Expected an v3f property, but didn't find one" );


    // We know this is an array property (I'm eliding the if/else
    //  statements required to recognize and handle this properly)
    IV3fArrayProperty positions( props, propNames[0] );
    size_t numSamples = positions.getNumSamples();
    std::cout << ".. it has " << numSamples << " samples" << std::endl;
    ABCA_ASSERT( numSamples == 5, "Expected 5 samples, found " << numSamples );

    TimeSamplingPtr ts = positions.getTimeSampling();
    std::cout << "..with time/value pairs: " << std::endl;;
    for (unsigned int ss=0; ss<numSamples; ss++)
    {
        std::cout << "   ";
        ISampleSelector iss( (index_t) ss);
        std::cout << ts->getSampleTime( (index_t) ss ) << " / ";

        V3fArraySamplePtr samplePtr;
        positions.get( samplePtr, iss );
        std::cout << "[ ";
        size_t numPoints = samplePtr->size();
        for ( size_t jj=0 ; jj<numPoints ; jj++ )
            std::cout << (*samplePtr)[jj] << " ";
        std::cout << "]" << std::endl;

        if (ss == 2) // no entries in sample #2
        {
            ABCA_ASSERT( numPoints == 0,
                         "Expected an empty sample, but found " << numPoints
                         << " entries." );
        }
        else
        {
            for ( size_t jj=0 ; jj<numPoints ; jj++ )
                ABCA_ASSERT( (*samplePtr)[jj] == g_vectors[jj],
                             "Incorrect value read from archive." );
        }

    }
    ABCA_ASSERT(
        archive.getMaxNumSamplesForTimeSamplingIndex(1) == (index_t) numSamples,
        "Incorrect number of max samples in readV3fArrayProperty." );
    std::cout << std::endl;
    // Done - the archive closes itself

    double start, end;
    GetArchiveStartAndEndTime( archive, start, end );

    TESTING_ASSERT( almostEqual(start, 123.0) );
    TESTING_ASSERT( almostEqual(end, 123.0 + 4.0 / 24.0) );
}
开发者ID:BlackGinger,项目名称:ExocortexCrate,代码行数:96,代码来源:ArrayPropertyTest.cpp


示例14: replaceTest

//-*****************************************************************************
void replaceTest()
{
    std::string fileName = "objectReplace1.abc";
    std::string fileName2 = "objectReplace2.abc";
    {
        OArchive archive( Alembic::AbcCoreOgawa::WriteArchive(), fileName );
        OObject child( archive.getTop(), "child" );

        OObject childCool( child, "cool" );
        OObject childCooler( childCool, "cooler" );

        OObject childGuy( child, "guy" );
        OObject childGuyA( childGuy, "A" );

        OObject childA( archive.getTop(), "childA" );
        OObject childAA( childA, "A" );

        OObject childB( archive.getTop(), "childB" );
        OObject childBB( childB, "B" );
    }

    {
        MetaData md;
        Alembic::AbcCoreLayer::SetReplace( md, true );

        OArchive archive( Alembic::AbcCoreOgawa::WriteArchive(), fileName2 );
        OObject child( archive.getTop(), "child" );
        OObject childGuy( child, "guy", md );

        OObject childCool( child, "cool", md );
        OObject childCoolA( childCool, "A" );
        OObject childCoolB( childCool, "B", md );

        OObject childA( archive.getTop(), "childA", md );

        OObject childB( archive.getTop(), "childB", md );
        OObject childBA( childB, "A", md );
        OObject childBC( childB, "C", md );
        OObject childBCA( childBC, "A", md );
    }

    {
        std::vector< std::string > files;
        files.push_back( fileName );
        files.push_back( fileName2 );

        Alembic::AbcCoreFactory::IFactory factory;
        IArchive archive = factory.getArchive( files );

        IObject root = archive.getTop();

        // child, childA, childB
        TESTING_ASSERT( root.getNumChildren() == 3 );

        IObject child( root, "child" );
        TESTING_ASSERT( child.getNumChildren() == 2 );
        TESTING_ASSERT( IObject( child, "cool" ).valid() );
        TESTING_ASSERT( IObject( child, "guy" ).valid() );
        TESTING_ASSERT( IObject( child, "cool" ).getNumChildren() == 2 );
        TESTING_ASSERT( IObject( child, "guy" ).getNumChildren() == 0 );

        IObject childCool( child, "cool" );
        TESTING_ASSERT( IObject( childCool, "A" ).valid() );
        TESTING_ASSERT( IObject( childCool, "A" ).getNumChildren() == 0 );
        TESTING_ASSERT( IObject( childCool, "B" ).valid() );
        TESTING_ASSERT( IObject( childCool, "B" ).getNumChildren() == 0 );

        IObject childA( root, "childA" );
        TESTING_ASSERT( childA.getNumChildren() == 0 );

        IObject childB( root, "childB" );
        TESTING_ASSERT( childB.getNumChildren() == 2 );
        TESTING_ASSERT( IObject( childB, "A" ).valid() );
        TESTING_ASSERT( IObject( childB, "C" ).valid() );
        TESTING_ASSERT( IObject( childB, "A" ).getNumChildren() == 0 );
        TESTING_ASSERT( IObject( childB, "C" ).getNumChildren() == 1 );

        IObject childBC( childB, "C" );
        TESTING_ASSERT( IObject( childBC, "A" ).valid() );
        TESTING_ASSERT( IObject( childBC, "A" ).getNumChildren() == 0 );
    }
}
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:83,代码来源:ObjectTests.cpp


示例15: emptyAndValueTest

void emptyAndValueTest(const std::string &archiveName, bool useOgawa)
{
    std::vector<std::string> strVec;
    strVec.push_back( "potato" );

    std::vector<C3f> colorVec;
    colorVec.push_back( C3f( 0.0, 0.5, 0.75 ) );

    std::vector<Alembic::Util::int32_t> intVec;
    intVec.push_back(42);

    StringArraySample strSamp( strVec );
    C3fArraySample colorSamp( colorVec );
    Int32ArraySample intSamp( intVec );

    StringArraySample emptyStrSamp = StringArraySample::emptySample();
    C3fArraySample emptyColorSamp = C3fArraySample::emptySample();
    Int32ArraySample emptyIntSamp = Int32ArraySample::emptySample();

    {
        OArchive archive;
        if (useOgawa)
        {
            archive = OArchive( Alembic::AbcCoreOgawa::WriteArchive(),
                archiveName );
        }
        else
        {
            archive = OArchive( Alembic::AbcCoreHDF5::WriteArchive(),
                archiveName );
        }

        OCompoundProperty root = archive.getTop().getProperties();
        OC3fArrayProperty colorProp( root, "colors" );
        OInt32ArrayProperty numProp( root, "numbers" );
        AbcA::MetaData md;
        SetReference( md );
        OStringArrayProperty strProp( root, "strings", md );
        TESTING_ASSERT( isReference( strProp.getHeader() ) );

        colorProp.set( emptyColorSamp );
        colorProp.set( colorSamp );
        colorProp.set( emptyColorSamp );
        colorProp.set( colorSamp );

        numProp.set( emptyIntSamp );
        numProp.set( intSamp );
        numProp.set( emptyIntSamp );
        numProp.set( intSamp );

        strProp.set( emptyStrSamp );
        strProp.set( strSamp );
        strProp.set( emptyStrSamp );
        strProp.set( strSamp );
    }

    {
        StringArraySamplePtr strSampPtr;
        C3fArraySamplePtr colorSampPtr;
        Int32ArraySamplePtr intSampPtr;

        AbcF::IFactory factory;
        factory.setPolicy(  ErrorHandler::kThrowPolicy );
        AbcF::IFactory::CoreType coreType;
        IArchive archive = factory.getArchive(archiveName, coreType);
        TESTING_ASSERT( (useOgawa && coreType == AbcF::IFactory::kOgawa) ||
                        (!useOgawa && coreType == AbcF::IFactory::kHDF5) );

        ICompoundProperty root = archive.getTop().getProperties();
        IC3fArrayProperty colorProp( root, "colors" );
        IInt32ArrayProperty numProp( root, "numbers" );
        IStringArrayProperty strProp( root, "strings" );
        TESTING_ASSERT( isReference( strProp.getHeader() ) );

        TESTING_ASSERT( colorProp.getNumSamples() == 4 );
        TESTING_ASSERT( strProp.getNumSamples() == 4 );
        TESTING_ASSERT( numProp.getNumSamples() == 4 );

        colorProp.get( colorSampPtr, 0 );
        strProp.get( strSampPtr, 0 );
        numProp.get( intSampPtr, 0 );
        TESTING_ASSERT( colorSampPtr->size() == 0 );
        TESTING_ASSERT( strSampPtr->size() == 0 );
        TESTING_ASSERT( intSampPtr->size() == 0 );

        colorProp.get( colorSampPtr, 2 );
        strProp.get( strSampPtr, 2 );
        numProp.get( intSampPtr, 2 );
        TESTING_ASSERT( colorSampPtr->size() == 0 );
        TESTING_ASSERT( strSampPtr->size() == 0 );
        TESTING_ASSERT( intSampPtr->size() == 0 );

        colorProp.get( colorSampPtr, 1 );
        strProp.get( strSampPtr, 1 );
        numProp.get( intSampPtr, 1 );
        TESTING_ASSERT( colorSampPtr->size() == 1 &&
            colorSamp[0] == ( *colorSampPtr )[0] );
        TESTING_ASSERT( strSampPtr->size() == 1 &&
            strSamp[0] == ( *strSampPtr )[0] );
        TESTING_ASSERT( intSampPtr->size() == 1 &&
//.........这里部分代码省略.........
开发者ID:BlackGinger,项目名称:ExocortexCrate,代码行数:101,代码来源:ArrayPropertyTest.cpp


示例16: readWriteColorArrayProperty

void readWriteColorArrayProperty(const std::string &archiveName, bool useOgawa)
{

    {
        OArchive archive;
        if (useOgawa)
        {
            archive = OArchive( Alembic::AbcCoreOgawa::WriteArchive(),
                archiveName, ErrorHandler::kThrowPolicy );
        }
        else
        {
            archive = OArchive( Alembic::AbcCoreHDF5::WriteArchive(),
                archiveName, ErrorHandler::kThrowPolicy );
        }

        OObject archiveTop = archive.getTop();

        OObject child( archiveTop, "test" );
        OCompoundProperty childProps = child.getProperties();

        OC3fArrayProperty shades( childProps, "shades", 0 );

        std::vector < C3f > grays(8);
        grays[0].x = 0.0; grays[0].y = 0.0; grays[0].z = 0.0;
        grays[1].x = 0.125; grays[1].y = 0.125; grays[1].z = 0.125;

        grays[2].x = 0.25; grays[2].y = 0.25; grays[2].z = 0.25;
        grays[3].x = 0.375; grays[3].y = 0.375; grays[3].z = 0.375;

        grays[4].x = 0.5; grays[4].y = 0.5; grays[4].z = 0.5;
        grays[5].x = 0.625; grays[5].y = 0.625; grays[5].z = 0.625;

        grays[6].x = 0.75; grays[6].y = 0.75; grays[6].z = 0.75;
        grays[7].x = 0.875; grays[7].y = 0.875; grays[7].z = 0.875;

        // let's write 4 different color3f[2]
        Dimensions d;
        d.setRank(2);
        d[0] = 2;
        d[1] = 4;

        C3fArraySample cas(&(grays.front()), d);
        shades.set(cas);
    }
    {
        // now read it
        AbcF::IFactory factory;
        factory.setPolicy(  ErrorHandler::kThrowPolicy );
        AbcF::IFactory::CoreType coreType;
        IArchive archive = factory.getArchive(archiveName, coreType);
        TESTING_ASSERT( (useOgawa && coreType == AbcF::IFactory::kOgawa) ||
                        (!useOgawa && coreType == AbcF::IFactory::kHDF5) );

        IObject archiveTop = archive.getTop();

        IObject child( archiveTop, archiveTop.getChildHeader(0).getName() );
        ICompoundProperty props = child.getProperties();
        IC3fArrayProperty shades( props, "shades" );

        C3fArraySamplePtr samplePtr;
        shades.get( samplePtr );

        ABCA_ASSERT( samplePtr->getDimensions().rank() == 2,
                     "Incorrect rank on the sample." );

        ABCA_ASSERT( samplePtr->getDimensions().numPoints() == 8,
                     "Incorrect number of total points." );

        ABCA_ASSERT( samplePtr->getDimensions()[0] == 2,
                     "Incorrect size on dimension 0." );

        ABCA_ASSERT( samplePtr->getDimensions()[1] == 4,
                     "Incorrect size on dimension 1." );

        Alembic::Util::Dimensions dims;
        shades.getDimensions( dims );

        ABCA_ASSERT( dims.rank() == 2,
                     "Incorrect rank on the sample." );

        ABCA_ASSERT( dims.numPoints() == 8,
                     "Incorrect number of total points." );

        ABCA_ASSERT( dims[0] == 2,
                     "Incorrect size on dimension 0." );

        ABCA_ASSERT( dims[1] == 4,
                     "Incorrect size on dimension 1." );

        for (size_t i = 0; i < 8; ++i)
        {
            ABCA_ASSERT( (*samplePtr)[i].x == i/8.0 &&
                         (*samplePtr)[i].x == (*samplePtr)[i].y &&
                         (*samplePtr)[i].x == (*samplePtr)[i].z,
                         "Color [" << i << "] is incorrect.");
        }

        double start, end;
        GetArchiveStartAndEndTime( archive, start, end );
//.........这里部分代码省略.........
开发者ID:BlackGinger,项目名称:ExocortexCrate,代码行数:101,代码来源:ArrayPropertyTest.cpp


示例17: diabolicalInstance

//-*****************************************************************************
void diabolicalInstance( const std::string& iArchiveName, bool useOgawa )
{
    /*
               a0  b0 (points to a0)
              /  |
            a1   b1 (points to a1)
           /  |
          a2  b2 (points to b2)
    */

{
    OArchive archive;
    if (useOgawa)
    {
        archive = OArchive( Alembic::AbcCoreOgawa::WriteArchive(),
            iArchiveName, ErrorHandler::kThrowPolicy );
    }
    else
    {
        archive = OArchive( Alembic::AbcCoreHDF5::WriteArchive() 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ alib::CommandLine类代码示例发布时间:2022-05-31
下一篇:
C++ abccoreabstract::ArchiveReaderPtr类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap