HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OXform.h
Go to the documentation of this file.
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_OXform_h
38 #define Alembic_AbcGeom_OXform_h
39 
40 #include <Alembic/Util/Export.h>
43 
45 
46 namespace Alembic {
47 namespace AbcGeom {
48 namespace ALEMBIC_VERSION_NS {
49 
50 //! The default value for determining whether a property is actually
51 //! different from the default.
52 static ALEMBIC_EXPORT_CONST double kXFORM_DELTA_TOLERANCE = 1.0e-12;
53 
54 //-*****************************************************************************
55 class ALEMBIC_EXPORT OXformSchema : public Abc::OSchema<XformSchemaInfo>
56 {
57  //-*************************************************************************
58  // XFORM SCHEMA
59  //-*************************************************************************
60 public:
61 
62  //! By convention we always define this_type in AbcGeom classes.
63  //! Used by unspecified-bool-type conversion below
67 
68  //-*************************************************************************
69  // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
70  //-*************************************************************************
71 
72  //! The default constructor creates an empty OPolyMeshSchema
73  //! ...
75  {
76  m_numChannels = 0;
77  m_numOps = 0;
78  m_useArrayProp = false;
79  m_isIdentity = true;
80  }
81 
82  //! This constructor creates a new xform writer.
83  //! The first argument is an CompoundPropertyWriterPtr to use as a parent.
84  //! The next is the name to give the schema which is usually the default
85  //! name given by OFaceSet (.xform) The remaining optional arguments
86  //! can be used to override the ErrorHandlerPolicy, to specify
87  //! MetaData, specify sparse sampling and to set TimeSampling.
89  const std::string &iName,
90  const Abc::Argument &iArg0 = Abc::Argument(),
91  const Abc::Argument &iArg1 = Abc::Argument(),
92  const Abc::Argument &iArg2 = Abc::Argument(),
93  const Abc::Argument &iArg3 = Abc::Argument() );
94 
95  //! This constructor creates a new xform writer.
96  //! The first argument is an OCompundProperty to use as a parent, and from
97  //! which the ErrorHandlerPolicy is derived. The next is the name to give
98  //! the schema which is usually the default name given by OXform (.xform)
99  //! The remaining optional arguments can be used to specify MetaData,
100  //! specify sparse sampling and to set TimeSampling.
102  const std::string &iName,
103  const Abc::Argument &iArg0 = Abc::Argument(),
104  const Abc::Argument &iArg1 = Abc::Argument(),
105  const Abc::Argument &iArg2 = Abc::Argument() );
106 
107  //! Explicit copy constructor to work around MSVC bug
108  OXformSchema( const OXformSchema &iCopy )
109  : Abc::OSchema<XformSchemaInfo>()
110  { *this = iCopy; }
111 
112  //! Default assignment operator used.
113 
114  //-*************************************************************************
115  // SCHEMA STUFF
116  //-*************************************************************************
117 
118  AbcA::TimeSamplingPtr getTimeSampling() const;
119 
120  //-*************************************************************************
121  // SAMPLE STUFF
122  //-*************************************************************************
123 
124  //! Get number of samples written so far.
125  //! ...
126  size_t getNumSamples() const;
127 
128  //! Set an animated sample. On first call to set, the sample is modified,
129  //! so it can't be const.
130  void set( XformSample &ioSamp );
131 
132  //! Set from previous sample. Will hold the animated channels.
133  void setFromPrevious();
134 
135  void setTimeSampling( uint32_t iIndex );
136  void setTimeSampling( AbcA::TimeSamplingPtr iTime );
137 
138  Abc::OCompoundProperty getArbGeomParams();
139  Abc::OCompoundProperty getUserProperties();
140  Abc::OBox3dProperty getChildBoundsProperty();
141 
142  //-*************************************************************************
143  // ABC BASE MECHANISMS
144  // These functions are used by Abc to deal with errors, validity,
145  // and so on.
146  //-*************************************************************************
147 
148  //! Reset returns this function set to an empty, default
149  //! state.
150  void reset()
151  {
152  m_childBoundsProperty.reset();
153  m_inheritsProperty.reset();
154  m_opsPWPtr.reset();
155  m_valsPWPtr.reset();
156  m_protoSample.reset();
157  m_data.reset();
158 
159  m_arbGeomParams.reset();
160  m_userProperties.reset();
161 
162  m_useArrayProp = false;
163  m_isIdentity = true;
164 
166  }
167 
168  //! Valid returns whether this function set is valid.
169  bool valid() const
170  {
171  return ( super_type::valid() );
172  }
173 
174  //! unspecified-bool-type operator overload.
175  //! ...
176  ALEMBIC_OVERRIDE_OPERATOR_BOOL( this_type::valid() );
177 
178 
179 private:
180  void init( const AbcA::index_t iTSIndex );
181 
182  // not technically needed as the m_protoSample can return this info
183  std::size_t m_numChannels;
184  std::size_t m_numOps;
185 
186  // should we store are channel values in an ArrayProperty,
187  // or in a ScalarProperty with some Dimension > 0 and < MAX_SCALAR_CHANS
188  bool m_useArrayProp{false};
189 
190  AbcA::DataType m_arrayValuesDataType;
191  Alembic::Util::Dimensions m_arraySampleDimensions;
192 
193  void setChannelValues( const std::vector<double> &iVals );
194 
195 protected:
196 
198 
200 
202 
204 
206 
207  // ensure that our sample's topology is unchanging between
208  // calls to set; see usage in OXformSchema::set()
210 
211  bool m_isIdentity{true};
212 
214 
216 
217  class Data;
218 
219  // shared and not scoped because we want this to be shared across copies
220  Util::shared_ptr< Data > m_data;
221 };
222 
223 //-*****************************************************************************
224 // SCHEMA OBJECT
225 //-*****************************************************************************
227 
228 typedef Util::shared_ptr< OXform > OXformPtr;
229 
230 } // End namespace ALEMBIC_VERSION_NS
231 
232 using namespace ALEMBIC_VERSION_NS;
233 
234 } // End namespace AbcGeom
235 } // End namespace Alembic
236 
237 #endif
bool valid() const
Valid returns whether this function set is valid.
Definition: OXform.h:169
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
#define ALEMBIC_EXPORT
Definition: Export.h:51
AbcA::ScalarPropertyWriterPtr m_opsPWPtr
Definition: OXform.h:199
AbcA::BasePropertyWriterPtr m_valsPWPtr
Definition: OXform.h:201
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Definition: TimeSampling.h:137
Alembic::Util::shared_ptr< BasePropertyWriter > BasePropertyWriterPtr
GLboolean reset
Definition: glad.h:5138
Abc::OSchema< XformSchemaInfo > super_type
Definition: OXform.h:64
#define ALEMBIC_EXPORT_CONST
Definition: Export.h:53
#define ALEMBIC_OVERRIDE_OPERATOR_BOOL(PASS_COND)
Definition: OperatorBool.h:56
Alembic::Util::shared_ptr< ScalarPropertyWriter > ScalarPropertyWriterPtr
Abc::OSchemaObject< OXformSchema > OXform
Definition: OXform.h:226
Util::shared_ptr< OXform > OXformPtr
Definition: OXform.h:228
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:88
OXformSchema(const OXformSchema &iCopy)
Explicit copy constructor to work around MSVC bug.
Definition: OXform.h:108
Alembic::Util::shared_ptr< CompoundPropertyWriter > CompoundPropertyWriterPtr