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

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

Added original make3d

File size: 3.7 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 <limits.h>
23#include <stdlib.h>
24#include <math.h>
25#include <unistd.h>
26#include <sys/wait.h>
27
28#include "vrip.h"
29#include "vripGlobals.h"
30#include "Mesh.h"
31#include "plyio.h"
32#include "vripPlyCmds.h"
33#include "rangePly.h"
34
35int
36Vrip_FillPlyGapsCmd(ClientData, Tcl_Interp *interp, int argc, const char *argv[])
37{
38    if (argc != 3) {
39        interp->result = "Usage: vrip_fillplygaps <file-in> <file-out>";
40        return TCL_ERROR;
41    }
42
43    Mesh *mesh = readMeshFromPly(argv[1], TRUE, FALSE);
44
45    doConfidence(mesh);
46
47    writePlyFile(argv[2], mesh);
48
49    delete mesh;
50
51    return TCL_OK;
52}
53
54
55int
56Vrip_ExtendPlyEdgesCmd(ClientData, Tcl_Interp *interp, int argc, const char *argv[])
57{
58    if (argc != 3) {
59        interp->result = "Usage: vrip_extendplyedges <file-in> <file-out>";
60        return TCL_ERROR;
61    }
62
63    Mesh *mesh = readMeshFromPly(argv[1], FALSE, TRUE);
64
65    doConfidence(mesh);
66
67    writePlyFile(argv[2], mesh);
68
69    delete mesh;
70
71    return TCL_OK;
72}
73
74
75int
76Vrip_PlyConfidenceCmd(ClientData, Tcl_Interp *interp, int argc, const char *argv[])
77{
78    if (argc != 3) {
79        interp->result = "Usage: vrip_plyconf <file-in> <file-out>";
80        return TCL_ERROR;
81    }
82
83    Mesh *mesh = readMeshFromPly(argv[1], FALSE, FALSE);
84
85    doConfidence(mesh);   
86
87    writePlyFile(argv[2], mesh);
88
89    delete mesh;
90
91    return TCL_OK;
92}
93
94
95int
96Vrip_PlyCleanRangeMeshCmd(ClientData, Tcl_Interp *interp, int argc, const char *argv[])
97{
98    if (argc != 3) {
99        interp->result = "Usage: vrip_plycleanrangemesh <file-in> <file-out>";
100        return TCL_ERROR;
101    }
102
103    Mesh *inMesh = readMeshFromPly(argv[1], FALSE, FALSE);
104
105    Mesh *mesh = cleanMeshFromRangeMesh(inMesh);
106
107    doConfidence(mesh);   
108   
109    writePlyFile(argv[2], mesh);
110
111    delete mesh;
112    delete inMesh;
113
114    return TCL_OK;
115}
116
117
118int
119Vrip_PlyCleanMeshCmd(ClientData, Tcl_Interp *interp, int argc, const char *argv[])
120{
121    if (argc != 3) {
122        interp->result = "Usage: vrip_plycleanmesh <file-in> <file-out>";
123        return TCL_ERROR;
124    }
125
126    Mesh *inMesh = readMeshFromPly(argv[1], FALSE, FALSE);
127
128    Mesh *mesh = cleanMesh(inMesh);
129
130    writePlyFile(argv[2], mesh);
131
132    delete mesh;
133    delete inMesh;
134
135    return TCL_OK;
136}
137
138
139int
140Vrip_PlyDepthMapCmd(ClientData, Tcl_Interp *interp, int argc, const char *argv[])
141{
142   float noiseLevel = 0;
143
144   if (argc != 2 && argc != 3) {
145      interp->result = "Usage: vrip_plydmap <file-out> [noise_level]";
146      return TCL_ERROR;
147   }
148   
149   if (argc == 3) {
150      noiseLevel = atof(argv[2]);
151   }
152   
153   theDepthMap->writePly(argv[1], noiseLevel);
154   
155   return TCL_OK;
156}
157
158
159int
160Vrip_PlyRangeGridToMeshCmd(ClientData, Tcl_Interp *interp, 
161                           int argc, const char *argv[])
162{
163   if (argc >= 2) {
164      interp->result = "Usage: vrip_rangegridtomesh [reads from stdin writes to stdout]";
165      return TCL_ERROR;
166   }
167   
168   RangeGrid *rangeGrid = readRangeGrid(NULL);
169
170   if (rangeGrid == NULL)
171      return TCL_ERROR;
172
173   Mesh *mesh = meshFromGrid(rangeGrid, MeshResolution, FALSE);
174   if (mesh == NULL) {
175      delete rangeGrid;
176      return TCL_ERROR;
177   }
178
179   doConfidence(mesh);   
180
181   writePlyFile(NULL, mesh);
182
183   delete mesh;
184   delete rangeGrid;
185
186   return TCL_OK;
187}
188
Note: See TracBrowser for help on using the repository browser.