level 1
年轮王小嵩
楼主
vtkRenderer ren = new vtkRenderer();
vtkRenderWindow win = this.vtkFormsWindowControl1.GetRenderWindow();
vtkPoints point = new vtkPoints();
vtkCellArray cell = new vtkCellArray();
point.InsertNextPoint(0, 0, 0);
point.InsertNextPoint(0, 100, 0);
point.InsertNextPoint(100, 100, 0);
point.InsertNextPoint(100, 0, 0);
point.InsertNextPoint(0, 0, 30);
point.InsertNextPoint(0, 100, 30);
point.InsertNextPoint(100, 100, 30);
point.InsertNextPoint(100, 0, 30);
cell.InsertCellPoint(4);
cell.InsertNextCell(0);
cell.InsertNextCell(1);
cell.InsertNextCell(2);
cell.InsertNextCell(3);
cell.InsertCellPoint(4);
cell.InsertNextCell(4);
cell.InsertNextCell(5);
cell.InsertNextCell(6);
cell.InsertNextCell(7);
cell.InsertCellPoint(4);
cell.InsertNextCell(0);
cell.InsertNextCell(1);
cell.InsertNextCell(5);
cell.InsertNextCell(4);
cell.InsertCellPoint(4);
cell.InsertNextCell(1);
cell.InsertNextCell(2);
cell.InsertNextCell(6);
cell.InsertNextCell(5);
cell.InsertCellPoint(4);
cell.InsertNextCell(2);
cell.InsertNextCell(3);
cell.InsertNextCell(7);
cell.InsertNextCell(6);
cell.InsertCellPoint(4);
cell.InsertNextCell(3);
cell.InsertNextCell(0);
cell.InsertNextCell(4);
cell.InsertNextCell(7);
vtkPolyData polydata = new vtkPolyData();
polydata.SetPoints(point);
polydata.SetPolys(cell);
vtkActor actor = new vtkActor();
vtkPolyDataNormals normal = new vtkPolyDataNormals();
normal.SetInput(polydata);
vtkTextureMapToCylinder tmapper = new vtkTextureMapToCylinder();
tmapper.SetInput(normal.GetOutput());
tmapper.PreventSeamOn();
vtkTransformTextureCoords transform_texture = new vtkTransformTextureCoords();
transform_texture.SetInput(tmapper.GetOutput());
vtkDataSetMapper data_mapper = new vtkDataSetMapper();
data_mapper.SetInput(transform_texture.GetOutput());
vtkJPEGReader reader = new vtkJPEGReader();
reader.SetFileName("E:\\地层\\8.jpg");
vtkTexture texture = new vtkTexture();
texture.SetInputConnection(reader.GetOutputPort());
texture.InterpolateOn();
actor.SetTexture(texture);
actor.SetMapper(data_mapper);
ren.SetBackground(0, 1, 0);
ren.AddActor(actor);
win.AddRenderer(ren);
2014年04月10日 03点04分
1
vtkRenderWindow win = this.vtkFormsWindowControl1.GetRenderWindow();
vtkPoints point = new vtkPoints();
vtkCellArray cell = new vtkCellArray();
point.InsertNextPoint(0, 0, 0);
point.InsertNextPoint(0, 100, 0);
point.InsertNextPoint(100, 100, 0);
point.InsertNextPoint(100, 0, 0);
point.InsertNextPoint(0, 0, 30);
point.InsertNextPoint(0, 100, 30);
point.InsertNextPoint(100, 100, 30);
point.InsertNextPoint(100, 0, 30);
cell.InsertCellPoint(4);
cell.InsertNextCell(0);
cell.InsertNextCell(1);
cell.InsertNextCell(2);
cell.InsertNextCell(3);
cell.InsertCellPoint(4);
cell.InsertNextCell(4);
cell.InsertNextCell(5);
cell.InsertNextCell(6);
cell.InsertNextCell(7);
cell.InsertCellPoint(4);
cell.InsertNextCell(0);
cell.InsertNextCell(1);
cell.InsertNextCell(5);
cell.InsertNextCell(4);
cell.InsertCellPoint(4);
cell.InsertNextCell(1);
cell.InsertNextCell(2);
cell.InsertNextCell(6);
cell.InsertNextCell(5);
cell.InsertCellPoint(4);
cell.InsertNextCell(2);
cell.InsertNextCell(3);
cell.InsertNextCell(7);
cell.InsertNextCell(6);
cell.InsertCellPoint(4);
cell.InsertNextCell(3);
cell.InsertNextCell(0);
cell.InsertNextCell(4);
cell.InsertNextCell(7);
vtkPolyData polydata = new vtkPolyData();
polydata.SetPoints(point);
polydata.SetPolys(cell);
vtkActor actor = new vtkActor();
vtkPolyDataNormals normal = new vtkPolyDataNormals();
normal.SetInput(polydata);
vtkTextureMapToCylinder tmapper = new vtkTextureMapToCylinder();
tmapper.SetInput(normal.GetOutput());
tmapper.PreventSeamOn();
vtkTransformTextureCoords transform_texture = new vtkTransformTextureCoords();
transform_texture.SetInput(tmapper.GetOutput());
vtkDataSetMapper data_mapper = new vtkDataSetMapper();
data_mapper.SetInput(transform_texture.GetOutput());
vtkJPEGReader reader = new vtkJPEGReader();
reader.SetFileName("E:\\地层\\8.jpg");
vtkTexture texture = new vtkTexture();
texture.SetInputConnection(reader.GetOutputPort());
texture.InterpolateOn();
actor.SetTexture(texture);
actor.SetMapper(data_mapper);
ren.SetBackground(0, 1, 0);
ren.AddActor(actor);
win.AddRenderer(ren);