MCPcopy Create free account
hub / github.com/Kitware/VTK / ApplyMorphingToDataArray

Function ApplyMorphingToDataArray

IO/Geometry/vtkGLTFReader.cxx:175–207  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

173
174//------------------------------------------------------------------------------
175vtkSmartPointer<vtkDataArray> ApplyMorphingToDataArray(vtkSmartPointer<vtkDataArray> origin,
176 const std::vector<float>& weights, const std::vector<vtkSmartPointer<vtkFloatArray>>& targets)
177{
178 if (origin == nullptr)
179 {
180 return nullptr;
181 }
182
183 vtkSmartPointer<vtkDataArray> result = vtkSmartPointer<vtkDataArray>::Take(origin->NewInstance());
184 result->DeepCopy(origin);
185
186 if (targets.empty() || weights.empty() || targets.size() != weights.size())
187 {
188 return origin;
189 }
190 std::vector<double> tuple(origin->GetNumberOfComponents(), 0);
191 for (int tupleId = 0; tupleId < origin->GetNumberOfTuples(); tupleId++)
192 {
193 origin->GetTuple(tupleId, tuple.data());
194 for (unsigned int targetId = 0; targetId < targets.size(); targetId++)
195 {
196 for (int component = 0; component < targets[targetId]->GetNumberOfComponents(); component++)
197 {
198 // Morphing:
199 // P the resulting tuple, P0 the primitive's tuple, wi the weights, Ti the targets' tuples:
200 // P = P0 + sum(wi * Ti)
201 tuple[component] += weights[targetId] * targets[targetId]->GetTuple(tupleId)[component];
202 }
203 }
204 result->SetTuple(tupleId, tuple.data());
205 }
206 return result;
207}
208
209//------------------------------------------------------------------------------
210void SetupWeightedTransformFilterForGLTFSkinning(vtkSmartPointer<vtkWeightedTransformFilter> filter,

Callers 1

ApplyMorphingToPolyDataFunction · 0.85

Calls 10

TakeFunction · 0.85
NewInstanceMethod · 0.45
DeepCopyMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
GetNumberOfComponentsMethod · 0.45
GetNumberOfTuplesMethod · 0.45
GetTupleMethod · 0.45
dataMethod · 0.45
SetTupleMethod · 0.45

Tested by

no test coverage detected