Coverage Report

Created: 2025-07-11 06:05

/src/alembic/lib/Alembic/AbcGeom/IFaceSet.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_IFaceSet_h
38
#define Alembic_AbcGeom_IFaceSet_h
39
40
#include <Alembic/Util/Export.h>
41
#include <Alembic/AbcGeom/Foundation.h>
42
#include <Alembic/AbcGeom/SchemaInfoDeclarations.h>
43
#include <Alembic/AbcGeom/IGeomParam.h>
44
#include <Alembic/AbcGeom/FaceSetExclusivity.h>
45
#include <Alembic/AbcGeom/IGeomBase.h>
46
47
namespace Alembic {
48
namespace AbcGeom {
49
namespace ALEMBIC_VERSION_NS {
50
51
//-*****************************************************************************
52
class ALEMBIC_EXPORT IFaceSetSchema : public IGeomBaseSchema<FaceSetSchemaInfo>
53
{
54
public:
55
    //-*************************************************************************
56
    // FACESET MESH SCHEMA SAMPLE TYPE
57
    //-*************************************************************************
58
    class Sample
59
    {
60
    public:
61
        typedef Sample this_type;
62
63
        //! Users never create this data directly
64
0
        Sample() { reset(); }
65
66
        // main stuff
67
0
        Abc::Int32ArraySamplePtr getFaces() const { return m_faces; }
68
69
        // bounds
70
0
        Abc::Box3d getSelfBounds() const { return m_selfBounds; }
71
72
        bool valid() const
73
0
        {
74
0
            return m_faces.get() != 0;
75
0
        }
76
77
        void reset()
78
0
        {
79
0
            m_faces.reset();
80
0
81
0
            m_selfBounds.makeEmpty();
82
0
        }
83
84
        ALEMBIC_OPERATOR_BOOL( valid() );
85
86
    protected:
87
        friend class IFaceSetSchema;
88
89
        Abc::Int32ArraySamplePtr    m_faces;
90
91
92
        // bounds
93
        Abc::Box3d m_selfBounds;
94
95
    }; // end IFaceSetSchema::Sample
96
97
    //-*************************************************************************
98
    // FACESET SCHEMA
99
    //-*************************************************************************
100
public:
101
    //! By convention we always define this_type in AbcGeom classes.
102
    //! Used by unspecified-bool-type conversion below
103
    typedef IFaceSetSchema this_type;
104
105
    //-*************************************************************************
106
    // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
107
    //-*************************************************************************
108
109
    //! The default constructor creates an empty IFaceSetSchema
110
    //! ...
111
0
    IFaceSetSchema() {}
112
113
    //! This constructor creates a new faceset reader.
114
    //! The first argument is the parent ICompoundProperty, from which the
115
    //! error handler policy for is derived.  The second argument is the name
116
    //! of the ICompoundProperty that contains this schemas properties.  The
117
    //! remaining optional arguments can be used to override the
118
    //! ErrorHandlerPolicy and to specify schema interpretation matching.
119
    IFaceSetSchema( const ICompoundProperty &iParent,
120
                    const std::string &iName,
121
122
                    const Abc::Argument &iArg0 = Abc::Argument(),
123
                    const Abc::Argument &iArg1 = Abc::Argument() )
124
0
      : IGeomBaseSchema<FaceSetSchemaInfo>( iParent, iName, iArg0, iArg1 )
125
0
    {
126
0
        init(  iArg0, iArg1 );
127
0
    }
128
129
    //! This constructor wraps an existing ICompoundProperty as the faceset
130
    //! reader, and the error handler policy is derived from it.
131
    //! The  remaining optional arguments can be used to override the
132
    //! ErrorHandlerPolicy and to specify schema interpretation matching.
133
    IFaceSetSchema( const ICompoundProperty &iProp,
134
                    const Abc::Argument &iArg0 = Abc::Argument(),
135
                    const Abc::Argument &iArg1 = Abc::Argument() )
136
      : IGeomBaseSchema<FaceSetSchemaInfo>( iProp, iArg0, iArg1 )
137
0
    {
138
0
        init( iArg0, iArg1 );
139
0
    }
140
141
    //! wrap an existing schema object
142
    template <class CPROP_PTR>
143
    IFaceSetSchema( CPROP_PTR iThis,
144
                 Abc::WrapExistingFlag iFlag,
145
146
                 const Abc::Argument &iArg0 = Abc::Argument(),
147
                 const Abc::Argument &iArg1 = Abc::Argument() )
148
      : IGeomBaseSchema<FaceSetSchemaInfo>( iThis, iFlag, iArg0, iArg1 )
149
    {
150
        init( iArg0, iArg1 );
151
    }
152
153
    //! Default assignment and copy operator used.
154
155
    //-*************************************************************************
156
    // SCHEMA STUFF
157
    //-*************************************************************************
158
159
160
    //! if isConstant() is true, the mesh contains no time-varying values
161
0
    bool isConstant() const { return (m_facesProperty.isConstant ()); }
162
163
    //-*************************************************************************
164
    // SAMPLE STUFF
165
    //-*************************************************************************
166
167
    //! Get number of samples written so far.
168
    //! ...
169
    size_t getNumSamples() const;
170
171
    //! Return the time sampling
172
    AbcA::TimeSamplingPtr getTimeSampling() const
173
0
    {
174
0
        if ( m_facesProperty.valid() )
175
0
            return m_facesProperty.getTimeSampling();
176
0
        return getObject().getArchive().getTimeSampling(0);
177
0
    }
178
179
    void get( Sample &iSamp,
180
              const Abc::ISampleSelector &iSS = Abc::ISampleSelector() ) const;
181
182
    Sample getValue( const Abc::ISampleSelector &iSS = Abc::ISampleSelector() ) const
183
0
    {
184
0
        Sample smp;
185
0
        get( smp, iSS );
186
0
        return smp;
187
0
    }
188
189
    FaceSetExclusivity getFaceExclusivity() const;
190
191
    Abc::IInt32ArrayProperty getFacesProperty() const
192
0
    {
193
0
        return m_facesProperty;
194
0
    }
195
196
    //-*************************************************************************
197
    // ABC BASE MECHANISMS
198
    // These functions are used by Abc to deal with errors, rewrapping,
199
    // and so on.
200
    //-*************************************************************************
201
202
    //! Reset returns this function set to an empty, default
203
    //! state.
204
    void reset()
205
0
    {
206
0
        m_facesProperty.reset();
207
208
0
        IGeomBaseSchema<FaceSetSchemaInfo>::reset();
209
0
    }
210
211
    //! Valid returns whether this function set is
212
    //! valid.
213
    bool valid() const
214
0
    {
215
0
        return ( IGeomBaseSchema<FaceSetSchemaInfo>::valid() &&
216
0
                 m_facesProperty.valid() );
217
0
    }
218
219
    //! unspecified-bool-type operator overload.
220
    //! ...
221
    ALEMBIC_OVERRIDE_OPERATOR_BOOL( IFaceSetSchema::valid() );
222
223
protected:
224
    void init( const Abc::Argument &iArg0, const Abc::Argument &iArg1 );
225
226
    Abc::IInt32ArrayProperty    m_facesProperty;
227
};
228
229
//-*****************************************************************************
230
// SCHEMA OBJECT
231
//-*****************************************************************************
232
typedef Abc::ISchemaObject<IFaceSetSchema> IFaceSet;
233
234
typedef Util::shared_ptr< IFaceSet > IFaceSetPtr;
235
236
} // End namespace ALEMBIC_VERSION_NS
237
238
using namespace ALEMBIC_VERSION_NS;
239
240
} // End namespace AbcGeom
241
} // End namespace Alembic
242
243
#endif