先贴代码
Kitware.VTK.vtkRenderer Renderer = this.renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer();
vtkFloatArray xCoords = new vtkFloatArray();
for (int i = 0; i < 50; i++)
{
xCoords.InsertNextValue(i);
}
vtkFloatArray yCoords = new vtkFloatArray();
for (int i = 0; i < 55; i++)
{
yCoords.InsertNextValue(i);
}
vtkFloatArray zCoords = new vtkFloatArray();
for (int i = 0; i < 60; i++)
{
zCoords.InsertNextValue(i);
}
vtkRectilinearGrid Grid = new vtkRectilinearGrid();
Grid.SetDimensions(50, 55, 60);
Grid.SetXCoordinates(xCoords);
Grid.SetYCoordinates(yCoords);
Grid.SetZCoordinates(zCoords);
vtkRectilinearGridGeometryFilter Filter = new vtkRectilinearGridGeometryFilter();
Filter.SetInput(Grid);
Filter.SetExtent(0, 50, 0, 55, 0, 60);
vtkPolyDataMapper Mapper = vtkPolyDataMapper.New();
Mapper.SetInputConnection(Filter.GetOutputPort());
vtkActor Actor = new vtkActor();
Actor.SetMapper(Mapper);
Actor.GetProperty().SetColor(1, 0, 0);
vtkOutlineFilter GridOut = vtkOutlineFilter.New();
GridOut.SetInput(Grid);
vtkPolyDataMapper outMapper = vtkPolyDataMapper.New();
outMapper.SetInputConnection(GridOut.GetOutputPort());
vtkActor outActor = new vtkActor();
outActor.SetMapper(outMapper);
Renderer.AddActor(Actor);
Renderer.AddActor(outActor);
Renderer.ResetCamera();
this.renderWindowControl1.RenderWindow.Render();
网格体就做成这样了,呵呵!全是点点!
