00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <iostream>
00022
00023
00024 #include "vtkPoints.h"
00025 #include "vtkHexahedron.h"
00026 #include "vtkUnstructuredGrid.h"
00027 #include "vtkDataSetMapper.h"
00028 #include "vtkActor.h"
00029 #include "vtkProperty.h"
00030
00031
00032 #include "vtkwrap/vtkwin.h"
00033 #include "vtkwrap/ugridlabels.h"
00034 #include "vtkwrap/ugridclipper.h"
00035
00036 using std::cout;
00037 using std::endl;
00038
00039 int main(int argc, char **argv)
00040 {
00041
00042 VTKWin win;
00043
00044
00045 vtkPoints * pts = vtkPoints::New();
00046 pts -> SetNumberOfPoints (8);
00047 pts -> InsertPoint (0, 0, 0, 0);
00048 pts -> InsertPoint (1, 1, 0, 0);
00049 pts -> InsertPoint (2, 1, 1, 0);
00050 pts -> InsertPoint (3, 0, 1, 0);
00051 pts -> InsertPoint (4, 0, 0, 1);
00052 pts -> InsertPoint (5, 1, 0, 1);
00053 pts -> InsertPoint (6, 1, 1, 1);
00054 pts -> InsertPoint (7, 0, 1, 1);
00055
00056
00057 vtkHexahedron * hex = vtkHexahedron::New();
00058 hex -> GetPointIds() -> SetId(0, 0);
00059 hex -> GetPointIds() -> SetId(1, 1);
00060 hex -> GetPointIds() -> SetId(2, 2);
00061 hex -> GetPointIds() -> SetId(3, 3);
00062 hex -> GetPointIds() -> SetId(4, 4);
00063 hex -> GetPointIds() -> SetId(5, 5);
00064 hex -> GetPointIds() -> SetId(6, 6);
00065 hex -> GetPointIds() -> SetId(7, 7);
00066
00067
00068 vtkUnstructuredGrid * ugrid = vtkUnstructuredGrid ::New();
00069 vtkDataSetMapper * mapper = vtkDataSetMapper ::New();
00070 vtkActor * actor = vtkActor ::New();
00071 ugrid -> Allocate (1, 1);
00072 ugrid -> InsertNextCell (hex->GetCellType(), hex->GetPointIds());
00073 ugrid -> SetPoints (pts);
00074 mapper -> SetInput (ugrid);
00075 actor -> SetMapper (mapper);
00076 actor -> GetProperty()->SetDiffuseColor(1, 1, 0);
00077
00078
00079 UGridLabels lab(win, ugrid);
00080 lab.AddActorsTo(win);
00081
00082
00083
00084
00085
00086
00087 win.AddActor(actor);
00088 win.Show();
00089
00090 return 0;
00091 }