1 /*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkPolygonsPainter.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 "vtkPolygonsPainter.h"
16
17 #include "vtkCellArray.h"
18 #include "vtkCellData.h"
19 #include "vtkObjectFactory.h"
20 #include "vtkPainterDeviceAdapter.h"
21 #include "vtkPoints.h"
22 #include "vtkPointData.h"
23 #include "vtkPolyData.h"
24 #include "vtkPolygon.h"
25 #include "vtkProperty.h"
26 #include "vtkRenderer.h"
27 #include "vtkRenderWindow.h"
28 #include "vtkUnsignedCharArray.h"
29 vtkStandardNewMacro(vtkPolygonsPainter);
30
31 #define VTK_PP_INVALID_TYPE -1
32 //-----------------------------------------------------------------------------
vtkPolygonsPainter()33 vtkPolygonsPainter::vtkPolygonsPainter()
34 {
35 this->SetSupportedPrimitive(vtkPainter::POLYS);
36 }
37
38 //-----------------------------------------------------------------------------
~vtkPolygonsPainter()39 vtkPolygonsPainter::~vtkPolygonsPainter()
40 {
41 }
42
43 //-----------------------------------------------------------------------------
44 //
45 // Helper routine which starts a poly, triangle or quad based upon
46 // the number of points in the polygon and whether triangles or quads
47 // were the last thing being drawn (we can get better performance if we
48 // can draw several triangles within a single glBegin(GL_TRIANGLES) or
49 // several quads within a single glBegin(GL_QUADS).
50 //
vtkOpenGLBeginPolyTriangleOrQuad(int aPrimitive,int & previousPrimitive,int npts,vtkPainterDeviceAdapter * device)51 static inline void vtkOpenGLBeginPolyTriangleOrQuad(int aPrimitive,
52 int &previousPrimitive,
53 int npts,
54 vtkPainterDeviceAdapter* device)
55 {
56 if (aPrimitive == VTK_POLYGON)
57 {
58 switch (npts)
59 {
60 case 3: // Need to draw a triangle.
61 if (previousPrimitive != VTK_TRIANGLE)
62 {
63 // we were not already drawing triangles, were we drawing quads?
64 if (previousPrimitive == VTK_QUAD)
65 {
66 // we were previously drawing quads, close down the quads.
67 device->EndPrimitive();
68 }
69 // start drawing triangles
70 previousPrimitive = VTK_TRIANGLE;
71 device->BeginPrimitive(VTK_TRIANGLE);
72 }
73 break;
74 case 4: // Need to draw a quad
75 if (previousPrimitive != VTK_QUAD)
76 {
77 // we were not already drawing quads, were we drawing triangles?
78 if (previousPrimitive == VTK_TRIANGLE)
79 {
80 // we were previously drawing triangles, close down the triangles.
81 device->EndPrimitive();
82 }
83 // start drawing quads
84 previousPrimitive = VTK_QUAD;
85 device->BeginPrimitive(VTK_QUAD);
86 }
87 break;
88 default:
89 // if we were supposed to be drawing polygons but were really
90 // drawing triangles or quads, then we need to close down the
91 // triangles or quads and begin a polygon
92 if (previousPrimitive != VTK_PP_INVALID_TYPE
93 && previousPrimitive != VTK_POLYGON)
94 {
95 device->EndPrimitive();
96 }
97 previousPrimitive = VTK_POLYGON;
98 device->BeginPrimitive(VTK_POLYGON);
99 break;
100 }
101 }
102 else if (aPrimitive == VTK_VERTEX || aPrimitive == VTK_POLY_VERTEX)
103 {
104 // we are supposed to be drawing points
105 if (previousPrimitive != VTK_VERTEX && previousPrimitive != VTK_POLY_VERTEX)
106 {
107 // We were not drawing points before this, switch to points.
108 // We don't need to worry about switching from triangles or quads
109 // since draw all points before drawing any polygons (i.e. in the polys
110 // case we switch to triangles and quads as an optimization, there is
111 // nothing to switch to that is below points).
112 previousPrimitive = VTK_VERTEX;
113 device->BeginPrimitive(VTK_VERTEX);
114 }
115 }
116 else
117 {
118 previousPrimitive = aPrimitive;
119 device->BeginPrimitive(aPrimitive);
120 }
121 }
122
123 //-----------------------------------------------------------------------------
124 #define vtkDrawPolysMacro(prim,glVertFuncs,glCellFuncs,glInitFuncs) \
125 { \
126 vtkIdType nPts; unsigned short count = 0; \
127 int previousPrimitive = VTK_PP_INVALID_TYPE; \
128 glInitFuncs \
129 while (ptIds < endPtIds) \
130 { \
131 nPts = *ptIds; \
132 ++ptIds; \
133 vtkOpenGLBeginPolyTriangleOrQuad( prim, previousPrimitive, nPts, device); \
134 glCellFuncs \
135 while (nPts > 0) \
136 { \
137 glVertFuncs \
138 ++ptIds; \
139 --nPts; \
140 } \
141 cellNum++;\
142 if (++count == 10000) \
143 { \
144 count = 0; \
145 this->UpdateProgress(static_cast<double>(cellNum-cellNumStart)/totalCells);\
146 if (ren->GetRenderWindow()->CheckAbortStatus()) \
147 { \
148 break; \
149 } \
150 } \
151 if ((previousPrimitive != VTK_TRIANGLE) \
152 && (previousPrimitive != VTK_QUAD) \
153 && (previousPrimitive != VTK_VERTEX)) \
154 { \
155 device->EndPrimitive(); \
156 } \
157 } \
158 if ((previousPrimitive == VTK_TRIANGLE) \
159 || (previousPrimitive == VTK_QUAD) \
160 || (previousPrimitive == VTK_VERTEX)) \
161 { \
162 device->EndPrimitive(); \
163 } \
164 }
165
166 //-----------------------------------------------------------------------------
167 // used to build normals when normals are missing.
168 #define PolyNormal \
169 { double polyNorm[3]; vtkPolygon::ComputeNormal(p,nPts,ptIds,polyNorm); \
170 device->SendAttribute(vtkPointData::NORMALS, 3, VTK_DOUBLE, polyNorm); }
171
172 //-----------------------------------------------------------------------------
RenderPrimitive(unsigned long idx,vtkDataArray * n,vtkUnsignedCharArray * c,vtkDataArray * t,vtkRenderer * ren)173 int vtkPolygonsPainter::RenderPrimitive(unsigned long idx, vtkDataArray* n,
174 vtkUnsignedCharArray* c, vtkDataArray* t, vtkRenderer* ren)
175 {
176 vtkPolyData* pd = this->GetInputAsPolyData();
177 vtkPoints* p = pd->GetPoints();
178 vtkCellArray* ca = pd->GetPolys();
179 vtkIdType cellNum = pd->GetVerts()->GetNumberOfCells() +
180 pd->GetLines()->GetNumberOfCells();
181 vtkIdType cellNumStart = cellNum;
182 vtkIdType totalCells = ca->GetNumberOfCells();
183 vtkUnsignedCharArray *ef = vtkUnsignedCharArray::SafeDownCast(
184 pd->GetPointData()->GetAttribute(vtkDataSetAttributes::EDGEFLAG));
185
186 vtkPainterDeviceAdapter* device = ren->GetRenderWindow()->
187 GetPainterDeviceAdapter();
188 void *points = p->GetVoidPointer(0);
189 void *normals = 0;
190 void *tcoords = 0;
191 unsigned char *colors = 0;
192 unsigned char *edgeflags = 0;
193 int primitive = VTK_POLYGON;
194
195 if (ca->GetNumberOfCells() == 0)
196 {
197 return 1;
198 }
199 if (n)
200 {
201 normals = n->GetVoidPointer(0);
202 }
203 if (c)
204 {
205 colors = c->GetPointer(0);
206 // if these are cell colors then advance to the first cell
207 if (idx & VTK_PDM_CELL_COLORS)
208 {
209 colors = colors + cellNum*4;
210 }
211 }
212 if (t)
213 {
214 tcoords = t->GetVoidPointer(0);
215 }
216 if (ef)
217 {
218 edgeflags = ef->GetPointer(0);
219 }
220 vtkIdType *ptIds = ca->GetPointer();
221 vtkIdType *endPtIds = ptIds + ca->GetNumberOfConnectivityEntries();
222 int ptype = p->GetDataType();
223 int ntype = (n)? n->GetDataType() : 0;
224 int ttype = (t)? t->GetDataType() : 0;
225 int tcomps = (t)? t->GetNumberOfComponents() : 0;
226 int eftype = (ef)? ef->GetDataType() : 0;
227 int celloffset = 0;
228
229 // since this painter does not deal with field colors specially,
230 // we just ignore the flag.
231 idx &= (~VTK_PDM_FIELD_COLORS);
232
233 // draw all the elements, use fast path if available
234 switch (idx)
235 {
236 case 0:
237 if (this->BuildNormals)
238 {
239 vtkDrawPolysMacro(primitive,
240 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
241 ptype, points, 3**ptIds);, PolyNormal,;);
242 }
243 else
244 {
245 vtkDrawPolysMacro(primitive,
246 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
247 ptype, points, 3**ptIds);, ;,;);
248 }
249 break;
250
251 case VTK_PDM_NORMALS:
252 vtkDrawPolysMacro(primitive,
253 device->SendAttribute(vtkPointData::NORMALS, 3,
254 ntype, normals, 3**ptIds);
255 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
256 ptype, points, 3**ptIds);,;,;);
257 break;
258
259 case VTK_PDM_COLORS:
260 if (this->BuildNormals)
261 {
262 vtkDrawPolysMacro(primitive,
263 device->SendAttribute(vtkPointData::SCALARS, 4,
264 VTK_UNSIGNED_CHAR, colors + 4**ptIds);
265 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
266 ptype, points, 3**ptIds);,
267 PolyNormal,;);
268 }
269 else
270 {
271 vtkDrawPolysMacro(primitive,
272 device->SendAttribute(vtkPointData::SCALARS, 4,
273 VTK_UNSIGNED_CHAR, colors + 4**ptIds);
274 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
275 ptype, points, 3**ptIds);,
276 ;,;);
277 }
278 break;
279 case VTK_PDM_COLORS | VTK_PDM_OPAQUE_COLORS:
280 if (this->BuildNormals)
281 {
282 vtkDrawPolysMacro(primitive,
283 device->SendAttribute(vtkPointData::SCALARS, 3,
284 VTK_UNSIGNED_CHAR, colors + 4**ptIds);
285 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
286 ptype, points, 3**ptIds);,
287 PolyNormal,;);
288 }
289 else
290 {
291 vtkDrawPolysMacro(primitive,
292 device->SendAttribute(vtkPointData::SCALARS, 3,
293 VTK_UNSIGNED_CHAR, colors + 4**ptIds);
294 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
295 ptype, points, 3**ptIds);,
296 ;,;);
297 }
298 break;
299 case VTK_PDM_NORMALS | VTK_PDM_COLORS:
300 vtkDrawPolysMacro(primitive,
301 device->SendAttribute(vtkPointData::NORMALS, 3,
302 ntype, normals, 3**ptIds);
303 device->SendAttribute(vtkPointData::SCALARS, 4,
304 VTK_UNSIGNED_CHAR, colors + 4**ptIds);
305 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
306 ptype, points, 3**ptIds);,;,;);
307 break;
308 case VTK_PDM_NORMALS | VTK_PDM_COLORS | VTK_PDM_OPAQUE_COLORS:
309 vtkDrawPolysMacro(primitive,
310 device->SendAttribute(vtkPointData::NORMALS, 3,
311 ntype, normals, 3**ptIds);
312 device->SendAttribute(vtkPointData::SCALARS, 3,
313 VTK_UNSIGNED_CHAR, colors + 4**ptIds);
314 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
315 ptype, points, 3**ptIds);,;,;);
316 break;
317 case VTK_PDM_NORMALS | VTK_PDM_TCOORDS:
318 vtkDrawPolysMacro(primitive,
319 device->SendAttribute(vtkPointData::NORMALS, 3,
320 ntype, normals, 3**ptIds);
321 device->SendAttribute(vtkPointData::TCOORDS, tcomps,
322 ttype, tcoords, tcomps**ptIds);
323 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
324 ptype, points, 3**ptIds);,;,;);
325 break;
326 case VTK_PDM_CELL_NORMALS | VTK_PDM_TCOORDS:
327 vtkDrawPolysMacro(primitive,
328 device->SendAttribute(vtkPointData::TCOORDS, tcomps,
329 ttype, tcoords, tcomps**ptIds);
330 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
331 ptype, points, 3**ptIds);,
332 device->SendAttribute(vtkPointData::NORMALS, 3,
333 ntype, normals, 3*celloffset); celloffset++;,
334 celloffset = cellNum;);
335 break;
336 case VTK_PDM_TCOORDS:
337 if (this->BuildNormals)
338 {
339 vtkDrawPolysMacro(primitive,
340 device->SendAttribute(vtkPointData::TCOORDS, tcomps,
341 ttype, tcoords, tcomps**ptIds);
342 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
343 ptype, points, 3**ptIds);,
344 PolyNormal,;);
345 }
346 else
347 {
348 vtkDrawPolysMacro(primitive,
349 device->SendAttribute(vtkPointData::TCOORDS, 1,
350 ttype, tcoords, *ptIds);
351 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
352 ptype, points, 3**ptIds);,
353 ;,;);
354 }
355 break;
356 case VTK_PDM_CELL_NORMALS:
357 vtkDrawPolysMacro(primitive,
358 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
359 ptype, points, 3**ptIds);,
360 device->SendAttribute(vtkPointData::NORMALS, 3,
361 ntype, normals, 3*celloffset); celloffset++;,
362 celloffset = cellNum;);
363 break;
364 case VTK_PDM_CELL_NORMALS | VTK_PDM_COLORS:
365 vtkDrawPolysMacro(primitive,
366 device->SendAttribute(vtkPointData::SCALARS, 4,
367 VTK_UNSIGNED_CHAR, colors + 4**ptIds);
368 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
369 ptype, points, 3**ptIds);,
370 device->SendAttribute(vtkPointData::NORMALS, 3,
371 ntype, normals, 3*celloffset); celloffset++;,
372 celloffset = cellNum;);
373 break;
374 case VTK_PDM_CELL_NORMALS | VTK_PDM_COLORS | VTK_PDM_OPAQUE_COLORS:
375 vtkDrawPolysMacro(primitive,
376 device->SendAttribute(vtkPointData::SCALARS, 3,
377 VTK_UNSIGNED_CHAR, colors + 4**ptIds);
378 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
379 ptype, points, 3**ptIds);,
380 device->SendAttribute(vtkPointData::NORMALS, 3,
381 ntype, normals, 3*celloffset); celloffset++;,
382 celloffset = cellNum;);
383 break;
384 case VTK_PDM_NORMALS | VTK_PDM_COLORS | VTK_PDM_CELL_COLORS:
385 vtkDrawPolysMacro(primitive,
386 device->SendAttribute(vtkPointData::NORMALS, 3,
387 ntype, normals, 3**ptIds);
388 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
389 ptype, points, 3**ptIds);,
390 device->SendAttribute(vtkPointData::SCALARS, 4,
391 VTK_UNSIGNED_CHAR, colors); colors += 4;,;);
392 break;
393 case VTK_PDM_NORMALS | VTK_PDM_COLORS | VTK_PDM_OPAQUE_COLORS | VTK_PDM_CELL_COLORS:
394 vtkDrawPolysMacro(primitive,
395 device->SendAttribute(vtkPointData::NORMALS, 3,
396 ntype, normals, 3**ptIds);
397 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
398 ptype, points, 3**ptIds);,
399 device->SendAttribute(vtkPointData::SCALARS, 3,
400 VTK_UNSIGNED_CHAR, colors); colors += 4;,;);
401 break;
402 case VTK_PDM_CELL_NORMALS | VTK_PDM_COLORS | VTK_PDM_CELL_COLORS:
403 vtkDrawPolysMacro(primitive,
404 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
405 ptype, points, 3**ptIds);,
406 device->SendAttribute(vtkPointData::NORMALS, 3,
407 ntype, normals, 3*celloffset); celloffset++;
408 device->SendAttribute(vtkPointData::SCALARS, 4,
409 VTK_UNSIGNED_CHAR, colors); colors += 4;,
410 celloffset = cellNum;);
411 break;
412 case VTK_PDM_CELL_NORMALS | VTK_PDM_COLORS | VTK_PDM_OPAQUE_COLORS | VTK_PDM_CELL_COLORS:
413 vtkDrawPolysMacro(primitive,
414 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
415 ptype, points, 3**ptIds);,
416 device->SendAttribute(vtkPointData::NORMALS, 3,
417 ntype, normals, 3*celloffset); celloffset++;
418 device->SendAttribute(vtkPointData::SCALARS, 3,
419 VTK_UNSIGNED_CHAR, colors); colors += 4;,
420 celloffset = cellNum;);
421 break;
422
423 case VTK_PDM_EDGEFLAGS:
424 if (this->BuildNormals)
425 {
426 vtkDrawPolysMacro(primitive,
427 device->SendAttribute(vtkPointData::EDGEFLAG, 1,
428 eftype, edgeflags, *ptIds);
429 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
430 ptype, points, 3**ptIds);,
431 PolyNormal,;);
432 }
433 else
434 {
435 vtkDrawPolysMacro(primitive,
436 device->SendAttribute(vtkPointData::EDGEFLAG, 1,
437 eftype, edgeflags, *ptIds);
438 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
439 ptype, points, 3**ptIds);, ;,;);
440 }
441 break;
442
443 case VTK_PDM_NORMALS | VTK_PDM_EDGEFLAGS:
444 vtkDrawPolysMacro(primitive,
445 device->SendAttribute(vtkPointData::EDGEFLAG, 1,
446 eftype, edgeflags, *ptIds);
447 device->SendAttribute(vtkPointData::NORMALS, 3,
448 ntype, normals, 3**ptIds);
449 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
450 ptype, points, 3**ptIds);,;,;);
451 break;
452
453 case VTK_PDM_COLORS | VTK_PDM_EDGEFLAGS:
454 if (this->BuildNormals)
455 {
456 vtkDrawPolysMacro(primitive,
457 device->SendAttribute(vtkPointData::EDGEFLAG, 1,
458 eftype, edgeflags, *ptIds);
459 device->SendAttribute(vtkPointData::SCALARS, 4,
460 VTK_UNSIGNED_CHAR,
461 colors + 4**ptIds);
462 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
463 ptype, points, 3**ptIds);,
464 PolyNormal,;);
465 }
466 else
467 {
468 vtkDrawPolysMacro(primitive,
469 device->SendAttribute(vtkPointData::EDGEFLAG, 1,
470 eftype, edgeflags, *ptIds);
471 device->SendAttribute(vtkPointData::SCALARS, 4,
472 VTK_UNSIGNED_CHAR,
473 colors + 4**ptIds);
474 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
475 ptype, points, 3**ptIds);,
476 ;,;);
477 }
478 break;
479 case VTK_PDM_COLORS | VTK_PDM_OPAQUE_COLORS | VTK_PDM_EDGEFLAGS:
480 if (this->BuildNormals)
481 {
482 vtkDrawPolysMacro(primitive,
483 device->SendAttribute(vtkPointData::EDGEFLAG, 1,
484 eftype, edgeflags, *ptIds);
485 device->SendAttribute(vtkPointData::SCALARS, 3,
486 VTK_UNSIGNED_CHAR,
487 colors + 4**ptIds);
488 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
489 ptype, points, 3**ptIds);,
490 PolyNormal,;);
491 }
492 else
493 {
494 vtkDrawPolysMacro(primitive,
495 device->SendAttribute(vtkPointData::EDGEFLAG, 1,
496 eftype, edgeflags, *ptIds);
497 device->SendAttribute(vtkPointData::SCALARS, 3,
498 VTK_UNSIGNED_CHAR,
499 colors + 4**ptIds);
500 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
501 ptype, points, 3**ptIds);,
502 ;,;);
503 }
504 break;
505 case VTK_PDM_NORMALS | VTK_PDM_COLORS | VTK_PDM_EDGEFLAGS:
506 vtkDrawPolysMacro(primitive,
507 device->SendAttribute(vtkPointData::EDGEFLAG, 1,
508 eftype, edgeflags, *ptIds);
509 device->SendAttribute(vtkPointData::NORMALS, 3,
510 ntype, normals, 3**ptIds);
511 device->SendAttribute(vtkPointData::SCALARS, 4,
512 VTK_UNSIGNED_CHAR,
513 colors + 4**ptIds);
514 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
515 ptype, points, 3**ptIds);,;,;);
516 break;
517 case VTK_PDM_NORMALS | VTK_PDM_COLORS | VTK_PDM_OPAQUE_COLORS | VTK_PDM_EDGEFLAGS:
518 vtkDrawPolysMacro(primitive,
519 device->SendAttribute(vtkPointData::EDGEFLAG, 1,
520 eftype, edgeflags, *ptIds);
521 device->SendAttribute(vtkPointData::NORMALS, 3,
522 ntype, normals, 3**ptIds);
523 device->SendAttribute(vtkPointData::SCALARS, 3,
524 VTK_UNSIGNED_CHAR,
525 colors + 4**ptIds);
526 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
527 ptype, points, 3**ptIds);,;,;);
528 break;
529 case VTK_PDM_NORMALS | VTK_PDM_TCOORDS | VTK_PDM_EDGEFLAGS:
530 vtkDrawPolysMacro(primitive,
531 device->SendAttribute(vtkPointData::EDGEFLAG, 1,
532 eftype, edgeflags, *ptIds);
533 device->SendAttribute(vtkPointData::NORMALS, 3,
534 ntype, normals, 3**ptIds);
535 device->SendAttribute(vtkPointData::TCOORDS, tcomps,
536 ttype, tcoords, tcomps**ptIds);
537 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
538 ptype, points, 3**ptIds);,;,;);
539 break;
540 case VTK_PDM_CELL_NORMALS | VTK_PDM_TCOORDS | VTK_PDM_EDGEFLAGS:
541 vtkDrawPolysMacro(primitive,
542 device->SendAttribute(vtkPointData::EDGEFLAG, 1,
543 eftype, edgeflags, *ptIds);
544 device->SendAttribute(vtkPointData::TCOORDS, tcomps,
545 ttype, tcoords, tcomps**ptIds);
546 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
547 ptype, points, 3**ptIds);,
548 device->SendAttribute(vtkPointData::NORMALS, 3,
549 ntype, normals, 3*celloffset);
550 celloffset++;,
551 celloffset = cellNum;);
552 break;
553 case VTK_PDM_TCOORDS | VTK_PDM_EDGEFLAGS:
554 if (this->BuildNormals)
555 {
556 vtkDrawPolysMacro(primitive,
557 device->SendAttribute(vtkPointData::EDGEFLAG, 1,
558 eftype, edgeflags, *ptIds);
559 device->SendAttribute(vtkPointData::TCOORDS, tcomps,
560 ttype, tcoords, tcomps**ptIds);
561 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
562 ptype, points, 3**ptIds);,
563 PolyNormal,;);
564 }
565 else
566 {
567 vtkDrawPolysMacro(primitive,
568 device->SendAttribute(vtkPointData::EDGEFLAG, 1,
569 eftype, edgeflags, *ptIds);
570 device->SendAttribute(vtkPointData::TCOORDS, 1,
571 ttype, tcoords, *ptIds);
572 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
573 ptype, points, 3**ptIds);,
574 ;,;);
575 }
576 break;
577 case VTK_PDM_CELL_NORMALS | VTK_PDM_EDGEFLAGS:
578 vtkDrawPolysMacro(primitive,
579 device->SendAttribute(vtkPointData::EDGEFLAG, 1,
580 eftype, edgeflags, *ptIds);
581 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
582 ptype, points, 3**ptIds);,
583 device->SendAttribute(vtkPointData::NORMALS, 3,
584 ntype, normals, 3*celloffset);
585 celloffset++;,
586 celloffset = cellNum;);
587 break;
588 case VTK_PDM_CELL_NORMALS | VTK_PDM_COLORS | VTK_PDM_EDGEFLAGS:
589 vtkDrawPolysMacro(primitive,
590 device->SendAttribute(vtkPointData::EDGEFLAG, 1,
591 eftype, edgeflags, *ptIds);
592 device->SendAttribute(vtkPointData::SCALARS, 4,
593 VTK_UNSIGNED_CHAR,
594 colors + 4**ptIds);
595 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
596 ptype, points, 3**ptIds);,
597 device->SendAttribute(vtkPointData::NORMALS, 3,
598 ntype, normals, 3*celloffset);
599 celloffset++;,
600 celloffset = cellNum;);
601 break;
602 case VTK_PDM_CELL_NORMALS | VTK_PDM_COLORS | VTK_PDM_OPAQUE_COLORS | VTK_PDM_EDGEFLAGS:
603 vtkDrawPolysMacro(primitive,
604 device->SendAttribute(vtkPointData::EDGEFLAG, 1,
605 eftype, edgeflags, *ptIds);
606 device->SendAttribute(vtkPointData::SCALARS, 3,
607 VTK_UNSIGNED_CHAR,
608 colors + 4**ptIds);
609 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
610 ptype, points, 3**ptIds);,
611 device->SendAttribute(vtkPointData::NORMALS, 3,
612 ntype, normals, 3*celloffset);
613 celloffset++;,
614 celloffset = cellNum;);
615 break;
616 case VTK_PDM_NORMALS | VTK_PDM_COLORS | VTK_PDM_CELL_COLORS | VTK_PDM_EDGEFLAGS:
617 vtkDrawPolysMacro(primitive,
618 device->SendAttribute(vtkPointData::EDGEFLAG, 1,
619 eftype, edgeflags, *ptIds);
620 device->SendAttribute(vtkPointData::NORMALS, 3,
621 ntype, normals, 3**ptIds);
622 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
623 ptype, points, 3**ptIds);,
624 device->SendAttribute(vtkPointData::SCALARS, 4,
625 VTK_UNSIGNED_CHAR, colors);
626 colors += 4;,;);
627 break;
628 case VTK_PDM_NORMALS | VTK_PDM_COLORS | VTK_PDM_OPAQUE_COLORS | VTK_PDM_CELL_COLORS | VTK_PDM_EDGEFLAGS:
629 vtkDrawPolysMacro(primitive,
630 device->SendAttribute(vtkPointData::EDGEFLAG, 1,
631 eftype, edgeflags, *ptIds);
632 device->SendAttribute(vtkPointData::NORMALS, 3,
633 ntype, normals, 3**ptIds);
634 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
635 ptype, points, 3**ptIds);,
636 device->SendAttribute(vtkPointData::SCALARS, 3,
637 VTK_UNSIGNED_CHAR, colors);
638 colors += 4;,;);
639 break;
640 case VTK_PDM_CELL_NORMALS | VTK_PDM_COLORS | VTK_PDM_CELL_COLORS | VTK_PDM_EDGEFLAGS:
641 vtkDrawPolysMacro(primitive,
642 device->SendAttribute(vtkPointData::EDGEFLAG, 1,
643 eftype, edgeflags, *ptIds);
644 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
645 ptype, points, 3**ptIds);,
646 device->SendAttribute(vtkPointData::NORMALS, 3,
647 ntype, normals, 3*celloffset);
648 celloffset++;
649 device->SendAttribute(vtkPointData::SCALARS, 4,
650 VTK_UNSIGNED_CHAR, colors);
651 colors += 4;,
652 celloffset = cellNum;);
653 break;
654 case VTK_PDM_CELL_NORMALS | VTK_PDM_COLORS | VTK_PDM_OPAQUE_COLORS | VTK_PDM_CELL_COLORS | VTK_PDM_EDGEFLAGS:
655 vtkDrawPolysMacro(primitive,
656 device->SendAttribute(vtkPointData::EDGEFLAG, 1,
657 eftype, edgeflags, *ptIds);
658 device->SendAttribute(vtkPointData::NUM_ATTRIBUTES, 3,
659 ptype, points, 3**ptIds);,
660 device->SendAttribute(vtkPointData::NORMALS, 3,
661 ntype, normals, 3*celloffset);
662 celloffset++;
663 device->SendAttribute(vtkPointData::SCALARS, 3,
664 VTK_UNSIGNED_CHAR, colors);
665 colors += 4;,
666 celloffset = cellNum;);
667 break;
668
669 default:
670 return 0; // let the delegate painter handle it.
671 }
672
673 if (idx & VTK_PDM_EDGEFLAGS)
674 {
675 // Reset the edge flag to 1 so that if the next thing rendered does not
676 // have an edge flag, it will have all edges on.
677 unsigned char edgeflag = 1;
678 device->SendAttribute(vtkPointData::EDGEFLAG, 1, VTK_UNSIGNED_CHAR,
679 &edgeflag, 0);
680 }
681
682 return 1;
683 }
684
685 //-----------------------------------------------------------------------------
PrintSelf(ostream & os,vtkIndent indent)686 void vtkPolygonsPainter::PrintSelf(ostream& os, vtkIndent indent)
687 {
688 this->Superclass::PrintSelf(os, indent);
689 }
690