Changeset 2323 for GTP/trunk/Lib/Geom
- Timestamp:
- 04/12/07 09:25:16 (18 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSimplifier.cpp
r2300 r2323 55 55 for (size_t i = 0; i < geoMesh->mSubMeshCount; i++) 56 56 { 57 // Debug.58 cout << "Indices of submesh "59 << i60 << ": "61 << geoMesh->mSubMesh[i].mIndexCount62 << endl;63 64 57 if ((geoMesh->mSubMesh[i].mIndexCount > 0) 65 58 || … … 69 62 } 70 63 } 71 72 // Reassign submesh count.73 geoMesh->mSubMeshCount = valid_submesh_count;74 64 75 65 // Reserve memory for valid submeshes. … … 171 161 delete []geoMesh->mSubMesh; 172 162 173 geoMesh->mSubMesh = geosubmesh; 163 geoMesh->mSubMeshCount = valid_submesh_count; 164 geoMesh->mSubMesh = geosubmesh; 174 165 } 175 166 … … 377 368 } 378 369 370 //------------------------------------------------------------------------ 379 371 // Init VMI options. 372 //------------------------------------------------------------------------ 380 373 int ViewPointDrivenSimplifier::init(void) 381 374 { … … 394 387 395 388 if (VMI::bLoadCamerasFromFile == GL_FALSE) 396 VMI::cameras = VMI::setCameras( VMI::radius, 389 VMI::cameras = VMI::setCameras( VMI::radius, 397 390 VMI::cameraType, 398 391 &VMI::numCameras); … … 535 528 VMI::Mesh * ViewPointDrivenSimplifier::initMeshStructure(Mesh *geoMesh) 536 529 { 537 GLuint i, j, v1, v2, v3, n, e, t; 530 GLuint i, j, v1, v2, v3, e; 531 float x, y, z; 538 532 VMI::Mesh *vmi_mesh; 539 533 SubMesh *geosubmesh; 540 534 VertexBuffer *vertex_buffer; 541 535 int mesh_index_count; 542 int index;543 536 544 537 // Reallocate memory for vmi mesh object. … … 558 551 * 559 552 vertex_buffer->mVertexCount); 553 vmi_mesh->numVertices = 0; 560 554 561 555 if (vmi_mesh->vertices == NULL) … … 579 573 * 580 574 (mesh_index_count / 3)); 575 vmi_mesh->numTriangles = 0; 581 576 582 577 if (vmi_mesh->triangles == NULL) … … 592 587 { 593 588 // Vertices start at 0. 594 vmi_mesh->vertices[i].x = vertex_buffer->mPosition[i].x; 595 vmi_mesh->vertices[i].y = vertex_buffer->mPosition[i].y; 596 vmi_mesh->vertices[i].z = vertex_buffer->mPosition[i].z; 597 598 vmi_mesh->vertices[i].numTriangles = 0; 599 vmi_mesh->vertices[i].triangles = NULL; 600 vmi_mesh->vertices[i].numEdges = 0; 601 vmi_mesh->vertices[i].edges = NULL; 602 vmi_mesh->vertices[i].enable = GL_TRUE; 589 x = vertex_buffer->mPosition[i].x; 590 y = vertex_buffer->mPosition[i].y; 591 z = vertex_buffer->mPosition[i].z; 592 593 addVertex(vmi_mesh, x, y, z); 603 594 } 604 595 605 596 printf("Ok\n"); 606 vmi_mesh->numVertices = int(vertex_buffer->mVertexCount); 607 vmi_mesh->currentNumVertices = int(vertex_buffer->mVertexCount); 597 vmi_mesh->currentNumVertices = vmi_mesh->numVertices; 608 598 609 599 printf("Vertices: %d\n",vmi_mesh->numVertices); … … 611 601 // Fill up triangles. 612 602 printf("Adding triangles..."); 613 614 // Initialize index of triangle.615 index = 0;616 603 617 604 // For each submesh. … … 626 613 for (i = 0; i < (geosubmesh->mIndexCount / 3); i++) 627 614 { 628 vmi_mesh->triangles[index].id = index; 629 vmi_mesh->triangles[index].submesh = submesh; 630 vmi_mesh->triangles[index].indices[0] = geosubmesh->mIndex[(3 * i)]; 631 vmi_mesh->triangles[index].indices[1] = geosubmesh->mIndex[(3 * i) + 1]; 632 vmi_mesh->triangles[index].indices[2] = geosubmesh->mIndex[(3 * i) + 2]; 633 634 vmi_mesh->triangles[index].area = computeTriangleArea( 635 vmi_mesh->vertices, 636 &vmi_mesh->triangles[index]); 637 638 computeTriangleNormal(vmi_mesh->vertices, 639 &vmi_mesh->triangles[index]); 640 641 vmi_mesh->triangles[index].saliency = 0.0; 642 643 vmi_mesh->triangles[index].enable = GL_TRUE; 644 645 for (j = 0; j < 3; j++) 646 { 647 // Adding triangle index adjacent to 3 vertices. 648 v1 = vmi_mesh->triangles[index].indices[j]; 649 650 // Reallocate memory for the new adjacent triangle. 651 vmi_mesh->vertices[v1].triangles = 652 (int *)realloc(vmi_mesh->vertices[v1].triangles, 653 (vmi_mesh->vertices[v1].numTriangles + 1) 654 * 655 sizeof(int)); 656 657 VMI::addItem( (int *)vmi_mesh->vertices[v1].triangles, 658 (int *)&vmi_mesh->vertices[v1].numTriangles, 659 index); 660 } 661 662 // Increments triangle count. 663 index++; 615 v1 = geosubmesh->mIndex[(3 * i)]; 616 v2 = geosubmesh->mIndex[(3 * i) + 1]; 617 v3 = geosubmesh->mIndex[(3 * i) + 2]; 618 619 // not a degenerated triangle 620 //if ((v1 != v2) && (v2 != v3) && (v1 != v3)) { 621 622 addTriangle(vmi_mesh, submesh, v1, v2, v3); 623 //} 664 624 } 665 625 } … … 667 627 printf("Ok\n"); 668 628 669 vmi_mesh->numTriangles = mesh_index_count / 3; 670 vmi_mesh->currentNumTriangles = mesh_index_count / 3; 671 672 printf("Num Triangles: %d\n",vmi_mesh->numTriangles); 629 vmi_mesh->currentNumTriangles = vmi_mesh->numTriangles; 630 printf("Number of triangles: %d\n", vmi_mesh->numTriangles); 631 //printf("Number of degenerated triangles: %d\n", pmodel->numtriangles - vmi_mesh->numTriangles); 673 632 674 633 // E = 3 T / 2 … … 676 635 * 677 636 vmi_mesh->numTriangles * 3); 637 vmi_mesh->numEdges = 0; 678 638 679 639 if (vmi_mesh->edges == NULL) … … 684 644 685 645 printf("Adding edges..."); 686 n = 0;687 646 688 647 // For each triangle adds three edges. 689 648 for (i = 0; i < vmi_mesh->numTriangles; i++) 690 649 { 691 t = 0;692 650 v1 = vmi_mesh->triangles[i].indices[0]; 693 651 v2 = vmi_mesh->triangles[i].indices[1]; 694 652 v3 = vmi_mesh->triangles[i].indices[2]; 695 653 696 if ((e = findEdge(vmi_mesh->edges, n, v1, v2)) == -1) 697 { 698 vmi_mesh->edges[n].u = v1; 699 vmi_mesh->edges[n].v = v2; 700 vmi_mesh->edges[n].enable = GL_TRUE; 701 702 n++; 703 } 704 705 if ((e = findEdge(vmi_mesh->edges, n, v2, v3)) == -1) 706 { 707 vmi_mesh->edges[n].u = v2; 708 vmi_mesh->edges[n].v = v3; 709 vmi_mesh->edges[n].enable = GL_TRUE; 710 711 n++; 654 if ((e = findEdge(vmi_mesh->edges, vmi_mesh->numEdges, v1, v2)) == -1) 655 { 656 addEdge(vmi_mesh, v1, v2); 657 } 658 659 if ((e = findEdge(vmi_mesh->edges, vmi_mesh->numEdges, v2, v3)) == -1) 660 { 661 addEdge(vmi_mesh, v2, v3); 712 662 } 713 663 714 if ((e = findEdge(vmi_mesh->edges, n, v3, v1)) == -1) 715 { 716 vmi_mesh->edges[n].u = v3; 717 vmi_mesh->edges[n].v = v1; 718 vmi_mesh->edges[n].enable = GL_TRUE; 719 720 n++; 664 if ((e = findEdge(vmi_mesh->edges, vmi_mesh->numEdges, v3, v1)) == -1) 665 { 666 addEdge(vmi_mesh, v3, v1); 721 667 } 722 668 } 723 669 724 670 printf("Ok\n"); 725 vmi_mesh->numEdges = n;726 727 for (i = 0; i < vmi_mesh->numEdges; i++)728 {729 v1 = vmi_mesh->edges[i].u;730 v2 = vmi_mesh->edges[i].v;731 732 vmi_mesh->vertices[v1].edges =733 (int *)realloc(vmi_mesh->vertices[v1].edges,734 (vmi_mesh->vertices[v1].numEdges + 1) * sizeof(int));735 736 // Adding edge i adjacent to vertex v1737 VMI::addItem( vmi_mesh->vertices[v1].edges,738 &vmi_mesh->vertices[v1].numEdges,739 i);740 741 vmi_mesh->vertices[v2].edges =742 (int *)realloc(vmi_mesh->vertices[v2].edges,743 (vmi_mesh->vertices[v2].numEdges + 1) * sizeof(int));744 745 // Adding edge i adjacent to vertex v2746 VMI::addItem( vmi_mesh->vertices[v2].edges,747 &vmi_mesh->vertices[v2].numEdges,748 i);749 }750 671 751 672 // Creates vertex multimap. … … 942 863 943 864 mGeoMesh->mBones.push_back(bone); 865 944 866 vertex_found = true; 945 867 } -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/mesh.h
r2194 r2323 47 47 extern double computeTriangleVolume(Vertex *vertices, Triangle *t); 48 48 49 extern int addEdge(Mesh *mesh, int u, int v); 50 extern int addTriangle(Mesh *mesh, int curGroup, int v1, int v2, int v3); 51 extern int addVertex(Mesh *mesh, float x, float y, float z); 52 49 53 extern Vertex *addVertex(Vertex *list, int *n, float x, float y, float z, int *pos); 50 54 extern int findEdge(Edge *e, int num, int _u, int _v); -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/mesh.cpp
r2194 r2323 212 212 t->normal[2] = cpz / r; 213 213 } 214 int VMI::addEdge(Mesh *mesh, int u, int v) { 215 int n = mesh->numEdges; 216 217 mesh->edges[n].u = u; 218 mesh->edges[n].v = v; 219 mesh->edges[n].enable = TRUE; 220 221 mesh->vertices[u].edges = 222 (int *)realloc(mesh->vertices[u].edges, (mesh->vertices[u].numEdges + 1) * sizeof(int)); 223 // Adding edge n adjacent to vertex u 224 addItem(mesh->vertices[u].edges, &mesh->vertices[u].numEdges, n); 225 226 mesh->vertices[v].edges = 227 (int *)realloc(mesh->vertices[v].edges, (mesh->vertices[v].numEdges + 1) * sizeof(int)); 228 // Adding edge n adjacent to vertex v 229 addItem(mesh->vertices[v].edges, &mesh->vertices[v].numEdges, n); 230 231 mesh->numEdges++; 232 233 return n; 234 } 235 236 int VMI::addVertex(Mesh *mesh, float x, float y, float z) { 237 int n = mesh->numVertices; 238 239 mesh->vertices[n].x = x; 240 mesh->vertices[n].y = y; 241 mesh->vertices[n].z = z; 242 mesh->vertices[n].numTriangles = 0; 243 mesh->vertices[n].triangles = NULL; 244 mesh->vertices[n].numEdges = 0; 245 mesh->vertices[n].edges = NULL; 246 mesh->vertices[n].enable = TRUE; 247 248 mesh->numVertices++; 249 250 return n; 251 } 252 253 int VMI::addTriangle(Mesh *mesh, int curGroup, int v1, int v2, int v3) { 254 int j, n = mesh->numTriangles; 255 256 mesh->triangles[n].id = n; 257 mesh->triangles[n].group = curGroup; // set group 258 mesh->triangles[n].submesh = curGroup; // set group 259 mesh->triangles[n].indices[0] = v1; 260 mesh->triangles[n].indices[1] = v2; 261 mesh->triangles[n].indices[2] = v3; 262 mesh->triangles[n].area = computeTriangleArea(mesh->vertices, &mesh->triangles[n]); 263 //printf("\n%d a: %f",i , mesh->triangles[i].area); 264 computeTriangleNormal(mesh->vertices, &mesh->triangles[n]); 265 mesh->triangles[n].saliency = 0.0; 266 mesh->triangles[n].enable = TRUE; 267 268 for (j=0; j<3; j++) { 269 // Adding triangle n adjacent to 3 vertices 270 v1 = mesh->triangles[n].indices[j]; 271 272 // Reallocate memory for the new adjacent triangle 273 mesh->vertices[v1].triangles = 274 (int *)realloc(mesh->vertices[v1].triangles, (mesh->vertices[v1].numTriangles + 1) * sizeof(int)); 275 addItem(mesh->vertices[v1].triangles, &mesh->vertices[v1].numTriangles, n); 276 } 277 278 mesh->numTriangles++; 279 280 return n; 281 } 214 282 215 283 Mesh *VMI::initMesh(GLMmodel* pmodel) { 216 217 int i, j, curGroup, v1, v2, v3, n, m, t; 218 int e; 219 Mesh *mesh; 220 GLMgroup *group; 221 222 mesh = (Mesh *)malloc (sizeof(Mesh)); 223 224 if (mesh == NULL) { 225 fprintf(stderr, "Error allocating memory\n"); 226 exit(1); 227 } 228 229 mesh->vertices = (Vertex *)malloc (sizeof(Vertex) * pmodel->numvertices); 230 231 if (mesh->vertices == NULL) { 232 fprintf(stderr, "Error allocating memory\n"); 233 exit(1); 234 } 235 236 mesh->triangles = (Triangle *)malloc (sizeof(Triangle) * pmodel->numtriangles); 237 238 if (mesh->triangles == NULL) { 239 fprintf(stderr, "Error allocating memory\n"); 240 exit(1); 241 } 284 int i, e; 285 int v1, v2, v3; 286 float x, y, z; 287 //int *vlist = NULL, j, num; 288 Mesh *mesh; 289 #ifdef OUTPUT_SEVERAL_GROUPS 290 int t; 291 int curGroup; 292 GLMgroup *group; 293 #endif 294 295 mesh = (Mesh *)malloc (sizeof(Mesh)); 296 297 if (mesh == NULL) { 298 fprintf(stderr, "Error allocating memory\n"); 299 exit(1); 300 } 301 302 mesh->vertices = (Vertex *)malloc (sizeof(Vertex) * pmodel->numvertices); 303 mesh->numVertices = 0; 304 305 if (mesh->vertices == NULL) { 306 fprintf(stderr, "Error allocating memory\n"); 307 exit(1); 308 } 309 310 mesh->triangles = (Triangle *)malloc (sizeof(Triangle) * pmodel->numtriangles); 311 mesh->numTriangles = 0; 312 313 if (mesh->triangles == NULL) { 314 fprintf(stderr, "Error allocating memory\n"); 315 exit(1); 316 } 242 317 243 318 printf("Adding vertices..."); 244 for (i=1; i<=(int)pmodel->numvertices; i++) { // Vertices start at 1 245 mesh->vertices[i - 1].x = pmodel->vertices[3 * i + 0]; 246 mesh->vertices[i - 1].y = pmodel->vertices[3 * i + 1]; 247 mesh->vertices[i - 1].z = pmodel->vertices[3 * i + 2]; 248 mesh->vertices[i - 1].numTriangles = 0; 249 mesh->vertices[i - 1].triangles = NULL; 250 mesh->vertices[i - 1].numEdges = 0; 251 mesh->vertices[i - 1].edges = NULL; 252 mesh->vertices[i - 1].enable = GL_TRUE; 253 } 319 for (i=1; i<=(int)pmodel->numvertices; i++) { // Vertices start at 1 320 321 x = pmodel->vertices[3 * i + 0]; 322 y = pmodel->vertices[3 * i + 1]; 323 z = pmodel->vertices[3 * i + 2]; 324 325 addVertex(mesh, x, y, z); 326 } 254 327 printf("Ok\n"); 255 mesh-> numVertices = pmodel->numvertices;256 mesh->currentNumVertices = pmodel->numvertices;328 mesh->currentNumVertices = mesh->numVertices; 329 printf("Number of vertices: %d\n", mesh->numVertices); 257 330 258 331 printf("Adding triangles..."); 259 260 332 #ifdef OUTPUT_SEVERAL_GROUPS 261 333 group = pmodel->groups; 262 334 curGroup=0; // current group 263 while(group) { 264 265 for (i=0; i<(int)group->numtriangles; i++) { 266 267 t = group->triangles[i]; 268 269 mesh->triangles[t].id = t; 270 mesh->triangles[t].group = curGroup; // set group 271 mesh->triangles[t].indices[0] = pmodel->triangles[t].vindices[0] - 1; 272 mesh->triangles[t].indices[1] = pmodel->triangles[t].vindices[1] - 1; 273 mesh->triangles[t].indices[2] = pmodel->triangles[t].vindices[2] - 1; 274 mesh->triangles[t].area = computeTriangleArea(mesh->vertices, &mesh->triangles[t]); 275 //printf("\n%d a: %f",i , mesh->triangles[i].area); 276 computeTriangleNormal(mesh->vertices, &mesh->triangles[t]); 277 278 mesh->triangles[t].saliency = 0.0; 279 280 mesh->triangles[t].enable = GL_TRUE; 281 282 for (j=0; j<3; j++) { 283 // Adding triangle i adjacent to 3 vertices 284 v1 = mesh->triangles[t].indices[j]; 285 286 // Reallocate memory for the new adjacent triangle 287 mesh->vertices[v1].triangles = 288 (int *)realloc(mesh->vertices[v1].triangles, (mesh->vertices[v1].numTriangles + 1) * sizeof(int)); 289 addItem((int *)mesh->vertices[v1].triangles, (int *)&mesh->vertices[v1].numTriangles, t); 290 } 291 } 292 curGroup++; 293 group = group->next; 294 } 335 while(group) { 336 337 for (i=0; i<(int)group->numtriangles; i++) { 338 339 t = group->triangles[i]; 340 341 v1 = pmodel->triangles[t].vindices[0] - 1; 342 v2 = pmodel->triangles[t].vindices[1] - 1; 343 v3 = pmodel->triangles[t].vindices[2] - 1; 344 345 // not a degenerated triangle 346 if ((v1 != v2) && (v2 != v3) && (v1 != v3)) { 347 348 addTriangle(mesh, curGroup, v1, v2, v3); 349 } 350 } 351 curGroup++; 352 group = group->next; 353 } 295 354 #else // One single group 296 for (i=0; i<pmodel->numtriangles; i++) { 297 mesh->triangles[i].id = i; 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; 301 mesh->triangles[i].area = computeTriangleArea(mesh->vertices, &mesh->triangles[i]); 302 //printf("\n%d a: %f",i , mesh->triangles[i].area); 303 computeTriangleNormal(mesh->vertices, &mesh->triangles[i]); 304 305 mesh->triangles[i].saliency = 0.0; 306 307 mesh->triangles[i].enable = GL_TRUE; 308 309 for (j=0; j<3; j++) { 310 // Adding triangle i adjacent to 3 vertices 311 v1 = mesh->triangles[i].indices[j]; 312 313 // Reallocate memory for the new adjacent triangle 314 mesh->vertices[v1].triangles = 315 (int *)realloc(mesh->vertices[v1].triangles, (mesh->vertices[v1].numTriangles + 1) * sizeof(int)); 316 addItem((int *)mesh->vertices[v1].triangles, (int *)&mesh->vertices[v1].numTriangles, i); 317 } 318 } 355 for (i=0; i<(int)pmodel->numtriangles; i++) { 356 357 v1 = pmodel->triangles[i].vindices[0] - 1; 358 v2 = pmodel->triangles[i].vindices[1] - 1; 359 v3 = pmodel->triangles[i].vindices[2] - 1; 360 361 // not a degenerated triangle 362 if ((v1 != v2) && (v2 != v3) && (v1 != v3)) { 363 364 addTriangle(mesh, 1, v1, v2, v3); 365 } 366 } 319 367 printf("\n"); 320 368 #endif 369 printf("Ok\n"); 370 mesh->currentNumTriangles = mesh->numTriangles; 371 printf("Number of triangles: %d\n", mesh->numTriangles); 372 printf("Number of degenerated triangles: %d\n", pmodel->numtriangles - mesh->numTriangles); 373 374 mesh->edges = (Edge *)malloc (sizeof(Edge) * mesh->numTriangles * 3); // E = 3 T / 2 375 mesh->numEdges = 0; 376 377 if (mesh->edges == NULL) { 378 fprintf(stderr, "Error allocating memory\n"); 379 exit(1); 380 } 381 382 printf("Adding edges..."); 383 384 /*for (i=0; i<mesh->numVertices; i++) { 385 vlist = verticesAdjToVertex(mesh, i, &num); 386 387 for (j=0; j<num; j++) { 388 389 if (i < vlist[j]) { 390 391 addEdge(mesh, i, vlist[j]); 392 } 393 } 394 free(vlist); 395 }*/ 396 397 for (i=0; i<mesh->numTriangles; i++) { 398 399 v1 = mesh->triangles[i].indices[0]; 400 v2 = mesh->triangles[i].indices[1]; 401 v3 = mesh->triangles[i].indices[2]; 402 403 ///////////////////////////////////////////////////////////////////////////////// 404 // edge (v1,v2) 405 if ((e = findEdge(mesh->edges, mesh->numEdges, v1, v2)) == -1) { 406 407 addEdge(mesh, v1, v2); 408 } 409 ///////////////////////////////////////////////////////////////////////////////// 410 // edge (v2,v3) 411 if ((e = findEdge(mesh->edges, mesh->numEdges, v2, v3)) == -1) { 412 413 addEdge(mesh, v2, v3); 414 } 415 ///////////////////////////////////////////////////////////////////////////////// 416 // edge (v3,v1) 417 if ((e = findEdge(mesh->edges, mesh->numEdges, v3, v1)) == -1) { 418 419 addEdge(mesh, v3, v1); 420 } 421 } 321 422 printf("Ok\n"); 322 323 mesh->numTriangles = pmodel->numtriangles;324 mesh->currentNumTriangles = pmodel->numtriangles;325 printf("Number of triangles: %d\n", mesh->numTriangles);326 327 mesh->edges = (Edge *)malloc (sizeof(Edge) * mesh->numTriangles * 3); // E = 3 T / 2328 329 if (mesh->edges == NULL) {330 fprintf(stderr, "Error allocating memory\n");331 exit(1);332 }333 334 printf("Adding edges...");335 n = 0;336 337 for (i=0; i<mesh->numTriangles; i++) {338 t = 0;339 v1 = mesh->triangles[i].indices[0];340 v2 = mesh->triangles[i].indices[1];341 v3 = mesh->triangles[i].indices[2];342 343 /////////////////////////////////////////////////////////////////////////////////344 // edge (v1,v2)345 if ((e = findEdge(mesh->edges, n, v1, v2)) == -1) {346 mesh->edges[n].u = v1;347 mesh->edges[n].v = v2;348 mesh->edges[n].enable = GL_TRUE;349 m = n;350 n++;351 } else m = e;352 353 /////////////////////////////////////////////////////////////////////////////////354 // edge (v2,v3)355 if (( e = findEdge(mesh->edges, n, v2, v3)) == -1) {356 mesh->edges[n].u = v2;357 mesh->edges[n].v = v3;358 mesh->edges[n].enable = GL_TRUE;359 m = n;360 n++;361 } else m = e;362 363 /////////////////////////////////////////////////////////////////////////////////364 // edge (v3,v1)365 if ((e = findEdge(mesh->edges, n, v3, v1)) == -1) {366 mesh->edges[n].u = v3;367 mesh->edges[n].v = v1;368 mesh->edges[n].enable = GL_TRUE;369 m = n;370 n++;371 } else m = e;372 }373 printf("Ok\n");374 mesh->numEdges = n;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 v1383 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 v2388 addItem(mesh->vertices[v2].edges, &mesh->vertices[v2].numEdges, i);389 }390 423 391 424 return mesh; -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/saliency.cpp
r2127 r2323 58 58 59 59 double VMI::computeTriangleSaliency(Mesh *mesh, int **histogram, int numCameras, int k) { 60 int i, l, v0, v1, v2;61 int *triangles = NULL,n = 0;60 int i, j, t, v0; 61 int n = 0; 62 62 double sal = 0.0; 63 63 64 v0 = mesh->triangles[k].indices[0]; 65 v1 = mesh->triangles[k].indices[1]; 66 v2 = mesh->triangles[k].indices[2]; 67 68 /* Allocating memory */ 69 triangles = (int *)malloc((mesh->vertices[v0].numTriangles + 70 mesh->vertices[v1].numTriangles + 71 mesh->vertices[v2].numTriangles) * sizeof(int)); 72 73 for(i=0; i<mesh->vertices[v0].numTriangles; i++) { 74 l = mesh->vertices[v0].triangles[i]; 64 for (j=0; j<3; j++) { 75 65 76 if (l != k) 77 addItem(triangles, &n, l); 78 } 79 80 for(i=0; i<mesh->vertices[v1].numTriangles; i++) { 81 l = mesh->vertices[v1].triangles[i]; 66 v0 = mesh->triangles[k].indices[j]; 82 67 83 if (l != k) 84 addItem(triangles, &n, l); 85 } 86 87 for(i=0; i<mesh->vertices[v2].numTriangles; i++) { 88 l = mesh->vertices[v2].triangles[i]; 89 90 if (l != k) 91 addItem(triangles, &n, l); 92 } 93 94 //printItemList(triangles, n); 95 96 for(i=0; i<n; i++) { 97 //printf("\n%d %d", k, triangles[i]); 98 //sal += computeJS(histogram, numCameras, k, triangles[i]); 99 sal = MAX ( sal, computeJS(histogram, numCameras, k, triangles[i])); 68 for(i=0; i<mesh->vertices[v0].numTriangles; i++) { 69 t = mesh->vertices[v0].triangles[i]; 70 71 if (t != k) { 72 //printf("\n%d %d", k, triangles[i]); 73 //sal += computeJS(histogram, numCameras, k, t); 74 sal = MAX(sal, computeJS(histogram, numCameras, k, t)); 75 76 n++; 77 } 78 } 100 79 } 101 80 //printf("\nT%d Sal: %f\n", k, (sal / n)); 102 81 //getchar(); 103 82 104 free(triangles);105 106 83 return (sal /*/ n*/); 107 84 } -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp
r2300 r2323 413 413 //------------------------------------------------------------------------- 414 414 inline void GeoMeshViewUI::cb_menuEditPan_i(fltk::Item *item, void*) 415 { 415 { 416 416 // If the item is activated. 417 417 if (item->value()) … … 496 496 geoMeshView->deactiveSolid(); 497 497 } 498 498 499 499 // Repaint the canvas. 500 500 //geoMeshView->redraw(); … … 790 790 // Leaves collapse Callback 791 791 //------------------------------------------------------------------------- 792 inline void GeoMeshViewUI::cb_menuSimplifyLeavesCollapse_i(fltk::Item*, void*) 792 inline void GeoMeshViewUI::cb_menuSimplifyLeavesCollapse_i( fltk::Item *, 793 void *) 793 794 { 794 795 // Show title. … … 896 897 cb_menuLodTreesGenerate_i(o,v); 897 898 } 898 899 899 900 900 //------------------------------------------------------------------------- … … 1038 1038 } 1039 1039 1040 1041 1042 1040 //------------------------------------------------------------------------- 1043 1041 // About Callback … … 1103 1101 } 1104 1102 1105 // if the mesh is stripified.1103 // If the mesh is stripified. 1106 1104 if (error) 1107 1105 { … … 1119 1117 mGeoMesh = mesh_aux; 1120 1118 1121 // 1119 // Visualize mesh. 1122 1120 geoMeshView->setMesh(mGeoMesh); 1123 1121 … … 1128 1126 } 1129 1127 1130 // 1128 // Visualize mesh. 1131 1129 geoMeshView->setMesh(mGeoMesh); 1132 1130 … … 1134 1132 break; 1135 1133 1136 // 1134 // Simplify leaves 1137 1135 case LEAVES_COLLAPSE: 1138 1136 … … 1347 1345 delete mUndoMesh; 1348 1346 1349 1350 1347 mUndoMesh = new Mesh(); 1351 1348 … … 1617 1614 } 1618 1615 1619 //------------------------------------------------------------------------- --1616 //------------------------------------------------------------------------- 1620 1617 // Show the Simlify Leaves Collapse. 1621 //------------------------------------------------------------------------- --1618 //------------------------------------------------------------------------- 1622 1619 void GeoMeshViewUI::showLeavesCollapse() 1623 1620 { … … 2021 2018 // If the mesh does not have shared vertex. 2022 2019 if (!geoSubMesh->mSharedVertexBuffer) 2023 { 2020 { 2024 2021 // Adds the vertex of the submesh to the total count. 2025 2022 vertex_count += geoSubMesh->mVertexBuffer->mVertexCount; … … 2089 2086 { 2090 2087 strip_count += geoSubMesh->mStripCount; 2091 } 2088 } 2092 2089 } 2093 2090 … … 2351 2348 tree_sequencer = mTreeSimplifier->GetSimplificationSequence(); 2352 2349 2353 tree_sequencer->putMeshName(nombremesh); 2350 tree_sequencer->putMeshName(nombremesh); 2354 2351 tree_sequencer->Save(Serializer(filename,Serializer::APPEND)); 2355 2352 … … 2483 2480 } 2484 2481 2482 //------------------------------------------------------------------------- 2485 2483 // Method that updates the porgress bar. 2484 //------------------------------------------------------------------------- 2486 2485 float GeoMeshViewUI::updateProgressBar(float v) 2487 2486 { … … 2538 2537 // Initialize the lodTreelibrary for visualization. 2539 2538 //------------------------------------------------------------------------- 2540 void GeoMeshViewUI::setLodTreesLibrary(const LodStripsLibraryData *lodstripsdata, const TreeSimplificationSequence *treesimpseq, Mesh *geomesh/*, uint32 ileafSubMesh*/) 2539 void GeoMeshViewUI::setLodTreesLibrary( 2540 const LodStripsLibraryData *lodstripsdata, 2541 const TreeSimplificationSequence *treesimpseq, 2542 Mesh *geomesh) 2541 2543 { 2542 2544 // If there is no lod strips object. … … 2548 2550 2549 2551 // New lod strips object. 2550 2551 2552 lod_index_data = new GeoToolIndexData(geomesh->mSubMeshCount); 2552 lodTreeLib = new Geometry::LodTreeLibrary(lodstripsdata,treesimpseq,geomesh,lod_index_data); 2553 2554 lodTreeLib = new Geometry::LodTreeLibrary( lodstripsdata, 2555 treesimpseq, 2556 geomesh, 2557 lod_index_data); 2553 2558 2554 2559 // Sets the slider range. … … 2616 2621 // Translate the MB count to a char value. 2617 2622 sprintf(char_value, 2618 "MB %.3f",2619 (float)geoMeshLoader->getFileSize()/1024/1024);2623 "MB %.3f", 2624 (float)geoMeshLoader->getFileSize()/1024/1024); 2620 2625 2621 2626 mMB->label(char_value); … … 2747 2752 // Initialize the lod strip object. 2748 2753 lodStripsLib = NULL; 2749 lodTreeLib = NULL;2750 2751 // Identify the mesh that stores the leaves 2754 lodTreeLib = NULL; 2755 2756 // Identify the mesh that stores the leaves. 2752 2757 idMeshLeaves = -1; 2753 2758
Note: See TracChangeset
for help on using the changeset viewer.