Coverage Report

Created: 2023-03-26 07:07

/src/alembic/lib/Alembic/AbcGeom/IXform.h
Line
Count
Source (jump to first uncovered line)
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
#ifndef Alembic_AbcGeom_IXform_h
38
#define Alembic_AbcGeom_IXform_h
39
40
#include <Alembic/Util/Export.h>
41
#include <Alembic/AbcGeom/Foundation.h>
42
#include <Alembic/AbcGeom/SchemaInfoDeclarations.h>
43
44
#include <Alembic/AbcGeom/XformSample.h>
45
46
namespace Alembic {
47
namespace AbcGeom {
48
namespace ALEMBIC_VERSION_NS {
49
50
//-*****************************************************************************
51
class ALEMBIC_EXPORT IXformSchema : public Abc::ISchema<XformSchemaInfo>
52
{
53
    //-*************************************************************************
54
    // XFORM SCHEMA
55
    //-*************************************************************************
56
public:
57
58
    //! By convention we always define this_type in AbcGeom classes.
59
    //! Used by unspecified-bool-type conversion below
60
    typedef Abc::ISchema<XformSchemaInfo> super_type;
61
    typedef IXformSchema this_type;
62
    typedef XformSample sample_type;
63
64
    //-*************************************************************************
65
    // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
66
    //-*************************************************************************
67
68
    //! The default constructor creates an empty IXformSchema
69
    //! ...
70
    IXformSchema()
71
0
    {
72
0
        m_useArrayProp = false;
73
0
        m_isConstant = true;
74
0
        m_isConstantIdentity = true;
75
0
    }
76
77
    //! This constructor creates a new xform reader.
78
    //! The first argument is the parent ICompoundProperty, from which the
79
    //! error handler policy for is derived.  The second argument is the name
80
    //! of the ICompoundProperty that contains this schemas properties.  The
81
    //! remaining optional arguments can be used to override the
82
    //! ErrorHandlerPolicy and to specify schema interpretation matching.
83
    IXformSchema( const ICompoundProperty &iParent,
84
                  const std::string &iName,
85
                  const Abc::Argument &iArg0 = Abc::Argument(),
86
                  const Abc::Argument &iArg1 = Abc::Argument() )
87
      : Abc::ISchema<XformSchemaInfo>( iParent, iName, iArg0, iArg1 )
88
0
    {
89
        // Meta data and error handling are eaten up by
90
        // the super type, so all that's left is SchemaInterpMatching.
91
0
        init( iArg0, iArg1 );
92
0
    }
93
94
    //! This constructor wraps an existing ICompoundProperty as the xform
95
    //! reader, and the error handler policy is derived from it.
96
    //! The  remaining optional arguments can be used to override the
97
    //! ErrorHandlerPolicy and to specify schema interpretation matching.
98
    IXformSchema( const ICompoundProperty &iProp,
99
                  const Abc::Argument &iArg0 = Abc::Argument(),
100
                  const Abc::Argument &iArg1 = Abc::Argument() )
101
      : Abc::ISchema<XformSchemaInfo>( iProp, iArg0, iArg1 )
102
0
    {
103
0
        init( iArg0, iArg1 );
104
0
    }
105
106
    AbcA::TimeSamplingPtr getTimeSampling() const;
107
108
0
    bool isConstant() const { return m_isConstant; }
109
110
    //! is this xform both constant and identity?
111
0
    bool isConstantIdentity() const { return m_isConstantIdentity; }
112
113
    size_t getNumSamples() const;
114
115
    //! fill the supplied sample reference with values
116
    void get( XformSample &oSamp,
117
              const Abc::ISampleSelector &iSS = Abc::ISampleSelector() ) const;
118
119
    XformSample getValue( const Abc::ISampleSelector &iSS =
120
                          Abc::ISampleSelector() ) const;
121
122
    Abc::IBox3dProperty getChildBoundsProperty() const
123
0
    {
124
0
        return m_childBoundsProperty;
125
0
    }
126
127
    // lightweight get to avoid constructing a sample
128
    // see XformSample.h for explanation of this property
129
    bool getInheritsXforms( const Abc::ISampleSelector &iSS =
130
                            Abc::ISampleSelector() ) const;
131
132
0
    size_t getNumOps() const { return m_sample.getNumOps(); }
133
134
    //! Reset returns this function set to an empty, default
135
    //! state.
136
    void reset()
137
0
    {
138
0
        m_childBoundsProperty.reset();
139
0
        m_sample = XformSample();
140
0
        m_inheritsProperty.reset();
141
0
        m_isConstant = true;
142
0
        m_isConstantIdentity = true;
143
144
0
        m_arbGeomParams.reset();
145
0
        m_userProperties.reset();
146
147
0
        super_type::reset();
148
0
    }
149
150
    //! Valid returns whether this function set is valid.
151
    bool valid() const
152
0
    {
153
0
        return ( super_type::valid() );
154
0
    }
155
156
0
    ICompoundProperty getArbGeomParams() const { return m_arbGeomParams; }
157
158
0
    ICompoundProperty getUserProperties() const { return m_userProperties; }
159
160
    //! unspecified-bool-type operator overload.
161
    //! ...
162
    ALEMBIC_OVERRIDE_OPERATOR_BOOL( this_type::valid() );
163
164
165
protected:
166
    Abc::IBox3dProperty m_childBoundsProperty;
167
168
    AbcA::BasePropertyReaderPtr m_valsProperty;
169
170
    Abc::IBoolProperty m_inheritsProperty;
171
172
    Abc::ICompoundProperty m_arbGeomParams;
173
    Abc::ICompoundProperty m_userProperties;
174
175
    bool m_isConstant;
176
177
    bool m_isConstantIdentity;
178
179
    XformSample m_sample;
180
181
private:
182
    void init( const Abc::Argument &iArg0, const Abc::Argument &iArg1 );
183
184
    // is m_vals an ArrayProperty, or a ScalarProperty?
185
    bool m_useArrayProp;
186
187
    // fills m_valVec with data
188
    void getChannelValues( const AbcA::index_t iSampleIndex,
189
                           XformSample & oSamp ) const;
190
};
191
192
//-*****************************************************************************
193
// SCHEMA OBJECT
194
//-*****************************************************************************
195
typedef Abc::ISchemaObject<IXformSchema> IXform;
196
197
typedef Util::shared_ptr< IXform > IXformPtr;
198
199
} // End namespace ALEMBIC_VERSION_NS
200
201
using namespace ALEMBIC_VERSION_NS;
202
203
} // End namespace AbcGeom
204
} // End namespace Alembic
205
206
#endif