//-***************************************************************************** void IArrayProperty::init( AbcA::CompoundPropertyReaderPtr iParent, const std::string &iName, ErrorHandler::Policy iParentPolicy, const Argument &iArg0, const Argument &iArg1 ) { Arguments args( iParentPolicy ); iArg0.setInto( args ); iArg1.setInto( args ); getErrorHandler().setPolicy( args.getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::init()" ); const AbcA::PropertyHeader *pheader = iParent->getPropertyHeader( iName ); ABCA_ASSERT( pheader != NULL, "Nonexistent array property: " << iName ); m_property = iParent->getArrayProperty( iName ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); }
//-***************************************************************************** AbcA::CompoundPropertyReaderPtr OrData::getProperties( AbcA::ObjectReaderPtr iParent ) { AbcA::CompoundPropertyReaderPtr ret = m_top.lock(); if ( ! ret ) { // time to make a new one ret.reset( new CprImpl( iParent, m_data ) ); m_top = ret; } return ret; }
//-***************************************************************************** AbcA::CompoundPropertyReaderPtr CprData::getCompoundProperty( AbcA::CompoundPropertyReaderPtr iParent, const std::string &iName ) { // map of names to indexes filled by ctor (CprAttrVistor), // so multithread safe. SubPropertiesMap::iterator fiter = m_subProperties.find( iName ); if ( fiter == m_subProperties.end() ) { return AbcA::CompoundPropertyReaderPtr(); } SubProperty & sub = m_propertyHeaders[fiter->second]; if ( !(sub.header->header.isCompound()) ) { ABCA_THROW( "Tried to read a compound property from a non-compound: " << iName << ", type: " << sub.header->header.getPropertyType() ); } AbcA::BasePropertyReaderPtr bptr = sub.made.lock(); if ( ! bptr ) { Alembic::Util::shared_ptr< ArImpl > implPtr = Alembic::Util::dynamic_pointer_cast< ArImpl, AbcA::ArchiveReader > ( iParent->getObject()->getArchive() ); StreamIDPtr streamId = implPtr->getStreamID(); Ogawa::IGroupPtr group = m_group->getGroup( fiter->second, false, streamId->getID() ); ABCA_ASSERT( group, "Compound Property not backed by a valid group."); // Make a new one. bptr.reset( new CprImpl( iParent, group, sub.header, streamId->getID(), implPtr->getIndexedMetaData() ) ); sub.made = bptr; } AbcA::CompoundPropertyReaderPtr ret = Alembic::Util::dynamic_pointer_cast<AbcA::CompoundPropertyReader, AbcA::BasePropertyReader>( bptr ); return ret; }
//-***************************************************************************** AbcA::ScalarPropertyReaderPtr CprData::getScalarProperty( AbcA::CompoundPropertyReaderPtr iParent, const std::string &iName ) { SubPropertiesMap::iterator fiter = m_subProperties.find( iName ); if ( fiter == m_subProperties.end() ) { return AbcA::ScalarPropertyReaderPtr(); } SubProperty & sub = m_propertyHeaders[fiter->second]; if ( !(sub.header->header.isScalar()) ) { ABCA_THROW( "Tried to read a scalar property from a non-scalar: " << iName << ", type: " << sub.header->header.getPropertyType() ); } AbcA::BasePropertyReaderPtr bptr = sub.made.lock(); if ( ! bptr ) { StreamIDPtr streamId = Alembic::Util::dynamic_pointer_cast< ArImpl, AbcA::ArchiveReader > ( iParent->getObject()->getArchive() )->getStreamID(); Ogawa::IGroupPtr group = m_group->getGroup( fiter->second, true, streamId->getID() ); ABCA_ASSERT( group, "Scalar Property not backed by a valid group."); // Make a new one. bptr.reset( new SprImpl( iParent, group, sub.header ) ); sub.made = bptr; } AbcA::ScalarPropertyReaderPtr ret = Alembic::Util::dynamic_pointer_cast<AbcA::ScalarPropertyReader, AbcA::BasePropertyReader>( bptr ); return ret; }
//-***************************************************************************** void IXformSchema::init( const Abc::Argument &iArg0, const Abc::Argument &iArg1 ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IXformSchema::init()" ); Abc::Arguments args; iArg0.setInto( args ); iArg1.setInto( args ); AbcA::CompoundPropertyReaderPtr ptr = this->getPtr(); if ( ptr->getPropertyHeader( ".childBnds" ) ) { m_childBoundsProperty = Abc::IBox3dProperty( ptr, ".childBnds", iArg0, iArg1 ); } if ( ptr->getPropertyHeader( ".inherits" ) ) { m_inheritsProperty = Abc::IBoolProperty( ptr, ".inherits", iArg0, iArg1 ); } AbcA::ScalarPropertyReaderPtr ops = ptr->getScalarProperty( ".ops" ); m_useArrayProp = false; const AbcA::PropertyHeader *valsPH = ptr->getPropertyHeader( ".vals" ); if ( valsPH != NULL ) { if ( valsPH->isScalar() ) { m_valsProperty = ptr->getScalarProperty( valsPH->getName() ); } else { m_useArrayProp = true; m_valsProperty = ptr->getArrayProperty( valsPH->getName() ); } } m_isConstantIdentity = true; if ( ptr->getPropertyHeader( "isNotConstantIdentity" ) ) { // that it's here at all means we're not constant identity. m_isConstantIdentity = false; } m_isConstant = true; if ( m_valsProperty ) { if ( m_useArrayProp ) { m_isConstant = m_valsProperty->asArrayPtr()->isConstant(); } else { m_isConstant = m_valsProperty->asScalarPtr()->isConstant(); } } m_isConstant = m_isConstant && ( !m_inheritsProperty || m_inheritsProperty.isConstant() ); std::set < Alembic::Util::uint32_t > animChannels; if ( ptr->getPropertyHeader( ".animChans" ) ) { Abc::IUInt32ArrayProperty p( ptr, ".animChans" ); if ( p.getNumSamples() > 0 ) { Abc::UInt32ArraySamplePtr animSamp; p.get( animSamp, p.getNumSamples() - 1 ); for ( std::size_t i = 0; i < animSamp->size(); ++i ) { animChannels.insert( (*animSamp)[i] ); } } } if ( ops && ops->getNumSamples() > 0 ) { std::size_t numOps = ops->getHeader().getDataType().getExtent(); std::vector<Alembic::Util::uint8_t> opVec( numOps ); ops->getSample( 0, &(opVec.front()) ); for ( std::size_t i = 0; i < numOps; ++i ) { XformOp op( opVec[i] ); m_sample.addOp( op ); } std::set < Alembic::Util::uint32_t >::iterator it, itEnd; std::vector< XformOp >::iterator op = m_sample.m_ops.begin(); std::vector< XformOp >::iterator opEnd = m_sample.m_ops.end(); std::size_t curChan = 0; std::size_t chanPos = 0; for ( it = animChannels.begin(), itEnd = animChannels.end(); it != itEnd; ++it ) { Alembic::Util::uint32_t animChan = *it; while ( op != opEnd ) { std::size_t numChans = op->getNumChannels(); bool foundChan = false; while ( curChan < numChans ) { if ( animChan == chanPos ) { op->m_animChannels.insert( curChan ); foundChan = true; break; } ++curChan; ++chanPos; } // move on to the next animChan, because we found the current one if ( foundChan == true ) { ++curChan; ++chanPos; break; } ++op; curChan = 0; } } } if ( ptr->getPropertyHeader( ".arbGeomParams" ) != NULL ) { m_arbGeomParams = Abc::ICompoundProperty( ptr, ".arbGeomParams", args.getErrorHandlerPolicy() ); } if ( ptr->getPropertyHeader( ".userProperties" ) != NULL ) { m_userProperties = Abc::ICompoundProperty( ptr, ".userProperties", args.getErrorHandlerPolicy() ); } ALEMBIC_ABC_SAFE_CALL_END_RESET(); }