]> Creatis software - clitk.git/blob - vv/vvLandmarksGlyph.cxx
removed headers
[clitk.git] / vv / vvLandmarksGlyph.cxx
1 #include "vvLandmarksGlyph.h"
2
3 #include "vtkCellArray.h"
4 #include "vtkInformation.h"
5 #include "vtkInformationVector.h"
6 #include "vtkObjectFactory.h"
7 #include "vtkPointData.h"
8 #include "vtkPoints.h"
9 #include "vtkPolyData.h"
10 #include "vtkUnsignedCharArray.h"
11 #include <cassert>
12
13 vtkCxxRevisionMacro(vvLandmarksGlyph, "DummyRevision");
14 vtkStandardNewMacro(vvLandmarksGlyph);
15
16 #define vtkfont_width 9
17 //#define vtkfont_width 14
18 #define vtkfont_row_width 864
19 #define vtkfont_height 15
20 //#define vtkfont_height 20
21 static unsigned char vtkfont_bits[] = {
22     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
23     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
24     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
25     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
26     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
27     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
28     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
29     0x00,0x00,0xe0,0x00,0x10,0x90,0x00,0x00,0x40,0x88,0x03,0x1c,0x10,0x08,0x00,
30     0x00,0x00,0x00,0x00,0x00,0x20,0x1c,0x10,0xf8,0xf8,0x03,0xe2,0x0f,0x8f,0x3f,
31     0x3e,0x7c,0x00,0x00,0x00,0x02,0x80,0x00,0x1f,0x3e,0x10,0xfc,0xf0,0xf1,0xe3,
32     0xcf,0x1f,0x1f,0x41,0x7c,0xe0,0x09,0x12,0x20,0x48,0x10,0x1f,0x3f,0x7c,0xfc,
33     0xf0,0xf1,0x27,0x48,0x90,0x20,0x41,0x82,0xfc,0xe1,0x11,0xc0,0x03,0x02,0x00,
34     0x0e,0x00,0x04,0x00,0x00,0x04,0x00,0x0e,0x00,0x01,0x00,0x00,0x08,0xc0,0x00,
35     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
36     0x80,0x83,0xe0,0x80,0x11,0xe0,0x00,0x10,0x90,0x90,0x80,0xa0,0x44,0x04,0x0c,
37     0x08,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x22,0x18,0x04,0x01,0x02,0x23,
38     0x80,0x00,0x20,0x41,0x82,0x00,0x00,0x00,0x01,0x00,0x81,0x20,0x41,0x28,0x08,
39     0x09,0x22,0x44,0x80,0x80,0x20,0x41,0x10,0x80,0x08,0x11,0x20,0x48,0x90,0x20,
40     0x41,0x82,0x04,0x09,0x82,0x20,0x48,0x90,0x20,0x41,0x82,0x00,0x21,0x20,0x00,
41     0x02,0x05,0x00,0x0c,0x00,0x04,0x00,0x00,0x04,0x00,0x11,0x00,0x01,0x10,0x80,
42     0x08,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,
43     0x00,0x00,0x00,0x40,0x80,0x00,0x41,0x12,0xe0,0x00,0x10,0x90,0x90,0xe0,0xa3,
44     0x44,0x04,0x02,0x08,0x10,0x00,0x40,0x00,0x00,0x00,0x00,0x10,0x41,0x14,0x04,
45     0x01,0x81,0x22,0x40,0x00,0x20,0x41,0x82,0x00,0x00,0x80,0x00,0x00,0x82,0x20,
46     0x41,0x44,0x08,0x09,0x20,0x44,0x80,0x80,0x00,0x41,0x10,0x80,0x88,0x10,0x60,
47     0xcc,0x90,0x20,0x41,0x82,0x04,0x09,0x80,0x20,0x48,0x90,0x20,0x22,0x44,0x80,
48     0x20,0x20,0x00,0x82,0x08,0x00,0x10,0x00,0x04,0x00,0x00,0x04,0x00,0x11,0x00,
49     0x01,0x00,0x00,0x08,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,
50     0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x00,0x41,0x0c,0xe0,0x00,0x10,0x00,
51     0xf8,0x91,0x40,0x42,0x04,0x00,0x04,0x20,0x88,0x40,0x00,0x00,0x00,0x00,0x08,
52     0x41,0x10,0x00,0x81,0x40,0xa2,0x47,0x00,0x10,0x41,0x82,0x20,0x40,0x40,0x00,
53     0x00,0x04,0x20,0x79,0x82,0x08,0x09,0x20,0x44,0x80,0x80,0x00,0x41,0x10,0x80,
54     0x48,0x10,0xa0,0x4a,0x91,0x20,0x41,0x82,0x04,0x09,0x80,0x20,0x88,0x88,0x20,
55     0x14,0x28,0x40,0x20,0x40,0x00,0x42,0x10,0x00,0x00,0x7c,0xf4,0xf0,0xe1,0xc5,
56     0x07,0x01,0x2f,0x3d,0x18,0xe0,0x08,0x82,0xe0,0x46,0x0f,0x1f,0x3d,0xbc,0xe4,
57     0xf0,0xf1,0x23,0x44,0x90,0x20,0x41,0x42,0xfc,0x81,0x80,0x80,0x00,0x00,0xe0,
58     0x00,0x10,0x00,0x90,0x90,0x00,0x81,0x03,0x00,0x04,0x20,0x50,0x40,0x00,0x00,
59     0x00,0x00,0x04,0x41,0x10,0x80,0xc0,0x21,0x62,0x48,0x0f,0x08,0x3e,0xc2,0x70,
60     0xe0,0x20,0xe0,0x0f,0x08,0x10,0x45,0x82,0xf8,0x08,0x20,0xc4,0x83,0x87,0x00,
61     0x7f,0x10,0x80,0x38,0x10,0xa0,0x4a,0x92,0x20,0x3f,0x82,0xfc,0xf0,0x81,0x20,
62     0x88,0x88,0x24,0x08,0x10,0x20,0x20,0x80,0x00,0x02,0x00,0x00,0x00,0x80,0x0c,
63     0x09,0x12,0x26,0x08,0x81,0x10,0x43,0x10,0x80,0x88,0x81,0x20,0xc9,0x90,0x20,
64     0x43,0xc2,0x18,0x09,0x42,0x20,0x44,0x90,0x20,0x22,0x42,0x80,0x60,0x80,0x00,
65     0x03,0x00,0xe0,0x00,0x10,0x00,0x90,0xe0,0x03,0x41,0x04,0x00,0x04,0x20,0xfc,
66     0xf9,0x03,0xe0,0x0f,0x00,0x04,0x41,0x10,0x40,0x00,0x12,0x02,0xc8,0x10,0x04,
67     0x41,0xbc,0x20,0x40,0x20,0x00,0x00,0x08,0x08,0x65,0x82,0x08,0x09,0x20,0x44,
68     0x80,0x80,0x38,0x41,0x10,0x80,0x28,0x10,0x20,0x49,0x94,0x20,0x01,0x82,0x24,
69     0x00,0x82,0x20,0x88,0x88,0x24,0x08,0x10,0x10,0x20,0x80,0x00,0x02,0x00,0x00,
70     0x00,0x80,0x04,0x09,0x10,0x24,0xc8,0x87,0x10,0x41,0x10,0x80,0x68,0x80,0x20,
71     0x49,0x90,0x20,0x41,0x82,0x08,0x09,0x40,0x20,0x84,0x88,0x24,0x14,0x42,0x40,
72     0x60,0x80,0x00,0x03,0x00,0xe0,0x00,0x10,0x00,0xf8,0x81,0x84,0x44,0x14,0x00,
73     0x04,0x20,0x50,0x40,0x00,0x00,0x00,0x00,0x02,0x41,0x10,0x30,0x00,0xf2,0x07,
74     0x48,0x10,0x02,0x41,0x80,0x00,0x00,0x40,0x00,0x00,0x04,0x04,0x59,0xfe,0x08,
75     0x09,0x20,0x44,0x80,0x80,0x20,0x41,0x10,0x80,0x48,0x10,0x20,0x49,0x98,0x20,
76     0x01,0x82,0x44,0x00,0x82,0x20,0x08,0x85,0x24,0x14,0x10,0x08,0x20,0x00,0x01,
77     0x02,0x00,0x00,0x00,0xfc,0x04,0x09,0x10,0xe4,0x0f,0x81,0x10,0x41,0x10,0x80,
78     0x18,0x80,0x20,0x49,0x90,0x20,0x41,0x82,0x08,0xf0,0x41,0x20,0x84,0x88,0x24,
79     0x08,0x42,0x20,0x80,0x80,0x80,0x00,0x00,0xe0,0x00,0x10,0x00,0x90,0x80,0x44,
80     0x4a,0x08,0x00,0x08,0x10,0x88,0x40,0x00,0x00,0x00,0x00,0x01,0x41,0x10,0x08,
81     0x00,0x02,0x02,0x48,0x10,0x02,0x41,0x80,0x00,0x00,0x80,0xe0,0x0f,0x02,0x04,
82     0x01,0x82,0x08,0x09,0x20,0x44,0x80,0x80,0x20,0x41,0x10,0x80,0x88,0x10,0x20,
83     0x48,0x90,0x20,0x01,0x92,0x84,0x00,0x82,0x20,0x08,0x85,0x24,0x22,0x10,0x04,
84     0x20,0x00,0x02,0x02,0x00,0x00,0x00,0x82,0x04,0x09,0x10,0x24,0x00,0x01,0x0f,
85     0x41,0x10,0x80,0x68,0x80,0x20,0x49,0x90,0x20,0x41,0x82,0x08,0x00,0x42,0x20,
86     0x04,0x85,0x24,0x14,0x42,0x10,0x40,0x80,0x00,0x01,0x00,0xe0,0x00,0x00,0x00,
87     0x90,0xe0,0x43,0x4a,0x0c,0x00,0x08,0x10,0x00,0x40,0xc0,0x01,0x00,0x02,0x01,
88     0x22,0x10,0x04,0x08,0x02,0x22,0x48,0x10,0x01,0x41,0x40,0x20,0xe0,0x00,0x01,
89     0x00,0x01,0x00,0x01,0x82,0x08,0x09,0x22,0x44,0x80,0x80,0x20,0x41,0x10,0x84,
90     0x08,0x11,0x20,0x48,0x90,0x20,0x01,0xa2,0x04,0x09,0x82,0x20,0x08,0x85,0x2a,
91     0x41,0x10,0x04,0x20,0x00,0x02,0x02,0x00,0x00,0x00,0xc2,0x0c,0x09,0x12,0x26,
92     0x00,0x81,0x00,0x41,0x10,0x80,0x88,0x81,0x20,0x49,0x90,0x20,0x43,0xc2,0x08,
93     0x08,0x42,0x24,0x04,0x85,0x2a,0x22,0x62,0x08,0x40,0x80,0x00,0x01,0x00,0xe0,
94     0x00,0x10,0x00,0x00,0x80,0x20,0x84,0x13,0x00,0x10,0x08,0x00,0x00,0xc0,0x00,
95     0x00,0x87,0x00,0x1c,0x7c,0xfc,0xf1,0x01,0xc2,0x87,0x0f,0x01,0x3e,0x3c,0x70,
96     0x60,0x00,0x02,0x80,0x00,0x04,0x3e,0x82,0xfc,0xf0,0xf1,0xe3,0x8f,0x00,0x1f,
97     0x41,0x7c,0x78,0x08,0xf2,0x27,0x48,0x10,0x1f,0x01,0x7c,0x04,0xf1,0x81,0xc0,
98     0x07,0x02,0x11,0x41,0x10,0xfc,0xe1,0x01,0xc4,0x03,0x00,0x00,0x00,0xbc,0xf4,
99     0xf0,0xe1,0xc5,0x07,0x01,0x1f,0x41,0x7c,0x84,0x08,0xe2,0x23,0x48,0x10,0x1f,
100     0x3d,0xbc,0x08,0xf0,0x81,0xc3,0x0b,0x02,0x11,0x41,0x5c,0xfc,0x81,0x83,0xe0,
101     0x00,0x00,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
102     0x00,0x20,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
103     0x00,0x00,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
104     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,
105     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x3f,
106     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x20,0x00,0x00,0x84,0x00,0x00,0x00,
107     0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,
108     0x00,0x00,0x00,0x00,0x00,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
109     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
110     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
111     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
112     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
113     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x20,0x00,0x00,0x84,
114     0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
115     0x00,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,
116     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
117     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
118     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
119     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
120     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,
121     0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,
122     0x00,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x00,0x00,0x00,
123     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
124     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
125     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
126     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
127     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
128     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
129     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0
130 };
131
132 // Construct object with no string set and backing enabled.
133 vvLandmarksGlyph::vvLandmarksGlyph()
134 {
135     this->Text = NULL;
136     this->Backing = 1;
137     this->ForegroundColor[0] = 1.0;
138     this->ForegroundColor[1] = 1.0;
139     this->ForegroundColor[2] = 1.0;
140     this->ForegroundColor[3] = 1.0;
141     this->BackgroundColor[0] = 0.0;
142     this->BackgroundColor[1] = 0.0;
143     this->BackgroundColor[2] = 0.0;
144     this->BackgroundColor[3] = 1.0;
145
146     this->SetNumberOfInputPorts(0);
147 }
148
149 vvLandmarksGlyph::~vvLandmarksGlyph()
150 {
151     if (this->Text)
152     {
153         delete [] this->Text;
154     }
155 }
156
157 int vvLandmarksGlyph::RequestData(
158     vtkInformation *vtkNotUsed(request),
159     vtkInformationVector **vtkNotUsed(inputVector),
160     vtkInformationVector *outputVector)
161 {
162     // get the info object
163     vtkInformation *outInfo = outputVector->GetInformationObject(0);
164
165     // get the ouptut
166     vtkPolyData *output = vtkPolyData::SafeDownCast(
167                               outInfo->Get(vtkDataObject::DATA_OBJECT()));
168
169     vtkPoints *newPoints;
170     vtkCellArray *newPolys;
171     vtkCellArray *newLines;
172     vtkUnsignedCharArray *newScalars;
173
174     newPoints = vtkPoints::New();
175     newPolys = vtkCellArray::New();
176     newScalars = vtkUnsignedCharArray::New();
177     newScalars->SetNumberOfComponents(4);
178     newLines = vtkCellArray::New();
179     newLines->Allocate(newLines->EstimateSize(3,2));
180
181     AddTextGlyph(newPoints,newScalars,newPolys,0);
182     AddTextGlyph(newPoints,newScalars,newPolys,1);
183     AddTextGlyph(newPoints,newScalars,newPolys,2);
184
185     AddCrossGlyph(newPoints, newLines);
186
187     output->SetPoints(newPoints);
188     newPoints->Delete();
189
190     output->SetLines(newLines);
191     newLines->Delete();
192
193     output->GetPointData()->SetScalars(newScalars);
194     newScalars->Delete();
195
196     output->SetPolys(newPolys);
197     newPolys->Delete();
198
199     return 1;
200 }
201
202 void vvLandmarksGlyph::AddTextGlyph(vtkPoints* newPoints,vtkUnsignedCharArray* newScalars, vtkCellArray *newPolys, int orientation)
203 {
204     int row, col;
205     int pos = 0;
206     int pixelPos;
207     vtkIdType pts[5];
208     vtkIdType numPolys = 0;
209     double x[3];
210     int acol;
211     int drawingWhite = 0;
212     int drawingBlack = 0;
213     unsigned char white[4];
214     unsigned char black[4];
215     std::cout << "AddTextGlyph(output," << orientation << ")" << std::endl;
216
217     if (this->Text == NULL)
218     {
219         vtkErrorMacro (<< "Text is not set!");
220         return;
221     }
222
223     // convert colors to unsigned char
224     for (int i = 0; i < 4; i++)
225     {
226         white[i] = (unsigned char) (this->ForegroundColor[i] * 255.0);
227         black[i] = (unsigned char) (this->BackgroundColor[i] * 255.0);
228     }
229
230     std::cout << "Create Text" << std::endl;
231     // Create Text
232     while (this->Text[pos])
233     {
234         if (this->Text[pos] != 32)
235         {
236             for (col = 0; col < vtkfont_width; col++)
237             {
238                 acol = (this->Text[pos] - 32)*vtkfont_width + col - 1;
239                 for (row = 0; row < vtkfont_height; row++)
240                 {
241                     pixelPos = acol + row*vtkfont_row_width;
242                     if (vtkfont_bits[pixelPos/8] & (0x01 << pixelPos%8))
243                     {
244                         if (drawingBlack)
245                         {
246                             x[0] = pos*vtkfont_width + col + 1;
247                             x[1] = vtkfont_height - row;
248                             x[2] = 0;
249                             ChangeOrientation(x,orientation);
250                             newPoints->InsertNextPoint(x);
251                             newScalars->InsertNextValue(black[0]);
252                             newScalars->InsertNextValue(black[1]);
253                             newScalars->InsertNextValue(black[2]);
254                             newScalars->InsertNextValue(black[3]);
255
256                             x[0] = pos*vtkfont_width + col;
257                             x[1] = vtkfont_height - row;
258                             x[2] = 0;
259                             ChangeOrientation(x,orientation);
260                             newPoints->InsertNextPoint(x);
261                             newScalars->InsertNextValue(black[0]);
262                             newScalars->InsertNextValue(black[1]);
263                             newScalars->InsertNextValue(black[2]);
264                             newScalars->InsertNextValue(black[3]);
265
266                             pts[0] = numPolys*4;
267                             pts[1] = numPolys*4 + 1;
268                             pts[2] = numPolys*4 + 2;
269                             pts[3] = numPolys*4 + 3;
270                             newPolys->InsertNextCell(4,pts);
271                             numPolys++;
272                             drawingBlack = 0;
273                         }
274                         if (!drawingWhite)
275                         {
276                             x[0] = pos*vtkfont_width + col;
277                             x[1] = vtkfont_height - row;
278                             x[2] = 0;
279                             ChangeOrientation(x,orientation);
280                             newPoints->InsertNextPoint(x);
281                             newScalars->InsertNextValue(white[0]);
282                             newScalars->InsertNextValue(white[1]);
283                             newScalars->InsertNextValue(white[2]);
284                             newScalars->InsertNextValue(white[3]);
285
286                             x[0] = pos*vtkfont_width + col + 1;
287                             x[1] = vtkfont_height - row;
288                             x[2] = 0;
289                             ChangeOrientation(x,orientation);
290                             newPoints->InsertNextPoint(x);
291                             newScalars->InsertNextValue(white[0]);
292                             newScalars->InsertNextValue(white[1]);
293                             newScalars->InsertNextValue(white[2]);
294                             newScalars->InsertNextValue(white[3]);
295                             drawingWhite = 1;
296                         }
297                     }
298                     // if the pixel is not set the close up the rectangle
299                     else
300                     {
301                         if (drawingWhite)
302                         {
303                             x[0] = pos*vtkfont_width + col + 1;
304                             x[1] = vtkfont_height - row;
305                             x[2] = 0;
306                             ChangeOrientation(x,orientation);
307                             newPoints->InsertNextPoint(x);
308                             newScalars->InsertNextValue(white[0]);
309                             newScalars->InsertNextValue(white[1]);
310                             newScalars->InsertNextValue(white[2]);
311                             newScalars->InsertNextValue(white[3]);
312
313                             x[0] = pos*vtkfont_width + col;
314                             x[1] = vtkfont_height - row;
315                             x[2] = 0;
316                             ChangeOrientation(x,orientation);
317                             newPoints->InsertNextPoint(x);
318                             newScalars->InsertNextValue(white[0]);
319                             newScalars->InsertNextValue(white[1]);
320                             newScalars->InsertNextValue(white[2]);
321                             newScalars->InsertNextValue(white[3]);
322
323                             pts[0] = numPolys*4;
324                             pts[1] = numPolys*4 + 1;
325                             pts[2] = numPolys*4 + 2;
326                             pts[3] = numPolys*4 + 3;
327                             newPolys->InsertNextCell(4,pts);
328                             numPolys++;
329                             drawingWhite = 0;
330                         }
331                         if (!drawingBlack && this->Backing)
332                         {
333                             x[0] = pos*vtkfont_width + col;
334                             x[1] = vtkfont_height - row;
335                             x[2] = 0;
336                             ChangeOrientation(x,orientation);
337                             newPoints->InsertNextPoint(x);
338                             newScalars->InsertNextValue(black[0]);
339                             newScalars->InsertNextValue(black[1]);
340                             newScalars->InsertNextValue(black[2]);
341                             newScalars->InsertNextValue(black[3]);
342
343                             x[0] = pos*vtkfont_width + col + 1;
344                             x[1] = vtkfont_height - row;
345                             x[2] = 0;
346                             ChangeOrientation(x,orientation);
347                             newPoints->InsertNextPoint(x);
348                             newScalars->InsertNextValue(black[0]);
349                             newScalars->InsertNextValue(black[1]);
350                             newScalars->InsertNextValue(black[2]);
351                             newScalars->InsertNextValue(black[3]);
352                             drawingBlack = 1;
353                         }
354                     }
355                 }
356                 // if we finished up a row but are still drawing close it up
357                 if (drawingWhite)
358                 {
359                     x[0] = pos*vtkfont_width + col + 1;
360                     x[1] = 0;
361                     x[2] = 0;
362                     ChangeOrientation(x,orientation);
363                     newPoints->InsertNextPoint(x);
364                     newScalars->InsertNextValue(white[0]);
365                     newScalars->InsertNextValue(white[1]);
366                     newScalars->InsertNextValue(white[2]);
367                     newScalars->InsertNextValue(white[3]);
368
369                     x[0] = pos*vtkfont_width + col;
370                     x[1] = 0;
371                     x[2] = 0;
372                     ChangeOrientation(x,orientation);
373                     newPoints->InsertNextPoint(x);
374                     newScalars->InsertNextValue(white[0]);
375                     newScalars->InsertNextValue(white[1]);
376                     newScalars->InsertNextValue(white[2]);
377                     newScalars->InsertNextValue(white[3]);
378
379                     pts[0] = numPolys*4;
380                     pts[1] = numPolys*4 + 1;
381                     pts[2] = numPolys*4 + 2;
382                     pts[3] = numPolys*4 + 3;
383                     newPolys->InsertNextCell(4,pts);
384                     numPolys++;
385                     drawingWhite = 0;
386                 }
387                 if (drawingBlack)
388                 {
389                     x[0] = pos*vtkfont_width + col + 1;
390                     x[1] = 0;
391                     x[2] = 0;
392                     ChangeOrientation(x,orientation);
393                     newPoints->InsertNextPoint(x);
394                     newScalars->InsertNextValue(black[0]);
395                     newScalars->InsertNextValue(black[1]);
396                     newScalars->InsertNextValue(black[2]);
397                     newScalars->InsertNextValue(black[3]);
398
399                     x[0] = pos*vtkfont_width + col;
400                     x[1] = 0;
401                     x[2] = 0;
402                     ChangeOrientation(x,orientation);
403                     newPoints->InsertNextPoint(x);
404                     newScalars->InsertNextValue(black[0]);
405                     newScalars->InsertNextValue(black[1]);
406                     newScalars->InsertNextValue(black[2]);
407                     newScalars->InsertNextValue(black[3]);
408
409                     pts[0] = numPolys*4;
410                     pts[1] = numPolys*4 + 1;
411                     pts[2] = numPolys*4 + 2;
412                     pts[3] = numPolys*4 + 3;
413                     newPolys->InsertNextCell(4,pts);
414                     numPolys++;
415                     drawingBlack = 0;
416                 }
417             }
418         }
419         else
420         {
421             // draw a black square for a space
422             if (this->Backing)
423             {
424                 x[0] = pos*vtkfont_width;
425                 x[1] = vtkfont_height;
426                 x[2] = 0;
427                 ChangeOrientation(x,orientation);
428                 newPoints->InsertNextPoint(x);
429                 newScalars->InsertNextValue(black[0]);
430                 newScalars->InsertNextValue(black[1]);
431                 newScalars->InsertNextValue(black[2]);
432                 newScalars->InsertNextValue(black[3]);
433
434                 x[0] = pos*vtkfont_width + vtkfont_width;
435                 x[1] = vtkfont_height;
436                 x[2] = 0;
437                 ChangeOrientation(x,orientation);
438                 newPoints->InsertNextPoint(x);
439                 newScalars->InsertNextValue(black[0]);
440                 newScalars->InsertNextValue(black[1]);
441                 newScalars->InsertNextValue(black[2]);
442                 newScalars->InsertNextValue(black[3]);
443
444                 x[0] = pos*vtkfont_width + vtkfont_width;
445                 x[1] = 0;
446                 x[2] = 0;
447                 ChangeOrientation(x,orientation);
448                 newPoints->InsertNextPoint(x);
449                 newScalars->InsertNextValue(black[0]);
450                 newScalars->InsertNextValue(black[1]);
451                 newScalars->InsertNextValue(black[2]);
452                 newScalars->InsertNextValue(black[3]);
453
454                 x[0] = pos*vtkfont_width;
455                 x[1] = 0;
456                 x[2] = 0;
457                 ChangeOrientation(x,orientation);
458                 newPoints->InsertNextPoint(x);
459                 newScalars->InsertNextValue(black[0]);
460                 newScalars->InsertNextValue(black[1]);
461                 newScalars->InsertNextValue(black[2]);
462                 newScalars->InsertNextValue(black[3]);
463
464                 pts[0] = numPolys*4;
465                 pts[1] = numPolys*4 + 1;
466                 pts[2] = numPolys*4 + 2;
467                 pts[3] = numPolys*4 + 3;
468                 newPolys->InsertNextCell(4,pts);
469                 numPolys++;
470             }
471         }
472         pos++;
473     }
474 }
475
476 void vvLandmarksGlyph::AddCrossGlyph(vtkPoints* newPts,vtkCellArray* newLines)
477 {
478     vtkIdType ptIds[2];
479     double x[3];
480     std::cout << "AddCross" << std::endl;
481     x[0] = -10;
482     x[1] = 0;
483     x[2] = 0;
484     ptIds[0] = newPts->InsertNextPoint(x);
485
486     x[0] = 10;
487     x[1] = 0;
488     x[2] = 0;
489     ptIds[1] = newPts->InsertNextPoint(x);
490     newLines->InsertNextCell(2,ptIds);
491
492     x[0] = 0;
493     x[1] = -10;
494     x[2] = 0;
495     ptIds[0] = newPts->InsertNextPoint(x);
496
497     x[0] = 0;
498     x[1] = 10;
499     x[2] = 0;
500     ptIds[1] = newPts->InsertNextPoint(x);
501     newLines->InsertNextCell(2,ptIds);
502
503     x[0] = 0;
504     x[1] = 0;
505     x[2] = -10;
506     ptIds[0] = newPts->InsertNextPoint(x);
507
508     x[0] = 0;
509     x[1] = 0;
510     x[2] = 10;
511     ptIds[1] = newPts->InsertNextPoint(x);
512     newLines->InsertNextCell(2,ptIds);
513 }
514
515
516 void vvLandmarksGlyph::ChangeOrientation(double v[3],int orientation)
517 {
518     double x=0,y=0,z=0;
519     switch (orientation)
520     {
521     case 0:
522         x = v[1];
523         y = v[2];
524         z = v[0];
525         break;
526     case 1:
527         x = v[2];
528         y = v[0];
529         z = v[1];
530         break;
531     case 2:
532         x = v[0];
533         y = v[1];
534         z = v[2];
535         break;
536     default:
537         assert(false); //This definitely shouldn't happen
538     }
539     v[0] = x;
540     v[1] = y;
541     v[2] = z;
542 }
543
544 void vvLandmarksGlyph::PrintSelf(ostream& os, vtkIndent indent)
545 {
546     this->Superclass::PrintSelf(os,indent);
547
548     os << indent << "Text: " << (this->Text ? this->Text : "(none)") << "\n";
549     os << indent << "Background Drawn: " << (this->Backing ? "On\n" : "Off\n");
550     os << indent << "ForegroundColor: (" << this->ForegroundColor[0] << ", "
551     << this->ForegroundColor[1] << ", " << this->ForegroundColor[2]  << ")\n";
552     os << indent << "BackgroundColor: (" << this->BackgroundColor[0] << ", "
553     << this->BackgroundColor[1] << ", " << this->BackgroundColor[2] << ")\n";
554 }