示例#1
0
void test() {
  IServiceManager* servmgr;
  IStaticServiceHandler* handler;
  IMonikerService* monikers;
  IObject* test;
  IObject* obj;

  servmgr = XPLC::getServiceManager();
  ASSERT(servmgr != 0, "could not obtain service manager");

  obj = servmgr->getObject(XPLC::staticServiceHandler);
  ASSERT(obj != 0, "could not obtain static service handler");

  handler = mutate<IStaticServiceHandler>(obj);
  ASSERT(handler != 0, "static service handler does not have the IStaticServiceHandler interface");

  test = new TestObject;
  ASSERT(test != 0, "could not create TestObject");
  test->addRef();

  handler->addObject(TestObject_CID, test);
  VERIFY(servmgr->getObject(TestObject_CID) == test, "adding the test object did not work");
  VERIFY(test->release() == 2, "incorrect refcount on test object");

  obj = servmgr->getObject(XPLC::monikers);
  ASSERT(obj != 0, "could not obtain moniker component");
  
  monikers = mutate<IMonikerService>(obj);
  ASSERT(monikers != 0, "moniker service does not have the IMoniker interface");
  monikers->registerObject("moniker", XPLC::monikers);
  monikers->registerObject("testobject", TestObject_CID);

  obj = monikers->resolve("testobject");
  ASSERT(obj != 0, "resolving the test object returned nothing");
  ASSERT(obj == test, "the testobject moniker resolved to something else than the test object");
  VERIFY(obj->release() == 2, "refcount is wrong on the test object");

  obj = monikers->resolve("moniker:testobject");
  ASSERT(obj != 0, "resolving the test object indirectly returned nothing");
  ASSERT(obj == test, "the testobject moniker indirectly resolved to something else than the test object");
  VERIFY(obj->release() == 2, "refcount is wrong on the test object");

  obj = monikers->resolve("moniker:");
  VERIFY(obj == 0, "resolving an empty sub-moniker returned something");

  VERIFY(monikers->release() == 1, "incorrect refcount on moniker service");

  VERIFY(handler->release() == 2, "incorrect refcount on static service handler");

  servmgr->shutdown();
  VERIFY(servmgr->release() == 0, "service manager has non-zero refcount after shutdown/release");

  VERIFY(test->release() == 0, "refcount is wrong on the test object");
}
bool CVisitNodeDWORD::Visit(IComponent *component, bool bVisitEnter)
{
	IObject *theObject;
	IHashString *objName;

	theObject = dynamic_cast<IObject *>(component);

	// if the object is invalid
	if (!theObject)
	{
		// log error
		return false;
	}

	// get the name of the object
	objName = theObject->GetName();

	// add name to set
	m_DWORDSet->Add(objName);

	return true;
}
DWORD CObjectCubeMapManager::PumpHandler(DWORD size, void *data, IHashString *name, 
									 IHashString *compType, MSGFUNCTION msgFunction)
{
	MODELTOCUBETEXTUREMAP::iterator startIter;
	MODELTOCUBETEXTUREMAP::iterator endIter;

	DWORD retval = MSG_NOT_HANDLED;
		
	// specific object
	if (name != NULL)
	{
		startIter = m_ModelCubeTexturesMap.lower_bound(name->GetUniqueID());
		endIter = m_ModelCubeTexturesMap.upper_bound(name->GetUniqueID());
	}
	
	// pump through everything if no name is specified
	else
	{
		startIter = m_ModelCubeTexturesMap.begin();
		endIter = m_ModelCubeTexturesMap.end();
	}

	for (; startIter != endIter; startIter++)
	{
		IObject *object = startIter->second;

		if ((compType == NULL) || (object->IsKindOf(compType)))
		{
			retval = (object->*msgFunction)(size, data);

			if (retval == MSG_HANDLED_STOP)
			{
				return retval;
			}
		}
	}
	return retval;
}
//-*****************************************************************************
Box3d getBounds( IObject iObj )
{
    Box3d bnds;
    bnds.makeEmpty();

    M44d xf = getFinalMatrix( iObj );

    if ( IPolyMesh::matches( iObj.getMetaData() ) )
    {
        IPolyMesh mesh( iObj, kWrapExisting );
        IPolyMeshSchema ms = mesh.getSchema();
        V3fArraySamplePtr positions = ms.getValue().getPositions();
        size_t numPoints = positions->size();

        for ( size_t i = 0 ; i < numPoints ; ++i )
        {
            bnds.extendBy( (*positions)[i] );
        }
    }
    else if ( ISubD::matches( iObj.getMetaData() ) )
    {
        ISubD mesh( iObj, kWrapExisting );
        ISubDSchema ms = mesh.getSchema();
        V3fArraySamplePtr positions = ms.getValue().getPositions();
        size_t numPoints = positions->size();

        for ( size_t i = 0 ; i < numPoints ; ++i )
        {
            bnds.extendBy( (*positions)[i] );
        }
    }

    bnds.extendBy( Imath::transform( bnds, xf ) );

    g_bounds.extendBy( bnds );

    return bnds;
}
示例#5
0
void test() {
  MyTestObject* test = 0;
  IObject* iobj = 0;
  IFoo* ifoo = 0;
  IBar* ibar = 0;

  test = MyTestObject::create();
  ASSERT(test, "could not instantiate test object");

  iobj = static_cast<IFoo*>(test)->getInterface(IObject::IID);
  VERIFY(iobj, "getInterface(IObject::IID) failed on test object");

  VERIFY(reinterpret_cast<void*>(iobj) == reinterpret_cast<void*>(test), "identity test failed");

  ifoo = get<IFoo>(iobj);
  VERIFY(ifoo, "get<IFoo> failed on test object");

  ibar = get<IBar>(ifoo);
  VERIFY(ibar, "get<IBar> failed on test object");

  ifoo->setFoo(10);
  ibar->setBar(20);

  VERIFY(ifoo->getFoo() == 10, "test object has unexpected behavior");
  VERIFY(ibar->getBar() == 20, "test object has unexpected behavior");

  VERIFY(iobj->addRef() == 4, "incorrect refcount");
  VERIFY(ifoo->addRef() == 5, "incorrect refcount");
  VERIFY(ibar->addRef() == 6, "incorrect refcount");

  VERIFY(iobj->release() == 5, "incorrect refcount");
  VERIFY(ifoo->release() == 4, "incorrect refcount");
  VERIFY(ibar->release() == 3, "incorrect refcount");

  VERIFY(iobj->release() == 2, "incorrect refcount");
  VERIFY(ifoo->release() == 1, "incorrect refcount");
  VERIFY(ibar->release() == 0, "incorrect refcount");
}
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");
    }
}
示例#7
0
ELAPI _Impl_CheckClsId(
    /* [in] */ PInterface serverObj,
    /* [in] */ const ClassID* classiD,
    /* [out] */ PInterface* outServerObj)
{
    IObject* object;
    char str[80];
    ClassID clsid;
    clsid.mUunm = str;

    object = (IObject*)serverObj->Probe(EIID_IObject);
    if (NULL == object) return E_INVALID_ARGUMENT;

    object->GetClassID(&clsid);
    while (*(EMuid *)&clsid != *(EMuid *)classiD) {
        object = (IObject*)object->Probe(EIID_SUPER_OBJECT);
        if (NULL == object) return E_INVALID_ARGUMENT;

        object->GetClassID(&clsid);
    }
    *outServerObj = object;  // don't AddRef, Caller don't Release either.
    return NOERROR;
}
示例#8
0
文件: main.cpp 项目: ahmidou/aphid
//-*****************************************************************************
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 );
    }
}
示例#9
0
文件: cull.hpp 项目: Asmodean-/Vulkan
    virtual VkBool32 objectBindDrawIndexedRecursive(const IObject& object, const ICommandBuffersSP& cmdBuffer, const SmartPointerVector<IGraphicsPipelineSP>& allGraphicsPipelines, const uint32_t bufferIndex) const
    {
    	if (viewFrustum)
    	{
    		if (viewFrustum->isVisible(object.getRootNode()->getBoundingSphere()))
    		{
    			return VK_TRUE;
    		}

    		return VK_FALSE;
    	}

    	return VK_TRUE;
    }
//-*****************************************************************************
void ICompoundProperty::init ( const IObject & iObject,
                               const Argument &iArg0,
                               const Argument &iArg1 )
{
    getErrorHandler().setPolicy(
        GetErrorHandlerPolicy( iObject, iArg0, iArg1 ) );

    ALEMBIC_ABC_SAFE_CALL_BEGIN(
        "ICompoundProperty::init( IObject )" );

    m_property = iObject.getProperties().getPtr();

    ALEMBIC_ABC_SAFE_CALL_END_RESET();
}
示例#11
0
文件: DataNode.cpp 项目: zenkovich/o2
	void DataNode::GetValueRaw(IObject& object) const
	{

		struct helper
		{
			static void ReadObject(void* object, const ObjectType& type, const DataNode& node)
			{
				for (auto baseType : type.GetBaseTypes())
				{
					const ObjectType* baseObjectType = dynamic_cast<const ObjectType*>(baseType.type);
					if (!baseObjectType)
						continue;

					void* baseObject = (*baseType.dynamicCastUpFunc)(object);
					ReadObject(baseObject, *baseObjectType, node);
				}

				for (auto field : type.GetFields())
				{
					auto srlzAttribute = field->GetAttribute<SerializableAttribute>();
					if (srlzAttribute)
					{
						auto fldNode = node.GetNode(field->GetName());
						if (fldNode)
							field->DeserializeFromObject(object, *fldNode);
					}
				}
			}
		};

		const ObjectType& type = dynamic_cast<const ObjectType&>(object.GetType());
		void* objectPtr = type.DynamicCastFromIObject(const_cast<IObject*>(&object));
		helper::ReadObject(objectPtr, type, *this);

		if (object.GetType().IsBasedOn(TypeOf(ISerializable)))
			((ISerializable&)object).OnDeserialized(*this);
	}
DWORD CCoordinateToolManager::OnDeleteObject(DWORD size, void *param)
{
	// This message has its priority raised so that it gets called before the
  	// parent entity's delete object. We MUST to remove coordinate tool
  	// for entity, before its deletion. Otherwise physics will crash.
  	// Is there any better solution, except to catch all DeleteObject messages?
  
  	VERIFY_MESSAGE_SIZE(sizeof(DELETEOBJECTPARAMS), size);
  	DELETEOBJECTPARAMS* dop = (DELETEOBJECTPARAMS*)param;
  
  	IObject * object = FindByParent(dop->name);
  	if (object != NULL)
  	{
  		// Remove coordinate tool for this parent object.
  		DELETEOBJECTPARAMS dop;
  		dop.name = object->GetName();
  		static DWORD msgHash_DeleteObject = CHashString(_T("DeleteObject")).GetUniqueID();
  		m_ToolBox->SendMessage(msgHash_DeleteObject, sizeof(DELETEOBJECTPARAMS), &dop);

		m_CoordinateToolName = NULL;
  	}

	return MSG_HANDLED_PROCEED;
}
示例#13
0
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
}
//-*****************************************************************************
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 );
    }
}
示例#15
0
/**
 * Return a random point in a generic shape limited by a bounding box.
 * @param object an object in which the point is generated
 * @param rng a random number generator
 * @param box a box restricting the point's volume
 * @param maxAttempts number of attempts to find a suitable point
 * @return a point or none if maxAttempts was exceeded
 */
boost::optional<Kernel::V3D> bounded(const IObject &object,
                                     Kernel::PseudoRandomNumberGenerator &rng,
                                     const BoundingBox &box,
                                     size_t maxAttempts) {
  boost::optional<Kernel::V3D> point{boost::none};
  if (box.isNull()) {
    throw std::invalid_argument(
        "Invalid bounding box. Cannot generate random point.");
  }
  for (size_t attempts{0}; attempts < maxAttempts; ++attempts) {
    const double r1 = rng.nextValue();
    const double r2 = rng.nextValue();
    const double r3 = rng.nextValue();
    auto pt = box.generatePointInside(r1, r2, r3);
    if (object.isValid(pt)) {
      point = pt;
      break;
    }
  };
  return point;
}
示例#16
0
void IGeom::setupWithObject(IObject object)
{
	size_t numChildren = object.getNumChildren();
	
	for (size_t i = 0; i < numChildren; ++i)
	{
		const ObjectHeader &ohead = object.getChildHeader(i);

		ofPtr<IGeom> dptr;
		if (Alembic::AbcGeom::IPolyMesh::matches(ohead))
		{
			Alembic::AbcGeom::IPolyMesh pmesh(object, ohead.getName());
			if (pmesh)
			{
				dptr.reset(new ofxAlembic::IPolyMesh(pmesh));
			}
		}
		else if (Alembic::AbcGeom::IPoints::matches(ohead))
		{
			Alembic::AbcGeom::IPoints points(object, ohead.getName());
			if (points)
			{
				dptr.reset(new ofxAlembic::IPoints(points));
			}
		}
		else if (Alembic::AbcGeom::ICurves::matches(ohead))
		{
			Alembic::AbcGeom::ICurves curves(object, ohead.getName());
			if (curves)
			{
				dptr.reset(new ofxAlembic::ICurves(curves));
			}
		}
		else if (Alembic::AbcGeom::INuPatch::matches(ohead))
		{
			ofLogError("ofxAlembic") << "INuPatch not implemented";
			assert(false);

//			Alembic::AbcGeom::INuPatch nuPatch(object, ohead.getName());
//			if ( nuPatch )
//			{
//				dptr.reset( new INuPatchDrw( nuPatch ) );
//			}
		}
		else if (Alembic::AbcGeom::IXform::matches(ohead))
		{
			Alembic::AbcGeom::IXform xform(object, ohead.getName());
			if (xform)
			{
				dptr.reset(new ofxAlembic::IXform(xform));
			}
		}
		else if (Alembic::AbcGeom::ISubD::matches(ohead))
		{
			ofLogError("ofxAlembic") << "ISubD not implemented";
			assert(false);

//			Alembic::AbcGeom::ISubD subd(object, ohead.getName());
//			if ( subd )
//			{
//				dptr.reset( new ISubDDrw( subd ) );
//			}
		}
		else if (Alembic::AbcGeom::ICamera::matches(ohead))
		{
			Alembic::AbcGeom::ICamera camera(object, ohead.getName());
			if (camera)
			{
				dptr.reset(new ofxAlembic::ICamera(camera));
			}
		}
		else
		{
			ofLogError("ofxAlembic") << "unknown object type: " << ohead.getFullName();
		}

		if (dptr && dptr->valid())
		{
			dptr->index = m_children.size();
			m_children.push_back(dptr);
			m_minTime = std::min(m_minTime, dptr->m_minTime);
			m_maxTime = std::max(m_maxTime, dptr->m_maxTime);
		}
	}
}
示例#17
0
void BIF_ObjInvoke(ExprTokenType &aResultToken, ExprTokenType *aParam[], int aParamCount)
{
    int invoke_type;
    IObject *obj;
    ExprTokenType *obj_param;

	// Since ObjGet/ObjSet/ObjCall are not publicly accessible as functions, Func::mName
	// (passed via aResultToken.marker) contains the actual flag rather than a name.
	invoke_type = (int)(INT_PTR)aResultToken.marker;

	// Set default return value; ONLY AFTER THE ABOVE.
	aResultToken.symbol = SYM_STRING;
	aResultToken.marker = _T("");
    
    obj_param = *aParam; // aParam[0].  Load-time validation has ensured at least one parameter was specified.
	++aParam;
	--aParamCount;

	// The following is used in place of TokenToObject to bypass #Warn UseUnset:
	if (obj_param->symbol == SYM_OBJECT)
		obj = obj_param->object;
	else if (obj_param->symbol == SYM_VAR && obj_param->var->HasObject())
		obj = obj_param->var->Object();
	else
		obj = NULL;
    
    if (obj)
	{
		bool param_is_var = obj_param->symbol == SYM_VAR;
		if (param_is_var)
			// Since the variable may be cleared as a side-effect of the invocation, call AddRef to ensure the object does not expire prematurely.
			// This is not necessary for SYM_OBJECT since that reference is already counted and cannot be released before we return.  Each object
			// could take care not to delete itself prematurely, but it seems more proper, more reliable and more maintainable to handle it here.
			obj->AddRef();
        obj->Invoke(aResultToken, *obj_param, invoke_type, aParam, aParamCount);
		if (param_is_var)
			obj->Release();
	}
	// Invoke meta-functions of g_MetaObject.
	else if (INVOKE_NOT_HANDLED == g_MetaObject.Invoke(aResultToken, *obj_param, invoke_type | IF_META, aParam, aParamCount))
	{
		// Since above did not handle it, check for attempts to access .base of non-object value (g_MetaObject itself).
		if (   invoke_type != IT_CALL // Exclude things like "".base().
			&& aParamCount > (invoke_type == IT_SET ? 2 : 0) // SET is supported only when an index is specified: "".base[x]:=y
			&& !_tcsicmp(TokenToString(*aParam[0]), _T("base"))   )
		{
			if (aParamCount > 1)	// "".base[x] or similar
			{
				// Re-invoke g_MetaObject without meta flag or "base" param.
				ExprTokenType base_token;
				base_token.symbol = SYM_OBJECT;
				base_token.object = &g_MetaObject;
				g_MetaObject.Invoke(aResultToken, base_token, invoke_type, aParam + 1, aParamCount - 1);
			}
			else					// "".base
			{
				// Return a reference to g_MetaObject.  No need to AddRef as g_MetaObject ignores it.
				aResultToken.symbol = SYM_OBJECT;
				aResultToken.object = &g_MetaObject;
			}
		}
		else
		{
			// Since it wasn't handled (not even by g_MetaObject), maybe warn at this point:
			if (obj_param->symbol == SYM_VAR)
				obj_param->var->MaybeWarnUninitialized();
		}
	}
}
示例#18
0
bool CWorldVisitor::Visit( IComponent * component, bool bVisitEnter )
{
	IObject *theObject;
	IHashString *name;
	IHashString *parentName;
	IHashString *type;

	StdString parentType;
	StdString childType;

	std::string str;

	theObject = dynamic_cast<IObject *>(component);
	// This shouldn't happen but it does for some odd reason....
	assert(theObject);
	if( theObject == NULL )
	{
		return false;
	}
	name = theObject->GetName();
	parentName = theObject->GetParentName();
	type = theObject->GetComponentType();

	//Check to see if it is a valid object (for object exclusion)
	if( !CheckObject( type->GetString() ) )
	{
		return true;
	}

	else
	{
		if ( name == NULL )
		{
			name = &CHashString(_T("NULL"));
		}	

		if( bVisitEnter == true )
		{
			//if( (m_pArchiver != NULL) && ( _tcscmp( type->GetString(), _T("CPhysicsObject") ) != 0 ) )
			if( (m_pArchiver != NULL) )
			{
				// Start the Node
				m_pArchiver->StartClass( type->GetString() );
				
				// Write out the Unique ID aka Name
				m_pArchiver->Write( name->GetString(), _T("Name") );
				theObject->Serialize( *m_pArchiver );
			}

			// Removal of CPhysShape and changes to CPhysicsObject
			if( _tcscmp( type->GetString(), _T("CPhysicsObject") ) == 0 )
			{
				
				CPhysObjectStruct tmpCPhysObject;
				StdString CPhyShapeFile;
				StdString CPhyShapeFileOld;
				// if it's parent is not a CTerrainSector Object
				if( _tcsstr( name->GetString(), _T("Terrain") ) == NULL )
				{
					static DWORD msgHash_GetModelFileName = CHashString(_T("GetModelFileName")).GetUniqueID();
					m_ToolBox->SendMessage(msgHash_GetModelFileName, sizeof(StdString*), &CPhyShapeFile, parentName, NULL );
					CPhyShapeFile += _T(".psl");
				}
				// CTerrainSector Object
				else
				{
					CPhyShapeFile = _T("maps\\terrain.psl");
				}

				IArchive *PhysObjectIn;
				IArchive *PhysObjectRead;
				CHashString memTypePhysObjectIn(_T("Memory"));
				
				int PhysObjectInMemSize = 1024 * 1024 * sizeof(char);
				char* PhysObjectInMemChunk = new char[PhysObjectInMemSize];
				memset( PhysObjectInMemChunk, 0, PhysObjectInMemSize );

				CREATEARCHIVE caPhysObjectIn;
				caPhysObjectIn.mode = STREAM_MODE_READ;
				caPhysObjectIn.streamData = PhysObjectInMemChunk;
				caPhysObjectIn.streamSize = PhysObjectInMemSize;
				caPhysObjectIn.streamType = &memTypePhysObjectIn;
				static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
				if (m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &caPhysObjectIn) != MSG_HANDLED)
				{
					return true;
				}
				PhysObjectIn = caPhysObjectIn.archive;

				CREATESTREAM csPhysObjectIn;
				csPhysObjectIn.streamData = caPhysObjectIn.streamData;
				csPhysObjectIn.streamSize = caPhysObjectIn.streamSize;
				csPhysObjectIn.mode = STREAM_MODE_WRITE;
				static DWORD msgHash_CreateStream_Memory = CHashString(_T("CreateStream_Memory")).GetUniqueID();
				if (m_ToolBox->SendMessage(msgHash_CreateStream_Memory, sizeof(CREATESTREAM), &csPhysObjectIn) != MSG_HANDLED)
				{
					return true;
				}
				PhysObjectIn->Init(csPhysObjectIn.openStream);		    

				SERIALIZEOBJECTPARAMS sop;
				sop.name = name;
				sop.archive = PhysObjectIn;
				static DWORD msgHash_SerializeObject = CHashString(_T("SerializeObject")).GetUniqueID();
				m_ToolBox->SendMessage(msgHash_SerializeObject, sizeof(SERIALIZEOBJECTPARAMS), &sop, NULL, NULL);
				PhysObjectIn->Close();
				
				CREATEARCHIVE caPhysObjectRead;
				caPhysObjectRead.mode = STREAM_MODE_WRITE;
				caPhysObjectRead.streamData = PhysObjectInMemChunk;
				caPhysObjectRead.streamSize = PhysObjectInMemSize;
				caPhysObjectRead.streamType = &memTypePhysObjectIn;
				if (m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &caPhysObjectRead) != MSG_HANDLED)
				{
					return true;
				}
				PhysObjectRead = caPhysObjectRead.archive;

				CREATESTREAM csPhysObjectRead;
				csPhysObjectRead.streamData = caPhysObjectRead.streamData;
				csPhysObjectRead.streamSize = caPhysObjectRead.streamSize;
				csPhysObjectRead.mode = STREAM_MODE_READ;
				if (m_ToolBox->SendMessage(msgHash_CreateStream_Memory, sizeof(CREATESTREAM), &csPhysObjectRead) != MSG_HANDLED)
				{
					return true;
				}
				PhysObjectRead->Init(csPhysObjectRead.openStream);
				PhysObjectRead->Read( tmpCPhysObject.vPosition, _T("pos") );
				PhysObjectRead->Read( tmpCPhysObject.vRotation, _T("rot") );
				PhysObjectRead->Read( tmpCPhysObject.vScale, _T("scale") );
				PhysObjectRead->Read( tmpCPhysObject.fMass, _T("mass") );
				PhysObjectRead->Read( tmpCPhysObject.szDynamic, _T("dynamics") );
				PhysObjectRead->Read( CPhyShapeFileOld, _T("shapeFile") );
				PhysObjectRead->Close();
                
				// Archive the Data Back In
				IArchive *MemArchivePhysObject;	
				CHashString memTypePhysObject(_T("Memory"));
				//int sizePhysObject = 1024 * 1024;
				//char* memchunkPhysObject = new char[sizePhysObject];

				CREATEARCHIVE caPhysObject;
				caPhysObject.mode = STREAM_MODE_WRITE;
				caPhysObject.streamData = PhysObjectInMemChunk;
				caPhysObject.streamSize = PhysObjectInMemSize;
				caPhysObject.streamType = &memTypePhysObject;
				if (m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &caPhysObject) != MSG_HANDLED)
				{
					return true;
				}
				MemArchivePhysObject = caPhysObject.archive;
				MemArchivePhysObject->Write( tmpCPhysObject.vPosition, _T("pos") );
				MemArchivePhysObject->Write( tmpCPhysObject.vRotation, _T("rot") );
				MemArchivePhysObject->Write( tmpCPhysObject.vScale, _T("scale") );
				MemArchivePhysObject->Write( tmpCPhysObject.fMass, _T("mass") );
				MemArchivePhysObject->Write( tmpCPhysObject.szDynamic, _T("dynamics") );
				MemArchivePhysObject->Write( CPhyShapeFile, _T("shapeFile") );
				
				CREATESTREAM csPhysObject;
				csPhysObject.streamData = caPhysObject.streamData;
				csPhysObject.streamSize = caPhysObject.streamSize;
				csPhysObject.mode = STREAM_MODE_READ;
				if (m_ToolBox->SendMessage(msgHash_CreateStream_Memory, sizeof(CREATESTREAM), &csPhysObject) != MSG_HANDLED)
				{
					return true;
				}
				MemArchivePhysObject->Init(csPhysObject.openStream);

				SERIALIZEOBJECTPARAMS sopPhysObject;
				sopPhysObject.name = name;
				sopPhysObject.archive = MemArchivePhysObject;
				m_ToolBox->SendMessage(msgHash_SerializeObject, sizeof(SERIALIZEOBJECTPARAMS), &sopPhysObject, NULL, NULL);

				MemArchivePhysObject->Close();
				//delete [] memchunkPhysObject;
				//memchunkPhysObject = NULL;
				delete [] PhysObjectInMemChunk;
				PhysObjectInMemChunk = NULL;
			}

			// Model Rename Changes
			if( (m_pReporter != NULL) && ( _tcscmp( type->GetString(), _T("CV3ORenderObject") ) == 0 ) )
			{
				IArchive *MemArchive;
				IArchive *MemArchive2;
				CHashString memType(_T("Memory"));
				memset( m_pMemChunk, '\0', m_iMemSize );

				CREATEARCHIVE ca;
				ca.mode = STREAM_MODE_READ;
				ca.streamData = m_pMemChunk;
				ca.streamSize = m_iMemSize;
				ca.streamType = &memType;
				static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
				if (m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &ca) != MSG_HANDLED)
				{
					return true;
				}
				MemArchive = ca.archive;

				CREATESTREAM cs;
				cs.streamData = ca.streamData;
				cs.streamSize = ca.streamSize;
				cs.mode = STREAM_MODE_WRITE;
				static DWORD msgHash_CreateStream_Memory = CHashString(_T("CreateStream_Memory")).GetUniqueID();
				if (m_ToolBox->SendMessage(msgHash_CreateStream_Memory, sizeof(CREATESTREAM), &cs) != MSG_HANDLED)
				{
					return true;
				}
				MemArchive->Init(cs.openStream);		    

				SERIALIZEOBJECTPARAMS sop;
				sop.name = name;
				sop.archive = MemArchive;
				static DWORD msgHash_SerializeObject = CHashString(_T("SerializeObject")).GetUniqueID();
				m_ToolBox->SendMessage(msgHash_SerializeObject, sizeof(SERIALIZEOBJECTPARAMS), &sop, NULL, NULL);
				MemArchive->Close();
				
				CREATEARCHIVE ca2;
				ca2.mode = STREAM_MODE_WRITE;
				ca2.streamData = m_pMemChunk;
				ca2.streamSize = m_iMemSize;
				ca2.streamType = &memType;
				if (m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &ca2) != MSG_HANDLED)
				{
					return true;
				}
				MemArchive2 = ca2.archive;

				CREATESTREAM cs2;
				cs2.streamData = ca2.streamData;
				cs2.streamSize = ca2.streamSize;
				cs2.mode = STREAM_MODE_READ;
				if (m_ToolBox->SendMessage(msgHash_CreateStream_Memory, sizeof(CREATESTREAM), &cs2) != MSG_HANDLED)
				{
					return true;
				}
				MemArchive2->Init(cs2.openStream);

				StdString wszModelFileName;
				Vec3 Position;
				Vec3 Rotation;
				Vec3 Scale;

				MemArchive2->Read( wszModelFileName );
				MemArchive2->Read( Position );
				MemArchive2->Read( Rotation );
				MemArchive2->Read( Scale );
				MemArchive2->Close();
				
				MODELMAP::iterator itr;
				bool bReArchive = false;
				while( 1 )
				{		
					itr = m_vModelReference.find( wszModelFileName );
					// If the Model Refernce already exists
					if( itr != m_vModelReference.end() )
					{
						// If its newfilename is different and it isn't an empty string
						// We Change the file name and set the archive flag
						if( (wszModelFileName != itr->second.m_wszNewFileName) &&
							(itr->second.m_wszNewFileName != StdString("")) )
						{
							wszModelFileName = itr->second.m_wszNewFileName;
							bReArchive = true;
						}
						
						// We've reached a file that has the same exact newfilename, no change neccisary
						else
						{
							break;
						}
					}
					
					
					// We change model name first (up above) and then make sure to add it as a reference and break out
					itr = m_vModelReference.find( wszModelFileName );
					if( itr == m_vModelReference.end() )
					{
						/*
						MODELINFO tmpModelInfo;
						tmpModelInfo.m_wszNewFileName = wszModelFileName;
						m_vModelReference[wszModelFileName] = tmpModelInfo;
						m_iNewEntries++;
						*/
						break;
					}
					
				}
				
				m_szLastV3OFileName = wszModelFileName;

				// Archive the object back out
				if( bReArchive == true )
				{
					IArchive *MemArchiveRE;	
					CHashString memTypeRE(_T("Memory"));
					int sizeRE = 1024 + sizeof(Vec3) * 3;
					char* memchunkRE = new char[sizeRE];

					CREATEARCHIVE caRE;
					caRE.mode = STREAM_MODE_WRITE;
					caRE.streamData = memchunkRE;
					caRE.streamSize = sizeRE;
					caRE.streamType = &memTypeRE;
					static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
					if (m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &caRE) != MSG_HANDLED)
					{
						return true;
					}
					MemArchiveRE = caRE.archive;
					MemArchiveRE->Write( wszModelFileName );
					MemArchiveRE->Write( Position );
					MemArchiveRE->Write( Rotation );
					MemArchiveRE->Write( Scale );

					CREATESTREAM csRE;
					csRE.streamData = caRE.streamData;
					csRE.streamSize = caRE.streamSize;
					csRE.mode = STREAM_MODE_READ;
					static DWORD msgHash_CreateStream_Memory = CHashString(_T("CreateStream_Memory")).GetUniqueID();
					if (m_ToolBox->SendMessage(msgHash_CreateStream_Memory, sizeof(CREATESTREAM), &csRE) != MSG_HANDLED)
					{
						return true;
					}
					MemArchiveRE->Init(csRE.openStream);

					SERIALIZEOBJECTPARAMS sopRE;
					sopRE.name = name;
					sopRE.archive = MemArchiveRE;
					static DWORD msgHash_SerializeObject = CHashString(_T("SerializeObject")).GetUniqueID();
					m_ToolBox->SendMessage(msgHash_SerializeObject, sizeof(SERIALIZEOBJECTPARAMS), &sopRE, NULL, NULL);

					MemArchiveRE->Close();
					delete [] memchunkRE;
					memchunkRE = NULL;
					m_iV3ONameEdits++;
				}
			}
		}

		// bVisitEnter == false
		else
		{
			if( m_pArchiver != NULL )
			{
				m_pArchiver->EndClass();
			}
		}
	}
	
	return true;
}
示例#19
0
文件: lwf_movie.cpp 项目: KitoHo/lwf
void Movie::PostExec(bool progressing)
{
	hasButton = false;
	if (!active)
		return;

	m_execedFrame = -1;
	bool postExeced = m_postExecCount == lwf->execCount;
	if (progressing && playing && !m_jumped && !postExeced) {
		++m_currentFrameInternal;
		currentFrame = m_currentFrameInternal + 1;
	}
	for (;;) {
		if (m_currentFrameInternal < 0 ||
				m_currentFrameInternal >= totalFrames) {
			m_currentFrameInternal = 0;
			currentFrame = m_currentFrameInternal + 1;
		}
		if (m_currentFrameInternal == m_execedFrame)
			break;

		m_currentFrameCurrent = m_currentFrameInternal;
		m_execedFrame = m_currentFrameCurrent;
		const Data *d = lwf->data.get();
		const Format::Frame &frame = d->frames[
			data->frameOffset + m_currentFrameCurrent];

		int controlAnimationOffset;
		IObject *instance;

		if (m_lastControlOffset == frame.controlOffset &&
				m_lastControls == frame.controls) {

			controlAnimationOffset = m_lastControlAnimationOffset;

			if (m_skipped) {
				instance = m_instanceHead;
				while (instance) {
					if (instance->IsMovie()) {
						Movie *movie = (Movie *)instance;
						movie->m_attachMovieExeced = false;
						movie->m_attachMoviePostExeced = false;
					} else if (instance->IsButton()) {
						((Button *)instance)->EnterFrame();
					}
					instance = instance->linkInstance;
				}
				hasButton = m_lastHasButton;
			} else {
				for (int dlDepth = 0; dlDepth < data->depths; ++dlDepth) {
					Object *obj = m_displayList[dlDepth].get();
					if (obj) {
						if (!postExeced) {
							obj->matrixIdChanged = false;
							obj->colorTransformIdChanged = false;
						}
						if (obj->IsMovie()) {
							Movie *movie = (Movie *)obj;
							movie->m_attachMovieExeced = false;
							movie->m_attachMoviePostExeced = false;
						} else if (obj->IsButton()) {
							((Button *)obj)->EnterFrame();
							hasButton = true;
						}
					}
				}
				m_lastHasButton = hasButton;
				m_skipped = true;
			}

		} else {
			++m_movieExecCount;
			m_instanceHead = 0;
			m_instanceTail = 0;
			m_lastControlOffset = frame.controlOffset;
			m_lastControls = frame.controls;
			controlAnimationOffset = -1;
			for (int i = 0; i < frame.controls; ++i) {
				const Format::Control &control =
					d->controls[frame.controlOffset + i];

				switch (control.controlType) {
				case Format::Control::MOVE:
					{
						const Format::Place &p = d->places[control.controlId];
						ExecObject(p.depth, p.objectId,
							p.matrixId, 0, p.instanceId, p.blendMode);
					}
					break;

				case Format::Control::MOVEM:
					{
						const Format::ControlMoveM &ctrl =
							d->controlMoveMs[control.controlId];
						const Format::Place &p = d->places[ctrl.placeId];
						ExecObject(p.depth, p.objectId,
							ctrl.matrixId, 0, p.instanceId, p.blendMode);
					}
					break;

				case Format::Control::MOVEC:
					{
						const Format::ControlMoveC &ctrl =
							d->controlMoveCs[control.controlId];
						const Format::Place &p = d->places[ctrl.placeId];
						ExecObject(p.depth, p.objectId, p.matrixId,
							ctrl.colorTransformId, p.instanceId, p.blendMode);
					}
					break;

				case Format::Control::MOVEMC:
					{
						const Format::ControlMoveMC &ctrl =
							d->controlMoveMCs[control.controlId];
						const Format::Place &p = d->places[ctrl.placeId];
						ExecObject(p.depth, p.objectId, ctrl.matrixId,
							ctrl.colorTransformId, p.instanceId, p.blendMode);
					}
					break;

				case Format::Control::ANIMATION:
					if (controlAnimationOffset == -1)
						controlAnimationOffset = i;
					break;

				case Format::Control::CONTROL_MAX:
					// SUPPRESS WARNING
					break;
				}
			}

			m_lastControlAnimationOffset = controlAnimationOffset;
			m_lastHasButton = hasButton;

			for (int dlDepth = 0; dlDepth < data->depths; ++dlDepth) {
				Object *obj = m_displayList[dlDepth].get();
				if (obj && obj->execCount != m_movieExecCount) {
					if (m_texts && obj->IsText())
						EraseText(obj->objectId);
					obj->Destroy();
					m_displayList[dlDepth].reset();
				}
			}
		}

		m_attachMovieExeced = true;
		if (!m_attachedMovies.empty()) {
			AttachedMovieList::iterator it(m_attachedMovieList.begin()),
				itend(m_attachedMovieList.end());
			for (; it != itend; ++it)
				if (it->second)
					it->second->Exec();
		}

		m_attachMoviePostExeced = true;
		instance = m_instanceHead;
		while (instance) {
			if (instance->IsMovie()) {
				Movie *movie = (Movie *)instance;
				movie->PostExec(progressing);
				if (!hasButton && movie->hasButton)
					hasButton = true;
			}
			instance = instance->linkInstance;
		}

		if (!m_attachedMovies.empty()) {
			DetachDict::const_iterator
				dit(m_detachedMovies.begin()), ditend(m_detachedMovies.end());
			for (; dit != ditend; ++dit) {
				AttachedMovies::iterator it = m_attachedMovies.find(dit->first);
				if (it != m_attachedMovies.end())
					DeleteAttachedMovie(this, it->second, true, false);
			}
			m_detachedMovies.clear();

			AttachedMovieList::iterator it(m_attachedMovieList.begin()),
				itend(m_attachedMovieList.end());
			for (; it != itend; ++it) {
				if (it->second) {
					it->second->PostExec(progressing);
					if (!hasButton && it->second->hasButton)
						hasButton = true;
				}
			}
		}

		if (!m_attachedLWFs.empty())
			hasButton = true;

		if (!m_postLoaded) {
			m_postLoaded = true;
#if defined(LWF_USE_LUA)
			if (m_isRoot && !m_rootPostLoadFunc.empty())
				lwf->CallFunctionLua(m_rootPostLoadFunc, this);
			if (!m_postLoadFunc.empty())
				lwf->CallFunctionLua(m_postLoadFunc, this);
#endif
			if (!m_handler.Empty())
				m_handler.Call(METype::POSTLOAD, this);
		}

		if (controlAnimationOffset != -1 &&
				m_execedFrame == m_currentFrameInternal) {
			bool animationPlayed = m_animationPlayedFrame ==
				m_currentFrameCurrent && !m_jumped;
			if (!animationPlayed) {
				for (int i = controlAnimationOffset;
						i < frame.controls; ++i) {
					const Format::Control &control =
						d->controls[frame.controlOffset + i];
					lwf->PlayAnimation(control.controlId, this);
				}
			}
		}

		m_animationPlayedFrame = m_currentFrameCurrent;
		if (m_currentFrameCurrent == m_currentFrameInternal)
			m_jumped = false;
	}

#if defined(LWF_USE_LUA)
	if (m_isRoot && !m_rootEnterFrameFunc.empty())
		lwf->CallFunctionLua(m_rootEnterFrameFunc, this);
	if (!m_enterFrameFunc.empty())
		lwf->CallFunctionLua(m_enterFrameFunc, this);
#endif
	PlayAnimation(ClipEvent::ENTERFRAME);
	if (!m_handler.Empty())
		m_handler.Call(METype::ENTERFRAME, this);
	m_postExecCount = lwf->execCount;
}
示例#20
0
//-*****************************************************************************
//-*****************************************************************************
// 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;
            }

            iArchives.push_back(archive);
        }

        // now reorder the input nodes so they are in increasing order of their
        // min values in the frame range
        std::sort(minVec.begin(), minVec.end());
        std::vector< IArchive > iOrderedArchives;
        iOrderedArchives.reserve(numInputs);

        for (size_t f = 0; f < numInputs; ++f)
        {
            size_t index = minIndexMap.find(minVec[f])->second;
            iOrderedArchives.push_back(iArchives[index]);
        }

        std::string appWriter = "AbcStitcher";
        std::string fileName = argv[1];
        std::string userStr;

        // Create an archive with the default writer
        OArchive oArchive;
        if (coreType == Alembic::AbcCoreFactory::IFactory::kHDF5)
        {
            oArchive = CreateArchiveWithInfo(
                Alembic::AbcCoreHDF5::WriteArchive(),
                fileName, appWriter, userStr, ErrorHandler::kThrowPolicy);
        }
        else if (coreType == Alembic::AbcCoreFactory::IFactory::kOgawa)
        {
            oArchive = CreateArchiveWithInfo(
                Alembic::AbcCoreOgawa::WriteArchive(),
                fileName, appWriter, userStr, ErrorHandler::kThrowPolicy);
        }

        OObject oRoot = oArchive.getTop();
        if (!oRoot.valid())
            return -1;

        std::vector<IObject> iRoots;
        iRoots.resize(numInputs);
        for (size_t f = 0; f < rootChildren; ++f)
        {
            for (size_t g = 0; g < numInputs; ++g)
            {
                iRoots[g] = iOrderedArchives[g].getTop().getChild(f);
            }

            visitObjects(iRoots, oRoot);
        }

        // collect the top level compound property
        ICompoundPropertyVec iCompoundProps;
        iCompoundProps.reserve(numInputs);
        for (size_t f = 0; f < numInputs; ++f)
        {
            iCompoundProps.push_back(iRoots[f].getParent().getProperties());
        }

        OCompoundProperty oCompoundProperty = oRoot.getProperties();
        stitchCompoundProp(iCompoundProps, oCompoundProperty);

    }

    return 0;
}
示例#21
0
//-*****************************************************************************
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(),
            iArchiveName, ErrorHandler::kThrowPolicy );
    }

    OObject topobj = archive.getTop();

    OObject a0( topobj, "a0" );
    TESTING_ASSERT( topobj.addChildInstance( a0, "b0" ) );

    OObject a1( a0, "a1" );
    TESTING_ASSERT( a0.addChildInstance( a1, "b1" ) );

    OObject a2( a1, "a2" );
    TESTING_ASSERT( a1.addChildInstance( a2, "b2" ) );
}

{
    AbcF::IFactory factory;

    IArchive archive = factory.getArchive( iArchiveName );
    IObject topObject = archive.getTop();

    IObject a0( topObject.getChild(0) );
    TESTING_ASSERT( !a0.isInstanceDescendant() );
    TESTING_ASSERT( a0.getFullName() == "/a0" );
    TESTING_ASSERT( !a0.getParent().isInstanceDescendant() );
    TESTING_ASSERT( a0.getParent().getFullName() == "/" );

    IObject b0( topObject.getChild(1) );
    TESTING_ASSERT( b0.isInstanceDescendant() );
    TESTING_ASSERT( b0.getName() == "b0" );
    TESTING_ASSERT( b0.getFullName() == "/b0" );
    TESTING_ASSERT( !b0.getParent().isInstanceDescendant() );
    TESTING_ASSERT( b0.getParent().getFullName() == "/" );

    IObject a0a1( a0.getChild(0) );
    TESTING_ASSERT( !a0a1.isInstanceDescendant() );
    TESTING_ASSERT( a0a1.getName() == "a1" );
    TESTING_ASSERT( a0a1.getFullName() == "/a0/a1" );
    TESTING_ASSERT( !a0a1.getParent().isInstanceDescendant() );
    TESTING_ASSERT( a0a1.getParent().getName() == "a0" );
    TESTING_ASSERT( a0a1.getParent().getFullName() == "/a0" );

    IObject a0b1( a0.getChild(1) );
    TESTING_ASSERT( a0b1.isInstanceDescendant() );
    TESTING_ASSERT( a0b1.getName() == "b1" );
    TESTING_ASSERT( a0b1.getFullName() == "/a0/b1" );
    TESTING_ASSERT( !a0b1.getParent().isInstanceDescendant() );
    TESTING_ASSERT( a0b1.getParent().getName() == "a0" );
    TESTING_ASSERT( a0b1.getParent().getFullName() == "/a0" );

    IObject b0a1( b0.getChild(0) );
    TESTING_ASSERT( b0a1.isInstanceDescendant() );
    TESTING_ASSERT( b0a1.getParent().isInstanceDescendant() );

    IObject b0b1( b0.getChild(1) );
    TESTING_ASSERT( b0b1.isInstanceDescendant() );
    TESTING_ASSERT( b0b1.getName() == "b1" );
    TESTING_ASSERT( b0b1.getFullName() == "/b0/b1" );
    TESTING_ASSERT( b0b1.getParent().isInstanceDescendant() );
    TESTING_ASSERT( b0b1.getParent().getName() == "b0" );
    TESTING_ASSERT( b0b1.getParent().getFullName() == "/b0" );

    IObject a0a1a2( a0a1.getChild(0) );
    TESTING_ASSERT( !a0a1a2.isInstanceDescendant() );
    TESTING_ASSERT( a0a1a2.getName() == "a2" );
    TESTING_ASSERT( a0a1a2.getFullName() == "/a0/a1/a2" );
    TESTING_ASSERT( !a0a1a2.getParent().isInstanceDescendant() );
    TESTING_ASSERT( a0a1a2.getParent().getName() == "a1" );
    TESTING_ASSERT( a0a1a2.getParent().getFullName() == "/a0/a1" );
    TESTING_ASSERT( !a0a1a2.getParent().getParent().isInstanceDescendant() );
    TESTING_ASSERT( a0a1a2.getParent().getParent().getName() == "a0" );
    TESTING_ASSERT( a0a1a2.getParent().getParent().getFullName() == "/a0" );

    IObject a0a1b2( a0a1.getChild(1) );
    TESTING_ASSERT( a0a1b2.isInstanceDescendant() );
    TESTING_ASSERT( a0a1b2.getName() == "b2" );
    TESTING_ASSERT( a0a1b2.getFullName() == "/a0/a1/b2" );
    TESTING_ASSERT( !a0a1b2.getParent().isInstanceDescendant() );
    TESTING_ASSERT( a0a1b2.getParent().getName() == "a1" );
    TESTING_ASSERT( a0a1b2.getParent().getFullName() == "/a0/a1" );
    TESTING_ASSERT( !a0a1b2.getParent().getParent().isInstanceDescendant() );
    TESTING_ASSERT( a0a1b2.getParent().getParent().getName() == "a0" );
    TESTING_ASSERT( a0a1b2.getParent().getParent().getFullName() == "/a0" );

    IObject a0b1a2( a0b1.getChild(0) );
    TESTING_ASSERT( a0b1a2.isInstanceDescendant() );
    TESTING_ASSERT( a0b1a2.getName() == "a2" );
    TESTING_ASSERT( a0b1a2.getFullName() == "/a0/b1/a2" );
    TESTING_ASSERT( a0b1a2.getParent().isInstanceDescendant() );
    TESTING_ASSERT( a0b1a2.getParent().getName() == "b1" );
    TESTING_ASSERT( a0b1a2.getParent().getFullName() == "/a0/b1" );
    TESTING_ASSERT( !a0b1a2.getParent().getParent().isInstanceDescendant() );
    TESTING_ASSERT( a0b1a2.getParent().getParent().getName() == "a0" );
    TESTING_ASSERT( a0b1a2.getParent().getParent().getFullName() == "/a0" );

    IObject a0b1b2( a0b1.getChild(1) );
    TESTING_ASSERT( a0b1b2.isInstanceDescendant() );
    TESTING_ASSERT( a0b1b2.getName() == "b2" );
    TESTING_ASSERT( a0b1b2.getFullName() == "/a0/b1/b2" );
    TESTING_ASSERT( a0b1b2.getParent().isInstanceDescendant() );
    TESTING_ASSERT( a0b1b2.getParent().getName() == "b1" );
    TESTING_ASSERT( a0b1b2.getParent().getFullName() == "/a0/b1" );
    TESTING_ASSERT( !a0b1b2.getParent().getParent().isInstanceDescendant() );
    TESTING_ASSERT( a0b1b2.getParent().getParent().getName() == "a0" );
    TESTING_ASSERT( a0b1b2.getParent().getParent().getFullName() == "/a0" );

    IObject b0a1a2( b0a1.getChild(0) );
    TESTING_ASSERT( b0a1a2.isInstanceDescendant() );
    TESTING_ASSERT( b0a1a2.getName() == "a2" );
    TESTING_ASSERT( b0a1a2.getFullName() == "/b0/a1/a2" );
    TESTING_ASSERT( b0a1a2.getParent().isInstanceDescendant() );
    TESTING_ASSERT( b0a1a2.getParent().getName() == "a1" );
    TESTING_ASSERT( b0a1a2.getParent().getFullName() == "/b0/a1" );
    TESTING_ASSERT( b0a1a2.getParent().getParent().isInstanceDescendant() );
    TESTING_ASSERT( b0a1a2.getParent().getParent().getName() == "b0" );
    TESTING_ASSERT( b0a1a2.getParent().getParent().getFullName() == "/b0" );

    IObject b0a1b2( b0a1.getChild(1) );
    TESTING_ASSERT( b0a1b2.isInstanceDescendant() );
    TESTING_ASSERT( b0a1b2.getName() == "b2" );
    TESTING_ASSERT( b0a1b2.getFullName() == "/b0/a1/b2" );
    TESTING_ASSERT( b0a1b2.getParent().isInstanceDescendant() );
    TESTING_ASSERT( b0a1b2.getParent().getName() == "a1" );
    TESTING_ASSERT( b0a1b2.getParent().getFullName() == "/b0/a1" );
    TESTING_ASSERT( b0a1b2.getParent().getParent().isInstanceDescendant() );
    TESTING_ASSERT( b0a1b2.getParent().getParent().getName() == "b0" );
    TESTING_ASSERT( b0a1b2.getParent().getParent().getFullName() == "/b0" );

    IObject b0b1a2( b0b1.getChild(0) );
    TESTING_ASSERT( b0b1a2.isInstanceDescendant() );
    TESTING_ASSERT( b0b1a2.getName() == "a2" );
    TESTING_ASSERT( b0b1a2.getFullName() == "/b0/b1/a2" );
    TESTING_ASSERT( b0b1a2.getParent().isInstanceDescendant() );
    TESTING_ASSERT( b0b1a2.getParent().getName() == "b1" );
    TESTING_ASSERT( b0b1a2.getParent().getFullName() == "/b0/b1" );
    TESTING_ASSERT( b0b1a2.getParent().getParent().isInstanceDescendant() );
    TESTING_ASSERT( b0b1a2.getParent().getParent().getName() == "b0" );
    TESTING_ASSERT( b0b1a2.getParent().getParent().getFullName() == "/b0" );

    IObject b0b1b2( b0b1.getChild(1) );
    TESTING_ASSERT( b0b1b2.isInstanceDescendant() );
    TESTING_ASSERT( b0b1b2.getName() == "b2" );
    TESTING_ASSERT( b0b1b2.getFullName() == "/b0/b1/b2" );
    TESTING_ASSERT( b0b1b2.getParent().isInstanceDescendant() );
    TESTING_ASSERT( b0b1b2.getParent().getName() == "b1" );
    TESTING_ASSERT( b0b1b2.getParent().getFullName() == "/b0/b1" );
    TESTING_ASSERT( b0b1b2.getParent().getParent().isInstanceDescendant() );
    TESTING_ASSERT( b0b1b2.getParent().getParent().getName() == "b0" );
    TESTING_ASSERT( b0b1b2.getParent().getParent().getFullName() == "/b0" );
}

}
示例#22
0
void readProperty(const std::string &archiveName)
{
    // Open an existing archive for reading. Indicate that we want
    //   Alembic to throw exceptions on errors.
    std::cout  << "Reading " << archiveName << std::endl;
    IArchive archive( Alembic::AbcCoreHDF5::ReadArchive(),
                      archiveName, ErrorHandler::kThrowPolicy );
    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 3)");
    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 << "  " << 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 << " has a simple 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 == kScalarProperty, 
                 "Expected a scalar property, but didn't find one" );

    DataType dType = props.getPropertyHeader(0).getDataType();
    ABCA_ASSERT( dType.getPod() == kFloat64POD,
                 "Expected a double (kFloat64POD) property, but didn't"
                 " find one" );

    // We know this is a scalar property (I'm eliding the if/else
    //  statements required to recognize this)
    IDoubleProperty mass( props, propNames[0] );
    size_t numSamples = mass.getNumSamples();
    std::cout << ".. it has " << numSamples << " samples" << std::endl;
    ABCA_ASSERT( numSamples == 5, "Expected 5 samples, found " << numSamples );
    
    std::cout << "..with values: ";
    for (int ss=0; ss<numSamples; ss++)
    {
        ISampleSelector iss( (index_t) ss);
        printSampleValue( mass, iss );

        double massDiff = mass.getValue( iss ) -  (33.0 + 0.1*ss);
        ABCA_ASSERT( fabs(massDiff) < 1e-12, "Incorrect sample value read" );
    }
    std::cout << std::endl;    

    // Done - the archive closes itself
}
示例#23
0
void readUInt32ArrayProperty(const std::string &archiveName)
{
    // Open an existing archive for reading. Indicate that we want
    //   Alembic to throw exceptions on errors.
    std::cout  << "Reading " << archiveName << std::endl;
    IArchive archive( Alembic::AbcCoreHDF5::ReadArchive(),
                      archiveName, ErrorHandler::kThrowPolicy );
    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() == kUint32POD,
                 "Expected an unsigned int (kUint32POD) 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)
    IUInt32ArrayProperty primes( props, propNames[0] );
    size_t numSamples = primes.getNumSamples();
    std::cout << ".. it has " << numSamples << " samples" << std::endl;
    ABCA_ASSERT( numSamples == 5, "Expected 5 samples, found " << numSamples );

    const TimeSampling ts = primes.getTimeSampling();
    std::cout << "..with time/value pairs: " << std::endl;;
    for (int ss=0; ss<numSamples; ss++)
    {
        std::cout << "   ";
        ISampleSelector iss( (index_t) ss);
        std::cout << ts.getSampleTime( (index_t) ss ) << " / ";

        UInt32ArraySamplePtr samplePtr;
        primes.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;

        // ASSERT that we are reading the correct values
        for ( size_t jj=0 ; jj<numPoints ; jj++ )
            ABCA_ASSERT( (*samplePtr)[jj] == g_primes[jj],
                         "Incorrect value read from archive." );
    }
    std::cout << std::endl;
    // Done - the archive closes itself
}
示例#24
0
void ofLive::setup()
{
  rCPP.Initialise(&rLOG, NULL);

# ifdef TARGET_LINUX
# ifdef NDEBUG
  rCPP.AddLibraryDir("../of/lib-linux/release-x86-64");
# else
  rCPP.AddLibraryDir("../of/lib-linux/debug-x86-64");
# endif
# endif

# ifdef TARGET_LINUX
  rCPP.AddIncludeDir("/usr/include/AL");
  rCPP.AddIncludeDir("/usr/include/cairo");
  rCPP.AddIncludeDir("/usr/include/gtk-3.0");
  rCPP.AddIncludeDir("/usr/include/atk-1.0");
  rCPP.AddIncludeDir("/usr/include/glib-2.0");
  rCPP.AddIncludeDir("/usr/lib/glib-2.0/include/");
  rCPP.AddIncludeDir("/usr/include/harfbuzz");
  rCPP.AddIncludeDir("/usr/include/pixman-1");
  rCPP.AddIncludeDir("/usr/include/libpng12");
  rCPP.AddIncludeDir("/usr/include/pango-1.0");
  rCPP.AddIncludeDir("/usr/include/freetype2");
  rCPP.AddIncludeDir("/usr/include/gio-unix-2.0");
  rCPP.AddIncludeDir("/usr/include/gstreamer-1.0");
  rCPP.AddIncludeDir("/usr/lib/gstreamer-1.0/include");
  rCPP.AddIncludeDir("/usr/lib/gstreamer-1.0/include/gst");
  rCPP.AddIncludeDir("/usr/include/gdk-pixbuf-2.0");
  rCPP.AddIncludeDir("/usr/include/at-spi2-atk/2.0");
  rCPP.AddIncludeDir("/usr/lib/x86_64-linux-gnu/glib-2.0/include");
# endif

  rCPP.AddIncludeDir("../of/src/freeimage");
  rCPP.AddIncludeDir("../of/src/freeimage/OpenEXR");
  rCPP.AddIncludeDir("../of/src/freeimage/OpenEXR/Half");
  rCPP.AddIncludeDir("../of/src/freeimage/OpenEXR/Iex");
  rCPP.AddIncludeDir("../of/src/freeimage/OpenEXR/IlmImf");
  rCPP.AddIncludeDir("../of/src/freeimage/OpenEXR/IlmThread");
  rCPP.AddIncludeDir("../of/src/freeimage/OpenEXR/Imath");
  rCPP.AddIncludeDir("../of/src/rtaudio");
  rCPP.AddIncludeDir("../of/src/rtaudio/include");
  rCPP.AddIncludeDir("../of/src/utf8cpp");
  rCPP.AddIncludeDir("../of/src/utf8cpp/include");
  rCPP.AddIncludeDir("../of/src/utf8cpp/include/utf8");
  rCPP.AddIncludeDir("../of/src/glew");
  rCPP.AddIncludeDir("../of/src/glew/include");
  rCPP.AddIncludeDir("../of/src/glfw");
  rCPP.AddIncludeDir("../of/src/glfw/include");
  rCPP.AddIncludeDir("../of/src/glfw/include/GLFW");
  rCPP.AddIncludeDir("../of/src/kissfft");
  rCPP.AddIncludeDir("../of/src/kissfft/tools");
  rCPP.AddIncludeDir("../of/src/poco");
  rCPP.AddIncludeDir("../of/src/poco/Crypto/include");
  rCPP.AddIncludeDir("../of/src/poco/Foundation/include");
  rCPP.AddIncludeDir("../of/src/poco/Net/include");
  rCPP.AddIncludeDir("../of/src/poco/NetSSL_OpenSSL/include");
  rCPP.AddIncludeDir("../of/src/poco/Util/include");
  rCPP.AddIncludeDir("../of/src/poco/XML/include");
  rCPP.AddIncludeDir("../of/src/poco/Zip/include");
  rCPP.AddIncludeDir("../of/src/rtaudio");
  rCPP.AddIncludeDir("../of/src/rtaudio/include");
  rCPP.AddIncludeDir("../of/src/libtess2");
  rCPP.AddIncludeDir("../of/src/libtess2/Include");
  rCPP.AddIncludeDir("../of/src/libtess2/Sources");
  rCPP.AddIncludeDir("../of/src/openframeworks");
  rCPP.AddIncludeDir("of/src/openframeworks");
  rCPP.AddIncludeDir("../of/src/openframeworks/3d");
  rCPP.AddIncludeDir("../of/src/openframeworks/app");
  rCPP.AddIncludeDir("../of/src/openframeworks/communication");
  rCPP.AddIncludeDir("../of/src/openframeworks/events");
  rCPP.AddIncludeDir("../of/src/openframeworks/gl");
  rCPP.AddIncludeDir("../of/src/openframeworks/graphics");
  rCPP.AddIncludeDir("../of/src/openframeworks/math");
  rCPP.AddIncludeDir("../of/src/openframeworks/sound");
  rCPP.AddIncludeDir("../of/src/openframeworks/types");
  rCPP.AddIncludeDir("../of/src/openframeworks/utils");
  rCPP.AddIncludeDir("../of/src/openframeworks/video");

  rCPP.AddIncludeDir("RuntimeCompiledCPlusPlus/Aurora");
  rCPP.AddIncludeDir("addons/ofxImGui/src");
  rCPP.AddIncludeDir("addons/ofxImGui/libs/imgui/src");
  rCPP.AddIncludeDir("../of/addons/ofxAssimpModelLoader/src");
  rCPP.AddIncludeDir("../of/addons/ofxAssimpModelLoader/libs/assimp/include/");
  rCPP.AddIncludeDir("./");

  {
    ofDirectory dir(ofFilePath::getCurrentExeDir() + "..");
    dir.listDir();
    vector<ofFile> files = dir.getFiles();
    for (ofFile& file : files)
    {
      if (file.isDirectory() &&
          file.getBaseName().substr(0,3) == "ofx")
      {
        rCPP.AddIncludeDir(&(file.path())[0]);
        rCPP.AddIncludeDir(&(file.path() + "/src")[0]);
      }
    }
  }

  rCPP.GetObjectFactorySystem()->AddListener(this);

  {
    IObject* rObject = rCPP.GetObjectFactorySystem()->GetConstructor("ofApp")->Construct();
    rObject->GetInterface(&rAPP);
    rOID = rObject->GetObjectId();
  }

  rAPP->setup();
}
示例#25
0
void accumXform( Imath::M44d &xf, IObject obj, chrono_t curTime, bool interpolate)
{
    if ( IXform::matches( obj.getHeader() ) )
    {
        Imath::M44d mtx;
        IXform x( obj, kWrapExisting );
        XformSample xs;
        x.getSchema().get( xs );

        if (!x.getSchema().isConstant()) {

            TimeSamplingPtr timeSampler = x.getSchema().getTimeSampling();

            if (interpolate) {

                //std::pair<index_t, chrono_t> lSamp;// = timeSampler->getFloorIndex(curTime, x.getSchema().getNumSamples());
                Alembic::AbcCoreAbstract::index_t floorIdx, ceilIdx;

                double amt = getWeightAndIndex(curTime, timeSampler,
                                               x.getSchema().getNumSamples(), floorIdx, ceilIdx);

                if (amt != 0 && floorIdx != ceilIdx) {

                    const ISampleSelector iss_start(floorIdx);//lSamp.first);
                    Imath::M44d mtx_start = x.getSchema().getValue(iss_start).getMatrix();

                    //std::pair<index_t, chrono_t> rSamp = timeSampler->getCeilIndex(curTime, x.getSchema().getNumSamples());
                    const ISampleSelector iss_end(ceilIdx);//rSamp.first);
                    Imath::M44d mtx_end = x.getSchema().getValue(iss_end).getMatrix();


                    Imath::V3d s_l,s_r,h_l,h_r,t_l,t_r;
                    Imath::Quatd quat_l,quat_r;



                    DecomposeXForm(mtx_start, s_l, h_l, quat_l, t_l);
                    DecomposeXForm(mtx_end, s_r, h_r, quat_r, t_r);


                    if ((quat_l ^ quat_r) < 0)
                    {
                        quat_r = -quat_r;
                    }

                    mtx =  RecomposeXForm(Imath::lerp(s_l, s_r, amt),
                                          Imath::lerp(h_l, h_r, amt),
                                          Imath::slerp(quat_l, quat_r, amt),
                                          Imath::lerp(t_l, t_r, amt));


                }

                else {
                    const ISampleSelector iss(curTime);
                    xs = x.getSchema().getValue(iss);
                    mtx = xs.getMatrix();
                }

            }



            else { // no interpolation, get nearest sample
                const ISampleSelector iss(curTime);
                xs = x.getSchema().getValue(iss);
                mtx = xs.getMatrix();
            }

        }
        else {
            mtx = xs.getMatrix();
        }
        xf *= mtx;
    }
}
示例#26
0
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" );
    }
}
示例#27
0
bool avm_elem::Equals(const IObject &value) const
{
  return(this->ToString() == value.ToString());
}
示例#28
0
/**
 * Return a random point in a generic shape.
 * @param object an IObject within which the point is generated
 * @param rng a random number generator
 * @param maxAttempts maximum number of random numbers to use before giving up
 * @return a point
 */
boost::optional<Kernel::V3D>
inGenericShape(const IObject &object, Kernel::PseudoRandomNumberGenerator &rng,
               size_t maxAttempts) {
  return bounded(object, rng, object.getBoundingBox(), maxAttempts);
}
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;
                case kFloat32POD:
                    std::cout << "float" << std::endl;
                    break;
                case kFloat64POD:
                    std::cout << "double" << std::endl;
                    break;

                case kStringPOD:
                    std::cout << "string" << std::endl;
                    break;

                case kUnknownPOD:
                default:
                    std::cout << " Unknown! (this is bad)" << std::endl;
            };

            TimeSamplingPtr ts =
                GetCompoundPropertyReaderPtr(props)->
                getScalarProperty( propNames[jj] )->getTimeSampling();

            int numSamples = ts->getNumStoredTimes();


            std::cout << "    ..and "
                      << ts->getTimeSamplingType() << std::endl
                      << "    ..and " << numSamples << " samples at times: ";

            if (numSamples > 0)
            {
                std::cout << " ( ";
                for (int ss=0; ss<numSamples; ss++)
                    std::cout << ts->getSampleTime(ss) << " ";
                std::cout << ")";
            }
            std::cout << std::endl;

            std::cout << "    ..and values: ";
            if (numSamples > 0)
            {
                for (int ss=0; ss<numSamples; ss++)
                {
                    ISampleSelector iss( (index_t) ss);
                    switch (dType.getPod())
                    {
                        // Boolean
                        case  kBooleanPOD:
                        {
                            IBoolProperty prop( props,  propNames[jj] );
                            printSampleValue( prop, iss );
                            break;
                        }

                        // Char/UChar
                        case kUint8POD:
                        {
                            IUcharProperty prop( props,  propNames[jj] );
                            printSampleValue( prop, iss );
                            break;
                        }
                        case kInt8POD:
                        {
                            ICharProperty prop( props,  propNames[jj] );
                            printSampleValue( prop, iss );
                            break;
                        }

                        // Short/UShort
                        case kUint16POD:
                        {
                            IUInt16Property prop( props,  propNames[jj] );
                            printSampleValue( prop, iss );
                            break;
                        }
                        case kInt16POD:
                        {
                            IInt16Property prop( props,  propNames[jj] );
                            printSampleValue( prop, iss );
                            break;
                        }

                        // Int/UInt
                        case kUint32POD:
                        {
                            IUInt32Property prop( props,  propNames[jj] );
                            printSampleValue( prop, iss );
                            break;
                        }
                        case kInt32POD:
                        {
                            IInt32Property prop( props,  propNames[jj] );
                            printSampleValue( prop, iss );
                            break;
                        }

                        // Long/ULong
                        case kUint64POD:
                        {
                            IUInt64Property prop( props,  propNames[jj] );
                            printSampleValue( prop, iss );
                            break;
                        }
                        case kInt64POD:
                        {
                            IInt64Property prop( props,  propNames[jj] );
                            printSampleValue( prop, iss );
                            break;
                        }

                        // Half/Float/Double
                        case kFloat16POD:
                            // iostream doesn't understand float_16's
                            //printSampleValue( IHalfProperty( props,  propNames[jj] ),
                            //                  iss );
                            break;
                        case kFloat32POD:
                        {
                            IFloatProperty prop( props,  propNames[jj] );
                            printSampleValue( prop, iss );
                            break;
                        }
                        case kFloat64POD:
                        {
                            IDoubleProperty prop( props,  propNames[jj] );
                            printSampleValue( prop, iss );
                            break;
                        }

                        case kUnknownPOD:
                        default:
                            std::cout << " Unknown! (this is bad)" << std::endl;
                    };

                }
            }
            std::cout << std::endl;



            std::cout << std::endl; // done parsing property
        }
    }

    // Done - the archive closes itself
}
示例#30
0
void readWriteColorArrayProperty(const std::string &archiveName)
{

    {

        OArchive archive( Alembic::AbcCoreHDF5::WriteArchive(), archiveName,
                          ErrorHandler::kThrowPolicy );
        OObject archiveTop = archive.getTop();

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

        OC3fArrayProperty shades( childProps, "shades",
                                  TimeSamplingType( 1.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
        IArchive archive( Alembic::AbcCoreHDF5::ReadArchive(),
                          archiveName, ErrorHandler::kThrowPolicy );
        IObject archiveTop = archive.getTop();

        const unsigned int numChildren =  archiveTop.getNumChildren();


        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." );

        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.");
        }

    }
}