/src/alembic/lib/Alembic/AbcGeom/XformSample.h
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 | | #ifndef Alembic_AbcGeom_XformSample_h |
38 | | #define Alembic_AbcGeom_XformSample_h |
39 | | |
40 | | #include <Alembic/Util/Export.h> |
41 | | #include <Alembic/AbcGeom/Foundation.h> |
42 | | |
43 | | #include <Alembic/AbcGeom/XformOp.h> |
44 | | |
45 | | namespace Alembic { |
46 | | namespace AbcGeom { |
47 | | namespace ALEMBIC_VERSION_NS { |
48 | | |
49 | | //-***************************************************************************** |
50 | | class ALEMBIC_EXPORT XformSample |
51 | | { |
52 | | public: |
53 | | XformSample(); |
54 | | |
55 | | // add translate or scale op |
56 | | // returns the index of the op in its op-stack |
57 | | std::size_t addOp( XformOp iTransOrScaleOp, const Abc::V3d &iVal ); |
58 | | |
59 | | // add rotate op |
60 | | // returns the index of the op in its op-stack |
61 | | std::size_t addOp( XformOp iRotateOp, const Abc::V3d &iAxis, |
62 | | const double iAngleInDegrees ); |
63 | | |
64 | | // add matrix op |
65 | | // returns the index of the op in its op-stack |
66 | | std::size_t addOp( XformOp iMatrixOp, const Abc::M44d &iMatrix ); |
67 | | |
68 | | // add rotateX, rotateY, or rotateZ op |
69 | | std::size_t addOp( XformOp iSingleRotateOp, |
70 | | const double iSingleAxisRotationInDegrees ); |
71 | | |
72 | | // add an op with values already set on the op |
73 | | std::size_t addOp( const XformOp &iOp ); |
74 | | |
75 | | XformOp getOp( const std::size_t iIndex ) const; |
76 | | |
77 | | XformOp &operator[]( const std::size_t &iIndex ); |
78 | | const XformOp &operator[]( const std::size_t &iIndex ) const; |
79 | | |
80 | | std::size_t getNumOps() const; |
81 | | //! The sum of the number of channels of all the ops in this Sample. |
82 | | std::size_t getNumOpChannels() const; |
83 | | |
84 | | //! "Inherits xforms" means, "Does this xform concatenate to or ignore the |
85 | | //! transforms of its parents?" |
86 | | void setInheritsXforms( bool iInherits ); |
87 | | bool getInheritsXforms() const; |
88 | | |
89 | | // non-op-based methods; the getters will compute their return values |
90 | | // from the ops under the hood, hence return-by-value. |
91 | | |
92 | | //! Order matters when calling different setFoo() methods; |
93 | | //! callstack of methods must be the same for each call to |
94 | | //! OXformSchmea::set() with a given Sample. |
95 | | //! For example, a Sample with calls to setTranslation() and |
96 | | //! setRotation() must make thgose same calls in the same order |
97 | | //! between each use of OXforSchema::set(). |
98 | | void setTranslation( const Abc::V3d &iTrans ); |
99 | | Abc::V3d getTranslation() const; |
100 | | |
101 | | void setRotation( const Abc::V3d &iAxis, const double iAngleInDegress ); |
102 | | Abc::V3d getAxis() const; |
103 | | double getAngle() const; |
104 | | |
105 | | void setXRotation( const double iAngleInDegrees ); |
106 | | double getXRotation() const; |
107 | | |
108 | | void setYRotation( const double iAngleInDegrees ); |
109 | | double getYRotation() const; |
110 | | |
111 | | void setZRotation( const double iAngleInDegrees ); |
112 | | double getZRotation() const; |
113 | | |
114 | | void setScale( const Abc::V3d &iScale ); |
115 | | Abc::V3d getScale() const; |
116 | | |
117 | | void setMatrix( const Abc::M44d &iMatrix ); |
118 | | Abc::M44d getMatrix() const; |
119 | | |
120 | | //! Tests whether this sample has the same topology as iSample |
121 | | bool isTopologyEqual( const XformSample & iSample ); |
122 | | |
123 | | //! Has this Sample been used in a call to OXformSchema::set() |
124 | 0 | bool getIsTopologyFrozen() const { return m_hasBeenRead; } |
125 | | |
126 | | void reset(); |
127 | | |
128 | | private: |
129 | | friend class OXformSchema; |
130 | | friend class IXformSchema; |
131 | | void freezeTopology(); |
132 | | const std::vector<Alembic::Util::uint8_t> &getOpsArray() const; |
133 | | void clear(); |
134 | | |
135 | | |
136 | | private: |
137 | | //! 0 is unset; 1 is set via addOp; 2 is set via non-op-based methods |
138 | | int32_t m_setWithOpStack; |
139 | | |
140 | | std::vector<XformOp> m_ops; |
141 | | |
142 | | bool m_inherits; |
143 | | |
144 | | //! This starts out false, but is set to true by the OXform and controls |
145 | | //! whether or not addOp() changes the topology of the Sample, in the form |
146 | | //! of the layout of the m_opsArray. |
147 | | bool m_hasBeenRead; |
148 | | |
149 | | size_t m_opIndex; |
150 | | }; |
151 | | |
152 | | |
153 | | } // End namespace ALEMBIC_VERSION_NS |
154 | | |
155 | | using namespace ALEMBIC_VERSION_NS; |
156 | | |
157 | | } // End namespace AbcGeom |
158 | | } // End namespace Alembic |
159 | | |
160 | | #endif |