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

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

Added original make3d

File size: 3.3 KB
Line 
1/*
2
3Name:         main.c
4
5Coded:        Paul Ning
6
7Modified by:  Brian Curless
8              Computer Graphics Laboratory
9              Stanford University
10
11Comment:      Isosurface reconstruction using Marching Cubes-style
12              table lookup on cube topologies.
13
14
15Copyright (1997) The Board of Trustees of the Leland Stanford Junior
16University. Except for commercial resale, lease, license or other
17commercial transactions, permission is hereby given to use, copy,
18modify this software for academic purposes only.  No part of this
19software or any derivatives thereof may be used in the production of
20computer models for resale or for use in a commercial
21product. STANFORD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND
22CONCERNING THIS SOFTWARE.  No support is implied or provided.
23
24*/
25
26
27#include <stdio.h>
28#include "mc.h"
29#include "var.h"
30#include <stdlib.h>
31#include <string.h>
32#include <unistd.h>
33#include <sys/types.h>
34#include <sys/times.h>
35#include <limits.h>
36//#include <iostream>
37#include <time.h>
38
39clock_t tm;
40
41void printUsage();
42static void start_time();
43static void end_time();
44static void print_time();
45static float time_elapsed();
46
47
48int
49main(int argc, char **argv)
50{
51   int index;
52   
53   start_time();
54   
55   if (argc < 3 || argc > 5) {
56      printUsage();
57      exit(1);
58   }
59   
60   WriteNormals = FALSE;
61   UseValueWeightProduct = FALSE;
62   SaveGradientAsConfidence = FALSE;
63
64   index = 1;
65   char dash[2] = "-";
66
67   threshold = 128;
68
69   // Need to fix this; should use a loop, and thresh should be -thresh
70   while (argv[index][0] == dash[0]) {
71      if (strstr(argv[index], "-n")) {
72         WriteNormals = TRUE;
73         index++;
74      } 
75      else if (strstr(argv[index], "-vw")) {
76         UseValueWeightProduct = TRUE;
77         index++;
78      }
79      else if (strstr(argv[index], "-gc")) {
80         SaveGradientAsConfidence = TRUE;
81         index++;
82      }
83      else if (strstr(argv[index], "-thresh")) {
84         index++;
85         threshold = atoi(argv[index])/256.0;
86         index++;
87      } else {
88         fprintf(stderr, "Invalid command line argument '%s'\n", argv[index]);
89         exit(1);
90      }
91   }
92
93      /*
94   if (strstr(argv[1], "-n")) {
95      WriteNormals = TRUE;
96      index++;
97   }
98   else if (strstr(argv[1], "-vw")) {
99      UseValueWeightProduct = TRUE;
100      index++;
101   }
102   
103   if (strstr(argv[2], "-n")) {
104      WriteNormals = TRUE;
105      index++;
106   }
107   else if (strstr(argv[2], "-vw")) {
108      UseValueWeightProduct = TRUE;
109      index++;
110   }
111   */
112   
113   strcpy(infile, argv[index++]);
114   strcpy(outfile, argv[index++]);
115   
116   if (index < argc)
117      OCC_CONF_THRESHOLD = atoi((char *)argv[index++]);
118   else 
119      OCC_CONF_THRESHOLD = 0;
120   
121   FirstSliceFileNumber = 0;
122   i0 = j_0 = k0 = 1;
123   
124   
125   Init();
126   /*  DoSlices();*/
127   DoSlicesOccRLE();
128
129   end_time();
130   
131   /*    print_time();*/
132   
133   Quit();
134   
135   return 0;
136   
137} /* main */
138
139
140
141void 
142printUsage()
143{
144    printf("Usage: mc <in-rle-file> <out-ply-file> [weight-threshold]\n");
145}
146
147
148static void
149start_time()
150{
151  struct tms buffer;
152  times(&buffer);
153  tm = buffer.tms_utime;
154}
155
156static void
157end_time()
158{
159  struct tms buffer;
160  times(&buffer);
161  tm = buffer.tms_utime - tm;
162}
163
164static void
165print_time()
166{
167   printf("%f seconds\n", (double) tm / (double) CLOCKS_PER_SEC);
168   //std::cout << (double) tm / (double) CLOCKS_PER_SEC << " seconds" << std::endl;
169}
170
171
172static float
173time_elapsed()
174{
175    return (double) tm / (double) CLOCKS_PER_SEC;
176}
177
178
179
Note: See TracBrowser for help on using the repository browser.