52 typedef typename TRAITS::value_type value_type;
61 typedef Sample this_type;
64 : m_scope( kUnknownScope )
68 GeometryScope iScope )
74 const Abc::UInt32ArraySample &iIndices,
75 GeometryScope iScope )
77 , m_indices( iIndices )
86 void setIndices(
const Abc::UInt32ArraySample &iIndices )
87 { m_indices = iIndices; }
88 const Abc::UInt32ArraySample &getIndices()
const
91 void setScope( GeometryScope iScope )
93 GeometryScope getScope()
const
100 m_scope = kUnknownScope;
103 bool valid()
const {
return m_vals; }
105 ALEMBIC_OPERATOR_BOOL( valid() );
109 Abc::UInt32ArraySample m_indices;
110 GeometryScope m_scope;
114 typedef OTypedGeomParam<TRAITS> this_type;
117 static const char * getInterpretation()
119 return TRAITS::interpretation();
122 static bool matches(
const AbcA::PropertyHeader &iHeader,
123 SchemaInterpMatching iMatching = kStrictMatching )
125 if ( iHeader.isCompound() )
127 return ( iHeader.getMetaData().get(
"podName" ) ==
128 Alembic::Util::PODName( TRAITS::dataType().getPod() ) &&
129 ( std::string() == getInterpretation() ||
131 iHeader.getMetaData().get(
"podExtent" ).c_str() ) ==
132 TRAITS::dataType().getExtent() ) ) &&
135 else if ( iHeader.isArray() )
146 , m_scope(kUnknownScope)
151 OTypedGeomParam( OCompoundProperty iParent,
152 const std::string &iName,
154 GeometryScope iScope,
156 const Argument &iArg0 = Argument(),
157 const Argument &iArg1 = Argument(),
158 const Argument &iArg2 = Argument()
161 , m_isIndexed( iIsIndexed )
164 *
this = OTypedGeomParam( iParent.getPtr(), iName, iIsIndexed, iScope,
165 iArrayExtent, iArg0, iArg1, iArg2 );
168 OTypedGeomParam( AbcA::CompoundPropertyWriterPtr iParent,
169 const std::string &iName,
171 GeometryScope iScope,
173 const Argument &iArg0 = Argument(),
174 const Argument &iArg1 = Argument(),
175 const Argument &iArg2 = Argument()
178 , m_isIndexed( iIsIndexed )
181 Arguments args( Abc::GetErrorHandlerPolicy( iParent ) );
182 iArg0.setInto( args );
183 iArg1.setInto( args );
184 iArg2.setInto( args );
186 AbcA::MetaData md = args.getMetaData();
188 SetGeometryScope( md, iScope );
190 md.set(
"isGeomParam",
"true" );
192 std::string podName( Alembic::Util::PODName(
193 TRAITS::dataType().getPod() ) );
195 size_t extent = TRAITS::dataType().getExtent();
197 md.set(
"podName", podName );
199 std::ostringstream extentStrm;
200 extentStrm << extent;
201 std::string extentStr = extentStrm.str();
202 md.set(
"podExtent", extentStr );
204 std::ostringstream arrayExtentStrm;
205 arrayExtentStrm << iArrayExtent;
206 std::string arrayExtentStr = arrayExtentStrm.str();
207 md.set(
"arrayExtent", arrayExtentStr );
209 md.set(
"interpretation", TRAITS::interpretation() );
211 Abc::ErrorHandler::Policy ehp = args.getErrorHandlerPolicy();
213 AbcA::TimeSamplingPtr tsPtr = args.getTimeSampling();
214 uint32_t tsIndex = args.getTimeSamplingIndex();
221 AbcA::CompoundPropertyWriterPtr parent =
222 GetCompoundPropertyWriterPtr( iParent );
224 parent->getObject()->getArchive()->addTimeSampling(*tsPtr);
229 m_cprop = Abc::OCompoundProperty( iParent, iName, md, ehp );
231 m_valProp = prop_type( m_cprop,
".vals", md, ehp, tsIndex );
233 m_indicesProperty = Abc::OUInt32ArrayProperty( m_cprop,
".indices",
238 m_valProp = prop_type( iParent, iName, md, ehp, tsIndex );
244 void set(
const sample_type &iSamp )
246 ALEMBIC_ABC_SAFE_CALL_BEGIN(
"OTypedGeomParam::set()" );
248 if ( m_valProp.getNumSamples() == 0 )
250 m_valProp.set( iSamp.getVals() );
251 if ( m_isIndexed ) { m_indicesProperty.set( iSamp.getIndices() ); }
255 SetPropUsePrevIfNull( m_valProp, iSamp.getVals() );
258 SetPropUsePrevIfNull( m_indicesProperty, iSamp.getIndices() );
262 ALEMBIC_ABC_SAFE_CALL_END_RESET();
265 void setFromPrevious()
267 ALEMBIC_ABC_SAFE_CALL_BEGIN(
"OTypedGeomParam::setFromPrevious()" );
269 m_valProp.setFromPrevious();
271 if ( m_isIndexed ) { m_indicesProperty.setFromPrevious(); }
273 ALEMBIC_ABC_SAFE_CALL_END();
276 void setTimeSampling( uint32_t iIndex )
278 ALEMBIC_ABC_SAFE_CALL_BEGIN(
279 "OTypedGeomParam::setTimeSampling( uint32_t )" );
281 m_valProp.setTimeSampling( iIndex );
283 if ( m_isIndexed ) { m_indicesProperty.setTimeSampling( iIndex ); }
285 ALEMBIC_ABC_SAFE_CALL_END();
288 void setTimeSampling( AbcA::TimeSamplingPtr iTime )
290 ALEMBIC_ABC_SAFE_CALL_BEGIN(
291 "OTypedGeomParam::setTimeSampling( TimeSamplingPtr )" );
296 m_valProp.getParent().getObject().getArchive().addTimeSampling(
298 setTimeSampling( tsIndex );
301 ALEMBIC_ABC_SAFE_CALL_END();
304 size_t getNumSamples()
const
306 ALEMBIC_ABC_SAFE_CALL_BEGIN(
"OTypedGeomParam::getNumSamples()" );
310 if ( m_indicesProperty )
312 return std::max( m_indicesProperty.getNumSamples(),
313 m_valProp.getNumSamples() );
319 if ( m_valProp ) {
return m_valProp.getNumSamples(); }
323 ALEMBIC_ABC_SAFE_CALL_END();
328 AbcA::DataType getDataType()
const {
return TRAITS::dataType(); }
330 bool isIndexed()
const {
return m_isIndexed; }
332 GeometryScope getScope()
const {
return m_scope; }
334 AbcA::TimeSamplingPtr getTimeSampling()
const
336 return m_valProp.getTimeSampling();
339 const std::string &getName()
const {
return m_name; }
343 return ( m_valProp.valid()
344 && ( ( ! m_isIndexed ) || m_indicesProperty ) );
347 ALEMBIC_OPERATOR_BOOL( this_type::valid() );
353 m_indicesProperty.reset();
355 m_scope = kUnknownScope;
359 prop_type getValueProperty()
const {
return m_valProp; }
361 OUInt32ArrayProperty getIndexProperty()
const {
return m_indicesProperty; }
364 Abc::ErrorHandler &getErrorHandler()
const
365 {
return m_valProp.getErrorHandler(); }
371 OUInt32ArrayProperty m_indicesProperty;
374 GeometryScope m_scope;
377 Abc::OCompoundProperty m_cprop;