HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XformSample.h
Go to the documentation of this file.
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>
42 
44 
45 namespace Alembic {
46 namespace AbcGeom {
47 namespace ALEMBIC_VERSION_NS {
48 
49 //-*****************************************************************************
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  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
Matrix44< double > M44d
Definition: ImathMatrix.h:874
Vec3< double > V3d
Definition: ImathVec.h:694
bool getIsTopologyFrozen() const
Has this Sample been used in a call to OXformSchema::set()
Definition: XformSample.h:124
Xform Operation This class holds the data about a particular transform operation, but does not hold t...
Definition: XformOp.h:120
Vec3< typename MatType::value_type > getScale(const MatType &mat)
Return a Vec3 representing the lengths of the passed matrix's upper 3x3's rows.
Definition: Mat.h:628
#define ALEMBIC_EXPORT
Definition: Export.h:51
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:104