1 #include "vvGlyphSource.h"
3 #include "vtkCellArray.h"
4 #include "vtkCellData.h"
6 #include "vtkInformation.h"
7 #include "vtkInformationVector.h"
8 #include "vtkObjectFactory.h"
9 #include "vtkPolyData.h"
10 #include "vtkUnsignedCharArray.h"
12 vtkCxxRevisionMacro(vvGlyphSource, "DummyRevision");
13 vtkStandardNewMacro(vvGlyphSource);
16 //----------------------------------------------------------------------------
17 int vvGlyphSource::RequestData(
18 vtkInformation *vtkNotUsed(request),
19 vtkInformationVector **vtkNotUsed(inputVector),
20 vtkInformationVector *outputVector)
22 // get the info object
23 vtkInformation *outInfo = outputVector->GetInformationObject(0);
26 vtkPolyData *output = vtkPolyData::SafeDownCast(
27 outInfo->Get(vtkDataObject::DATA_OBJECT()));
30 vtkPoints *pts = vtkPoints::New();
32 vtkCellArray *verts = vtkCellArray::New();
33 verts->Allocate(verts->EstimateSize(1,1),1);
34 vtkCellArray *lines = vtkCellArray::New();
35 lines->Allocate(lines->EstimateSize(4,2),2);
36 vtkCellArray *polys = vtkCellArray::New();
37 polys->Allocate(polys->EstimateSize(1,4),4);
38 vtkUnsignedCharArray *colors = vtkUnsignedCharArray::New();
39 colors->SetNumberOfComponents(3);
40 colors->Allocate(2,2);
47 int filled = this->Filled;
49 this->CreateDash(pts,lines,polys,colors,this->Scale2);
50 this->Filled = filled;
54 int filled = this->Filled;
56 this->CreateCross(pts,lines,polys,colors,this->Scale2);
57 this->Filled = filled;
60 //Call the right function
61 switch (this->GlyphType)
65 case VTK_VERTEX_GLYPH:
66 this->CreateVertex(pts,verts,colors);
69 this->CreateDash(pts,lines,polys,colors,this->Scale);
72 this->CreateCross(pts,lines,polys,colors,this->Scale);
74 case VTK_THICKCROSS_GLYPH:
75 this->CreateThickCross(pts,lines,polys,colors);
77 case VTK_TRIANGLE_GLYPH:
78 this->CreateTriangle(pts,lines,polys,colors);
80 case VTK_SQUARE_GLYPH:
81 this->CreateSquare(pts,lines,polys,colors);
83 case VTK_CIRCLE_GLYPH:
84 this->CreateCircle(pts,lines,polys,colors);
86 case VTK_DIAMOND_GLYPH:
87 this->CreateDiamond(pts,lines,polys,colors);
90 this->CreateArrow(pts,lines,polys,colors);
92 case VTK_THICKARROW_GLYPH:
93 this->CreateThickArrow(pts,lines,polys,colors);
95 case VTK_HOOKEDARROW_GLYPH:
96 this->CreateHookedArrow(pts,lines,polys,colors);
98 case VTK_EDGEARROW_GLYPH:
99 this->CreateEdgeArrow(pts,lines,polys,colors);
101 case VTK_SPECIFICARROW_GLYPH:
102 this->CreateSpecificArrow(pts,lines,polys,colors);
106 this->TransformGlyph(pts);
109 output->SetPoints(pts);
112 output->SetVerts(verts);
115 output->SetLines(lines);
118 output->SetPolys(polys);
121 output->GetCellData()->SetScalars(colors);
127 void vvGlyphSource::CreateSpecificArrow(vtkPoints *pts, vtkCellArray *lines,
128 vtkCellArray *polys, vtkUnsignedCharArray *colors)
132 ptIds[0] = pts->InsertNextPoint( 0.0, 0.0, 0.0);
133 ptIds[1] = pts->InsertNextPoint( 1.0, 0.0, 0.0);
134 lines->InsertNextCell(2,ptIds);
135 colors->InsertNextValue(0);
136 colors->InsertNextValue(0);
137 colors->InsertNextValue(1);
140 ptIds[0] = pts->InsertNextPoint( 0.7, -0.1, 0.0);
141 ptIds[1] = pts->InsertNextPoint( 1.0, 0.0, 0.0);
142 ptIds[2] = pts->InsertNextPoint( 0.7, 0.1, 0.0);
143 lines->InsertNextCell(3,ptIds);
144 colors->InsertNextValue(0);
145 colors->InsertNextValue(1);
146 colors->InsertNextValue(0);
149 void vvGlyphSource::PrintSelf(ostream& os, vtkIndent indent)
151 this->Superclass::PrintSelf(os, indent);