Diff of /parser.c [032bc7] .. [85654b]  Maximize  Restore

  Switch to unified view

a/parser.c b/parser.c
...
...
66
#define MY_SSCANF( str, format, ptr )       if( sscanf( str, format, ptr ) != 1 )   \
66
#define MY_SSCANF( str, format, ptr )       if( sscanf( str, format, ptr ) != 1 )   \
67
                                            {                                       \
67
                                            {                                       \
68
                                                PrintError(                         \
68
                                                PrintError(                         \
69
                                                "Syntax error in script: Line %d\nCould not assign variable [%s]",\
69
                                                "Syntax error in script: Line %d\nCould not assign variable [%s]",\
70
                                                lineNum, str);         \
70
                                                lineNum, str);         \
71
                                                return -1;                          \
71
                                                goto fail;                          \
72
                                            }                                       \
72
                                            }                                       \
73
73
74
#define READ_VAR(format, ptr )      nextWord( buf, &li );           \
74
#define READ_VAR(format, ptr )      nextWord( buf, &li );           \
75
                                    MY_SSCANF( buf, format, ptr );
75
                                    MY_SSCANF( buf, format, ptr );
76
                                    
76
                                    
...
...
81
#define READ_OPT_VAR(var)       nextWord( buf, &li );           \
81
#define READ_OPT_VAR(var)       nextWord( buf, &li );           \
82
                                MY_SSCANF( buf, "%d", &k);      \
82
                                MY_SSCANF( buf, "%d", &k);      \
83
                                if( k<0 || k>= numIm )          \
83
                                if( k<0 || k>= numIm )          \
84
                                {                               \
84
                                {                               \
85
                                    PrintError("Syntax error in script: Line %d\n\nIllegal image number: %ld", lineNum, k);\
85
                                    PrintError("Syntax error in script: Line %d\n\nIllegal image number: %ld", lineNum, k);\
86
                                    return -1;                  \
86
                                    goto fail;                  \
87
                                }                               \
87
                                }                               \
88
                                if( gl->opt[k].var )            \
88
                                if( gl->opt[k].var )            \
89
                                {                               \
89
                                {                               \
90
                                    PrintError("Conflict in script: Line %d. Multiple Instances of Variable %s Image number: %d (%d)", lineNum, #var, k, gl->opt[k].var); \
90
                                    PrintError("Conflict in script: Line %d. Multiple Instances of Variable %s Image number: %d (%d)", lineNum, #var, k, gl->opt[k].var); \
91
                                    return -1;                  \
91
                                    goto fail;                  \
92
                                }                               \
92
                                }                               \
93
                                gl->opt[k].var   = 1;           \
93
                                gl->opt[k].var   = 1;           \
94
                                n++;                            \
94
                                n++;                            \
95
                                            
95
                                            
96
//Increased so more params can be parsed/optimized (MRDL - March 2002)
96
//Increased so more params can be parsed/optimized (MRDL - March 2002)
97
#define LINE_LENGTH         65536
97
#define LINE_LENGTH         65536
98
99
                                            
100
/* 
101
void panoLocaleSave(void)
102
{
103
    char *p;
104
    p=setlocale(LC_ALL, NULL);
105
    oldLocale=strdup(p);
106
    setlocale(LC_ALL, "C");
107
}
108
*/
109
98
110
#define panoLocaleSave    char *oldLocale;oldLocale=strdup(setlocale(LC_ALL, NULL));setlocale(LC_ALL, "C")
99
#define panoLocaleSave    char *oldLocale;oldLocale=strdup(setlocale(LC_ALL, NULL));setlocale(LC_ALL, "C")
111
100
112
#define panoLocaleRestore (oldLocale != NULL? (setlocale(LC_ALL,oldLocale),free(oldLocale)):0)
101
#define panoLocaleRestore (oldLocale != NULL? (setlocale(LC_ALL,oldLocale),free(oldLocale)):0)
113
102
...
...
377
                                li = panoParseVariable(buf, li, lineNum, &(opt->tiltScaleOpt), &(im->cP.tilt_scale));
366
                                li = panoParseVariable(buf, li, lineNum, &(opt->tiltScaleOpt), &(im->cP.tilt_scale));
378
                                if (opt->tiltScaleOpt > 1) {
367
                                if (opt->tiltScaleOpt > 1) {
379
                                    // it is an actual value to optimize, not a reference... check it
368
                                    // it is an actual value to optimize, not a reference... check it
380
                                    if (im->cP.tilt_scale == 0) {
369
                                    if (im->cP.tilt_scale == 0) {
381
                                        PrintError("TiS parameter can't be zero. Error in script: Line %d", lineNum);
370
                                        PrintError("TiS parameter can't be zero. Error in script: Line %d", lineNum);
382
                                        return -1;
371
                                        goto fail;
383
                                    }
372
                                    }
384
                                }
373
                                }
385
                                break;
374
                                break;
386
                            default:
375
                            default:
387
                                PrintError("Unkonwn parameter Ti%c in script: Line %d", *li, lineNum);
376
                                PrintError("Unkonwn parameter Ti%c in script: Line %d", *li, lineNum);
388
                                return -1;
377
                                goto fail;
389
                            }
378
                            }
390
379
391
                            if (li == NULL) return -1;
380
                            if (li == NULL) goto fail;
392
                            im->cP.tilt    = TRUE;
381
                            im->cP.tilt    = TRUE;
393
382
394
                            break;
383
                            break;
395
                        case 'r': // Translation
384
                        case 'r': // Translation
396
                            li++;
385
                            li++;
...
...
404
                            case 'Z': 
393
                            case 'Z': 
405
                                li = panoParseVariable(buf, li, lineNum, &(opt->transZopt), &(im->cP.trans_z));
394
                                li = panoParseVariable(buf, li, lineNum, &(opt->transZopt), &(im->cP.trans_z));
406
                                break;
395
                                break;
407
                            default:
396
                            default:
408
                                PrintError("Unknown translation parameter Tr%c in script: Line %d", *li, lineNum);
397
                                PrintError("Unknown translation parameter Tr%c in script: Line %d", *li, lineNum);
409
                                return -1;
398
                                goto fail;
410
                            }
399
                            }
411
                            if (li == NULL) return -1;
400
                            if (li == NULL) goto fail;
412
                            // Make sure that we only apply trans when these parameters are not zero
401
                            // Make sure that we only apply trans when these parameters are not zero
413
                            // Otherwise images are not rendered beyond 180 degrees FOV
402
                            // Otherwise images are not rendered beyond 180 degrees FOV
414
                            if (im->cP.trans_x != 0.0 || 
403
                            if (im->cP.trans_x != 0.0 || 
415
                                im->cP.trans_y != 0.0 || 
404
                                im->cP.trans_y != 0.0 || 
416
                                im->cP.trans_z != 0.0) {
405
                                im->cP.trans_z != 0.0) {
...
...
426
                            case 'p': 
415
                            case 'p': 
427
                                li = panoParseVariable(buf, li, lineNum, &(opt->transPitchOpt), &(im->cP.trans_pitch));
416
                                li = panoParseVariable(buf, li, lineNum, &(opt->transPitchOpt), &(im->cP.trans_pitch));
428
                                break;
417
                                break;
429
                            default:
418
                            default:
430
                                PrintError("Unknown translation parameter Tp%c in script: Line %d", *li, lineNum);
419
                                PrintError("Unknown translation parameter Tp%c in script: Line %d", *li, lineNum);
431
                                return -1;
420
                                goto fail;
432
                            }
421
                            }
433
                            if (li == NULL) return -1;
422
                            if (li == NULL) goto fail;
434
                            break;
423
                            break;
435
                        case 'e': // test parameters
424
                        case 'e': // test parameters
436
                            li++;
425
                            li++;
437
                            switch (*li) {
426
                            switch (*li) {
438
                            case '0':  
427
                            case '0':  
...
...
447
                            case '3': 
436
                            case '3': 
448
                                li = panoParseVariable(buf, li, lineNum, &(opt->testP3opt), &(im->cP.test_p3));
437
                                li = panoParseVariable(buf, li, lineNum, &(opt->testP3opt), &(im->cP.test_p3));
449
                                break;
438
                                break;
450
                            default:
439
                            default:
451
                                PrintError("Unknown Test parameter Te%c in script: Line %d", *li, lineNum);
440
                                PrintError("Unknown Test parameter Te%c in script: Line %d", *li, lineNum);
452
                                return -1;
441
                                goto fail;
453
                            }
442
                            }
454
                            if (li == NULL) return -1;
443
                            if (li == NULL) goto fail;
455
                            im->cP.test    = TRUE;
444
                            im->cP.test    = TRUE;
456
                            break;
445
                            break;
457
                        default:
446
                        default:
458
                            PrintError("Unkonwn parameter T%c in script: Line %d", *li, lineNum);
447
                            PrintError("Unkonwn parameter T%c in script: Line %d", *li, lineNum);
459
                            return -1;
448
                            goto fail;
460
                        }
449
                        }
461
                        break;
450
                        break;
462
                    case 'n':           // Set filename
451
                    case 'n':           // Set filename
463
                        nextWord( buf, &li );
452
                        nextWord( buf, &li );
464
                        sprintf( im->name, "%s", buf );
453
                        sprintf( im->name, "%s", buf );
...
...
601
                                case 'S':
590
                                case 'S':
602
                                    READ_OPT_VAR(tiltScaleOpt);
591
                                    READ_OPT_VAR(tiltScaleOpt);
603
                                    break;
592
                                    break;
604
                                default:
593
                                default:
605
                                    PrintError("Unknown variable name variable to optimize Ti%c in script: Line %d", *li, lineNum);
594
                                    PrintError("Unknown variable name variable to optimize Ti%c in script: Line %d", *li, lineNum);
606
                                    return -1;
595
                                    goto fail;
607
                                }
596
                                }
608
                                break;
597
                                break;
609
                            case 'r':
598
                            case 'r':
610
                                li++;
599
                                li++;
611
                                switch (*li) {
600
                                switch (*li) {
...
...
618
                                case 'Z':
607
                                case 'Z':
619
                                    READ_OPT_VAR(transZopt);
608
                                    READ_OPT_VAR(transZopt);
620
                                    break;
609
                                    break;
621
                                default:
610
                                default:
622
                                    PrintError("Unknown variable name to optimize Tr%c in script: Line %d", *li, lineNum);
611
                                    PrintError("Unknown variable name to optimize Tr%c in script: Line %d", *li, lineNum);
623
                                    return -1;
612
                                    goto fail;
624
                                }
613
                                }
625
                                break;
614
                                break;
626
                            case 'p':
615
                            case 'p':
627
                                li++;
616
                                li++;
628
                                switch (*li) {
617
                                switch (*li) {
...
...
632
                                case 'p':
621
                                case 'p':
633
                                    READ_OPT_VAR(transPitchOpt);
622
                                    READ_OPT_VAR(transPitchOpt);
634
                                    break;
623
                                    break;
635
                                default:
624
                                default:
636
                                    PrintError("Unknown variable name to optimize Tp%c in script: Line %d", *li, lineNum);
625
                                    PrintError("Unknown variable name to optimize Tp%c in script: Line %d", *li, lineNum);
637
                                    return -1;
626
                                    goto fail;
638
                                }
627
                                }
639
                                break;
628
                                break;
640
                            case 'e':
629
                            case 'e':
641
                                li++;
630
                                li++;
642
                                switch (*li) {
631
                                switch (*li) {
...
...
652
                                case '3':
641
                                case '3':
653
                                    READ_OPT_VAR(testP3opt);
642
                                    READ_OPT_VAR(testP3opt);
654
                                    break;
643
                                    break;
655
                                default:
644
                                default:
656
                                    PrintError("Unknown variable name to optimize Te%c in script: Line %d", *li, lineNum);
645
                                    PrintError("Unknown variable name to optimize Te%c in script: Line %d", *li, lineNum);
657
                                    return -1;
646
                                    goto fail;
658
                                }
647
                                }
659
                                break;
648
                                break;
660
                            default:
649
                            default:
661
                                PrintError("Unkonwn parameter T%c in script: Line %d", *li, lineNum);
650
                                PrintError("Unkonwn parameter T%c in script: Line %d", *li, lineNum);
662
                                return -1;
651
                                goto fail;
663
                            }                                
652
                            }                                
664
653
665
                            break;
654
                            break;
666
                        case 'X':   READ_VAR( "%d", &k );
655
                        case 'X':   READ_VAR( "%d", &k );
667
                            if( k>=0 && k<gl->numIm )
656
                            if( k>=0 && k<gl->numIm )
...
...
1523
                defCn.x[0]  =   defCn.x[1] =    defCn.y[0]  =   defCn.y[1] = 0;
1512
                defCn.x[0]  =   defCn.x[1] =    defCn.y[0]  =   defCn.y[1] = 0;
1524
                
1513
                
1525
                if( ReadControlPoint( &defCn, &(line[1]) ) != 0 )
1514
                if( ReadControlPoint( &defCn, &(line[1]) ) != 0 )
1526
                {
1515
                {
1527
                    PrintError("Error in line %d", lineNum);
1516
                    PrintError("Error in line %d", lineNum);
1517
                    panoLocaleRestore;
1528
                    return;
1518
                    return;
1529
                }
1519
                }
1530
                if( defCn.num[1] == -1 )    // We found a partial controlpoint
1520
                if( defCn.num[1] == -1 )    // We found a partial controlpoint
1531
                {
1521
                {
1532
                    *lineStart = 0;         // script ends here
1522
                    *lineStart = 0;         // script ends here
...
...
2103
    char *ch = line;
2093
    char *ch = line;
2104
    char buf[LINE_LENGTH];
2094
    char buf[LINE_LENGTH];
2105
    double sigma = 0;
2095
    double sigma = 0;
2106
    int n;
2096
    int n;
2107
2097
2108
    panoLocaleSave;
2109
2110
    memcpy( &theSprefs,     sP,  sizeof(sPrefs) );
2098
    memcpy( &theSprefs,     sP,  sizeof(sPrefs) );
2111
2099
2112
    // set some default values
2100
    // set some default values
2113
    setFcnPanoHuberSigma(0);
2101
    setFcnPanoHuberSigma(0);
2114
    
2102
    
...
...
2116
    {
2104
    {
2117
        switch(*ch)
2105
        switch(*ch)
2118
        {
2106
        {
2119
            case 'g':   READ_VAR( "%lf", &theSprefs.gamma );
2107
            case 'g':   READ_VAR( "%lf", &theSprefs.gamma );
2120
                        if( theSprefs.gamma <= 0.0 )
2108
                        if( theSprefs.gamma <= 0.0 )
2121
                            goto fail;
2109
                            return -1;
2122
                        break;
2110
                        break;
2123
            case 'i':   READ_VAR( "%d", &theSprefs.interpolator );
2111
            case 'i':   READ_VAR( "%d", &theSprefs.interpolator );
2124
                        if( theSprefs.interpolator < 0 ||  theSprefs.interpolator > 23)
2112
                        if( theSprefs.interpolator < 0 ||  theSprefs.interpolator > 23)
2125
                            theSprefs.interpolator = 0;
2113
                            theSprefs.interpolator = 0;
2126
                        break;
2114
                        break;
...
...
2145
    }
2133
    }
2146
    
2134
    
2147
    // appears ok
2135
    // appears ok
2148
    
2136
    
2149
    memcpy( sP,  &theSprefs,    sizeof(sPrefs) );
2137
    memcpy( sP,  &theSprefs,    sizeof(sPrefs) );
2150
    panoLocaleRestore;
2151
    return 0;
2138
    return 0;
2152
2153
 fail:
2154
    panoLocaleRestore;
2155
    return -1;
2156
2139
2157
}
2140
}
2158
2141
2159
// Parse a string desscribing VRPanoOptions
2142
// Parse a string desscribing VRPanoOptions
2160
2143

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks