summaryrefslogtreecommitdiff
path: root/xicc/xfbview.c
blob: 3d7c6651e2f81b517a401c9eaaf035a9b9409a1c (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

/* 
 * View inv fwd table device interp of an ICC file, V1.23\n");
 *
 * Author:  Graeme W. Gill
 * Date:    2000/12/8
 * Version: 1.23
 *
 * Copyright 2000 Graeme W. Gill
 * Please refer to License.txt file for details.
 */

/* TTBD:
 *
 * Should reject device link profiles ?
 *
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <fcntl.h>
#include <string.h>
#include <math.h>
#include "copyright.h"
#include "aconfig.h"
#include "numlib.h"
#include "icc.h"
#include "xicc.h"
#include "vrml.h"

#define RW 0.5		/* PCS Delta */ 

//#define FLAGS ICX_CLIP_NEAREST | ICX_CAM_CLIP | ICX_FAST_SETUP
//#define FLAGS ICX_CLIP_NEAREST | ICX_CAM_CLIP
//#define FLAGS ICX_CLIP_NEAREST | ICX_FAST_SETUP
#define FLAGS ICX_CLIP_NEAREST

/* - - - - - - - - - - - - - */

/* Return maximum difference */
double maxdiff(double in1[3], double in2[3]) {
	double tt, rv = 0.0;
	if ((tt = fabs(in1[0] - in2[0])) > rv)
		rv = tt;
	if ((tt = fabs(in1[1] - in2[1])) > rv)
		rv = tt;
	if ((tt = fabs(in1[2] - in2[2])) > rv)
		rv = tt;
	return rv;
}

/* Return absolute difference */
double absdiff(double in1[3], double in2[3]) {
	double tt, rv = 0.0;
	tt = in1[0] - in2[0];
	rv += tt * tt;
	tt = in1[1] - in2[1];
	rv += tt * tt;
	tt = in1[2] - in2[2];
	rv += tt * tt;
	return sqrt(rv);
}

/* ---------------------------------------- */

void usage(void) {
	fprintf(stderr,"View inv fwd table device interp of an ICC file, Version %s\n",ARGYLL_VERSION_STR);
	fprintf(stderr,"Author: Graeme W. Gill, licensed under the AGPL Version 3\n");
	fprintf(stderr,"usage: fbtest [options] infile\n");
	fprintf(stderr," -v          verbose\n");
	fprintf(stderr," -f          Add PCS -inv(a2b)- device -a2b- PCS Vectors\n");
	fprintf(stderr," -d          Add ave(PCS + 4 x a*b* variations -inv(a2b)- device) -a2b- PCS\n");
	fprintf(stderr," -b          Add PCS -b2a- device -a2b- PCS Vectors\n");
	fprintf(stderr," -e          Add dif between inv(a2b) and b2a cliped vectors\n");
	fprintf(stderr," -r res      Resolution of test grid [Def 33]\n");
	fprintf(stderr," -g          Do full grid, not just cube\n");
	fprintf(stderr," -a          Do all values, not just clipped ones\n");
	fprintf(stderr," -l tlimit   set total ink limit, 0 - 400%% (estimate by default)\n");
	fprintf(stderr," -L klimit   set black ink limit, 0 - 100%% (estimate by default)\n");
	exit(1);
}

int
main(
	int argc,
	char *argv[]
) {
	int fa,nfa;				/* argument we're looking at */
	int verb = 0;
	int doaxes = 0;
	double tlimit = -1.0;	/* Total ink limit */
	double klimit = -1.0;	/* Black ink limit */
	int tres = 33;
	int doref = 0;			/* Show reference lookups */
	int dodelta = 0;		/* Show device interp delta variation */
	int dob2a = 0;			/* Show B2A lookups */
	int doeee = 0;			/* Show clipped ref PCS to B2A clipped PCS */
	int dogrid = 0;			/* Do full grid, not just cube */
	int doclip = 1;			/* Do just clipped values */
	char in_name[100];
	char *xl, out_name[100];
	icmFile *rd_fp;
	icc *rd_icco;
	int rv = 0;
	icColorSpaceSignature ins, outs;	/* Type of input and output spaces */
	int inn;							/* Number of device values */
	double abscale = 128.0;

	error_program = argv[0];

	if (argc < 2)
		usage();

	/* Process the arguments */
	for(fa = 1;fa < argc;fa++) {
		nfa = fa;					/* skip to nfa if next argument is used */
		if (argv[fa][0] == '-')	{	/* Look for any flags */
			char *na = NULL;		/* next argument after flag, null if none */

			if (argv[fa][2] != '\000')
				na = &argv[fa][2];		/* next is directly after flag */
			else {
				if ((fa+1) < argc) {
					if (argv[fa+1][0] != '-') {
						nfa = fa + 1;
						na = argv[nfa];		/* next is seperate non-flag argument */
					}
				}
			}

			/* Verbosity */
			if (argv[fa][1] == 'v') {
				verb = 1;
			}
			/* Show reference */
			else if (argv[fa][1] == 'f') {
				doref = 1;
			}
			/* Show device delta variation */
			else if (argv[fa][1] == 'd') {
				dodelta = 1;
			}
			/* Show B2A table lookup */
			else if (argv[fa][1] == 'b') {
				dob2a = 1;
			}
			/* Show reference clipped PCS to clipped B2A PCS */
			else if (argv[fa][1] == 'e') {
				doeee = 1;
			}
			/* Do full grid, not just cube */
			else if (argv[fa][1] == 'g') {
				dogrid = 1;
			}
			/* Do all values, not just clipped ones */
			else if (argv[fa][1] == 'a') {
				doclip = 0;
			}
			/* Ink limit */
			else if (argv[fa][1] == 'l') {
				fa = nfa;
				if (na == NULL) usage();
				tlimit = atoi(na)/100.0;
			}
			else if (argv[fa][1] == 'L') {
				fa = nfa;
				if (na == NULL) usage();
				klimit = atoi(na)/100.0;
			}

			/* Resolution */
			else if (argv[fa][1] == 'r') {
				fa = nfa;
				if (na == NULL) usage();
				tres = atoi(na);
			}

			else if (argv[fa][1] == '?')
				usage();
			else 
				usage();
		}
		else
			break;
	}

	if (fa >= argc || argv[fa][0] == '-') usage();
	strcpy(in_name,argv[fa]);

	strcpy(out_name, in_name);
	if ((xl = strrchr(out_name, '.')) == NULL)	/* Figure where extention is */
		xl = out_name + strlen(out_name);
	xl[0] = '\000';				/* Remove extension */

	/* Open up the file for reading */
	if ((rd_fp = new_icmFileStd_name(in_name,"r")) == NULL)
		error ("Read: Can't open file '%s'",in_name);

	if ((rd_icco = new_icc()) == NULL)
		error ("Read: Creation of ICC object failed");

	/* Read the header and tag list */
	if ((rv = rd_icco->read(rd_icco,rd_fp,0)) != 0)
		error ("Read: %d, %s",rv,rd_icco->err);

	/* Run the target Lab values through the bwd and fwd tables, */
	/* to compute the overall error. */
	{
#define GAMUT_LCENT 50.0
		xicc *xicco;
		icxLuBase *luo;
		icxInk ink;					/* Ink parameters */
		vrml *wrl;
		struct {
			double x, y, z;
			double wx, wy, wz;
			double r, g, b;
		} axes[5] = {
			{ 0, 0,  50-GAMUT_LCENT,  2, 2, 100,  .7, .7, .7 },	/* L axis */
			{ 50, 0,  0-GAMUT_LCENT,  100, 2, 2,   1,  0,  0 },	/* +a (red) axis */
			{ 0, -50, 0-GAMUT_LCENT,  2, 100, 2,   0,  0,  1 },	/* -b (blue) axis */
			{ -50, 0, 0-GAMUT_LCENT,  100, 2, 2,   0,  1,  0 },	/* -a (green) axis */
			{ 0,  50, 0-GAMUT_LCENT,  2, 100, 2,   1,  1,  0 },	/* +b (yellow) axis */
		};
		int coa[4];
		int i, j;
	
		/* Wrap with an expanded icc */
		if ((xicco = new_xicc(rd_icco)) == NULL)
			error ("Creation of xicc failed");
	
		/* Set the default ink limits if not set on command line */
		icxDefaultLimits(xicco, &ink.tlimit, tlimit, &ink.klimit, klimit);

		if (verb) {
			if (ink.tlimit >= 0.0)
				printf("Total ink limit assumed is %3.0f%%\n",100.0 * ink.tlimit);
			if (ink.klimit >= 0.0)
				printf("Black ink limit assumed is %3.0f%%\n",100.0 * ink.klimit);
		}
	
		ink.c.Ksmth = ICXINKDEFSMTH;	/* Default smoothing */
		ink.c.Kskew = ICXINKDEFSKEW;	/* default curve skew */
		ink.c.Kstle = 0.5;		/* Min K at white end */
		ink.c.Kstpo = 0.5;		/* Start of transition is at white */ 	
		ink.c.Kenle = 0.5;		/* Max K at black end */
		ink.c.Kenpo = 0.5;		/* End transition at black */
		ink.c.Kshap = 1.0;		/* Linear transition */

		/* Get a Device to PCS conversion object */
		if ((luo = xicco->get_luobj(xicco, FLAGS, icmFwd, icAbsoluteColorimetric, icSigLabData, icmLuOrdNorm, NULL, &ink)) == NULL) {
			if ((luo = xicco->get_luobj(xicco, FLAGS, icmFwd, icmDefaultIntent, icSigLabData, icmLuOrdNorm, NULL, &ink)) == NULL)
				error ("%d, %s",rd_icco->errc, rd_icco->err);
		}
		/* Get details of conversion */
		luo->spaces(luo, &ins, &inn, &outs, NULL, NULL, NULL, NULL, NULL);

		if (ins != icSigCmykData
		 && ins != icSigRgbData) {
			error("Expecting RGB or CMYK device");
		}
		
		if ((wrl = new_vrml(out_name, doaxes, vrml_lab)) == NULL) {
			fprintf(stderr,"new_vrml failed for '%s%s'\n",out_name,vrml_ext());
			return 2;
		}

		/* ---------------------------------------------- */
		/* Clipping vectors of inverse a2b */
		/* PCS -inv(a2b)- device -a2b- PCS Vectors */

		/* PCS -> device -> PCS */
		if (doref) {
			double rgb[3];

			if (verb)
				printf("Adding PCS -inv(a2b)- device -a2b- PCS Vectors \n");

			wrl->start_line_set(wrl, 0);

			i = 0;
			/* For range of PCS values */
			for (coa[0] = 0; coa[0] < tres; coa[0]++) {
				for (coa[1] = 0; coa[1] < tres; coa[1]++) {
					for (coa[2] = 0; coa[2] < tres; coa[2]++) {
						double in[4], dev[4], out[4];
						double temp[4];
						int rv1, rv2;

						if (!dogrid
						 && coa[0] != 0 && coa[0] != (tres-1)
						 && coa[1] != 0 && coa[1] != (tres-1)
						 && coa[2] != 0 && coa[2] != (tres-1)) {
							continue;
						}

						temp[0] = coa[0]/(tres-1.0);
						temp[1] = coa[1]/(tres-1.0);
						temp[2] = coa[2]/(tres-1.0);

						/* PCS values */
						in[0] = temp[0] * 100.0;
						in[1] = abscale * 2.0 * (temp[1] - 0.5);
						in[2] = abscale * 2.0 * (temp[2] - 0.5);

						/* Do reference lookup */

						/* PCS -> Device */
						if ((rv2 = luo->inv_lookup(luo, dev, in)) > 1)
							error ("%d, %s",rd_icco->errc,rd_icco->err);
		
						if (doclip && rv2 != 1)	/* Not clip */
							continue;

						/* Device -> PCS */
						if ((rv1 = luo->lookup(luo, out, dev)) > 1)
							error ("%d, %s",rd_icco->errc,rd_icco->err);
		
						if (verb) 
							printf("."), fflush(stdout);

						/* Input PCS to ideal (Inverse AtoB) clipped PCS values */
						wrl->add_vertex(wrl, 0, in);
						wrl->add_vertex(wrl, 0, out);
						i++;
					}
				}
			}

			if (verb)
				printf("\n");

			for (j = 0; j < i; j++) {
				int ix[2];
				ix[0] = j * 2;
				ix[1] = j * 2 +1;
				wrl->add_line(wrl, 0, ix);
			}

			rgb[0] = 1.0;
			rgb[1] = 0.1;
			rgb[2] = 0.1;
			wrl->make_lines_cc(wrl, 0, 0.0, rgb);
		}

		/* ---------------------------------------------- */
		/* Clipping vectors of average around PCS of inverse a2b */
		/* Average of(PCS + 4 x a*b* variations -inv(a2b)- device) -a2b- PCS */

		if (dodelta) {
			double rgb[3];

			if (verb)
				printf("Adding ave(PCS + 4 x a*b* variations -inv(a2b)- device) -a2b- PCS\n");

			wrl->start_line_set(wrl, 0);

			i = 0;
			/* For Lab values */
			for (coa[0] = 0; coa[0] < tres; coa[0]++) {
				for (coa[1] = 0; coa[1] < tres; coa[1]++) {
					for (coa[2] = 0; coa[2] < tres; coa[2]++) {
						double in[4], dev[4], out[4];
						double in4[4], check[4];
						double temp[4], adev[4];
						double dev0[4], dev1[4], dev2[4], dev3[4];
						int rv1, rv2;

						if (!dogrid
						 && coa[0] != 0
						 && coa[0] != (tres-1)
						 && coa[1] != 0
						 && coa[1] != (tres-1)
						 && coa[2] != 0
						 && coa[2] != (tres-1))
							continue;

						temp[0] = coa[0]/(tres-1.0);
						temp[1] = coa[1]/(tres-1.0);
						temp[2] = coa[2]/(tres-1.0);

						in[0] = temp[0] * 100.0;
						in[1] = abscale * 2.0 * (temp[1] - 0.5);
						in[2] = abscale * 2.0 * (temp[2] - 0.5);

						/* Do reference lookup */

						/* PCS -> ideal Device */
						if ((rv2 = luo->inv_lookup(luo, dev, in)) > 1)
							error ("%d, %s",rd_icco->errc,rd_icco->err);
		
						if (doclip && rv2 != 1)	/* Not clip */
							continue;

						/* Device -> PCS check value - not used */
						if ((rv1 = luo->lookup(luo, check, dev)) > 1)
							error ("%d, %s",rd_icco->errc,rd_icco->err);
		
						/* - - - - - - - - - - - - - - - */
						/* Now do average in device space of two points */
						temp[0] = coa[0]/(tres-1.0);
						temp[1] = (coa[1]-RW)/(tres-1.0);
						temp[2] = (coa[2]-RW)/(tres-1.0);

						in4[0] = temp[0] * 100.0;
						in4[1] = abscale * 2.0 * (temp[1] - 0.5);
						in4[2] = abscale * 2.0 * (temp[2] - 0.5);

						/* PCS -> Device */
						if ((rv2 = luo->inv_lookup(luo, dev0, in4)) > 1)
							error ("%d, %s",rd_icco->errc,rd_icco->err);
		
						adev[0] = 0.25 * dev0[0];
						adev[1] = 0.25 * dev0[1];
						adev[2] = 0.25 * dev0[2];
						adev[3] = 0.25 * dev0[3];

						temp[0] = coa[0]/(tres-1.0);
						temp[1] = (coa[1]+RW)/(tres-1.0);
						temp[2] = (coa[2]-RW)/(tres-1.0);

						in4[0] = temp[0] * 100.0;
						in4[1] = abscale * 2.0 * (temp[1] - 0.5);
						in4[2] = abscale * 2.0 * (temp[2] - 0.5);

						/* PCS -> Device */
						if ((rv2 = luo->inv_lookup(luo, dev1, in4)) > 1)
							error ("%d, %s",rd_icco->errc,rd_icco->err);
		
						adev[0] += 0.25 * dev1[0];
						adev[1] += 0.25 * dev1[1];
						adev[2] += 0.25 * dev1[2];
						adev[3] += 0.25 * dev1[3];

						temp[0] = coa[0]/(tres-1.0);
						temp[1] = (coa[1]-RW)/(tres-1.0);
						temp[2] = (coa[2]+RW)/(tres-1.0);

						in4[0] = temp[0] * 100.0;
						in4[1] = abscale * 2.0 * (temp[1] - 0.5);
						in4[2] = abscale * 2.0 * (temp[2] - 0.5);

						/* PCS -> Device */
						if ((rv2 = luo->inv_lookup(luo, dev2, in4)) > 1)
							error ("%d, %s",rd_icco->errc,rd_icco->err);
		
						adev[0] += 0.25 * dev2[0];
						adev[1] += 0.25 * dev2[1];
						adev[2] += 0.25 * dev2[2];
						adev[3] += 0.25 * dev2[3];

						temp[0] = coa[0]/(tres-1.0);
						temp[1] = (coa[1]+RW)/(tres-1.0);
						temp[2] = (coa[2]+RW)/(tres-1.0);

						in4[0] = temp[0] * 100.0;
						in4[1] = abscale * 2.0 * (temp[1] - 0.5);
						in4[2] = abscale * 2.0 * (temp[2] - 0.5);

						/* PCS -> Device */
						if ((rv2 = luo->inv_lookup(luo, dev3, in4)) > 1)
							error ("%d, %s",rd_icco->errc,rd_icco->err);
		
						adev[0] += 0.25 * dev3[0];
						adev[1] += 0.25 * dev3[1];
						adev[2] += 0.25 * dev3[2];
						adev[3] += 0.25 * dev3[3];

						/* Average device -> PCS */
						if ((rv1 = luo->lookup(luo, out, adev)) > 1)
							error ("%d, %s",rd_icco->errc,rd_icco->err);
		
						if (verb)
							printf("."), fflush(stdout);

						wrl->add_vertex(wrl, 0, in);
						wrl->add_vertex(wrl, 0, out);
						i++;
					}
				}
			}

			if (verb)
				printf("\n");

			for (j = 0; j < i; j++) {
				int ix[2];
				ix[0] = j * 2;
				ix[1] = j * 2 +1;
				wrl->add_line(wrl, 0, ix);
			}

			rgb[0] = 0.9;
			rgb[1] = 0.9;
			rgb[2] = 0.9;
			wrl->make_lines_cc(wrl, 0, 0.0, rgb);
		}

		/* ---------------------------------------------- */
		/* Clipping vectors of b2a */
		/* PCS -b2a- device -a2b- PCS Vectors */

		if (dob2a) {
			double rgb[3];

			icxLuBase *luoB;

			wrl->start_line_set(wrl, 0);

			/* Get a B2A (PCS to Device) conversion object */
			if ((luoB = xicco->get_luobj(xicco, FLAGS, icmBwd, icAbsoluteColorimetric,
			                             icSigLabData, icmLuOrdNorm, NULL, &ink)) == NULL) {
				if ((luoB = xicco->get_luobj(xicco, FLAGS, icmBwd, icmDefaultIntent,
				                             icSigLabData, icmLuOrdNorm, NULL, &ink)) == NULL)
					error ("%d, %s",rd_icco->errc, rd_icco->err);
			}

			if (verb)
				printf("Adding PCS -b2a- device -a2b- PCS Vectors\n");

			i = 0;
			/* For PCS values */
			for (coa[0] = 0; coa[0] < tres; coa[0]++) {
				for (coa[1] = 0; coa[1] < tres; coa[1]++) {
					for (coa[2] = 0; coa[2] < tres; coa[2]++) {
						double in[4], dev[4], out[4];
						double temp[4];
						int rv1, rv2;

						if (!dogrid
						 && coa[0] != 0
						 && coa[0] != (tres-1)
						 && coa[1] != 0
						 && coa[1] != (tres-1)
						 && coa[2] != 0
						 && coa[2] != (tres-1))
							continue;

						temp[0] = coa[0]/(tres-1.0);
						temp[1] = coa[1]/(tres-1.0);
						temp[2] = coa[2]/(tres-1.0);

						in[0] = temp[0] * 100.0;
						in[1] = abscale * 2.0 * (temp[1] - 0.5);
						in[2] = abscale * 2.0 * (temp[2] - 0.5);

						/* PCS -> Device */
						if ((rv2 = luoB->lookup(luoB, dev, in)) > 1)
							error ("%d, %s",rd_icco->errc,rd_icco->err);
		
						if (doclip && rv2 != 1)	/* Not clip */
							continue;

						/* Device -> PCS */
						if ((rv1 = luo->lookup(luo, out, dev)) > 1)
							error ("%d, %s",rd_icco->errc,rd_icco->err);
		
						if (verb)
							printf("."), fflush(stdout);

						wrl->add_vertex(wrl, 0, in);
						wrl->add_vertex(wrl, 0, out);
						i++;
					}
				}
			}

			if (verb)
				printf("\n");

			for (j = 0; j < i; j++) {
				int ix[2];
				ix[0] = j * 2;
				ix[1] = j * 2 +1;
				wrl->add_line(wrl, 0, ix);
			}

			rgb[0] = 0.9;
			rgb[1] = 0.9;
			rgb[2] = 0.9;
			wrl->make_lines_cc(wrl, 0, 0.0, rgb);

			luoB->del(luoB);
		}

		/* ---------------------------------------------- */
		/* Difference between: 
		      PCS -inv(a2b)- device -a2b- PCS 
		   and
		      PCS -b2a- device -a2b- PCS
		 */

		if (doeee) {
			double rgb[3];

			icxLuBase *luoB;

			wrl->start_line_set(wrl, 0);

			/* Get a PCS to Device conversion object */
			if ((luoB = xicco->get_luobj(xicco, FLAGS, icmBwd, icAbsoluteColorimetric,
			                             icSigLabData, icmLuOrdNorm, NULL, &ink)) == NULL) {
				if ((luoB = xicco->get_luobj(xicco, FLAGS, icmBwd, icmDefaultIntent,
				                             icSigLabData, icmLuOrdNorm, NULL, &ink)) == NULL)
					error ("%d, %s",rd_icco->errc, rd_icco->err);
			}

			if (verb)
				printf("Adding differenve between inv(a2b) and b2a cliped vectors\n");

			i = 0;
			for (coa[0] = 0; coa[0] < tres; coa[0]++) {
				for (coa[1] = 0; coa[1] < tres; coa[1]++) {
					for (coa[2] = 0; coa[2] < tres; coa[2]++) {
						double in[4], dev[4], out[4];
						double check[4];
						double temp[4];
						int rv1, rv2;

						if (!dogrid
						 && coa[0] != 0
						 && coa[0] != (tres-1)
						 && coa[1] != 0
						 && coa[1] != (tres-1)
						 && coa[2] != 0
						 && coa[2] != (tres-1))
							continue;

						temp[0] = coa[0]/(tres-1.0);
						temp[1] = coa[1]/(tres-1.0);
						temp[2] = coa[2]/(tres-1.0);

						in[0] = temp[0] * 100.0;
						in[1] = abscale * 2.0 * (temp[1] - 0.5);
						in[2] = abscale * 2.0 * (temp[2] - 0.5);

						/* Do reference lookup using inverse a2b */
						/* PCS -> Device */
						if ((rv1 = luo->inv_lookup(luo, dev, in)) > 1)
							error ("%d, %s",rd_icco->errc,rd_icco->err);
		
						/* Device -> PCS */
						if (luo->lookup(luo, check, dev) > 1)
							error ("%d, %s",rd_icco->errc,rd_icco->err);
		

						/* Do B2A table lookup */
						/* PCS -> Device */
						if ((rv2 = luoB->lookup(luoB, dev, in)) > 1)
							error ("%d, %s",rd_icco->errc,rd_icco->err);
		
						/* Device -> PCS */
						if (luo->lookup(luo, out, dev) > 1)
							error ("%d, %s",rd_icco->errc,rd_icco->err);
		
						if (doclip && rv1 != 1 && rv2 != 1)	/* Not clip */
							continue;

						if (verb)
							printf("."), fflush(stdout);

						wrl->add_vertex(wrl, 0, check);
						wrl->add_vertex(wrl, 0, out);
						i++;
					}
				}
			}

			if (verb)
				printf("\n");

			for (j = 0; j < i; j++) {
				int ix[2];
				ix[0] = j * 2;
				ix[1] = j * 2 +1;
				wrl->add_line(wrl, 0, ix);
			}

			rgb[0] = 0.9;
			rgb[1] = 0.9;
			rgb[2] = 0.9;
			wrl->make_lines_cc(wrl, 0, 0.0, rgb);

			luoB->del(luoB);
		}

		/* ---------------------------------------------- */

		if (wrl->flush(wrl) != 0) {
			fprintf(stderr,"Error closing output file '%s%s'\n",out_name,vrml_ext());
			return 2;
		}
		wrl->del(wrl);

		/* Done with lookup object */
		luo->del(luo);
		xicco->del(xicco);
	}

	rd_icco->del(rd_icco);
	rd_fp->del(rd_fp);

	return 0;
}