Changeset 2127 for GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs
- Timestamp:
- 02/19/07 09:16:59 (18 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi
- Files:
-
- 2 added
- 2 deleted
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/camera.h
r2090 r2127 18 18 } Camera; 19 19 20 extern Camera *loadCameras(GLdouble radius, char* filename, GLuint *numCameras);21 extern void saveCameras(char* filename, Camera *cameras, GLuint numCameras);20 extern Camera *loadCameras(GLdouble radius, char* filename, int *numCameras); 21 extern void saveCameras(char* filename, Camera *cameras, int numCameras); 22 22 extern void copyToCameras(Camera *cameras, int numVertices, GLdouble vertices[][3]); 23 extern void setCameraWeights(Camera *cameras, GLuint numCameras, GLdouble *weights);24 extern Camera *setCameras(GLdouble radius, GLuint type, GLuint *numCameras);25 extern void printCameras(Camera *cameras, GLuint numCameras);23 extern void setCameraWeights(Camera *cameras, int numCameras, GLdouble *weights); 24 extern Camera *setCameras(GLdouble radius, int type, int *numCameras); 25 extern void printCameras(Camera *cameras, int numCameras); 26 26 27 27 extern void drawSphere(Camera *cameras, GLdouble radius, int slices, int stacks); -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/change.h
r2090 r2127 68 68 extern void modifyTriangle(Triangle *t, int c, int p); 69 69 extern int isATriangleToModify(Triangle *t, int c); 70 extern Triangle *getTrianglesToModify(Mesh *mesh, Change *c, GLuint *numMod);70 extern Triangle *getTrianglesToModify(Mesh *mesh, Change *c, int *numMod); 71 71 extern int isATriangleToDelete(Triangle *t, int c, int p); 72 extern Triangle *getTrianglesToDelete(Mesh *mesh, Change *c, GLuint *numDel);72 extern Triangle *getTrianglesToDelete(Mesh *mesh, Change *c, int *numDel); 73 73 74 74 extern void modifyTriangles(Mesh *mesh, Change *c); … … 85 85 86 86 extern void modifyEdges(Mesh *mesh, Change *c); 87 extern void deleteEdges(Mesh *mesh, Change *c); 87 extern int find(int *edges, int num, int v_); 88 extern void updateEdgeAdj(Mesh *mesh, Change *c) ; 88 89 89 90 // Save simplification sequence in Geometry Game Tools format. … … 92 93 //extern std::map<int, INTVECTOR> inversemap; 93 94 extern void swap(int *i, int *j); 94 extern int hasEdge(Triangle *t, int e); 95 extern void getEdges(Triangle *t, Change *c, int *d, int *a); 95 96 96 } 97 97 #endif -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/color.h
r2090 r2127 14 14 } Color; 15 15 16 extern Color *initColors( GLuint numColors);17 extern void fillAllColors(Color *colors, GLuint numColors, GLuint begin, GLuint end, GLubyte color);18 extern void setColors(Color *colors, GLuint numPasses, GLuint begin, GLuint end);19 extern void setColors2(Color *colors, GLuint numColors, GLuint begin, GLuint end);20 extern void setColors3(Color *colors, GLuint numColors, GLubyte color);21 extern void setColors4(Color *colors, GLuint numColors);22 extern void viewColors(Color *colors, GLuint numColors);16 extern Color *initColors(int numColors); 17 extern void fillAllColors(Color *colors, int numColors, int begin, int end, GLubyte color); 18 extern void setColors(Color *colors, int numPasses, int begin, int end); 19 extern void setColors2(Color *colors, int numColors, int begin, int end); 20 extern void setColors3(Color *colors, int numColors, GLubyte color); 21 extern void setColors4(Color *colors, int numColors); 22 extern void viewColors(Color *colors, int numColors); 23 23 24 24 } -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/global.h
r2090 r2127 60 60 //#define SALIENCY 61 61 62 #define CHECK_LOCAL_INVERSION 63 62 64 // Extension added into the filename 63 65 #ifdef KL // Kullback-Leibler … … 73 75 #define EXT "VCS" 74 76 #endif 75 76 //#define USE_EDGE_ADJACENCY77 77 78 78 #define CHECK_OPENGL_ERROR( cmd ) \ … … 109 109 110 110 extern Camera *cameras; 111 extern GLuint numCameras;111 extern int numCameras; 112 112 113 113 extern Color *colors; 114 114 115 extern GLuint **histogram,116 115 extern int **histogram; 116 extern GLuint *queries; 117 117 118 118 extern Mesh *mesh; … … 122 122 extern GLdouble radius; 123 123 extern GLdouble fov; 124 extern GLuint numDemandedTriangles,124 extern int numDemandedTriangles, 125 125 cameraType; 126 126 extern GLboolean bBeQuiet, … … 138 138 extern void init(void); 139 139 140 extern void renderScene(GLuint **histogram, GLuint numCameras); 141 extern void renderSceneWin(GLuint **histogram, GLuint numCameras, Change *c); 140 extern void resetProjectedAreas(int **histogram, int numCameras); 141 extern void getProjectedAreas(int **histogram, int numCameras); 142 extern void getProjectedAreasWin(int **histogram, int numCameras, Change *c); 142 143 143 144 extern void renderGeometry(void); … … 150 151 151 152 extern void applyHWAcceleration(void); 153 extern void updateHWAcceleration(Change *c); 152 154 extern void setOrthographicProjection(void); 153 155 extern void resetPerspectiveProjection(void); -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/histogram.h
r2090 r2127 11 11 { 12 12 13 extern void getSubHistogram( GLuint subHistoGram[][4]);14 extern void copySubHistogram(Color *colors, GLuint *histogram, GLuint begin, GLuint end, GLuint subHistoGram[][4]);15 extern void printHistogram( GLuint histoGram[][4]);16 extern void plotHistogram( GLuint histoGram[][4]);13 extern void getSubHistogram(int subHistoGram[][4]); 14 extern void copySubHistogram(Color *colors, int *histogram, int begin, int end, int subHistoGram[][4]); 15 extern void printHistogram(int histoGram[][4]); 16 extern void plotHistogram(int histoGram[][4]); 17 17 18 extern GLuint **initHistogram(GLuint numTriangles, GLuint numCameras);19 extern void deleteHistogram( GLuint **histogram, GLuint numCameras);20 extern void printFullHistogram( GLuint **histogram, GLuint numCameras, GLuint numTriangles);21 extern void getSWHistogram( GLuint *histogram, GLubyte *pixels);22 extern void getSWHistogramWin( GLuint *histogram, GLubyte *pixels, GLfloat min[3], GLfloat max[3], Change *c);23 extern void getSWHistoByOcclusionQuery(Mesh *mesh, Color *colors, GLuint *histogram);18 extern int **initHistogram(int numTriangles, int numCameras); 19 extern void deleteHistogram(int **histogram, int numCameras); 20 extern void printFullHistogram(int **histogram, int numCameras, int numTriangles); 21 extern void getSWHistogram(int *histogram, GLubyte *pixels); 22 extern void getSWHistogramWin(int *histogram, GLubyte *pixels, GLfloat min[3], GLfloat max[3], Change *c); 23 extern void getSWHistoByOcclusionQuery(Mesh *mesh, Color *colors, int *histogram); 24 24 25 extern void resetSWHistogram( GLuint *histogram, GLuint numTriangles);25 extern void resetSWHistogram(int *histogram, int numTriangles); 26 26 extern void getBoundingBox(Change *c, GLfloat min[3], GLfloat max[3]); 27 27 extern void getWindow(GLfloat min[3], GLfloat max[3], int minw[2], int maxw[2]); -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/mesh.h
r2090 r2127 7 7 8 8 typedef struct _Vertex { 9 GLfloat x, y, z; // Vertex coordinates 10 GLuint numTriangles; // Number of triangles 11 GLuint *triangles; // List of triangles 9 float x, y, z; // Vertex coordinates 10 int numTriangles; // Number of triangles 11 int *triangles; // List of triangles 12 int numEdges; 13 int *edges; 12 14 int enable; 13 15 int movable; // If vertex is part of a border. … … 15 17 16 18 typedef struct _Edge { 17 GLuint u, v; // Edge vertices 18 GLuint *triangles; // Edge triangles 19 GLuint numTriangles; // Number of triangles 19 int u, v; // Edge vertices 20 20 int enable; 21 21 } Edge; 22 22 23 23 typedef struct _Triangle { 24 GLuint id; // Triangle id 25 GLuint group; // Triangle group 26 GLuint submesh; // Triangle submesh 27 GLuint indices[3]; // Triangle vertices 28 GLuint edges[3]; // Triangle edges 29 GLfloat normal[3]; // Triangle normal 30 GLdouble area; // Triangle area 31 GLdouble saliency; // Triangle saliency 24 int id; // Triangle id 25 int group; // Triangle group 26 int submesh; // Triangle submesh 27 int indices[3]; // Triangle vertices 28 float normal[3]; // Triangle normal 29 double area; // Triangle area 30 double saliency; // Triangle saliency 32 31 int enable; 33 32 } Triangle; … … 35 34 typedef struct _Mesh { 36 35 Vertex *vertices; // Mesh vertices 37 GLuint numVertices; // Number of vertices38 GLuint currentNumVertices; // Current number of vertices36 int numVertices; // Number of vertices 37 int currentNumVertices; // Current number of vertices 39 38 Edge *edges; // Mesh edges 40 GLuint numEdges; // Number of edges39 int numEdges; // Number of edges 41 40 Triangle *triangles; // Mesh triangles 42 GLuint numTriangles; // Number of triangles43 GLuint currentNumTriangles; // Current number of triangles41 int numTriangles; // Number of triangles 42 int currentNumTriangles; // Current number of triangles 44 43 } Mesh; 45 44 46 45 extern GLdouble computeTriangleArea(Vertex *vertices, Triangle *t); 46 extern double computeEdgeLength(Vertex *vertices, int u, int v); 47 47 extern void computeTriangleNormal(Vertex *vertices, Triangle *t); 48 extern double computeTriangleVolume(Vertex *vertices, Triangle *t); 48 49 49 50 extern Vertex *addVertex(Vertex *list, int *n, float x, float y, float z, int *pos); 50 extern int findEdge(Edge *e, GLuint num, GLuint _u, GLuint _v);51 extern int findEdge(Edge *e, int num, int _u, int _v); 51 52 extern Edge *addEdge(Edge *list, int *n, int u, int v, int *pos); 52 extern GLboolean findVertex( GLfloat *vertices, GLuint num, GLfloat x, GLfloat y, GLfloat z, int *pos);53 extern GLboolean findVertex(float *vertices, int num, float x, float y, float z, int *pos); 53 54 54 55 extern Mesh *initMesh(GLMmodel* pmodel); … … 56 57 extern void printMesh(Mesh *mesh); 57 58 extern void saveModel(char *filename, GLMmodel* pmodel, Mesh *mesh); 58 extern void updateModel(GLMmodel* pmodel, Mesh *mesh, GLuint numVertices, GLuint numTriangles);59 extern void updateModel(GLMmodel* pmodel, Mesh *mesh, int numVertices, int numTriangles); 59 60 60 61 extern int *trianglesAdjToEdge(Mesh *mesh, int e, int *n); 61 62 extern int *verticesAdjToVertex(Mesh *mesh, int v, int *n); 62 extern int *edgesAdjToVertex(Mesh *mesh, int v, int *n);63 63 extern int *edgesAdjToVertices(Mesh *mesh, int *vertices, int numVertices, int *n); 64 64 -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/metrics.h
r2090 r2127 8 8 namespace VMI 9 9 { 10 extern GLdouble computeMI(Mesh *mesh, GLuint **histogram, GLuint numCameras, GLuint cam);11 extern GLdouble decMI(GLdouble I, GLuint **histogram, GLuint numCameras, GLuint cam, Change *c);12 extern GLdouble incMI(GLdouble I, GLuint **histogram, GLuint numCameras, GLuint cam, Change *c);10 extern GLdouble computeMI(Mesh *mesh, int **histogram, int numCameras, int cam); 11 extern GLdouble decMI(GLdouble I, int **histogram, int numCameras, int cam, Change *c); 12 extern GLdouble incMI(GLdouble I, int **histogram, int numCameras, int cam, Change *c); 13 13 14 extern GLdouble computeHE(Mesh *mesh, GLuint *histogram);15 extern GLdouble computeKL(Mesh *mesh, GLuint *histogram);16 extern GLdouble computeCS(Mesh *mesh, GLuint *histogram);14 extern GLdouble computeHE(Mesh *mesh, int *histogram); 15 extern GLdouble computeKL(Mesh *mesh, int *histogram); 16 extern GLdouble computeCS(Mesh *mesh, int *histogram); 17 17 18 extern GLdouble computeMeanProjArea( GLuint **histogram, GLuint numCameras, int t);19 extern GLdouble computeJS( GLuint **histogram, GLuint numCameras, GLuint j, GLuint k);20 extern GLdouble computeEntropy( GLuint **histogram, GLuint numCameras, GLuint k);21 extern GLdouble computeMixedEntropy(GLdouble *mixed, GLuint numCameras);22 extern GLdouble computeMeanProjAreaNoBG( GLuint **histogram, GLuint numCameras, int t);18 extern GLdouble computeMeanProjArea(int **histogram, int numCameras, int t); 19 extern GLdouble computeJS(int **histogram, int numCameras, int j, int k); 20 extern GLdouble computeEntropy(int **histogram, int numCameras, int k); 21 extern GLdouble computeMixedEntropy(GLdouble *mixed, int numCameras); 22 extern GLdouble computeMeanProjAreaNoBG(int **histogram, int numCameras, int t); 23 23 24 extern void getProjectedAreas(GLuint **histogram, GLuint numCameras); 25 extern void getProjectedAreasWin(GLuint **histogram, GLuint numCameras, Change *c); 26 extern void resetProjectedAreas(GLuint **histogram, GLuint numCameras); 27 28 extern GLdouble *initIs(GLuint numCameras); 29 extern void computeCameraIs(GLuint **histogram, GLuint numCameras, GLdouble *mis); 30 extern void printIs(GLdouble *mis, GLuint numCameras); 24 extern GLdouble *initIs(int numCameras); 25 extern void computeCameraIs(int **histogram, int numCameras, GLdouble *mis); 26 extern void printIs(GLdouble *mis, int numCameras); 31 27 } 32 28 #endif -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/saliency.h
r2090 r2127 13 13 extern double percentile; 14 14 15 extern void computeSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras);16 extern void updateTriangleSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras, int v);15 extern void computeSaliency(Mesh *mesh, int **histogram, int numCameras); 16 extern void updateTriangleSaliency(Mesh *mesh, int **histogram, int numCameras, int v); 17 17 18 extern double computeTriangleSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras, GLuint k);18 extern double computeTriangleSaliency(Mesh *mesh, int **histogram, int numCameras, int k); 19 19 20 20 extern double computeEdgeSaliency(Mesh *mesh, Change *c, double p); -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/simplify.h
r2090 r2127 19 19 extern bheap_t *updateHeap(bheap_t *h, Mesh *mesh, Change *c); 20 20 21 extern void simplifyModel(Mesh *mesh, GLuint numDemandedTri);21 extern void simplifyModel(Mesh *mesh, int numDemandedTri); 22 22 23 23 24 24 extern void bh_mydump(Mesh *mesh, bheap_t *h); 25 extern GLdouble computeEdgeLength(Vertex *vertices, int u, int v);26 25 27 26 extern void chooseBestEndPoints(Mesh *mesh, int e); -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/vmi_simplifier.h
r983 r2127 13 13 #include "saliency.h" 14 14 #include "simplify.h" 15 #include " interleave.h"15 #include "buffers.h" 16 16 -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/camera.cpp
r2090 r2127 14 14 //#define DRAW_DEBUG // just for debugging not necessary 15 15 16 Camera *VMI::loadCameras(GLdouble radius, char* filename, GLuint *numCameras) {16 Camera *VMI::loadCameras(GLdouble radius, char* filename, int *numCameras) { 17 17 FILE *fp; 18 18 Camera *cameras; 19 GLuint num, i;19 int num, i; 20 20 GLfloat eyeX, eyeY, eyeZ, 21 21 centerX, centerY, centerZ, … … 118 118 } 119 119 120 void VMI::saveCameras(char* filename, Camera *cameras, GLuint numCameras) {120 void VMI::saveCameras(char* filename, Camera *cameras, int numCameras) { 121 121 FILE *fp; 122 GLuint i;122 int i; 123 123 124 124 if((fp= fopen(filename, "wt"))== NULL) { … … 170 170 } 171 171 172 Camera *VMI::setCameras(GLdouble radius, GLuint type, GLuint *numCameras) {172 Camera *VMI::setCameras(GLdouble radius, int type, int *numCameras) { 173 173 Camera *cameras = NULL; 174 174 … … 221 221 } 222 222 223 void VMI::setCameraWeights(Camera *cameras, GLuint numCameras, GLdouble *weights) {224 GLuint i;223 void VMI::setCameraWeights(Camera *cameras, int numCameras, GLdouble *weights) { 224 int i; 225 225 226 226 for (i = 0; i<numCameras; i++) { … … 229 229 } 230 230 231 void VMI::printCameras(Camera *cameras, GLuint numCameras) {232 GLuint i;231 void VMI::printCameras(Camera *cameras, int numCameras) { 232 int i; 233 233 234 234 printf("\n"); -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/change.cpp
r2090 r2127 157 157 if (c->numMod > 0) { 158 158 mesh->vertices[c->v].triangles = 159 ( GLuint *)realloc(mesh->vertices[c->v].triangles,160 (mesh->vertices[c->v].numTriangles + mesh->vertices[c->u].numTriangles) * sizeof( GLuint));159 (int *)realloc(mesh->vertices[c->v].triangles, 160 (mesh->vertices[c->v].numTriangles + mesh->vertices[c->u].numTriangles) * sizeof(int)); 161 161 } 162 162 … … 193 193 } 194 194 195 int VMI::hasEdge(Triangle *t, int e) {196 int e0 = t->edges[0],197 e1 = t->edges[1],198 e2 = t->edges[2];199 200 if ((e == e0) || (e == e1) || (e == e2)) return TRUE;201 202 return FALSE;203 }204 205 void VMI::getEdges(Triangle *t, Change *c, int *l, int *r) {206 207 // Default edges208 *l = -1;209 *r = -1;210 211 // Set edge l and r212 if ((int)t->edges[0] == c->e) {213 *l = t->edges[1];214 *r = t->edges[2];215 if ((int)mesh->edges[*l].u == c->v || (int)mesh->edges[*l].v == c->v)216 swap(l, r);217 } else if ((int)t->edges[1] == c->e) {218 *l = t->edges[0];219 *r = t->edges[2];220 if ((int)mesh->edges[*l].u == c->v || (int)mesh->edges[*l].v == c->v)221 swap(l, r);222 } else if ((int)t->edges[2] == c->e) {223 *l = t->edges[0];224 *r = t->edges[1];225 if ((int)mesh->edges[*l].u == c->v || (int)mesh->edges[*l].v == c->v)226 swap(l, r);227 }228 }229 230 195 void VMI::swap(int *i, int *j) { 231 196 int t; … … 238 203 void VMI::deleteTriangles(Mesh *mesh, Change *c) 239 204 { 240 int i, j, t, v; 241 #ifdef USE_EDGE_ADJACENCY 242 int t1, l, r; 243 #endif 205 int i, j, t, v; 244 206 245 207 for (i=0; i<c->numDel; i++) { … … 255 217 } 256 218 257 #ifdef USE_EDGE_ADJACENCY258 // Update triangle edge adjancency259 // The modified triangles have to be calculated before260 // Set edge l and r261 getEdges(&c->deleted[i], c, &l, &r);262 //printf("e%d(%d,%d): l:%d r:%d\n", c->e, c->u, c->v, l, r);263 // Find triangle that contains edge l264 for (j=0; j<c->numMod; j++)265 if (hasEdge(&c->modified[j], l)) {266 // Change edge l by r in the Mesh267 t1 = c->modified[j].id;268 //printf("t:%d %d %d %d\n", t1, mesh->triangles[t1].edges[0], mesh->triangles[t1].edges[1] ,mesh->triangles[t1].edges[2]);269 if (mesh->triangles[t1].edges[0] == (GLuint)l) mesh->triangles[t1].edges[0] = r;270 if (mesh->triangles[t1].edges[1] == (GLuint)l) mesh->triangles[t1].edges[1] = r;271 if (mesh->triangles[t1].edges[2] == (GLuint)l) mesh->triangles[t1].edges[2] = r;272 //printf("t:%d %d %d %d\n", t1, mesh->triangles[t1].edges[0], mesh->triangles[t1].edges[1] ,mesh->triangles[t1].edges[2]);273 break;274 }275 276 // Delete edge l277 if (l != -1) mesh->edges[l].enable = FALSE;278 #endif279 219 mesh->triangles[t].enable = FALSE; 280 220 mesh->currentNumTriangles--; … … 301 241 addItem((int *)mesh->vertices[v].triangles,(int *)&mesh->vertices[v].numTriangles,t); 302 242 } 303 #ifdef USE_EDGE_ADJACENCY 304 // Enable adjacent edges 305 for (j=0; j<3; j++) { 306 mesh->edges[mesh->triangles[t].edges[j]].enable = TRUE; 307 } 308 #endif 243 309 244 mesh->triangles[t].enable = TRUE; 310 245 mesh->currentNumTriangles++; … … 312 247 } 313 248 314 Triangle *VMI::getTrianglesToModify(Mesh *mesh, Change *c, GLuint *numMod) {249 Triangle *VMI::getTrianglesToModify(Mesh *mesh, Change *c, int *numMod) { 315 250 int i, t; 316 251 Triangle *modified = NULL; … … 336 271 } 337 272 338 Triangle *VMI::getTrianglesToDelete(Mesh *mesh, Change *c, GLuint *numDel) {273 Triangle *VMI::getTrianglesToDelete(Mesh *mesh, Change *c, int *numDel) { 339 274 int i, t; 340 275 Triangle *deleted = NULL; … … 359 294 } 360 295 361 void VMI:: deleteEdges(Mesh *mesh, Change *c) {296 void VMI::modifyEdges(Mesh *mesh, Change *c) { 362 297 int i, e; 363 #ifndef USE_EDGE_ADJACENCY 364 int n0, n1, n2; 365 #else 366 int j, u, v; 367 #endif 368 369 #ifdef USE_EDGE_ADJACENCY 370 for (i=0; i<c->numDel; i++) { 298 299 for(i = 0; i < mesh->vertices[c->v].numEdges; i++) { 371 300 372 for (j=0; j<3; j++) { 373 e = c->deleted[i].edges[j]; 374 if (e != c->e) { 375 u = mesh->edges[e].u; 376 v = mesh->edges[e].v; 377 if (u == c->u || v == c->u) { 378 //printf("%d\n",j); 379 mesh->edges[e].enable = FALSE; 380 } 381 } 382 } 383 //getchar(); 384 } 385 #else 386 for (i=0; i<c->numDel; i++) { 387 388 n0 = c->deleted[i].indices[0]; 389 n1 = c->deleted[i].indices[1]; 390 n2 = c->deleted[i].indices[2]; 391 392 if ((n0 == c->u && n1 != c->v) || (n1 == c->u && n0 != c->v)) { 393 e = findEdge(mesh->edges, mesh->numEdges, n0, n1); 394 395 //printf("a\n"); 396 if (e != -1) 397 mesh->edges[e].enable = FALSE; 398 } 399 400 if ((n1 == c->u && n2 != c->v) || (n2 == c->u && n1 != c->v)) { 401 e = findEdge(mesh->edges, mesh->numEdges, n1, n2); 402 403 //printf("b\n"); 404 if (e != -1) 405 mesh->edges[e].enable = FALSE; 406 } 407 408 if ((n0 == c->u && n2 != c->v) || (n2 == c->u && n0 != c->v)) { 409 e = findEdge(mesh->edges, mesh->numEdges, n0, n2); 410 411 //printf("c\n"); 412 if (e != -1) 413 mesh->edges[e].enable = FALSE; 414 } 415 //getchar(); 416 } 417 #endif 418 } 419 420 void VMI::modifyEdges(Mesh *mesh, Change *c) { 421 int e, u, v; 422 423 // Update mesh and heap 424 for(e = 0; e < (int)mesh->numEdges; e++) { 425 301 e = mesh->vertices[c->v].edges[i]; 302 426 303 if (mesh->edges[e].enable == TRUE) { 427 304 428 305 // Modify edge 429 if ( (int)mesh->edges[e].u == c->u)306 if (mesh->edges[e].u == c->u) 430 307 mesh->edges[e].u = c->v; 431 308 432 if ( (int)mesh->edges[e].v == c->u)309 if (mesh->edges[e].v == c->u) 433 310 mesh->edges[e].v = c->v; 434 435 // Check edge436 u = mesh->edges[e].u;437 v = mesh->edges[e].v;438 439 // if the edge is not valid, we simply delete it440 if ((u == v) ||441 (u == c->u) || (v == c->u))442 443 mesh->edges[e].enable = FALSE;444 311 } 445 312 } 446 313 } 447 314 315 int VMI::find(int *edges, int num, int v_) { 316 int i; 317 318 int u, v; 319 320 321 for(i=0; i<num; i++) { 322 323 u = mesh->edges[edges[i]].u; 324 325 v = mesh->edges[edges[i]].v; 326 327 if (u == v_ || v == v_) return TRUE; 328 329 } 330 331 return FALSE; 332 } 333 void VMI::updateEdgeAdj(Mesh *mesh, Change *c) { 334 int i; 335 336 int v, e; 337 338 mesh->vertices[c->v].edges = 339 (int *)realloc(mesh->vertices[c->v].edges, 340 (mesh->vertices[c->v].numEdges + mesh->vertices[c->u].numEdges) * sizeof(int)); 341 342 for (i=0; i<mesh->vertices[c->u].numEdges; i++) { 343 344 e = mesh->vertices[c->u].edges[i]; 345 if (mesh->edges[e].u == c->u) v =mesh->edges[e].v; 346 else v = mesh->edges[e].u; 347 348 if (!find(mesh->vertices[c->v].edges, mesh->vertices[c->v].numEdges, v)) 349 addItem(mesh->vertices[c->v].edges, &mesh->vertices[c->v].numEdges, e); 350 else mesh->edges[e].enable = FALSE; 351 } 352 353 delItem(mesh->vertices[c->v].edges, &mesh->vertices[c->v].numEdges, c->e); 354 } 355 448 356 /////////////////////////////////////////////////////////////////////////////// 449 357 450 358 // Compute the triangle mesh changes due to a heap node simplification 451 359 void VMI::computeChange(Mesh *mesh, Change *c) { 452 GLuint numMod, numDel;360 int numMod, numDel; 453 361 Triangle *m = getTrianglesToModify(mesh, c, &numMod), 454 362 *d = getTrianglesToDelete(mesh, c, &numDel); -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/color.cpp
r2090 r2127 7 7 using namespace VMI; 8 8 9 Color *VMI::initColors( GLuint numColors) {9 Color *VMI::initColors(int numColors) { 10 10 Color *colors; 11 11 … … 25 25 } 26 26 27 void VMI::fillAllColors(Color *colors, GLuint numColors, GLuint begin, GLuint end, GLubyte color) {28 GLuint i;27 void VMI::fillAllColors(Color *colors, int numColors, int begin, int end, GLubyte color) { 28 int i; 29 29 30 30 if (end > numColors) return; … … 40 40 } 41 41 42 void VMI::setColors(Color *colors, GLuint numPasses, GLuint begin, GLuint end) {43 GLuint i, step = numPasses * MAX_NUM_COLORS;42 void VMI::setColors(Color *colors, int numPasses, int begin, int end) { 43 int i, step = numPasses * MAX_NUM_COLORS; 44 44 GLubyte r = 1, 45 45 g = 1, … … 86 86 } 87 87 88 void VMI::setColors2(Color *colors, GLuint numColors, GLuint begin, GLuint end) {89 GLuint i,88 void VMI::setColors2(Color *colors, int numColors, int begin, int end) { 89 int i, 90 90 channel = 0, 91 91 step = (numColors < MAX_NUM_COLORS) ? (MAX_NUM_COLORS / numColors) : 1; … … 133 133 } 134 134 135 void VMI::setColors3(Color *colors, GLuint numColors, GLubyte color) {136 GLuint i;135 void VMI::setColors3(Color *colors, int numColors, GLubyte color) { 136 int i; 137 137 138 138 for (i = 0; i < numColors; i++) { … … 148 148 } 149 149 150 void VMI::setColors4(Color *colors, GLuint numColors) {151 GLuint i, c = 1;150 void VMI::setColors4(Color *colors, int numColors) { 151 int i, c = 1; 152 152 153 153 for (i = 0; i < numColors; i++) { … … 164 164 } 165 165 166 void VMI::viewColors(Color *colors, GLuint numColors) {167 GLuint i;166 void VMI::viewColors(Color *colors, int numColors) { 167 int i; 168 168 169 169 printf("\n"); -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/histogram.cpp
r2090 r2127 14 14 using namespace VMI; 15 15 16 void VMI::printHistogram( GLuint histoGram[][4]) {16 void VMI::printHistogram(int histoGram[][4]) { 17 17 int i; 18 18 … … 23 23 } 24 24 25 void VMI::plotHistogram( GLuint histoGram[][4]) {25 void VMI::plotHistogram(int histoGram[][4]) { 26 26 int i; 27 GLuint iLargest = 0; // Largest histogram value27 int iLargest = 0; // Largest histogram value 28 28 GLfloat maxHeight = height / 2.0f; 29 29 … … 72 72 } 73 73 74 GLuint **VMI::initHistogram(GLuint numTriangles, GLuint numCameras) {75 GLuint i;76 GLuint **histogram;77 78 histogram = ( GLuint **)malloc(sizeof(GLuint *) * numCameras);74 int **VMI::initHistogram(int numTriangles, int numCameras) { 75 int i; 76 int **histogram; 77 78 histogram = (int **)malloc(sizeof(int *) * numCameras); 79 79 80 80 if (histogram == NULL) { … … 84 84 85 85 for (i=0; i<numCameras; i++) 86 histogram[i] = ( GLuint *)malloc(sizeof(GLuint) * (numTriangles + 1)); // + 1 because the last is the numPixels of the background86 histogram[i] = (int *)malloc(sizeof(int) * (numTriangles + 1)); // + 1 because the last is the numPixels of the background 87 87 88 88 // Fill the histogram buffer with 0 89 89 for (i=0; i<numCameras; i++) 90 memset(histogram[i], 0, sizeof( GLuint) * (numTriangles + 1));90 memset(histogram[i], 0, sizeof(int) * (numTriangles + 1)); 91 91 92 92 return histogram; 93 93 } 94 94 95 void VMI::deleteHistogram( GLuint **histogram, GLuint numCameras) {96 GLuint i;95 void VMI::deleteHistogram(int **histogram, int numCameras) { 96 int i; 97 97 98 98 for (i=0;i<numCameras;i++) … … 102 102 } 103 103 104 void VMI::printFullHistogram( GLuint **histogram, GLuint numCameras, GLuint numTriangles) {105 GLuint i, j;104 void VMI::printFullHistogram(int **histogram, int numCameras, int numTriangles) { 105 int i, j; 106 106 107 107 printf("\n"); … … 116 116 } 117 117 118 void VMI::getSubHistogram( GLuint subHistoGram[][4]) {118 void VMI::getSubHistogram(int subHistoGram[][4]) { 119 119 //printf("Computing histogram...\n"); 120 120 // Define the histogram … … 137 137 } 138 138 139 void VMI::copySubHistogram(Color *colors, GLuint *histogram, GLuint begin, GLuint end, GLuint subHistoGram[][4]) {140 GLuint i;139 void VMI::copySubHistogram(Color *colors, int *histogram, int begin, int end, int subHistoGram[][4]) { 140 int i; 141 141 GLubyte r, g, b, a; 142 GLuint h = 0;142 int h = 0; 143 143 144 144 for (i=begin; i<end; i++) { … … 165 165 } 166 166 167 void VMI::getSWHistogram( GLuint *histogram, GLubyte *pixels) {167 void VMI::getSWHistogram(int *histogram, GLubyte *pixels) { 168 168 GLubyte r, g, b, a; 169 GLuint i, t, p, numPixels = width * height;169 int i, t, p, numPixels = width * height; 170 170 171 171 glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); … … 188 188 189 189 void VMI::getBoundingBox(Change *c, GLfloat min[3], GLfloat max[3]) { 190 GLuint i, j, t, v;190 int i, j, t, v; 191 191 GLfloat maxx = 0.0f, minx = 0.0f, 192 192 maxy = 0.0f, miny = 0.0f, … … 194 194 195 195 /* get the max/mins */ 196 for (i=0; i< (GLuint)c->numMod; i++) {196 for (i=0; i<c->numMod; i++) { 197 197 t = c->modified[i].id; 198 198 … … 217 217 } 218 218 219 for (i=0; i< (GLuint)c->numDel; i++) {219 for (i=0; i<c->numDel; i++) { 220 220 t = c->deleted[i].id; 221 221 … … 322 322 } 323 323 324 void VMI::getSWHistogramWin( GLuint *histogram, GLubyte *pixels, GLfloat min[3], GLfloat max[3], Change *c) {324 void VMI::getSWHistogramWin(int *histogram, GLubyte *pixels, GLfloat min[3], GLfloat max[3], Change *c) { 325 325 GLubyte r, g, b, a; 326 GLuint i, t, p, numPixels,327 *histoAux = ( GLuint *)calloc(mesh->numTriangles + 1, sizeof(GLuint));326 int i, t, p, numPixels, 327 *histoAux = (int *)calloc(mesh->numTriangles + 1, sizeof(int)); 328 328 GLint minw[2], maxw[2], ox, oy, h, w; 329 329 … … 369 369 } 370 370 371 for (i=0; i< (GLuint)c->numMod; i++) {372 t = (GLuint)c->modified[i].id;371 for (i=0; i<c->numMod; i++) { 372 t = c->modified[i].id; 373 373 374 374 histogram[t + 1] = histoAux[t + 1]; … … 379 379 } 380 380 381 void VMI::getSWHistoByOcclusionQuery(Mesh *mesh, Color *colors, GLuint *histogram) {382 GLuint i, v1, v2, v3;381 void VMI::getSWHistoByOcclusionQuery(Mesh *mesh, Color *colors, int *histogram) { 382 int i, v1, v2, v3; 383 383 GLint area, totalArea = 0; 384 384 … … 432 432 } 433 433 434 void VMI::resetSWHistogram( GLuint *histogram, GLuint numTriangles) {434 void VMI::resetSWHistogram(int *histogram, int numTriangles) { 435 435 436 436 // Fill the histogram buffer with 0 437 memset(histogram, 0, sizeof( GLuint) * (numTriangles + 1));438 } 437 memset(histogram, 0, sizeof(int) * (numTriangles + 1)); 438 } -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/main.cpp
r2090 r2127 8 8 9 9 Camera *cameras = NULL; 10 GLuint numCameras = 0;10 int numCameras = 0; 11 11 12 12 Color *colors = NULL; 13 13 14 GLuint **histogram = NULL, 15 14 int **histogram = NULL; 15 GLuint *queries = NULL; 16 16 17 17 Mesh *mesh = NULL; … … 28 28 bRemoveRedundantVertices = GL_TRUE; 29 29 30 GLuint cameraType = 0,30 int cameraType = 0, 31 31 numDemandedTriangles = 0; 32 32 … … 174 174 } 175 175 176 void VMI::updateHWAcceleration(Change *c) { 177 178 #ifdef VERTEX_ARRAY_INTERLEAVE 179 if (interleave != NULL) free(interleave); 180 interleave = setupInterleave(mesh, colors); 181 #endif 182 #ifdef VERTEX_ARRAY 183 updateVertexArray(mesh, c); 184 #endif 185 #ifdef VERTEX_BUFFER_OBJECTS 186 updateVertexBufferObjects(mesh, c); 187 #endif 188 189 } 190 176 191 void VMI::setOrthographicProjection(void) { 177 192 // Switch to projection mode … … 208 223 void VMI::renderGeometry(void) { 209 224 #ifdef IMMEDIATE_MODE 210 GLuint i, v1, v2, v3;225 int i, v1, v2, v3; 211 226 212 227 // Immediate mode … … 228 243 #else 229 244 #ifdef VERTEX_ARRAY 230 glDrawArrays(GL_TRIANGLES, 0, mesh-> currentNumTriangles * 3);245 glDrawArrays(GL_TRIANGLES, 0, mesh->numTriangles * 3); 231 246 #endif 232 247 #ifdef VERTEX_ARRAY_INTERLEAVE … … 235 250 #endif 236 251 #ifdef VERTEX_BUFFER_OBJECTS 237 glDrawArrays(GL_TRIANGLES, 0, mesh-> currentNumTriangles * 3);252 glDrawArrays(GL_TRIANGLES, 0, mesh->numTriangles * 3); 238 253 #endif 239 254 … … 264 279 glutSwapBuffers(); 265 280 } 266 void VMI::renderScene(GLuint **histogram, GLuint numCameras) 267 { 268 GLuint i; 281 282 void VMI::resetProjectedAreas(int **histogram, int numCameras) { 283 int i = 0; 284 285 // Reset the projected areas for all cameras 286 for (i=0; i<numCameras; i++) 287 resetSWHistogram(histogram[i], mesh->numTriangles); 288 } 289 290 void VMI::getProjectedAreas(int **histogram, int numCameras) 291 { 292 int i; 269 293 270 294 // draw to the frame buffer 271 295 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); 272 273 // Apply HW acceleration OpenGL Technique 274 applyHWAcceleration(); 275 276 glDrawBuffer(GL_BACK); 277 glReadBuffer(GL_BACK); 296 297 //glDrawBuffer(GL_BACK); 298 //glReadBuffer(GL_BACK); 278 299 279 300 // Get the projected areas for all cameras … … 312 333 /////////////////////////////////////////////////////////////////////////// 313 334 } 314 void VMI:: renderSceneWin(GLuint **histogram, GLuint numCameras, Change *c)315 { 316 GLuint i, j, t, background;335 void VMI::getProjectedAreasWin(int **histogram, int numCameras, Change *c) 336 { 337 int i, j, t, background; 317 338 int del_area, mod_area; 318 339 GLfloat min[3], max[3]; … … 325 346 //printf("\n(%f,%f,%f)-(%f,%f,%f)\n", min[0], min[1], min[2], max[0], max[1], max[2]); 326 347 327 // ApplyHW acceleration OpenGL Technique328 applyHWAcceleration();329 330 glDrawBuffer(GL_BACK);331 glReadBuffer(GL_BACK);348 // Update HW acceleration OpenGL Technique 349 updateHWAcceleration(c); 350 351 //glDrawBuffer(GL_BACK); 352 //glReadBuffer(GL_BACK); 332 353 333 354 // Get the projected areas for all cameras … … 355 376 mod_area = 0; 356 377 357 for (j=0; j< ( GLuint)c->numDel; j++) {378 for (j=0; j<c->numDel; j++) { 358 379 t = c->deleted[j].id; 359 380 del_area += histogram[i][t + 1]; … … 362 383 } 363 384 364 for (j=0; j< ( GLuint)c->numMod; j++) {385 for (j=0; j<c->numMod; j++) { 365 386 t = c->modified[j].id; 366 387 del_area += histogram[i][t + 1]; … … 371 392 getSWHistogramWin(histogram[i], pixels, min, max, c); 372 393 373 for (j=0; j< ( GLuint)c->numMod; j++) {394 for (j=0; j<c->numMod; j++) { 374 395 t = c->modified[j].id; 375 396 mod_area += histogram[i][t + 1]; … … 425 446 426 447 glDeleteBuffersARB(1, &color_buf); 448 449 //free(pbuf_vertices); 450 //free(pbuf_colors); 451 452 buf_vertices = NULL; 453 buf_colors = NULL; 454 455 #endif 456 #ifdef VERTEX_ARRAY 457 //free(pbuf_vertices); 458 //free(pbuf_colors); 459 460 buf_vertices = NULL; 461 buf_colors = NULL; 427 462 #endif 428 463 … … 457 492 458 493 start = clock(); 494 495 // Apply HW acceleration OpenGL Technique 496 applyHWAcceleration(); 459 497 460 498 getProjectedAreas(histogram, numCameras); -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/mesh.cpp
r2090 r2127 53 53 /////////////////////////////////////////////////////////////////////////////// 54 54 55 int VMI::findEdge(Edge *e, GLuint num, GLuint _u, GLuint _v) {56 GLuint i, u, v;55 int VMI::findEdge(Edge *e, int num, int _u, int _v) { 56 int i, u, v; 57 57 int found = -1; 58 58 … … 85 85 newList[*n].u = u; 86 86 newList[*n].v = v; 87 88 // This edge has no triangle adjancency89 newList[*n].numTriangles = 0;90 newList[*n].triangles = NULL;91 87 92 88 // Enable the new edge … … 102 98 } 103 99 100 double VMI::computeEdgeLength(Vertex *vertices, int u, int v) { 101 float ux, uy, uz, vx, vy ,vz, rx, ry, rz; 102 103 ux = vertices[u].x; 104 uy = vertices[u].y; 105 uz = vertices[u].z; 106 107 vx = vertices[v].x; 108 vy = vertices[v].y; 109 vz = vertices[v].z; 110 111 rx = ux - vx; 112 ry = uy - vy; 113 rz = uz - vz; 114 115 return sqrt((rx * rx) + (ry * ry) + (rz * rz)); 116 } 117 118 double VMI::computeTriangleVolume(Vertex *vertices, Triangle *t) { 119 int i; 120 double m[3][3], vol; 121 122 // Compute triangle Volume 123 i = t->indices[0]; 124 m[0][0] = mesh->vertices[i].x; 125 m[0][1] = mesh->vertices[i].y; 126 m[0][2] = mesh->vertices[i].z; 127 128 i = t->indices[1]; 129 m[1][0] = mesh->vertices[i].x; 130 m[1][1] = mesh->vertices[i].y; 131 m[1][2] = mesh->vertices[i].z; 132 133 i = t->indices[2]; 134 m[2][0] = mesh->vertices[i].x; 135 m[2][1] = mesh->vertices[i].y; 136 m[2][2] = mesh->vertices[i].z; 137 138 vol = computeMatDet(m); 139 140 //printf("Triangle Volume: %f\n", vol) 141 return vol; 142 } 143 104 144 GLdouble VMI::computeTriangleArea(Vertex *vertices, Triangle *t) { 105 GLuint i;145 int i; 106 146 GLdouble v0[3], v1[3], v2[3], a; 107 147 … … 129 169 130 170 void VMI::computeTriangleNormal(Vertex *vertices, Triangle *t) { 131 GLuint i;171 int i; 132 172 GLfloat x0, y0, z0, 133 173 x1, y1, z1, … … 175 215 Mesh *VMI::initMesh(GLMmodel* pmodel) { 176 216 177 GLuint i, j, curGroup, v1, v2, v3, n, m, t;217 int i, j, curGroup, v1, v2, v3, n, m, t; 178 218 int e; 179 219 Mesh *mesh; … … 202 242 203 243 printf("Adding vertices..."); 204 for (i=1; i<= pmodel->numvertices; i++) { // Vertices start at 1244 for (i=1; i<=(int)pmodel->numvertices; i++) { // Vertices start at 1 205 245 mesh->vertices[i - 1].x = pmodel->vertices[3 * i + 0]; 206 246 mesh->vertices[i - 1].y = pmodel->vertices[3 * i + 1]; … … 208 248 mesh->vertices[i - 1].numTriangles = 0; 209 249 mesh->vertices[i - 1].triangles = NULL; 250 mesh->vertices[i - 1].numEdges = 0; 251 mesh->vertices[i - 1].edges = NULL; 210 252 mesh->vertices[i - 1].enable = GL_TRUE; 211 253 } … … 221 263 while(group) { 222 264 223 for (i=0; i< group->numtriangles; i++) {265 for (i=0; i<(int)group->numtriangles; i++) { 224 266 225 267 t = group->triangles[i]; … … 244 286 // Reallocate memory for the new adjacent triangle 245 287 mesh->vertices[v1].triangles = 246 ( GLuint *)realloc(mesh->vertices[v1].triangles, (mesh->vertices[v1].numTriangles + 1) * sizeof(GLuint));288 (int *)realloc(mesh->vertices[v1].triangles, (mesh->vertices[v1].numTriangles + 1) * sizeof(int)); 247 289 addItem((int *)mesh->vertices[v1].triangles, (int *)&mesh->vertices[v1].numTriangles, t); 248 290 } … … 254 296 for (i=0; i<pmodel->numtriangles; i++) { 255 297 mesh->triangles[i].id = i; 256 mesh->triangles[i].indices[0] = pmodel->triangles[i].vindices[0] - 1;257 mesh->triangles[i].indices[1] = pmodel->triangles[i].vindices[1] - 1;258 mesh->triangles[i].indices[2] = pmodel->triangles[i].vindices[2] - 1;298 mesh->triangles[i].indices[0] = (int)pmodel->triangles[i].vindices[0] - 1; 299 mesh->triangles[i].indices[1] = (int)pmodel->triangles[i].vindices[1] - 1; 300 mesh->triangles[i].indices[2] = (int)pmodel->triangles[i].vindices[2] - 1; 259 301 mesh->triangles[i].area = computeTriangleArea(mesh->vertices, &mesh->triangles[i]); 260 302 //printf("\n%d a: %f",i , mesh->triangles[i].area); … … 271 313 // Reallocate memory for the new adjacent triangle 272 314 mesh->vertices[v1].triangles = 273 ( GLuint *)realloc(mesh->vertices[v1].triangles, (mesh->vertices[v1].numTriangles + 1) * sizeof(GLuint));315 (int *)realloc(mesh->vertices[v1].triangles, (mesh->vertices[v1].numTriangles + 1) * sizeof(int)); 274 316 addItem((int *)mesh->vertices[v1].triangles, (int *)&mesh->vertices[v1].numTriangles, i); 275 317 } … … 304 346 mesh->edges[n].u = v1; 305 347 mesh->edges[n].v = v2; 306 mesh->edges[n].triangles = NULL;307 mesh->edges[n].numTriangles = 0;308 348 mesh->edges[n].enable = GL_TRUE; 309 349 m = n; 310 350 n++; 311 351 } else m = e; 312 // Reallocate memory for the new adjacent triangle313 mesh->edges[m].triangles =314 (GLuint *)realloc(mesh->edges[m].triangles, (mesh->edges[m].numTriangles + 1) * sizeof(GLuint));315 // Adding triangle i adjacent to edge m316 addItem((int *)mesh->edges[m].triangles, (int *)&mesh->edges[m].numTriangles, i);317 //printf("n:%d i:%d\n", m, i);318 319 // Adding edge m adjacent to triangle i320 addItem((int *)mesh->triangles[i].edges, (int *)&t, m);321 352 322 353 ///////////////////////////////////////////////////////////////////////////////// … … 325 356 mesh->edges[n].u = v2; 326 357 mesh->edges[n].v = v3; 327 mesh->edges[n].triangles = NULL;328 mesh->edges[n].numTriangles = 0;329 358 mesh->edges[n].enable = GL_TRUE; 330 359 m = n; 331 360 n++; 332 361 } else m = e; 333 // Reallocate memory for the new adjacent triangle334 mesh->edges[m].triangles =335 (GLuint *)realloc(mesh->edges[m].triangles, (mesh->edges[m].numTriangles + 1) * sizeof(GLuint));336 // Adding triangle i adjacent to edge m337 addItem((int *)mesh->edges[m].triangles, (int *)&mesh->edges[m].numTriangles, i);338 //printf("n:%d i:%d\n", m, i);339 340 // Adding edge m adjacent to triangle i341 addItem((int *)mesh->triangles[i].edges, (int *)&t, m);342 362 343 363 ///////////////////////////////////////////////////////////////////////////////// … … 346 366 mesh->edges[n].u = v3; 347 367 mesh->edges[n].v = v1; 348 mesh->edges[n].triangles = NULL;349 mesh->edges[n].numTriangles = 0;350 368 mesh->edges[n].enable = GL_TRUE; 351 369 m = n; 352 370 n++; 353 371 } else m = e; 354 // Reallocate memory for the new adjacent triangle355 mesh->edges[m].triangles =356 (GLuint *)realloc(mesh->edges[m].triangles, (mesh->edges[m].numTriangles + 1) * sizeof(GLuint));357 // Adding triangle i adjacent to edge m358 addItem((int *)mesh->edges[m].triangles, (int *)&mesh->edges[m].numTriangles, i);359 //printf("n:%d i:%d\n", m, i);360 361 // Adding edge m adjacent to triangle i362 addItem((int *)mesh->triangles[i].edges, (int *)&t, m);363 372 } 364 373 printf("Ok\n"); 365 374 mesh->numEdges = n; 366 375 376 for (i=0; i<mesh->numEdges; i++) { 377 v1 = mesh->edges[i].u; 378 v2 = mesh->edges[i].v; 379 380 mesh->vertices[v1].edges = 381 (int *)realloc(mesh->vertices[v1].edges, (mesh->vertices[v1].numEdges + 1) * sizeof(int)); 382 // Adding edge i adjacent to vertex v1 383 addItem(mesh->vertices[v1].edges, &mesh->vertices[v1].numEdges, i); 384 385 mesh->vertices[v2].edges = 386 (int *)realloc(mesh->vertices[v2].edges, (mesh->vertices[v2].numEdges + 1) * sizeof(int)); 387 // Adding edge i adjacent to vertex v2 388 addItem(mesh->vertices[v2].edges, &mesh->vertices[v2].numEdges, i); 389 } 390 367 391 return mesh; 368 392 } 369 393 370 394 void VMI::printMesh(Mesh *mesh) { 371 GLuint i, j;395 int i, j; 372 396 373 397 printf("Vertices (%d)\n", mesh->numVertices); … … 385 409 } 386 410 printf("]\n"); 411 412 printf(" e(%d)[", mesh->vertices[i].numEdges); 413 if (mesh->vertices[i].edges != NULL) { 414 printf("%d", mesh->vertices[i].edges[0]); 415 for (j=1; j<mesh->vertices[i].numEdges; j++) { 416 printf(",%d", mesh->vertices[i].edges[j]); 417 } 418 } 419 printf("]\n"); 387 420 } 388 421 … … 391 424 for (i=0; i<mesh->numEdges; i++) { 392 425 printf("e%d (%d,%d) %d\n", i, mesh->edges[i].u, mesh->edges[i].v, mesh->edges[i].enable); 393 printf(" t(%d)[", mesh->edges[i].numTriangles);394 if (mesh->edges[i].triangles != NULL) {395 printf("%d", mesh->edges[i].triangles[0]);396 for (j=1; j<mesh->edges[i].numTriangles; j++) {397 printf(",%d", mesh->edges[i].triangles[j]);398 }399 }400 printf("]\n");401 426 } 402 427 … … 406 431 printf("t%d (%d,%d,%d) %d\n", i, mesh->triangles[i].indices[0], mesh->triangles[i].indices[1], 407 432 mesh->triangles[i].indices[2], mesh->triangles[i].enable); 408 printf(" e(3)[");409 printf("%d", mesh->triangles[i].edges[0]);410 for (j=1; j<3; j++) {411 printf(",%d", mesh->triangles[i].edges[j]);412 }413 printf("]\n");414 433 415 434 printf(" n(3)["); … … 425 444 426 445 void VMI::deleteMesh(Mesh *mesh) { 427 GLuint i;446 int i; 428 447 429 448 if (NULL != mesh) { … … 432 451 free(mesh->vertices[i].triangles); 433 452 453 if (mesh->vertices[i].edges != NULL) 454 free(mesh->vertices[i].edges); 455 434 456 } 435 457 if (mesh->vertices != NULL) free(mesh->vertices); 436 458 mesh->numVertices = 0; 437 459 438 for (i=0; i<mesh->numEdges; i++) {439 if (mesh->edges[i].triangles != NULL)440 free(mesh->edges[i].triangles);441 }442 460 if (mesh->edges != NULL) free(mesh->edges); 443 461 mesh->numEdges = 0; … … 525 543 } 526 544 527 int *VMI::edgesAdjToVertex(Mesh *mesh, int v, int *n) {528 int *edges = NULL;529 int i, t, e;530 #ifndef USE_EDGE_ADJACENCY531 int n0, n1, n2;532 #else533 int j;534 #endif535 int num = 0;536 537 if (mesh->vertices[v].numTriangles > 0)538 edges = (int*)malloc(sizeof(int) * mesh->vertices[v].numTriangles * 2);539 540 for (i=0; i<(int)mesh->vertices[v].numTriangles; i++) {541 542 t = mesh->vertices[v].triangles[i];543 544 #ifdef USE_EDGE_ADJACENCY545 for (j=0; j<3; j++) {546 e = mesh->triangles[t].edges[j];547 548 if ((int)mesh->edges[e].u == v || (int)mesh->edges[e].v == v)549 550 addItem(edges, &num, e);551 }552 #else553 n0 = mesh->triangles[t].indices[0];554 n1 = mesh->triangles[t].indices[1];555 n2 = mesh->triangles[t].indices[2];556 557 if (((n0 == v) || (n1 == v)) &&558 ((e = findEdge(mesh->edges, mesh->numEdges, n0, n1)) != -1)) addItem(edges, &num, e);559 560 if (((n1 == v) || (n2 == v)) &&561 ((e = findEdge(mesh->edges, mesh->numEdges, n1, n2)) != -1)) addItem(edges, &num, e);562 563 if (((n0 == v) || (n2 == v)) &&564 ((e = findEdge(mesh->edges, mesh->numEdges, n0, n2)) != -1)) addItem(edges, &num, e);565 566 #endif567 }568 *n = num;569 570 return edges;571 }572 573 545 int *VMI::edgesAdjToVertices(Mesh *mesh, int *vertices, int numVertices, int *n) { 574 546 int *edges = NULL; … … 578 550 if (numVertices > 0) { 579 551 // Add the first 580 list = edgesAdjToVertex(mesh, vertices[0], &numEdges); 552 list = mesh->vertices[vertices[0]].edges; 553 numEdges = mesh->vertices[vertices[0]].numEdges; 581 554 582 555 // Allocate memory … … 585 558 memcpy(edges, list, sizeof(int) * numEdges); 586 559 587 free(list);588 589 560 num = numEdges; 590 561 … … 592 563 for (i=1; i<numVertices; i++) { 593 564 594 list = edgesAdjToVertex(mesh, vertices[i], &numEdges); 565 list = mesh->vertices[vertices[i]].edges; 566 numEdges = mesh->vertices[vertices[i]].numEdges; 595 567 596 568 // Reallocate memory 597 569 if (numEdges > 0) { 598 570 599 571 edges = (int *)realloc(edges, (num + numEdges + 1) * sizeof(int)); … … 601 573 for (j=0; j<numEdges; j++) 602 574 addItem(edges, &num, list[j]); 603 } 604 free(list); 575 } 605 576 } 606 577 } … … 610 581 } 611 582 612 GLboolean VMI::findVertex( GLfloat *vertices, GLuint num, GLfloat x, GLfloat y, GLfloat z, int *pos) {613 GLuint i;614 GLfloat _x, _y, _z;583 GLboolean VMI::findVertex(float *vertices, int num, float x, float y, float z, int *pos) { 584 int i; 585 float _x, _y, _z; 615 586 GLboolean found = GL_FALSE; 616 587 … … 648 619 newList[*n].numTriangles = 0; 649 620 newList[*n].triangles = NULL; 621 622 newList[*n].numEdges= 0; 623 newList[*n].edges = NULL; 650 624 651 625 // Enable the new vertex … … 663 637 664 638 665 void VMI::updateModel(GLMmodel* pmodel, Mesh *mesh, GLuint numVertices, GLuint numTriangles) {666 GLuint i , v1, v2 ,v3, numV = 1, numT = 0;639 void VMI::updateModel(GLMmodel* pmodel, Mesh *mesh, int numVertices, int numTriangles) { 640 int i , v1, v2 ,v3, numV = 1, numT = 0; 667 641 int pos; 668 GLfloat x, y, z;642 float x, y, z; 669 643 670 644 if (pmodel->vertices != NULL) free(pmodel->vertices); … … 726 700 727 701 void VMI::saveModel(char *filename, GLMmodel* pmodel, Mesh *mesh) { 728 GLuint i, j, g, numT = 0;702 int i, j, g, numT = 0; 729 703 GLMgroup *group; 730 704 -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/metrics.cpp
r2090 r2127 13 13 using namespace VMI; 14 14 15 GLdouble VMI::computeMeanProjAreaNoBG( GLuint **histogram, GLuint numCameras, int t) {16 GLuint i;15 GLdouble VMI::computeMeanProjAreaNoBG(int **histogram, int numCameras, int t) { 16 int i; 17 17 GLdouble mean_proj_area = 0.0; 18 18 … … 24 24 } 25 25 26 GLdouble VMI::computeMeanProjArea( GLuint **histogram, GLuint numCameras, int t) {27 GLuint i;26 GLdouble VMI::computeMeanProjArea(int **histogram, int numCameras, int t) { 27 int i; 28 28 GLdouble mean_proj_area = 0.0, total_proj_area, resolution = width * height; 29 29 … … 38 38 /////////////////////////////////////////////////////////////////////////////// 39 39 // Mutual Information 40 GLdouble VMI::computeMI(Mesh *mesh, GLuint **histogram, GLuint numCameras, GLuint cam) {40 GLdouble VMI::computeMI(Mesh *mesh, int **histogram, int numCameras, int cam) { 41 41 GLdouble I = 0.0, pov, po, total_proj_area = width * height; 42 GLuint i;42 int i; 43 43 44 44 for (i=0; i<mesh->numTriangles; i++) { … … 66 66 } 67 67 68 GLdouble VMI::decMI(GLdouble I, GLuint **histogram, GLuint numCameras, GLuint cam, Change *c) {68 GLdouble VMI::decMI(GLdouble I, int **histogram, int numCameras, int cam, Change *c) { 69 69 GLdouble newI = I * numCameras, 70 70 pov = 0.0, po; … … 109 109 } 110 110 111 GLdouble VMI::incMI(GLdouble I, GLuint **histogram, GLuint numCameras, GLuint cam, Change *c) {111 GLdouble VMI::incMI(GLdouble I, int **histogram, int numCameras, int cam, Change *c) { 112 112 GLdouble newI = I * numCameras, 113 113 pov = 0.0, po; 114 114 GLsizei total_proj_area = width * height; 115 GLuint i, t;115 int i, t; 116 116 117 117 // increase entropy of modified triangles 118 for (i=0; i< (GLuint)c->numMod; i++) {118 for (i=0; i<c->numMod; i++) { 119 119 120 120 t = c->modified[i].id; … … 140 140 /////////////////////////////////////////////////////////////////////////////// 141 141 // Kullback-Leibler divergence 142 GLdouble VMI::computeKL(Mesh *mesh, GLuint *histogram) {142 GLdouble VMI::computeKL(Mesh *mesh, int *histogram) { 143 143 GLdouble I = 0.0, 144 144 total_real_area = 0.0, pi, tri_area; 145 145 GLsizei total_proj_area = (width * height) - histogram[0]; 146 GLuint i;146 int i; 147 147 148 148 // Compute total real area of all triangles … … 169 169 170 170 // Hellinger divergence (square root) 171 GLdouble VMI::computeHE(Mesh *mesh, GLuint *histogram) {171 GLdouble VMI::computeHE(Mesh *mesh, int *histogram) { 172 172 GLdouble I = 0.0, temp, 173 173 total_real_area = 0.0, pi, qi; 174 174 GLsizei total_proj_area = (width * height) - histogram[0]; 175 GLuint i;175 int i; 176 176 177 177 // Compute total real area of all triangles … … 203 203 204 204 // Chi-Square divergence (square root) 205 GLdouble VMI::computeCS(Mesh *mesh, GLuint *histogram) {205 GLdouble VMI::computeCS(Mesh *mesh, int *histogram) { 206 206 GLdouble I = 0.0, 207 207 total_real_area = 0.0, pi, qi; 208 208 GLsizei total_proj_area = (width * height) - histogram[0]; 209 GLuint i;209 int i; 210 210 211 211 /// Compute total real area of all triangles … … 231 231 } 232 232 /////////////////////////////////////////////////////////////////////////////// 233 GLdouble VMI::computeEntropy( GLuint **histogram, GLuint numCameras, GLuint k) {233 GLdouble VMI::computeEntropy(int **histogram, int numCameras, int k) { 234 234 GLdouble H = 0.0, POk, pi, 235 235 total_proj_area, resolution = width * height, pv = 1.0 / (GLdouble)numCameras; 236 GLuint i;236 int i; 237 237 238 238 for (i=0; i<numCameras; i++) { … … 253 253 } 254 254 255 GLdouble VMI::computeMixedEntropy(GLdouble *mixed, GLuint numCameras) {255 GLdouble VMI::computeMixedEntropy(GLdouble *mixed, int numCameras) { 256 256 GLdouble H = 0.0, pi; 257 GLuint i;257 int i; 258 258 259 259 for (i=0; i<numCameras; i++) { … … 269 269 /////////////////////////////////////////////////////////////////////////////// 270 270 // Jensen-Shannon divergence 271 GLdouble VMI::computeJS( GLuint **histogram, GLuint numCameras, GLuint j, GLuint k) {271 GLdouble VMI::computeJS(int **histogram, int numCameras, int j, int k) { 272 272 GLdouble js, Wj = 0.0, Wk = 0.0, POj, POk, pj, pk, total_proj_area, 273 273 resolution = width * height, pv = 1.0 / (GLdouble)numCameras, 274 274 *mixing = (GLdouble *)malloc(numCameras * sizeof(GLdouble)); 275 GLuint i;275 int i; 276 276 277 277 POj = computeMeanProjArea(histogram, numCameras, j + 1); … … 311 311 } 312 312 /////////////////////////////////////////////////////////////////////////////// 313 void VMI::getProjectedAreas(GLuint **histogram, GLuint numCameras) { 314 315 renderScene(histogram, numCameras); 316 } 317 318 void VMI::getProjectedAreasWin(GLuint **histogram, GLuint numCameras, Change *c) { 319 320 renderSceneWin(histogram, numCameras, c); 321 } 322 323 void VMI::resetProjectedAreas(GLuint **histogram, GLuint numCameras) { 324 GLuint i = 0; 325 326 // Reset the projected areas for all cameras 327 for (i=0; i<numCameras; i++) 328 resetSWHistogram(histogram[i], mesh->numTriangles); 329 } 330 331 GLdouble *VMI::initIs(GLuint numCameras) { 313 314 GLdouble *VMI::initIs(int numCameras) { 332 315 GLdouble *initialIs; 333 316 … … 346 329 } 347 330 348 void VMI::computeCameraIs( GLuint **histogram, GLuint numCameras, GLdouble *mis) {349 GLuint i = 0;331 void VMI::computeCameraIs(int **histogram, int numCameras, GLdouble *mis) { 332 int i = 0; 350 333 GLdouble meanI = 0.0; 351 334 … … 374 357 } 375 358 376 void VMI::printIs(GLdouble *mis, GLuint numCameras) {377 GLuint i;359 void VMI::printIs(GLdouble *mis, int numCameras) { 360 int i; 378 361 379 362 printf("\n"); -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/saliency.cpp
r2090 r2127 22 22 using namespace VMI; 23 23 24 void VMI::computeSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras) {25 GLuint i = 0;24 void VMI::computeSaliency(Mesh *mesh, int **histogram, int numCameras) { 25 int i = 0; 26 26 double sal; 27 27 … … 46 46 } 47 47 48 void updateTriangleSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras, int v) {48 void updateTriangleSaliency(Mesh *mesh, int **histogram, int numCameras, int v) { 49 49 int i, t; 50 50 … … 57 57 } 58 58 59 double VMI::computeTriangleSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras, GLuint k) {60 GLuint i, l, v0, v1, v2;59 double VMI::computeTriangleSaliency(Mesh *mesh, int **histogram, int numCameras, int k) { 60 int i, l, v0, v1, v2; 61 61 int *triangles = NULL, n = 0; 62 62 double sal = 0.0; … … 94 94 //printItemList(triangles, n); 95 95 96 for(i=0; i< (GLuint)n; i++) {96 for(i=0; i<n; i++) { 97 97 //printf("\n%d %d", k, triangles[i]); 98 98 //sal += computeJS(histogram, numCameras, k, triangles[i]); … … 137 137 void VMI::saveSaliencyMap(Mesh *mesh, char* filename) { 138 138 FILE *fp; 139 GLuint i;139 int i; 140 140 141 141 … … 162 162 void VMI::loadSaliencyMap(Mesh *mesh, char* filename) { 163 163 FILE *fp; 164 unsignedint i, num;164 int i, num; 165 165 float s; 166 166 … … 202 202 203 203 void VMI::viewSaliency(Mesh *mesh, Camera *cameras, int cam) { 204 GLuint i, v1, v2, v3;204 int i, v1, v2, v3; 205 205 float r, g, b; 206 206 -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/simplify.cpp
r2103 r2127 10 10 #include "../include/saliency.h" 11 11 #include "../include/histogram.h" 12 #include "../include/buffers.h" 12 13 13 14 //#define RECOMPUTE_THE_WHOLE_HEAP … … 59 60 60 61 bheap_t *VMI::initHeap(Mesh *mesh) { 61 GLuint i;62 int i; 62 63 double cost; 63 64 bheap_t *h = NULL; … … 152 153 153 154 return h; 154 }155 156 GLdouble VMI::computeEdgeLength(Vertex *vertices, int u, int v) {157 GLfloat ux, uy, uz, vx, vy ,vz, rx, ry, rz;158 159 ux = vertices[u].x;160 uy = vertices[u].y;161 uz = vertices[u].z;162 163 vx = vertices[v].x;164 vy = vertices[v].y;165 vz = vertices[v].z;166 167 rx = ux - vx;168 ry = uy - vy;169 rz = uz - vz;170 171 return sqrt((rx * rx) + (ry * ry) + (rz * rz));172 155 } 173 156 … … 243 226 /////////////////////////////////////////////////////////////////////////////// 244 227 245 void saveProjectedAreas( GLuint **histogram, GLuint numCameras, Change *c, GLuint *dest) {246 GLuint i, j, t, n = 0;247 248 for (j=0; j< (GLuint)c->numDel; j++) {228 void saveProjectedAreas(int **histogram, int numCameras, Change *c, int *dest) { 229 int i, j, t, n = 0; 230 231 for (j=0; j<c->numDel; j++) { 249 232 250 233 t = c->deleted[j].id; … … 257 240 } 258 241 259 for (j=0; j< (GLuint)c->numMod; j++) {242 for (j=0; j<c->numMod; j++) { 260 243 261 244 t = c->modified[j].id; … … 276 259 } 277 260 278 void loadProjectedAreas( GLuint *src, GLuint numCameras, Change *c, GLuint **histogram) {279 GLuint i, j, t, n = 0;280 281 for (j=0; j< (GLuint)c->numDel; j++) {261 void loadProjectedAreas(int *src, int numCameras, Change *c, int **histogram) { 262 int i, j, t, n = 0; 263 264 for (j=0; j<c->numDel; j++) { 282 265 283 266 t = c->deleted[j].id; … … 290 273 } 291 274 292 for (j=0; j< (GLuint)c->numMod; j++) {275 for (j=0; j<c->numMod; j++) { 293 276 294 277 t = c->modified[j].id; … … 308 291 } 309 292 } 310 311 293 /////////////////////////////////////////////////////////////////////////////// 294 #ifdef CHECK_LOCAL_INVERSION 295 int check_local_inversion(Mesh *mesh, Change *c) { 296 int i, t; 297 int v0, v1, v2; 298 double vol_before; 299 double vol_after; 300 Triangle tri; 301 302 for(i=0; i<mesh->vertices[c->u].numTriangles; i++) { 303 304 t = mesh->vertices[c->u].triangles[i]; 305 306 v0 = mesh->triangles[t].indices[0]; 307 v1 = mesh->triangles[t].indices[1]; 308 v2 = mesh->triangles[t].indices[2]; 309 310 if ((v0 != c->v) && (v1 != c->v) && (v2 != c->v)) { 311 312 //printf("%d\n", t); 313 memcpy(&tri, &mesh->triangles[t], sizeof(Triangle)); 314 315 vol_before = computeTriangleVolume(mesh->vertices, &tri); 316 317 //printf("t:[%d,%d,%d]\n", tri.indices[0], tri.indices[1], tri.indices[2]); 318 //printf("v:%f\n", vol_before); 319 320 if (tri.indices[0] == c->u) tri.indices[0] = c->v; 321 if (tri.indices[1] == c->u) tri.indices[1] = c->v; 322 if (tri.indices[2] == c->u) tri.indices[2] = c->v; 323 324 vol_after = computeTriangleVolume(mesh->vertices, &tri); 325 326 //printf("t:[%d,%d,%d]\n", tri.indices[0], tri.indices[1], tri.indices[2]); 327 //printf("v:%f\n", vol_after); 328 329 if (((vol_before > 0) && (vol_after < 0)) || 330 ((vol_before < 0) && (vol_after > 0))) 331 332 return TRUE; 333 } 334 } 335 return FALSE; 336 } 337 #endif 312 338 313 339 GLdouble VMI::computeEdgeCost(Mesh *mesh, int e) { … … 318 344 GLdouble newI; 319 345 #endif 320 GLuint i, *histoAux = NULL;346 int i, *histoAux = NULL; 321 347 Change *c; 348 #if defined(VERTEX_BUFFER_OBJECTS) || defined(VERTEX_ARRAY) 349 VertexIL *vb = NULL; 350 #endif 351 #ifdef CHECK_LOCAL_INVERSION 352 int penalized; 353 #endif 322 354 323 355 chooseBestEndPoints(mesh, e); … … 327 359 328 360 // Compute cost only for boundary or manifold edges 329 if (c->numDel == 2 330 /*(c->numDel <3) && (c->numDel > 0)*/) { 361 if (/*c->numDel == 2*/ 362 (c->numDel <3) && (c->numDel > 0)) { 363 364 #ifdef CHECK_LOCAL_INVERSION 365 penalized = check_local_inversion(mesh, c); 366 #endif 331 367 // Allocate memory 332 histoAux = (GLuint *)malloc((c->numDel + c->numMod + 1) * numCameras * sizeof(GLuint)); 368 histoAux = (int *)malloc((c->numDel + c->numMod + 1) * numCameras * sizeof(int)); 369 370 #if defined(VERTEX_BUFFER_OBJECTS) || defined(VERTEX_ARRAY) 371 vb = (VertexIL *)malloc((c->numDel + c->numMod + 1) * 3 * sizeof(VertexIL)); 372 373 saveVertexBuffer(c, vb); 374 #endif 333 375 334 376 #ifdef MI // Mutual Information … … 365 407 //printf(" I0:%f Is: %f\n", auxE[i], initialIs[i]); 366 408 367 cost += (ABS(auxIs[i] - initialIs[i]) * cameras[i].weight * sal);409 cost += (ABS(auxIs[i] - initialIs[i]) * cameras[i].weight); 368 410 369 411 // Restore old informations … … 405 447 newI = computeCS(mesh, histogram[i]); 406 448 #endif 407 cost += (ABS(initialIs[i] - newI) * cameras[i].weight * sal);449 cost += (ABS(initialIs[i] - newI) * cameras[i].weight); 408 450 } 409 451 undoChange(mesh, c); … … 417 459 // Free memory 418 460 free(histoAux); 461 #if defined(VERTEX_BUFFER_OBJECTS) || defined(VERTEX_ARRAY) 462 loadVertexBuffer(vb, c); 463 free(vb); 464 #endif 465 #ifdef CHECK_LOCAL_INVERSION 466 if (penalized) cost *= 5; 467 #endif 419 468 420 469 } else cost = FLT_MAX; … … 422 471 deleteChange(c); 423 472 424 return cost; 425 } 473 return (cost * sal); 474 } 475 476 int isValidEdge_(Mesh *mesh, int e) { 477 int u , v; 478 479 if (mesh->edges[e].enable == FALSE) return FALSE; 480 else { 481 u = mesh->edges[e].u; 482 v = mesh->edges[e].v; 483 484 if (u == v) { 485 486 mesh->edges[e].enable = FALSE; 487 return FALSE; 488 } 489 } 490 491 return TRUE; 492 } 493 426 494 /* Get a valid edge from the heap */ 427 495 int getMinValidEdge(Mesh *mesh, bheap_t *h) { … … 431 499 e = bh_min(h); 432 500 433 while ( mesh->edges[e].enable == FALSE) {501 while (!isValidEdge_(mesh, e)) { 434 502 /* delete invalid edge */ 435 503 bh_delete(h, e); … … 473 541 474 542 /////////////////////////////////////////////////////////////////////////// 475 void VMI::simplifyModel(Mesh *mesh, GLuint numDemandedTri)543 void VMI::simplifyModel(Mesh *mesh, int numDemandedTri) 476 544 { 477 545 int e; … … 558 626 bh_delete(h, e); 559 627 628 updateHWAcceleration(c); 629 560 630 // Get projected areas after the edge collapse 561 631 getProjectedAreas(histogram, numCameras); … … 563 633 computeCameraIs(histogram, numCameras, initialIs); 564 634 565 deleteEdges(mesh, c); 566 modifyEdges(mesh, c); 635 updateEdgeAdj(mesh, c); 636 637 modifyEdges(mesh, c); 567 638 568 639 // Update the heap according to the edge collapse … … 751 822 752 823 Edge *econ; 753 float x,y,z;754 824 int *lv1; 755 825 int v0; … … 797 867 v1 = (*lb1).second; 798 868 799 lv1 = edgesAdjToVertex(mesh,v1,&num_edges); 869 lv1 = mesh->vertices[v1].edges; 870 num_edges = mesh->vertices[v1].numEdges; 800 871 801 872 // Edje iterator. … … 857 928 858 929 deleteVertexOfMap(mesh, c->u); 859 deleteEdges(mesh, c);860 930 updateEdgeAdj(mesh, c); 931 modifyEdges(mesh, c); 861 932 deleteChange(c); 862 933 … … 910 981 lonely_vert = (*it).second; 911 982 912 le = edgesAdjToVertex(mesh,lonely_vert,&num_edges); 983 le = mesh->vertices[lonely_vert].edges; 984 985 num_edges = mesh->vertices[lonely_vert].numEdges; 913 986 914 987 // Find an edge width v coordinates. … … 977 1050 978 1051 deleteVertexOfMap(mesh, c->u); 979 deleteEdges(mesh, c);980 1052 updateEdgeAdj(mesh, c); 1053 modifyEdges(mesh, c); 981 1054 deleteChange(c); 982 1055 } … … 1069 1142 1070 1143 deleteVertexOfMap(mesh, c->u); 1071 deleteEdges(mesh, c);1072 1144 updateEdgeAdj(mesh, c); 1145 modifyEdges(mesh, c); 1073 1146 deleteChange(c); 1074 1147 }
Note: See TracChangeset
for help on using the changeset viewer.