[vtkusers] How to use vtkClipDataSet and preserve Arrays
Fernando Nellmeldin
f.nellmeldin at open-engineering.com
Wed Nov 4 05:10:35 EST 2015
Hello everyone. I'm new with VTK and I'm working on a visualization
interface. I need some help.
Input: I have a vtkUnstructuredGrid with one Point Array Data called
"Displacements"
Point 1: I would like to clip this ugrid with a Plane. Then, display the
resulting clipped data.
Point 2: On the other hand, as the array is a 3d vector array that
represents displacement, I want to display the mesh warped into the
direction of the vectors (the points moved and the mesh deformed).
I can do both Point 1 and Point 2 on separate cases, but when I try to
combine them, after Point 1, the array disappear from the output grid of
vtkClipDataSet.
My objective is to see the clipped data displaced.
I attach an image on Paraview of what I would like to have (more or less).
I'm using VTK 5.10 under Windows 8.1 (64 bits).
Thank you!.
PS:
Here is the relevant part of code.
/* omitted code that reads the model */
vtkSmartPointer<vtkUnstructuredGrid> model = reader->GetOutput();
// this shows that model has one point data array called "Displacements"
model->Print(std::cout);
// Plane to cut it
vtkSmartPointer<vtkPlane> plane = vtkSmartPointer<vtkPlane>::New();
plane->SetOrigin(0.0,0.0,0.0); plane->SetNormal(1,0,0);
// Clip data
vtkSmartPointer<vtkClipDataSet> clipDataSet =
vtkSmartPointer<vtkClipDataSet>::New();
clipDataSet->SetClipFunction(plane);
clipDataSet->SetInputConnection(model->GetProducerPort());
clipDataSet->InsideOutOn();
clipDataSet->GenerateClippedOutputOn();
//PROBLEM HERE. The print shows that there aren't any arrays on the output
data
clipDataSet->GetOutput()->Print(std::cout);
// Warp the data.
vtkSmartPointer<vtkWarpVector> warpingVector =
vtkSmartPointer<vtkWarpVector>::New();
warpingVector->SetInput(clipDataSet->GetOutput());
warpingVector->Update();
// Filter the data because vtkFeatureEdges needs polydata as input
vtkSmartPointer<vtkGeometryFilter> outGeometryFilter =
vtkSmartPointer<vtkGeometryFilter>::New();
outGeometryFilter->SetInput(warpingVector->GetOutput());
//Create a filter to only draw the boundaries of the displaced mesh
vtkSmartPointer<vtkFeatureEdges> drawOnlyBoundaries =
vtkSmartPointer<vtkFeatureEdges>::New();
drawOnlyBoundaries->SetInputConnection(outGeometryFilter->GetOutputPort());
// configuration of drawOnlyBoundaries, it is not important
drawOnlyBoundaries->BoundaryEdgesOn();
drawOnlyBoundaries->ManifoldEdgesOff();
drawOnlyBoundaries->NonManifoldEdgesOff(); drawOnlyBoundaries->Update();
/* Here I omitted the code to display the mesh using
clipDataSet->GetOutputPort() as input*/
/* Also, the code to configure the mapper and actor using
drawOnlyBoundaries as input */
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151104/08a07532/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clipped_displaced_data.png
Type: image/png
Size: 43124 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151104/08a07532/attachment-0001.png>
More information about the vtkusers
mailing list