Example #1
0
//-*****************************************************************************
AwImpl::AwImpl( const std::string &iFileName,
                const AbcA::MetaData &iMetaData )
  : m_fileName( iFileName )
  , m_metaData( iMetaData )
  , m_file( -1 )
{

    // add default time sampling
    AbcA::TimeSamplingPtr ts( new AbcA::TimeSampling() );
    m_timeSamples.push_back(ts);

    // OPEN THE FILE!
    hid_t faid = H5Pcreate( H5P_FILE_ACCESS );
    if ( faid < 0 )
    {
        ABCA_THROW( "Could not create property access for fopen" );
    }
    H5Pset_libver_bounds( faid, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST );

    m_file = H5Fcreate( m_fileName.c_str(),
                        H5F_ACC_TRUNC, H5P_DEFAULT,
                        faid );

    H5Pclose( faid );

    if ( m_file < 0 )
    {
        ABCA_THROW( "Could not open file: " << m_fileName );
    }

    // set the version using HDF5 native calls
    // This expresses the AbcCoreHDF5 version - how properties,
    // are stored within HDF5, etc.
    int version = ALEMBIC_HDF5_FILE_VERSION;
    H5LTset_attribute_int(m_file, ".", "abc_version", &version, 1);

    // This is the Alembic library version XXYYZZ
    // Where XX is the major version, YY is the minor version
    // and ZZ is the patch version
    int libraryVersion = ALEMBIC_LIBRARY_VERSION;
    H5LTset_attribute_int(m_file, ".", "abc_release_version", 
        &libraryVersion, 1);

    m_metaData.set("_ai_AlembicVersion", AbcA::GetLibraryVersion());

    // Create top explicitly.
    m_top = new TopOwImpl( *this, m_file, m_metaData );
}
Example #2
0
//-*****************************************************************************
CprImpl::CprImpl( AbcA::CompoundPropertyReaderPtr iParent,
                  H5Node & iParentGroup,
                  PropertyHeaderPtr iHeader )
    : m_parent( iParent )
    , m_header( iHeader )
{
    ABCA_ASSERT( m_parent, "Invalid parent in CprImpl(Compound)" );
    ABCA_ASSERT( m_header, "invalid header in CprImpl(Compound)" );

    AbcA::PropertyType pType = m_header->getPropertyType();
    if ( pType != AbcA::kCompoundProperty )
    {
        ABCA_THROW( "Tried to create compound property with the wrong "
                    "property type: " << pType );
    }

    // Set object.
    AbcA::ObjectReaderPtr optr = m_parent->getObject();
    ABCA_ASSERT( optr, "Invalid object in CprImpl::CprImpl(Compound)" );
    m_object = optr;

    m_data.reset( new CprData( iParentGroup,
        m_parent->getObject()->getArchive()->getArchiveVersion(),
        m_header->getName() ) );
}
Example #3
0
//-*****************************************************************************
// With the compound property writer as an input.
CpwImpl::CpwImpl( AbcA::CompoundPropertyWriterPtr iParent,
                  hid_t iParentGroup,
                  PropertyHeaderPtr iHeader )
  : BaseCpwImpl( iParentGroup )
  , m_parent( iParent )
  , m_header( iHeader )
{
    // Check the validity of all inputs.
    ABCA_ASSERT( m_parent, "Invalid parent" );
    ABCA_ASSERT( m_header, "Invalid property header" );

    if ( m_header->getPropertyType() != AbcA::kCompoundProperty )
    {
        ABCA_THROW( "Tried to create compound property with the wrong "
                     "property type: " << m_header->getPropertyType() );
    }

    // Set the object.
    AbcA::ObjectWriterPtr optr = m_parent->getObject();
    ABCA_ASSERT( optr, "Invalid object" );
    m_object = optr;

    // Write the property header.
    WritePropertyHeaderExceptTime( iParentGroup,
                                   m_header->getName(),
                                   *m_header );
}
Example #4
0
//-*****************************************************************************
CprImpl::CprImpl( AbcA::CompoundPropertyReaderPtr iParent,
                  Ogawa::IGroupPtr iGroup,
                  PropertyHeaderPtr iHeader,
                  std::size_t iThreadId,
                  const std::vector< AbcA::MetaData > & iIndexedMetaData )
    : m_parent( iParent )
    , m_header( iHeader )
{
    ABCA_ASSERT( m_parent, "Invalid parent in CprImpl(Compound)" );
    ABCA_ASSERT( m_header, "invalid header in CprImpl(Compound)" );

    AbcA::PropertyType pType = m_header->header.getPropertyType();
    if ( pType != AbcA::kCompoundProperty )
    {
        ABCA_THROW( "Tried to create compound property with the wrong "
                    "property type: " << pType );
    }

    // Set object.
    AbcA::ObjectReaderPtr optr = m_parent->getObject();
    ABCA_ASSERT( optr, "Invalid object in CprImpl::CprImpl(Compound)" );
    m_object = optr;

    m_data.reset( new CprData( iGroup, iThreadId, *( m_object->getArchive() ),
                               iIndexedMetaData ) );
}
Example #5
0
//-*****************************************************************************
AbcA::CompoundPropertyWriterPtr
CpwData::createCompoundProperty( AbcA::CompoundPropertyWriterPtr iParent,
                                 const std::string & iName,
                                 const AbcA::MetaData & iMetaData )
{
    if ( m_madeProperties.count( iName ) )
    {
        ABCA_THROW( "Already have a property named: " << iName );
    }

   PropertyHeaderPtr headerPtr( new PropertyHeaderAndFriends( iName,
                                iMetaData ) );

    Alembic::Util::shared_ptr<CpwImpl>
        ret( new CpwImpl( iParent, m_group->addGroup(), headerPtr,
                          m_propertyHeaders.size() ) );

    m_propertyHeaders.push_back( headerPtr );
    m_madeProperties[iName] = WeakBpwPtr( ret );

    m_hashes.push_back(0);
    m_hashes.push_back(0);

    return ret;
}
Example #6
0
//-*****************************************************************************
// With the compound property writer as an input.
CpwImpl::CpwImpl( AbcA::CompoundPropertyWriterPtr iParent,
                  hid_t iParentGroup,
                  const std::string & iName,
                  const AbcA::MetaData & iMeta )
  : BaseCpwImpl( iParentGroup )
  , m_parent( iParent )
  , m_header( new AbcA::PropertyHeader(iName, iMeta) )
{
    // Check the validity of all inputs.
    ABCA_ASSERT( m_parent, "Invalid parent" );
    ABCA_ASSERT( m_header, "Invalid property header" );

    if ( m_header->getPropertyType() != AbcA::kCompoundProperty )
    {
        ABCA_THROW( "Tried to create compound property with the wrong "
                     "property type: " << m_header->getPropertyType() );
    }

    // Set the object.
    AbcA::ObjectWriterPtr optr = m_parent->getObject();
    ABCA_ASSERT( optr, "Invalid object" );
    m_object = optr;

    // Write the property header.
    WritePropertyInfo( iParentGroup, m_header->getName(),
        m_header->getPropertyType(), m_header->getDataType(),
        false, 0, 0, 0, 0 );

    WriteMetaData( iParentGroup, m_header->getName() + ".meta",
        m_header->getMetaData() );
}
Example #7
0
AbcA::ObjectWriterPtr OwData::createChild( AbcA::ObjectWriterPtr iParent,
                                           const std::string & iFullName,
                                           const AbcA::ObjectHeader &iHeader )
{
    std::string name = iHeader.getName();

    if ( m_madeChildren.count( name ) )
    {
        ABCA_THROW( "Already have an Object named: "
                     << name );
    }

    if ( name.empty() )
    {
        ABCA_THROW( "Object not given a name, parent is: " <<
                    iFullName );
    }
    else if ( iHeader.getName().find('/') != std::string::npos )
    {
        ABCA_THROW( "Object has illegal name: "
                     << iHeader.getName() );
    }

    std::string parentName = iFullName;
    if ( parentName != "/" )
    {
        parentName += "/";
    }

    ObjectHeaderPtr header(
        new AbcA::ObjectHeader( iHeader.getName(),
                                parentName + iHeader.getName(),
                                iHeader.getMetaData() ) );

    Alembic::Util::shared_ptr<OwImpl> ret( new OwImpl( iParent,
                            m_group,
                            header ) );

    m_childHeaders.push_back( header );
    m_madeChildren[iHeader.getName()] = WeakOwPtr( ret );

    return ret;
}
Example #8
0
//-*****************************************************************************
const AbcA::ObjectHeader & OwData::getChildHeader( size_t i )
{
    if ( i >= m_childHeaders.size() )
    {
        ABCA_THROW( "Out of range index in OwImpl::getChildHeader: "
                     << i );
    }

    ABCA_ASSERT( m_childHeaders[i], "Invalid child header: " << i );

    return *(m_childHeaders[i]);
}
Example #9
0
//-*****************************************************************************
const AbcA::PropertyHeader &
CprData::getPropertyHeader( AbcA::CompoundPropertyReaderPtr iParent, size_t i )
{
    // fixed length and resize called in ctor, so multithread safe.
    if ( i > m_propertyHeaders.size() )
    {
        ABCA_THROW( "Out of range index in "
                    << "CprData::getPropertyHeader: " << i );
    }

    return m_propertyHeaders[i].header->header;
}
Example #10
0
//-*****************************************************************************
const AbcA::PropertyHeader &
BaseCpwImpl::getPropertyHeader( size_t i )
{
    if ( i > m_propertyHeaders.size() )
    {
        ABCA_THROW( "Out of range index in " <<
                    "CpwImpl::getPropertyHeader: " << i );
    }

    PropertyHeaderPtr ptr = m_propertyHeaders[i];
    ABCA_ASSERT( ptr, "Invalid property header ptr in CpwImpl" );

    return *ptr;
}
Example #11
0
//-*************************************************************************
SpwImpl::SpwImpl( AbcA::CompoundPropertyWriterPtr iParent,
                  hid_t iParentGroup,
                  PropertyHeaderPtr iHeader )
  : SimplePwImpl<AbcA::ScalarPropertyWriter,
                 SpwImpl,
                 const void *,
                 ScalarSampleKey>( iParent, iParentGroup, iHeader )
  , m_previousSample( iHeader->getDataType() )
{
    if ( m_header->getPropertyType() != AbcA::kScalarProperty )
    {
        ABCA_THROW( "Attempted to create a ScalarPropertyWriter from a "
                    "non-scalar property type" );
    }
}
Example #12
0
//-*****************************************************************************
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;
}
Example #13
0
//-*****************************************************************************
void XformOp::setAngle( const double iAngle )
{
    switch ( m_type )
    {
    case kRotateOperation:
        m_channels[3] = iAngle;
        break;
    case kRotateXOperation:
    case kRotateYOperation:
    case kRotateZOperation:
        m_channels[0] = iAngle;
        break;
    default:
        ABCA_THROW( "Meaningless to set rotation angle on non-rotation op." );
    }
}
Example #14
0
//-*****************************************************************************
double XformOp::getAngle() const
{
    switch ( m_type )
    {
    case kRotateOperation:
        return m_channels[3];
    case kRotateXOperation:
    case kRotateYOperation:
    case kRotateZOperation:
        return m_channels[0];
    default:
        ABCA_THROW( "Meaningless to get rotation angle from non-rotation op." );
    }

    return 0.0;
}
Example #15
0
//-*****************************************************************************
SpwImpl::SpwImpl( AbcA::CompoundPropertyWriterPtr iParent,
                  Ogawa::OGroupPtr iGroup,
                  PropertyHeaderPtr iHeader,
                  size_t iIndex ) :
    m_parent( iParent ), m_header( iHeader ), m_group( iGroup ),
    m_index( iIndex )
{
    ABCA_ASSERT( m_parent, "Invalid parent" );
    ABCA_ASSERT( m_header, "Invalid property header" );
    ABCA_ASSERT( m_group, "Invalid group" );

    if ( m_header->header.getPropertyType() != AbcA::kScalarProperty )
    {
        ABCA_THROW( "Attempted to create a ScalarPropertyWriter from a "
                    "non-scalar property type" );
    }
}
Example #16
0
//-*****************************************************************************
Abc::V3d XformOp::getAxis() const
{
    switch ( m_type )
    {
    case kRotateOperation:
        return this->getVector();
    case kRotateXOperation:
        return Abc::V3d(1.0, 0.0, 0.0);
    case kRotateYOperation:
        return Abc::V3d(0.0, 1.0, 0.0);
    case kRotateZOperation:
        return Abc::V3d(0.0, 0.0, 1.0);
    default:
        ABCA_THROW( "Meaningless to get rotation axis from non-rotation op." );
    }

    return Abc::V3d(0.0, 0.0, 0.0);
}
Example #17
0
//-*****************************************************************************
void ErrorHandler::handleIt( const std::string &iMsg )
{
    switch ( m_policy )
    {
    case kNoisyNoopPolicy:
        std::cerr << iMsg << std::endl;
        // Intentionally passing through to next
    case kQuietNoopPolicy:
        m_errorLog.append( iMsg );
        m_errorLog.append( "\n" );
        return;

    default:
    case kThrowPolicy:
        ABCA_THROW( iMsg );
        return;
    }
}
Example #18
0
//-*****************************************************************************
AwImpl::AwImpl( std::ostream * iStream,
                const AbcA::MetaData &iMetaData )
    : m_metaData( iMetaData )
    , m_archive( iStream )
    , m_metaDataMap( new MetaDataMap() )
{
    // add default time sampling
    AbcA::TimeSamplingPtr ts( new AbcA::TimeSampling() );
    m_timeSamples.push_back(ts);
    m_maxSamples.push_back(0);

    if ( !m_archive.isValid() )
    {
        ABCA_THROW( "Could not use the given ostream." );
    }

    init();
}
Example #19
0
//-*****************************************************************************
AwImpl::AwImpl( const std::string &iFileName,
                const AbcA::MetaData &iMetaData )
    : m_fileName( iFileName )
    , m_metaData( iMetaData )
    , m_archive( iFileName )
    , m_metaDataMap( new MetaDataMap() )
{

    // add default time sampling
    AbcA::TimeSamplingPtr ts( new AbcA::TimeSampling() );
    m_timeSamples.push_back(ts);
    m_maxSamples.push_back(0);

    if ( !m_archive.isValid() )
    {
        ABCA_THROW( "Could not open file: " << m_fileName );
    }

    init();
}
Example #20
0
//-*****************************************************************************
AbcA::ArrayPropertyReaderPtr
CprData::getArrayProperty( 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::ArrayPropertyReaderPtr();
    }

    // make sure we've read the header
    getPropertyHeader( iParent, fiter->second );
    SubProperty & sub = m_propertyHeaders[fiter->second];

    if ( !(sub.header->isArray()) )
    {
        ABCA_THROW( "Tried to read an array property from a non-array: "
                    << iName << ", type: "
                    << sub.header->getPropertyType() );
    }

    Alembic::Util::scoped_lock l( m_subPropertyMutexes[fiter->second] );
    AbcA::BasePropertyReaderPtr bptr = sub.made.lock();
    if ( ! bptr )
    {
        // Make a new one.
        bptr = Alembic::Util::shared_ptr<AprImpl>(
            new AprImpl( iParent, m_group, sub.header, sub.isScalarLike,
                         sub.numSamples, sub.firstChangedIndex,
                         sub.lastChangedIndex ) );

        sub.made = bptr;
    }

    AbcA::ArrayPropertyReaderPtr ret =
        Alembic::Util::dynamic_pointer_cast<AbcA::ArrayPropertyReader,
        AbcA::BasePropertyReader>( bptr );
    return ret;
}
Example #21
0
//-*****************************************************************************
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;
}
Example #22
0
//-*****************************************************************************
AwImpl::~AwImpl()
{
    delete m_top;
    m_top = NULL;

    // empty out the map so any dataset IDs will be freed up
    m_writtenArraySampleMap.m_map.clear();

    if ( m_file >= 0 )
    {
        int dsetCount = H5Fget_obj_count( m_file,
            H5F_OBJ_LOCAL | H5F_OBJ_DATASET);
        int grpCount = H5Fget_obj_count( m_file,
            H5F_OBJ_LOCAL | H5F_OBJ_GROUP );
        int dtypCount = H5Fget_obj_count( m_file,
            H5F_OBJ_LOCAL | H5F_OBJ_DATATYPE );
        int attrCount = H5Fget_obj_count( m_file,
            H5F_OBJ_LOCAL | H5F_OBJ_ATTR );

        int objCount = dsetCount + grpCount + dtypCount + attrCount;

        if ( objCount != 0 )
        {
            std::string excStr =
                ( boost::format(
                      "Open HDF5 handles detected during writing:\n"
                      "DataSets: %d, Groups: %d, "
                      "DataTypes: %d, Attributes: %d" )
                  % dsetCount
                  % grpCount
                  % dtypCount
                  % attrCount ).str();

            m_file = -1;
            ABCA_THROW( excStr );
        }

        H5Fclose( m_file );
        m_file = -1;
    }
}
Example #23
0
//-*****************************************************************************
AbcA::CompoundPropertyWriterPtr
BaseCpwImpl::createCompoundProperty( const std::string & iName,
        const AbcA::MetaData & iMetaData )
{

    if ( m_madeProperties.count( iName ) )
    {
        ABCA_THROW( "Already have a property named: " << iName );
    }

    hid_t myGroup = getGroup();

    AbcA::CompoundPropertyWriterPtr
        ret( new CpwImpl( this->asCompoundPtr(), myGroup, iName, iMetaData ) );

    PropertyHeaderPtr headerPtr( new AbcA::PropertyHeader( ret->getHeader() ) );
    m_propertyHeaders.push_back( headerPtr );
    m_madeProperties[iName] = WeakBpwPtr( ret );

    return ret;
}
Example #24
0
//-*****************************************************************************
CprImpl::CprImpl( AbcA::CompoundPropertyReaderPtr iParent,
                  hid_t iParentGroup,
                  PropertyHeaderPtr iHeader )
  : BaseCprImpl( iParentGroup, iHeader->getName() )
  , m_parent( iParent )
  , m_header( iHeader )
{
    ABCA_ASSERT( m_parent, "invalid parent" );
    ABCA_ASSERT( m_header, "invalid header" );
    
    AbcA::PropertyType pType = m_header->getPropertyType();
    if ( pType != AbcA::kCompoundProperty )
    {
        ABCA_THROW( "Tried to create compound property with the wrong "
                    "property type: " << pType );
    }

    // Set object.
    AbcA::ObjectReaderPtr optr = m_parent->getObject();
    ABCA_ASSERT( optr, "Invalid object in CprImpl::CprImpl()" );
    m_object = optr;
}
Example #25
0
//-*****************************************************************************
const AbcA::PropertyHeader &
CprData::getPropertyHeader( AbcA::CompoundPropertyReaderPtr iParent, size_t i )
{
    // fixed length and resize called in ctor, so multithread safe.
    if ( i > m_propertyHeaders.size() )
    {
        ABCA_THROW( "Out of range index in "
                    << "CprData::getPropertyHeader: " << i );
    }
    Alembic::Util::scoped_lock l( m_subPropertyMutexes[i] );

    // read the property header stuff if we haven't yet
    if ( m_propertyHeaders[i].header == NULL )
    {
        uint32_t tsid = 0;

        PropertyHeaderPtr iPtr( new AbcA::PropertyHeader() );
        ReadPropertyHeader( m_group, m_propertyHeaders[i].name, *iPtr,
                            m_propertyHeaders[i].isScalarLike,
                            m_propertyHeaders[i].numSamples,
                            m_propertyHeaders[i].firstChangedIndex,
                            m_propertyHeaders[i].lastChangedIndex, tsid );

        if ( iPtr->isSimple() )
        {
            AbcA::TimeSamplingPtr tsPtr =
                iParent->getObject()->getArchive()->getTimeSampling( tsid );

            iPtr->setTimeSampling(tsPtr);
        }

        m_propertyHeaders[i].header = iPtr;

        // don't need name anymore (it's in the header)
        m_propertyHeaders[i].name = "";
    }

    return *(m_propertyHeaders[i].header);
}
Example #26
0
//-*****************************************************************************
ArImpl::~ArImpl()
{
    delete m_top;
    m_top = NULL;

    if ( m_file >= 0 )
    {
        int dsetCount = H5Fget_obj_count( m_file,
            H5F_OBJ_LOCAL | H5F_OBJ_DATASET);
        int grpCount = H5Fget_obj_count( m_file,
            H5F_OBJ_LOCAL | H5F_OBJ_GROUP );
        int dtypCount = H5Fget_obj_count( m_file,
            H5F_OBJ_LOCAL | H5F_OBJ_DATATYPE );
        int attrCount = H5Fget_obj_count( m_file,
            H5F_OBJ_LOCAL | H5F_OBJ_ATTR );

        int objCount = dsetCount + grpCount + dtypCount + attrCount;

        if ( objCount != 0 )
        {
            std::string excStr =
                ( boost::format(
                      "Open HDF5 handles detected during reading:\n"
                      "DataSets: %d, Groups: %d, "
                      "DataTypes: %d, Attributes: %d" )
                  % dsetCount
                  % grpCount
                  % dtypCount
                  % attrCount ).str();

            m_file = -1;
            ABCA_THROW( excStr );
        }

        H5Fclose( m_file );
        m_file = -1;
    }
}
Example #27
0
//-*****************************************************************************
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();
    }

    // make sure we've read the header
    getPropertyHeader( iParent, fiter->second );
    SubProperty & sub = m_propertyHeaders[fiter->second];

    if ( !(sub.header->isCompound()) )
    {
        ABCA_THROW( "Tried to read a compound property from a non-compound: "
                    << iName << ", type: "
                    << sub.header->getPropertyType() );
    }

    AbcA::BasePropertyReaderPtr bptr = sub.made.lock();
    if ( ! bptr )
    {
        // Make a new one.
        bptr = Alembic::Util::shared_ptr<CprImpl>(
            new CprImpl( iParent, m_group, sub.header ) );

        sub.made = bptr;
    }

    AbcA::CompoundPropertyReaderPtr ret =
        Alembic::Util::dynamic_pointer_cast<AbcA::CompoundPropertyReader,
        AbcA::BasePropertyReader>( bptr );
    return ret;
}
Example #28
0
//-*****************************************************************************
AbcA::ScalarPropertyWriterPtr
BaseCpwImpl::createScalarProperty( const std::string & iName,
        const AbcA::MetaData & iMetaData,
        const AbcA::DataType & iDataType,
        uint32_t iTimeSamplingIndex )
{
    if ( m_madeProperties.count( iName ) )
    {
        ABCA_THROW( "Already have a property named: " << iName );
    }

    hid_t myGroup = getGroup();

    AbcA::ScalarPropertyWriterPtr
        ret( new SpwImpl( asCompoundPtr(), myGroup, iName, iMetaData,
            iDataType, iTimeSamplingIndex ) );

    PropertyHeaderPtr headerPtr( new AbcA::PropertyHeader( ret->getHeader() ) );
    m_propertyHeaders.push_back( headerPtr );
    m_madeProperties[iName] = WeakBpwPtr( ret );

    return ret;
}
Example #29
0
//-*****************************************************************************
AbcA::ArrayPropertyWriterPtr
CpwData::createArrayProperty( AbcA::CompoundPropertyWriterPtr iParent,
                              const std::string & iName,
                              const AbcA::MetaData & iMetaData,
                              const AbcA::DataType & iDataType,
                              Util::uint32_t iTimeSamplingIndex )
{
    if ( m_madeProperties.count( iName ) )
    {
        ABCA_THROW( "Already have a property named: " << iName );
    }

    ABCA_ASSERT( iDataType.getExtent() != 0 &&
                 iDataType.getPod() != Alembic::Util::kNumPlainOldDataTypes &&
                 iDataType.getPod() != Alembic::Util::kUnknownPOD,
                 "createArrayProperty, illegal DataType provided.");

    // will assert if TimeSamplingPtr not found
    AbcA::TimeSamplingPtr ts =
        iParent->getObject()->getArchive()->getTimeSampling(
            iTimeSamplingIndex );

    PropertyHeaderPtr headerPtr( new PropertyHeaderAndFriends( iName,
        AbcA::kArrayProperty, iMetaData, iDataType, ts, iTimeSamplingIndex ) );

    Alembic::Util::shared_ptr<ApwImpl>
        ret( new ApwImpl( iParent, m_group->addGroup(), headerPtr,
                          m_propertyHeaders.size() ) );

    m_propertyHeaders.push_back( headerPtr );
    m_madeProperties[iName] = WeakBpwPtr( ret );

    m_hashes.push_back(0);
    m_hashes.push_back(0);

    return ret;
}
Example #30
0
//-*************************************************************************
SpwImpl::SpwImpl( AbcA::CompoundPropertyWriterPtr iParent,
                  hid_t iParentGroup,
                  const std::string & iName,
                  const AbcA::MetaData & iMetaData,
                  const AbcA::DataType & iDataType,
                  uint32_t iTimeSamplingIndex )
  : SimplePwImpl<AbcA::ScalarPropertyWriter,
                 SpwImpl,
                 const void *,
                 ScalarSampleKey>( iParent,
                                   iParentGroup,
                                   iName,
                                   iMetaData,
                                   iDataType,
                                   iTimeSamplingIndex,
                                   AbcA::kScalarProperty )
  , m_previousSample( iDataType )
{
    if ( m_header->getPropertyType() != AbcA::kScalarProperty )
    {
        ABCA_THROW( "Attempted to create a ScalarPropertyWriter from a "
                    "non-scalar property type" );
    }
}