Changeset 3935
- Timestamp:
- Sep 18, 2013 2:51:50 AM (10 years ago)
- Location:
- trunk/packages/vizservers/nanovis
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/Doxyfile.in
r3597 r3935 599 599 # subdirectory from a directory tree whose root is specified with the INPUT tag. 600 600 601 EXCLUDE = @srcdir@/ newmat11 @srcdir@/CircularQueue.h @srcdir@/ParticleEmitter.h @srcdir@/ParticleEmitter.cpp @srcdir@/ParticleSystem.h @srcdir@/ParticleSystem.cpp @srcdir@/ParticleSystemFactory.h @srcdir@/ParticleSystemFactory.cpp @srcdir@/BucketSort.h @srcdir@/BucketSort.cpp @srcdir@/PCASplit.h @srcdir@/PCASplit.cpp @srcdir@/PointSet.h @srcdir@/PointSet.cpp @srcdir@/PointSetRenderer.h @srcdir@/PointSetRenderer.cpp @srcdir@/PointShader.h @srcdir@/PointShader.cpp601 EXCLUDE = @srcdir@/bak @srcdir@/newmat11 @srcdir@/CircularQueue.h @srcdir@/ParticleEmitter.h @srcdir@/ParticleEmitter.cpp @srcdir@/ParticleSystem.h @srcdir@/ParticleSystem.cpp @srcdir@/ParticleSystemFactory.h @srcdir@/ParticleSystemFactory.cpp @srcdir@/BucketSort.h @srcdir@/BucketSort.cpp @srcdir@/PCASplit.h @srcdir@/PCASplit.cpp @srcdir@/PointSet.h @srcdir@/PointSet.cpp @srcdir@/PointSetRenderer.h @srcdir@/PointSetRenderer.cpp @srcdir@/PointShader.h @srcdir@/PointShader.cpp 602 602 603 603 # The EXCLUDE_SYMLINKS tag can be used select whether or not files or -
trunk/packages/vizservers/nanovis/Flow.cpp
r3630 r3935 41 41 _interp(interp), 42 42 _name(name), 43 _data(NULL),44 43 _volume(NULL) 45 44 { … … 59 58 Rappture::FreeSwitches(_switches, &_sv, 0); 60 59 61 if (_data != NULL) {62 delete _data;63 }64 60 if (_volume != NULL) { 65 61 NanoVis::removeVolume(_volume); … … 91 87 if (isDataLoaded()) { 92 88 BBox bbox; 93 data()->getBounds(bbox.min, bbox.max);89 _volume->getBounds(bbox.min, bbox.max); 94 90 allBounds.extend(bbox); 95 91 } … … 115 111 switch (position->axis) { 116 112 case AXIS_X: 117 return (position->value - _ data->xMin()) /118 (_ data->xMax() - _data->xMin());113 return (position->value - _volume->xAxis.min()) / 114 (_volume->xAxis.max() - _volume->xAxis.min()); 119 115 case AXIS_Y: 120 return (position->value - _ data->yMin()) /121 (_ data->yMax() - _data->yMin());116 return (position->value - _volume->yAxis.min()) / 117 (_volume->yAxis.max() - _volume->yAxis.min()); 122 118 case AXIS_Z: 123 return (position->value - _ data->zMin()) /124 (_ data->zMax() - _data->zMin());119 return (position->value - _volume->zAxis.min()) / 120 (_volume->zAxis.max() - _volume->zAxis.min()); 125 121 } 126 122 return 0.0; … … 303 299 Flow::scaleVectorField() 304 300 { 305 float *vdata = getScaledVector(); 306 if (_volume != NULL) { 307 TRACE("Updating existing volume: %s", _volume->name()); 308 _volume->setData(vdata, magMin, magMax, 0); 309 } else { 310 _volume = makeVolume(vdata); 311 if (_volume == NULL) { 312 return false; 313 } 314 } 315 delete [] vdata; 301 if (_volume == NULL) { 302 return false; 303 } 304 316 305 // FIXME: LIC and arrows should be per-flow 317 306 if (NanoVis::licRenderer != NULL) { … … 346 335 347 336 float * 348 Flow::getScaledVector( )349 { 350 assert( _data->nComponents() == 3);351 size_t n = _data->nValues() / _data->nComponents() * 4;337 Flow::getScaledVector(Rappture::Unirect3d *unirect) 338 { 339 assert(unirect->nComponents() == 3); 340 size_t n = unirect->nValues() / unirect->nComponents() * 4; 352 341 float *data = new float[n]; 353 342 memset(data, 0, sizeof(float) * n); 354 343 float *dest = data; 355 const float *values = _data->values();356 for (size_t iz = 0; iz < _data->zNum(); iz++) {357 for (size_t iy = 0; iy < _data->yNum(); iy++) {358 for (size_t ix = 0; ix < _data->xNum(); ix++) {344 const float *values = unirect->values(); 345 for (size_t iz = 0; iz < unirect->zNum(); iz++) { 346 for (size_t iy = 0; iy < unirect->yNum(); iy++) { 347 for (size_t ix = 0; ix < unirect->xNum(); ix++) { 359 348 double vx, vy, vz, vm; 360 349 vx = values[0]; … … 362 351 vz = values[2]; 363 352 vm = sqrt(vx*vx + vy*vy + vz*vz); 364 dest[0] = vm / magMax;365 dest[1] = vx /(2.0 * magMax) + 0.5;366 dest[2] = vy /(2.0 * magMax) + 0.5;367 dest[3] = vz /(2.0 * magMax) + 0.5;353 dest[0] = vm / unirect->magMax(); 354 dest[1] = vx /(2.0 * unirect->magMax()) + 0.5; 355 dest[2] = vy /(2.0 * unirect->magMax()) + 0.5; 356 dest[3] = vz /(2.0 * unirect->magMax()) + 0.5; 368 357 values += 3; 369 358 dest += 4; … … 375 364 376 365 Volume * 377 Flow::makeVolume( float *data)366 Flow::makeVolume(Rappture::Unirect3d *unirect, float *data) 378 367 { 379 368 Volume *volume = 380 369 NanoVis::loadVolume(_name.c_str(), 381 _data->xNum(),382 _data->yNum(),383 _data->zNum(),370 unirect->xNum(), 371 unirect->yNum(), 372 unirect->zNum(), 384 373 4, data, 385 magMin, magMax, 0); 386 volume->xAxis.setRange(_data->xMin(), _data->xMax()); 387 volume->yAxis.setRange(_data->yMin(), _data->yMax()); 388 volume->zAxis.setRange(_data->zMin(), _data->zMax()); 389 390 TRACE("mag=%g %g", magMin, magMax); 391 392 volume->disableCutplane(0); 393 volume->disableCutplane(1); 394 volume->disableCutplane(2); 374 unirect->magMin(), 375 unirect->magMax(), 376 0); 377 volume->xAxis.setRange(unirect->xMin(), unirect->xMax()); 378 volume->yAxis.setRange(unirect->yMin(), unirect->yMax()); 379 volume->zAxis.setRange(unirect->zMin(), unirect->zMax()); 380 381 TRACE("mag=%g %g", unirect->magMin(), unirect->magMax()); 382 383 return volume; 384 } 385 386 void 387 Flow::initVolume() 388 { 389 _volume->disableCutplane(0); 390 _volume->disableCutplane(1); 391 _volume->disableCutplane(2); 395 392 396 393 /* Initialize the volume with the previously configured values. */ 397 volume->transferFunction(_sv.transferFunction);398 volume->dataEnabled(_sv.showVolume);399 volume->twoSidedLighting(_sv.twoSidedLighting);400 volume->outline(_sv.showOutline);401 volume->opacityScale(_sv.opacity);402 volume->ambient(_sv.ambient);403 volume->diffuse(_sv.diffuse);404 volume->specularLevel(_sv.specular);405 volume->specularExponent(_sv.specularExp);394 _volume->transferFunction(_sv.transferFunction); 395 _volume->dataEnabled(_sv.showVolume); 396 _volume->twoSidedLighting(_sv.twoSidedLighting); 397 _volume->outline(_sv.showOutline); 398 _volume->opacityScale(_sv.opacity); 399 _volume->ambient(_sv.ambient); 400 _volume->diffuse(_sv.diffuse); 401 _volume->specularLevel(_sv.specular); 402 _volume->specularExponent(_sv.specularExp); 406 403 407 404 Volume::updatePending = true; 408 return volume; 409 } 405 } -
trunk/packages/vizservers/nanovis/Flow.h
r3630 r3935 83 83 void getBoxNames(std::vector<std::string>& names); 84 84 85 bool scaleVectorField();86 87 85 bool visible() 88 86 { … … 97 95 bool isDataLoaded() 98 96 { 99 return (_data != NULL); 100 } 101 102 Rappture::Unirect3d *data() 103 { 104 return _data; 105 } 106 107 void data(Rappture::Unirect3d *data) 108 { 109 if (_data != NULL) { 110 delete _data; 111 } 112 _data = data; 97 return (_volume != NULL); 98 } 99 100 void getVectorRange(double range[]) 101 { 102 range[0] = _volume->wAxis.min(); 103 range[1] = _volume->wAxis.max(); 104 } 105 106 void data(Rappture::Unirect3d *unirect) 107 { 108 float *vdata = getScaledVector(unirect); 109 _volume = makeVolume(unirect, vdata); 110 delete [] vdata; 111 initVolume(); 112 scaleVectorField(); 113 delete unirect; 114 } 115 116 void data(Volume *volume) 117 { 118 _volume = volume; 119 initVolume(); 120 scaleVectorField(); 113 121 } 114 122 … … 198 206 typedef std::tr1::unordered_map<BoxId, FlowBox *> BoxHashmap; 199 207 200 float *getScaledVector(); 201 202 Volume *makeVolume(float *data); 208 void initVolume(); 209 210 bool scaleVectorField(); 211 212 float *getScaledVector(Rappture::Unirect3d *unirect); 213 214 Volume *makeVolume(Rappture::Unirect3d *unirect, float *data); 203 215 204 216 void renderBoxes(); … … 219 231 220 232 /** 221 * Uniform rectangular data222 * representing the mesh and vector223 * field values. These values are224 * kept to regenerate the volume225 * associated with the flow. */226 Rappture::Unirect3d *_data;227 228 /**229 233 * The volume associated with the 230 234 * flow. This isn't the same thing as -
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(); -
trunk/packages/vizservers/nanovis/Grid.cpp
r3916 r3935 20 20 21 21 #define NUMDIGITS 6 22 #define GRID_TICK 0.05 22 #define TICK_LENGTH 0.05 23 #define LABEL_OFFSET 0.06 24 #define TITLE_OFFSET 0.2 23 25 24 26 Grid::Grid() : … … 55 57 glEnable(GL_DEPTH_TEST); 56 58 glDisable(GL_TEXTURE_2D); 59 #ifdef notdef 57 60 glEnable(GL_BLEND); 58 #ifdef notdef59 61 glEnable(GL_LINE_SMOOTH); 62 #else 63 glDisable(GL_BLEND); 60 64 #endif 61 65 … … 73 77 { 74 78 glVertex3f(0.0f, 0.0f, 0.0f); 75 glVertex3f(1.0f + GRID_TICK, 0.0f, 0.0f);79 glVertex3f(1.0f + TICK_LENGTH/xAxis.range(), 0.0f, 0.0f); 76 80 glVertex3f(0.0f, 0.0f, 0.0f); 77 glVertex3f(0.0f, 1.0f + GRID_TICK, 0.0f);81 glVertex3f(0.0f, 1.0f + TICK_LENGTH/yAxis.range(), 0.0f); 78 82 glVertex3f(0.0f, 0.0f, 0.0f); 79 glVertex3f(0.0f, 0.0f, 1.0f + GRID_TICK);83 glVertex3f(0.0f, 0.0f, 1.0f + TICK_LENGTH/zAxis.range()); 80 84 } 81 85 glEnd(); … … 96 100 glVertex3f(x, 1.0f, 0.0f); 97 101 glVertex3f(x, 0.0f, 0.0f); 98 glVertex3f(x, 0.0f, 1.0f + GRID_TICK);102 glVertex3f(x, 0.0f, 1.0f + TICK_LENGTH/zAxis.range()); 99 103 } 100 104 for (result = yAxis.firstMajor(iter); result; result = iter.next()) { … … 102 106 y = yAxis.map(iter.getValue()); 103 107 glVertex3f(0.0f, y, 0.0f); 104 glVertex3f(1.0f + GRID_TICK, y, 0.0f);108 glVertex3f(1.0f + TICK_LENGTH/xAxis.range(), y, 0.0f); 105 109 glVertex3f(0.0f, y, 0.0f); 106 110 glVertex3f(0.0f, y, 1.0f); … … 112 116 glVertex3f(0.0f, 1.0f, z); 113 117 glVertex3f(0.0f, 0.0f, z); 114 glVertex3f(1.0f + GRID_TICK, 0.0f, z);118 glVertex3f(1.0f + TICK_LENGTH/xAxis.range(), 0.0f, z); 115 119 } 116 120 } … … 163 167 glGetDoublev(GL_PROJECTION_MATRIX, prjm); 164 168 glGetIntegerv(GL_VIEWPORT, viewport); 165 169 166 170 _font->begin(); 167 if (gluProject(1. 2, 0.0, 0.0, mv, prjm, viewport, &wx, &wy, &wz) &&171 if (gluProject(1.0 + TITLE_OFFSET/xAxis.range(), 0.0, 0.0, mv, prjm, viewport, &wx, &wy, &wz) && 168 172 wz >= 0.0 && wz <= 1.0) { 169 173 glLoadIdentity(); … … 176 180 } 177 181 178 if (gluProject(0.0, 1. 2, 0.0, mv, prjm, viewport, &wx, &wy, &wz) &&182 if (gluProject(0.0, 1.0 + TITLE_OFFSET/yAxis.range(), 0.0, mv, prjm, viewport, &wx, &wy, &wz) && 179 183 wz >= 0.0 && wz <= 1.0) { 180 184 glLoadIdentity(); … … 187 191 } 188 192 189 if (gluProject(0.0, 0.0, 1. 2, mv, prjm, viewport, &wx, &wy, &wz) &&193 if (gluProject(0.0, 0.0, 1.0 + TITLE_OFFSET/zAxis.range(), mv, prjm, viewport, &wx, &wy, &wz) && 190 194 wz >= 0.0 && wz <= 1.0) { 191 195 glLoadIdentity(); … … 203 207 float x; 204 208 x = xAxis.map(iter.getValue()); 205 if (gluProject(x, 0.0f, 1.0 6f, mv, prjm, viewport, &wx, &wy, &wz) &&209 if (gluProject(x, 0.0f, 1.0 + LABEL_OFFSET/zAxis.range(), mv, prjm, viewport, &wx, &wy, &wz) && 206 210 wz >= 0.0 && wz <= 1.0) { 207 211 char buff[20]; … … 215 219 float y; 216 220 y = yAxis.map(iter.getValue()); 217 if (gluProject(1.0 6f, y, 0.0f, mv, prjm, viewport, &wx, &wy, &wz) &&221 if (gluProject(1.0 + LABEL_OFFSET/xAxis.range(), y, 0.0f, mv, prjm, viewport, &wx, &wy, &wz) && 218 222 wz >= 0.0 && wz <= 1.0) { 219 223 char buff[20]; … … 224 228 } 225 229 } 226 for (result = zAxis.firstMajor(iter) ; result; result = iter.next()) {230 for (result = zAxis.firstMajor(iter) + LABEL_OFFSET/xAxis.range(); result; result = iter.next()) { 227 231 float z; 228 232 z = zAxis.map(iter.getValue()); 229 if (gluProject(1.0 6f, 0.0f, z, mv, prjm, viewport, &wx, &wy, &wz) &&233 if (gluProject(1.0 + LABEL_OFFSET/xAxis.range(), 0.0f, z, mv, prjm, viewport, &wx, &wy, &wz) && 230 234 wz >= 0.0 && wz <= 1.0) { 231 235 char buff[20]; -
trunk/packages/vizservers/nanovis/ReaderCommon.cpp
r3611 r3935 64 64 65 65 /** 66 * \brief Normalize data to [0,1] based on vmin,vmax range 67 * 68 * Data outside of given range is clamped, and NaNs are set to 69 * -1 in the output 70 * 71 * \param data Float array of unnormalized data, will be normalized on return 72 * \param count Number of elts in array 73 * \param stride Stride between values in data array 74 * \param vmin Minimum value in data array 75 * \param vmax Maximum value in data array 76 */ 77 void 78 nv::normalizeVector(float *data, int count, double vmin, double vmax) 79 { 80 for (int p = 0; p < count; p++) { 81 int i = p * 4; 82 data[i ] = data[i]/vmax; 83 data[i+1] = data[i+1]/(2.0 * vmax) + 0.5; 84 data[i+2] = data[i+2]/(2.0 * vmax) + 0.5; 85 data[i+3] = data[i+3]/(2.0 * vmax) + 0.5; 86 } 87 } 88 89 /** 66 90 * \brief Compute Sobel filtered gradients for a 3D volume 67 91 * -
trunk/packages/vizservers/nanovis/ReaderCommon.h
r3613 r3935 15 15 normalizeScalar(float *data, int count, int stride, double min, double max); 16 16 17 extern void 18 normalizeVector(float *data, int count, double min, double max); 19 17 20 extern float * 18 21 computeGradient(float *data, -
trunk/packages/vizservers/nanovis/Unirect.cpp
r3611 r3935 8 8 9 9 #include <tcl.h> 10 11 #include <RpField1D.h>12 #include <RpFieldRect3D.h>13 10 14 11 #include "Command.h" … … 634 631 } 635 632 636 bool637 Rappture::Unirect3d::resample(Rappture::Outcome &result, size_t nSamples)638 {639 Rappture::Mesh1D xgrid(_xMin, _xMax, _xNum);640 Rappture::Mesh1D ygrid(_yMin, _yMax, _yNum);641 Rappture::Mesh1D zgrid(_zMin, _zMax, _zNum);642 Rappture::FieldRect3D xfield(xgrid, ygrid, zgrid);643 Rappture::FieldRect3D yfield(xgrid, ygrid, zgrid);644 Rappture::FieldRect3D zfield(xgrid, ygrid, zgrid);645 646 size_t i, j;647 for (i = 0, j = 0; i < _nValues; i += _nComponents, j++) {648 double vx, vy, vz;649 650 vx = _values[i];651 vy = _values[i+1];652 vz = _values[i+2];653 654 xfield.define(j, vx);655 yfield.define(j, vy);656 zfield.define(j, vz);657 }658 // Figure out a good mesh spacing659 double dx, dy, dz;660 double lx, ly, lz;661 lx = xfield.rangeMax(Rappture::xaxis) - xfield.rangeMin(Rappture::xaxis);662 ly = xfield.rangeMax(Rappture::yaxis) - xfield.rangeMin(Rappture::yaxis);663 lz = xfield.rangeMax(Rappture::zaxis) - xfield.rangeMin(Rappture::zaxis);664 665 double dmin;666 dmin = pow((lx*ly*lz)/((nSamples-1)*(nSamples-1)*(nSamples-1)), 0.333);667 668 /* Recompute new number of points for each axis. */669 _xNum = (size_t)ceil(lx/dmin);670 _yNum = (size_t)ceil(ly/dmin);671 _zNum = (size_t)ceil(lz/dmin);672 673 #ifndef HAVE_NPOT_TEXTURES674 // must be an even power of 2 for older cards675 _xNum = (int)pow(2.0, ceil(log10((double)_xNum)/log10(2.0)));676 _yNum = (int)pow(2.0, ceil(log10((double)_yNum)/log10(2.0)));677 _zNum = (int)pow(2.0, ceil(log10((double)_zNum)/log10(2.0)));678 #endif679 680 dx = lx/(double)(_xNum-1);681 dy = ly/(double)(_yNum-1);682 dz = lz/(double)(_zNum-1);683 684 TRACE("lx:%lf ly:%lf lz:%lf dmin:%lf dx:%lf dy:%lf dz:%lf", lx, ly, lz, dmin, dx, dy, dz);685 686 size_t n = _nComponents * _xNum * _yNum * _zNum;687 _values = (float *)realloc(_values, sizeof(float) * n);688 memset(_values, 0, sizeof(float) * n);689 690 // Generate the uniformly sampled rectangle that we need for a volume691 float *destPtr = _values;692 for (size_t i = 0; i < _zNum; i++) {693 double z;694 695 z = _zMin + (i * dx);696 for (size_t j = 0; j < _yNum; j++) {697 double y;698 699 y = _yMin + (j * dy);700 for (size_t k = 0; k < _xNum; k++) {701 double x;702 703 x = _xMin + (k * dz);704 destPtr[0] = xfield.value(x, y, z);705 destPtr[1] = yfield.value(x, y, z);706 destPtr[2] = zfield.value(x, y, z);707 }708 }709 }710 _nValues = _xNum * _yNum * _zNum * _nComponents;711 return true;712 }713 714 633 void 715 634 Rappture::Unirect3d::getVectorRange() -
trunk/packages/vizservers/nanovis/Unirect.h
r3630 r3935 229 229 bool convert(Unirect2d *dataPtr); 230 230 231 bool resample(Rappture::Outcome &context, size_t nSamples = 30);232 233 231 bool isInitialized() 234 232 { … … 247 245 float _zValueMin, _zValueMax; 248 246 double _magMin, _magMax; /* Range of magnitudes of vector 249 * data. */247 * data. */ 250 248 char *_xUnits; 251 249 char *_yUnits; -
trunk/packages/vizservers/nanovis/Volume.cpp
r3883 r3935 31 31 double Volume::valueMax = 1.0; 32 32 33 Volume::Volume(int w , int h, int d,34 int n , float *data,35 double v 0, double v1, double nonZeroMin) :33 Volume::Volume(int width, int height, int depth, 34 int numComponents, float *data, 35 double vmin, double vmax, double nonZeroMin) : 36 36 _id(0), 37 _width(w ),38 _height(h ),39 _depth(d ),37 _width(width), 38 _height(height), 39 _depth(depth), 40 40 _transferFunc(NULL), 41 41 _ambient(0.6f), … … 46 46 _opacityScale(0.5f), 47 47 _data(NULL), 48 _numComponents(n ),48 _numComponents(numComponents), 49 49 _nonZeroMin(nonZeroMin), 50 50 _cutplanesVisible(true), … … 63 63 _outlineColor[0] = _outlineColor[1] = _outlineColor[2] = 1.0f; 64 64 65 _tex = new Texture3D(_width, _height, _depth, GL_FLOAT, GL_LINEAR, n);65 _tex = new Texture3D(_width, _height, _depth, GL_FLOAT, GL_LINEAR, _numComponents); 66 66 int fcount = _width * _height * _depth * _numComponents; 67 67 _data = new float[fcount]; … … 71 71 _id = _tex->id(); 72 72 73 wAxis.setRange(v 0, v1);73 wAxis.setRange(vmin, vmax); 74 74 75 75 //Add cut planes. We create 3 default cut planes facing x, y, z directions. … … 91 91 } 92 92 93 void Volume::setData(float *data, double v 0, double v1, double nonZeroMin)93 void Volume::setData(float *data, double vmin, double vmax, double nonZeroMin) 94 94 { 95 95 int fcount = _width * _height * _depth * _numComponents; 96 96 memcpy(_data, data, fcount * sizeof(float)); 97 97 _tex->update(_data); 98 wAxis.setRange(v 0, v1);98 wAxis.setRange(vmin, vmax); 99 99 _nonZeroMin = nonZeroMin; 100 100 updatePending = true; -
trunk/packages/vizservers/nanovis/Volume.h
r3883 r3935 125 125 } 126 126 127 void setData(float *data, double v 0, double v1, double nonZeroMin);127 void setData(float *data, double vmin, double vmax, double nonZeroMin); 128 128 129 129 const float *data() const -
trunk/packages/vizservers/nanovis/VtkDataSetReader.cpp
r3870 r3935 11 11 #include <vtkDataSet.h> 12 12 #include <vtkImageData.h> 13 #include <vtkPointData.h> 14 #include <vtkDataArray.h> 13 15 #include <vtkDataSetReader.h> 14 16 #include <vtkCharArray.h> … … 104 106 memset(data, 0, npts * 4); 105 107 108 bool isVectorData = (resampledDataSet->GetPointData()->GetVectors() != NULL); 109 106 110 int ix = 0; 107 111 int iy = 0; … … 109 113 for (int p = 0; p < npts; p++) { 110 114 int nindex = p * 4; 111 double val = resampledDataSet->GetScalarComponentAsDouble(ix, iy, iz, 0); 112 data[nindex] = (float)val; 113 if (val < vmin) { 115 double val; 116 if (isVectorData) { 117 double vec[3]; 118 int loc[3]; 119 loc[0] = ix; loc[1] = iy; loc[2] = iz; 120 vtkIdType idx = resampledDataSet->ComputePointId(loc); 121 resampledDataSet->GetPointData()->GetVectors()->GetTuple(idx, vec); 122 val = sqrt(vec[0]*vec[0] + vec[1]*vec[1] * vec[2]*vec[2]); 123 data[nindex] = (float)val; 124 data[nindex+1] = (float)vec[0]; 125 data[nindex+2] = (float)vec[1]; 126 data[nindex+3] = (float)vec[2]; 127 } else { 128 val = resampledDataSet->GetScalarComponentAsDouble(ix, iy, iz, 0); 129 data[nindex] = (float)val; 130 } 131 if (val < vmin) { 114 132 vmin = val; 115 133 } else if (val > vmax) { … … 129 147 } 130 148 131 // scale all values [0-1], -1 => out of bounds 132 normalizeScalar(data, npts, 4, vmin, vmax); 133 computeSimpleGradient(data, nx, ny, nz, 134 dx, dy, dz); 149 if (isVectorData) { 150 // Normalize magnitude [0,1] and vector components [0,1] 151 normalizeVector(data, npts, vmin, vmax); 152 } else { 153 // scale all values [0-1], -1 => out of bounds 154 normalizeScalar(data, npts, 4, vmin, vmax); 155 computeSimpleGradient(data, nx, ny, nz, 156 dx, dy, dz); 157 } 135 158 136 159 TRACE("nx = %i ny = %i nz = %i", nx, ny, nz); -
trunk/packages/vizservers/nanovis/ZincBlendeVolume.cpp
r3630 r3935 24 24 using namespace vrmath; 25 25 26 ZincBlendeVolume::ZincBlendeVolume(int w, int h, int d, int n, 26 ZincBlendeVolume::ZincBlendeVolume(int width, int height, int depth, 27 int numComponents, 27 28 float *dataVolumeA, float *dataVolumeB, 28 double v 0, double v1, double non_zeromin,29 double vmin, double vmax, double nonZeroMin, 29 30 const Vector3f& cellSz) : 30 Volume(w , h, d, n, dataVolumeA, v0, v1, non_zeromin),31 Volume(width, height, depth, numComponents, dataVolumeA, vmin, vmax, nonZeroMin), 31 32 cellSize(cellSz) 32 33 { … … 34 35 _volumeType = ZINCBLENDE; 35 36 36 //store member tex initialize in Volume() as zincblende _tex[0]37 //store member tex initialize in Volume() as zincblendeTex[0] 37 38 assert(_tex); 38 39 zincblendeTex[0] = _tex; 39 40 40 41 //now add another tex as zincblende_tex[1] 41 Texture3D *secondTex = new Texture3D(w , h, d, GL_FLOAT, GL_LINEAR, n);42 Texture3D *secondTex = new Texture3D(width, height, depth, GL_FLOAT, GL_LINEAR, numComponents); 42 43 assert(secondTex); 43 44 secondTex->initialize(dataVolumeB); -
trunk/packages/vizservers/nanovis/ZincBlendeVolume.h
r3630 r3935 23 23 ZincBlendeVolume(int width, int height, int depth, int numComponents, 24 24 float *dataVolumeA, float *dataVolumeB, 25 double vmin, double vmax, double non _zeromin,25 double vmin, double vmax, double nonZeroMin, 26 26 const vrmath::Vector3f& cellSize); 27 27 -
trunk/packages/vizservers/nanovis/nanovis.cpp
r3900 r3935 619 619 } 620 620 621 /** 622 * \brief Called when new volumes are added to update ranges 623 */ 621 624 void 622 625 NanoVis::setVolumeRanges() … … 644 647 } 645 648 649 /** 650 * \brief Called when new heightmaps are added to update ranges 651 */ 646 652 void 647 653 NanoVis::setHeightmapRanges() … … 676 682 NanoVis::collectBounds(bool onlyVisible) 677 683 { 678 if (Flow::updatePending) {679 mapFlows();680 }681 682 684 sceneBounds.makeEmpty(); 683 685 … … 706 708 } 707 709 708 { 710 for (FlowHashmap::iterator itr = flowTable.begin(); 711 itr != flowTable.end(); ++itr) { 712 Flow *flow = itr->second; 713 709 714 BBox bbox; 710 getFlowBounds(bbox.min, bbox.max, onlyVisible);715 flow->getBounds(bbox.min, bbox.max, onlyVisible); 711 716 sceneBounds.extend(bbox); 712 717 } … … 812 817 } 813 818 819 /** 820 * \brief Called when new flows are added to update ranges 821 */ 814 822 bool 815 NanoVis:: mapFlows()823 NanoVis::setFlowRanges() 816 824 { 817 825 TRACE("Enter"); … … 827 835 itr != flowTable.end(); ++itr) { 828 836 Flow *flow = itr->second; 829 double min, max;830 837 if (!flow->isDataLoaded()) { 831 838 continue; 832 839 } 833 Rappture::Unirect3d *data = flow->data(); 834 min = data->magMin(); 835 max = data->magMax(); 836 if (min < Flow::magMin) { 837 Flow::magMin = min; 840 double range[2]; 841 flow->getVectorRange(range); 842 if (range[0] < Flow::magMin) { 843 Flow::magMin = range[0]; 838 844 } 839 if ( max> Flow::magMax) {840 Flow::magMax = max;845 if (range[1] > Flow::magMax) { 846 Flow::magMax = range[1]; 841 847 } 842 848 } … … 856 862 flow->initializeParticles(); 857 863 } 858 if (!flow->scaleVectorField()) {859 return false;860 }861 864 } 862 865 863 866 Flow::updatePending = false; 864 867 return true; 865 }866 867 void868 NanoVis::getFlowBounds(Vector3f& min,869 Vector3f& max,870 bool onlyVisible)871 {872 TRACE("Enter");873 874 BBox allBounds;875 for (FlowHashmap::iterator itr = flowTable.begin();876 itr != flowTable.end(); ++itr) {877 BBox bbox;878 itr->second->getBounds(bbox.min, bbox.max, onlyVisible);879 allBounds.extend(bbox);880 }881 882 min = allBounds.min;883 max = allBounds.max;884 868 } 885 869 … … 928 912 929 913 if (Flow::updatePending) { 930 mapFlows();914 setFlowRanges(); 931 915 } 932 916 if (HeightMap::updatePending) { -
trunk/packages/vizservers/nanovis/nanovis.h
r3630 r3935 123 123 static void setVolumeRanges(); 124 124 static void setHeightmapRanges(); 125 static bool mapFlows();125 static bool setFlowRanges(); 126 126 127 127 static Flow *getFlow(const char *name); … … 129 129 static void deleteFlows(Tcl_Interp *interp); 130 130 static void deleteFlow(const char *name); 131 static void getFlowBounds(vrmath::Vector3f& min, 132 vrmath::Vector3f& max, 133 bool onlyVisible = false); 131 134 132 static void renderFlows(); 135 133 static void resetFlows(); -
trunk/packages/vizservers/nanovis/util/Fonts.cpp
r3559 r3935 93 93 glLoadIdentity(); 94 94 95 #if 0 96 glDisable(GL_BLEND); 97 glEnable(GL_DEPTH_TEST); 98 #else 95 99 glEnable(GL_BLEND); 96 100 glDisable(GL_DEPTH_TEST); 101 #endif 97 102 } 98 103 … … 223 228 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); 224 229 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); 230 glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE); 225 231 glBindTexture(GL_TEXTURE_2D, 0); 226 232
Note: See TracChangeset
for help on using the changeset viewer.