Beispiel #1
0
void PrimitiveReader::readGeomParam( const T &param, const Alembic::Abc::ISampleSelector &sampleSelector, IECoreScene::Primitive *primitive ) const
{

	typedef typename T::prop_type::sample_ptr_type SamplePtr;
	typedef typename IGeomParamTraits<T>::DataType DataType;
	typedef typename T::sample_type GeomParamSample;

	if( param.getArrayExtent() > 1 )
	{
		IECore::msg( IECore::Msg::Warning, "FromAlembicGeomBaseConverter::convertArbGeomParam", boost::format( "Param \"%s\" has unsupported array extent" ) % param.getHeader().getName() );
		return;
	}

	SamplePtr sample;
	Abc::UInt32ArraySamplePtr indices;

	if( param.isIndexed() )
	{
		GeomParamSample geomParamSample = param.getIndexedValue( sampleSelector );
		sample = geomParamSample.getVals();
		indices = geomParamSample.getIndices();
	}
	else
	{
		sample = param.getExpandedValue( sampleSelector ).getVals();
	}

	typename DataType::Ptr data = new DataType();
	data->writable().resize( sample->size() );
	std::copy( sample->get(), sample->get() + sample->size(), data->writable().begin() );

	ApplyGeometricInterpretation<DataType, T>::apply( data.get() );

	PrimitiveVariable pv;
	pv.interpolation = interpolation( param.getScope() );
	pv.data = data;

	if( param.isIndexed() )
	{
		IntVectorDataPtr indexData = new IntVectorData();
		indexData->writable().resize( indices->size() );
		std::copy( indices->get(), indices->get() + indices->size(), indexData->writable().begin() );
		pv.indices = indexData;
	}

	primitive->variables[param.getHeader().getName()] = pv;
}
Beispiel #2
0
//-*****************************************************************************
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();
}