[vtkusers] Volume rendering of vtkUnstructuredGrid
jiksed
jiksed at yahoo.com
Wed Feb 23 10:31:09 EST 2005
My scalar data is the variable values at nodes of 3D irregular hexahedral cells from the
finite element modeling. I have been trying to volume-render this unstructured grid but have
had no luck so far. My questions would be
1) How do I add hexahedral cells to the vtkUnstructuredGrid?
2) According to posts in this list, vtkUnstructuredGridVolumeRayCastMapper renders
tretrahedral cells only. Is vtkDataSetTriangleFilter the right filter to convert hexahedral
cells to tretrahedral cells?
3) I got an error message like this " E2316 'SetVolumeRayCastFunction' is not a member
of 'vtkUnstructuredGridVolumeRayCastMapper". Did I miss including any header file?
According to an example IntermixedUnstructuredGrid.tcl, 'SetVolumeRayCastFunction'
is not required. Is this true?
I am using VTK4.4 and running WinXP Pro. Here is part of my code. Thank you.
----------------------------------------------------
// Points and scalars
vtkPoints *pts = vtkPoints::New();
vtkDoubleArray *scalars = vtkDoubleArray::New();
vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::New();
ugrid->Allocate(NumPoints, NumPoints);
for (i=0; i<gNumCoreElems; ++i)
{
pts->InsertNextPoint(X[i], Y[i], Z[i]);
scalars->InsertNextTuple1(V[i]);
}
ugrid->SetPoints(pts);
ugrid->GetPointData()->SetScalars(scalars);
// Cells
int nyz = ny * nz;
int IndexOffset[8] = {0, 1, nz, nz+1, nyz, nyz+1, nyz+nz, nyz+nz+1};
vtkHexahedron *hexa = vtkHexahedron::New();
n = 0;
for (i=0; i<gNumCoreElem[0]-1; ++i)
{
for (j=0; j<gNumCoreElem[1]-1; ++j)
{
for (k=0; k<gNumCoreElem[2]-1; ++k)
{
for (kk=0; kk<8; ++kk)
{
hexa->GetPointIds()->SetId(VTK_HEXAHEDRON, n+IndexOffset[kk]);
}
ugrid->InsertNextCell(hexa->GetCellType(), hexa->GetPointIds());
++n;
}
}
}
// Volume rendering
vtkUnstructuredGridVolumeRayCastMapper *volumeMapper =
vtkUnstructuredGridVolumeRayCastMapper::New();
vtkDataSetTriangleFilter *tri = vtkDataSetTriangleFilter::New();
tri->SetInput(ugrid);
volumeMapper->SetInput(tri->GetOutput());
vtkUnstructuredGridBunykRayCastFunction *compositeFunction =
vtkUnstructuredGridBunykRayCastFunction::New();
// E2316 'SetVolumeRayCastFunction' is not a member
// of 'vtkUnstructuredGridVolumeRayCastMapper'
volumeMapper->SetVolumeRayCastFunction(compositeFunction); // Error
volume->SetMapper(volumeMapper);
vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
volumeProperty->SetColor(colorFunc);
volumeProperty->SetScalarOpacity(opacityFunc);
volumeProperty->ShadeOff();
volumeProperty->SetInterpolationTypeToLinear();
volume->SetProperty(volumeProperty);
.....
---------------------------------
Do you Yahoo!?
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050223/6e34480a/attachment.htm>
More information about the vtkusers
mailing list