HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OGeomBase.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_OGeometrySchema_h_
38 #define _Alembic_AbcGeom_OGeometrySchema_h_
39 
40 #include <Alembic/Abc/OSchema.h>
43 
44 namespace Alembic {
45 namespace AbcGeom {
46 namespace ALEMBIC_VERSION_NS {
47 
48 
49 //! This class holds properties common to all classes with a physical volume.
50 //! - selfBounds
51 //! - childBounds (optional)
52 //! - GeomParams (optional)
53 //! - UserProperties (optional)
54 //!
55 //! This class is used to encapsulate common functionality of the
56 //! real Geometry schema classes, like OPoints and OPolyMesh and so on
57 template <class INFO>
58 class OGeomBaseSchema : public Abc::OSchema<INFO>
59 {
60 public:
61  //-*************************************************************************
62  // TYPEDEFS AND IDENTIFIERS
63  //-*************************************************************************
64 
65  typedef INFO info_type;
66 
67 
68  //-*************************************************************************
69  // Constructors that pass through to OSchema
70  //-*************************************************************************
71  //
72  //! The default constructor creates an empty OSchema.
73  //! Used to create "NULL/invalid" instances.
75 
76  //! Delegates to Abc/OSchema, and then creates always-present
77  //! properties
78  template <class CPROP_PTR>
79  OGeomBaseSchema( CPROP_PTR iParentCompound,
80  const std::string &iName,
81  const Argument &iArg0 = Argument(),
82  const Argument &iArg1 = Argument(),
83  const Argument &iArg2 = Argument() )
84  : Abc::OSchema<info_type>( iParentCompound, iName, iArg0, iArg1, iArg2 )
85  {
86  AbcA::TimeSamplingPtr tsPtr =
87  Abc::GetTimeSampling( iArg0, iArg1, iArg2 );
88  uint32_t tsIndex =
89  Abc::GetTimeSamplingIndex( iArg0, iArg1, iArg2 );
90 
91  // if we specified a valid TimeSamplingPtr, use it to determine the
92  // index otherwise use the default index of 0 - uniform.
93  if ( tsPtr )
94  {
95  tsIndex = GetCompoundPropertyWriterPtr(iParentCompound)->getObject(
96  )->getArchive()->addTimeSampling(*tsPtr);
97  }
98 
99  // Create our always present property
100  init( tsIndex );
101  }
102 
103  template <class CPROP_PTR>
104  explicit OGeomBaseSchema( CPROP_PTR iParentCompound,
105  const Argument &iArg0 = Argument(),
106  const Argument &iArg1 = Argument(),
107  const Argument &iArg2 = Argument() )
108  : Abc::OSchema<info_type>( iParentCompound, iArg0, iArg1, iArg2 )
109  {
110  AbcA::TimeSamplingPtr tsPtr =
111  Abc::GetTimeSampling( iArg0, iArg1, iArg2 );
112  uint32_t tsIndex =
113  Abc::GetTimeSamplingIndex( iArg0, iArg1, iArg2 );
114 
115  // if we specified a valid TimeSamplingPtr, use it to determine the
116  // index otherwise we'll use the index, which defaults to the intrinsic
117  // 0 index
118  if ( tsPtr )
119  {
120  tsIndex = GetCompoundPropertyWriterPtr(iParentCompound)->getObject(
121  )->getArchive()->addTimeSampling(*tsPtr);
122  }
123 
124  // Create our always present property
125  init( tsIndex );
126  }
127 
128  //! Copy constructor
130  : Abc::OSchema<info_type>()
131  {
132  *this = iCopy;
133  }
134 
135  void init( uint32_t iTsHandle)
136  {
137  ALEMBIC_ABC_SAFE_CALL_BEGIN( "OGeomBaseSchema::init()" );
138 
139  AbcA::CompoundPropertyWriterPtr _this = this->getPtr();
140 
141  // Create our always present property. All other
142  // properties are optional.
144  ".selfBnds", iTsHandle );
145 
147  }
148 
149  virtual void reset ()
150  {
156  }
157 
158  virtual bool valid() const
159  {
160  // Only selfBounds is required, all others are optional
161  return ( Abc::OSchema<info_type>::valid() &&
163  }
164 
166  {
167  // Accessing the ArbGeomParams will create its compound
168  // property if needed.
169  ALEMBIC_ABC_SAFE_CALL_BEGIN( "OGeomBaseSchema::getArbGeomParams()" );
170 
171  if ( ! m_arbGeomParams )
172  {
174  ".arbGeomParams" );
175  }
176 
177  return m_arbGeomParams;
178 
180 
182  return ret;
183  }
184 
186  {
187  // Accessing UserProperties will create its compound
188  // property if needed.
189  ALEMBIC_ABC_SAFE_CALL_BEGIN( "OGeomBaseSchema::getUserProperties()" );
190 
191  if ( ! m_userProperties )
192  {
194  ".userProperties" );
195  }
196 
197  return m_userProperties;
198 
200 
202  return ret;
203  }
204 
206  {
207  // Accessing Child Bounds Property will create it if needed
209  "OGeomBaseSchema::getChildBoundsProperty()" );
210 
211  if ( ! m_childBoundsProperty )
212  {
213  AbcA::CompoundPropertyWriterPtr _this = this->getPtr();
214 
215  // for now, use the self bounds time sampling, this
216  // can and should be changed depending on how the children
217  // are sampled
219  ".childBnds", m_selfBoundsProperty.getTimeSampling() );
220 
221  }
222 
224  return m_childBoundsProperty;
225  }
226 
227 protected:
228  // Only selfBounds is required, all others are optional
231 
234 
235 };
236 
237 
238 } // End namespace ALEMBIC_VERSION_NS
239 
240 using namespace ALEMBIC_VERSION_NS;
241 
242 } // End namespace AbcGeom
243 } // End namespace Alembic
244 
245 #endif
AbcA::TimeSamplingPtr getTimeSampling() const
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
OTypedScalarProperty< Box3dTPTraits > OBox3dProperty
OGeomBaseSchema(CPROP_PTR iParentCompound, const std::string &iName, const Argument &iArg0=Argument(), const Argument &iArg1=Argument(), const Argument &iArg2=Argument())
Definition: OGeomBase.h:79
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Definition: TimeSampling.h:137
#define ALEMBIC_ABC_SAFE_CALL_END_RESET()
Definition: ErrorHandler.h:181
#define ALEMBIC_ABC_SAFE_CALL_BEGIN(CONTEXT)
Definition: ErrorHandler.h:172
OGeomBaseSchema(const OGeomBaseSchema &iCopy)
Copy constructor.
Definition: OGeomBase.h:129
OGeomBaseSchema(CPROP_PTR iParentCompound, const Argument &iArg0=Argument(), const Argument &iArg1=Argument(), const Argument &iArg2=Argument())
Definition: OGeomBase.h:104
#define ALEMBIC_ABC_SAFE_CALL_END()
Definition: ErrorHandler.h:198
AbcA::TimeSamplingPtr GetTimeSampling(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument())
Definition: Argument.h:259
AbcA::CompoundPropertyWriterPtr GetCompoundPropertyWriterPtr(AbcA::CompoundPropertyWriterPtr iPtr)
Definition: Foundation.h:164
uint32_t GetTimeSamplingIndex(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument())
Definition: Argument.h:272
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:104
Alembic::Util::shared_ptr< CompoundPropertyWriter > CompoundPropertyWriterPtr