Coverage Report

Created: 2026-03-31 06:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/alembic/lib/Alembic/AbcGeom/ICurves.cpp
Line
Count
Source
1
//-*****************************************************************************
2
//
3
// Copyright (c) 2009-2013,
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/AbcGeom/ICurves.h>
38
39
namespace Alembic {
40
namespace AbcGeom {
41
namespace ALEMBIC_VERSION_NS {
42
43
//-*****************************************************************************
44
MeshTopologyVariance ICurvesSchema::getTopologyVariance() const
45
0
{
46
0
    ALEMBIC_ABC_SAFE_CALL_BEGIN( "ICurvesSchema::getTopologyVariance()" );
47
48
0
    bool pointsConstant = m_positionsProperty.isConstant() &&
49
0
        ( !m_positionWeightsProperty ||
50
0
           m_positionWeightsProperty.isConstant() );
51
52
0
    if ( pointsConstant && m_nVerticesProperty.isConstant() &&
53
0
         m_basisAndTypeProperty.isConstant() )
54
0
    {
55
0
        return kConstantTopology;
56
0
    }
57
58
0
    else if ( m_nVerticesProperty.isConstant() &&
59
0
              m_basisAndTypeProperty.isConstant() )
60
0
    {
61
0
        return kHomogenousTopology;
62
0
    }
63
0
    else
64
0
    {
65
0
        return kHeterogenousTopology;
66
0
    }
67
68
0
    ALEMBIC_ABC_SAFE_CALL_END();
69
70
    // Not all error handlers throw
71
0
    return kHeterogenousTopology;
72
0
}
73
74
//-*****************************************************************************
75
void ICurvesSchema::init( const Abc::Argument &iArg0,
76
                          const Abc::Argument &iArg1 )
77
0
{
78
    // Only callable by ctors (mt-safety)
79
0
    ALEMBIC_ABC_SAFE_CALL_BEGIN( "ICurvesSchema::init()" );
80
81
0
    Abc::Arguments args;
82
0
    iArg0.setInto( args );
83
0
    iArg1.setInto( args );
84
85
0
    AbcA::CompoundPropertyReaderPtr _this = this->getPtr();
86
87
    // no matching so we pick up old assets written as V3f
88
0
    m_positionsProperty = Abc::IP3fArrayProperty( _this, "P", kNoMatching,
89
0
        args.getErrorHandlerPolicy() );
90
91
0
    m_nVerticesProperty = Abc::IInt32ArrayProperty( _this, "nVertices",
92
0
                                                    iArg0, iArg1 );
93
94
95
0
    m_basisAndTypeProperty = Abc::IScalarProperty( _this, "curveBasisAndType",
96
0
        args.getErrorHandlerPolicy());
97
98
    // none of the things below here are guaranteed to exist
99
0
    if ( this->getPropertyHeader( "w" ) != NULL )
100
0
    {
101
0
        m_positionWeightsProperty = Abc::IFloatArrayProperty( _this, "w",
102
0
            iArg0, iArg1 );
103
0
    }
104
105
0
    if ( this->getPropertyHeader( "uv" ) != NULL )
106
0
    {
107
0
        m_uvsParam = IV2fGeomParam( _this, "uv", iArg0, iArg1 );
108
0
    }
109
110
0
    if ( this->getPropertyHeader( "N" ) != NULL )
111
0
    {
112
0
        m_normalsParam = IN3fGeomParam( _this, "N", iArg0, iArg1 );
113
0
    }
114
115
0
    if ( this->getPropertyHeader( "width" ) != NULL )
116
0
    {
117
0
        m_widthsParam = IFloatGeomParam( _this, "width", iArg0, iArg1 );
118
0
    }
119
120
0
    if ( this->getPropertyHeader( ".velocities" ) != NULL )
121
0
    {
122
0
        m_velocitiesProperty = Abc::IV3fArrayProperty( _this, ".velocities",
123
0
                                               iArg0, iArg1 );
124
0
    }
125
126
0
    if ( this->getPropertyHeader( ".orders" ) != NULL )
127
0
    {
128
0
        m_ordersProperty = Abc::IUcharArrayProperty( _this, ".orders",
129
0
            iArg0, iArg1 );
130
0
    }
131
132
0
    if ( this->getPropertyHeader( ".knots" ) != NULL )
133
0
    {
134
0
        m_knotsProperty = Abc::IFloatArrayProperty( _this, ".knots",
135
0
            iArg0, iArg1 );
136
0
    }
137
138
139
0
    ALEMBIC_ABC_SAFE_CALL_END_RESET();
140
0
}
141
142
//-*****************************************************************************
143
void ICurvesSchema::get( ICurvesSchema::Sample &oSample,
144
                         const Abc::ISampleSelector &iSS ) const
145
0
{
146
0
    ALEMBIC_ABC_SAFE_CALL_BEGIN( "ICurvesSchema::get()" );
147
148
0
    if ( ! valid() ) { return; }
149
150
0
    m_positionsProperty.get( oSample.m_positions, iSS );
151
0
    m_nVerticesProperty.get( oSample.m_nVertices, iSS );
152
153
0
    Alembic::Util::uint8_t basisAndType[4];
154
0
    m_basisAndTypeProperty.get( basisAndType, iSS );
155
156
0
    oSample.m_type = static_cast<CurveType>( basisAndType[0] );
157
0
    oSample.m_wrap = static_cast<CurvePeriodicity>( basisAndType[1] );
158
0
    oSample.m_basis = static_cast<BasisType>( basisAndType[2] );
159
    // we ignore basisAndType[3] since it is the same as basisAndType[2]
160
161
0
    if ( m_positionWeightsProperty )
162
0
    {
163
0
        m_positionWeightsProperty.get( oSample.m_positionWeights, iSS );
164
0
    }
165
166
0
    if ( m_ordersProperty )
167
0
    {
168
0
        m_ordersProperty.get( oSample.m_orders, iSS );
169
0
    }
170
171
0
    if ( m_knotsProperty )
172
0
    {
173
0
        m_knotsProperty.get( oSample.m_knots, iSS );
174
0
    }
175
176
0
    if ( m_selfBoundsProperty )
177
0
    {
178
0
        m_selfBoundsProperty.get( oSample.m_selfBounds, iSS );
179
0
    }
180
181
0
    if ( m_velocitiesProperty && m_velocitiesProperty.getNumSamples() > 0 )
182
0
    {
183
0
        m_velocitiesProperty.get( oSample.m_velocities, iSS );
184
0
    }
185
186
0
    ALEMBIC_ABC_SAFE_CALL_END();
187
0
}
188
189
} // End namespace ALEMBIC_VERSION_NS
190
} // End namespace AbcGeom
191
} // End namespace Alembic