Alembic Version 1.1

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>
41#include <Alembic/AbcGeom/Foundation.h>
42#include <Alembic/AbcGeom/OGeomParam.h>
43
44 namespace Alembic {
45 namespace AbcGeom {
46 namespace ALEMBIC_VERSION_NS {
47
48
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 //
74 OGeomBaseSchema() {}
75
78 OGeomBaseSchema( AbcA::CompoundPropertyWriterPtr iParent,
79 const std::string &iName,
80 const Argument &iArg0 = Argument(),
81 const Argument &iArg1 = Argument(),
82 const Argument &iArg2 = Argument(),
83 const Argument &iArg3 = Argument() )
84 : Abc::OSchema<info_type>( iParent, iName, iArg0, iArg1, iArg2, iArg3 )
85 {
86 AbcA::TimeSamplingPtr tsPtr =
87 Abc::GetTimeSampling( iArg0, iArg1, iArg2, iArg3 );
88 uint32_t tsIndex =
89 Abc::GetTimeSamplingIndex( iArg0, iArg1, iArg2, iArg3 );
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 = iParent->getObject()->getArchive()->addTimeSampling(
96 *tsPtr );
97 }
98
99 // Create our always present property
100 init( tsIndex, Abc::IsSparse( iArg0, iArg1, iArg2, iArg3 ) );
101 }
102
104 OGeomBaseSchema( const OGeomBaseSchema& iCopy )
105 : Abc::OSchema<info_type>()
106 {
107 *this = iCopy;
108 }
109
110 virtual void reset ()
111 {
112 m_selfBoundsProperty.reset();
113 m_childBoundsProperty.reset();
114 m_arbGeomParams.reset();
115 m_userProperties.reset();
116 Abc::OSchema<info_type>::reset();
117 }
118
119 virtual bool valid() const
120 {
121 return ( Abc::OSchema<info_type>::valid() );
122 }
123
124 Abc::OCompoundProperty getArbGeomParams()
125 {
126 // Accessing the ArbGeomParams will create its compound
127 // property if needed.
128 ALEMBIC_ABC_SAFE_CALL_BEGIN( "OGeomBaseSchema::getArbGeomParams()" );
129
130 if ( ! m_arbGeomParams )
131 {
132 m_arbGeomParams = Abc::OCompoundProperty( this->getPtr(),
133 ".arbGeomParams" );
134 }
135
136 return m_arbGeomParams;
137
138 ALEMBIC_ABC_SAFE_CALL_END();
139
140 Abc::OCompoundProperty ret;
141 return ret;
142 }
143
144 Abc::OCompoundProperty getUserProperties()
145 {
146 // Accessing UserProperties will create its compound
147 // property if needed.
148 ALEMBIC_ABC_SAFE_CALL_BEGIN( "OGeomBaseSchema::getUserProperties()" );
149
150 if ( ! m_userProperties )
151 {
152 m_userProperties = Abc::OCompoundProperty( this->getPtr(),
153 ".userProperties" );
154 }
155
156 return m_userProperties;
157
158 ALEMBIC_ABC_SAFE_CALL_END();
159
160 Abc::OCompoundProperty ret;
161 return ret;
162 }
163
164 Abc::OBox3dProperty getChildBoundsProperty()
165 {
166 // Accessing Child Bounds Property will create it if needed
167 ALEMBIC_ABC_SAFE_CALL_BEGIN(
168 "OGeomBaseSchema::getChildBoundsProperty()" );
169
170 if ( ! m_childBoundsProperty )
171 {
172 AbcA::CompoundPropertyWriterPtr _this = this->getPtr();
173
174 // for now, use the self bounds time sampling, this
175 // can and should be changed depending on how the children
176 // are sampled
177 m_childBoundsProperty = Abc::OBox3dProperty( _this,
178 ".childBnds", m_selfBoundsProperty.getTimeSampling() );
179
180 }
181
182 ALEMBIC_ABC_SAFE_CALL_END();
183 return m_childBoundsProperty;
184 }
185
186 protected:
187
188 void init( uint32_t iTsIndex, bool isSparse)
189 {
190 ALEMBIC_ABC_SAFE_CALL_BEGIN( "OGeomBaseSchema::init()" );
191
192 if( !isSparse )
193 {
194 createSelfBoundsProperty(iTsIndex, 0);
195 }
196
197 ALEMBIC_ABC_SAFE_CALL_END_RESET();
198 }
199
201 void createSelfBoundsProperty(uint32_t iTsIndex, size_t iNumSamples)
202 {
203 ALEMBIC_ABC_SAFE_CALL_BEGIN( "OGeomBaseSchema::createSelfBoundsProperty()" );
204
205 if ( m_selfBoundsProperty.valid() )
206 {
207 return;
208 }
209
210 m_selfBoundsProperty = Abc::OBox3dProperty( this->getPtr(), ".selfBnds",
211 iTsIndex );
212
213 Abc::Box3d bnds;
214 for ( size_t i = 0; i < iNumSamples; ++i )
215 {
216 m_selfBoundsProperty.set( bnds );
217 }
218 ALEMBIC_ABC_SAFE_CALL_END();
219 }
220
221 // Only selfBounds is required, all others are optional
222 Abc::OBox3dProperty m_selfBoundsProperty;
223 Abc::OBox3dProperty m_childBoundsProperty;
224
225 Abc::OCompoundProperty m_arbGeomParams;
226 Abc::OCompoundProperty m_userProperties;
227
228};
229
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
Foundation.h
ALEMBIC_ABC_SAFE_CALL_END
#define ALEMBIC_ABC_SAFE_CALL_END()
Definition: ErrorHandler.h:198
ALEMBIC_ABC_SAFE_CALL_BEGIN
#define ALEMBIC_ABC_SAFE_CALL_BEGIN(CONTEXT)
Definition: ErrorHandler.h:172
ALEMBIC_ABC_SAFE_CALL_END_RESET
#define ALEMBIC_ABC_SAFE_CALL_END_RESET()
Definition: ErrorHandler.h:181
OGeomParam.h
OSchema.h
ALEMBIC_VERSION_NS
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:105
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema
Definition: OGeomBase.h:59
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema::getChildBoundsProperty
Abc::OBox3dProperty getChildBoundsProperty()
Definition: OGeomBase.h:164
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema::OGeomBaseSchema
OGeomBaseSchema()
Definition: OGeomBase.h:74
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema::OGeomBaseSchema
OGeomBaseSchema(AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const Argument &iArg0=Argument(), const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
Definition: OGeomBase.h:78
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema::info_type
INFO info_type
Definition: OGeomBase.h:65
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema::m_arbGeomParams
Abc::OCompoundProperty m_arbGeomParams
Definition: OGeomBase.h:225
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema::reset
virtual void reset()
Definition: OGeomBase.h:110
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema::createSelfBoundsProperty
void createSelfBoundsProperty(uint32_t iTsIndex, size_t iNumSamples)
Creates the self bounds.
Definition: OGeomBase.h:201
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema::valid
virtual bool valid() const
Definition: OGeomBase.h:119
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema::getUserProperties
Abc::OCompoundProperty getUserProperties()
Definition: OGeomBase.h:144
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema::m_childBoundsProperty
Abc::OBox3dProperty m_childBoundsProperty
Definition: OGeomBase.h:223
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema::OGeomBaseSchema
OGeomBaseSchema(const OGeomBaseSchema &iCopy)
Copy constructor.
Definition: OGeomBase.h:104
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema::m_selfBoundsProperty
Abc::OBox3dProperty m_selfBoundsProperty
Definition: OGeomBase.h:222
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema::m_userProperties
Abc::OCompoundProperty m_userProperties
Definition: OGeomBase.h:226
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema::getArbGeomParams
Abc::OCompoundProperty getArbGeomParams()
Definition: OGeomBase.h:124
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema::init
void init(uint32_t iTsIndex, bool isSparse)
Definition: OGeomBase.h:188
Alembic::Abc::ALEMBIC_VERSION_NS::Argument
Definition: Argument.h:120
Alembic::Abc::ALEMBIC_VERSION_NS::OBasePropertyT< AbcA::CompoundPropertyWriterPtr >::getPtr
AbcA::CompoundPropertyWriterPtr getPtr() const
Definition: OBaseProperty.h:162
Alembic::Abc::ALEMBIC_VERSION_NS::OBasePropertyT::reset
void reset()
Definition: OBaseProperty.h:166
Alembic::Abc::ALEMBIC_VERSION_NS::OBasePropertyT::getTimeSampling
AbcA::TimeSamplingPtr getTimeSampling() const
Definition: OBaseProperty.h:143
Alembic::Abc::ALEMBIC_VERSION_NS::OBasePropertyT::valid
bool valid() const
Definition: OBaseProperty.h:170
Alembic::Abc::ALEMBIC_VERSION_NS::OCompoundProperty
Definition: OCompoundProperty.h:53
Alembic::Abc::ALEMBIC_VERSION_NS::OSchema
Definition: OSchema.h:119
Alembic::Abc::ALEMBIC_VERSION_NS::OSchema::info_type
INFO info_type
Definition: OSchema.h:125
Alembic::Abc::ALEMBIC_VERSION_NS::OTypedScalarProperty< Box3dTPTraits >
Alembic::Abc::ALEMBIC_VERSION_NS::OTypedScalarProperty::set
void set(const value_type &iVal)
Definition: OTypedScalarProperty.h:173
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::CompoundPropertyWriterPtr
Alembic::Util::shared_ptr< CompoundPropertyWriter > CompoundPropertyWriterPtr
Definition: ForwardDeclarations.h:83
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::TimeSamplingPtr
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Definition: TimeSampling.h:137
Alembic::Abc::ALEMBIC_VERSION_NS
Definition: ArchiveInfo.h:48
Alembic::Abc::ALEMBIC_VERSION_NS::OBox3dProperty
OTypedScalarProperty< Box3dTPTraits > OBox3dProperty
Definition: OTypedScalarProperty.h:273
Alembic::Abc::ALEMBIC_VERSION_NS::GetTimeSampling
AbcA::TimeSamplingPtr GetTimeSampling(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
Definition: Argument.h:288
Alembic::Abc::ALEMBIC_VERSION_NS::GetTimeSamplingIndex
uint32_t GetTimeSamplingIndex(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
Definition: Argument.h:303
Alembic::Abc::ALEMBIC_VERSION_NS::IsSparse
bool IsSparse(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
Definition: Argument.h:333
Alembic
Alembic namespace ...
Definition: ArchiveInfo.h:46