Alembic Version 1.1
IGeomBase.h
Go to the documentation of this file.
1//-*****************************************************************************
2//
3// Copyright (c) 2009-2011,
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_IGeometrySchema_h
38#define Alembic_AbcGeom_IGeometrySchema_h
39
40#include <Alembic/Abc/ISchema.h>
44
45namespace Alembic {
46namespace AbcGeom {
47namespace ALEMBIC_VERSION_NS {
48
49
59template <class INFO>
60class IGeomBaseSchema : public Abc::ISchema<INFO>
61{
62public:
63 //-*************************************************************************
64 // TYPEDEFS AND IDENTIFIERS
65 //-*************************************************************************
66
67 typedef INFO info_type;
68
69
70 //-*************************************************************************
71 // Constructors that pass through to ISchema
72 //-*************************************************************************
73 //
77
81 const std::string &iName,
82 const Argument &iArg0 = Argument(),
83 const Argument &iArg1 = Argument() )
84 : Abc::ISchema<info_type>( iParent, iName, iArg0, iArg1 )
85 {
86 init( iArg0, iArg1 );
87 }
88
91 const Abc::Argument &iArg0 = Abc::Argument(),
92 const Abc::Argument &iArg1 = Abc::Argument() )
93 : Abc::ISchema<info_type>( iProp, iArg0, iArg1 )
94 {
95 init( iArg0, iArg1 );
96 }
97
98 // Deprecated in favor of the constructor above
101 const Abc::Argument &iArg0 = Abc::Argument(),
102 const Abc::Argument &iArg1 = Abc::Argument() )
103 : Abc::ISchema<info_type>( iProp, iArg0, iArg1 )
104 {
105 init( iArg0, iArg1 );
106 }
107
110 : Abc::ISchema<info_type>()
111 {
112 *this = iCopy;
113 }
114
115 void init( const Abc::Argument &iArg0, const Abc::Argument &iArg1 )
116 {
117 ALEMBIC_ABC_SAFE_CALL_BEGIN( "IGeomBaseSchema::init()" );
118
119 Abc::Arguments args;
120 iArg0.setInto( args );
121 iArg1.setInto( args );
122
124
125 m_selfBoundsProperty = Abc::IBox3dProperty( _this, ".selfBnds",
126 iArg0, iArg1 );
127 if ( this->getPropertyHeader( ".childBnds" ) != NULL )
128 {
130 ".childBnds", iArg0, iArg1 );
131 }
132
133 if ( this->getPropertyHeader( ".arbGeomParams" ) != NULL )
134 {
135 m_arbGeomParams = Abc::ICompoundProperty( _this, ".arbGeomParams",
136 args.getErrorHandlerPolicy() );
137 }
138 if ( this->getPropertyHeader( ".userProperties" ) != NULL )
139 {
140 m_userProperties = Abc::ICompoundProperty( _this, ".userProperties",
141 args.getErrorHandlerPolicy() );
142 }
143
145 }
146
147 virtual void reset ()
148 {
154 }
155
156 virtual bool valid() const
157 {
158 // Only selfBounds is required, all others are optional
161 }
162
164 {
166 }
167
169 {
171 }
172
173 // compound property to use as parent for any arbitrary GeomParams
174 // underneath it
176
177 // compound property to use as parent for any user workflow specific
178 // properties
180
181protected:
182 // Only selfBounds is required, all others are optional
185
188
189};
190
191//-*****************************************************************************
206class IGeomBase : public IGeomBaseSchema<GeomBaseSchemaInfo>
207{
208public:
210
211 class Sample
212 {
213 public:
215
216 // Users don't ever create this data directly.
217 Sample() { reset(); }
218
219 Abc::Box3d getSelfBounds() const { return m_selfBounds; }
220
221 void reset()
222 {
223 m_selfBounds.makeEmpty();
224 }
225
226 protected:
227 friend class IGeomBase;
228 Abc::Box3d m_selfBounds;
229 };
230
231public:
234
235 //-*************************************************************************
236 // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
237 //-*************************************************************************
238
241
243 const std::string &iName,
244 const Abc::Argument &iArg0 = Abc::Argument(),
245 const Abc::Argument &iArg1 = Abc::Argument() )
246
247 // We don't want strict matching of the title because the real schema
248 // is going to be something like "AbcGeom_<type>_vX"
249 : IGeomBaseSchema<GeomBaseSchemaInfo>( iParent, iName, kNoMatching )
250 {
251 init( iArg0, iArg1 );
252 }
253
255 const Abc::Argument &iArg0 = Abc::Argument(),
256 const Abc::Argument &iArg1 = Abc::Argument() )
257 // We don't want strict matching of the title because the real schema
258 // is going to be something like "AbcGeom_<type>_vX"
259 : IGeomBaseSchema<GeomBaseSchemaInfo>( iThis, kNoMatching )
260 {
261 init( iArg0, iArg1 );
262 }
263
266 const Abc::Argument &iArg0 = Abc::Argument(),
267 const Abc::Argument &iArg1 = Abc::Argument() )
268 : IGeomBaseSchema<GeomBaseSchemaInfo>( iThis, kNoMatching )
269 {
270 init( iArg0, iArg1 );
271 }
272
274 IGeomBase(const IGeomBase & iCopy)
275 : IGeomBaseSchema<GeomBaseSchemaInfo>()
276 {
277 *this = iCopy;
278 }
279
281
282 //-*************************************************************************
283 // SCALAR PROPERTY READER FUNCTIONALITY
284 //-*************************************************************************
285
290 size_t getNumSamples() const
292
295 bool isConstant() const
296 { return m_selfBoundsProperty.isConstant(); }
297
301 {
303 {
305 }
306 else
307 {
308 return getObject().getArchive().getTimeSampling( 0 );
309 }
310 }
311
312 //-*************************************************************************
313 void get( Sample &oSample,
314 const Abc::ISampleSelector &iSS = Abc::ISampleSelector() ) const
315 {
316 ALEMBIC_ABC_SAFE_CALL_BEGIN( "IGeomBase::get()" );
317
318 m_selfBoundsProperty.get( oSample.m_selfBounds, iSS );
319
321 }
322
323 //-*************************************************************************
325 {
326 Sample smp;
327 get( smp, iSS );
328 return smp;
329 }
330
331 //-*************************************************************************
333
334 //-*************************************************************************
336
337 //-*************************************************************************
340 void reset()
341 {
343 }
344
345 //-*************************************************************************
348 bool valid() const
349 {
351 }
352
353 //-*************************************************************************
357
358 //-*************************************************************************
362 static bool matches( const AbcA::MetaData &iMetaData,
364 {
365 if ( iMatching == kNoMatching )
366 { return true; }
367
368 if ( iMatching == kStrictMatching || iMatching == kSchemaTitleMatching )
369 {
370 return iMetaData.get( "schemaBaseType" ) ==
371 GeomBaseSchemaInfo::title();
372 }
373
374 return false;
375 }
376
377 //-*************************************************************************
381 static bool matches( const AbcA::PropertyHeader &iHeader,
383 {
384 return matches( iHeader.getMetaData(), iMatching );
385 }
386
387};
388
389//-*****************************************************************************
391
392} // End namespace ALEMBIC_VERSION_NS
393
394using namespace ALEMBIC_VERSION_NS;
395
396} // End namespace AbcGeom
397} // End namespace Alembic
398
399#endif
#define ALEMBIC_ABC_SAFE_CALL_END()
Definition: ErrorHandler.h:198
#define ALEMBIC_ABC_SAFE_CALL_BEGIN(CONTEXT)
Definition: ErrorHandler.h:172
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:105
std::string get(const std::string &iKey) const
Definition: MetaData.h:192
IGeomBaseSchema(const ICompoundProperty &iParent, const std::string &iName, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
Definition: IGeomBase.h:80
IGeomBaseSchema(const IGeomBaseSchema &iCopy)
Copy constructor.
Definition: IGeomBase.h:109
IGeomBaseSchema(const ICompoundProperty &iProp, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Wrap an existing schema object.
Definition: IGeomBase.h:90
Abc::IBox3dProperty getSelfBoundsProperty() const
Definition: IGeomBase.h:163
void init(const Abc::Argument &iArg0, const Abc::Argument &iArg1)
Definition: IGeomBase.h:115
Abc::IBox3dProperty getChildBoundsProperty() const
Definition: IGeomBase.h:168
IGeomBaseSchema(const ICompoundProperty &iProp, Abc::WrapExistingFlag iFlag, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: IGeomBase.h:99
size_t getNumSamples() const
Default assignment operator used.
Definition: IGeomBase.h:290
IGeomBase(const ICompoundProperty &iParent, const std::string &iName, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: IGeomBase.h:242
IGeomBase()
The default constructor creates an empty GeomBase.
Definition: IGeomBase.h:240
Abc::ICompoundProperty getArbGeomParams() const
Definition: IGeomBase.h:332
static bool matches(const AbcA::MetaData &iMetaData, SchemaInterpMatching iMatching=kStrictMatching)
Definition: IGeomBase.h:362
IGeomBase(const ICompoundProperty &iThis, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: IGeomBase.h:254
static bool matches(const AbcA::PropertyHeader &iHeader, SchemaInterpMatching iMatching=kStrictMatching)
Definition: IGeomBase.h:381
void get(Sample &oSample, const Abc::ISampleSelector &iSS=Abc::ISampleSelector()) const
Definition: IGeomBase.h:313
IGeomBase(const ICompoundProperty &iThis, Abc::WrapExistingFlag iFlag, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: IGeomBase.h:264
Abc::ICompoundProperty getUserProperties() const
Definition: IGeomBase.h:335
IGeomBase(const IGeomBase &iCopy)
Copy constructor.
Definition: IGeomBase.h:274
Sample getValue(const Abc::ISampleSelector &iSS=Abc::ISampleSelector()) const
Definition: IGeomBase.h:324
AbcA::TimeSamplingPtr getTimeSampling() const
Definition: IGeomBase.h:300
void setInto(Arguments &iArgs) const
Definition: Argument.h:149
ErrorHandler::Policy getErrorHandlerPolicy() const
Definition: Argument.h:83
AbcA::TimeSamplingPtr getTimeSampling(uint32_t iIndex)
Returns the TimeSampling at a given index.
const AbcA::PropertyHeader & getPropertyHeader(size_t i) const
AbcA::TimeSamplingPtr getTimeSampling() const
void get(value_type &iVal, const ISampleSelector &iSS=ISampleSelector()) const
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Definition: TimeSampling.h:137
Alembic::Util::shared_ptr< CompoundPropertyReader > CompoundPropertyReaderPtr
Abc::ISchemaObject< IGeomBase > IGeomBaseObject
Definition: IGeomBase.h:390
ITypedScalarProperty< Box3dTPTraits > IBox3dProperty
Alembic namespace ...
Definition: ArchiveInfo.h:46