[vtkusers] Problem with probing unstructured grid
Sergey Ryadno
sergey.ryadno at gmail.com
Fri Feb 17 07:05:07 EST 2012
Hi,
i am trying to probe my unstructured grid with vtkProbeFilter, but i don`t
see any result.
// - At first step i create the unstructured grid:
VTK_CREATE(vtkPoints, points);
VTK_CREATE(vtkUnstructuredGrid, ngrid);
VTK_CREATE(vtkIdList, idList);
VTK_CREATE(vtkMergeCells, merger);
unstrGrid = vtkSmartPointer<vtkUnstructuredGrid>::New();
merger->SetTotalNumberOfCells(size_x*size_y);
merger->SetTotalNumberOfPoints(size_x*size_y*8);
merger->SetTotalNumberOfDataSets(1);
merger->SetUnstructuredGrid(unstrGrid);
points->Allocate(size_x*size_y*8);
int p_index = 0;
for(int iy = 0; iy < size_y; iy++ )
{
for(int ix = 0; ix < size_x; ix++ )
{
for(int i = 0; i < 8; i++)
points->InsertNextPoint(Points[i].x,
Points[i].y,
Points[i].z);
ngrid->SetPoints(points);
idList->Reset();
idList->InsertNextId(p_index++);
idList->InsertNextId(p_index++);
idList->InsertNextId(p_index++);
idList->InsertNextId(p_index++);
idList->InsertNextId(p_index++);
idList->InsertNextId(p_index++);
idList->InsertNextId(p_index++);
idList->InsertNextId(p_index++);
ngrid->InsertNextCell(VTK_HEXAHEDRON , idList);
}
}
merger->MergeDataSet(ngrid);
merger->Finish();
//- second, set scalars to each cell:
VTK_CREATE(vtkFloatArray, props);
for(int iy = 0; iy < size_y; iy++ )
{
for(int ix = 0; ix < size_x; ix++ )
{
props->InsertNextValue(attributes[ix][iy]);
}
}
unstrGrid->GetCellData()->SetScalars(props);
//and show grid
actor = vtkSmartPointer<vtkActor>::New();
VTK_CREATE(vtkGeometryFilter, geometryFilter);
geometryFilter->SetInput(unstrGrid);
VTK_CREATE(vtkPolyDataMapper, mapper);
mapper->SetInputConnection(geometryFilter->GetOutputPort());
actor->SetMapper(mapper);
actor ->GetProperty()->SetEdgeColor(0.0,0.0,0);
actor ->GetProperty()->SetEdgeVisibility(1);
renderer->AddActor(actor)
.......
//in result i have grid like on pic1.png.
//after that i try to probe this grid with vtkPlaneSource
PlaneSource = vtkSmartPointer<vtkPlaneSource>::New();
PlaneSource->SetOrigin(p1.x, p1.y, Top);
PlaneSource->SetPoint1(p1.x,p1.y, Bottom);
PlaneSource->SetPoint2(p2.x, p2.y, Top);
PlaneSource->Update();
Plane = PlaneSource->GetOutput();
PolyDataMapper= vtkSmartPointer<vtkPolyDataMapper>::New();
PolyDataMapper->SetInput(Plane);
planeActor = vtkSmartPointer<vtkActor>::New();
plane Actor->SetMapper(PolyDataMapper);
planeActor->GetProperty()->SetColor(0.4, 0.4, 0.3);
planeActor->GetProperty()->SetOpacity(0.8);
planeActor->SetVisibility(0);
renderer->AddActor( planeActor )
//this plane shown on pic2.png.
// create probeFilter
probeActor = vtkSmartPointer<vtkActor>::New();
VTK_CREATE(vtkProbeFilter, probeFilter);
probeFilter->SetSource(unstrGrid);
probeFilter->SetInput( PlaneSource->GetOutput());
probeFilter->Update();
VTK_CREATE(vtkDataSetMapper, probeMapper);
probeMapper->SetInputConnection(probeFilter->GetOutputPort());
probeMapper->SetScalarRange(probeFilter->GetOutput()->GetScalarRange());
probeActor->SetMapper(probeMapper);
probeActor->GetProperty()->SetEdgeVisibility(0);
renderer->AddActor( probeActor )
//after that i hide all actors except probeActor and in result i have an
empty plane on screen without anything on it. What i am doing wrong? I will
be grateful for any help, suggestion or code example about this theme.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120217/201355aa/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pic1.png
Type: image/png
Size: 36295 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120217/201355aa/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pic2.png
Type: image/png
Size: 35982 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120217/201355aa/attachment-0001.png>
More information about the vtkusers
mailing list