@@ -117,7 +117,7 @@ struct AverageValueFromVector
117
117
}
118
118
119
119
template <typename T>
120
- IECore::DataPtr operator ()( const IECore::TypedData<std::vector<T> > *data, typename std::enable_if<IsArithmeticVectorTypedData<IECore::TypedData<std::vector<T> > >::value>::type *enabler = nullptr )
120
+ IECore::DataPtr operator ()( const IECore::TypedData<std::vector<T> > *data, typename std::enable_if<IsArithmeticVectorTypedData<IECore::TypedData<std::vector<T> > >::value>::type *enabler = nullptr )
121
121
{
122
122
const auto &src = data->readable ();
123
123
if ( !src.empty () )
@@ -133,61 +133,42 @@ struct AverageValueFromVector
133
133
}
134
134
};
135
135
136
-
137
- inline IECore::DataPtr createArrayData ( PrimitiveVariable& primitiveVariable, const Primitive *primitive, PrimitiveVariable::Interpolation interpolation )
136
+ struct FillVectorFromValue
138
137
{
139
- if ( primitiveVariable.interpolation != PrimitiveVariable::Constant )
140
- return nullptr ;
138
+ template <typename T>
139
+ using IsVectorTypedDataDefined = std::negation< std::is_void< typename IECore::TypedDataTraits< std::vector< T > >::DataHolder > >;
140
+
141
+ explicit FillVectorFromValue ( const size_t len )
142
+ : m_len( len )
143
+ {}
141
144
142
- size_t len = primitive-> variableSize ( interpolation );
143
- switch ( primitiveVariable. data -> typeId () )
145
+ template < typename T >
146
+ IECore::DataPtr operator ()( const IECore::GeometricTypedData< T > * data, typename std::enable_if< IsVectorTypedDataDefined< T >::value >::type *enabler = nullptr ) const
144
147
{
145
- case IECore::IntDataTypeId:
146
- {
147
- IECore::IntVectorDataPtr newData = new IECore::IntVectorData ();
148
- newData->writable ().resize ( len, static_cast < const IECore::IntData * >( primitiveVariable.data .get () )->readable () );
149
- return newData;
150
- }
151
- break ;
152
- case IECore::FloatDataTypeId:
153
- {
154
- IECore::FloatVectorDataPtr newData = new IECore::FloatVectorData ();
155
- newData->writable ().resize ( len, static_cast < const IECore::FloatData * >( primitiveVariable.data .get () )->readable () );
156
- return newData;
157
- }
158
- break ;
159
- case IECore::V2fDataTypeId:
160
- {
161
- IECore::V2fVectorDataPtr newData = new IECore::V2fVectorData ();
162
- newData->writable ().resize ( len, static_cast < const IECore::V2fData * >( primitiveVariable.data .get () )->readable () );
163
- return newData;
164
- }
165
- break ;
166
- case IECore::V3fDataTypeId:
167
- {
168
- IECore::V3fVectorDataPtr newData = new IECore::V3fVectorData ();
169
- newData->writable ().resize ( len, static_cast < const IECore::V3fData * >( primitiveVariable.data .get () )->readable () );
170
- return newData;
171
- }
172
- break ;
173
- case IECore::Color3fDataTypeId:
174
- {
175
- IECore::Color3fVectorDataPtr newData = new IECore::Color3fVectorData ();
176
- newData->writable ().resize ( len, static_cast < const IECore::Color3fData * >( primitiveVariable.data .get () )->readable () );
177
- return newData;
178
- }
179
- break ;
180
- case IECore::StringDataTypeId:
181
- {
182
- IECore::StringVectorDataPtr newData = new IECore::StringVectorData ();
183
- newData->writable ().resize ( len, static_cast < const IECore::StringData * >( primitiveVariable.data .get () )->readable () );
184
- return newData;
185
- }
186
- break ;
187
- default :
188
- return nullptr ;
148
+ using VectorT = IECore::GeometricTypedData< std::vector< T > >;
149
+ typename VectorT::Ptr newData = new VectorT ();
150
+ newData->writable ().resize ( m_len, static_cast < const IECore::GeometricTypedData< T > * >( data )->readable () );
151
+ return newData;
189
152
}
190
- }
153
+
154
+ template < typename T >
155
+ IECore::DataPtr operator ()( const IECore::TypedData< T > *data, typename std::enable_if< IsVectorTypedDataDefined< T >::value >::type *enabler = nullptr ) const
156
+ {
157
+ using VectorT = IECore::TypedData< std::vector< T > >;
158
+ typename VectorT::Ptr newData = new VectorT ();
159
+ newData->writable ().resize ( m_len, static_cast < const IECore::TypedData< T > * >( data )->readable () );
160
+ return newData;
161
+ }
162
+
163
+ IECore::DataPtr operator ()( const IECore::Data *data ) const
164
+ {
165
+ return nullptr ;
166
+ }
167
+
168
+ private:
169
+
170
+ size_t m_len;
171
+ };
191
172
192
173
// / template to dispatch only primvars which are supported by the SplitTask
193
174
// / Numeric & string like arrays, which contain elements which can be added to a std::set
0 commit comments