1 | /* |
---|
2 | |
---|
3 | Name: init.c |
---|
4 | |
---|
5 | Coded: Paul Ning |
---|
6 | |
---|
7 | Modified by: Brian Curless |
---|
8 | Computer Graphics Laboratory |
---|
9 | Stanford University |
---|
10 | |
---|
11 | Comment: Initialize some global variables. |
---|
12 | |
---|
13 | Copyright (1997) The Board of Trustees of the Leland Stanford Junior |
---|
14 | University. Except for commercial resale, lease, license or other |
---|
15 | commercial transactions, permission is hereby given to use, copy, |
---|
16 | modify this software for academic purposes only. No part of this |
---|
17 | software or any derivatives thereof may be used in the production of |
---|
18 | computer models for resale or for use in a commercial |
---|
19 | product. STANFORD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND |
---|
20 | CONCERNING THIS SOFTWARE. No support is implied or provided. |
---|
21 | |
---|
22 | */ |
---|
23 | |
---|
24 | |
---|
25 | #include <stdio.h> |
---|
26 | #include <string.h> |
---|
27 | #include <math.h> |
---|
28 | #include "mc.h" |
---|
29 | #include <unistd.h> |
---|
30 | |
---|
31 | void Init() |
---|
32 | { |
---|
33 | char OutMCFileName[PATH_MAX+3]; |
---|
34 | int outlength; |
---|
35 | float maxsize; |
---|
36 | |
---|
37 | /* |
---|
38 | * Read the EdgeTable file |
---|
39 | */ |
---|
40 | InitEdgeTable(); |
---|
41 | |
---|
42 | occGrid = new OccGridRLE(10,10,10,CHUNK_SIZE); |
---|
43 | if (!(occGrid->read(infile))) { |
---|
44 | printf("Cannot open file %s for reading\n",infile); |
---|
45 | exit(-1); |
---|
46 | } |
---|
47 | |
---|
48 | |
---|
49 | dx = dy = dz = occGrid->resolution; |
---|
50 | |
---|
51 | printf("Resolution = %f\n", dx); |
---|
52 | |
---|
53 | Nx = occGrid->zdim; |
---|
54 | Ny = occGrid->xdim; |
---|
55 | Nz = occGrid->ydim; |
---|
56 | |
---|
57 | i1 = Nx - 2; |
---|
58 | j_1 = Ny - 2; |
---|
59 | k1 = Nz - 2; |
---|
60 | |
---|
61 | /* |
---|
62 | * Initialize some variables |
---|
63 | */ |
---|
64 | outlength = strlen(outfile); |
---|
65 | strcpy(OutMCFileName,outfile); |
---|
66 | sprintf(&(OutMCFileName[outlength]),".mc"); |
---|
67 | |
---|
68 | maxsize = Nx*dx; |
---|
69 | if (Ny*dy > maxsize) maxsize = Ny*dy; |
---|
70 | if (Nz*dz > maxsize) maxsize = Nz*dz; |
---|
71 | FtoSScale = maxsize/65520.0; |
---|
72 | NrmMagScale = sqrt((double) 1/(dx*dx)+1/(dy*dy)+1/(dz*dz)) * 255.0/2.0/254.0; |
---|
73 | |
---|
74 | xstart = Nx/2.0*dx + occGrid->origin[2]; |
---|
75 | ystart = Ny/2.0*dy + occGrid->origin[0]; |
---|
76 | zstart = Nz/2.0*dz + occGrid->origin[1]; |
---|
77 | |
---|
78 | xstart = 0; |
---|
79 | ystart = 0; |
---|
80 | zstart = 0; |
---|
81 | |
---|
82 | |
---|
83 | /* |
---|
84 | * Initialize the output file |
---|
85 | */ |
---|
86 | |
---|
87 | |
---|
88 | /* |
---|
89 | if (!(OutMCFile = fopen(OutMCFileName,"w"))) |
---|
90 | Fatal("Cannot open MC file for writing"); |
---|
91 | |
---|
92 | MC_InitHeader(OutMCFile); |
---|
93 | */ |
---|
94 | |
---|
95 | } /* Init */ |
---|
96 | |
---|
97 | |
---|