Changeset 804 for trunk/vizservers
- Timestamp:
- Sep 24, 2007, 10:19:06 AM (17 years ago)
- Location:
- trunk/vizservers/nanovis
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/vizservers/nanovis/NvZincBlendeReconstructor.cpp
r800 r804 30 30 int width = 0, height = 0, depth = 0; 31 31 void* data = NULL; 32 32 33 33 34 std::ifstream stream; … … 59 60 else if (strstr((const char*) buff, "object") != 0) 60 61 { 62 printf("VERSION 1\n"); 63 fflush(stdout); 61 64 version = 1; 62 65 break; … … 64 67 else if (strstr(buff, "record format") != 0) 65 68 { 69 printf("VERSION 2\n"); 70 fflush(stdout); 66 71 version = 2; 67 72 break; … … 113 118 { 114 119 sscanf(pt, "%s%f%f%f", str[0], &(delta.x), &(delta.y), &(delta.z)); 120 printf("delta : %f %f %f\n", delta.x, delta.y, delta.z); 121 fflush(stdout); 115 122 } 116 123 else if ((pt = strstr(buff, "datacount")) != 0) 117 124 { 118 125 sscanf(pt, "%s%d", str[0], &datacount); 126 printf("datacount = %d\n", datacount); 127 fflush(stdout); 119 128 } 120 129 else if ((pt = strstr(buff, "datatype")) != 0) … … 128 137 { 129 138 sscanf(pt, "%s%d%d%d", str[0], &width, &height, &depth); 139 printf("width height depth %d %d %d\n", width, height, depth); 140 fflush(stdout); 130 141 } 131 142 else if ((pt = strstr(buff, "emptymark")) != 0) 132 143 { 133 144 sscanf(pt, "%s%lf", str[0], &emptyvalue); 145 printf("empryvalue %lf\n", emptyvalue); 146 fflush(stdout); 134 147 } 135 148 else if ((pt = strstr(buff, "emprymark")) != 0) 136 149 { 137 150 sscanf(pt, "%s%lf", str[0], &emptyvalue); 138 } 139 } while(strcmp(buff, "<\\HDR>") != 0); 151 printf("emptyvalue %lf\n", emptyvalue); 152 } 153 } while(strcmp(buff, "<\\HDR>") != 0 && strcmp(buff, "</HDR>") != 0); 140 154 141 155 data = malloc(width * height * depth * 8 * 4 * sizeof(double)); 156 memset(data, 0, width * height * depth * 8 * 4 * sizeof(double)); 142 157 stream.read((char*) data, width * height * depth * 8 * 4 * sizeof(double)); 143 158 … … 213 228 { 214 229 index = srcPtr->getIndex(width, height); 230 231 printf("index %d\n", index); 232 fflush(stdout); 233 215 234 component4A = fourAnionVolume + index; 216 235 component4B = fourCationVolume + index; … … 281 300 282 301 index = srcPtr->getIndex(width, height); 302 printf("[%d] index %d (width:%lf height:%lf depth:%lf)\n", i, index, srcPtr->indexX, srcPtr->indexY, srcPtr->indexZ); 303 fflush(stdout); 304 305 if (index < 0) { 306 printf("There is an invalid data\n"); 307 fflush(stdout); 308 srcPtr +=8; 309 continue; 310 } 311 283 312 component4A = fourAnionVolume + index; 284 313 component4B = fourCationVolume + index; … … 343 372 344 373 buff[index] = '\0'; 345 } 346 374 375 printf("%s", buff); 376 fflush(stdout); 377 } 378 379 ZincBlendeVolume* NvZincBlendeReconstructor::loadFromMemory(void* dataBlock) 380 { 381 ZincBlendeVolume* volume = 0; 382 Vector3 origin, delta; 383 double temp; 384 int width = 0, height = 0, depth = 0; 385 void* data = NULL; 386 int version = 1; 387 388 unsigned char* stream = (unsigned char*)dataBlock; 389 char str[5][20]; 390 do { 391 getLine(stream); 392 if (buff[0] == '#') 393 { 394 continue; 395 } 396 else if (strstr((const char*) buff, "object") != 0) 397 { 398 printf("VERSION 1\n"); 399 fflush(stdout); 400 version = 1; 401 break; 402 } 403 else if (strstr(buff, "record format") != 0) 404 { 405 printf("VERSION 2\n"); 406 fflush(stdout); 407 version = 2; 408 break; 409 } 410 } while(1); 411 412 413 if (version == 1) 414 { 415 sscanf(buff, "%s%s%s%s%s%d%d%d", str[0], str[1], str[2], str[3], str[4],&width, &height, &depth); 416 getLine(stream); 417 sscanf(buff, "%s%f%f%f", str[0], &(origin.x), &(origin.y), &(origin.z)); 418 getLine(stream); 419 sscanf(buff, "%s%f%f%f", str[0], &(delta.x), &temp, &temp); 420 getLine(stream); 421 sscanf(buff, "%s%f%f%f", str[0], &temp, &(delta.y), &temp); 422 getLine(stream); 423 sscanf(buff, "%s%f%f%f", str[0], &temp, &temp, &(delta.z)); 424 do { 425 getLine(stream); 426 } while(strcmp(buff, "<\\HDR>") != 0); 427 428 width = width / 4; 429 height = height / 4; 430 depth = depth / 4; 431 data = malloc(width * height * depth * 8 * 4 * sizeof(double)); 432 // 8 atom per cell, 4 double (x, y, z, and probability) per atom 433 try { 434 memcpy(data, stream, width * height * depth * 8 * 4 * sizeof(double)); 435 } 436 catch (...) 437 { 438 printf("ERROR\n"); 439 } 440 441 volume = buildUp(origin, delta, width, height, depth, data); 442 443 free(data); 444 } 445 else if (version == 2) 446 { 447 const char* pt; 448 int datacount = -1; 449 double emptyvalue; 450 do { 451 getLine(stream); 452 if ((pt = strstr(buff, "delta")) != 0) 453 { 454 sscanf(pt, "%s%f%f%f", str[0], &(delta.x), &(delta.y), &(delta.z)); 455 printf("delta : %f %f %f\n", delta.x, delta.y, delta.z); 456 fflush(stdout); 457 } 458 else if ((pt = strstr(buff, "datacount")) != 0) 459 { 460 sscanf(pt, "%s%d", str[0], &datacount); 461 printf("datacount = %d\n", datacount); 462 fflush(stdout); 463 } 464 else if ((pt = strstr(buff, "datatype")) != 0) 465 { 466 sscanf(pt, "%s%s", str[0], str[1]); 467 if (strcmp(str[1], "double64")) 468 { 469 } 470 } 471 else if ((pt = strstr(buff, "count")) != 0) 472 { 473 sscanf(pt, "%s%d%d%d", str[0], &width, &height, &depth); 474 printf("width height depth %d %d %d\n", width, height, depth); 475 fflush(stdout); 476 } 477 else if ((pt = strstr(buff, "emptymark")) != 0) 478 { 479 sscanf(pt, "%s%lf", str[0], &emptyvalue); 480 printf("empryvalue %lf\n", emptyvalue); 481 fflush(stdout); 482 } 483 else if ((pt = strstr(buff, "emprymark")) != 0) 484 { 485 sscanf(pt, "%s%lf", str[0], &emptyvalue); 486 printf("emptyvalue %lf\n", emptyvalue); 487 } 488 } while(strcmp(buff, "<\\HDR>") != 0 && strcmp(buff, "</HDR>") != 0); 489 490 if (datacount == -1) datacount = width * height * depth; 491 492 data = malloc(datacount * 8 * 4 * sizeof(double)); 493 memset(data, 0, datacount * 8 * 4 * sizeof(double)); 494 memcpy(data, stream, datacount * 8 * 4 * sizeof(double)); 495 496 volume = buildUp(origin, delta, width, height, depth, datacount, emptyvalue, data); 497 498 free(data); 499 } 500 return volume; 501 } 502 503 void NvZincBlendeReconstructor::getLine(unsigned char*& stream) 504 { 505 char ch; 506 int index = 0; 507 do { 508 ch = stream[0]; 509 ++stream; 510 if (ch == '\n') break; 511 buff[index++] = ch; 512 if (ch == '>') 513 { 514 if (buff[1] == '\\') 515 break; 516 } 517 } while (1); 518 519 buff[index] = '\0'; 520 521 printf("%s", buff); 522 fflush(stdout); 523 } -
trunk/vizservers/nanovis/NvZincBlendeReconstructor.h
r800 r804 56 56 */ 57 57 void getLine(std::istream& stream); 58 void getLine(unsigned char*& stream); 58 59 59 60 public : … … 69 70 */ 70 71 ZincBlendeVolume* loadFromStream(std::istream& stream); 72 ZincBlendeVolume* loadFromMemory(void* dataBlock); 71 73 72 74 /** -
trunk/vizservers/nanovis/nanovis.cpp
r799 r804 50 50 #include "HeightMap.h" 51 51 #include "Grid.h" 52 53 //#define _LOCAL_ZINC_TEST_ 52 54 53 55 // R2 headers … … 805 807 } 806 808 else if (c == 'f' && strcmp(argv[2],"follows") == 0) { 807 //printf("Data Loading\n");809 printf("Data Loading\n"); 808 810 //fflush(stdout); 809 811 //return TCL_OK; … … 817 819 Rappture::Buffer buf; 818 820 821 // DEBUG 822 int totalsize = nbytes; 819 823 char buffer[8096]; 820 824 while (nbytes > 0) … … 822 826 int chunk = (sizeof(buffer) < nbytes) ? sizeof(buffer) : nbytes; 823 827 int status = fread(buffer, 1, chunk, stdin); 828 printf("Begin Reading [%d Read : %d Left]\n", status, nbytes - status); 829 fflush(stdout); 824 830 if (status > 0) { 825 831 buf.append(buffer,status); 826 832 nbytes -= status; 827 833 } else { 834 printf("data unpacking failed\n"); 828 835 Tcl_AppendResult(interp, "data unpacking failed: unexpected EOF", 829 836 (char*)NULL); … … 834 841 err = Rappture::encoding::decode(buf,RPENC_Z|RPENC_B64|RPENC_HDR); 835 842 if (err) { 843 printf("ERROR -- DECODING\n"); 844 fflush(stdout); 836 845 Tcl_AppendResult(interp, err.remark().c_str(), (char*)NULL); 837 846 return TCL_ERROR; 838 847 } 839 840 /*841 int nbytes;842 if (Tcl_GetInt(interp, argv[3], &nbytes) != TCL_OK) {843 return TCL_ERROR;844 }845 */846 847 848 848 849 int n = n_volumes; … … 851 852 header[5] = '\0'; 852 853 854 #ifdef _LOCAL_ZINC_TEST_ 855 FILE* fp = fopen("/home/nanohub/vrinside/nv/data/HOON/QDWL_100_100_50_strain_8000i.nd_zatom_12_1", "rb"); 856 unsigned char* b = (unsigned char*) malloc(buf.size()); 857 if (fp == 0) 858 { 859 printf("cannot open the file\n"); 860 fflush(stdout); 861 return TCL_ERROR; 862 } 863 fread(b, buf.size(), 1, fp); 864 fclose(fp); 865 #endif 866 853 867 868 printf("Checking header[%s]\n", header); 869 fflush(stdout); 854 870 if (!strcmp(header, "<HDR>")) 855 871 { 856 printf("HDR stream is in\n");857 std::stringstream fdata(std::ios_base::out|std::ios_base::in|std::ios_base::binary);858 fdata.write(buf.bytes(),buf.size());859 860 872 Volume* vol = NULL; 861 vol = NvZincBlendeReconstructor::getInstance()->loadFromStream(fdata); 873 874 printf("ZincBlende stream is in\n"); 875 fflush(stdout); 876 //std::stringstream fdata(std::ios_base::out|std::ios_base::in|std::ios_base::binary); 877 //fdata.write(buf.bytes(),buf.size()); 878 //vol = NvZincBlendeReconstructor::getInstance()->loadFromStream(fdata); 879 880 #ifdef _LOCAL_ZINC_TEST_ 881 vol = NvZincBlendeReconstructor::getInstance()->loadFromMemory(b); 882 #else 883 vol = NvZincBlendeReconstructor::getInstance()->loadFromMemory((void*) buf.bytes()); 884 #endif 885 886 printf("finish loading\n"); 887 fflush(stdout); 862 888 if (vol) 863 889 { … … 885 911 { 886 912 printf("OpenDX loading...\n"); 913 fflush(stdout); 887 914 std::stringstream fdata; 888 915 fdata.write(buf.bytes(),buf.size()); … … 1648 1675 return TCL_OK; 1649 1676 } 1650 1651 1677 1652 1678 //report errors related to CG shaders
Note: See TracChangeset
for help on using the changeset viewer.