Coverage Report

Created: 2026-01-17 06:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/alembic/lib/Alembic/Abc/IArrayProperty.cpp
Line
Count
Source
1
//-*****************************************************************************
2
//
3
// Copyright (c) 2009-2012,
4
//  Sony Pictures Imageworks, Inc. and
5
//  Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd.
6
//
7
// All rights reserved.
8
//
9
// Redistribution and use in source and binary forms, with or without
10
// modification, are permitted provided that the following conditions are
11
// met:
12
// *       Redistributions of source code must retain the above copyright
13
// notice, this list of conditions and the following disclaimer.
14
// *       Redistributions in binary form must reproduce the above
15
// copyright notice, this list of conditions and the following disclaimer
16
// in the documentation and/or other materials provided with the
17
// distribution.
18
// *       Neither the name of Sony Pictures Imageworks, nor
19
// Industrial Light & Magic nor the names of their contributors may be used
20
// to endorse or promote products derived from this software without specific
21
// prior written permission.
22
//
23
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
//
35
//-*****************************************************************************
36
37
#include <Alembic/Abc/IArrayProperty.h>
38
39
namespace Alembic {
40
namespace Abc {
41
namespace ALEMBIC_VERSION_NS {
42
43
//-*****************************************************************************
44
IArrayProperty::IArrayProperty( const ICompoundProperty & iParent,
45
                                const std::string &iName,
46
                                const Argument &iArg0,
47
                                const Argument &iArg1 )
48
3
{
49
3
    init( iParent.getPtr(), iName,
50
3
          GetErrorHandlerPolicy( iParent ), iArg0, iArg1 );
51
3
}
52
53
//-*****************************************************************************
54
IArrayProperty::~IArrayProperty()
55
12
{
56
    // Nothing for now.
57
    // Mostly here in case we need to add reference-counting debug code.
58
12
}
59
60
//-*****************************************************************************
61
size_t IArrayProperty::getNumSamples() const
62
3
{
63
6
    ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::getNumSamples()" );
64
65
6
    return m_property->getNumSamples();
66
67
6
    ALEMBIC_ABC_SAFE_CALL_END();
68
69
    // Not all error handlers throw, so return a default.
70
0
    return 0;
71
3
}
72
73
//-*****************************************************************************
74
bool IArrayProperty::isConstant() const
75
0
{
76
0
    ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::isConstant()" );
77
78
0
    return m_property->isConstant();
79
80
0
    ALEMBIC_ABC_SAFE_CALL_END();
81
82
    // Not all error handlers throw, so return a default.
83
0
    return false;
84
0
}
85
86
//-*****************************************************************************
87
bool IArrayProperty::isScalarLike() const
88
0
{
89
0
    ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::isScalarLike()" );
90
91
0
    return m_property->isScalarLike();
92
93
0
    ALEMBIC_ABC_SAFE_CALL_END();
94
95
    // Not all error handlers throw, so return a default.
96
0
    return false;
97
0
}
98
99
//-*****************************************************************************
100
AbcA::TimeSamplingPtr IArrayProperty::getTimeSampling() const
101
0
{
102
0
    ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::getTimeSampling()" );
103
104
0
    return m_property->getTimeSampling();
105
106
0
    ALEMBIC_ABC_SAFE_CALL_END();
107
108
    // Not all error handlers throw, so return a default.
109
0
    return AbcA::TimeSamplingPtr();
110
0
}
111
112
//-*****************************************************************************
113
void IArrayProperty::get( AbcA::ArraySamplePtr& oSamp,
114
                          const ISampleSelector &iSS ) const
115
0
{
116
0
    ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::get()" );
117
118
0
    m_property->getSample(
119
0
        iSS.getIndex( m_property->getTimeSampling(),
120
0
                      m_property->getNumSamples() ),
121
0
        oSamp );
122
123
0
    ALEMBIC_ABC_SAFE_CALL_END();
124
0
}
125
126
//-*****************************************************************************
127
void IArrayProperty::getAs( void * oSample,
128
                            AbcA::PlainOldDataType iPod,
129
                            const ISampleSelector &iSS )
130
0
{
131
0
    ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::getAs(PlainOldDataType)" );
132
133
0
    m_property->getAs( iSS.getIndex( m_property->getTimeSampling(),
134
0
                                     m_property->getNumSamples() ),
135
0
                       oSample,
136
0
                       iPod
137
0
                     );
138
139
0
    ALEMBIC_ABC_SAFE_CALL_END();
140
0
}
141
142
//-*****************************************************************************
143
void IArrayProperty::getAs( void * oSample,
144
                            const ISampleSelector &iSS )
145
0
{
146
0
    ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::getAs()" );
147
148
0
    m_property->getAs( iSS.getIndex( m_property->getTimeSampling(),
149
0
                                     m_property->getNumSamples() ),
150
0
                       oSample,
151
0
                       m_property->getDataType().getPod()
152
0
                     );
153
154
0
    ALEMBIC_ABC_SAFE_CALL_END();
155
0
}
156
157
//-*****************************************************************************
158
bool IArrayProperty::getKey( AbcA::ArraySampleKey& oKey,
159
                             const ISampleSelector &iSS ) const
160
0
{
161
0
    ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::getKey()" );
162
163
0
    return m_property->getKey(
164
0
        iSS.getIndex( m_property->getTimeSampling(),
165
0
                      m_property->getNumSamples() ),
166
0
        oKey );
167
168
0
    ALEMBIC_ABC_SAFE_CALL_END();
169
170
    // for error handler that don't throw
171
0
    return false;
172
0
}
173
174
//-*****************************************************************************
175
void IArrayProperty::getDimensions( Util::Dimensions & oDim,
176
                                    const ISampleSelector &iSS ) const
177
0
{
178
0
    ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::getDimensions()" );
179
180
0
    m_property->getDimensions(
181
0
        iSS.getIndex( m_property->getTimeSampling(),
182
0
                      m_property->getNumSamples() ),
183
0
        oDim );
184
185
0
    ALEMBIC_ABC_SAFE_CALL_END();
186
0
}
187
188
//-*****************************************************************************
189
ICompoundProperty IArrayProperty::getParent() const
190
0
{
191
0
    ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::getParent()" );
192
193
0
    return ICompoundProperty( m_property->getParent(),
194
0
                              getErrorHandlerPolicy() );
195
196
0
    ALEMBIC_ABC_SAFE_CALL_END();
197
198
    // Not all error handlers throw. Have a default.
199
0
    return ICompoundProperty();
200
0
}
201
202
//-*****************************************************************************
203
void IArrayProperty::init( AbcA::CompoundPropertyReaderPtr iParent,
204
                           const std::string &iName,
205
206
                           ErrorHandler::Policy iParentPolicy,
207
                           const Argument &iArg0,
208
                           const Argument &iArg1 )
209
3
{
210
3
    Arguments args( iParentPolicy );
211
3
    iArg0.setInto( args );
212
3
    iArg1.setInto( args );
213
214
3
    getErrorHandler().setPolicy( args.getErrorHandlerPolicy() );
215
216
6
    ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::init()" );
217
218
6
    const AbcA::PropertyHeader *pheader =
219
6
        iParent->getPropertyHeader( iName );
220
221
6
    ABCA_ASSERT( pheader != NULL,
222
6
                 "Nonexistent array property: " << iName );
223
224
3
    m_property = iParent->getArrayProperty( iName );
225
226
3
    ALEMBIC_ABC_SAFE_CALL_END_RESET();
227
3
}
228
229
} // End namespace ALEMBIC_VERSION_NS
230
} // End namespace Abc
231
} // End namespace Alembic