Changeset 3935 for trunk/packages/vizservers/nanovis/FlowCmd.cpp
- Timestamp:
- Sep 18, 2013 2:51:50 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/FlowCmd.cpp
r3630 r3935 30 30 #include "Command.h" 31 31 #include "PPMWriter.h" 32 #ifdef USE_VTK 33 #include "VtkDataSetReader.h" 34 #endif 35 #include "VtkReader.h" 32 36 #include "FlowCmd.h" 33 37 #include "FlowTypes.h" … … 243 247 size_t length = buf.size(); 244 248 245 Rappture::Unirect3d * dataPtr;246 dataPtr = new Rappture::Unirect3d(nComponents);249 Rappture::Unirect3d *unirect = NULL; 250 Volume *volume = NULL; 247 251 248 252 Flow *flow = (Flow *)clientData; 249 253 if ((length > 4) && (strncmp(bytes, "<DX>", 4) == 0)) { 250 if (!dataPtr->importDx(result, nComponents, length - 4, bytes + 4)) { 254 unirect = new Rappture::Unirect3d(nComponents); 255 if (!unirect->importDx(result, nComponents, length - 4, bytes + 4)) { 251 256 Tcl_AppendResult(interp, result.remark(), (char *)NULL); 252 delete dataPtr;257 delete unirect; 253 258 return TCL_ERROR; 254 259 } 255 260 } else if ((length > 10) && (strncmp(bytes, "unirect3d ", 10) == 0)) { 256 if (dataPtr->parseBuffer(interp, buf) != TCL_OK) { 257 delete dataPtr; 261 unirect = new Rappture::Unirect3d(nComponents); 262 if (unirect->parseBuffer(interp, buf) != TCL_OK) { 263 delete unirect; 258 264 return TCL_ERROR; 259 265 } 260 266 } else if ((length > 10) && (strncmp(bytes, "unirect2d ", 10) == 0)) { 267 unirect = new Rappture::Unirect3d(nComponents); 261 268 Rappture::Unirect2d *u2dPtr; 262 269 u2dPtr = new Rappture::Unirect2d(nComponents); … … 265 272 return TCL_ERROR; 266 273 } 267 dataPtr->convert(u2dPtr);274 unirect->convert(u2dPtr); 268 275 delete u2dPtr; 269 #if 0270 276 } else if ((length > 14) && (strncmp(bytes, "# vtk DataFile", 14) == 0)) { 271 277 TRACE("VTK loading..."); … … 277 283 } 278 284 Rappture::Outcome context; 279 volume = load_vtk_volume_stream(context, tag, fdata); 285 #ifdef USE_VTK 286 volume = load_vtk_volume_stream(context, flow->name(), bytes, length); 287 #else 288 std::stringstream fdata; 289 fdata.write(bytes, nBytes); 290 volume = load_vtk_volume_stream(context, flow->name(), fdata); 291 #endif 280 292 if (volume == NULL) { 281 293 Tcl_AppendResult(interp, context.remark(), (char*)NULL); 282 294 return TCL_ERROR; 283 295 } 284 #endif285 296 } else { 286 297 TRACE("header is %.14s", buf.bytes()); 287 if (! dataPtr->importDx(result, nComponents, length, bytes)) {298 if (!unirect->importDx(result, nComponents, length, bytes)) { 288 299 Tcl_AppendResult(interp, result.remark(), (char *)NULL); 289 delete dataPtr;290 return TCL_ERROR; 291 } 292 } 293 if ( dataPtr->nValues() == 0) {294 delete dataPtr;300 delete unirect; 301 return TCL_ERROR; 302 } 303 } 304 if (unirect != NULL && unirect->nValues() == 0) { 305 delete unirect; 295 306 Tcl_AppendResult(interp, "no data found in stream", (char *)NULL); 296 307 return TCL_ERROR; 297 308 } 309 #if 0 298 310 TRACE("nx = %d ny = %d nz = %d", 299 dataPtr->xNum(), dataPtr->yNum(), dataPtr->zNum());311 unirect->xNum(), unirect->yNum(), unirect->zNum()); 300 312 TRACE("x0 = %lg y0 = %lg z0 = %lg", 301 dataPtr->xMin(), dataPtr->yMin(), dataPtr->zMin());313 unirect->xMin(), unirect->yMin(), unirect->zMin()); 302 314 TRACE("lx = %lg ly = %lg lz = %lg", 303 dataPtr->xMax() - dataPtr->xMin(),304 dataPtr->yMax() - dataPtr->yMin(),305 dataPtr->zMax() - dataPtr->zMin());315 unirect->xMax() - unirect->xMin(), 316 unirect->yMax() - unirect->yMin(), 317 unirect->zMax() - unirect->zMin()); 306 318 TRACE("dx = %lg dy = %lg dz = %lg", 307 dataPtr->xNum() > 1 ? (dataPtr->xMax() - dataPtr->xMin())/(dataPtr->xNum()-1) : 0,308 dataPtr->yNum() > 1 ? (dataPtr->yMax() - dataPtr->yMin())/(dataPtr->yNum()-1) : 0,309 dataPtr->zNum() > 1 ? (dataPtr->zMax() - dataPtr->zMin())/(dataPtr->zNum()-1) : 0);319 unirect->xNum() > 1 ? (unirect->xMax() - unirect->xMin())/(unirect->xNum()-1) : 0, 320 unirect->yNum() > 1 ? (unirect->yMax() - unirect->yMin())/(unirect->yNum()-1) : 0, 321 unirect->zNum() > 1 ? (unirect->zMax() - unirect->zMin())/(unirect->zNum()-1) : 0); 310 322 TRACE("magMin = %lg magMax = %lg", 311 dataPtr->magMin(), dataPtr->magMax()); 312 flow->data(dataPtr); 323 unirect->magMin(), unirect->magMax()); 324 #endif 325 if (unirect != NULL) { 326 flow->data(unirect); 327 } else { 328 flow->data(volume); 329 } 330 double range[2]; 331 flow->getVectorRange(range); 313 332 { 314 333 char info[1024]; 315 334 int length = 316 335 sprintf(info, "nv>data tag %s min %g max %g\n", 317 flow->name(), dataPtr->magMin(), dataPtr->magMax());336 flow->name(), range[0], range[1]); 318 337 #ifdef USE_THREADS 319 338 queueResponse(info, (size_t)length, Response::VOLATILE); … … 840 859 } 841 860 if (Flow::updatePending) { 842 NanoVis:: mapFlows();861 NanoVis::setFlowRanges(); 843 862 } 844 863 NanoVis::renderLegend(tf, Flow::magMin, Flow::magMax, w, h, label); … … 965 984 NanoVis::resetFlows(); 966 985 if (Flow::updatePending) { 967 NanoVis:: mapFlows();986 NanoVis::setFlowRanges(); 968 987 } 969 988 for (int i = 0; i < nSteps; i++) { … … 997 1016 assert(NanoVis::licRenderer != NULL); 998 1017 if (Flow::updatePending) { 999 NanoVis:: mapFlows();1018 NanoVis::setFlowRanges(); 1000 1019 } 1001 1020 NanoVis::licRenderer->convolve();
Note: See TracChangeset
for help on using the changeset viewer.