[vtkusers] How to manage two pipelines for a single filter?

rakesh patil prakeshofficial at gmail.com
Tue Sep 20 06:38:28 EDT 2011


Hello,

I am using the following pipline to displays points

pnts = vtkPoints::New();
pnts->SetNumberOfPoints(num);

scalar = vtkDoubleArray::New();
scalar->SetNumberOfTuples(num);

pVertex = vtkCellArray::New();

for (vtkIdType i = 0; i < num; i++)
{
   readFile >> xval >> yval >> zval;
   pnts->InsertPoint(i, xval, yval, 0);
   scalar->InsertTuple1(i, zval);

   pVertex->InsertNextCell(1, &i);
}

vtkPolyData *pd = vtkPolyData::New();
pd->SetPoints(pnts);
pd->SetVerts(pVertex);
pd->GetPointData()->SetScalars(scalar);

vtkSmartPointer<vtkTransform> translation =
    vtkSmartPointer<vtkTransform>::New();
  translation->Translate(1.0, 0.0, 0.0);

   transformFilter = vtkTransformPolyDataFilter::New();
  transformFilter->SetInput(pd->GetOutput());
  transformFilter->SetTransform(translation);
  transformFilter->Update();

vtkPolyDataMapper *mapp = vtkPolyDataMapper::New();
mapp->SetInputConnection( del->GetOutputPort() );
mapp->ScalarVisibilityOn();


actor = vtkActor::New();
actor->SetMapper(mapp);
actor->GetProperty()->SetColor(1, 0, 0);
actor->GetProperty()->SetPointSize(3);

renderer->AddActor(actor);

Here actor, pnts, scalar, pVertex and transformFilter are declared in
private section of a class. There is a member function of the class to
triangulate these points.

void TriangulatePoints()
{
   vtkSmartPointer<vtkPolyData> pd = vtkSmartPointer<vtkPolyData>::New();
   pd->SetPoints(pnts);
   pd->SetVerts(pVertex);
  pd->GetPointData()->SetScalars(scalar);

  vtkSmartPointer<vtkDelaunay2d> del = vtkSmartPointer<vtkDelaunay2D>::New();
  del->SetInput(pd);
  del->SetTolerance(0.00001);
  del->ReleaseDataFlagOn();
  del->Update();

  triangulatedMesh = vtkPolyData::New();
  triangulatedMesh->DeepCopy(del->GetOutput());

  transformFilter->SetInput(triangulatedMesh);
  transformFilter->Modified();
}


When I execute this function what exactly is happening to the previous
pipeline? First it is


vtkPoints          vtkDoubleArray         vtkCellArray
      |                           |                            |
      ----------------------------------------------------------
                                  |
                           vtkPolyData
                                  |
                 vtkTransformPolyDataFilter
                                  |
                     vtkPolyDataMapper
                                  |
                             vtkActor

After triangulation, the input for vtkTransformPolyDataFilter changes

vtkPoints          vtkDoubleArray         vtkCellArray
      |                           |                            |
      ----------------------------------------------------------
                                  |
                           vtkPolyData
                                  |
                         vtkDelaunay2D
                                  |
 //=================================================//
 // Pipeline is broken here, as the output is deep copied and
//
 // delaunays release data flag is on. Please correct me if I am wrong  //
 //=================================================//
                                  |
                         vtkPolyData
                                  |
                 vtkTransformPolyDataFilter
                                  |
// This is already connected to actor through polydata mapper
                                  |
                     vtkPolyDataMapper
                                  |
                             vtkActor

The question is after executing triangulation function, which input will be
going to transformFilter object? Will be previous pipeline exist after
triangulation? or it is destroyed and new pipeline is generated? If the
previous one is destroyed then is there way to handle two pipelines
simultaneously for a single transformFilter object?

Thanks

Regards
Rakesh Patil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110920/18a5c4bb/attachment.htm>


More information about the vtkusers mailing list