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