[vtkusers] vtkThreshold: how to change the parameter to colour instead of remove the areas

Polly Pui polly_sukting at hotmail.com
Thu Dec 28 12:21:16 EST 2017


Hi. I am using vtkThreshold to extract the areas on vtk 3D face data.
However, it removed the important areas (areas that i am looking at) and
left with holes.
My question is how can I change the parameter on this ThresholdByLower?
I would like to replace the deleted areas which meet the criterion with
different colour instead of just remove them and leave them with holes. I have been looking
over the library and found vtkThreshold.cxx regarding the parameter of this.

However, I am not able to change the 'delete' to 'SetColor'.

// now clean up / update ourselves
  pointMap->Delete();
  newCellPts->Delete();

  output->Delete();
  newPoints->Delete();

  output->Squeeze();


Much appreciate if someone can help on this.

Image is attached:
http://vtk.1045678.n5.nabble.com/file/t341727/M_0.jpg

[http://vtk.1045678.n5.nabble.com/file/t341727/M_0.jpg]


This is my code:
vtkPolyDataReader *reader = vtkPolyDataReader::New();
reader->SetFileName(argv[1]);
reader->Update();

vtkCurvatures *meanCurve = vtkCurvatures::New();
meanCurve->SetInputConnection(reader->GetOutputPort());
meanCurve->SetCurvatureTypeToMean();
meanCurve->Update();

vtkThreshold *thresh = vtkThreshold::New();
thresh->SetInputConnection(meanCurve->GetOutputPort());
thresh->ThresholdByLower(0.085);
thresh->Update();

vtkGeometryFilter *geom = vtkGeometryFilter::New();
geom->SetInputConnection(thresh->GetOutputPort());

vtkPolyDataMapper *mapper2 = vtkPolyDataMapper::New();
mapper2->SetInputConnection(geom->GetOutputPort());
mapper2->SetLookupTable(lut);
mapper2->Update();

vtkActor *actor2 = vtkActor::New();
actor2->SetMapper(mapper2);
actor2->GetProperty()->SetColor(0.0, 0.0, 0.0);

vtkRenderer *renderer = vtkRenderer::New();
renderer->AddActor(actor2);
renderer->SetBackground(.1, .2, .3); // Background color blue

// Render and interact
vtkRenderWindow *renderWindow = vtkRenderWindow::New();
renderWindow->AddRenderer(renderer);
renderWindow->SetSize(800, 800);

vtkRenderWindowInteractor *renderWindowInteractor =
vtkRenderWindowInteractor::New();
renderWindowInteractor->SetRenderWindow(renderWindow);

renderWindow->Render();
renderWindowInteractor->Start();

Thank you very much.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20171228/0aba921f/attachment.html>


More information about the vtkusers mailing list