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