/src/alembic/lib/Alembic/AbcGeom/OCamera.h
Line | Count | Source (jump to first uncovered line) |
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> |
41 | | #include <Alembic/AbcGeom/Foundation.h> |
42 | | #include <Alembic/AbcGeom/SchemaInfoDeclarations.h> |
43 | | #include <Alembic/AbcGeom/CameraSample.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 |
58 | | typedef OCameraSchema this_type; |
59 | | |
60 | | //-************************************************************************* |
61 | | // CONSTRUCTION, DESTRUCTION, ASSIGNMENT |
62 | | //-************************************************************************* |
63 | | |
64 | | //! The default constructor creates an empty OCameraMeshSchema |
65 | | //! ... |
66 | 0 | OCameraSchema() {} |
67 | | |
68 | | //! This constructor creates a new camera writer. |
69 | | //! The first argument is the compound property to use as a parent |
70 | | //! The remaining optional arguments are the parents ErrorHandlerPolicy, |
71 | | //! an override to the ErrorHandlerPolicy, MetaData, and TimeSampling info. |
72 | | OCameraSchema( AbcA::CompoundPropertyWriterPtr iParent, |
73 | | const std::string &iName, |
74 | | |
75 | | const Abc::Argument &iArg0 = Abc::Argument(), |
76 | | const Abc::Argument &iArg1 = Abc::Argument(), |
77 | | const Abc::Argument &iArg2 = Abc::Argument(), |
78 | | const Abc::Argument &iArg3 = Abc::Argument() ) |
79 | | : Abc::OSchema<CameraSchemaInfo>( iParent, iName, |
80 | | iArg0, iArg1, iArg2, iArg3 ) |
81 | 0 | { |
82 | 0 |
|
83 | 0 | AbcA::TimeSamplingPtr tsPtr = |
84 | 0 | Abc::GetTimeSampling( iArg0, iArg1, iArg2, iArg3 ); |
85 | 0 | uint32_t tsIndex = |
86 | 0 | Abc::GetTimeSamplingIndex( iArg0, iArg1, iArg2, iArg3 ); |
87 | 0 |
|
88 | 0 | // if we specified a valid TimeSamplingPtr, use it to determine the |
89 | 0 | // index otherwise we'll use the index, which defaults to the intrinsic |
90 | 0 | // 0 index |
91 | 0 | if (tsPtr) |
92 | 0 | { |
93 | 0 | tsIndex = iParent->getObject()->getArchive()->addTimeSampling( |
94 | 0 | *tsPtr); |
95 | 0 | } |
96 | 0 |
|
97 | 0 | // Meta data and error handling are eaten up by |
98 | 0 | // the super type, so all that's left is time sampling. |
99 | 0 | init( tsIndex ); |
100 | 0 | } |
101 | | |
102 | | //! Default assignment and copy operator used. |
103 | | |
104 | | //-************************************************************************* |
105 | | // SCHEMA STUFF |
106 | | //-************************************************************************* |
107 | | |
108 | | //! Return the time sampling. |
109 | | AbcA::TimeSamplingPtr getTimeSampling() const |
110 | 0 | { return m_coreProperties.getTimeSampling(); } |
111 | | |
112 | | //-************************************************************************* |
113 | | // SAMPLE STUFF |
114 | | //-************************************************************************* |
115 | | |
116 | | //! Get number of samples written so far. |
117 | | //! ... |
118 | | size_t getNumSamples() |
119 | 0 | { return m_coreProperties.getNumSamples(); } |
120 | | |
121 | | //! Set a sample |
122 | | void set( const CameraSample &iSamp ); |
123 | | |
124 | | //! Set from previous sample. |
125 | | void setFromPrevious(); |
126 | | |
127 | | void setTimeSampling( uint32_t iIndex ); |
128 | | void setTimeSampling( AbcA::TimeSamplingPtr iTime ); |
129 | | |
130 | | Abc::OCompoundProperty getUserProperties(); |
131 | | Abc::OCompoundProperty getArbGeomParams(); |
132 | | |
133 | | Abc::OBox3dProperty getChildBoundsProperty(); |
134 | | |
135 | | //-************************************************************************* |
136 | | // ABC BASE MECHANISMS |
137 | | // These functions are used by Abc to deal with errors, validity, |
138 | | // and so on. |
139 | | //-************************************************************************* |
140 | | |
141 | | //! Reset returns this function set to an empty, default |
142 | | //! state. |
143 | | void reset() |
144 | 0 | { |
145 | 0 | m_coreProperties.reset(); |
146 | 0 | m_childBoundsProperty.reset(); |
147 | 0 | m_userProperties.reset(); |
148 | 0 | m_arbGeomParams.reset(); |
149 | 0 | m_bigFilmBackChannelsProperty.reset(); |
150 | 0 | m_smallFilmBackChannelsProperty.reset(); |
151 | 0 | Abc::OSchema<CameraSchemaInfo>::reset(); |
152 | 0 | } |
153 | | |
154 | | //! Returns whether this function set is valid. |
155 | | bool valid() const |
156 | 0 | { |
157 | 0 | return ( Abc::OSchema<CameraSchemaInfo>::valid() && |
158 | 0 | m_coreProperties.valid() ); |
159 | 0 | } |
160 | | |
161 | | //! unspecified-bool-type operator overload. |
162 | | //! ... |
163 | | ALEMBIC_OVERRIDE_OPERATOR_BOOL( OCameraSchema::valid() ); |
164 | | |
165 | | protected: |
166 | | void init( uint32_t iTsIdx ); |
167 | | |
168 | | Abc::OScalarProperty m_coreProperties; |
169 | | |
170 | | Abc::OBox3dProperty m_childBoundsProperty; |
171 | | |
172 | | Abc::OCompoundProperty m_userProperties; |
173 | | Abc::OCompoundProperty m_arbGeomParams; |
174 | | |
175 | | Abc::ODoubleArrayProperty m_bigFilmBackChannelsProperty; |
176 | | |
177 | | Abc::OScalarProperty m_smallFilmBackChannelsProperty; |
178 | | |
179 | | private: |
180 | | CameraSample m_initialSample; |
181 | | |
182 | | }; |
183 | | |
184 | | //-***************************************************************************** |
185 | | // SCHEMA OBJECT |
186 | | //-***************************************************************************** |
187 | | typedef Abc::OSchemaObject<OCameraSchema> OCamera; |
188 | | |
189 | | typedef Util::shared_ptr< OCamera > OCameraPtr; |
190 | | |
191 | | } // End namespace ALEMBIC_VERSION_NS |
192 | | |
193 | | using namespace ALEMBIC_VERSION_NS; |
194 | | |
195 | | } // End namespace AbcGeom |
196 | | } // End namespace Alembic |
197 | | |
198 | | #endif |