source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/vrippack-0.31/src/vrip/vripInit.cc @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 8.0 KB
Line 
1/*
2
3Brian Curless
4
5Computer Graphics Laboratory
6Stanford University
7
8---------------------------------------------------------------------
9
10Copyright (1997) The Board of Trustees of the Leland Stanford Junior
11University. Except for commercial resale, lease, license or other
12commercial transactions, permission is hereby given to use, copy,
13modify this software for academic purposes only.  No part of this
14software or any derivatives thereof may be used in the production of
15computer models for resale or for use in a commercial
16product. STANFORD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND
17CONCERNING THIS SOFTWARE.  No support is implied or provided.
18
19*/
20
21
22#include <stdlib.h>
23#include <signal.h>
24
25#include "vrip.h"
26#include "vripGlobals.h"
27#include "scan.h"
28#include "occFunc.h"
29
30#include "vripInit.h"
31#include "vripFillCmds.h"
32#include "vripMiscCmds.h"
33#include "vripGridCmds.h"
34#include "vripFileCmds.h"
35#include "vripRangeCmds.h"
36#include "vripGUICmds.h"
37#include "vripPlyCmds.h"
38
39int
40Vrip_Init(Tcl_Interp *interp)
41{
42    char *occGridDir, *homeDir;
43    char occPath[PATH_MAX], rcPath[PATH_MAX];
44    int code, rcFileExists;
45    Tcl_CmdDeleteProc *nullDeleteProc;
46    ClientData nullClientData;
47
48    Tcl_CreateCommand(interp, "pcreate", PcreateCmd, NULL, NULL);
49    Tcl_CreateCommand(interp, "vrip_newgrid", Vrip_NewGridCmd, NULL, NULL);
50    Tcl_CreateCommand(interp, "vrip_newgridrle", Vrip_NewGridRLECmd, NULL, NULL);
51    Tcl_CreateCommand(interp, "vrip_newgridnormrle", Vrip_NewGridNormRLECmd, 
52                      NULL, NULL);
53    Tcl_CreateCommand(interp, "vrip_writegridnorm", Vrip_WriteGridNormCmd, 
54                      NULL, NULL);
55    Tcl_CreateCommand(interp, "vrip_writegrid", Vrip_WriteGridCmd, NULL, NULL);
56    Tcl_CreateCommand(interp, "vrip_readgrid", Vrip_ReadGridCmd, NULL, NULL);
57    Tcl_CreateCommand(interp, "vrip_readflatgrid", Vrip_ReadFlatGridCmd, 
58                      NULL, NULL);
59    Tcl_CreateCommand(interp, "vrip_writeflatgrid", Vrip_WriteFlatGridCmd, 
60                      NULL, NULL);
61    Tcl_CreateCommand(interp, "vrip_writeden", Vrip_WriteDenCmd, NULL, NULL);
62    Tcl_CreateCommand(interp, "vrip_readrawimages", Vrip_ReadRawImagesCmd, 
63                      NULL, NULL);
64    Tcl_CreateCommand(interp, "vrip_avgdown", Vrip_AvgDownCmd, NULL, NULL);
65    Tcl_CreateCommand(interp, "vrip_avgdownrle", Vrip_AvgDownRLECmd, NULL, NULL);
66    Tcl_CreateCommand(interp, "vrip_extract", Vrip_ExtractCmd, NULL, NULL);
67    Tcl_CreateCommand(interp, "vrip_ellipse", Vrip_EllipseCmd, NULL, NULL);
68    Tcl_CreateCommand(interp, "vrip_ellipserle", Vrip_EllipseRLECmd, NULL, NULL);
69    Tcl_CreateCommand(interp, "vrip_cylinderrle", Vrip_CylinderRLECmd, 
70                      NULL, NULL);
71    Tcl_CreateCommand(interp, "vrip_chair", Vrip_ChairRLECmd, 
72                      NULL, NULL);
73    Tcl_CreateCommand(interp, "vrip_gumdrop_torus", 
74                      Vrip_GumdropTorusRLECmd, NULL, NULL);
75    Tcl_CreateCommand(interp, "vrip_sinewave", 
76                      Vrip_SinewaveRLECmd, NULL, NULL);
77
78    Tcl_CreateCommand(interp, "vrip_fillrle", Vrip_FillRLECmd, NULL, NULL);
79    Tcl_CreateCommand(interp, "vrip_fillplygaps", Vrip_FillPlyGapsCmd, 
80                      NULL, NULL);
81    Tcl_CreateCommand(interp, "vrip_extendplyedges", Vrip_ExtendPlyEdgesCmd, 
82                      NULL, NULL);
83    Tcl_CreateCommand(interp, "vrip_plyconf", Vrip_PlyConfidenceCmd, 
84                      NULL, NULL);
85    Tcl_CreateCommand(interp, "vrip_rangegridtomesh", 
86                      Vrip_PlyRangeGridToMeshCmd, 
87                      NULL, NULL);
88    Tcl_CreateCommand(interp, "vrip_plycleanrangemesh", Vrip_PlyCleanRangeMeshCmd, 
89                      NULL, NULL);
90    Tcl_CreateCommand(interp, "vrip_plycleanmesh", Vrip_PlyCleanMeshCmd, 
91                      NULL, NULL);
92    Tcl_CreateCommand(interp, "vrip_cube", Vrip_CubeCmd, NULL, NULL);
93    Tcl_CreateCommand(interp, "vrip_cuberle", Vrip_CubeRLECmd, NULL, NULL);
94    Tcl_CreateCommand(interp, "vrip_transpxz", Vrip_TransposeXZCmd, NULL, NULL);
95    Tcl_CreateCommand(interp, "vrip_transpyz", Vrip_TransposeYZCmd, NULL, NULL);
96    Tcl_CreateCommand(interp, "vrip_transpxzrle", Vrip_TransposeXZRLECmd, 
97                      NULL, NULL);
98    Tcl_CreateCommand(interp, "vrip_transpxyrle", Vrip_TransposeXYRLECmd, 
99                      NULL, NULL);
100    Tcl_CreateCommand(interp, "vrip_transpyzrle", Vrip_TransposeYZRLECmd, 
101                      NULL, NULL);
102    Tcl_CreateCommand(interp, "vrip_photoslice", Vrip_PhotoSliceCmd, NULL, NULL);
103    Tcl_CreateCommand(interp, "vrip_photoslicerle", Vrip_PhotoSliceRLECmd,
104                      NULL, NULL);
105    Tcl_CreateCommand(interp, "vrip_getvoxelrle", Vrip_GetVoxelRLECmd,
106                      NULL, NULL);
107
108    Tcl_CreateCommand(interp, "vrip_volSize", Vrip_VolSizeCmd,
109                      NULL, NULL);
110    Tcl_CreateCommand(interp, "vrip_photoslicenormrle", 
111                      Vrip_PhotoSliceNormRLECmd, NULL, NULL);
112    Tcl_CreateCommand(interp, "vrip_setrenderphoto", Vrip_SetRenderPhotoCmd, 
113                      NULL, NULL);
114    Tcl_CreateCommand(interp, "vrip_setphotoslice", Vrip_SetPhotoSliceCmd, 
115                      NULL, NULL);
116    Tcl_CreateCommand(interp, "vrip_rangescan", Vrip_RangeScanCmd, NULL, NULL);
117    Tcl_CreateCommand(interp, "vrip_rangescantree", Vrip_RangeScanTreeCmd, 
118                      NULL, NULL);
119    Tcl_CreateCommand(interp, "vrip_rangescanrle", Vrip_RangeScanRLECmd, 
120                      NULL, NULL);
121    Tcl_CreateCommand(interp, "vrip_rangescanrlenotree", Vrip_RangeScanNoTreeRLECmd, 
122                      NULL, NULL);
123    Tcl_CreateCommand(interp, "vrip_rangescannormrle", Vrip_RangeScanNormRLECmd, 
124                      NULL, NULL);
125    Tcl_CreateCommand(interp, "vrip_rangescanedgesrle", 
126                      Vrip_RangeScanEdgesRLECmd, NULL, NULL);
127    Tcl_CreateCommand(interp, "vrip_rangescanlin", Vrip_RangeScanLinePerspCmd, 
128                      NULL, NULL);
129    Tcl_CreateCommand(interp, "vrip_rangescanpersp", Vrip_RangeScanPerspCmd, 
130                      NULL, NULL);
131    Tcl_CreateCommand(interp, "vrip_param", Vrip_ParamCmd, 
132                      NULL, NULL);
133    Tcl_CreateCommand(interp, "vrip_blurvb", Vrip_BlurVisBordersCmd, 
134                      NULL, NULL);
135    Tcl_CreateCommand(interp, "vrip_varfromconst", Vrip_ExpandVarToConstCmd, 
136                      NULL, NULL);
137    Tcl_CreateCommand(interp, "vrip_inforle", Vrip_InfoRLECmd, 
138                      NULL, NULL);
139    Tcl_CreateCommand(interp, "vrip_infonormrle", Vrip_InfoNormRLECmd, 
140                      NULL, NULL);
141    Tcl_CreateCommand(interp, "vrip_copyright", Vrip_CopyrightCmd,
142                      NULL, NULL);
143    Tcl_CreateCommand(interp, "vrip_tess_time", Vrip_TessTimeCmd,
144                      NULL, NULL);
145    Tcl_CreateCommand(interp, "vrip_merge_time", Vrip_MergeTimeCmd,
146                      NULL, NULL);
147    Tcl_CreateCommand(interp, "vrip_resamp_range_time", 
148                      Vrip_ResampleRangeTimeCmd,
149                      NULL, NULL);
150    Tcl_CreateCommand(interp, "vrip_plydmap", 
151                      Vrip_PlyDepthMapCmd,
152                      NULL, NULL);
153    Tcl_CreateCommand(interp, "vrip_calibraterotation", 
154                      Vrip_CalibrateRotationCmd,
155                      NULL, NULL);
156    Tcl_CreateCommand(interp, "vrip_testvascanner", 
157                      Vrip_TestVAScannerCmd,
158                      NULL, NULL);
159
160    theGrid = NULL;
161    frontRLEGrid = NULL;
162    backRLEGrid = NULL;
163    theDepthMap = NULL;
164
165    occGridDir = getenv("VRIP_DIR");
166    if (occGridDir == NULL)
167        occGridDir = ".";
168
169    strcpy(occPath, occGridDir);
170    strcat(occPath, "/vrip.tcl");
171
172    code = Tcl_EvalFile(interp, occPath);
173    if (code != TCL_OK) {
174       // This is an ugly bit of code to get around the fact that the compiler
175       //  doesn't like to pass the result of Tcl_GetVar directly to
176       //  Tcl_SetResult.  It would be better if there were a "free" procedure
177       //  to pass instead of NULL.  Oh well.
178       int length = strlen(Tcl_GetVar (interp, "errorInfo", TCL_GLOBAL_ONLY));
179       char *result = (char *)malloc(length*sizeof(char));
180       strcpy(result, Tcl_GetVar (interp, "errorInfo", TCL_GLOBAL_ONLY));
181       Tcl_SetResult(interp, result, NULL);
182      return TCL_ERROR;
183    }
184
185    homeDir = getenv("HOME");
186    if (homeDir == NULL) {
187       fprintf(stderr, "Environment variable HOME not set - will not execute $HOME/.vriprc\n");
188       return TCL_OK;
189    }
190
191    strcpy(rcPath, homeDir);
192    strcat(rcPath, "/.vriprc");
193    Tcl_VarEval(interp, "file exists ", rcPath, (char *)NULL);
194    rcFileExists = atoi(interp->result);
195
196    if (rcFileExists) {
197       code = Tcl_EvalFile(interp, rcPath);
198    } else {
199       code = TCL_OK;
200    }
201
202    // Don't die on FPE's
203    signal(SIGFPE, SIG_IGN);
204
205    return code;
206}
207
208
Note: See TracBrowser for help on using the repository browser.