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