1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkGlyphSource2D.cxx
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 "vtkGlyphSource2D.h"
16 
17 #include "vtkCellArray.h"
18 #include "vtkCellData.h"
19 #include "vtkMath.h"
20 #include "vtkInformation.h"
21 #include "vtkInformationVector.h"
22 #include "vtkObjectFactory.h"
23 #include "vtkPolyData.h"
24 #include "vtkUnsignedCharArray.h"
25 
26 vtkStandardNewMacro(vtkGlyphSource2D);
27 
28 //----------------------------------------------------------------------------
vtkGlyphSource2D()29 vtkGlyphSource2D::vtkGlyphSource2D()
30 {
31   this->Center[0] = 0.0;
32   this->Center[1] = 0.0;
33   this->Center[2] = 0.0;
34   this->Scale = 1.0;
35   this->Scale2 = 1.5;
36   this->Color[0] = 1.0;
37   this->Color[1] = 1.0;
38   this->Color[2] = 1.0;
39   this->Filled = 1;
40   this->Cross = 0;
41   this->Dash = 0;
42   this->RotationAngle = 0.0;
43   this->OutputPointsPrecision = SINGLE_PRECISION;
44   this->GlyphType = VTK_VERTEX_GLYPH;
45 
46   this->SetNumberOfInputPorts(0);
47 }
48 
49 //----------------------------------------------------------------------------
RequestData(vtkInformation * vtkNotUsed (request),vtkInformationVector ** vtkNotUsed (inputVector),vtkInformationVector * outputVector)50 int vtkGlyphSource2D::RequestData(
51   vtkInformation *vtkNotUsed(request),
52   vtkInformationVector **vtkNotUsed(inputVector),
53   vtkInformationVector *outputVector)
54 {
55   // get the info object
56   vtkInformation *outInfo = outputVector->GetInformationObject(0);
57 
58   // get the ouptut
59   vtkPolyData *output = vtkPolyData::SafeDownCast(
60     outInfo->Get(vtkDataObject::DATA_OBJECT()));
61 
62   //Allocate storage
63   vtkPoints *pts = vtkPoints::New();
64 
65   // Set the desired precision for the points in the output.
66   if(this->OutputPointsPrecision == vtkAlgorithm::DOUBLE_PRECISION)
67     {
68     pts->SetDataType(VTK_DOUBLE);
69     }
70   else
71     {
72     pts->SetDataType(VTK_FLOAT);
73     }
74 
75   pts->Allocate(6,6);
76   vtkCellArray *verts = vtkCellArray::New();
77   verts->Allocate(verts->EstimateSize(1,1),1);
78   vtkCellArray *lines = vtkCellArray::New();
79   lines->Allocate(lines->EstimateSize(4,2),2);
80   vtkCellArray *polys = vtkCellArray::New();
81   polys->Allocate(polys->EstimateSize(1,4),4);
82   vtkUnsignedCharArray *colors = vtkUnsignedCharArray::New();
83   colors->SetNumberOfComponents(3);
84   colors->Allocate(2,2);
85   colors->SetName("Colors");
86 
87   this->ConvertColor();
88 
89   //Special options
90   if ( this->Dash )
91     {
92     int filled = this->Filled;
93     this->Filled = 0;
94     this->CreateDash(pts,lines,polys,colors,this->Scale2);
95     this->Filled = filled;
96     }
97   if ( this->Cross )
98     {
99     int filled = this->Filled;
100     this->Filled = 0;
101     this->CreateCross(pts,lines,polys,colors,this->Scale2);
102     this->Filled = filled;
103     }
104 
105   //Call the right function
106   switch (this->GlyphType)
107     {
108     case VTK_NO_GLYPH:
109       break;
110     case VTK_VERTEX_GLYPH:
111       this->CreateVertex(pts,verts,colors);
112       break;
113     case VTK_DASH_GLYPH:
114       this->CreateDash(pts,lines,polys,colors,this->Scale);
115       break;
116     case VTK_CROSS_GLYPH:
117       this->CreateCross(pts,lines,polys,colors,this->Scale);
118       break;
119     case VTK_THICKCROSS_GLYPH:
120       this->CreateThickCross(pts,lines,polys,colors);
121       break;
122     case VTK_TRIANGLE_GLYPH:
123       this->CreateTriangle(pts,lines,polys,colors);
124       break;
125     case VTK_SQUARE_GLYPH:
126       this->CreateSquare(pts,lines,polys,colors);
127       break;
128     case VTK_CIRCLE_GLYPH:
129       this->CreateCircle(pts,lines,polys,colors);
130       break;
131     case VTK_DIAMOND_GLYPH:
132       this->CreateDiamond(pts,lines,polys,colors);
133       break;
134     case VTK_ARROW_GLYPH:
135       this->CreateArrow(pts,lines,polys,colors);
136       break;
137     case VTK_THICKARROW_GLYPH:
138       this->CreateThickArrow(pts,lines,polys,colors);
139       break;
140     case VTK_HOOKEDARROW_GLYPH:
141       this->CreateHookedArrow(pts,lines,polys,colors);
142       break;
143     case VTK_EDGEARROW_GLYPH:
144       this->CreateEdgeArrow(pts,lines,polys,colors);
145       break;
146     }
147 
148   this->TransformGlyph(pts);
149 
150   //Clean up
151   output->SetPoints(pts);
152   pts->Delete();
153 
154   output->SetVerts(verts);
155   verts->Delete();
156 
157   output->SetLines(lines);
158   lines->Delete();
159 
160   output->SetPolys(polys);
161   polys->Delete();
162 
163   output->GetCellData()->SetScalars(colors);
164   colors->Delete();
165 
166   return 1;
167 }
168 
ConvertColor()169 void vtkGlyphSource2D::ConvertColor()
170 {
171   this->RGB[0] = static_cast<unsigned char>(255.0 * this->Color[0]);
172   this->RGB[1] = static_cast<unsigned char>(255.0 * this->Color[1]);
173   this->RGB[2] = static_cast<unsigned char>(255.0 * this->Color[2]);
174 }
175 
TransformGlyph(vtkPoints * pts)176 void vtkGlyphSource2D::TransformGlyph(vtkPoints *pts)
177 {
178   double x[3];
179   int i;
180   int numPts=pts->GetNumberOfPoints();
181 
182   if ( this->RotationAngle == 0.0 )
183     {
184     for (i=0; i<numPts; i++)
185       {
186       pts->GetPoint(i,x);
187       x[0] = this->Center[0] + this->Scale * x[0];
188       x[1] = this->Center[1] + this->Scale * x[1];
189       pts->SetPoint(i,x);
190       }
191     }
192   else
193     {
194     double angle = vtkMath::RadiansFromDegrees( this->RotationAngle );
195     double xt;
196     for (i=0; i<numPts; i++)
197       {
198       pts->GetPoint(i,x);
199       xt = x[0]*cos(angle) - x[1]*sin(angle);
200       x[1] = x[0]*sin(angle) + x[1]*cos(angle);
201       x[0] = xt;
202       x[0] = this->Center[0] + this->Scale * x[0];
203       x[1] = this->Center[1] + this->Scale * x[1];
204       pts->SetPoint(i,x);
205       }
206     }
207 }
208 
CreateVertex(vtkPoints * pts,vtkCellArray * verts,vtkUnsignedCharArray * colors)209 void vtkGlyphSource2D::CreateVertex(vtkPoints *pts, vtkCellArray *verts,
210                                     vtkUnsignedCharArray *colors)
211 {
212   vtkIdType ptIds[1];
213   ptIds[0] = pts->InsertNextPoint(0.0,0.0,0.0);
214   verts->InsertNextCell(1,ptIds);
215   colors->InsertNextValue(this->RGB[0]);
216   colors->InsertNextValue(this->RGB[1]);
217   colors->InsertNextValue(this->RGB[2]);
218 }
219 
CreateCross(vtkPoints * pts,vtkCellArray * lines,vtkCellArray * polys,vtkUnsignedCharArray * colors,double scale)220 void vtkGlyphSource2D::CreateCross(vtkPoints *pts, vtkCellArray *lines,
221                                    vtkCellArray *polys, vtkUnsignedCharArray *colors,
222                                    double scale)
223 {
224   vtkIdType ptIds[4];
225 
226   if ( this->Filled )
227     {
228     this->CreateThickCross(pts,lines,polys,colors);
229     }
230   else
231     {
232     ptIds[0] = pts->InsertNextPoint(-0.5*scale, 0.0, 0.0);
233     ptIds[1] = pts->InsertNextPoint( 0.5*scale, 0.0, 0.0);
234     lines->InsertNextCell(2,ptIds);
235     colors->InsertNextValue(this->RGB[0]);
236     colors->InsertNextValue(this->RGB[1]);
237     colors->InsertNextValue(this->RGB[2]);
238     ptIds[0] = pts->InsertNextPoint(0.0, -0.5*scale, 0.0);
239     ptIds[1] = pts->InsertNextPoint(0.0,  0.5*scale, 0.0);
240     lines->InsertNextCell(2,ptIds);
241     colors->InsertNextValue(this->RGB[0]);
242     colors->InsertNextValue(this->RGB[1]);
243     colors->InsertNextValue(this->RGB[2]);
244     }
245 }
246 
CreateThickCross(vtkPoints * pts,vtkCellArray * lines,vtkCellArray * polys,vtkUnsignedCharArray * colors)247 void vtkGlyphSource2D::CreateThickCross(vtkPoints *pts, vtkCellArray *lines,
248                                         vtkCellArray *polys, vtkUnsignedCharArray *colors)
249 {
250   if ( this->Filled )
251     {
252     vtkIdType ptIds[4];
253     ptIds[0] = pts->InsertNextPoint(-0.5, -0.1, 0.0);
254     ptIds[1] = pts->InsertNextPoint( 0.5, -0.1, 0.0);
255     ptIds[2] = pts->InsertNextPoint( 0.5,  0.1, 0.0);
256     ptIds[3] = pts->InsertNextPoint(-0.5,  0.1, 0.0);
257     polys->InsertNextCell(4,ptIds);
258     colors->InsertNextValue(this->RGB[0]);
259     colors->InsertNextValue(this->RGB[1]);
260     colors->InsertNextValue(this->RGB[2]);
261     ptIds[0] = pts->InsertNextPoint(-0.1, -0.5, 0.0);
262     ptIds[1] = pts->InsertNextPoint( 0.1, -0.5, 0.0);
263     ptIds[2] = pts->InsertNextPoint( 0.1,  0.5, 0.0);
264     ptIds[3] = pts->InsertNextPoint(-0.1,  0.5, 0.0);
265     polys->InsertNextCell(4,ptIds);
266     colors->InsertNextValue(this->RGB[0]);
267     colors->InsertNextValue(this->RGB[1]);
268     colors->InsertNextValue(this->RGB[2]);
269     }
270   else
271     {
272     vtkIdType ptIds[13];
273     ptIds[0] = pts->InsertNextPoint(-0.5, -0.1, 0.0);
274     ptIds[1] = pts->InsertNextPoint(-0.1, -0.1, 0.0);
275     ptIds[2] = pts->InsertNextPoint(-0.1, -0.5, 0.0);
276     ptIds[3] = pts->InsertNextPoint( 0.1, -0.5, 0.0);
277     ptIds[4] = pts->InsertNextPoint( 0.1, -0.1, 0.0);
278     ptIds[5] = pts->InsertNextPoint( 0.5, -0.1, 0.0);
279     ptIds[6] = pts->InsertNextPoint( 0.5,  0.1, 0.0);
280     ptIds[7] = pts->InsertNextPoint( 0.1,  0.1, 0.0);
281     ptIds[8] = pts->InsertNextPoint( 0.1,  0.5, 0.0);
282     ptIds[9] = pts->InsertNextPoint(-0.1,  0.5, 0.0);
283     ptIds[10] = pts->InsertNextPoint(-0.1, 0.1, 0.0);
284     ptIds[11] = pts->InsertNextPoint(-0.5, 0.1, 0.0);
285     ptIds[12] = ptIds[0];
286     lines->InsertNextCell(13,ptIds);
287     colors->InsertNextValue(this->RGB[0]);
288     colors->InsertNextValue(this->RGB[1]);
289     colors->InsertNextValue(this->RGB[2]);
290     }
291 }
292 
CreateTriangle(vtkPoints * pts,vtkCellArray * lines,vtkCellArray * polys,vtkUnsignedCharArray * colors)293 void vtkGlyphSource2D::CreateTriangle(vtkPoints *pts, vtkCellArray *lines,
294                                       vtkCellArray *polys, vtkUnsignedCharArray *colors)
295 {
296   vtkIdType ptIds[4];
297 
298   ptIds[0] = pts->InsertNextPoint(-0.375, -0.25, 0.0);
299   ptIds[1] = pts->InsertNextPoint( 0.0,  0.5, 0.0);
300   ptIds[2] = pts->InsertNextPoint( 0.375, -0.25, 0.0);
301 
302   if ( this->Filled )
303     {
304     polys->InsertNextCell(3,ptIds);
305     }
306   else
307     {
308     ptIds[3] = ptIds[0];
309     lines->InsertNextCell(4,ptIds);
310     }
311   colors->InsertNextValue(this->RGB[0]);
312   colors->InsertNextValue(this->RGB[1]);
313   colors->InsertNextValue(this->RGB[2]);
314 }
315 
CreateSquare(vtkPoints * pts,vtkCellArray * lines,vtkCellArray * polys,vtkUnsignedCharArray * colors)316 void vtkGlyphSource2D::CreateSquare(vtkPoints *pts, vtkCellArray *lines,
317                                     vtkCellArray *polys, vtkUnsignedCharArray *colors)
318 {
319   vtkIdType ptIds[5];
320 
321   ptIds[0] = pts->InsertNextPoint(-0.5, -0.5, 0.0);
322   ptIds[1] = pts->InsertNextPoint( 0.5, -0.5, 0.0);
323   ptIds[2] = pts->InsertNextPoint( 0.5,  0.5, 0.0);
324   ptIds[3] = pts->InsertNextPoint(-0.5,  0.5, 0.0);
325 
326   if ( this->Filled )
327     {
328     polys->InsertNextCell(4,ptIds);
329     }
330   else
331     {
332     ptIds[4] = ptIds[0];
333     lines->InsertNextCell(5,ptIds);
334     }
335   colors->InsertNextValue(this->RGB[0]);
336   colors->InsertNextValue(this->RGB[1]);
337   colors->InsertNextValue(this->RGB[2]);
338 }
339 
CreateCircle(vtkPoints * pts,vtkCellArray * lines,vtkCellArray * polys,vtkUnsignedCharArray * colors)340 void vtkGlyphSource2D::CreateCircle(vtkPoints *pts, vtkCellArray *lines,
341                                     vtkCellArray *polys, vtkUnsignedCharArray *colors)
342 {
343   vtkIdType ptIds[9];
344   double x[3], theta;
345 
346   // generate eight points in a circle
347   x[2] = 0.0;
348   theta = 2.0 * vtkMath::Pi() / 8.0;
349   for (int i=0; i<8; i++)
350     {
351     x[0] = 0.5 * cos(i*theta);
352     x[1] = 0.5 * sin(i*theta);
353     ptIds[i] = pts->InsertNextPoint(x);
354     }
355 
356   if ( this->Filled )
357     {
358     polys->InsertNextCell(8,ptIds);
359     }
360   else
361     {
362     ptIds[8] = ptIds[0];
363     lines->InsertNextCell(9,ptIds);
364     }
365   colors->InsertNextValue(this->RGB[0]);
366   colors->InsertNextValue(this->RGB[1]);
367   colors->InsertNextValue(this->RGB[2]);
368 }
369 
CreateDiamond(vtkPoints * pts,vtkCellArray * lines,vtkCellArray * polys,vtkUnsignedCharArray * colors)370 void vtkGlyphSource2D::CreateDiamond(vtkPoints *pts, vtkCellArray *lines,
371                                      vtkCellArray *polys, vtkUnsignedCharArray *colors)
372 {
373   vtkIdType ptIds[5];
374 
375   ptIds[0] = pts->InsertNextPoint( 0.0, -0.5, 0.0);
376   ptIds[1] = pts->InsertNextPoint( 0.5,  0.0, 0.0);
377   ptIds[2] = pts->InsertNextPoint( 0.0,  0.5, 0.0);
378   ptIds[3] = pts->InsertNextPoint(-0.5,  0.0, 0.0);
379 
380   if ( this->Filled )
381     {
382     polys->InsertNextCell(4,ptIds);
383     }
384   else
385     {
386     ptIds[4] = ptIds[0];
387     lines->InsertNextCell(5,ptIds);
388     }
389   colors->InsertNextValue(this->RGB[0]);
390   colors->InsertNextValue(this->RGB[1]);
391   colors->InsertNextValue(this->RGB[2]);
392 }
393 
CreateArrow(vtkPoints * pts,vtkCellArray * lines,vtkCellArray * polys,vtkUnsignedCharArray * colors)394 void vtkGlyphSource2D::CreateArrow(vtkPoints *pts, vtkCellArray *lines,
395                                    vtkCellArray *polys, vtkUnsignedCharArray *colors)
396 {
397   if ( this->Filled ) //create two convex polygons
398     {
399     this->CreateThickArrow(pts,lines,polys,colors);
400     }
401   else
402     {
403     //stem
404     vtkIdType ptIds[3];
405     ptIds[0] = pts->InsertNextPoint( -0.5, 0.0, 0.0);
406     ptIds[1] = pts->InsertNextPoint(  0.5, 0.0, 0.0);
407     lines->InsertNextCell(2,ptIds);
408     colors->InsertNextValue(this->RGB[0]);
409     colors->InsertNextValue(this->RGB[1]);
410     colors->InsertNextValue(this->RGB[2]);
411 
412     //arrow head
413     ptIds[0] = pts->InsertNextPoint( 0.2, -0.1, 0.0);
414     ptIds[1] = pts->InsertNextPoint( 0.5,  0.0, 0.0);
415     ptIds[2] = pts->InsertNextPoint( 0.2,  0.1, 0.0);
416     lines->InsertNextCell(3,ptIds);
417     colors->InsertNextValue(this->RGB[0]);
418     colors->InsertNextValue(this->RGB[1]);
419     colors->InsertNextValue(this->RGB[2]);
420     }
421 }
422 
CreateThickArrow(vtkPoints * pts,vtkCellArray * lines,vtkCellArray * polys,vtkUnsignedCharArray * colors)423 void vtkGlyphSource2D::CreateThickArrow(vtkPoints *pts, vtkCellArray *lines,
424                                          vtkCellArray *polys, vtkUnsignedCharArray *colors)
425 {
426   vtkIdType ptIds[8];
427 
428   ptIds[0] = pts->InsertNextPoint( -0.5, -0.1, 0.0);
429   ptIds[1] = pts->InsertNextPoint(  0.1, -0.1, 0.0);
430   ptIds[2] = pts->InsertNextPoint(  0.1, -0.2, 0.0);
431   ptIds[3] = pts->InsertNextPoint(  0.5,  0.0, 0.0);
432   ptIds[4] = pts->InsertNextPoint(  0.1,  0.2, 0.0);
433   ptIds[5] = pts->InsertNextPoint(  0.1,  0.1, 0.0);
434   ptIds[6] = pts->InsertNextPoint( -0.5,  0.1, 0.0);
435 
436   if ( this->Filled ) //create two convex polygons
437     {
438     polys->InsertNextCell(4);
439     polys->InsertCellPoint(ptIds[0]);
440     polys->InsertCellPoint(ptIds[1]);
441     polys->InsertCellPoint(ptIds[5]);
442     polys->InsertCellPoint(ptIds[6]);
443     colors->InsertNextValue(this->RGB[0]);
444     colors->InsertNextValue(this->RGB[1]);
445     colors->InsertNextValue(this->RGB[2]);
446 
447     polys->InsertNextCell(5,ptIds+1);
448     colors->InsertNextValue(this->RGB[0]);
449     colors->InsertNextValue(this->RGB[1]);
450     colors->InsertNextValue(this->RGB[2]);
451     }
452   else
453     {
454     ptIds[7] = ptIds[0];
455     lines->InsertNextCell(8,ptIds);
456     colors->InsertNextValue(this->RGB[0]);
457     colors->InsertNextValue(this->RGB[1]);
458     colors->InsertNextValue(this->RGB[2]);
459     }
460 }
461 
CreateHookedArrow(vtkPoints * pts,vtkCellArray * lines,vtkCellArray * polys,vtkUnsignedCharArray * colors)462 void vtkGlyphSource2D::CreateHookedArrow(vtkPoints *pts, vtkCellArray *lines,
463                                          vtkCellArray *polys, vtkUnsignedCharArray *colors)
464 {
465   if ( this->Filled )
466     {
467     //create two convex polygons
468     vtkIdType ptIds[4];
469     ptIds[0] = pts->InsertNextPoint( -0.5,   -0.1, 0.0);
470     ptIds[1] = pts->InsertNextPoint(  0.1,   -0.1, 0.0);
471     ptIds[2] = pts->InsertNextPoint(  0.1,  0.075, 0.0);
472     ptIds[3] = pts->InsertNextPoint( -0.5,  0.075, 0.0);
473     polys->InsertNextCell(4,ptIds);
474     colors->InsertNextValue(this->RGB[0]);
475     colors->InsertNextValue(this->RGB[1]);
476     colors->InsertNextValue(this->RGB[2]);
477 
478     ptIds[0] = pts->InsertNextPoint( 0.1, -0.1, 0.0);
479     ptIds[1] = pts->InsertNextPoint( 0.5, -0.1, 0.0);
480     ptIds[2] = pts->InsertNextPoint( 0.1,  0.2, 0.0);
481     polys->InsertNextCell(3,ptIds);
482     colors->InsertNextValue(this->RGB[0]);
483     colors->InsertNextValue(this->RGB[1]);
484     colors->InsertNextValue(this->RGB[2]);
485     }
486   else
487     {
488     vtkIdType ptIds[3];
489     ptIds[0] = pts->InsertNextPoint( -0.5, 0.0, 0.0);
490     ptIds[1] = pts->InsertNextPoint(  0.5, 0.0, 0.0);
491     ptIds[2] = pts->InsertNextPoint(  0.2, 0.1, 0.0);
492     lines->InsertNextCell(3,ptIds);
493     colors->InsertNextValue(this->RGB[0]);
494     colors->InsertNextValue(this->RGB[1]);
495     colors->InsertNextValue(this->RGB[2]);
496     }
497 }
498 
CreateEdgeArrow(vtkPoints * pts,vtkCellArray * lines,vtkCellArray * polys,vtkUnsignedCharArray * colors)499 void vtkGlyphSource2D::CreateEdgeArrow(vtkPoints *pts, vtkCellArray *lines,
500                                        vtkCellArray *polys, vtkUnsignedCharArray *colors)
501 {
502   vtkIdType ptIds[3];
503 
504   double x = 0.5 / sqrt(3.0);
505   ptIds[0] = pts->InsertNextPoint(-1.0,   x, 0.0);
506   ptIds[1] = pts->InsertNextPoint( 0.0, 0.0, 0.0);
507   ptIds[2] = pts->InsertNextPoint(-1.0,  -x, 0.0);
508 
509   if ( this->Filled )
510     {
511     polys->InsertNextCell(3,ptIds);
512     }
513   else
514     {
515     lines->InsertNextCell(3,ptIds);
516     }
517   colors->InsertNextValue(this->RGB[0]);
518   colors->InsertNextValue(this->RGB[1]);
519   colors->InsertNextValue(this->RGB[2]);
520 }
521 
CreateDash(vtkPoints * pts,vtkCellArray * lines,vtkCellArray * polys,vtkUnsignedCharArray * colors,double scale)522 void vtkGlyphSource2D::CreateDash(vtkPoints *pts, vtkCellArray *lines,
523                                   vtkCellArray *polys, vtkUnsignedCharArray *colors,
524                                                                   double scale)
525 {
526   vtkIdType ptIds[5];
527   ptIds[0] = pts->InsertNextPoint(-0.5, -0.1, 0.0);
528   ptIds[1] = pts->InsertNextPoint( 0.5, -0.1, 0.0);
529   ptIds[2] = pts->InsertNextPoint( 0.5,  0.1, 0.0);
530   ptIds[3] = pts->InsertNextPoint(-0.5,  0.1, 0.0);
531 
532   if ( this->Filled )
533     {
534     polys->InsertNextCell(4,ptIds);
535     }
536   else
537     {
538     vtkIdType ptIds2D[2];
539     ptIds2D[0] = pts->InsertNextPoint(-0.5*scale, 0.0, 0.0);
540     ptIds2D[1] = pts->InsertNextPoint( 0.5*scale, 0.0, 0.0);
541     colors->InsertNextValue(this->RGB[0]);
542     colors->InsertNextValue(this->RGB[1]);
543     colors->InsertNextValue(this->RGB[2]);
544     lines->InsertNextCell(2,ptIds2D);
545     }
546   colors->InsertNextValue(this->RGB[0]);
547   colors->InsertNextValue(this->RGB[1]);
548   colors->InsertNextValue(this->RGB[2]);
549 }
550 
551 //----------------------------------------------------------------------------
PrintSelf(ostream & os,vtkIndent indent)552 void vtkGlyphSource2D::PrintSelf(ostream& os, vtkIndent indent)
553 {
554   this->Superclass::PrintSelf(os,indent);
555 
556   os << indent << "Center: (" << this->Center[0] << ", "
557      << this->Center[1] << ", " << this->Center[2] << ")\n";
558 
559   os << indent << "Scale: " << this->Scale << "\n";
560   os << indent << "Scale2: " << this->Scale2 << "\n";
561   os << indent << "Rotation Angle: " << this->RotationAngle << "\n";
562 
563   os << indent << "Color: (" << this->Color[0] << ", "
564      << this->Color[1] << ", " << this->Color[2] << ")\n";
565 
566   os << indent << "Filled: " << (this->Filled ? "On\n" : "Off\n");
567   os << indent << "Dash: " << (this->Dash ? "On\n" : "Off\n");
568   os << indent << "Cross: " << (this->Cross ? "On\n" : "Off\n");
569 
570   os << indent << "Glyph Type";
571   switch (this->GlyphType)
572     {
573     case VTK_NO_GLYPH:
574       os << "No Glyph\n";
575       break;
576     case VTK_VERTEX_GLYPH:
577       os << "Vertex\n";
578       break;
579     case VTK_DASH_GLYPH:
580       os << "Dash\n";
581       break;
582     case VTK_CROSS_GLYPH:
583       os << "Cross\n";
584       break;
585     case VTK_THICKCROSS_GLYPH:
586       os << "Cross\n";
587       break;
588     case VTK_TRIANGLE_GLYPH:
589       os << "Triangle\n";
590       break;
591     case VTK_SQUARE_GLYPH:
592       os << "Square\n";
593       break;
594     case VTK_CIRCLE_GLYPH:
595       os << "Circle\n";
596       break;
597     case VTK_DIAMOND_GLYPH:
598       os << "Diamond\n";
599       break;
600     case VTK_ARROW_GLYPH:
601       os << "Arrow\n";
602       break;
603     case VTK_THICKARROW_GLYPH:
604       os << "Arrow\n";
605       break;
606     case VTK_HOOKEDARROW_GLYPH:
607       os << "Hooked Arrow\n";
608       break;
609     case VTK_EDGEARROW_GLYPH:
610       os << "Edge Arrow\n";
611       break;
612     }
613   os << indent << "Output Points Precision: " << this->OutputPointsPrecision
614      << "\n";
615 }
616