117 if (this->
TimeStepsTable->GetNumberOfColumns() < 2 || numberOfRows == 1)
121 int previousRowIndex = this->
TimeStepsTable->GetValue(0,0).ToInt();
122 double previousRowTime = this->
TimeStepsTable->GetValue(0,1).ToDouble();
123 if (numberOfRows < 2 || previousRowTime == time)
128 double shiftedTime = time;
130 double period = this->
TimeStepsTable->GetValue(numberOfRows-1,1).ToDouble() - previousRowTime;
134 double ratio = (time - previousRowTime) / period;
135 shiftedTime = (ratio - floor(ratio)) * period + previousRowTime;
140 for (
int i=1; i<numberOfRows; i++)
148 double rowTime = this->
TimeStepsTable->GetValue(rowId,1).ToDouble();
149 if (shiftedTime > previousRowTime && shiftedTime <= rowTime)
153 p = (shiftedTime - previousRowTime) / (rowTime - previousRowTime);
158 previousRowIndex = rowIndex;
159 previousRowTime = rowTime;
166 prevRowId = numberOfRows - 2;
167 nextRowId = numberOfRows - 2;
179 int i, j, subId , numPts, id;
180 vtkDataArray * vectorsPrev = NULL;
181 vtkDataArray * vectorsNext = NULL;
182 vtkDataArray * component0Prev = NULL;
183 vtkDataArray * component0Next = NULL;
184 vtkDataArray * component1Prev = NULL;
185 vtkDataArray * component1Next = NULL;
186 vtkDataArray * component2Prev = NULL;
187 vtkDataArray * component2Next = NULL;
188 double vecPrev[3], vecNext[3];
191 char arrayName[1024];
193 f[0] = f[1] = f[2] = 0.0;
198 vtkErrorMacro( <<
"Can't evaluate dataset!" );
204 int prevRowId, nextRowId;
208 int prevTimeIndex = this->
TimeStepsTable->GetValue(prevRowId,0).ToInt();
209 int nextTimeIndex = this->
TimeStepsTable->GetValue(nextRowId,0).ToInt();
214 component0Prev = dataset->GetPointData()->GetArray(arrayName);
216 component1Prev = dataset->GetPointData()->GetArray(arrayName);
218 component2Prev = dataset->GetPointData()->GetArray(arrayName);
220 if (!component0Prev || !component1Prev || !component2Prev)
222 vtkErrorMacro(<<
"Component array not found for index "<<prevTimeIndex);
227 component0Next = dataset->GetPointData()->GetArray(arrayName);
229 component1Next = dataset->GetPointData()->GetArray(arrayName);
231 component2Next = dataset->GetPointData()->GetArray(arrayName);
233 if (timeP > 0.0 && (!component0Next || !component1Next || !component2Next))
235 vtkErrorMacro(<<
"Component array not found for index "<<nextTimeIndex);
242 vectorsPrev = dataset->GetPointData()->GetArray(arrayName);
244 if (timeP > 0.0 && !vectorsPrev)
246 vtkErrorMacro(<<
"Vector array not found for index "<<prevTimeIndex);
251 vectorsNext = dataset->GetPointData()->GetArray(arrayName);
255 vtkErrorMacro(<<
"Vector array not found for index "<<nextTimeIndex);
260 double tol2 = dataset->GetLength() *
261 vtkAbstractInterpolatedVelocityField::TOLERANCE_SCALE;
263#if VMTK_VTK_HAS_REWORKED_IVF
264 if (this->Weights.size() <
static_cast<size_t>(dataset->GetMaxCellSize()))
266 this->Weights.resize(dataset->GetMaxCellSize());
268 double* weights = this->Weights.data();
269 vtkGenericCell* genCell = this->TemporalGenCell;
270 vtkGenericCell* scratchCell = this->TemporalCell;
272 double* weights = this->Weights;
273 vtkGenericCell* genCell = this->GenCell;
274 vtkGenericCell* scratchCell = this->Cell;
282 if ( this->LastCellId == -1 ||
283 !( ret = genCell->EvaluatePosition
284 ( x, 0, subId, this->LastPCoords, dist2, weights)
290 if ( this->LastCellId != - 1 )
294 dataset->GetCell( this->LastCellId, scratchCell );
297 dataset->FindCell( x, scratchCell, genCell, this->LastCellId,
298 tol2, subId, this->LastPCoords, weights );
300 if ( this->LastCellId != -1 )
302 dataset->GetCell( this->LastCellId, genCell );
319 dataset->FindCell( x, 0, genCell, -1, tol2,
320 subId, this->LastPCoords, weights );
322 if ( this->LastCellId != -1 )
324 dataset->GetCell( this->LastCellId, genCell );
333 if ( this->LastCellId >= 0 )
335 numPts = genCell->GetNumberOfPoints();
338 for ( j = 0; j < numPts; j ++ )
340 id = genCell->PointIds->GetId( j );
343 vecPrev[0] = this->
VelocityScale * component0Prev->GetTuple1(
id);
344 vecPrev[1] = this->
VelocityScale * component1Prev->GetTuple1(
id);
345 vecPrev[2] = this->
VelocityScale * component2Prev->GetTuple1(
id);
349 vecNext[0] = this->
VelocityScale * component0Next->GetTuple1(
id);
350 vecNext[1] = this->
VelocityScale * component1Next->GetTuple1(
id);
351 vecNext[2] = this->
VelocityScale * component2Next->GetTuple1(
id);
356 vectorsPrev->GetTuple(
id, vecPrev );
357 for ( i = 0; i < 3; i ++ )
363 vectorsNext->GetTuple(
id, vecNext );
364 for ( i = 0; i < 3; i ++ )
372 for ( i = 0; i < 3; i ++ )
374 f[i] += (timeP * vecNext[i] + (1.0 - timeP) * vecPrev[i]) * weights[j];
379 for ( i = 0; i < 3; i ++ )
381 f[i] += vecPrev[i] * weights[j];
386 if ( this->NormalizeVector ==
true )
388 vtkMath::Normalize( f );