[vtkusers] How to set opacity of a certain color to 0?
Magnus Elden
magnus_elden at hotmail.com
Sun Jul 24 00:36:46 EDT 2016
I am cutting a volume using vtkCutter and I want to remove everything that
is black or close to black. Normally this would be done using a transfer
function, but I can not seem to find where to put it.
This is the flow of my program(shortened):
vtkPiecewiseFunction *opacityFun = vtkPiecewiseFunction::New();
vtkDataSet *dataSet;
vtkSmartPointer<vtkXMLImageDataReader> reader =
vtkSmartPointer<vtkXMLImageDataReader>::New();
dataSet = vtkDataSet::SafeDownCast(reader->GetOutput());
reader->GetOutput()->GetBounds(bounds);
vtkSmartPointer<vtkPlane> plane =
vtkSmartPointer<vtkPlane>::New();
// Create cutter
double high = plane->EvaluateFunction((bounds[1] + bounds[0]) / 2.0,
(bounds[3] + bounds[2]) / 2.0,
bounds[5]);
vtkSmartPointer<vtkCutter> cutter =
vtkSmartPointer<vtkCutter>::New();
cutter->SetInputConnection(reader->GetOutputPort());
cutter->SetCutFunction(plane);
cutter->GenerateValues(
numberOfCuts,
0.9,
0.9*high);
vtkSmartPointer<vtkPolyDataMapper> cutterMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
cutterMapper->SetInputConnection(cutter->GetOutputPort());
// Create cut actor
vtkSmartPointer<vtkActor> cutterActor =
vtkSmartPointer<vtkActor>::New();
cutterActor->GetProperty()->SetLineWidth(2);
cutterActor->SetMapper(cutterMapper);
// Create renderers and add actors of plane and model
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
renderer->AddActor(cutterActor);
//Code to render and interact with the cuts.
Where in this code do I apply the transfer function? Do I use a lookup
table? For now I want all colours to have opacity of 1 except for black that
should have opacity = 0. How can this be done? I am using C++ and none of
the examples seem to fit with the flow of my program. They either work only
on volumes, which my poly data cut is not, or the function they use does not
exist in any of the classes I am using. I tried setting a lookuptable with
opacity ranges, I tried using a vtkPiecewiseFunction, but nothing seems to
work.
Thank you for your help.
Yours,
Magnus Elden
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160724/2b2b0d63/attachment.html>
More information about the vtkusers
mailing list