Changeset 1380
- Timestamp:
- Apr 4, 2009 4:49:00 PM (15 years ago)
- Location:
- trunk/packages/vizservers
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanoscale/server.c
r1278 r1380 75 75 _x > _y ? _x : _y; }) 76 76 77 #ifdef notdef 77 78 static int 78 79 find_best_host(void) … … 103 104 return index; 104 105 } 106 #endif 105 107 106 108 static void … … 572 574 // accept the connection. 573 575 msg = 0; 574 write(i, &msg, 4); 576 if (write(i, &msg, 4) != 4) { 577 fprintf(stderr, "short write for hostname\n"); 578 } 575 579 576 580 int pair[2]; -
trunk/packages/vizservers/nanovis/Command.cpp
r1374 r1380 1753 1753 return TCL_ERROR; 1754 1754 } 1755 #ifdef notdef 1755 1756 } else if (strncmp(buf.bytes(), "<unirect3d>", 4) == 0) { 1757 1756 1758 Rappture::Unirect3d data; 1757 1759 Tcl_CmdInfo cmdInfo; … … 1775 1777 return TCL_ERROR; 1776 1778 } 1779 #endif 1777 1780 } 1778 1781 -
trunk/packages/vizservers/nanovis/FlowCmds.cpp
r1374 r1380 71 71 #include "NvLIC.h" 72 72 #include "Unirect.h" 73 74 struct Stream { 75 float position; 76 bool hide; 77 int axis; 78 }; 79 80 struct InitStream { 81 const char *name; 82 Tcl_HashEntry *hashPtr; 83 bool hide; 84 float position; 85 }; 86 87 struct FlowCmd { 88 const char *name; 89 Tcl_HashEntry *hashPtr; 90 Volume *volPtr; 91 Stream streams[3]; // Stream for each axis-aligned plane; 92 bool lic; 93 bool hide; 94 Tcl_HashTable injectTable; 95 Tcl_Command cmdToken; 96 }; 97 98 extern int GetDataStream(Tcl_Interp *interp, Rappture::Buffer &buf, int nBytes); 99 extern bool load_vector_stream2(Rappture::Outcome &result, int index, 100 size_t nBytes, char *bytes); 101 102 extern bool MakeVectorFieldFromUnirect3d(Rappture::Outcome &result, 103 Rappture::Unirect3d &data); 104 105 extern int GetBooleanFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 106 bool *boolPtr); 107 extern int GetFloatFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 108 float *floatPtr); 109 extern int GetAxisFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 110 int *axisPtr); 111 extern int GetVolumeFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 112 Volume **volumePtrPtr); 73 #include "FlowCmd.h" 113 74 114 75 static Tcl_HashTable flowTable; … … 134 95 Tcl_Obj *const *objv) 135 96 { 136 Rappture::Outcome result;97 Rappture::Outcome context; 137 98 138 99 const char *fileName; … … 145 106 } 146 107 Rappture::Buffer buf; 147 if (!buf.load( result, fileName)) {108 if (!buf.load(context, fileName)) { 148 109 Tcl_AppendResult(interp, "can't load data from \"", fileName, "\": ", 149 result.remark(), (char *)NULL);150 return TCL_ERROR; 151 } 152 153 int n = NanoVis::n_volumes;110 context.remark(), (char *)NULL); 111 return TCL_ERROR; 112 } 113 114 FlowCmd *flowPtr = (FlowCmd *)clientData; 154 115 if (strncmp(buf.bytes(), "<DX>", 4) == 0) { 155 if (!load_vector_stream2(result, n, buf.size(), (char *)buf.bytes())) { 156 Tcl_AppendResult(interp, result.remark(), (char *)NULL); 116 Rappture::Unirect3d data; 117 if (!load_vector_stream2(context, buf.size(), (char *)buf.bytes(), 118 data)) { 119 Tcl_AppendResult(interp, context.remark(), (char *)NULL); 157 120 return TCL_ERROR; 158 121 } 122 flowPtr->dataPtr = &data; 159 123 } else if (strncmp(buf.bytes(), "<unirect3d>", 4) == 0) { 160 124 Rappture::Unirect3d data; … … 175 139 return TCL_ERROR; 176 140 } 177 if (!MakeVectorFieldFromUnirect3d(result, data)) { 178 Tcl_AppendResult(interp, result.remark(), (char *)NULL); 179 return TCL_ERROR; 180 } 181 } 182 FlowCmd *flowPtr = (FlowCmd *)clientData; 183 184 if (flowPtr->volPtr != NULL) { 185 // You might have to remove the volume from the particle renderer. 186 delete flowPtr->volPtr; 187 } 141 flowPtr->dataPtr = &data; 142 } 143 144 #ifdef notdef 188 145 flowPtr->volPtr = NanoVis::volume[NanoVis::n_volumes]; 189 146 // … … 209 166 float dz0 = -0.5*flowPtr->volPtr->depth/flowPtr->volPtr->width; 210 167 flowPtr->volPtr->move(Vector3(dx0, dy0, dz0)); 168 #endif 211 169 return TCL_OK; 212 170 } … … 216 174 Tcl_Obj *const *objv) 217 175 { 218 Rappture::Outcome result;176 Rappture::Outcome context; 219 177 220 178 Trace("Flow Data Loading\n"); … … 232 190 return TCL_ERROR; 233 191 } 234 int n = NanoVis::n_volumes;192 FlowCmd *flowPtr = (FlowCmd *)clientData; 235 193 if (strncmp(buf.bytes(), "<DX>", 4) == 0) { 236 if (!load_vector_stream2(result, n, buf.size(), (char *)buf.bytes())) { 237 Tcl_AppendResult(interp, result.remark(), (char *)NULL); 194 if (!load_vector_stream2(context, buf.size(), (char *)buf.bytes(), 195 flowPtr)) { 196 Tcl_AppendResult(interp, context.remark(), (char *)NULL); 238 197 return TCL_ERROR; 239 198 } … … 256 215 return TCL_ERROR; 257 216 } 258 if (! MakeVectorFieldFromUnirect3d(result, data)) {259 Tcl_AppendResult(interp, result.remark(), (char *)NULL);217 if (!SetVectorFieldDataFromUnirect3d(context, data, flowPtr)) { 218 Tcl_AppendResult(interp, context.remark(), (char *)NULL); 260 219 return TCL_ERROR; 261 220 } 262 221 } 263 FlowCmd *flowPtr = (FlowCmd *)clientData;264 265 222 if (flowPtr->volPtr != NULL) { 266 223 delete flowPtr->volPtr; 267 224 } 225 #ifdef notdef 226 // FIXME: Move this to flow pending routine. 227 268 228 flowPtr->volPtr = NanoVis::volume[NanoVis::n_volumes]; 269 229 // … … 289 249 float dz0 = -0.5*flowPtr->volPtr->depth/flowPtr->volPtr->width; 290 250 flowPtr->volPtr->move(Vector3(dx0, dy0, dz0)); 251 #endif 291 252 return TCL_OK; 292 253 } … … 316 277 { 317 278 {Rappture::SWITCH_BOOLEAN, "-hide", "boolean", 318 offsetof(Stream, hid e), 0},279 offsetof(Stream, hidden), 0}, 319 280 {Rappture::SWITCH_FLOAT, "-position", "number", 320 281 offsetof(Stream, position), 0}, … … 429 390 { 430 391 {Rappture::SWITCH_BOOLEAN, "-lic", "boolean", 431 offsetof(FlowCmd, hide), 0}, 392 offsetof(FlowCmd, lic), 0}, 393 {Rappture::SWITCH_BOOLEAN, "-hide", "boolean", 394 offsetof(FlowCmd, hidden), 0}, 432 395 {Rappture::SWITCH_END} 433 396 }; … … 452 415 { 453 416 {Rappture::SWITCH_BOOLEAN, "-hide", "boolean", 454 offsetof(InitStream, hid e), 0},417 offsetof(InitStream, hidden), 0}, 455 418 {Rappture::SWITCH_FLOAT, "-position", "number", 456 419 offsetof(InitStream, position), 0}, … … 603 566 *--------------------------------------------------------------------------- 604 567 * 568 * FlowShapeOp-- 569 * 570 * This procedure is invoked to process commands on behalf of the flow 571 * object. 572 * 573 * Results: 574 * A standard Tcl result. 575 * 576 * Side effects: 577 * See the user documentation. 578 * 579 *--------------------------------------------------------------------------- 580 */ 581 static Rappture::CmdSpec flowShapeOps[] = { 582 {"add", 1, FlowInjectorAddOp, 3, 0, "name ?switches?",}, 583 {"configure", 1, FlowInjectorConfigureOp, 3, 5, "name ?switches?",}, 584 {"delete", 1, FlowInjectorDeleteOp, 3, 0, "?name...?"}, 585 {"names", 1, FlowInjectorNamesOp, 3, 4, "?pattern?"}, 586 }; 587 588 static int nFlowShapeOps = NumCmdSpecs(flowShapeOps); 589 590 static int 591 FlowShapeOp(ClientData clientData, Tcl_Interp *interp, int objc, 592 Tcl_Obj *const *objv) 593 { 594 Tcl_ObjCmdProc *proc; 595 proc = Rappture::GetOpFromObj(interp, nFlowShapeOps, flowShapeOps, 596 Rappture::CMDSPEC_ARG1, objc, objv, 0); 597 if (proc == NULL) { 598 return TCL_ERROR; 599 } 600 FlowCmd *flowPtr = (FlowCmd *)clientData; 601 Tcl_Preserve(flowPtr); 602 int result; 603 result = (*proc) (clientData, interp, objc, objv); 604 Tcl_Release(flowPtr); 605 return result; 606 } 607 608 /* 609 *--------------------------------------------------------------------------- 610 * 605 611 * FlowInstObjCmd -- 606 612 * … … 621 627 {"injector", 1, FlowInjectorOp, 3, 0, "oper ?args?",}, 622 628 {"particles", 1, FlowParticlesOp, 3, 0, "oper ?args?",}, 623 {"stream", 1, FlowStreamOp, 4, 0, "oper axis ?args?",}, 629 {"shape", 2, FlowShapeOp, 3, 0, "oper ?args?",}, 630 {"stream", 2, FlowStreamOp, 4, 0, "oper axis ?args?",}, 624 631 }; 625 632 static int nFlowInstOps = NumCmdSpecs(flowInstOps); … … 708 715 (Tcl_ObjCmdProc *)FlowInstObjCmd, flowPtr, FlowInstDeleteProc); 709 716 Tcl_SetHashValue(hPtr, flowPtr); 710 711 717 flowPtr->volPtr = NULL; 712 718 return TCL_OK; … … 734 740 } 735 741 Tcl_DeleteCommandFromToken(interp, flowPtr->cmdToken); 742 #ifdef notdef 743 NanoVis::flowVisRenderer->removeVectorField(flowPtr); 744 #endif 736 745 delete flowPtr; 737 746 } 747 return TCL_OK; 748 } 749 750 /* 751 *--------------------------------------------------------------------------- 752 * 753 * FlowInitOp -- 754 * 755 *--------------------------------------------------------------------------- 756 */ 757 /*ARGSUSED*/ 758 static int 759 FlowInitOp(ClientData clientData, Tcl_Interp *interp, int objc, 760 Tcl_Obj *const *objv) 761 { 762 Tcl_Obj *listObjPtr; 763 listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **) NULL); 764 765 Tcl_HashEntry *hPtr; 766 Tcl_HashSearch iter; 767 for (hPtr = Tcl_FirstHashEntry(&flowTable, &iter); hPtr != NULL; 768 hPtr = Tcl_NextHashEntry(&iter)) { 769 FlowCmd *flowPtr; 770 flowPtr = (FlowCmd *)Tcl_GetHashValue(hPtr); 771 if (flowPtr->fieldPtr != NULL) { 772 delete flowPtr->fieldPtr; // Remove the vector field. 773 flowPtr->fieldPtr = NULL; 774 } 775 } 776 #ifdef notdef 777 // For each flow vector enabled in the table add it to the renderer. 778 for (hPtr = Tcl_FirstHashEntry(&flowTable, &iter); hPtr != NULL; 779 hPtr = Tcl_NextHashEntry(&iter)) { 780 FlowCmd *flowPtr; 781 flowPtr = (FlowCmd *)Tcl_GetHashValue(hPtr); 782 if (flowPtr->hidden) { 783 continue; // Flow is hidden. 784 } 785 if (flowPtr->volPtr == NULL) { 786 continue; 787 } 788 volPtr->set_n_slice(256-n); 789 // volPtr->set_n_slice(512-n); 790 volPtr->disable_cutplane(0); 791 volPtr->disable_cutplane(1); 792 volPtr->disable_cutplane(2); 793 794 NanoVis::vol_renderer->add_volume(volPtr, 795 NanoVis::get_transfunc("default")); 796 float dx0 = -0.5; 797 float dy0 = -0.5*volPtr->height/volPtr->width; 798 float dz0 = -0.5*volPtr->depth/volPtr->width; 799 volPtr->move(Vector3(dx0, dy0, dz0)); 800 //volPtr->enable_data(); 801 volPtr->disable_data(); 802 NvVectorField *fieldPtr; 803 fieldPtr = NanoVis::flowVisRenderer->addVectorField(volPtr, 804 *(volPtr->get_location()), 1.0f, 805 volPtr->height / (float)volPtr->width, 806 volPtr->depth / (float)volPtr->width, 807 1.0f); 808 NanoVis::flowVisRenderer->activateVectorField(fieldPtr); 809 810 ////////////////////////////////// 811 // ADD Particle Injection Plane1 812 NanoVis::flowVisRenderer->addPlane(fieldPtr, plane_name1); 813 NanoVis::flowVisRenderer->setPlaneAxis(fieldPtr, plane_name1, 0); 814 NanoVis::flowVisRenderer->setPlanePos(fieldPtr, plane_name1, 0.9); 815 NanoVis::flowVisRenderer->setParticleColor(fieldPtr, plane_name1, 816 color1); 817 // ADD Particle Injection Plane2 818 NanoVis::flowVisRenderer->addPlane(fieldPtr, plane_name2); 819 NanoVis::flowVisRenderer->setPlaneAxis(fieldPtr, plane_name2, 0); 820 NanoVis::flowVisRenderer->setPlanePos(fieldPtr, plane_name2, 0.2); 821 NanoVis::flowVisRenderer->setParticleColor(fieldPtr, plane_name2, 822 color2); 823 NanoVis::flowVisRenderer->initialize(fieldPtr); 824 825 NanoVis::flowVisRenderer->activatePlane(fieldPtr, plane_name1); 826 NanoVis::flowVisRenderer->activatePlane(fieldPtr, plane_name2); 827 828 NanoVis::licRenderer->setVectorField(volPtr->id, 829 *(volPtr->get_location()), 830 1.0f / volPtr->aspect_ratio_width, 831 1.0f / volPtr->aspect_ratio_height, 832 1.0f / volPtr->aspect_ratio_depth, 833 volPtr->wAxis.max()); 834 } 835 } 836 const char *name; 837 name = Tcl_GetCommandName(interp, flowPtr->cmdToken); 838 Tcl_Obj *objPtr; 839 objPtr = Tcl_NewStringObj(name, -1); 840 Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); 841 } 842 Tcl_SetObjResult(interp, listObjPtr); 843 #endif 738 844 return TCL_OK; 739 845 } … … 860 966 Trace("FLOW started\n"); 861 967 862 Rappture::Outcome result;968 Rappture::Outcome context; 863 969 Rappture::AVTranslate movie(width, height, frameRate, bitRate); 864 970 … … 868 974 } 869 975 870 movie.init( result, fileName);976 movie.init(context, fileName); 871 977 872 978 for (int i = 0; i < numFrames; i++) { … … 888 994 // This is done before bmp_write_to_file because bmp_write_to_file 889 995 // turns rgb data to bgr 890 movie.append( result, NanoVis::screen_buffer, pad);996 movie.append(context, NanoVis::screen_buffer, pad); 891 997 // NanoVis::bmp_write_to_file(frame_count, fileName); 892 998 } 893 999 894 movie.done( result);1000 movie.done(context); 895 1001 Trace("FLOW end\n"); 896 1002 … … 905 1011 // FIXME: find a way to get the data from the movie object as a void* 906 1012 Rappture::Buffer data; 907 if (!data.load( result, fileName)) {1013 if (!data.load(context, fileName)) { 908 1014 Tcl_AppendResult(interp, "can't load data from temporary movie file \"", 909 fileName, "\": ", result.remark(), (char *)NULL);1015 fileName, "\": ", context.remark(), (char *)NULL); 910 1016 return TCL_ERROR; 911 1017 } … … 934 1040 {"add", 1, FlowAddOp, 2, 3, "?name? ?option value...?",}, 935 1041 {"delete", 1, FlowDeleteOp, 2, 0, "name...",}, 1042 {"init", 1, FlowInitOp, 2, 2, "",}, 936 1043 {"names", 1, FlowNamesOp, 2, 3, "?pattern?",}, 937 1044 {"next", 2, FlowNextOp, 2, 2, "",}, … … 980 1087 return TCL_OK; 981 1088 } 1089 1090 #ifdef notdef 1091 void 1092 MapFlowVectors(Tcl_Interp *interp) 1093 { 1094 double xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax; 1095 1096 if (debug_flag) { 1097 fprintf(stderr, "in SetHeightmapRanges\n"); 1098 } 1099 xMin = yMin = zMin = wMin = DBL_MAX; 1100 xMax = yMax = zMax = wMax = -DBL_MAX; 1101 Tcl_HashEntry *hPtr; 1102 Tcl_HashSearch iter; 1103 for (hPtr = Tcl_FirstHashEntry(&flowTable, &iter); hPtr != NULL; 1104 hPtr = Tcl_NextHashEntry(&iter)) { 1105 FlowCmd *flowPtr; 1106 flowPtr = (FlowCmd *)Tcl_GetHashValue(hPtr); 1107 1108 flowPtr-> 1109 1110 for (unsigned int i = 0; i < heightMap.size(); i++) { 1111 HeightMap *hmPtr; 1112 1113 hmPtr = heightMap[i]; 1114 if (hmPtr == NULL) { 1115 continue; 1116 } 1117 if (xMin > hmPtr->xAxis.min()) { 1118 xMin = hmPtr->xAxis.min(); 1119 } 1120 if (xMax < hmPtr->xAxis.max()) { 1121 xMax = hmPtr->xAxis.max(); 1122 } 1123 if (yMin > hmPtr->yAxis.min()) { 1124 yMin = hmPtr->yAxis.min(); 1125 } 1126 if (yMax < hmPtr->yAxis.max()) { 1127 yMax = hmPtr->yAxis.max(); 1128 } 1129 if (zMin > hmPtr->zAxis.min()) { 1130 zMin = hmPtr->zAxis.min(); 1131 } 1132 if (zMax < hmPtr->zAxis.max()) { 1133 zMax = hmPtr->zAxis.max(); 1134 } 1135 if (wMin > hmPtr->wAxis.min()) { 1136 wMin = hmPtr->wAxis.min(); 1137 } 1138 if (wMax < hmPtr->wAxis.max()) { 1139 wMax = hmPtr->wAxis.max(); 1140 } 1141 } 1142 if ((xMin < DBL_MAX) && (xMax > -DBL_MAX)) { 1143 grid->xAxis.SetScale(xMin, xMax); 1144 } 1145 if ((yMin < DBL_MAX) && (yMax > -DBL_MAX)) { 1146 grid->yAxis.SetScale(yMin, yMax); 1147 } 1148 if ((zMin < DBL_MAX) && (zMax > -DBL_MAX)) { 1149 grid->zAxis.SetScale(zMin, zMax); 1150 } 1151 if ((wMin < DBL_MAX) && (wMax > -DBL_MAX)) { 1152 HeightMap::valueMin = grid->yAxis.min(); 1153 HeightMap::valueMax = grid->yAxis.max(); 1154 } 1155 for (unsigned int i = 0; i < heightMap.size(); i++) { 1156 HeightMap *hmPtr; 1157 1158 hmPtr = heightMap[i]; 1159 if (hmPtr == NULL) { 1160 continue; 1161 } 1162 hmPtr->MapToGrid(grid); 1163 } 1164 HeightMap::update_pending = false; 1165 if (debug_flag) { 1166 fprintf(stderr, "leaving SetHeightmapRanges\n"); 1167 } 1168 } 1169 1170 Tcl_Obj *listObjPtr; 1171 listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **) NULL); 1172 1173 Tcl_HashEntry *hPtr; 1174 Tcl_HashSearch iter; 1175 for (hPtr = Tcl_FirstHashEntry(&flowTable, &iter); hPtr != NULL; 1176 hPtr = Tcl_NextHashEntry(&iter)) { 1177 FlowCmd *flowPtr; 1178 flowPtr = (FlowCmd *)Tcl_GetHashValue(hPtr); 1179 if (flowPtr->fieldPtr != NULL) { 1180 delete flowPtr->fieldPtr; // Remove the vector field. 1181 flowPtr->fieldPtr = NULL; 1182 } 1183 } 1184 1185 1186 Volume *volPtr; 1187 volPtr = NanoVis::load_volume(index, nx, ny, nz, 4, data, 1188 field.valueMin(), field.valueMax(), nzero_min); 1189 volPtr->xAxis.SetRange(field.rangeMin(Rappture::xaxis), 1190 field.rangeMax(Rappture::xaxis)); 1191 volPtr->yAxis.SetRange(field.rangeMin(Rappture::yaxis), 1192 field.rangeMax(Rappture::yaxis)); 1193 volPtr->zAxis.SetRange(field.rangeMin(Rappture::zaxis), 1194 field.rangeMax(Rappture::zaxis)); 1195 volPtr->wAxis.SetRange(field.valueMin(), field.valueMax()); 1196 volPtr->update_pending = true; 1197 delete [] data; 1198 #endif -
trunk/packages/vizservers/nanovis/LoadVector.cpp
r1374 r1380 10 10 #include "Nv.h" 11 11 #include "nanovis.h" 12 #include "FlowCmd.h" 12 13 13 14 static INLINE char * … … 36 37 return line; 37 38 } 39 38 40 bool 39 MakeVectorField(Rappture::Outcome &result,40 float xMin, float xMax, size_t xNum,41 float yMin, float yMax, size_t yNum,42 float zMin, float zMax, size_t zNum,43 size_t nValues, float *values)41 SetVectorFieldData(Rappture::Outcome &context, 42 float xMin, float xMax, size_t xNum, 43 float yMin, float yMax, size_t yNum, 44 float zMin, float zMax, size_t zNum, 45 size_t nValues, float *values, Unirect3d *dataPtr) 44 46 { 45 47 #ifdef notdef … … 95 97 } 96 98 } 97 98 Volume *volPtr; 99 int ivol = NanoVis::n_volumes; 100 volPtr = NanoVis::load_volume(ivol, xNum, yNum, zNum, 4, data, 101 min_mag, max_mag, 0); 102 volPtr->xAxis.SetRange(xMin, xMax); 103 volPtr->yAxis.SetRange(yMin, yMax); 104 volPtr->zAxis.SetRange(zMin, zMax); 105 volPtr->wAxis.SetRange(min_mag, max_mag); 106 volPtr->update_pending = true; 107 delete [] data; 99 dataPtr->xMin(xMin); 100 dataPtr->xMax(xMax); 101 dataPtr->xNum(xNum); 102 dataPtr->yMin(yMin); 103 dataPtr->yMax(yMax); 104 dataPtr->yNum(yNum); 105 dataPtr->yMin(zMin); 106 dataPtr->yMax(zMax); 107 dataPtr->yNum(zNum); 108 dataPtr->values(data); 109 dataPtr->minMag = min_mag; 110 dataPtr->maxMag = max_mag; 108 111 return true; 109 112 } 110 113 111 114 bool 112 MakeResampledVectorField(Rappture::Outcome &result,113 float xMin, float xMax, size_t xNum,114 float yMin, float yMax, size_t yNum,115 float zMin, float zMax, size_t zNum,116 size_t nValues, float *values)115 SetResampledVectorFieldData(Rappture::Outcome &context, 116 float xMin, float xMax, size_t xNum, 117 float yMin, float yMax, size_t yNum, 118 float zMin, float zMax, size_t zNum, 119 size_t nValues, float *values, FlowCmd *flowPtr) 117 120 { 118 121 Rappture::Mesh1D xgrid(xMin, xMax, xNum); … … 215 218 } 216 219 217 Volume *volPtr; 218 int ivol = NanoVis::n_volumes; 219 volPtr = NanoVis::load_volume(ivol, xNum, yNum, zNum, 4, data, 220 min_mag, max_mag, nzero_min); 221 volPtr->xAxis.SetRange(xMin, xMax); 222 volPtr->yAxis.SetRange(yMin, yMax); 223 volPtr->zAxis.SetRange(zMin, zMax); 224 volPtr->wAxis.SetRange(min_mag, max_mag); 225 volPtr->update_pending = true; 226 delete [] data; 220 flowPtr->xMin = xMin; 221 flowPtr->xMax = xMax; 222 flowPtr->xNum = xNum; 223 flowPtr->yMin = yMin; 224 flowPtr->yMax = yMax; 225 flowPtr->yNum = yNum; 226 flowPtr->yMin = zMin; 227 flowPtr->yMax = zMax; 228 flowPtr->yNum = zNum; 229 flowPtr->values = data; 230 flowPtr->minMag = min_mag; 231 flowPtr->maxMag = max_mag; 227 232 return true; 228 233 } 229 234 230 235 bool 231 MakeVectorFieldFromUnirect3d(Rappture::Outcome &result, 232 Rappture::Unirect3d &grid) 233 { 234 return MakeVectorField(result, 235 grid.xMin(), grid.xMax(), grid.xNum(), 236 grid.yMin(), grid.yMax(), grid.yNum(), 237 grid.zMin(), grid.zMax(), grid.zNum(), 238 grid.nValues(), grid.values()); 239 } 236 SetVectorFieldDataFromUnirect3d(Rappture::Outcome &context, 237 Rappture::Unirect3d &grid, FlowCmd *flowPtr) 238 { 239 flowPtr->dataPtr = gridPtr; 240 return SetVectorFieldData(context, 241 grid.xMin(), grid.xMax(), grid.xNum(), 242 grid.yMin(), grid.yMax(), grid.yNum(), 243 grid.zMin(), grid.zMax(), grid.zNum(), 244 grid.nValues(), grid.values(), flowPtr); 245 } 240 246 241 247 … … 245 251 */ 246 252 bool 247 load_vector_stream2(Rappture::Outcome &result, int ivol, size_t length, 248 char *string) 249 { 253 load_vector_stream2(Rappture::Outcome &context, size_t length, char *string, 254 Unirect3d *dataPtr) 255 { 256 Unirect3d data; 250 257 int nx, ny, nz, npts; 251 258 double x0, y0, z0, dx, dy, dz, ddx, ddy, ddz; … … 283 290 printf("point %d\n", npts); 284 291 if (npts != nx*ny*nz) { 285 result.addError("inconsistent data: expected %d points"292 context.addError("inconsistent data: expected %d points" 286 293 " but found %d points", nx*ny*nz, npts); 287 294 return false; … … 291 298 " times %d data follows", &npts) == 3) { 292 299 if (npts != nx*ny*nz) { 293 result.addError("inconsistent data: expected %d points"300 context.addError("inconsistent data: expected %d points" 294 301 " but found %d points", nx*ny*nz, npts); 295 302 return false; … … 353 360 // make sure that we read all of the expected points 354 361 if (nRead != nx*ny*nz) { 355 result.addError("inconsistent data: expected %d points"362 context.addError("inconsistent data: expected %d points" 356 363 " but found %d points", nx*ny*nz, npts); 357 364 return false; 358 365 } 359 366 bool status; 360 status = MakeVectorField(result, x0, x0 + nx, nx, y0, y0 + ny,ny,361 z0, z0 + ny, ny, nRead, srcData);367 status = SetVectorFieldData(context, x0, x0 + nx, nx, y0, y0 + ny, 368 ny, z0, z0 + ny, ny, nRead, srcData, flowPtr); 362 369 delete [] srcData; 363 370 return status; -
trunk/packages/vizservers/nanovis/Makefile.in
r1374 r1380 104 104 Event.o \ 105 105 Switch.o \ 106 FlowCmds.o \106 Unirect.o \ 107 107 GradientFilter.o \ 108 108 Grid.o \ 109 109 HeightMap.o \ 110 LoadVector.o \111 Unirect.o \112 110 Mat4x4.o \ 113 111 Nv.o \ -
trunk/packages/vizservers/nanovis/NvFlowVisRenderer.cpp
r1370 r1380 116 116 NvFlowVisRenderer::addVectorField(const std::string& vfName, Volume* volPtr, const Vector3& ori, float scaleX, float scaleY, float scaleZ, float max) 117 117 { 118 std::map<std::string, NvVectorField*>::iterator iter = _vectorFieldMap.find(vfName); 119 if (iter != _vectorFieldMap.end()) 120 { 121 if ((*iter).second) 122 { 123 ((*iter).second)->setVectorField(volPtr, ori, scaleX, scaleY, scaleZ, max); 124 } 125 else 126 { 127 NvVectorField* vf = new NvVectorField(); 128 _vectorFieldMap[vfName] = vf; 129 vf->setVectorField(volPtr, ori, scaleX, scaleY, scaleZ, max); 130 } 131 } 132 else 133 { 134 NvVectorField* vf = new NvVectorField(); 135 _vectorFieldMap[vfName] = vf; 136 vf->setVectorField(volPtr, ori, scaleX, scaleY, scaleZ, max); 137 138 } 118 std::map<std::string, NvVectorField*>::iterator iter = _vectorFieldMap.find(vfName); 119 if (iter != _vectorFieldMap.end()) { 120 if ((*iter).second) { 121 ((*iter).second)->setVectorField(volPtr, ori, scaleX, scaleY, scaleZ, max); 122 } else { 123 NvVectorField* vf = new NvVectorField(); 124 _vectorFieldMap[vfName] = vf; 125 vf->setVectorField(volPtr, ori, scaleX, scaleY, scaleZ, max); 126 } 127 } else { 128 NvVectorField* vf = new NvVectorField(); 129 _vectorFieldMap[vfName] = vf; 130 vf->setVectorField(volPtr, ori, scaleX, scaleY, scaleZ, max); 131 } 139 132 } 140 133 -
trunk/packages/vizservers/nanovis/NvParticleRenderer.cpp
r1370 r1380 30 30 NvParticleRenderer::NvParticleRenderer(int w, int h, CGcontext context) : 31 31 scale(1, 1, 1), 32 _activate(false),33 origin(0, 0, 0)32 origin(0, 0, 0), 33 _activate(false) 34 34 { 35 35 psys_width = w; -
trunk/packages/vizservers/nanovis/R2/src/R2FilePath.cpp
r1114 r1380 17 17 R2FilePath::R2FilePath() 18 18 { 19 char buff[ 255];19 char buff[BUFSIZ+2]; 20 20 #ifdef WIN32 21 21 _getcwd(buff, 255); 22 22 #else 23 getcwd(buff, 100); 23 if (getcwd(buff, BUFSIZ) == NULL) { 24 fprintf(stderr, "can't get current working directory\n"); 25 } 24 26 #endif 25 int length = strlen(buff);27 size_t length = strlen(buff); 26 28 buff[length] = '/'; 27 29 buff[length + 1] = '\0'; 28 29 30 _curDirectory = buff; 30 31 31 } 32 32 -
trunk/packages/vizservers/nanovis/Trace.cpp
r1204 r1380 15 15 vsnprintf(buff, 1023, format, lst); 16 16 buff[1023] = '\0'; 17 printf(buff);17 fprintf(stdout, "%s\n", buff); 18 18 fflush(stdout); 19 19 } -
trunk/packages/vizservers/nanovis/dxReader.cpp
r1374 r1380 156 156 } 157 157 line = getline(&p, endPtr); 158 if ((line == '#') || (line== '\0')) {158 if ((line[0] == '#') || (line[0] == '\0')) { 159 159 continue; // Skip blank or comment lines. 160 160 } -
trunk/packages/vizservers/nanovis/dxReader2.cpp
r1325 r1380 35 35 36 36 f = fopen(dxfilename, "w"); 37 fwrite(buf, sizeof(char), nBytes, f); 37 38 ssize_t nWritten; 39 nWritten = fwrite(buf, sizeof(char), nBytes, f); 38 40 fclose(f); 41 if (nWritten != nBytes) { 42 outcome.addError("Can't read %d bytes from file \"%s\"\n", 43 nBytes, dxfilename); 44 return false; 45 } 39 46 40 47 Rappture::DX dxObj(outcome, dxfilename); -
trunk/packages/vizservers/nanovis/imgLoaders/BMPImageLoaderImpl.cpp
r1196 r1380 29 29 30 30 char header[54]; 31 fread(&header, 54, 1, f); 31 if (fread(&header, 54, 1, f) != 1) { 32 printf("can't read header of BMP file\n"); 33 return 0; 34 }; 32 35 33 36 if (header[0] != 'B' || header[1] != 'M') { … … 66 69 fseek(f,offset,SEEK_SET); 67 70 if (_targetImageFormat == Image::IMG_RGB) { 68 fread(bytes,width*height*3,1,f); //24bit is easy 71 if (fread(bytes,width*height*3,1,f) != 1) { 72 fprintf(stderr, "can't read image data\n"); 73 } 69 74 for(x=0;x<width*height*3;x+=3) { //except the format is BGR, grr 70 75 unsigned char temp = bytes[x]; … … 74 79 } else if (_targetImageFormat == Image::IMG_RGBA) { 75 80 char* buff = (char*) malloc(width * height * sizeof(unsigned char) * 3); 76 fread(buff,width*height*3,1,f); //24bit is easy 81 if (fread(buff,width*height*3,1,f) != 1) { 82 fprintf(stderr, "can't read BMP image data\n"); 83 } 77 84 for(x=0, y = 0;x<width*height*3;x+=3, y+=4) { //except the format is BGR, grr 78 85 bytes[y] = buff[x+2]; … … 84 91 break; 85 92 case 8: 86 fread(cols,256 * 4,1,f); //read colortable 93 if (fread(cols,256 * 4,1,f) != 1) { 94 fprintf(stderr, "can't read colortable from BMP file\n"); 95 } 87 96 fseek(f,offset,SEEK_SET); 88 97 for(y=0;y<height;++y) { //(Notice 4bytes/col for some reason) 89 98 for(x=0;x<width;++x) { 90 99 unsigned char byte; 91 fread(&byte,1,1,f); //just read byte 100 if (fread(&byte,1,1,f) != 1) { 101 fprintf(stderr, "error reading BMP file\n"); 102 } 92 103 for(int c=0; c< 3; ++c) { 93 104 //bytes[(y*width+x)*3+c] = cols[byte*4+2-c]; //and look up in the table -
trunk/packages/vizservers/nanovis/nanovis.cpp
r1370 r1380 1805 1805 1806 1806 #ifdef NEW_FLOW_ENGINE 1807 void addVectorField(const char* filename, const char* vf_name, const char* plane_name1, const char* plane_name2, const Vector4& color1, const Vector4& color2) 1808 { 1809 Rappture::Outcome result; 1810 std::ifstream fdata; 1811 fdata.open(filename, std::ios::in); 1812 1813 int n = NanoVis::n_volumes; 1814 //fdata.write(buf.bytes(),buf.size()); 1815 if (load_vector_stream2(result, n, fdata)) { 1816 Volume *volPtr = NanoVis::volume[n]; 1817 if (volPtr != NULL) { 1818 volPtr->set_n_slice(256-n); 1819 // volPtr->set_n_slice(512-n); 1820 volPtr->disable_cutplane(0); 1821 volPtr->disable_cutplane(1); 1822 volPtr->disable_cutplane(2); 1823 1824 NanoVis::vol_renderer->add_volume(volPtr, 1825 NanoVis::get_transfunc("default")); 1826 float dx0 = -0.5; 1827 float dy0 = -0.5*volPtr->height/volPtr->width; 1828 float dz0 = -0.5*volPtr->depth/volPtr->width; 1829 volPtr->move(Vector3(dx0, dy0, dz0)); 1830 //volPtr->enable_data(); 1831 volPtr->disable_data(); 1832 NanoVis::flowVisRenderer->addVectorField(vf_name, volPtr, 1833 *(volPtr->get_location()), 1834 1.0f, 1835 volPtr->height / (float)volPtr->width, 1836 volPtr->depth / (float)volPtr->width, 1837 1.0f); 1838 NanoVis::flowVisRenderer->activateVectorField(vf_name); 1839 1840 ////////////////////////////////// 1841 // ADD Particle Injection Plane1 1842 NanoVis::flowVisRenderer->addPlane(vf_name, plane_name1); 1843 NanoVis::flowVisRenderer->setPlaneAxis(vf_name, plane_name1, 0); 1844 NanoVis::flowVisRenderer->setPlanePos(vf_name, plane_name1, 0.9); 1845 NanoVis::flowVisRenderer->setParticleColor(vf_name, plane_name1, color1); 1846 // ADD Particle Injection Plane2 1847 NanoVis::flowVisRenderer->addPlane(vf_name, plane_name2); 1848 NanoVis::flowVisRenderer->setPlaneAxis(vf_name, plane_name2, 0); 1849 NanoVis::flowVisRenderer->setPlanePos(vf_name, plane_name2, 0.2); 1850 NanoVis::flowVisRenderer->setParticleColor(vf_name, plane_name2, color2); 1851 NanoVis::flowVisRenderer->initialize(vf_name); 1852 1853 NanoVis::flowVisRenderer->activatePlane(vf_name, plane_name1); 1854 NanoVis::flowVisRenderer->activatePlane(vf_name, plane_name2); 1855 1856 NanoVis::licRenderer->setVectorField(volPtr->id, 1807 void addVectorField(const char* filename, const char* vf_name, 1808 const char* plane_name1, const char* plane_name2, 1809 const Vector4& color1, const Vector4& color2) 1810 { 1811 Rappture::Outcome result; 1812 std::ifstream fdata; 1813 fdata.open(filename, std::ios::in); 1814 1815 int n = NanoVis::n_volumes; 1816 //fdata.write(buf.bytes(),buf.size()); 1817 if (load_vector_stream2(result, n, fdata)) { 1818 Volume *volPtr = NanoVis::volume[n]; 1819 if (volPtr != NULL) { 1820 volPtr->set_n_slice(256-n); 1821 // volPtr->set_n_slice(512-n); 1822 volPtr->disable_cutplane(0); 1823 volPtr->disable_cutplane(1); 1824 volPtr->disable_cutplane(2); 1825 1826 NanoVis::vol_renderer->add_volume(volPtr, 1827 NanoVis::get_transfunc("default")); 1828 float dx0 = -0.5; 1829 float dy0 = -0.5*volPtr->height/volPtr->width; 1830 float dz0 = -0.5*volPtr->depth/volPtr->width; 1831 volPtr->move(Vector3(dx0, dy0, dz0)); 1832 //volPtr->enable_data(); 1833 volPtr->disable_data(); 1834 NanoVis::flowVisRenderer->addVectorField(vf_name, volPtr, 1835 *(volPtr->get_location()), 1836 1.0f, 1837 volPtr->height / (float)volPtr->width, 1838 volPtr->depth / (float)volPtr->width, 1839 1.0f); 1840 NanoVis::flowVisRenderer->activateVectorField(vf_name); 1841 1842 ////////////////////////////////// 1843 // ADD Particle Injection Plane1 1844 NanoVis::flowVisRenderer->addPlane(vf_name, plane_name1); 1845 NanoVis::flowVisRenderer->setPlaneAxis(vf_name, plane_name1, 0); 1846 NanoVis::flowVisRenderer->setPlanePos(vf_name, plane_name1, 0.9); 1847 NanoVis::flowVisRenderer->setParticleColor(vf_name, plane_name1, color1); 1848 // ADD Particle Injection Plane2 1849 NanoVis::flowVisRenderer->addPlane(vf_name, plane_name2); 1850 NanoVis::flowVisRenderer->setPlaneAxis(vf_name, plane_name2, 0); 1851 NanoVis::flowVisRenderer->setPlanePos(vf_name, plane_name2, 0.2); 1852 NanoVis::flowVisRenderer->setParticleColor(vf_name, plane_name2, color2); 1853 NanoVis::flowVisRenderer->initialize(vf_name); 1854 1855 NanoVis::flowVisRenderer->activatePlane(vf_name, plane_name1); 1856 NanoVis::flowVisRenderer->activatePlane(vf_name, plane_name2); 1857 1858 NanoVis::licRenderer->setVectorField(volPtr->id, 1857 1859 *(volPtr->get_location()), 1858 1860 1.0f / volPtr->aspect_ratio_width, … … 1860 1862 1.0f / volPtr->aspect_ratio_depth, 1861 1863 volPtr->wAxis.max()); 1862 }1863 1864 } 1864 //NanoVis::initParticle(); 1865 } 1866 //NanoVis::initParticle(); 1865 1867 } 1866 1868 #endif
Note: See TracChangeset
for help on using the changeset viewer.