<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2800.1400" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial>Hi,</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>An example about displaying the cell id and point id of a
sphere is shown below. </FONT></DIV>
<DIV><FONT face=Arial>Hope it help!</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>Yixun Liu</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>//test VTK about Volume Render<BR>//#include
<STDIO.H><BR>#include "vtkRenderer.h"<BR>#include
"vtkRenderWindow.h"<BR>#include "vtkRenderWindowInteractor.h"<BR>#include
"vtkVolume16Reader.h"<BR>#include "vtkPolyDataMapper.h"<BR>#include
"vtkActor.h"<BR>#include "vtkOutlineFilter.h"<BR>#include
"vtkCamera.h"<BR>#include "vtkProperty.h"<BR>#include
"vtkPolyDataNormals.h"<BR>#include "vtkContourFilter.h"<BR>#include
"vtkPoints.h"<BR>#include "vtkCellArray.h"<BR>#include
"vtkPolyData.h"<BR>#include "vtkPolyDataMapper.h"<BR>#include
"vtkActor.h"<BR>#include "vtkUnsignedCharArray.h"<BR>#include
"vtkPointData.h"<BR>#include "vtkCellData.h"<BR>#include
"vtkTiFFReader.h"<BR>#include "vtkImageViewer.h"<BR>#include
"vtkImageFlip.h"<BR>#include "vtkStructuredPointsReader.h"<BR>#include
"vtkImageCast.h"<BR>#include "vtkVolumeRayCastMapper.h"<BR>#include
"vtkVolumeRayCastCompositeFunction.h"<BR>#include "vtkmath.h"<BR>#include
"vtkDelaunay2D.h"<BR>#include "vtkExtractEdges.h"<BR>#include
"vtkTubeFilter.h"<BR>#include "vtkSphereSource.h"<BR>#include
"vtkGlyph3D.h"<BR>#include "vtkDelaunay3D.h"<BR>#include
"vtkShrinkFilter.h"<BR>#include "vtkDataSetMapper.h"<BR>#include
"vtkUnstructuredGrid.h"<BR>#include "vtkCellTypes.h"<BR>#include
"vtkTetra.h"<BR>#include "vtkIdList.h"<BR>#include
"vtkGenericCell.h"<BR>#include "vtkMeshQuality.h"<BR>#include
"vtkPolyDataMapper2D.h"<BR>#include "vtkActor2D.h"<BR>#include
"vtkIdFilter.h"<BR>#include "vtkSelectVisiblePoints.h"<BR>#include
"vtkLabeledDataMapper.h"<BR>#include "vtkCellCenters.h"<BR>#include
"vtkTextProperty.h"</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>int main(int argc, char *argv[])<BR>{<BR>//# Create a
selection window. We will display the point and cell ids that<BR>//# lie
within this window.<BR> int xmin = 200;<BR> int xLength =
100;<BR> int xmax = xmin + xLength;</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial> int ymin = 200;<BR> int yLength =
100;<BR> int ymax = ymin + yLength;</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial> vtkPoints *pts =
vtkPoints::New();<BR> pts->InsertPoint(0, xmin, ymin,
0);<BR> pts->InsertPoint(1, xmax, ymin,
0);<BR> pts->InsertPoint(2, xmax, ymax,
0);<BR> pts->InsertPoint(3, xmin, ymax, 0);</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial> vtkCellArray *rect =
vtkCellArray::New();<BR> rect->InsertNextCell(5);<BR> rect->InsertCellPoint(0);<BR> rect->InsertCellPoint(1);<BR> rect->InsertCellPoint(2);<BR> rect->InsertCellPoint(3);<BR> rect->InsertCellPoint(0);</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial> vtkPolyData *selectRect =
vtkPolyData::New();<BR> selectRect->SetPoints(pts);<BR> selectRect->SetLines(rect);</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial> vtkPolyDataMapper2D *rectMapper =
vtkPolyDataMapper2D::New();<BR> rectMapper->SetInput(selectRect);</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial> vtkActor2D *rectActor =
vtkActor2D::New();<BR> rectActor->SetMapper(rectMapper);</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><BR><FONT face=Arial>//# Create a sphere and its associated mapper and
actor.<BR> vtkSphereSource *sphere =
vtkSphereSource::New();<BR> vtkPolyDataMapper *sphereMapper =
vtkPolyDataMapper::New();<BR> sphereMapper->SetInput(sphere->GetOutput());<BR> sphereMapper->GlobalImmediateModeRenderingOn();<BR> vtkActor
*sphereActor =
vtkActor::New();<BR> sphereActor->SetMapper(sphereMapper);</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>//# Generate data arrays containing point and cell
ids<BR> vtkIdFilter *ids =
vtkIdFilter::New();<BR> ids->SetInput(sphere->GetOutput());<BR> ids->PointIdsOn();<BR> ids->CellIdsOn();<BR> ids->FieldDataOn();</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>//# Create the renderer here because
vtkSelectVisiblePoints needs it.<BR> vtkRenderer *ren1 =
vtkRenderer::New();</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>//# Create labels for
points<BR> vtkSelectVisiblePoints *visPts =
vtkSelectVisiblePoints::New();<BR> visPts->SetInput(ids->GetOutput());<BR> visPts->SetRenderer(ren1);<BR> visPts->SelectionWindowOn();<BR> visPts->SetSelection(xmin,
xmax, ymin, ymax);</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>//# Create the mapper to display the point ids.
Specify the<BR>//# format to use for the labels. Also create the
associated actor.<BR> vtkLabeledDataMapper *ldm =
vtkLabeledDataMapper::New();<BR> ldm->SetInput(visPts->GetOutput());<BR> ldm->SetLabelFormat("%g");<BR> ldm->SetLabelModeToLabelFieldData();</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial> vtkActor2D *pointLabels =
vtkActor2D::New();<BR> pointLabels->SetMapper(ldm);</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>//# Create labels for cells<BR> vtkCellCenters *cc =
vtkCellCenters::New();<BR> cc->SetInput(ids->GetOutput());<BR> vtkSelectVisiblePoints
*visCells =
vtkSelectVisiblePoints::New();<BR> visCells->SetInput(cc->GetOutput());<BR> visCells->SetRenderer(ren1);<BR> visCells->SelectionWindowOn();<BR> visCells->SetSelection(xmin,
xmax, ymin, ymax);</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>//# Create the mapper to display the cell ids.
Specify the<BR>//# format to use for the labels. Also create the
associated actor.<BR> vtkLabeledDataMapper *cellMapper =
vtkLabeledDataMapper::New();<BR> cellMapper->SetInput(visCells->GetOutput());<BR> cellMapper->SetLabelFormat("%g");<BR> cellMapper->SetLabelModeToLabelFieldData();<BR> cellMapper->GetLabelTextProperty()->SetColor(0,
1, 0);<BR> vtkActor2D *cellLabels =
vtkActor2D::New();<BR> cellLabels->SetMapper(cellMapper);</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>//# Create the RenderWindow and
RenderWindowInteractor<BR> vtkRenderWindow *renWin =
vtkRenderWindow::New();<BR> renWin->AddRenderer(ren1);<BR> <BR> vtkRenderWindowInteractor
*iren =
vtkRenderWindowInteractor::New();<BR> iren->SetRenderWindow(renWin);</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>//# Add the actors to the renderer; set the background and
size;<BR> ren1->AddActor(sphereActor);<BR> ren1->AddActor2D(rectActor);<BR> ren1->AddActor2D(pointLabels);<BR> ren1->AddActor2D(cellLabels);</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial> ren1->SetBackground(1, 1,
1);<BR> renWin->SetSize(500,
500);<BR> <BR>// renWin->Render();<BR> iren->Initialize();<BR> iren->Start();<BR> return
0;<BR>}<BR></FONT></DIV></BODY></HTML>