[vtkusers] vtkTemporalStreamTracer Not changing time step

Marcelino Rodriguez Cancio marcelinorc at uclv.edu.cu
Wed Nov 2 15:16:07 EDT 2011


Hi everybody,

I'm trying to visualize blood flow using vtkTemporalStreamTracer + vtkTemporalPathLineFilter.

The problem seems to be that the particle tracer (vtkTemporalStreamTracer) does not change the time step more than once. I mean, when I first run the pipeline, steps 0 and 1 are requested to the time aware source as supposed to. Also, if I do:

tracer->SetTimeStep(5)

time steps 5 and 6 are requested as expected but only at the first run. When I change the time step, source's RequestData method is not called at all.

To change the time step I have a widget. In the EndInteraction I tried:
    vtkStreamingDemandDrivenPipeline *sdd =
      vtkStreamingDemandDrivenPipeline::SafeDownCast(Tracer->GetExecutive());
    double times[1];
    times[0] = Slider->GetValue();
    sdd->SetUpdateTimeSteps(0, times, 1);
    Tracer->Modified();
    RenderWindow->Render();

Also tried (with tracer->IgnorePipelineTimeOn()):
    int step = vtkMath::Round(Slider->GetValue());
    Tracer->SetTimeStep(step);
    Tracer->Modified();
    RenderWindow->Render();


But nothing.


The time aware source is a filter inherited from vtkImageAlgorithm written by me. It seems to work quite well. Nevertheless, I'll copy here the RequestData and RequestInformation methods:

int vtkAF4DTemporalSerieVectorImageSource::RequestInformation(
  vtkInformation* request,
  vtkInformationVector** inputVector,
  vtkInformationVector* outputVector)
{
  //
  if (!this->Superclass::RequestInformation(request,
    inputVector, outputVector)) {
    return 0;
  }

  vtkInformation* outInfo = outputVector->GetInformationObject(0);

  //Check that te minimum time step is not bigger than the maximum
  if ( TimeStepRange[0] > TimeStepRange[1] ) {
    int tmp = TimeStepRange[1];
    TimeStepRange[1] = TimeStepRange[0];
    TimeStepRange[0] = tmp;
  }

  //The series images are discrete, so we must establish the TimeStepsValues
  TimeStepValues.resize(TimeStepRange[1] - TimeStepRange[0] + 1);
  for (int i = 0; i <= TimeStepRange[1]; ++i ) {
    TimeStepValues[i] = i;
  }
  outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
    &TimeStepValues[0], static_cast<int>(TimeStepValues.size()));

  //Not continuous data so this key is not set
  /*
  double timeRange[2];
  timeRange[0] = TimeStepValues.front();
  timeRange[1] = TimeStepValues.back();
  outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(),
    timeRange, 2);
  */
  outInfo->Set(vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES(),
    TimeStepRange[1]);

  return 1;
}

//----------------------------------------------------------------------------

int vtkAF4DTemporalSerieVectorImageSource::RequestData(
  vtkInformation* request,
  vtkInformationVector** inputVector,
  vtkInformationVector* outputVector)
{
  try {
    if(!SeriesPath)
      throw vtkstd::runtime_error("SeriesPath not set.");

    vtkInformation *info=outputVector->GetInformationObject(0);

    // get how many time steps were requested
    int numTimeSteps =
      info->Length(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS());
    //Get the time steps requested
    double *timeSteps =
      info->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS());

    /*
    vtkDataObject *doOutput=info->Get(vtkDataObject::DATA_OBJECT());
    vtkTemporalDataSet *output = vtkTemporalDataSet::SafeDownCast(doOutput);
    */
    vtkImageData *output = vtkImageData::SafeDownCast(
      info->Get(vtkDataObject::DATA_OBJECT()));

    if ( output == 0 ) {
      vtkErrorMacro("The output is not a vtkImageData");
      return 0;
    }

    if (!info->Has(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) ||
        !info->Has(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES())) {
      vtkErrorMacro("Expected information not found. "
                    "Cannot provide update extent.");
      return 0;
    }

    int ts;

    //HERE IS WHERE ACTUAL DATA IS BUILT.
    BuildTimeStep(output, timeSteps[ts]);

    output->GetInformation()->Set(vtkDataObject::DATA_TIME_STEPS(),
      timeSteps, numTimeSteps);

    return 1;
  }
  catch(vtkstd::exception& e) {
    vtkErrorMacro(<< e.what());
  }
  return 0;
}




Follows my pipeline:

  // we have to use a composite pipeline
  vtkCompositeDataPipeline* prototype = vtkCompositeDataPipeline::New();
  vtkAlgorithm::SetDefaultExecutivePrototype(prototype);
  prototype->Delete();


  // This is the time aware source.
  VTK_CREATE(vtkAF4DTemporalSerieVectorImageSource, source);
  source->SetSeriesPath("d:/data/studies/frances");
  source->SetMaskFileName("d:/data/vtks/francesmask.vtk");
  source->SetTimeStepRange(0, 13);

  // The temporal data set cache is set to hold just 2
  // data objects (steps) as described in the article by John Bidiscombe et. al.
  //"Time Dependent Processing in a Parallel Pipeline Architecture"
  VTK_CREATE(vtkTemporalDataSetCache, cache);
  cache->SetInputConnection(source->GetOutputPort());
  cache->SetCacheSize(2);

  // This is the source for the particle tracer
  VTK_CREATE(vtkPlaneSource, rake);
  rake->SetOrigin(0, 0, 0);
  rake->SetPoint1(50, 0, 0);
  rake->SetPoint2(0, 50, 0);
  rake->SetCenter(155.445, 31.9245, 203.15);
  rake->SetNormal(0.0, 0.6, 0.0);
  rake->SetResolution(150, 150);

  // The tracer
  VTK_CREATE(vtkTemporalStreamTracer, tracer);
  tracer->SetInputConnection(aa->GetOutputPort());
  tracer->SetSource(rake->GetOutput());
  tracer->SetIntegrationDirectionToForward();
  tracer->SetTerminationTimeUnitToStepUnit();
  tracer->StaticSeedsOn();
  tracer->StaticMeshOn();
  tracer->SetIntegratorTypeToRungeKutta4();
  //tracer->IgnorePipelineTimeOn();
  tracer->SetForceReinjectionEveryNSteps(1);
  //tracer->SetTimeStep(5);

  // This is the path line not working as expected,
  // I get no trails
  VTK_CREATE(vtkTemporalPathLineFilter, pathline);
  pathline->SetInputConnection(tracer->GetOutputPort());
  pathline->UsePointIndexForIdsOn();
  pathline->SetKeepDeadTrails(1);

  VTK_CREATE(vtkPolyDataMapper, pathMapper);
  pathMapper->SetInputConnection(pathline->GetOutputPort());
  pathMapper->SetLookupTable(lut);
  pathMapper->SetScalarRange(-150, 150);

  VTK_CREATE(vtkActor, pathActor);
  pathActor ->SetMapper(pathMapper);
  pathActor ->VisibilityOn();

I've read the "Time Dependent Processing in a Parallel Pipeline Architecture" from Jhon Bidiscombe et. al., analyzed the examples and unit tests as well as other resources but nothing yet. Any help will be highly appreciated.

Thanks a lot
Marcelino Rodriguez


________________________________
-Universidad Central "Marta Abreu" de Las Villas. http://www.uclv.edu.cu
-Participe en Universidad 2012, del 13 al 17 de febrero de 2012. Habana.Cuba. http://www.congresouniversidad.cu
-Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu/


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111102/66b5374f/attachment.htm>


More information about the vtkusers mailing list