/src/alembic/lib/Alembic/AbcGeom/IFaceSet.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //-***************************************************************************** |
2 | | // |
3 | | // Copyright (c) 2009-2011, |
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/IFaceSet.h> |
38 | | |
39 | | namespace Alembic { |
40 | | namespace AbcGeom { |
41 | | namespace ALEMBIC_VERSION_NS { |
42 | | |
43 | | //-***************************************************************************** |
44 | | size_t IFaceSetSchema::getNumSamples() const |
45 | 0 | { |
46 | 0 | size_t max = 0; |
47 | |
|
48 | 0 | for ( size_t i = 0 ; i < this->getNumProperties() ; i++ ) |
49 | 0 | { |
50 | 0 | const AbcA::PropertyHeader& ph = this->getPropertyHeader( i ); |
51 | 0 | if ( ph.isArray() ) |
52 | 0 | { |
53 | 0 | max = std::max( max, |
54 | 0 | Abc::IArrayProperty( |
55 | 0 | this->getPtr(), |
56 | 0 | ph.getName() ).getNumSamples() ); |
57 | 0 | } |
58 | 0 | else if ( ph.isScalar() ) |
59 | 0 | { |
60 | 0 | max = std::max( max, |
61 | 0 | Abc::IScalarProperty( |
62 | 0 | this->getPtr(), |
63 | 0 | ph.getName() ).getNumSamples() ); |
64 | 0 | } |
65 | 0 | } |
66 | |
|
67 | 0 | return max; |
68 | 0 | } |
69 | | |
70 | | //-***************************************************************************** |
71 | | void IFaceSetSchema::get( IFaceSetSchema::Sample &oSample, |
72 | | const Abc::ISampleSelector &iSS ) const |
73 | 0 | { |
74 | 0 | ALEMBIC_ABC_SAFE_CALL_BEGIN( "IFaceSetSchema::get()" ); |
75 | |
|
76 | 0 | m_facesProperty.get( oSample.m_faces, iSS ); |
77 | |
|
78 | 0 | ALEMBIC_ABC_SAFE_CALL_END(); |
79 | 0 | } |
80 | | |
81 | | //-***************************************************************************** |
82 | | void IFaceSetSchema::init( const Abc::Argument &iArg0, |
83 | | const Abc::Argument &iArg1 ) |
84 | 0 | { |
85 | | // Only callable by ctors (mt-safety) |
86 | 0 | ALEMBIC_ABC_SAFE_CALL_BEGIN( "IFaceSetSchema::init()" ); |
87 | |
|
88 | 0 | AbcA::CompoundPropertyReaderPtr _this = this->getPtr(); |
89 | |
|
90 | 0 | m_facesProperty = Abc::IInt32ArrayProperty( _this, ".faces", iArg0, iArg1 ); |
91 | |
|
92 | 0 | ALEMBIC_ABC_SAFE_CALL_END_RESET(); |
93 | 0 | } |
94 | | |
95 | | //-***************************************************************************** |
96 | | FaceSetExclusivity IFaceSetSchema::getFaceExclusivity() const |
97 | 0 | { |
98 | 0 | ALEMBIC_ABC_SAFE_CALL_BEGIN( "IFaceSetSchema::getFaceExclusivity" ); |
99 | |
|
100 | 0 | Abc::IUInt32Property facesExclusiveProperty( this->getPtr(), |
101 | 0 | ".facesExclusive", Abc::ErrorHandler::kQuietNoopPolicy); |
102 | 0 | if ( facesExclusiveProperty ) |
103 | 0 | { |
104 | 0 | size_t numSamples = facesExclusiveProperty.getNumSamples(); |
105 | 0 | uint32_t asInt = FaceSetExclusivity( |
106 | 0 | facesExclusiveProperty.getValue( numSamples - 1 ) ); |
107 | 0 | FaceSetExclusivity exclusivity = FaceSetExclusivity( asInt ); |
108 | 0 | return exclusivity; |
109 | 0 | } |
110 | |
|
111 | 0 | ALEMBIC_ABC_SAFE_CALL_END(); |
112 | | |
113 | | // If no property was written we know the FaceSet has the default value |
114 | | // for exclusivity - NonExclusive. |
115 | 0 | return kFaceSetNonExclusive; |
116 | 0 | } |
117 | | |
118 | | } // End namespace ALEMBIC_VERSION_NS |
119 | | } // End namespace AbcGeom |
120 | | } // End namespace Alembic |