Alembic 1.8.11

Loading...
Searching...
No Matches
IGeomBase.h
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>
41#include <Alembic/AbcGeom/Foundation.h>
42#include <Alembic/AbcGeom/IGeomParam.h>
43#include <Alembic/AbcGeom/SchemaInfoDeclarations.h>
44
45 namespace Alembic {
46 namespace AbcGeom {
47 namespace ALEMBIC_VERSION_NS {
48
49
59 template <class INFO>
60 class IGeomBaseSchema : public Abc::ISchema<INFO>
61{
62 public:
63 //-*************************************************************************
64 // TYPEDEFS AND IDENTIFIERS
65 //-*************************************************************************
66
67 typedef INFO info_type;
68
69
70 //-*************************************************************************
71 // Constructors that pass through to ISchema
72 //-*************************************************************************
73 //
76 IGeomBaseSchema() {}
77
80 IGeomBaseSchema( const ICompoundProperty & iParent,
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
90 IGeomBaseSchema( const ICompoundProperty & iProp,
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
99 IGeomBaseSchema( const ICompoundProperty & iProp,
100 Abc::WrapExistingFlag iFlag,
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
108 void init( const Abc::Argument &iArg0, const Abc::Argument &iArg1 )
109 {
110 ALEMBIC_ABC_SAFE_CALL_BEGIN( "IGeomBaseSchema::init()" );
111
112 Abc::Arguments args;
113 iArg0.setInto( args );
114 iArg1.setInto( args );
115
116 AbcA::CompoundPropertyReaderPtr _this = this->getPtr();
117
118 m_selfBoundsProperty = Abc::IBox3dProperty( _this, ".selfBnds",
119 iArg0, iArg1 );
120 if ( this->getPropertyHeader( ".childBnds" ) != NULL )
121 {
122 m_childBoundsProperty = Abc::IBox3dProperty( _this,
123 ".childBnds", iArg0, iArg1 );
124 }
125
126 if ( this->getPropertyHeader( ".arbGeomParams" ) != NULL )
127 {
128 m_arbGeomParams = Abc::ICompoundProperty( _this, ".arbGeomParams",
129 args.getErrorHandlerPolicy() );
130 }
131 if ( this->getPropertyHeader( ".userProperties" ) != NULL )
132 {
133 m_userProperties = Abc::ICompoundProperty( _this, ".userProperties",
134 args.getErrorHandlerPolicy() );
135 }
136
137 ALEMBIC_ABC_SAFE_CALL_END();
138 }
139
140 virtual void reset ()
141 {
142 m_selfBoundsProperty.reset();
143 m_childBoundsProperty.reset();
144 m_arbGeomParams.reset();
145 m_userProperties.reset();
146 Abc::ISchema<info_type>::reset();
147 }
148
149 virtual bool valid() const
150 {
151 // Only selfBounds is required, all others are optional
152 return ( Abc::ISchema<info_type>::valid() &&
153 m_selfBoundsProperty.valid() );
154 }
155
156 Abc::IBox3dProperty getSelfBoundsProperty() const
157 {
158 return m_selfBoundsProperty;
159 }
160
161 Abc::IBox3dProperty getChildBoundsProperty() const
162 {
163 return m_childBoundsProperty;
164 }
165
166 // compound property to use as parent for any arbitrary GeomParams
167 // underneath it
168 ICompoundProperty getArbGeomParams() const { return m_arbGeomParams; }
169
170 // compound property to use as parent for any user workflow specific
171 // properties
172 ICompoundProperty getUserProperties() const { return m_userProperties; }
173
174 protected:
175 // Only selfBounds is required, all others are optional
176 Abc::IBox3dProperty m_selfBoundsProperty;
177 Abc::IBox3dProperty m_childBoundsProperty;
178
179 Abc::ICompoundProperty m_arbGeomParams;
180 Abc::ICompoundProperty m_userProperties;
181
182};
183
184//-*****************************************************************************
199 class IGeomBase : public IGeomBaseSchema<GeomBaseSchemaInfo>
200{
201 public:
202 typedef IGeomBase this_type;
203
204 class Sample
205 {
206 public:
207 typedef Sample this_type;
208
209 // Users don't ever create this data directly.
210 Sample() { reset(); }
211
212 Abc::Box3d getSelfBounds() const { return m_selfBounds; }
213
214 void reset()
215 {
216 m_selfBounds.makeEmpty();
217 }
218
219 protected:
220 friend class IGeomBase;
221 Abc::Box3d m_selfBounds;
222 };
223
224 public:
227
228 //-*************************************************************************
229 // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
230 //-*************************************************************************
231
233 IGeomBase() {}
234
235 IGeomBase( const ICompoundProperty &iParent,
236 const std::string &iName,
237 const Abc::Argument &iArg0 = Abc::Argument(),
238 const Abc::Argument &iArg1 = Abc::Argument() )
239
240 // We don't want strict matching of the title because the real schema
241 // is going to be something like "AbcGeom_<type>_vX"
242 : IGeomBaseSchema<GeomBaseSchemaInfo>( iParent, iName, kNoMatching )
243 {
244 init( iArg0, iArg1 );
245 }
246
247 IGeomBase( const ICompoundProperty & iThis,
248 const Abc::Argument &iArg0 = Abc::Argument(),
249 const Abc::Argument &iArg1 = Abc::Argument() )
250 // We don't want strict matching of the title because the real schema
251 // is going to be something like "AbcGeom_<type>_vX"
252 : IGeomBaseSchema<GeomBaseSchemaInfo>( iThis, kNoMatching )
253 {
254 init( iArg0, iArg1 );
255 }
256
257 IGeomBase( const ICompoundProperty & iThis,
258 Abc::WrapExistingFlag iFlag,
259 const Abc::Argument &iArg0 = Abc::Argument(),
260 const Abc::Argument &iArg1 = Abc::Argument() )
261 : IGeomBaseSchema<GeomBaseSchemaInfo>( iThis, kNoMatching )
262 {
263 init( iArg0, iArg1 );
264 }
265
267
268 //-*************************************************************************
269 // SCALAR PROPERTY READER FUNCTIONALITY
270 //-*************************************************************************
271
276 size_t getNumSamples() const
277 { return m_selfBoundsProperty.getNumSamples(); }
278
281 bool isConstant() const
282 { return m_selfBoundsProperty.isConstant(); }
283
286 AbcA::TimeSamplingPtr getTimeSampling() const
287 {
288 if ( m_selfBoundsProperty.valid() )
289 {
290 return m_selfBoundsProperty.getTimeSampling();
291 }
292 else
293 {
294 return getObject().getArchive().getTimeSampling( 0 );
295 }
296 }
297
298 //-*************************************************************************
299 void get( Sample &oSample,
300 const Abc::ISampleSelector &iSS = Abc::ISampleSelector() ) const
301 {
302 ALEMBIC_ABC_SAFE_CALL_BEGIN( "IGeomBase::get()" );
303
304 m_selfBoundsProperty.get( oSample.m_selfBounds, iSS );
305
306 ALEMBIC_ABC_SAFE_CALL_END();
307 }
308
309 //-*************************************************************************
310 Sample getValue( const Abc::ISampleSelector &iSS = Abc::ISampleSelector() ) const
311 {
312 Sample smp;
313 get( smp, iSS );
314 return smp;
315 }
316
317 //-*************************************************************************
318 Abc::ICompoundProperty getArbGeomParams() const { return m_arbGeomParams; }
319
320 //-*************************************************************************
321 Abc::ICompoundProperty getUserProperties() const { return m_userProperties; }
322
323 //-*************************************************************************
326 void reset()
327 {
328 IGeomBaseSchema<GeomBaseSchemaInfo>::reset();
329 }
330
331 //-*************************************************************************
334 bool valid() const
335 {
336 return ( IGeomBaseSchema<GeomBaseSchemaInfo>::valid() );
337 }
338
339 //-*************************************************************************
342 ALEMBIC_OVERRIDE_OPERATOR_BOOL( IGeomBase::valid() );
343
344 //-*************************************************************************
348 static bool matches( const AbcA::MetaData &iMetaData,
349 SchemaInterpMatching iMatching = kStrictMatching )
350 {
351 if ( iMatching == kNoMatching )
352 { return true; }
353
354 if ( iMatching == kStrictMatching || iMatching == kSchemaTitleMatching )
355 {
356 return iMetaData.get( "schemaBaseType" ) ==
357 GeomBaseSchemaInfo::title();
358 }
359
360 return false;
361 }
362
363 //-*************************************************************************
367 static bool matches( const AbcA::PropertyHeader &iHeader,
368 SchemaInterpMatching iMatching = kStrictMatching )
369 {
370 return matches( iHeader.getMetaData(), iMatching );
371 }
372
373};
374
375//-*****************************************************************************
376 typedef Abc::ISchemaObject<IGeomBase> IGeomBaseObject;
377
378} // End namespace ALEMBIC_VERSION_NS
379
380 using namespace ALEMBIC_VERSION_NS;
381
382} // End namespace AbcGeom
383} // End namespace Alembic
384
385#endif
Alembic::Abc::ALEMBIC_VERSION_NS::Argument
Definition Argument.h:120
Alembic::Abc::ALEMBIC_VERSION_NS::Arguments
Definition Argument.h:49
Alembic::Abc::ALEMBIC_VERSION_NS::IArchive::getTimeSampling
AbcA::TimeSamplingPtr getTimeSampling(uint32_t iIndex)
Returns the TimeSampling at a given index.
Definition IArchive.cpp:93
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT< AbcA::CompoundPropertyReaderPtr >::getObject
IObject getObject() const
Definition IBaseProperty.h:207
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT< AbcA::CompoundPropertyReaderPtr >::reset
void reset()
Definition IBaseProperty.h:160
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT< AbcA::CompoundPropertyReaderPtr >::valid
bool valid() const
Definition IBaseProperty.h:164
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT< AbcA::CompoundPropertyReaderPtr >::getPtr
AbcA::CompoundPropertyReaderPtr getPtr() const
Definition IBaseProperty.h:156
Alembic::Abc::ALEMBIC_VERSION_NS::ICompoundProperty
Definition ICompoundProperty.h:53
Alembic::Abc::ALEMBIC_VERSION_NS::ICompoundProperty::ICompoundProperty
ICompoundProperty()
Definition ICompoundProperty.h:65
Alembic::Abc::ALEMBIC_VERSION_NS::ICompoundProperty::getPropertyHeader
const AbcA::PropertyHeader & getPropertyHeader(size_t i) const
Definition ICompoundProperty.cpp:111
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getArchive
IArchive getArchive() const
Definition IObject.cpp:106
Alembic::Abc::ALEMBIC_VERSION_NS::ISampleSelector
Definition ISampleSelector.h:49
Alembic::Abc::ALEMBIC_VERSION_NS::ISchema
Definition ISchema.h:58
Alembic::Abc::ALEMBIC_VERSION_NS::ISchema::ISchema
ISchema()
Definition ISchema.h:112
Alembic::Abc::ALEMBIC_VERSION_NS::ISchemaObject
Definition ISchemaObject.h:56
Alembic::Abc::ALEMBIC_VERSION_NS::ITypedScalarProperty::get
void get(value_type &iVal, const ISampleSelector &iSS=ISampleSelector()) const
Definition ITypedScalarProperty.h:194
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IGeomBase::getNumSamples
size_t getNumSamples() const
Default assignment and copy operator used.
Definition IGeomBase.h:276
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IGeomBase::ALEMBIC_OVERRIDE_OPERATOR_BOOL
ALEMBIC_OVERRIDE_OPERATOR_BOOL(IGeomBase::valid())
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IGeomBase::IGeomBase
IGeomBase()
The default constructor creates an empty GeomBase.
Definition IGeomBase.h:233
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IGeomBase::matches
static bool matches(const AbcA::MetaData &iMetaData, SchemaInterpMatching iMatching=kStrictMatching)
Definition IGeomBase.h:348
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IGeomBase::matches
static bool matches(const AbcA::PropertyHeader &iHeader, SchemaInterpMatching iMatching=kStrictMatching)
Definition IGeomBase.h:367
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IGeomBase::valid
bool valid() const
Definition IGeomBase.h:334
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IGeomBase::getTimeSampling
AbcA::TimeSamplingPtr getTimeSampling() const
Definition IGeomBase.h:286
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IGeomBase::reset
void reset()
Definition IGeomBase.h:326
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IGeomBase::isConstant
bool isConstant() const
Definition IGeomBase.h:281
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IGeomBaseSchema
Definition IGeomBase.h:61
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IGeomBaseSchema::IGeomBaseSchema
IGeomBaseSchema(const ICompoundProperty &iParent, const std::string &iName, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
Definition IGeomBase.h:80
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IGeomBaseSchema::IGeomBaseSchema
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
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IGeomBaseSchema::IGeomBaseSchema
IGeomBaseSchema()
Definition IGeomBase.h:76
Alembic
Alembic namespace ...
Definition ArchiveInfo.cpp:39