[vtkusers] vtk pipeline problem
Johnson
jgadel2 at uic.edu
Thu Jun 27 20:27:39 EDT 2013
Hi
This is the current pipeline, the actors doesn't appear in the render
window
vtkSmartPointer<vtkImageThreshold>threshold=vtkSmartPointer<vtkImageThreshold>::New();;
threshold->SetOutValue(0);
threshold->SetInput(brain3D);
threshold->ReleaseDataFlagOn();
vtkSmartPointer<vtkImageToStructuredPoints> imgToStrPnts = vtkSmartPointer<vtkImageToStructuredPoints>::New();
imgToStrPnts->SetInputConnection(threshold->GetOutputPort());
imgToStrPnts->ReleaseDataFlagOn();
// create an isosurface, note that vtkMarchingCubes is better than
// vtkContourFilter
vtkSmartPointer<vtkMarchingCubes> mcubes = vtkSmartPointer<vtkMarchingCubes>::New();
mcubes->SetInputConnection(imgToStrPnts->GetOutputPort());
mcubes->ComputeNormalsOff();
mcubes->ComputeGradientsOff();
mcubes->ComputeScalarsOff();
mcubes->ReleaseDataFlagOn();
// try to reduce the number of triangles
vtkSmartPointer<vtkDecimatePro> decimator = vtkSmartPointer<vtkDecimatePro>::New();
decimator->SetInputConnection(mcubes->GetOutputPort());
decimator->SetFeatureAngle(60);
decimator->SetMaximumError(1);
decimator->SplittingOff();
decimator->PreserveTopologyOn();
decimator->SetTargetReduction(0.5);
decimator->ReleaseDataFlagOn();
// smooth the result of the iso vtkMarchingCubes
vtkSmartPointer<vtkWindowedSincPolyDataFilter> smoother = vtkSmartPointer<vtkWindowedSincPolyDataFilter>::New();
smoother->SetInputConnection(decimator->GetOutputPort());
smoother->SetNumberOfIterations(10);
smoother->BoundarySmoothingOff();
smoother->FeatureEdgeSmoothingOff();
smoother->SetPassBand(0.1);
smoother->ReleaseDataFlagOn();
// compute normals and point normals
vtkSmartPointer<vtkPolyDataNormals> normals = vtkSmartPointer<vtkPolyDataNormals>::New();
normals->SetInputConnection(smoother->GetOutputPort());
normals->ComputePointNormalsOn();
normals->SetFeatureAngle(60);
normals->SetSplitting(true);
normals->ReleaseDataFlagOn();
// stripper: create triangle out of polygons
vtkSmartPointer<vtkStripper> stripper = vtkSmartPointer< vtkStripper >::New();
stripper->SetInputConnection(normals->GetOutputPort());
stripper->GetOutput()->ReleaseDataFlagOn();
// map smoothed data
vtkSmartPointer<vtkPolyDataMapper> isoMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
isoMapper->SetInputConnection(stripper->GetOutputPort());
isoMapper->ImmediateModeRenderingOn();
isoMapper->ScalarVisibilityOff(); // utilize actor's property I set
// render isosurfaces
for (uint i = 0;i <2;i++) { //lblValues.n_elem
progress.setValue(i);
qDebug()<<"processing "<<i;
// update the threshold according to the new label
threshold->ThresholdBetween(lblValues(i),lblValues(i));
mcubes->SetValue(0,lblValues(i));
// create actor
vtkSmartPointer<vtkActor> isoActor = vtkSmartPointer<vtkActor>::New();
isoActor->SetMapper(isoMapper);
isoMapper->Update();
QColor c = ctable.at(lblValues(i));
isoActor->GetProperty()->SetColor(c.red()/255.0,c.green()/255.0,c.blue()/255.0);
lblsActors.append(isoActor);
MainRenderer->AddActor(isoActor);
vtkWidget->GetRenderWindow()->Render();
}
Thanks
Johnson
On 6/27/2013 5:25 PM, Shawn Waldon wrote:
> Unfortunately that is as much as I know. I found it a few weeks ago
> here:
> http://www.vtk.org/Wiki/VTK/FAQ#Using_ReleaseDataFlag
>
> You should not need to clear the input with NULL as far as I know, but
> keep in mind that the filter is set to delete its output, not its
> input. So you would need to set the flag on the filter that is
> creating the brain3D in order to have the brain3D output data deleted.
>
> If you are declaring the same pipeline each time through the loop, you
> may be able to set up the pipeline initially and have the loop only
> feed it different input data each time, modify parameters on filters
> (remember to call Update()) and do something with the output.
> However, depending on what you are doing with the resulting data you
> may need to copy the output if using this approach.
>
> Shawn
>
>
> On Thu, Jun 27, 2013 at 6:05 PM, johnsonjonaris <jgadel2 at uic.edu
> <mailto:jgadel2 at uic.edu>> wrote:
>
> HI
> Thanks Shawn for your reply, that was quick.
> I tried to do as you suggested with no luck :(
> for example, I did the following for the vtkImageThreshold filter:
>
> threshold = vtkSmartPointer<vtkImageThreshold>::New();
> threshold->ThresholdBetween(lblValues(i),lblValues(i)); // lblValues
> is a vector of the labels
> threshold->SetOutValue(0);
> threshold->SetInput(brain3D);
> threshold->ReleaseDataFlagOn();
>
> Note that every time in the loop I declare the pipeline elements
> with New()
> Also, at the end of the loop I need to clear the input with NULL
> in order to
> clean the memory.
> Any suggestions ?
> Regards
>
>
>
>
> -----
> Johnson Jonaris
> PhD Candidate
> Electrical & Computer Eng
> University of IL at Chicago
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/vtk-pipeline-problem-tp5721639p5721642.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com <http://www.kitware.com>
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130627/81462d4b/attachment.htm>
More information about the vtkusers
mailing list