summaryrefslogtreecommitdiff
path: root/xc/programs/Xserver/PEX5/include/ddpex3.h
blob: cb8af4c0902e7d77211e065a235bde56eabfa36e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
/* $XConsortium: ddpex3.h,v 5.2 94/04/17 20:35:55 rws Exp $ */

/***********************************************************

Copyright (c) 1989, 1990, 1991  X Consortium

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of the X Consortium shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the X Consortium.

Copyright 1989, 1990, 1991 by Sun Microsystems, Inc. 

                        All Rights Reserved

Permission to use, copy, modify, and distribute this software and its 
documentation for any purpose and without fee is hereby granted, 
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in 
supporting documentation, and that the name of Sun Microsystems,
not be used in advertising or publicity pertaining to distribution of 
the software without specific, written prior permission.  

SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT 
SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.

******************************************************************/

#include "ddpex.h"

#ifndef DDPEX3_H
#define DDPEX3_H

/* just a reminder of what colours there are
        IndexedColour
        Rgb8Colour
        Rgb16Colour
        RgbFloatColour
        HsvColour
        HlsColour
        CieColour
*/

/* First, some basic point type definitions */
/* #define		DDPT_FLOAT		(0<<0) */
#define		DDPT_SHORT		(1<<0)
#define		DDPT_2D			(1<<1)
#define		DDPT_3D			(2<<1)
#define		DDPT_4D			(3<<1)
#define		DDPT_NORMAL		(1<<3)
#define		DDPT_EDGE		(1<<4)
#define		DDPT_COLOUR		(7<<5)
#define		DDPT_INDEXEDCOLOUR	(1<<5)
#define		DDPT_RGB8COLOUR 	(2<<5)
#define		DDPT_RGB16COLOUR 	(3<<5)
#define		DDPT_RGBFLOATCOLOUR 	(4<<5)
#define		DDPT_HSVCOLOUR 		(5<<5)
#define		DDPT_HLSCOLOUR 		(6<<5)
#define		DDPT_CIECOLOUR 		(7<<5)

/* 
 * Now, some access macros 
 * It is strongly recommended that these macros be used instead
 * of accessing the fields directly.
 */
#define	DD_IsVertFloat(type)	(!((type) & DDPT_SHORT))
#define DD_IsVertShort(type)	((type) & DDPT_SHORT)
#define DD_IsVert2D(type)	(((type) & DDPT_4D) == DDPT_2D)
#define DD_IsVert3D(type)	(((type) & DDPT_4D) == DDPT_3D)
#define DD_IsVert4D(type)	(((type) & DDPT_4D) == DDPT_4D)
#define DD_IsVertNormal(type)	((type) & DDPT_NORMAL)
#define DD_IsVertEdge(type)	((type) & DDPT_EDGE)
#define DD_IsVertColour(type)	((type) & DDPT_COLOUR)
#define DD_IsVertIndexed(type)	(((type) & DDPT_COLOUR) == DDPT_INDEXEDCOLOUR)
#define DD_IsVertRGB8(type)	(((type) & DDPT_COLOUR) == DDPT_RGB8COLOUR)
#define DD_IsVertRGB16(type)	(((type) & DDPT_COLOUR) == DDPT_RGB16COLOUR)
#define DD_IsVertRGBFLOAT(type)	(((type)&DDPT_COLOUR) == DDPT_RGBFLOATCOLOUR)
#define DD_IsVertHSV(type)	(((type) & DDPT_COLOUR) == DDPT_HSVCOLOUR)
#define DD_IsVertHLS(type)	(((type) & DDPT_COLOUR) == DDPT_HLSCOLOUR)
#define DD_IsVertCIE(type)	(((type) & DDPT_COLOUR) == DDPT_CIECOLOUR)

#define DD_IsVertCoordsOnly(type) 					\
	!((type & DDPT_COLOUR) || (type & DDPT_EDGE) || (type & DDPT_NORMAL)) 

/*
 * These macros are used to change a vertex type
 */
#define	DD_SetVertFloat(type)	((type) &= ~DDPT_SHORT)
#define DD_SetVertShort(type)	((type) |= DDPT_SHORT)
#define DD_SetVert2D(type)	((type) = (((type) & ~DDPT_4D) | DDPT_2D))
#define DD_SetVert3D(type)	((type) = (((type) & ~DDPT_4D) | DDPT_3D))
#define DD_SetVert4D(type)	((type) = (((type) & ~DDPT_4D) | DDPT_4D))
#define DD_SetVertNormal(type)	((type) |= DDPT_NORMAL)
#define DD_SetVertEdge(type)	((type) |= DDPT_EDGE)
#define DD_SetVertIndexed(type)	((type)=(((type) & ~DDPT_COLOUR) | DDPT_INDEXEDCOLOUR))
#define DD_SetVertRGB8(type)	((type)=(((type) & ~DDPT_COLOUR) | DDPT_RGB8COLOUR))
#define DD_SetVertRGB16(type)	((type)=(((type) & ~DDPT_COLOUR) | DDPT_RGB16COLOUR))
#define DD_SetVertRGBFLOAT(type) ((type)=(((type) & ~DDPT_COLOUR) | DDPT_RGBFLOATCOLOUR))
#define DD_SetVertHSV(type)	((type)=(((type) & ~DDPT_COLOUR) | DDPT_HSVCOLOUR))
#define DD_SetVertHLS(type)	((type)=(((type) & ~DDPT_COLOUR) | DDPT_HLSCOLOUR))
#define DD_SetVertCIE(type)	((type)=(((type) & ~DDPT_COLOUR) | DDPT_CIECOLOUR))

#define	DD_UnSetVertFloat(type)		((type) |= DDPT_SHORT)
#define DD_UnSetVertShort(type)		((type) &= ~DDPT_SHORT)
#define DD_UnSetVert2D(type)		((type) &= ~DDPT_4D)
#define DD_UnSetVert3D(type)		((type) &= ~DDPT_4D)
#define DD_UnSetVert4D(type)		((type) &= ~DDPT_4D)
#define DD_UnSetVertCoord(type)		((type) &= ~(DDPT_4D | DDPT_SHORT))
#define DD_UnSetVertNormal(type) 	((type) &= ~DDPT_NORMAL)
#define DD_UnSetVertEdge(type)		((type) &= ~DDPT_EDGE)
#define DD_UnSetColour(type)		((type) &= ~DDPT_COLOUR)
#define DD_UnSetVertIndexed(type) 	((type) &= ~DDPT_COLOUR)
#define DD_UnSetVertRGB8(type)		((type) &= ~DDPT_COLOUR)
#define DD_UnSetVertRGB16(type)		((type) &= ~DDPT_COLOUR)
#define DD_UnSetVertRGBFLOAT(type) 	((type) &= ~DDPT_COLOUR)
#define DD_UnSetVertHSV(type)		((type) &= ~DDPT_COLOUR)
#define DD_UnSetVertHLS(type)		((type) &= ~DDPT_COLOUR)
#define DD_UnSetVertCIE(type)		((type) &= ~DDPT_COLOUR)


/*
 * A macro to compute the point size - very usefull when
 * walking through a list of points and one isn't concerned
 * about the actual details of the point data
 */
#define DD_VertPointSize(type, size)					\
       {								\
	if (DD_IsVertFloat(type)) {					\
	  if (DD_IsVert2D(type)) size = sizeof(ddCoord2D);		\
	  else if (DD_IsVert3D(type)) size = sizeof(ddCoord3D);		\
	  else size = sizeof(ddCoord4D);				\
	} else {							\
	  if (DD_IsVert2D(type)) size = sizeof(ddCoord2DS);		\
	  else size = sizeof(ddCoord3DS);				\
	} 								\
	if (DD_IsVertNormal(type)) size += sizeof(ddVector3D);		\
	if (DD_IsVertColour(type)) {					\
	  if (DD_IsVertIndexed(type)) size += sizeof(ddIndexedColour);	\
	  else if (DD_IsVertRGB8(type)) size += sizeof(ddRgb8Colour);	\
	  else if (DD_IsVertRGB16(type)) size += sizeof(ddRgb16Colour);	\
	  else size += sizeof(ddRgbFloatColour);			\
	} 								\
	if (DD_IsVertEdge(type)) size += sizeof(ddULONG);		\
       }
/*
 * The following macros find offets from the start
 * of a structure in bytes to the desired vertex component.
 * again, very usefull macros for routines that wish
 * to access individual vertex components without necessarily
 * knowing all the details of the vertex. Offset is set to -1 
 * if the component does not exist in the vertex.
 */

/* 
 * Note that the color is always the first component following
 * the vertex data.
 */
#define DD_VertOffsetColor(type, offset)				\
	{								\
	 if (!DD_IsVertColour((type))) (offset) = -1;			\
	 else 								\
	   DD_VertPointSize(((type) & (DDPT_4D | DDPT_SHORT)),(offset));\
	}

/*
 * Note that the edge flag is always the last component in
 * a vertex. Thus the offset is the size of the point minus
 * the size of the edge field (a ddULONG).
 */
#define DD_VertOffsetEdge(type, offset)					\
	{								\
	 if (!DD_IsVertEdge((type))) (offset) = -1;			\
	 else { 							\
	   DD_VertPointSize((type), (offset));				\
	   (offset) -= sizeof(ddULONG);					\
	 }								\
	}

/*
 * This one is the most complex as the normal is last unless
 * there is an edge in which case it preceeds the edge flag.
 */
#define DD_VertOffsetNormal(type, offset)				\
	{								\
	 if (!DD_IsVertNormal((type))) (offset) = -1;			\
	 else { 							\
	   DD_VertPointSize((type), (offset));				\
	   if (DD_IsVertEdge((type))) (offset) -= sizeof(ddULONG);	\
	   (offset) -= sizeof(ddVector3D);				\
	 }								\
	}

/* Now create the point types */
#define  DD_2DS_POINT   		(DDPT_SHORT | DDPT_2D)
#define  DD_2D_POINT    		(DDPT_2D)
#define  DD_3DS_POINT   		(DDPT_SHORT | DDPT_3D)
#define  DD_3D_POINT    		(DDPT_3D)
#define  DD_INDEX_POINT  		(DDPT_3D | DDPT_INDEXEDCOLOUR)
#define  DD_INDEX_POINT4D  		(DDPT_4D | DDPT_INDEXEDCOLOUR)
#define  DD_RGB8_POINT  		(DDPT_3D | DDPT_RGB8COLOUR)
#define  DD_RGB8_POINT4D  		(DDPT_4D | DDPT_RGB8COLOUR)
#define  DD_RGB16_POINT  		(DDPT_3D | DDPT_RGB16COLOUR)
#define  DD_RGB16_POINT4D  		(DDPT_4D | DDPT_RGB16COLOUR)
#define  DD_RGBFLOAT_POINT2DS  		(DDPT_SHORT | DDPT_2D | DDPT_RGBFLOATCOLOUR)
#define  DD_RGBFLOAT_POINT  		(DDPT_3D | DDPT_RGBFLOATCOLOUR)
#define  DD_RGBFLOAT_POINT4D  		(DDPT_4D | DDPT_RGBFLOATCOLOUR)
#define  DD_HSV_POINT2DS  		(DDPT_SHORT | DDPT_2D | DDPT_HSVCOLOUR)
#define  DD_HSV_POINT  			(DDPT_3D | DDPT_HSVCOLOUR)
#define  DD_HSV_POINT4D  		(DDPT_4D | DDPT_HSVCOLOUR)
#define  DD_HLS_POINT2DS  		(DDPT_SHORT | DDPT_2D | DDPT_HLSCOLOUR)
#define  DD_HLS_POINT  			(DDPT_3D | DDPT_HLSCOLOUR)
#define  DD_HLS_POINT4D  		(DDPT_4D | DDPT_HLSCOLOUR)
#define  DD_CIE_POINT2DS  		(DDPT_SHORT | DDPT_2D | DDPT_CIECOLOUR)
#define  DD_CIE_POINT  			(DDPT_3D | DDPT_CIECOLOUR)
#define  DD_CIE_POINT4D  		(DDPT_4D | DDPT_CIECOLOUR)
#define  DD_NORM_POINT2DS  		(DDPT_SHORT | DDPT_2D | DDPT_NORMAL)
#define  DD_NORM_POINT  		(DDPT_3D | DDPT_NORMAL)
#define  DD_NORM_POINT4D  		(DDPT_4D | DDPT_NORMAL)
#define  DD_EDGE_POINT2DS  		(DDPT_SHORT | DDPT_2D | DDPT_EDGE)
#define  DD_EDGE_POINT  		(DDPT_3D | DDPT_EDGE)
#define  DD_EDGE_POINT4D  		(DDPT_4D | DDPT_EDGE)
#define  DD_INDEX_NORM_POINT  		(DDPT_3D | DDPT_NORMAL | DDPT_INDEXEDCOLOUR)
#define  DD_INDEX_NORM_POINT4D  	(DDPT_4D | DDPT_NORMAL | DDPT_INDEXEDCOLOUR)
#define  DD_RGB8_NORM_POINT  		(DDPT_3D | DDPT_NORMAL | DDPT_RGB8COLOUR)
#define  DD_RGB8_NORM_POINT4D  		(DDPT_4D | DDPT_NORMAL | DDPT_RGB8COLOUR)
#define  DD_RGB16_NORM_POINT   		(DDPT_3D | DDPT_NORMAL | DDPT_RGB16COLOUR)
#define  DD_RGB16_NORM_POINT4D   	(DDPT_4D | DDPT_NORMAL | DDPT_RGB16COLOUR)
#define  DD_RGBFLOAT_NORM_POINT2DS   	(DDPT_SHORT | DDPT_2D | DDPT_NORMAL | DDPT_RGBFLOATCOLOUR)
#define  DD_RGBFLOAT_NORM_POINT   	(DDPT_3D | DDPT_NORMAL | DDPT_RGBFLOATCOLOUR)
#define  DD_RGBFLOAT_NORM_POINT4D   	(DDPT_4D | DDPT_NORMAL | DDPT_RGBFLOATCOLOUR)
#define  DD_HSV_NORM_POINT2DS  		(DDPT_SHORT | DDPT_2D | DDPT_NORMAL | DDPT_HSVCOLOUR)
#define  DD_HSV_NORM_POINT  		(DDPT_3D | DDPT_NORMAL | DDPT_HSVCOLOUR)
#define  DD_HSV_NORM_POINT4D  		(DDPT_4D | DDPT_NORMAL | DDPT_HSVCOLOUR)
#define  DD_HLS_NORM_POINT2DS  		(DDPT_SHORT | DDPT_2D | DDPT_NORMAL | DDPT_HLSCOLOUR)
#define  DD_HLS_NORM_POINT  		(DDPT_3D | DDPT_NORMAL | DDPT_HLSCOLOUR)
#define  DD_HLS_NORM_POINT4D  		(DDPT_4D | DDPT_NORMAL | DDPT_HLSCOLOUR)
#define  DD_CIE_NORM_POINT2DS  		(DDPT_SHORT | DDPT_2D | DDPT_NORMAL | DDPT_CIECOLOUR)
#define  DD_CIE_NORM_POINT  		(DDPT_3D | DDPT_NORMAL | DDPT_CIECOLOUR)
#define  DD_CIE_NORM_POINT4D  		(DDPT_4D | DDPT_NORMAL | DDPT_CIECOLOUR)
#define  DD_INDEX_EDGE_POINT  		(DDPT_3D | DDPT_EDGE | DDPT_INDEXEDCOLOUR)
#define  DD_INDEX_EDGE_POINT4D  	(DDPT_4D | DDPT_EDGE | DDPT_INDEXEDCOLOUR)
#define  DD_RGB8_EDGE_POINT  		(DDPT_3D | DDPT_EDGE | DDPT_RGB8COLOUR)
#define  DD_RGB8_EDGE_POINT4D  		(DDPT_4D | DDPT_EDGE | DDPT_RGB8COLOUR)
#define  DD_RGB16_EDGE_POINT  		(DDPT_3D | DDPT_EDGE | DDPT_RGB16COLOUR)
#define  DD_RGB16_EDGE_POINT4D  	(DDPT_4D | DDPT_EDGE | DDPT_RGB16COLOUR)
#define  DD_RGBFLOAT_EDGE_POINT2DS   	(DDPT_SHORT | DDPT_2D | DDPT_EDGE | DDPT_RGBFLOATCOLOUR)
#define  DD_RGBFLOAT_EDGE_POINT   	(DDPT_3D | DDPT_EDGE | DDPT_RGBFLOATCOLOUR)
#define  DD_RGBFLOAT_EDGE_POINT4D   	(DDPT_4D | DDPT_EDGE | DDPT_RGBFLOATCOLOUR)
#define  DD_HSV_EDGE_POINT2DS  		(DDPT_SHORT | DDPT_2D | DDPT_EDGE | DDPT_HSVCOLOUR)
#define  DD_HSV_EDGE_POINT  		(DDPT_3D | DDPT_EDGE | DDPT_HSVCOLOUR)
#define  DD_HSV_EDGE_POINT4D  		(DDPT_4D | DDPT_EDGE | DDPT_HSVCOLOUR)
#define  DD_HLS_EDGE_POINT2DS  		(DDPT_SHORT | DDPT_2D | DDPT_EDGE | DDPT_HLSCOLOUR)
#define  DD_HLS_EDGE_POINT  		(DDPT_3D | DDPT_EDGE | DDPT_HLSCOLOUR)
#define  DD_HLS_EDGE_POINT4D  		(DDPT_4D | DDPT_EDGE | DDPT_HLSCOLOUR)
#define  DD_CIE_EDGE_POINT2DS  		(DDPT_SHORT | DDPT_2D | DDPT_EDGE | DDPT_CIECOLOUR)
#define  DD_CIE_EDGE_POINT  		(DDPT_3D | DDPT_EDGE | DDPT_CIECOLOUR)
#define  DD_CIE_EDGE_POINT4D  		(DDPT_4D | DDPT_EDGE | DDPT_CIECOLOUR)
#define  DD_NORM_EDGE_POINT2DS  	(DDPT_SHORT | DDPT_2D | DDPT_NORMAL | DDPT_EDGE )
#define  DD_NORM_EDGE_POINT  		(DDPT_3D | DDPT_NORMAL | DDPT_EDGE )
#define  DD_NORM_EDGE_POINT4D  		(DDPT_4D | DDPT_NORMAL | DDPT_EDGE )
#define  DD_INDEX_NORM_EDGE_POINT  	(DDPT_3D | DDPT_NORMAL | DDPT_EDGE | DDPT_INDEXEDCOLOUR)
#define  DD_INDEX_NORM_EDGE_POINT4D  	(DDPT_4D | DDPT_NORMAL | DDPT_EDGE | DDPT_INDEXEDCOLOUR)
#define  DD_RGB8_NORM_EDGE_POINT  	(DDPT_3D | DDPT_NORMAL | DDPT_EDGE | DDPT_RGB8COLOUR)
#define  DD_RGB8_NORM_EDGE_POINT4D  	(DDPT_4D | DDPT_NORMAL | DDPT_EDGE | DDPT_RGB8COLOUR)
#define  DD_RGB16_NORM_EDGE_POINT  	(DDPT_3D | DDPT_NORMAL | DDPT_EDGE | DDPT_RGB16COLOUR)
#define  DD_RGB16_NORM_EDGE_POINT4D  	(DDPT_4D | DDPT_NORMAL | DDPT_EDGE | DDPT_RGB16COLOUR)
#define  DD_RGBFLOAT_NORM_EDGE_POINT2DS  	(DDPT_SHORT | DDPT_2D | DDPT_NORMAL | DDPT_EDGE | DDPT_RGBFLOATCOLOUR)
#define  DD_RGBFLOAT_NORM_EDGE_POINT  	(DDPT_3D | DDPT_NORMAL | DDPT_EDGE | DDPT_RGBFLOATCOLOUR)
#define  DD_RGBFLOAT_NORM_EDGE_POINT4D 	(DDPT_4D | DDPT_NORMAL | DDPT_EDGE | DDPT_RGBFLOATCOLOUR)
#define  DD_HSV_NORM_EDGE_POINT2DS   	(DDPT_SHORT | DDPT_2D | DDPT_NORMAL | DDPT_EDGE | DDPT_HSVCOLOUR)
#define  DD_HSV_NORM_EDGE_POINT   	(DDPT_3D | DDPT_NORMAL | DDPT_EDGE | DDPT_HSVCOLOUR)
#define  DD_HSV_NORM_EDGE_POINT4D   	(DDPT_4D | DDPT_NORMAL | DDPT_EDGE | DDPT_HSVCOLOUR)
#define  DD_HLS_NORM_EDGE_POINT2DS   	(DDPT_SHORT | DDPT_2D | DDPT_NORMAL | DDPT_EDGE | DDPT_HLSCOLOUR)
#define  DD_HLS_NORM_EDGE_POINT   	(DDPT_3D | DDPT_NORMAL | DDPT_EDGE | DDPT_HLSCOLOUR)
#define  DD_HLS_NORM_EDGE_POINT4D   	(DDPT_4D | DDPT_NORMAL | DDPT_EDGE | DDPT_HLSCOLOUR)
#define  DD_CIE_NORM_EDGE_POINT2DS   	(DDPT_SHORT | DDPT_2D | DDPT_NORMAL | DDPT_EDGE | DDPT_CIECOLOUR)
#define  DD_CIE_NORM_EDGE_POINT   	(DDPT_3D | DDPT_NORMAL | DDPT_EDGE | DDPT_CIECOLOUR)
#define  DD_CIE_NORM_EDGE_POINT4D   	(DDPT_4D | DDPT_NORMAL | DDPT_EDGE | DDPT_CIECOLOUR)
#define  DD_HOMOGENOUS_POINT  		(DDPT_4D)

typedef ddUSHORT ddPointType;

/* 
 * The point types correspond to the point types in the PEX protocol 
 */
typedef struct {
	ddCoord3D	pt;
	ddIndexedColour	colour;
} ddIndexPoint;

typedef struct {
	ddCoord3D	pt;
	ddRgb8Colour	colour;
} ddRgb8Point;

typedef struct {
	ddCoord3D	pt;
	ddRgb16Colour	colour;
} ddRgb16Point;

typedef struct {
	ddCoord2DS	pt;
	ddRgbFloatColour	colour;
} ddRgbFloatPoint2DS;

typedef struct {
	ddCoord3D	pt;
	ddRgbFloatColour	colour;
} ddRgbFloatPoint;

typedef struct {
	ddCoord2DS	pt;
	ddHsvColour	colour;
} ddHsvPoint2DS;

typedef struct {
	ddCoord3D	pt;
	ddHsvColour	colour;
} ddHsvPoint;

typedef struct {
	ddCoord2DS	pt;
	ddHlsColour	colour;
} ddHlsPoint2DS;

typedef struct {
	ddCoord3D	pt;
	ddHlsColour	colour;
} ddHlsPoint;

typedef struct {
	ddCoord2DS	pt;
	ddCieColour	colour;
} ddCiePoint2DS;

typedef struct {
	ddCoord3D	pt;
	ddCieColour	colour;
} ddCiePoint;

typedef struct {
	ddCoord2DS	pt;
	ddVector3D	normal;
} ddNormalPoint2DS;

typedef struct {
	ddCoord3D	pt;
	ddVector3D	normal;
} ddNormalPoint;

typedef struct {
	ddCoord2DS	pt;
	ddULONG		edge;
} ddEdgePoint2DS;

typedef struct {
	ddCoord3D	pt;
	ddULONG		edge;
} ddEdgePoint;

typedef struct {
	ddCoord3D	pt;
	ddIndexedColour	colour;
	ddVector3D	normal;
} ddIndexNormalPoint;

typedef struct {
	ddCoord3D	pt;
	ddRgb8Colour	colour;
	ddVector3D	normal;
} ddRgb8NormalPoint;

typedef struct {
	ddCoord3D	pt;
	ddRgb16Colour	colour;
	ddVector3D	normal;
} ddRgb16NormalPoint;

typedef struct {
	ddCoord2DS	pt;
	ddRgbFloatColour	colour;
	ddVector3D	normal;
} ddRgbFloatNormalPoint2DS;

typedef struct {
	ddCoord3D	pt;
	ddRgbFloatColour	colour;
	ddVector3D	normal;
} ddRgbFloatNormalPoint;

typedef struct {
	ddCoord2DS	pt;
	ddHsvColour	colour;
	ddVector3D	normal;
} ddHsvNormalPoint2DS;

typedef struct {
	ddCoord3D	pt;
	ddHsvColour	colour;
	ddVector3D	normal;
} ddHsvNormalPoint;

typedef struct {
	ddCoord2DS	pt;
	ddHlsColour	colour;
	ddVector3D	normal;
} ddHlsNormalPoint2DS;

typedef struct {
	ddCoord3D	pt;
	ddHlsColour	colour;
	ddVector3D	normal;
} ddHlsNormalPoint;

typedef struct {
	ddCoord2DS	pt;
	ddCieColour	colour;
	ddVector3D	normal;
} ddCieNormalPoint2DS;

typedef struct {
	ddCoord3D	pt;
	ddCieColour	colour;
	ddVector3D	normal;
} ddCieNormalPoint;

typedef struct {
	ddCoord3D	pt;
	ddIndexedColour	colour;
	ddULONG		edge;
} ddIndexEdgePoint;

typedef struct {
	ddCoord3D	pt;
	ddRgb8Colour	colour;
	ddULONG		edge;
} ddRgb8EdgePoint;

typedef struct {
	ddCoord3D	pt;
	ddRgb16Colour	colour;
	ddULONG		edge;
} ddRgb16EdgePoint;

typedef struct {
	ddCoord2DS	pt;
	ddRgbFloatColour	colour;
	ddULONG		edge;
} ddRgbFloatEdgePoint2DS;

typedef struct {
	ddCoord3D	pt;
	ddRgbFloatColour	colour;
	ddULONG		edge;
} ddRgbFloatEdgePoint;

typedef struct {
	ddCoord2DS	pt;
	ddHsvColour	colour;
	ddULONG		edge;
} ddHsvEdgePoint2DS;

typedef struct {
	ddCoord3D	pt;
	ddHsvColour	colour;
	ddULONG		edge;
} ddHsvEdgePoint;

typedef struct {
	ddCoord2DS	pt;
	ddHlsColour	colour;
	ddULONG		edge;
} ddHlsEdgePoint2DS;

typedef struct {
	ddCoord3D	pt;
	ddHlsColour	colour;
	ddULONG		edge;
} ddHlsEdgePoint;

typedef struct {
	ddCoord2DS	pt;
	ddCieColour	colour;
	ddULONG		edge;
} ddCieEdgePoint2DS;

typedef struct {
	ddCoord3D	pt;
	ddCieColour	colour;
	ddULONG		edge;
} ddCieEdgePoint;

typedef struct {
	ddCoord2DS       pt;
	ddVector3D	normal;
	ddULONG		edge;
} ddNormEdgePoint2DS;

typedef struct {
	ddCoord3D       pt;
	ddVector3D	normal;
	ddULONG		edge;
} ddNormEdgePoint;

typedef struct {
	ddCoord3D	pt;
	ddIndexedColour	colour;
	ddVector3D	normal;
	ddULONG		edge;
} ddIndexNormEdgePoint;

typedef struct {
	ddCoord3D	pt;
	ddRgb8Colour	colour;
	ddVector3D	normal;
	ddULONG		edge;
} ddRgb8NormEdgePoint;

typedef struct {
	ddCoord3D	pt;
	ddRgb16Colour	colour;
	ddVector3D	normal;
	ddULONG		edge;
} ddRgb16NormEdgePoint;

typedef struct {
	ddCoord2DS	pt;
	ddRgbFloatColour	colour;
	ddVector3D	normal;
	ddULONG		edge;
} ddRgbFloatNormEdgePoint2DS;

typedef struct {
	ddCoord3D	pt;
	ddRgbFloatColour	colour;
	ddVector3D	normal;
	ddULONG		edge;
} ddRgbFloatNormEdgePoint;

typedef struct {
	ddCoord2DS	pt;
	ddHsvColour	colour;
	ddVector3D	normal;
	ddULONG		edge;
} ddHsvNormEdgePoint2DS;

typedef struct {
	ddCoord3D	pt;
	ddHsvColour	colour;
	ddVector3D	normal;
	ddULONG		edge;
} ddHsvNormEdgePoint;

typedef struct {
	ddCoord2DS	pt;
	ddHlsColour	colour;
	ddVector3D	normal;
	ddULONG		edge;
} ddHlsNormEdgePoint2DS;

typedef struct {
	ddCoord3D	pt;
	ddHlsColour	colour;
	ddVector3D	normal;
	ddULONG		edge;
} ddHlsNormEdgePoint;

typedef struct {
	ddCoord2DS	pt;
	ddCieColour	colour;
	ddVector3D	normal;
	ddULONG		edge;
} ddCieNormEdgePoint2DS;

typedef struct {
	ddCoord3D	pt;
	ddCieColour	colour;
	ddVector3D	normal;
	ddULONG		edge;
} ddCieNormEdgePoint;

/* 
 * The point types are internal point types only.
 */

typedef struct {
	ddCoord4D	pt;
	ddIndexedColour	colour;
} ddIndexPoint4D;

typedef struct {
	ddCoord4D	pt;
	ddRgb8Colour	colour;
} ddRgb8Point4D;

typedef struct {
	ddCoord4D	pt;
	ddRgb16Colour	colour;
} ddRgb16Point4D;

typedef struct {
	ddCoord4D	pt;
	ddRgbFloatColour	colour;
} ddRgbFloatPoint4D;

typedef struct {
	ddCoord4D	pt;
	ddHsvColour	colour;
} ddHsvPoint4D;

typedef struct {
	ddCoord4D	pt;
	ddHlsColour	colour;
} ddHlsPoint4D;

typedef struct {
	ddCoord4D	pt;
	ddCieColour	colour;
} ddCiePoint4D;

typedef struct {
	ddCoord4D	pt;
	ddVector3D	normal;
} ddNormalPoint4D;

typedef struct {
	ddCoord4D	pt;
	ddULONG		edge;
} ddEdgePoint4D;

typedef struct {
	ddCoord4D	pt;
	ddIndexedColour	colour;
	ddVector3D	normal;
} ddIndexNormalPoint4D;

typedef struct {
	ddCoord4D	pt;
	ddRgb8Colour	colour;
	ddVector3D	normal;
} ddRgb8NormalPoint4D;

typedef struct {
	ddCoord4D	pt;
	ddRgb16Colour	colour;
	ddVector3D	normal;
} ddRgb16NormalPoint4D;

typedef struct {
	ddCoord4D	pt;
	ddRgbFloatColour	colour;
	ddVector3D	normal;
} ddRgbFloatNormalPoint4D;

typedef struct {
	ddCoord4D	pt;
	ddHsvColour	colour;
	ddVector3D	normal;
} ddHsvNormalPoint4D;

typedef struct {
	ddCoord4D	pt;
	ddHlsColour	colour;
	ddVector3D	normal;
} ddHlsNormalPoint4D;

typedef struct {
	ddCoord4D	pt;
	ddCieColour	colour;
	ddVector3D	normal;
} ddCieNormalPoint4D;

typedef struct {
	ddCoord4D	pt;
	ddIndexedColour	colour;
	ddULONG		edge;
} ddIndexEdgePoint4D;

typedef struct {
	ddCoord4D	pt;
	ddRgb8Colour	colour;
	ddULONG		edge;
} ddRgb8EdgePoint4D;

typedef struct {
	ddCoord4D	pt;
	ddRgb16Colour	colour;
	ddULONG		edge;
} ddRgb16EdgePoint4D;

typedef struct {
	ddCoord4D	pt;
	ddRgbFloatColour	colour;
	ddULONG		edge;
} ddRgbFloatEdgePoint4D;

typedef struct {
	ddCoord4D	pt;
	ddHsvColour	colour;
	ddULONG		edge;
} ddHsvEdgePoint4D;

typedef struct {
	ddCoord4D	pt;
	ddHlsColour	colour;
	ddULONG		edge;
} ddHlsEdgePoint4D;

typedef struct {
	ddCoord4D	pt;
	ddCieColour	colour;
	ddULONG		edge;
} ddCieEdgePoint4D;

typedef struct {
	ddCoord4D       pt;
	ddVector3D	normal;
	ddULONG		edge;
} ddNormEdgePoint4D;

typedef struct {
	ddCoord4D	pt;
	ddIndexedColour	colour;
	ddVector3D	normal;
	ddULONG		edge;
} ddIndexNormEdgePoint4D;

typedef struct {
	ddCoord4D	pt;
	ddRgb8Colour	colour;
	ddVector3D	normal;
	ddULONG		edge;
} ddRgb8NormEdgePoint4D;

typedef struct {
	ddCoord4D	pt;
	ddRgb16Colour	colour;
	ddVector3D	normal;
	ddULONG		edge;
} ddRgb16NormEdgePoint4D;

typedef struct {
	ddCoord4D	pt;
	ddRgbFloatColour	colour;
	ddVector3D	normal;
	ddULONG		edge;
} ddRgbFloatNormEdgePoint4D;

typedef struct {
	ddCoord4D	pt;
	ddHsvColour	colour;
	ddVector3D	normal;
	ddULONG		edge;
} ddHsvNormEdgePoint4D;

typedef struct {
	ddCoord4D	pt;
	ddHlsColour	colour;
	ddVector3D	normal;
	ddULONG		edge;
} ddHlsNormEdgePoint4D;

typedef struct {
	ddCoord4D	pt;
	ddCieColour	colour;
	ddVector3D	normal;
	ddULONG		edge;
} ddCieNormEdgePoint4D;

typedef union {
	ddCoord2D			*p2Dpt;
	ddCoord3D			*p3Dpt;
	ddCoord2DL			*p2DLpt;
	ddCoord3DL			*p3DLpt;
	ddCoord2DS			*p2DSpt;
	ddCoord3DS			*p3DSpt;
	ddIndexedColour			*pIndexClr;
	ddRgb8Colour			*pRgb8Clr;
	ddRgb16Colour			*pRgb16Clr;
	ddRgbFloatColour		*pRgbFloatClr;
	ddHsvColour			*pHsvClr;
	ddHlsColour			*pHlsClr;
	ddCieColour			*pCieClr;
	ddIndexPoint			*pIndexpt;
	ddRgb8Point			*pRgb8pt;  
	ddRgb16Point			*pRgb16pt;
	ddRgbFloatPoint			*pRgbFloatpt;
	ddHsvPoint			*pHsvpt;
	ddHlsPoint			*pHlspt;
	ddCiePoint			*pCiept;
	ddVector3D			*pNormal;
	ddNormalPoint			*pNpt;
	ddULONG				*pEdge;
	ddEdgePoint			*pEpt;
	ddIndexNormalPoint		*pIndexNpt;
	ddRgb8NormalPoint		*pRgb8Npt;
	ddRgb16NormalPoint		*pRgb16Npt;
	ddRgbFloatNormalPoint		*pRgbFloatNpt;
	ddHsvNormalPoint		*pHsvNpt;
	ddHlsNormalPoint		*pHlsNpt;
	ddCieNormalPoint		*pCieNpt;
	ddIndexEdgePoint		*pIndexEpt;
	ddRgb8EdgePoint			*pRgb8Ept;
	ddRgb16EdgePoint		*pRgb16Ept;
	ddRgbFloatEdgePoint		*pRgbFloatEpt;
	ddHsvEdgePoint			*pHsvEpt;
	ddHlsEdgePoint			*pHlsEpt;
	ddCieEdgePoint			*pCieEpt;
	ddNormEdgePoint			*pNEpt;
	ddIndexNormEdgePoint		*pIndexNEpt;
	ddRgb8NormEdgePoint		*pRgb8NEpt;
	ddRgb16NormEdgePoint		*pRgb16NEpt;
	ddRgbFloatNormEdgePoint		*pRgbFloatNEpt;
	ddHsvNormEdgePoint		*pHsvNEpt;
	ddHlsNormEdgePoint		*pHlsNEpt;
	ddCieNormEdgePoint		*pCieNEpt;
	ddCoord4D			*p4Dpt;
	ddIndexPoint4D			*pIndexpt4D;
	ddRgb8Point4D			*pRgb8pt4D;  
	ddRgb16Point4D			*pRgb16pt4D;
	ddRgbFloatPoint4D		*pRgbFloatpt4D;
	ddHsvPoint4D			*pHsvpt4D;
	ddHlsPoint4D			*pHlspt4D;
	ddCiePoint4D			*pCiept4D;
	ddNormalPoint4D			*pNpt4D;
	ddEdgePoint4D			*pEpt4D;
	ddIndexNormalPoint4D		*pIndexNpt4D;
	ddRgb8NormalPoint4D		*pRgb8Npt4D;
	ddRgb16NormalPoint4D		*pRgb16Npt4D;
	ddRgbFloatNormalPoint4D		*pRgbFloatNpt4D;
	ddHsvNormalPoint4D		*pHsvNpt4D;
	ddHlsNormalPoint4D		*pHlsNpt4D;
	ddCieNormalPoint4D		*pCieNpt4D;
	ddIndexEdgePoint4D		*pIndexEpt4D;
	ddRgb8EdgePoint4D		*pRgb8Ept4D;
	ddRgb16EdgePoint4D		*pRgb16Ept4D;
	ddRgbFloatEdgePoint4D		*pRgbFloatEpt4D;
	ddHsvEdgePoint4D		*pHsvEpt4D;
	ddHlsEdgePoint4D		*pHlsEpt4D;
	ddCieEdgePoint4D		*pCieEpt4D;
	ddNormEdgePoint4D		*pNEpt4D;
	ddIndexNormEdgePoint4D		*pIndexNEpt4D;
	ddRgb8NormEdgePoint4D		*pRgb8NEpt4D;
	ddRgb16NormEdgePoint4D		*pRgb16NEpt4D;
	ddRgbFloatNormEdgePoint4D	*pRgbFloatNEpt4D;
	ddHsvNormEdgePoint4D		*pHsvNEpt4D;
	ddHlsNormEdgePoint4D		*pHlsNEpt4D;
	ddCieNormEdgePoint4D		*pCieNEpt4D;
	char				*ptr;
} ddPointUnion;

/*
 * Last - create a point header data structure
 *
 * Note: any changes to this structure MUST also be
 *       made to the MarkerlistofddPoint structure below.
 */
typedef struct {
	ddULONG		numPoints;	/* number of vertices in list */
	ddULONG		maxData;	/* allocated data in bytes */
	ddPointUnion	pts;		/* pointer to vertex data */
} listofddPoint;

/*
 * Create a parallel structure to listofddPoint for
 * pre-initializing Markers. Note that the listofddPoint
 * structure and the MarkerlistofddPoint structure MUST always
 * match with the exception of the union elememt.
 */
typedef struct {
	ddULONG		numPoints;	/* number of vertices in list */
	ddULONG		maxData;	/* allocated data in bytes */
	ddCoord2D	*pts;
} MarkerlistofddPoint;

typedef struct {
	ddUSHORT	order;
	ddFLOAT		uMin;
	ddFLOAT		uMax;
	ddULONG		numKnots;
	ddFLOAT		*pKnots;
	listofddPoint	points;
} ddNurbCurve;

typedef enum {
	DD_FACET_NONE=0,		/* no facet attributes */
	DD_FACET_INDEX=1,		/* facet colour */
	DD_FACET_RGB8=2,		/* facet colour */
	DD_FACET_RGB16=3,		/* facet colour */
	DD_FACET_RGBFLOAT=4,		/* facet colour */
	DD_FACET_HSV=5,			/* facet colour */
	DD_FACET_HLS=6,			/* facet colour */
	DD_FACET_CIE=7,			/* facet colour */
	DD_FACET_NORM=8,		/* facet normal */
	DD_FACET_INDEX_NORM=9,		/* facet colour & normal */
	DD_FACET_RGB8_NORM=10,		/* facet colour & normal */
	DD_FACET_RGB16_NORM=11,		/* facet colour & normal */
	DD_FACET_RGBFLOAT_NORM=12,	/* facet colour & normal */
	DD_FACET_HSV_NORM=13,		/* facet colour & normal */
	DD_FACET_HLS_NORM=14,		/* facet colour & normal */
	DD_FACET_CIE_NORM=15		/* facet colour & normal */
} ddFacetType;

/*
 * A useful macro to determine the size of a facet
 *
 */
#define DDFacetSIZE(type, size)                                         \
        switch((type)){                                                 \
          case(DD_FACET_NONE): (size) = 0;                              \
            break;                                                      \
          case(DD_FACET_INDEX): (size) = sizeof(ddIndexedColour);       \
            break;                                                      \
          case(DD_FACET_RGB8): (size) = sizeof(ddRgb8Colour);           \
            break;                                                      \
          case(DD_FACET_RGB16): (size) = sizeof(ddRgb16Colour);         \
            break;                                                      \
          case(DD_FACET_RGBFLOAT): (size) = sizeof(ddRgbFloatColour);   \
            break;                                                      \
          case(DD_FACET_HSV): (size) = sizeof(ddHsvColour);             \
            break;                                                      \
          case(DD_FACET_HLS): (size) = sizeof(ddHlsColour);             \
            break;                                                      \
          case(DD_FACET_CIE): (size) = sizeof(ddCieColour);             \
            break;                                                      \
          case(DD_FACET_NORM): (size) = sizeof(ddVector3D);             \
            break;                                                      \
          case(DD_FACET_INDEX_NORM): (size) = sizeof(ddIndexNormal);    \
            break;                                                      \
          case(DD_FACET_RGB8_NORM): (size) = sizeof(ddRgb8Normal);      \
            break;                                                      \
          case(DD_FACET_RGB16_NORM): (size) = sizeof(ddRgb16Normal);    \
            break;                                                      \
          case(DD_FACET_RGBFLOAT_NORM): (size) = sizeof(ddRgbFloatNormal);\
            break;                                                      \
          case(DD_FACET_HSV_NORM): (size) = sizeof(ddHsvNormal);        \
            break;                                                      \
          case(DD_FACET_HLS_NORM): (size) = sizeof(ddHlsNormal);        \
            break;                                                      \
          case(DD_FACET_CIE_NORM): (size) = sizeof(ddCieNormal);        \
            break;                                                      \
	  default: (size) = -1;						\
        }

/*
 * more facet macros for determining type.
 */
#define DD_IsFacetNormal(type)	\
((((int)type)>=((int)DD_FACET_NORM))&&(((int)type)<=((int)DD_FACET_CIE_NORM)))
#define DD_IsFacetColour(type)	\
( ((type) != DD_FACET_NONE) && ((type) != DD_FACET_NORM) )

typedef struct {
	ddIndexedColour	colour;
	ddVector3D	normal;
} ddIndexNormal;

typedef struct {
	ddRgb8Colour	colour;
	ddVector3D	normal;
} ddRgb8Normal;

typedef struct {
	ddRgb16Colour	colour;
	ddVector3D	normal;
} ddRgb16Normal;

typedef struct {
	ddRgbFloatColour	colour;
	ddVector3D	normal;
} ddRgbFloatNormal;

typedef struct {
	ddHsvColour	colour;
	ddVector3D	normal;
} ddHsvNormal;

typedef struct {
	ddHlsColour	colour;
	ddVector3D	normal;
} ddHlsNormal;

typedef struct {
	ddCieColour	colour;
	ddVector3D	normal;
} ddCieNormal;

typedef union {
	ddPointer		pNoFacet;
	ddIndexedColour		*pFacetIndex;
	ddRgb8Colour		*pFacetRgb8;
	ddRgb16Colour		*pFacetRgb16;
	ddRgbFloatColour	*pFacetRgbFloat;
	ddHsvColour		*pFacetHsv;
	ddHlsColour		*pFacetHls;
	ddCieColour		*pFacetCie;
	ddVector3D		*pFacetN;
	ddIndexNormal		*pFacetIndexN;
	ddRgb8Normal		*pFacetRgb8N;
	ddRgb16Normal		*pFacetRgb16N;
	ddRgbFloatNormal	*pFacetRgbFloatN;
	ddHsvNormal		*pFacetHsvN;
	ddHlsNormal		*pFacetHlsN;
	ddCieNormal		*pFacetCieN;
} ddFacetUnion;

typedef struct {
	ddFacetType	type;
	ddULONG		numFacets;	/* number of facets in list */
	ddULONG		maxData;	/* allocated data in bytes */
	ddFacetUnion	facets;		/* Pointer to facet data */
} listofddFacet;

typedef enum {
	DD_VERTEX=0,
	DD_VERTEX_EDGE=1
} ddVertIndexType;

typedef struct {
	ddUSHORT	index;
	ddULONG		edge;
} ddVertIndexEdge;
	
typedef struct {
	ddVertIndexType	type;
	ddULONG		numIndex;
	union {
		ddUSHORT	*pVertIndex;
		ddVertIndexEdge		*pVertIndexE;
	} index;
} listofddIndex;

typedef struct {
	ddUSHORT	uOrder;
	ddUSHORT	vOrder;
	ddFLOAT		uMin;
	ddFLOAT		uMax;
	ddFLOAT		vMin;
	ddFLOAT		vMax;
	ddFLOAT		mpts;
	ddFLOAT		npts;
	ddULONG		numUKnots;
	ddFLOAT		*pUKnot;
	ddULONG		numVKnots;
	ddFLOAT		*pVKnot;
	listofddPoint	points;
} ddNurbSurface;

typedef struct {
	ddBYTE		visibility;
	ddUSHORT	order;
	ddCurveApprox	curveApprox;
	ddFLOAT		uMin;
	ddFLOAT		uMax;
	ddULONG		numKnots;
	ddFLOAT		*pKnots;
	ddPointType	pttype;
	listofddPoint	points;
} ddTrimCurve;

typedef struct {
	ddULONG		count;
	ddTrimCurve	*pTC;
} listofTrimCurve;

/* for cell arrays */
typedef struct {
	ddSHORT	colourType;
	union {
		ddIndexedColour		*pIndex;
		ddRgb8Colour		*pRgb8;
		ddRgb16Colour		*pRgb16;
		ddRgbFloatColour	*pRgbFloat;
		ddHsvColour		*pHsv;
		ddHlsColour		*pHls;
		ddCieColour		*pCie;
	} colour;
} listofColour;

#endif   /* DDPEX3_H */