HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OCamera.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_OCamera_h_
38 #define _Alembic_AbcGeom_OCamera_h_
39 
40 #include <Alembic/Util/Export.h>
44 
45 namespace Alembic {
46 namespace AbcGeom {
47 namespace ALEMBIC_VERSION_NS {
48 
49 //-*****************************************************************************
50 class ALEMBIC_EXPORT OCameraSchema : public Abc::OSchema<CameraSchemaInfo>
51 {
52  //-*************************************************************************
53  // CAMERA SCHEMA
54  //-*************************************************************************
55 public:
56  //! By convention we always define this_type in AbcGeom classes.
57  //! Used by unspecified-bool-type conversion below
59 
60  //-*************************************************************************
61  // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
62  //-*************************************************************************
63 
64  //! The default constructor creates an empty OCameraMeshSchema
65  //! ...
67 
68  //! This templated, primary constructor creates a new camera writer.
69  //! The first argument is any Abc (or AbcCoreAbstract) object
70  //! which can intrusively be converted to an CompoundPropertyWriterPtr
71  //! to use as a parent, from which the error handler policy for
72  //! inheritance is also derived. The remaining optional arguments
73  //! can be used to override the ErrorHandlerPolicy, to specify
74  //! MetaData, and to set TimeSampling.
75  template <class CPROP_PTR>
76  OCameraSchema( CPROP_PTR iParent,
77  const std::string &iName,
78 
79  const Abc::Argument &iArg0 = Abc::Argument(),
80  const Abc::Argument &iArg1 = Abc::Argument(),
81  const Abc::Argument &iArg2 = Abc::Argument() )
82  : Abc::OSchema<CameraSchemaInfo>(
84  iName, iArg0, iArg1, iArg2 )
85  {
86 
87  AbcA::TimeSamplingPtr tsPtr =
88  Abc::GetTimeSampling( iArg0, iArg1, iArg2 );
89  uint32_t tsIndex =
90  Abc::GetTimeSamplingIndex( iArg0, iArg1, iArg2 );
91 
92  // if we specified a valid TimeSamplingPtr, use it to determine the
93  // index otherwise we'll use the index, which defaults to the intrinsic
94  // 0 index
95  if (tsPtr)
96  {
97  tsIndex = GetCompoundPropertyWriterPtr( iParent )->getObject(
98  )->getArchive()->addTimeSampling(*tsPtr);
99  }
100 
101  // Meta data and error handling are eaten up by
102  // the super type, so all that's left is time sampling.
103  init( tsIndex );
104  }
105 
106  template <class CPROP_PTR>
107  explicit OCameraSchema( CPROP_PTR iParent,
108  const Abc::Argument &iArg0 = Abc::Argument(),
109  const Abc::Argument &iArg1 = Abc::Argument(),
110  const Abc::Argument &iArg2 = Abc::Argument() )
111  : Abc::OSchema<CameraSchemaInfo>(
112  GetCompoundPropertyWriterPtr( iParent ),
113  iArg0, iArg1, iArg2 )
114  {
115 
116  AbcA::TimeSamplingPtr tsPtr =
117  Abc::GetTimeSampling( iArg0, iArg1, iArg2 );
118  uint32_t tsIndex =
119  Abc::GetTimeSamplingIndex( iArg0, iArg1, iArg2 );
120 
121  // if we specified a valid TimeSamplingPtr, use it to determine the
122  // index otherwise we'll use the index, which defaults to the intrinsic
123  // 0 index
124  if (tsPtr)
125  {
126  tsIndex = GetCompoundPropertyWriterPtr( iParent )->getObject(
127  )->getArchive()->addTimeSampling(*tsPtr);
128  }
129 
130  // Meta data and error handling are eaten up by
131  // the super type, so all that's left is time sampling.
132  init( tsIndex );
133  }
134 
135  //! Copy constructor.
137  : Abc::OSchema<CameraSchemaInfo>()
138  {
139  *this = iCopy;
140  }
141 
142  //! Default assignment operator used.
143 
144  //-*************************************************************************
145  // SCHEMA STUFF
146  //-*************************************************************************
147 
148  //! Return the time sampling.
150  { return m_coreProperties.getTimeSampling(); }
151 
152  //-*************************************************************************
153  // SAMPLE STUFF
154  //-*************************************************************************
155 
156  //! Get number of samples written so far.
157  //! ...
158  size_t getNumSamples()
159  { return m_coreProperties.getNumSamples(); }
160 
161  //! Set a sample
162  void set( const CameraSample &iSamp );
163 
164  //! Set from previous sample.
165  void setFromPrevious();
166 
167  void setTimeSampling( uint32_t iIndex );
168  void setTimeSampling( AbcA::TimeSamplingPtr iTime );
169 
170  Abc::OCompoundProperty getUserProperties();
171  Abc::OCompoundProperty getArbGeomParams();
172 
173  Abc::OBox3dProperty getChildBoundsProperty();
174 
175  //-*************************************************************************
176  // ABC BASE MECHANISMS
177  // These functions are used by Abc to deal with errors, validity,
178  // and so on.
179  //-*************************************************************************
180 
181  //! Reset returns this function set to an empty, default
182  //! state.
183  void reset()
184  {
185  m_coreProperties.reset();
186  m_childBoundsProperty.reset();
187  m_userProperties.reset();
188  m_arbGeomParams.reset();
189  m_bigFilmBackChannelsProperty.reset();
190  m_smallFilmBackChannelsProperty.reset();
192  }
193 
194  //! Returns whether this function set is valid.
195  bool valid() const
196  {
198  m_coreProperties.valid() );
199  }
200 
201  //! unspecified-bool-type operator overload.
202  //! ...
204 
205 protected:
206  void init( uint32_t iTsIdx );
207 
209 
211 
214 
216 
218 
219 private:
220  CameraSample m_initialSample;
221 
222 };
223 
224 //-*****************************************************************************
225 // SCHEMA OBJECT
226 //-*****************************************************************************
228 
229 typedef Util::shared_ptr< OCamera > OCameraPtr;
230 
231 } // End namespace ALEMBIC_VERSION_NS
232 
233 using namespace ALEMBIC_VERSION_NS;
234 
235 } // End namespace AbcGeom
236 } // End namespace Alembic
237 
238 #endif
Abc::ODoubleArrayProperty m_bigFilmBackChannelsProperty
Definition: OCamera.h:215
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
Abc::OSchemaObject< OCameraSchema > OCamera
Definition: OCamera.h:227
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Definition: TimeSampling.h:137
#define ALEMBIC_OVERRIDE_OPERATOR_BOOL(PASS_COND)
Definition: OperatorBool.h:56
OCameraSchema(CPROP_PTR iParent, const std::string &iName, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument(), const Abc::Argument &iArg2=Abc::Argument())
Definition: OCamera.h:76
OCameraSchema(CPROP_PTR iParent, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument(), const Abc::Argument &iArg2=Abc::Argument())
Definition: OCamera.h:107
AbcA::TimeSamplingPtr GetTimeSampling(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument())
Definition: Argument.h:259
bool valid() const
Returns whether this function set is valid.
Definition: OCamera.h:195
AbcA::TimeSamplingPtr getTimeSampling() const
Default assignment operator used.
Definition: OCamera.h:149
AbcA::CompoundPropertyWriterPtr GetCompoundPropertyWriterPtr(AbcA::CompoundPropertyWriterPtr iPtr)
Definition: Foundation.h:164
OCameraSchema(const OCameraSchema &iCopy)
Copy constructor.
Definition: OCamera.h:136
#define ALEMBIC_EXPORT
Definition: Export.h:51
uint32_t GetTimeSamplingIndex(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument())
Definition: Argument.h:272
Util::shared_ptr< OCamera > OCameraPtr
Definition: OCamera.h:229
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:104