Changeset 860 for trunk/vizservers
- Timestamp:
- Jan 29, 2008, 1:06:07 PM (17 years ago)
- Location:
- trunk/vizservers/nanovis
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/vizservers/nanovis/Command.cpp
r851 r860 82 82 int n_component, float* data, double vmin, double vmax, 83 83 double nzero_min); 84 extern void load_vector_stream(int index, std::istream& fin); 84 85 85 86 // Tcl interpreter for incoming messages … … 128 129 static Tcl_CmdProc UpCmd; 129 130 static Tcl_CmdProc VolumeCmd; 131 static Tcl_CmdProc FlowCmd; 130 132 131 133 static int GetVolumeIndices(Tcl_Interp *interp, int argc, const char *argv[], … … 226 228 return TCL_ERROR; 227 229 } 230 231 /* 232 Trace("Camera pos(%f %f %f), rot(%f %f %f), aim(%f %f %f)\n", 233 NanoVis::cam->location.x, NanoVis::cam->location.y, NanoVis::cam->location.z, 234 NanoVis::cam->angle.x, NanoVis::cam->angle.y, NanoVis::cam->angle.z, 235 NanoVis::cam->target.x, NanoVis::cam->target.y, NanoVis::cam->target.z); 236 237 NanoVis::cam->aim(0, 0, 100); 238 NanoVis::cam->rotate(-51.868206, 88.637497, 0.000000); 239 NanoVis::cam->move(-0.000000, -0.000000, -0.819200); 240 */ 241 228 242 return TCL_OK; 229 243 } … … 1081 1095 } 1082 1096 1097 static int getDataStream(int nbytes, Rappture::Buffer* buf) 1098 { 1099 Rappture::Outcome err; 1100 1101 char buffer[8096]; 1102 while (nbytes > 0) { 1103 unsigned int chunk; 1104 int status; 1105 1106 chunk = (sizeof(buffer) < (unsigned int) nbytes) ? sizeof(buffer) : nbytes; 1107 status = fread(buffer, 1, chunk, stdin); 1108 if (status > 0) { 1109 buf->append(buffer,status); 1110 nbytes -= status; 1111 } else { 1112 printf("data unpacking failed\n"); 1113 Tcl_AppendResult(interp, "data unpacking failed: unexpected EOF", 1114 (char*)NULL); 1115 return TCL_ERROR; 1116 } 1117 } 1118 1119 err = Rappture::encoding::decode(*buf,RPENC_Z|RPENC_B64|RPENC_HDR); 1120 if (err) { 1121 printf("ERROR -- DECODING\n"); 1122 fflush(stdout); 1123 Tcl_AppendResult(interp, err.remark().c_str(), (char*)NULL); 1124 return TCL_ERROR; 1125 } 1126 } 1127 1128 static int 1129 FlowCmd(ClientData cdata, Tcl_Interp *interp, int argc, const char *argv[]) 1130 { 1131 Rappture::Outcome err; 1132 1133 char c = argv[1][0]; 1134 if ((c == 'v') && (strcmp(argv[1], "vectorid") == 0)) 1135 { 1136 int n = 0; 1137 if (Tcl_GetInt(interp, argv[2], &n) != TCL_OK) { 1138 return TCL_ERROR; 1139 } 1140 1141 if (NanoVis::particleRenderer) 1142 { 1143 1144 NanoVis::particleRenderer->setVectorField( 1145 NanoVis::volume[n]->id, 1146 1.0f, 1147 NanoVis::volume[n]->height / (float) NanoVis::volume[n]->width, 1148 NanoVis::volume[n]->depth / (float) NanoVis::volume[n]->width, 1149 NanoVis::volume[n]->range_max()); 1150 1151 NanoVis::initParticle(); 1152 1153 } 1154 1155 if (NanoVis::licRenderer) 1156 { 1157 NanoVis::licRenderer->setVectorField( 1158 NanoVis::volume[n]->id, 1159 1.0f/NanoVis::volume[n]->aspect_ratio_width, 1160 1.0f/NanoVis::volume[n]->aspect_ratio_height, 1161 1.0f/NanoVis::volume[n]->aspect_ratio_depth, 1162 NanoVis::volume[n]->range_max()); 1163 NanoVis::licRenderer->set_offset(NanoVis::lic_slice_z); 1164 } 1165 } 1166 else if (c == 'l' && strcmp(argv[1],"lic") == 0) 1167 { 1168 if (argc < 3) { 1169 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1170 argv[1], " on|off \"", (char*)NULL); 1171 return TCL_ERROR; 1172 } 1173 1174 char ch = argv[2][0]; 1175 if (ch == 'o' && strcmp(argv[2],"on") == 0) 1176 { 1177 NanoVis::lic_on = true; 1178 } 1179 else if (ch == 'o' && strcmp(argv[2],"off") == 0) 1180 { 1181 NanoVis::lic_on = false; 1182 } 1183 else 1184 { 1185 return TCL_ERROR; 1186 } 1187 } 1188 else if (c == 'p' && strcmp(argv[1],"particle") == 0) 1189 { 1190 if (argc < 4) { 1191 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1192 argv[1], " more parameters \"", (char*)NULL); 1193 return TCL_ERROR; 1194 } 1195 1196 char ch = argv[2][0]; 1197 if (ch == 'v' && strcmp(argv[2],"visible") == 0) 1198 { 1199 int state; 1200 if (Tcl_GetBoolean(interp, argv[2], &state) != TCL_OK) 1201 { 1202 return TCL_ERROR; 1203 } 1204 NanoVis::particle_on = state; 1205 } 1206 else if (ch == 's' && strcmp(argv[2],"slice") == 0) 1207 { 1208 if (argv[3][0] == 'x') 1209 { 1210 NanoVis::lic_axis = 0; 1211 } 1212 else if (argv[3][0] == 'y') 1213 { 1214 NanoVis::lic_axis = 1; 1215 } 1216 else if (argv[3][0] == 'z') 1217 { 1218 NanoVis::lic_axis = 2; 1219 } 1220 else 1221 { 1222 // TBD.. put error message 1223 return TCL_ERROR; 1224 } 1225 1226 } 1227 else if (ch == 's' && strcmp(argv[2],"slicepos") == 0) 1228 { 1229 float pos; 1230 if (GetFloat(interp, argv[2], &pos) != TCL_OK) 1231 { 1232 return TCL_ERROR; 1233 } 1234 1235 if (pos < 0.0f) pos = 0.0f; 1236 if (pos > 1.0f) pos = 1.0f; 1237 1238 switch (NanoVis::lic_axis) 1239 { 1240 case 0 : 1241 NanoVis::lic_slice_x = pos; 1242 break; 1243 case 1 : 1244 NanoVis::lic_slice_y = pos; 1245 break; 1246 case 2 : 1247 NanoVis::lic_slice_z = pos; 1248 break; 1249 } 1250 } 1251 else 1252 { 1253 return TCL_ERROR; 1254 } 1255 } 1256 else if (c == 'r' && strcmp(argv[1],"reset") == 0) 1257 { 1258 NanoVis::initParticle(); 1259 } 1260 else if (c == 'c' && strcmp(argv[1],"capture") == 0) 1261 { 1262 int frame_count; 1263 if (Tcl_GetInt(interp, argv[2], &frame_count) != TCL_OK) 1264 { 1265 return TCL_ERROR; 1266 } 1267 1268 if (NanoVis::licRenderer) NanoVis::licRenderer->activate(); 1269 if (NanoVis::particleRenderer) NanoVis::particleRenderer->activate(); 1270 1271 // Karl 1272 // pur your code .. 1273 1274 if (NanoVis::licRenderer) NanoVis::licRenderer->deactivate(); 1275 if (NanoVis::particleRenderer) NanoVis::particleRenderer->deactivate(); 1276 NanoVis::initParticle(); 1277 } 1278 else if (c == 'd' && strcmp(argv[1],"data") == 0) 1279 { 1280 char ch = argv[2][0]; 1281 if (ch == 'f' && strcmp(argv[2],"follows") == 0) { 1282 int nbytes; 1283 if (Tcl_GetInt(interp, argv[3], &nbytes) != TCL_OK) 1284 { 1285 return TCL_ERROR; 1286 } 1287 1288 Rappture::Buffer buf; 1289 if (getDataStream(nbytes, &buf) != TCL_OK) 1290 { 1291 /// TBD.. 1292 //Tcl_AppendResult(interp, err.remark().c_str(), (char*)NULL); 1293 return TCL_ERROR; 1294 } 1295 1296 int n = NanoVis::n_volumes; 1297 std::stringstream fdata; 1298 fdata.write(buf.bytes(),buf.size()); 1299 load_vector_stream(n, fdata); 1300 1301 // 1302 // BE CAREFUL: Set the number of slices to something 1303 // slightly different for each volume. If we have 1304 // identical volumes at exactly the same position 1305 // with exactly the same number of slices, the second 1306 // volume will overwrite the first, so the first won't 1307 // appear at all. 1308 // 1309 if (NanoVis::volume[n] != NULL) 1310 { 1311 NanoVis::volume[n]->set_n_slice(256-n); 1312 NanoVis::volume[n]->disable_cutplane(0); 1313 NanoVis::volume[n]->disable_cutplane(1); 1314 NanoVis::volume[n]->disable_cutplane(2); 1315 1316 NanoVis::vol_renderer->add_volume(NanoVis::volume[n],NanoVis::get_transfunc("default")); 1317 } 1318 } 1319 } 1320 else 1321 { 1322 return TCL_ERROR; 1323 } 1324 1325 return TCL_OK; 1326 } 1327 1083 1328 static int 1084 1329 HeightMapCmd(ClientData cdata, Tcl_Interp *interp, int argc, … … 1087 1332 if (argc < 2) { 1088 1333 srand((unsigned)time(NULL)); 1089 int size = 20 * 20 ;1334 int size = 20 * 200; 1090 1335 double sigma = 5.0; 1091 1336 double mean = exp(0.0) / (sigma * sqrt(2.0)); … … 1096 1341 x = - 10 + i%20; 1097 1342 data[i] = exp(- (x * x)/(2 * sigma * sigma)) / 1098 (sigma * sqrt(2.0)) / mean * 2 ;1343 (sigma * sqrt(2.0)) / mean * 2 + 1000; 1099 1344 } 1100 1345 … … 1104 1349 float miny = 0.5f; 1105 1350 float maxy = 3.5f; 1106 heightMap->setHeight(minx, miny, maxx, maxy, 20, 20 , data);1351 heightMap->setHeight(minx, miny, maxx, maxy, 20, 200, data); 1107 1352 heightMap->setColorMap(NanoVis::get_transfunc("default")); 1108 1353 heightMap->setVisible(true); … … 1771 2016 // manipulate volume data 1772 2017 Tcl_CreateCommand(interp, "volume", VolumeCmd, 2018 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); 2019 2020 Tcl_CreateCommand(interp, "flow", FlowCmd, 2021 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); 2022 2023 Tcl_CreateCommand(interp, "axis", AxisCmd, 2024 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); 2025 2026 Tcl_CreateCommand(interp, "grid", GridCmd, 2027 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); 2028 2029 Tcl_CreateCommand(interp, "heightmap", HeightMapCmd, 2030 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); 2031 2032 // get screenshot 2033 Tcl_CreateCommand(interp, "screenshot", ScreenShotCmd, 2034 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); 2035 2036 Tcl_CreateCommand(interp, "unirect2d", UniRect2dCmd, 1773 2037 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); 1774 2038 -
trunk/vizservers/nanovis/nanovis.cpp
r854 r860 78 78 Camera* NanoVis::cam = NULL; 79 79 bool NanoVis::axis_on = true; 80 //bool NanoVis::axis_on = false; 80 81 int NanoVis::win_width = NPIX; //size of the render window 81 82 int NanoVis::win_height = NPIX; //size of the render window … … 93 94 NvLIC* NanoVis::licRenderer = 0; 94 95 96 bool NanoVis::lic_on = false; 97 bool NanoVis::particle_on = false; 98 bool NanoVis::vector_on = false; 99 95 100 // pointers to volumes, currently handle up to 10 volumes 96 101 /*FIXME: Is the above comment true? Is there a 10 volume limit */ … … 176 181 float NanoVis::lic_slice_y = 0.0f; 177 182 float NanoVis::lic_slice_z = 0.5f; 183 int NanoVis::lic_axis = 2; 178 184 179 185 /* -
trunk/vizservers/nanovis/nanovis.h
r851 r860 127 127 static float lic_slice_y; 128 128 static float lic_slice_z; 129 static int lic_axis; /* 0:x, 1:y, 2:z */ 129 130 130 131 static bool axis_on; … … 132 133 static int win_width; //size of the render window 133 134 static int win_height; //size of the render window 135 136 137 static bool lic_on; 138 static bool particle_on; 139 static bool vector_on; 134 140 135 141 static TransferFunction* get_transfunc(const char *name);
Note: See TracChangeset
for help on using the changeset viewer.