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