HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IXform.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_IXform_h_
38 #define _Alembic_AbcGeom_IXform_h_
39 
40 #include <Alembic/Util/Export.h>
43 
45 
46 namespace Alembic {
47 namespace AbcGeom {
48 namespace ALEMBIC_VERSION_NS {
49 
50 //-*****************************************************************************
51 class ALEMBIC_EXPORT IXformSchema : public Abc::ISchema<XformSchemaInfo>
52 {
53  //-*************************************************************************
54  // XFORM SCHEMA
55  //-*************************************************************************
56 public:
57 
58  //! By convention we always define this_type in AbcGeom classes.
59  //! Used by unspecified-bool-type conversion below
63 
64  //-*************************************************************************
65  // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
66  //-*************************************************************************
67 
68  //! The default constructor creates an empty OPolyMeshSchema
69  //! ...
71 
72  //! This templated, primary constructor creates a new xform writer.
73  //! The first argument is any Abc (or AbcCoreAbstract) object
74  //! which can intrusively be converted to an CompoundPropertyWriterPtr
75  //! to use as a parent, from which the error handler policy for
76  //! inheritance is also derived. The remaining optional arguments
77  //! can be used to override the ErrorHandlerPolicy, to specify
78  //! MetaData, and to set TimeSamplingType.
79  template <class CPROP_PTR>
80  IXformSchema( CPROP_PTR iParent,
81  const std::string &iName,
82  const Abc::Argument &iArg0 = Abc::Argument(),
83  const Abc::Argument &iArg1 = Abc::Argument() )
84  : Abc::ISchema<XformSchemaInfo>( iParent, iName,
85  iArg0, iArg1 )
86  {
87  // Meta data and error handling are eaten up by
88  // the super type, so all that's left is SchemaInterpMatching.
89  init( iArg0, iArg1 );
90  }
91 
92  //! This constructor does the same as the above, but uses the default
93  //! name from the XformSchemaInfo struct.
94  template <class CPROP_PTR>
95  explicit IXformSchema( CPROP_PTR iParent,
96 
97  const Abc::Argument &iArg0 = Abc::Argument(),
98  const Abc::Argument &iArg1 = Abc::Argument() )
99  : Abc::ISchema<XformSchemaInfo>( iParent, iArg0, iArg1 )
100  {
101  init( iArg0, iArg1 );
102  }
103 
104  //! Wrap an existing IXform object
105  template <class CPROP_PTR>
106  explicit IXformSchema( CPROP_PTR iThis,
107  Abc::WrapExistingFlag iFlag,
108 
109  const Abc::Argument &iArg0 = Abc::Argument(),
110  const Abc::Argument &iArg1 = Abc::Argument() )
111  : Abc::ISchema<XformSchemaInfo>( iThis, iFlag, iArg0, iArg1 )
112  {
113  init( iArg0, iArg1 );
114  }
115 
116  //! explicit copy constructor to work around Windows compiler bug
117  IXformSchema( const IXformSchema &iCopy )
118  : Abc::ISchema<XformSchemaInfo>()
119  {
120  *this = iCopy;
121  }
122 
123  AbcA::TimeSamplingPtr getTimeSampling() const;
124 
125  bool isConstant() const { return m_isConstant; }
126 
127  //! is this xform both constant and identity?
128  bool isConstantIdentity() const { return m_isConstantIdentity; }
129 
130  size_t getNumSamples() const;
131 
132  //! fill the supplied sample reference with values
133  void get( XformSample &oSamp,
134  const Abc::ISampleSelector &iSS = Abc::ISampleSelector() ) const;
135 
136  XformSample getValue( const Abc::ISampleSelector &iSS =
137  Abc::ISampleSelector() ) const;
138 
140  {
141  return m_childBoundsProperty;
142  }
143 
144  // lightweight get to avoid constructing a sample
145  // see XformSample.h for explanation of this property
146  bool getInheritsXforms( const Abc::ISampleSelector &iSS =
148 
149  size_t getNumOps() const { return m_sample.getNumOps(); }
150 
151  //! Reset returns this function set to an empty, default
152  //! state.
153  void reset()
154  {
155  m_childBoundsProperty.reset();
156  m_sample = XformSample();
157  m_inheritsProperty.reset();
158  m_isConstant = true;
159  m_isConstantIdentity = true;
160 
161  m_arbGeomParams.reset();
162  m_userProperties.reset();
163 
164  super_type::reset();
165  }
166 
167  //! Valid returns whether this function set is valid.
168  bool valid() const
169  {
170  return ( super_type::valid() );
171  }
172 
173  ICompoundProperty getArbGeomParams() const { return m_arbGeomParams; }
174 
175  ICompoundProperty getUserProperties() const { return m_userProperties; }
176 
177  //! unspecified-bool-type operator overload.
178  //! ...
179  ALEMBIC_OVERRIDE_OPERATOR_BOOL( this_type::valid() );
180 
181 
182 protected:
184 
186 
188 
191 
193 
195 
197 
198 private:
199  void init( const Abc::Argument &iArg0, const Abc::Argument &iArg1 );
200 
201  // is m_vals an ArrayProperty, or a ScalarProperty?
202  bool m_useArrayProp;
203 
204  // fills m_valVec with data
205  void getChannelValues( const AbcA::index_t iSampleIndex,
206  XformSample & oSamp ) const;
207 };
208 
209 //-*****************************************************************************
210 // SCHEMA OBJECT
211 //-*****************************************************************************
213 
214 typedef Util::shared_ptr< IXform > IXformPtr;
215 
216 } // End namespace ALEMBIC_VERSION_NS
217 
218 using namespace ALEMBIC_VERSION_NS;
219 
220 } // End namespace AbcGeom
221 } // End namespace Alembic
222 
223 #endif
IXformSchema(const IXformSchema &iCopy)
explicit copy constructor to work around Windows compiler bug
Definition: IXform.h:117
Util::shared_ptr< IXform > IXformPtr
Definition: IXform.h:214
IXformSchema(CPROP_PTR iThis, Abc::WrapExistingFlag iFlag, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Wrap an existing IXform object.
Definition: IXform.h:106
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
IXformSchema(CPROP_PTR iParent, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: IXform.h:95
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Definition: TimeSampling.h:137
AbcA::BasePropertyReaderPtr m_valsProperty
Definition: IXform.h:185
IXformSchema(CPROP_PTR iParent, const std::string &iName, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: IXform.h:80
ICompoundProperty getUserProperties() const
Definition: IXform.h:175
#define ALEMBIC_OVERRIDE_OPERATOR_BOOL(PASS_COND)
Definition: OperatorBool.h:56
bool valid() const
Valid returns whether this function set is valid.
Definition: IXform.h:168
ICompoundProperty getArbGeomParams() const
Definition: IXform.h:173
Abc::ISchema< XformSchemaInfo > super_type
Definition: IXform.h:60
Abc::IBox3dProperty getChildBoundsProperty() const
Definition: IXform.h:139
bool isConstantIdentity() const
is this xform both constant and identity?
Definition: IXform.h:128
#define ALEMBIC_EXPORT
Definition: Export.h:51
Abc::ISchemaObject< IXformSchema > IXform
Definition: IXform.h:212
Alembic::Util::shared_ptr< BasePropertyReader > BasePropertyReaderPtr
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:104