void CModelComponentsObject::addComponent(_In_ PModelComponent pComponent)
	{
		if (!pComponent)
			throw CNMRException(NMR_ERROR_INVALIDPARAM);
		
		CModel * pModel = getModel();
		CModelObject * pModelObject = pComponent->getObject();

		if (pModel != pModelObject->getModel())
			throw CNMRException(NMR_ERROR_MODELMISMATCH);

		m_Components.push_back(pComponent);
	}
	LIB3MFMETHODIMP CCOMModelBuildItem::GetObjectResource(_Outptr_ ILib3MFModelObjectResource ** ppObject)
	{
		try {
			if (!ppObject)
				throw CNMRException(NMR_ERROR_INVALIDPOINTER);

			if (!m_pModelBuildItem.get())
				throw CNMRException(NMR_ERROR_INVALIDBUILDITEM);

			// Retrieve Object of Build Item
			CModelObject * pObject = m_pModelBuildItem->getObject();
			if (!pObject)
				throw CNMRException(NMR_ERROR_INVALIDOBJECT);

			// Retrieve Model of Build Item
			CModel * pModel = pObject->getModel();
			if (!pModel)
				throw CNMRException(NMR_ERROR_INVALIDMODEL);

			// Retrieve corresponding Model Resource
			PModelResource pResource = pModel->findResource(pObject->getResourceID());
			if (!pResource.get())
				throw CNMRException(NMR_ERROR_INVALIDMODELRESOURCE);

			// Resource interface
			ILib3MFModelObjectResource * pResourceInterface = nullptr;

			// Return Mesh COM Object
			fnCreateModelObjectResourceFromClass(pResource, false, &pResourceInterface);

			// We have not found a suitable object class to return..
			if (pResourceInterface == nullptr)
				throw CNMRException(NMR_ERROR_RESOURCENOTFOUND);

			// Return result
			*ppObject = pResourceInterface;

			return handleSuccess();
		}
		catch (CNMRException & Exception) {
			return handleNMRException(&Exception);
		}
		catch (...) {
			return handleGenericException();
		}
	}