Changeset 2290 for trunk/packages/vizservers
- Timestamp:
- Jun 22, 2011 3:39:41 PM (13 years ago)
- Location:
- trunk/packages/vizservers/vtkvis
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/vtkvis/Makefile.in
r2269 r2290 76 76 PPMWriter.cpp \ 77 77 RpContour2D.cpp \ 78 RpContour3D.cpp \ 78 79 RpGlyphs.cpp \ 79 80 RpHeightMap.cpp \ … … 126 127 PPMWriter.o: PPMWriter.h Trace.h 127 128 RpContour2D.o: RpContour2D.h RpVtkDataSet.h Trace.h 129 RpContour3D.o: RpContour3D.h RpVtkDataSet.h Trace.h 128 130 RpPolyData.o: RpPolyData.h RpVtkDataSet.h Trace.h 129 131 RpGlyphs.o: RpGlyphs.h RpVtkDataSet.h ColorMap.h Trace.h -
trunk/packages/vizservers/vtkvis/RpContour2D.cpp
r2270 r2290 115 115 } 116 116 117 vtkSmartPointer<vtkCellDataToPointData> cellToPtData; 118 117 119 if (ds->GetPointData() == NULL || 118 120 ds->GetPointData()->GetScalars() == NULL) { … … 120 122 if (ds->GetCellData() != NULL && 121 123 ds->GetCellData()->GetScalars() != NULL) { 122 vtkSmartPointer<vtkCellDataToPointData> cellToPtData;123 124 cellToPtData = 124 125 vtkSmartPointer<vtkCellDataToPointData>::New(); -
trunk/packages/vizservers/vtkvis/RpGlyphs.cpp
r2271 r2290 147 147 setGlyphShape(_glyphShape); 148 148 149 vtkSmartPointer<vtkCellDataToPointData> cellToPtData; 150 149 151 if (ds->GetPointData() == NULL || 150 152 ds->GetPointData()->GetScalars() == NULL) { … … 152 154 if (ds->GetCellData() != NULL && 153 155 ds->GetCellData()->GetScalars() != NULL) { 154 vtkSmartPointer<vtkCellDataToPointData> cellToPtData;155 156 cellToPtData = 156 157 vtkSmartPointer<vtkCellDataToPointData>::New(); -
trunk/packages/vizservers/vtkvis/RpHeightMap.cpp
r2270 r2290 20 20 #include <vtkDelaunay2D.h> 21 21 #include <vtkDelaunay3D.h> 22 #include <vtkProbeFilter.h> 22 23 #include <vtkGaussianSplatter.h> 23 24 #include <vtkExtractVOI.h> … … 32 33 using namespace Rappture::VtkVis; 33 34 34 //#define MESH_POINTS35 #define MESH_POINT_CLOUDS 35 36 36 37 HeightMap::HeightMap() : … … 41 42 _opacity(1.0), 42 43 _warpScale(1.0), 44 _sliceAxis(Z_AXIS), 43 45 _pipelineInitialized(false) 44 46 { … … 78 80 _dataRange[0] = dataRange[0]; 79 81 _dataRange[1] = dataRange[1]; 82 83 // Compute a data scaling factor to make maximum 84 // height (at default _warpScale) equivalent to 85 // largest dimension of data set 86 double bounds[6]; 87 double boundsRange = 0.0; 88 _dataSet->getBounds(bounds); 89 for (int i = 0; i < 6; i+=2) { 90 double r = bounds[i+1] - bounds[i]; 91 if (r > boundsRange) 92 boundsRange = r; 93 } 94 double datRange = _dataRange[1] - _dataRange[0]; 95 if (datRange < 1.0e-10) { 96 _dataScale = 1.0; 97 } else { 98 _dataScale = boundsRange / datRange; 99 } 100 TRACE("Bounds range: %g data range: %g scaling: %g", 101 boundsRange, datRange, _dataScale); 80 102 } 81 103 … … 115 137 116 138 if (!_pipelineInitialized) { 139 vtkSmartPointer<vtkCellDataToPointData> cellToPtData; 140 117 141 if (ds->GetPointData() == NULL || 118 142 ds->GetPointData()->GetScalars() == NULL) { … … 120 144 if (ds->GetCellData() != NULL && 121 145 ds->GetCellData()->GetScalars() != NULL) { 122 vtkSmartPointer<vtkCellDataToPointData> cellToPtData;123 146 cellToPtData = 124 147 vtkSmartPointer<vtkCellDataToPointData>::New(); … … 141 164 // DataSet is a point cloud 142 165 if (_dataSet->is2D()) { 143 #ifdef MESH_POINTS 166 #ifdef MESH_POINT_CLOUDS 167 // Result of Delaunay2D is a PolyData 144 168 vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New(); 145 169 mesher->SetInput(pd); … … 169 193 _volumeSlicer->SetSampleRate(1, 1, 1); 170 194 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 195 gf->UseStripsOn(); 171 196 gf->SetInputConnection(_volumeSlicer->GetOutputPort()); 172 197 vtkAlgorithmOutput *warpOutput = initWarp(gf->GetOutputPort()); … … 175 200 #endif 176 201 } else { 177 #ifdef MESH_POINTS 202 #ifdef MESH_POINT_CLOUDS 203 // Data Set is a 3D point cloud 204 // Result of Delaunay3D mesher is unstructured grid 178 205 vtkSmartPointer<vtkDelaunay3D> mesher = vtkSmartPointer<vtkDelaunay3D>::New(); 179 206 mesher->SetInput(pd); 207 // Run the mesher 208 mesher->Update(); 209 // Get bounds of resulting grid 210 double bounds[6]; 211 mesher->GetOutput()->GetBounds(bounds); 212 // Sample a plane within the grid bounding box 213 if (_probeFilter == NULL) 214 _probeFilter = vtkSmartPointer<vtkProbeFilter>::New(); 215 _probeFilter->SetSourceConnection(mesher->GetOutputPort()); 216 vtkSmartPointer<vtkImageData> imageData = vtkSmartPointer<vtkImageData>::New(); 217 int xdim = 256; 218 int ydim = 256; 219 int zdim = 1; 220 imageData->SetDimensions(xdim, ydim, zdim); 221 imageData->SetOrigin(bounds[0], bounds[2], bounds[4] + (bounds[5]-bounds[4])/2.); 222 imageData->SetSpacing((bounds[1]-bounds[0])/((double)(xdim-1)), 223 (bounds[3]-bounds[2])/((double)(ydim-1)), 224 0); 225 _probeFilter->SetInput(imageData); 180 226 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 181 gf->SetInputConnection(mesher->GetOutputPort()); 227 gf->UseStripsOn(); 228 gf->SetInputConnection(_probeFilter->GetOutputPort()); 182 229 #else 183 230 if (_pointSplatter == NULL) … … 202 249 _volumeSlicer->SetSampleRate(1, 1, 1); 203 250 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 251 gf->UseStripsOn(); 204 252 gf->SetInputConnection(_volumeSlicer->GetOutputPort()); 205 253 #endif … … 223 271 // Can be: image/volume/uniform grid, structured grid, unstructured grid, rectilinear grid 224 272 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 273 gf->UseStripsOn(); 225 274 vtkImageData *imageData = vtkImageData::SafeDownCast(ds); 226 275 if (!_dataSet->is2D() && imageData != NULL) { … … 235 284 _volumeSlicer->SetSampleRate(1, 1, 1); 236 285 gf->SetInputConnection(_volumeSlicer->GetOutputPort()); 286 } else if (imageData == NULL) { 287 // structured grid, unstructured grid, or rectilinear grid 288 double bounds[6]; 289 ds->GetBounds(bounds); 290 // Sample a plane within the grid bounding box 291 if (_probeFilter == NULL) 292 _probeFilter = vtkSmartPointer<vtkProbeFilter>::New(); 293 _probeFilter->SetSource(ds); 294 vtkSmartPointer<vtkImageData> imageData = vtkSmartPointer<vtkImageData>::New(); 295 int xdim = 256; 296 int ydim = 256; 297 int zdim = 1; 298 imageData->SetDimensions(xdim, ydim, zdim); 299 imageData->SetOrigin(bounds[0], bounds[2], bounds[4] + (bounds[5]-bounds[4])/2.); 300 imageData->SetSpacing((bounds[1]-bounds[0])/((double)(xdim-1)), 301 (bounds[3]-bounds[2])/((double)(ydim-1)), 302 0); 303 _probeFilter->SetInput(imageData); 304 gf->SetInputConnection(_probeFilter->GetOutputPort()); 237 305 } else { 238 // 2D image data , structured grid, unstructured grid, or rectilinear grid306 // 2D image data 239 307 gf->SetInput(ds); 240 308 } … … 269 337 initProp(); 270 338 339 _dsMapper->SetColorModeToMapScalars(); 271 340 _dsMapper->UseLookupTableScalarRangeOn(); 272 341 _dsMapper->SetLookupTable(_lut); … … 325 394 if (_warp == NULL) 326 395 _warp = vtkSmartPointer<vtkWarpScalar>::New(); 327 _warp->SetNormal(0, 0, 1); 396 switch (_sliceAxis) { 397 case X_AXIS: 398 _warp->SetNormal(1, 0, 0); 399 break; 400 case Y_AXIS: 401 _warp->SetNormal(0, 1, 0); 402 break; 403 default: 404 _warp->SetNormal(0, 0, 1); 405 } 328 406 _warp->UseNormalOn(); 329 _warp->SetScaleFactor(_warpScale );407 _warp->SetScaleFactor(_warpScale * _dataScale); 330 408 _warp->SetInputConnection(input); 331 409 return _warp->GetOutputPort(); … … 345 423 if (_warp == NULL) 346 424 _warp = vtkSmartPointer<vtkWarpScalar>::New(); 347 _warp->SetNormal(0, 0, 1); 425 switch (_sliceAxis) { 426 case X_AXIS: 427 _warp->SetNormal(1, 0, 0); 428 break; 429 case Y_AXIS: 430 _warp->SetNormal(0, 1, 0); 431 break; 432 default: 433 _warp->SetNormal(0, 0, 1); 434 } 348 435 _warp->UseNormalOn(); 349 _warp->SetScaleFactor(_warpScale );436 _warp->SetScaleFactor(_warpScale * _dataScale); 350 437 _warp->SetInput(pdInput); 351 438 return _warp->GetOutputPort(); … … 369 456 _warp = NULL; 370 457 } else { 371 _warp->SetScaleFactor(_warpScale );458 _warp->SetScaleFactor(_warpScale * _dataScale); 372 459 } 373 460 … … 385 472 } 386 473 387 if (_ warp == NULL ||388 _volumeSlicer == NULL) {474 if (_volumeSlicer == NULL && 475 _probeFilter == NULL) { 389 476 WARN("Called before update() or DataSet is not a volume"); 390 477 return; … … 392 479 393 480 int dims[3]; 394 int voi[6];395 481 396 482 if (_pointSplatter != NULL) { … … 399 485 vtkImageData *imageData = vtkImageData::SafeDownCast(_dataSet->getVtkDataSet()); 400 486 if (imageData == NULL) { 401 ERROR("Not a volume data set"); 487 if (_probeFilter != NULL) { 488 imageData = vtkImageData::SafeDownCast(_probeFilter->GetInput()); 489 if (imageData == NULL) { 490 ERROR("Couldn't get probe filter input image"); 491 return; 492 } 493 } else { 494 ERROR("Not a volume data set"); 495 return; 496 } 497 } 498 imageData->GetDimensions(dims); 499 } 500 501 _sliceAxis = axis; 502 if (_warp != NULL) { 503 switch (axis) { 504 case X_AXIS: 505 _warp->SetNormal(1, 0, 0); 506 break; 507 case Y_AXIS: 508 _warp->SetNormal(0, 1, 0); 509 break; 510 case Z_AXIS: 511 _warp->SetNormal(0, 0, 1); 512 break; 513 default: 514 ERROR("Invalid Axis"); 402 515 return; 403 516 } 404 imageData->GetDimensions(dims); 405 } 406 407 switch (axis) { 408 case X_AXIS: 409 voi[0] = voi[1] = (int)((dims[0]-1) * ratio); 410 voi[2] = 0; 411 voi[3] = dims[1]-1; 412 voi[4] = 0; 413 voi[5] = dims[2]-1; 414 _warp->SetNormal(1, 0, 0); 415 break; 416 case Y_AXIS: 417 voi[2] = voi[3] = (int)((dims[1]-1) * ratio); 418 voi[0] = 0; 419 voi[1] = dims[0]-1; 420 voi[4] = 0; 421 voi[5] = dims[2]-1; 422 _warp->SetNormal(0, 1, 0); 423 break; 424 case Z_AXIS: 425 voi[4] = voi[5] = (int)((dims[2]-1) * ratio); 426 voi[0] = 0; 427 voi[1] = dims[0]-1; 428 voi[2] = 0; 429 voi[3] = dims[1]-1; 430 _warp->SetNormal(0, 0, 1); 431 break; 432 default: 433 ERROR("Invalid Axis"); 434 return; 435 } 436 437 _volumeSlicer->SetVOI(voi[0], voi[1], voi[2], voi[3], voi[4], voi[5]); 517 } 518 519 if (_probeFilter != NULL) { 520 vtkImageData *imageData = vtkImageData::SafeDownCast(_probeFilter->GetInput()); 521 double bounds[6]; 522 assert(vtkDataSet::SafeDownCast(_probeFilter->GetSource()) != NULL); 523 vtkDataSet::SafeDownCast(_probeFilter->GetSource())->GetBounds(bounds); 524 int dim = 256; 525 526 switch (axis) { 527 case X_AXIS: 528 imageData->SetDimensions(1, dim, dim); 529 imageData->SetOrigin(bounds[0] + (bounds[1]-bounds[0])*ratio, bounds[2], bounds[4]); 530 imageData->SetSpacing(0, 531 (bounds[3]-bounds[2])/((double)(dim-1)), 532 (bounds[5]-bounds[4])/((double)(dim-1))); 533 break; 534 case Y_AXIS: 535 imageData->SetDimensions(dim, 1, dim); 536 imageData->SetOrigin(bounds[0], bounds[2] + (bounds[3]-bounds[2])*ratio, bounds[4]); 537 imageData->SetSpacing((bounds[1]-bounds[0])/((double)(dim-1)), 538 0, 539 (bounds[5]-bounds[4])/((double)(dim-1))); 540 break; 541 case Z_AXIS: 542 imageData->SetDimensions(dim, dim, 1); 543 imageData->SetOrigin(bounds[0], bounds[2], bounds[4] + (bounds[5]-bounds[4])*ratio); 544 imageData->SetSpacing((bounds[1]-bounds[0])/((double)(dim-1)), 545 (bounds[3]-bounds[2])/((double)(dim-1)), 546 0); 547 break; 548 default: 549 ERROR("Invalid Axis"); 550 return; 551 } 552 } else { 553 int voi[6]; 554 555 switch (axis) { 556 case X_AXIS: 557 voi[0] = voi[1] = (int)((dims[0]-1) * ratio); 558 voi[2] = 0; 559 voi[3] = dims[1]-1; 560 voi[4] = 0; 561 voi[5] = dims[2]-1; 562 break; 563 case Y_AXIS: 564 voi[2] = voi[3] = (int)((dims[1]-1) * ratio); 565 voi[0] = 0; 566 voi[1] = dims[0]-1; 567 voi[4] = 0; 568 voi[5] = dims[2]-1; 569 break; 570 case Z_AXIS: 571 voi[4] = voi[5] = (int)((dims[2]-1) * ratio); 572 voi[0] = 0; 573 voi[1] = dims[0]-1; 574 voi[2] = 0; 575 voi[3] = dims[1]-1; 576 break; 577 default: 578 ERROR("Invalid Axis"); 579 return; 580 } 581 582 _volumeSlicer->SetVOI(voi[0], voi[1], voi[2], voi[3], voi[4], voi[5]); 583 } 584 438 585 if (_dsMapper != NULL) 439 586 _dsMapper->Update(); -
trunk/packages/vizservers/vtkvis/RpHeightMap.h
r2270 r2290 12 12 #include <vtkAlgorithmOutput.h> 13 13 #include <vtkContourFilter.h> 14 #include <vtkProbeFilter.h> 14 15 #include <vtkLookupTable.h> 15 16 #include <vtkDataSetMapper.h> … … 107 108 double _opacity; 108 109 double _warpScale; 110 double _dataScale; 111 Axis _sliceAxis; 109 112 bool _pipelineInitialized; 110 113 … … 114 117 vtkSmartPointer<vtkPolyDataMapper> _contourMapper; 115 118 vtkSmartPointer<vtkGaussianSplatter> _pointSplatter; 119 vtkSmartPointer<vtkProbeFilter> _probeFilter; 116 120 vtkSmartPointer<vtkExtractVOI> _volumeSlicer; 117 121 vtkSmartPointer<vtkWarpScalar> _warp; -
trunk/packages/vizservers/vtkvis/RpPseudoColor.cpp
r2270 r2290 24 24 #include "Trace.h" 25 25 26 #define MESH_POINT_CLOUDS 27 26 28 using namespace Rappture::VtkVis; 27 29 … … 93 95 // DataSet is a point cloud 94 96 if (_dataSet->is2D()) { 95 #if 097 #ifdef MESH_POINT_CLOUDS 96 98 vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New(); 97 99 mesher->SetInput(pd); 98 _dsMapper->SetInputConnection(mesher->GetOutputPort()); 100 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 101 gf->SetInputConnection(mesher->GetOutputPort()); 102 _dsMapper->SetInputConnection(gf->GetOutputPort()); 99 103 #else 100 104 vtkSmartPointer<vtkGaussianSplatter> splatter = vtkSmartPointer<vtkGaussianSplatter>::New(); … … 117 121 slicer->SetSampleRate(1, 1, 1); 118 122 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 123 gf->UseStripsOn(); 119 124 gf->SetInputConnection(slicer->GetOutputPort()); 120 125 _dsMapper->SetInputConnection(gf->GetOutputPort()); … … 158 163 _lut->SetRange(dataRange); 159 164 165 _dsMapper->SetColorModeToMapScalars(); 160 166 _dsMapper->UseLookupTableScalarRangeOn(); 161 167 _dsMapper->SetLookupTable(_lut); -
trunk/packages/vizservers/vtkvis/RpVtkDataSet.cpp
r2270 r2290 124 124 TRACE("DataSet class: %s", _dataSet->GetClassName()); 125 125 TRACE("Scalar Range: %.12e, %.12e", _dataRange[0], _dataRange[1]); 126 TRACE("DataSet bounds: %g %g %g %g %g %g", 127 _bounds[0], _bounds[1], 128 _bounds[2], _bounds[3], 129 _bounds[4], _bounds[5]); 126 130 return true; 127 131 } … … 141 145 TRACE("DataSet class: %s", _dataSet->GetClassName()); 142 146 TRACE("Scalar Range: %.12e, %.12e", _dataRange[0], _dataRange[1]); 147 TRACE("DataSet bounds: %g %g %g %g %g %g", 148 _bounds[0], _bounds[1], 149 _bounds[2], _bounds[3], 150 _bounds[4], _bounds[5]); 143 151 return true; 144 152 } … … 217 225 void DataSet::getDataRange(double minmax[2]) 218 226 { 219 minmax[0] = _dataRange[0]; 220 minmax[1] = _dataRange[1]; 227 memcpy(minmax, _dataRange, sizeof(double)*2); 228 } 229 230 /** 231 * \brief Get the bounds the DataSet 232 */ 233 void DataSet::getBounds(double bounds[6]) 234 { 235 memcpy(bounds, _bounds, sizeof(double)*6); 221 236 } 222 237 -
trunk/packages/vizservers/vtkvis/RpVtkDataSet.h
r2270 r2290 47 47 void getDataRange(double minmax[2]); 48 48 49 void getBounds(double bounds[6]); 50 49 51 double getDataValue(double x, double y, double z); 50 52 -
trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp
r2277 r2290 104 104 #endif 105 105 _renderWindow->SetSize(_windowWidth, _windowHeight); 106 // Next 2 options needed to support depth peeling 107 _renderWindow->SetAlphaBitPlanes(1); 108 _renderWindow->SetMultiSamples(0); 109 _renderer->SetMaximumNumberOfPeels(100); 110 _renderer->SetUseDepthPeeling(1); 106 111 _renderWindow->AddRenderer(_renderer); 107 112 addColorMap("default", ColorMap::getDefault()); … … 112 117 { 113 118 TRACE("Enter"); 114 TRACE("Deleting Contour s");115 for (Contour2DHashmap::iterator itr = _contour s.begin();116 itr != _contour s.end(); ++itr) {119 TRACE("Deleting Contour2Ds"); 120 for (Contour2DHashmap::iterator itr = _contour2Ds.begin(); 121 itr != _contour2Ds.end(); ++itr) { 117 122 delete itr->second; 118 123 } 119 _contours.clear(); 124 _contour2Ds.clear(); 125 TRACE("Deleting Contour3Ds"); 126 for (Contour3DHashmap::iterator itr = _contour3Ds.begin(); 127 itr != _contour3Ds.end(); ++itr) { 128 delete itr->second; 129 } 130 _contour3Ds.clear(); 120 131 TRACE("Deleting Glyphs"); 121 132 for (GlyphsHashmap::iterator itr = _glyphs.begin(); … … 169 180 * 170 181 * This just adds the DataSet to the Renderer's list of data sets. 171 * In order to render the data, a PseudoColor or Contour2D must172 * be added to the Renderer.182 * In order to render the data, a graphics object using the data 183 * set must be added to the Renderer. 173 184 */ 174 185 void Renderer::addDataSet(const DataSetId& id) … … 193 204 194 205 if (id.compare("all") == 0) { 195 itr = _contour s.begin();196 doAll = true; 197 } else { 198 itr = _contour s.find(id);199 } 200 if (itr == _contour s.end()) {206 itr = _contour2Ds.begin(); 207 doAll = true; 208 } else { 209 itr = _contour2Ds.find(id); 210 } 211 if (itr == _contour2Ds.end()) { 201 212 ERROR("Contour2D not found: %s", id.c_str()); 202 213 return; … … 211 222 delete contour; 212 223 213 itr = _contours.erase(itr); 214 } while (doAll && itr != _contours.end()); 224 itr = _contour2Ds.erase(itr); 225 } while (doAll && itr != _contour2Ds.end()); 226 227 _needsRedraw = true; 228 } 229 230 /** 231 * \brief Remove the Contour3D isosurfaces for the specified DataSet 232 * 233 * The underlying Contour3D is deleted, freeing its memory 234 */ 235 void Renderer::deleteContour3D(const DataSetId& id) 236 { 237 Contour3DHashmap::iterator itr; 238 239 bool doAll = false; 240 241 if (id.compare("all") == 0) { 242 itr = _contour3Ds.begin(); 243 doAll = true; 244 } else { 245 itr = _contour3Ds.find(id); 246 } 247 if (itr == _contour3Ds.end()) { 248 ERROR("Contour3D not found: %s", id.c_str()); 249 return; 250 } 251 252 TRACE("Deleting Contour3Ds for %s", id.c_str()); 253 254 do { 255 Contour3D *contour = itr->second; 256 if (contour->getProp()) 257 _renderer->RemoveViewProp(contour->getProp()); 258 delete contour; 259 260 itr = _contour3Ds.erase(itr); 261 } while (doAll && itr != _contour3Ds.end()); 215 262 216 263 _needsRedraw = true; … … 424 471 425 472 deleteContour2D(itr->second->getName()); 473 deleteContour3D(itr->second->getName()); 426 474 deleteGlyphs(itr->second->getName()); 427 475 deleteHeightMap(itr->second->getName()); … … 982 1030 983 1031 Contour2D *contour = new Contour2D(); 984 _contour s[dsID] = contour;1032 _contour2Ds[dsID] = contour; 985 1033 986 1034 contour->setDataSet(ds); … … 998 1046 Contour2D *Renderer::getContour2D(const DataSetId& id) 999 1047 { 1000 Contour2DHashmap::iterator itr = _contour s.find(id);1001 1002 if (itr == _contour s.end()) {1048 Contour2DHashmap::iterator itr = _contour2Ds.find(id); 1049 1050 if (itr == _contour2Ds.end()) { 1003 1051 TRACE("Contour2D not found: %s", id.c_str()); 1004 1052 return NULL; … … 1010 1058 * \brief Set the number of equally spaced contour isolines for the given DataSet 1011 1059 */ 1012 void Renderer::setContour s(const DataSetId& id, int numContours)1060 void Renderer::setContour2DContours(const DataSetId& id, int numContours) 1013 1061 { 1014 1062 Contour2DHashmap::iterator itr; … … 1017 1065 1018 1066 if (id.compare("all") == 0) { 1019 itr = _contour s.begin();1020 doAll = true; 1021 } else { 1022 itr = _contour s.find(id);1023 } 1024 if (itr == _contour s.end()) {1067 itr = _contour2Ds.begin(); 1068 doAll = true; 1069 } else { 1070 itr = _contour2Ds.find(id); 1071 } 1072 if (itr == _contour2Ds.end()) { 1025 1073 ERROR("Contour2D not found: %s", id.c_str()); 1026 1074 return; … … 1033 1081 itr->second->setContours(numContours); 1034 1082 } 1035 } while (doAll && ++itr != _contour s.end());1083 } while (doAll && ++itr != _contour2Ds.end()); 1036 1084 1037 1085 _needsRedraw = true; … … 1041 1089 * \brief Set a list of isovalues for the given DataSet 1042 1090 */ 1043 void Renderer::setContour List(const DataSetId& id, const std::vector<double>& contours)1091 void Renderer::setContour2DContourList(const DataSetId& id, const std::vector<double>& contours) 1044 1092 { 1045 1093 Contour2DHashmap::iterator itr; … … 1048 1096 1049 1097 if (id.compare("all") == 0) { 1050 itr = _contour s.begin();1051 doAll = true; 1052 } else { 1053 itr = _contour s.find(id);1054 } 1055 if (itr == _contour s.end()) {1098 itr = _contour2Ds.begin(); 1099 doAll = true; 1100 } else { 1101 itr = _contour2Ds.find(id); 1102 } 1103 if (itr == _contour2Ds.end()) { 1056 1104 ERROR("Contour2D not found: %s", id.c_str()); 1057 1105 return; … … 1060 1108 do { 1061 1109 itr->second->setContourList(contours); 1062 } while (doAll && ++itr != _contour s.end());1110 } while (doAll && ++itr != _contour2Ds.end()); 1063 1111 1064 1112 _needsRedraw = true; … … 1068 1116 * \brief Set opacity of contour lines for the given DataSet 1069 1117 */ 1070 void Renderer::setContour Opacity(const DataSetId& id, double opacity)1118 void Renderer::setContour2DOpacity(const DataSetId& id, double opacity) 1071 1119 { 1072 1120 Contour2DHashmap::iterator itr; … … 1075 1123 1076 1124 if (id.compare("all") == 0) { 1077 itr = _contour s.begin();1078 doAll = true; 1079 } else { 1080 itr = _contour s.find(id);1081 } 1082 if (itr == _contour s.end()) {1125 itr = _contour2Ds.begin(); 1126 doAll = true; 1127 } else { 1128 itr = _contour2Ds.find(id); 1129 } 1130 if (itr == _contour2Ds.end()) { 1083 1131 ERROR("Contour2D not found: %s", id.c_str()); 1084 1132 return; … … 1087 1135 do { 1088 1136 itr->second->setOpacity(opacity); 1089 } while (doAll && ++itr != _contour s.end());1137 } while (doAll && ++itr != _contour2Ds.end()); 1090 1138 1091 1139 _needsRedraw = true; … … 1095 1143 * \brief Turn on/off rendering contour lines for the given DataSet 1096 1144 */ 1097 void Renderer::setContour Visibility(const DataSetId& id, bool state)1145 void Renderer::setContour2DVisibility(const DataSetId& id, bool state) 1098 1146 { 1099 1147 Contour2DHashmap::iterator itr; … … 1102 1150 1103 1151 if (id.compare("all") == 0) { 1104 itr = _contour s.begin();1105 doAll = true; 1106 } else { 1107 itr = _contour s.find(id);1108 } 1109 if (itr == _contour s.end()) {1152 itr = _contour2Ds.begin(); 1153 doAll = true; 1154 } else { 1155 itr = _contour2Ds.find(id); 1156 } 1157 if (itr == _contour2Ds.end()) { 1110 1158 ERROR("Contour2D not found: %s", id.c_str()); 1111 1159 return; … … 1114 1162 do { 1115 1163 itr->second->setVisibility(state); 1116 } while (doAll && ++itr != _contour s.end());1164 } while (doAll && ++itr != _contour2Ds.end()); 1117 1165 1118 1166 _needsRedraw = true; … … 1122 1170 * \brief Set the RGB isoline color for the specified DataSet 1123 1171 */ 1124 void Renderer::setContour EdgeColor(const DataSetId& id, float color[3])1172 void Renderer::setContour2DEdgeColor(const DataSetId& id, float color[3]) 1125 1173 { 1126 1174 Contour2DHashmap::iterator itr; … … 1129 1177 1130 1178 if (id.compare("all") == 0) { 1131 itr = _contour s.begin();1132 doAll = true; 1133 } else { 1134 itr = _contour s.find(id);1135 } 1136 if (itr == _contour s.end()) {1179 itr = _contour2Ds.begin(); 1180 doAll = true; 1181 } else { 1182 itr = _contour2Ds.find(id); 1183 } 1184 if (itr == _contour2Ds.end()) { 1137 1185 ERROR("Contour2D not found: %s", id.c_str()); 1138 1186 return; … … 1141 1189 do { 1142 1190 itr->second->setEdgeColor(color); 1143 } while (doAll && ++itr != _contour s.end());1191 } while (doAll && ++itr != _contour2Ds.end()); 1144 1192 1145 1193 _needsRedraw = true; … … 1152 1200 * this function may not have an effect. 1153 1201 */ 1154 void Renderer::setContour EdgeWidth(const DataSetId& id, float edgeWidth)1202 void Renderer::setContour2DEdgeWidth(const DataSetId& id, float edgeWidth) 1155 1203 { 1156 1204 Contour2DHashmap::iterator itr; … … 1159 1207 1160 1208 if (id.compare("all") == 0) { 1161 itr = _contour s.begin();1162 doAll = true; 1163 } else { 1164 itr = _contour s.find(id);1165 } 1166 if (itr == _contour s.end()) {1209 itr = _contour2Ds.begin(); 1210 doAll = true; 1211 } else { 1212 itr = _contour2Ds.find(id); 1213 } 1214 if (itr == _contour2Ds.end()) { 1167 1215 ERROR("Contour2D not found: %s", id.c_str()); 1168 1216 return; … … 1171 1219 do { 1172 1220 itr->second->setEdgeWidth(edgeWidth); 1173 } while (doAll && ++itr != _contour s.end());1221 } while (doAll && ++itr != _contour2Ds.end()); 1174 1222 1175 1223 _needsRedraw = true; … … 1179 1227 * \brief Turn contour lighting on/off for the specified DataSet 1180 1228 */ 1181 void Renderer::setContour Lighting(const DataSetId& id, bool state)1229 void Renderer::setContour2DLighting(const DataSetId& id, bool state) 1182 1230 { 1183 1231 Contour2DHashmap::iterator itr; … … 1186 1234 1187 1235 if (id.compare("all") == 0) { 1188 itr = _contour s.begin();1189 doAll = true; 1190 } else { 1191 itr = _contour s.find(id);1192 } 1193 if (itr == _contour s.end()) {1236 itr = _contour2Ds.begin(); 1237 doAll = true; 1238 } else { 1239 itr = _contour2Ds.find(id); 1240 } 1241 if (itr == _contour2Ds.end()) { 1194 1242 ERROR("Contour2D not found: %s", id.c_str()); 1195 1243 return; … … 1198 1246 do { 1199 1247 itr->second->setLighting(state); 1200 } while (doAll && ++itr != _contours.end()); 1248 } while (doAll && ++itr != _contour2Ds.end()); 1249 _needsRedraw = true; 1250 } 1251 1252 /** 1253 * \brief Create a new Contour3D and associate it with the named DataSet 1254 */ 1255 void Renderer::addContour3D(const DataSetId& id) 1256 { 1257 DataSetHashmap::iterator itr; 1258 1259 bool doAll = false; 1260 1261 if (id.compare("all") == 0) { 1262 itr = _dataSets.begin(); 1263 } else { 1264 itr = _dataSets.find(id); 1265 } 1266 if (itr == _dataSets.end()) { 1267 ERROR("Unknown dataset %s", id.c_str()); 1268 return; 1269 } 1270 1271 do { 1272 DataSet *ds = itr->second; 1273 const DataSetId& dsID = ds->getName(); 1274 1275 if (getContour3D(dsID)) { 1276 WARN("Replacing existing contour3d %s", dsID.c_str()); 1277 deleteContour3D(dsID); 1278 } 1279 1280 Contour3D *contour = new Contour3D(); 1281 _contour3Ds[dsID] = contour; 1282 1283 contour->setDataSet(ds); 1284 1285 // Use the default color map 1286 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 1287 ColorMap *cmap = getColorMap("default"); 1288 lut->DeepCopy(cmap->getLookupTable()); 1289 if (_useCumulativeRange) { 1290 lut->SetRange(_cumulativeDataRange); 1291 } else { 1292 double range[2]; 1293 ds->getDataRange(range); 1294 lut->SetRange(range); 1295 } 1296 1297 contour->setLookupTable(lut); 1298 1299 _renderer->AddViewProp(contour->getProp()); 1300 } while (doAll && ++itr != _dataSets.end()); 1301 1302 if (_cameraMode == IMAGE) 1303 setCameraMode(PERSPECTIVE); 1304 initCamera(); 1305 _needsRedraw = true; 1306 } 1307 1308 /** 1309 * \brief Get the Contour3D associated with a named DataSet 1310 */ 1311 Contour3D *Renderer::getContour3D(const DataSetId& id) 1312 { 1313 Contour3DHashmap::iterator itr = _contour3Ds.find(id); 1314 1315 if (itr == _contour3Ds.end()) { 1316 TRACE("Contour3D not found: %s", id.c_str()); 1317 return NULL; 1318 } else 1319 return itr->second; 1320 } 1321 1322 /** 1323 * \brief Set the number of equally spaced isosurfaces for the given DataSet 1324 */ 1325 void Renderer::setContour3DContours(const DataSetId& id, int numContours) 1326 { 1327 Contour3DHashmap::iterator itr; 1328 1329 bool doAll = false; 1330 1331 if (id.compare("all") == 0) { 1332 itr = _contour3Ds.begin(); 1333 doAll = true; 1334 } else { 1335 itr = _contour3Ds.find(id); 1336 } 1337 if (itr == _contour3Ds.end()) { 1338 ERROR("Contour3D not found: %s", id.c_str()); 1339 return; 1340 } 1341 1342 do { 1343 if (_useCumulativeRange) { 1344 itr->second->setContours(numContours, _cumulativeDataRange); 1345 } else { 1346 itr->second->setContours(numContours); 1347 } 1348 } while (doAll && ++itr != _contour3Ds.end()); 1349 1350 initCamera(); 1351 _needsRedraw = true; 1352 } 1353 1354 /** 1355 * \brief Set a list of isovalues for the given DataSet 1356 */ 1357 void Renderer::setContour3DContourList(const DataSetId& id, const std::vector<double>& contours) 1358 { 1359 Contour3DHashmap::iterator itr; 1360 1361 bool doAll = false; 1362 1363 if (id.compare("all") == 0) { 1364 itr = _contour3Ds.begin(); 1365 doAll = true; 1366 } else { 1367 itr = _contour3Ds.find(id); 1368 } 1369 if (itr == _contour3Ds.end()) { 1370 ERROR("Contour3D not found: %s", id.c_str()); 1371 return; 1372 } 1373 1374 do { 1375 itr->second->setContourList(contours); 1376 } while (doAll && ++itr != _contour3Ds.end()); 1377 1378 initCamera(); 1379 _needsRedraw = true; 1380 } 1381 1382 /** 1383 * \brief Set opacity of isosurfaces for the given DataSet 1384 */ 1385 void Renderer::setContour3DOpacity(const DataSetId& id, double opacity) 1386 { 1387 Contour3DHashmap::iterator itr; 1388 1389 bool doAll = false; 1390 1391 if (id.compare("all") == 0) { 1392 itr = _contour3Ds.begin(); 1393 doAll = true; 1394 } else { 1395 itr = _contour3Ds.find(id); 1396 } 1397 if (itr == _contour3Ds.end()) { 1398 ERROR("Contour3D not found: %s", id.c_str()); 1399 return; 1400 } 1401 1402 do { 1403 itr->second->setOpacity(opacity); 1404 } while (doAll && ++itr != _contour3Ds.end()); 1405 1406 _needsRedraw = true; 1407 } 1408 1409 /** 1410 * \brief Turn on/off rendering isosurfaces for the given DataSet 1411 */ 1412 void Renderer::setContour3DVisibility(const DataSetId& id, bool state) 1413 { 1414 Contour3DHashmap::iterator itr; 1415 1416 bool doAll = false; 1417 1418 if (id.compare("all") == 0) { 1419 itr = _contour3Ds.begin(); 1420 doAll = true; 1421 } else { 1422 itr = _contour3Ds.find(id); 1423 } 1424 if (itr == _contour3Ds.end()) { 1425 ERROR("Contour3D not found: %s", id.c_str()); 1426 return; 1427 } 1428 1429 do { 1430 itr->second->setVisibility(state); 1431 } while (doAll && ++itr != _contour3Ds.end()); 1432 1433 _needsRedraw = true; 1434 } 1435 1436 /** 1437 * \brief Associate an existing named color map with a Contour3D for the given 1438 * DataSet 1439 */ 1440 void Renderer::setContour3DColorMap(const DataSetId& id, const ColorMapId& colorMapId) 1441 { 1442 Contour3DHashmap::iterator itr; 1443 1444 bool doAll = false; 1445 1446 if (id.compare("all") == 0) { 1447 itr = _contour3Ds.begin(); 1448 doAll = true; 1449 } else { 1450 itr = _contour3Ds.find(id); 1451 } 1452 1453 if (itr == _contour3Ds.end()) { 1454 ERROR("Contour3D not found: %s", id.c_str()); 1455 return; 1456 } 1457 1458 ColorMap *cmap = getColorMap(colorMapId); 1459 if (cmap == NULL) { 1460 ERROR("Unknown colormap: %s", colorMapId.c_str()); 1461 return; 1462 } 1463 1464 do { 1465 TRACE("Set Contour3D color map: %s for dataset %s", colorMapId.c_str(), 1466 itr->second->getDataSet()->getName().c_str()); 1467 1468 // Make a copy of the generic colormap lookup table, so 1469 // data range can be set in the copy table to match the 1470 // dataset being plotted 1471 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 1472 lut->DeepCopy(cmap->getLookupTable()); 1473 1474 if (_useCumulativeRange) { 1475 lut->SetRange(_cumulativeDataRange); 1476 } else { 1477 if (itr->second->getDataSet() != NULL) { 1478 double range[2]; 1479 itr->second->getDataSet()->getDataRange(range); 1480 lut->SetRange(range); 1481 } 1482 } 1483 1484 itr->second->setLookupTable(lut); 1485 } while (doAll && ++itr != _contour3Ds.end()); 1486 1487 _needsRedraw = true; 1488 } 1489 1490 /** 1491 * \brief Set the RGB isosurface color for the specified DataSet 1492 */ 1493 void Renderer::setContour3DColor(const DataSetId& id, float color[3]) 1494 { 1495 Contour3DHashmap::iterator itr; 1496 1497 bool doAll = false; 1498 1499 if (id.compare("all") == 0) { 1500 itr = _contour3Ds.begin(); 1501 doAll = true; 1502 } else { 1503 itr = _contour3Ds.find(id); 1504 } 1505 if (itr == _contour3Ds.end()) { 1506 ERROR("Contour3D not found: %s", id.c_str()); 1507 return; 1508 } 1509 1510 do { 1511 itr->second->setColor(color); 1512 } while (doAll && ++itr != _contour3Ds.end()); 1513 _needsRedraw = true; 1514 } 1515 1516 /** 1517 * \brief Turn on/off rendering isosurface edges for the given DataSet 1518 */ 1519 void Renderer::setContour3DEdgeVisibility(const DataSetId& id, bool state) 1520 { 1521 Contour3DHashmap::iterator itr; 1522 1523 bool doAll = false; 1524 1525 if (id.compare("all") == 0) { 1526 itr = _contour3Ds.begin(); 1527 doAll = true; 1528 } else { 1529 itr = _contour3Ds.find(id); 1530 } 1531 if (itr == _contour3Ds.end()) { 1532 ERROR("Contour3D not found: %s", id.c_str()); 1533 return; 1534 } 1535 1536 do { 1537 itr->second->setEdgeVisibility(state); 1538 } while (doAll && ++itr != _contour3Ds.end()); 1539 1540 _needsRedraw = true; 1541 } 1542 1543 /** 1544 * \brief Set the RGB isosurface edge color for the specified DataSet 1545 */ 1546 void Renderer::setContour3DEdgeColor(const DataSetId& id, float color[3]) 1547 { 1548 Contour3DHashmap::iterator itr; 1549 1550 bool doAll = false; 1551 1552 if (id.compare("all") == 0) { 1553 itr = _contour3Ds.begin(); 1554 doAll = true; 1555 } else { 1556 itr = _contour3Ds.find(id); 1557 } 1558 if (itr == _contour3Ds.end()) { 1559 ERROR("Contour3D not found: %s", id.c_str()); 1560 return; 1561 } 1562 1563 do { 1564 itr->second->setEdgeColor(color); 1565 } while (doAll && ++itr != _contour3Ds.end()); 1566 1567 _needsRedraw = true; 1568 } 1569 1570 /** 1571 * \brief Set the isosurface edge width for the specified DataSet (may be a no-op) 1572 * 1573 * If the OpenGL implementation/hardware does not support wide lines, 1574 * this function may not have an effect. 1575 */ 1576 void Renderer::setContour3DEdgeWidth(const DataSetId& id, float edgeWidth) 1577 { 1578 Contour3DHashmap::iterator itr; 1579 1580 bool doAll = false; 1581 1582 if (id.compare("all") == 0) { 1583 itr = _contour3Ds.begin(); 1584 doAll = true; 1585 } else { 1586 itr = _contour3Ds.find(id); 1587 } 1588 if (itr == _contour3Ds.end()) { 1589 ERROR("Contour3D not found: %s", id.c_str()); 1590 return; 1591 } 1592 1593 do { 1594 itr->second->setEdgeWidth(edgeWidth); 1595 } while (doAll && ++itr != _contour3Ds.end()); 1596 1597 _needsRedraw = true; 1598 } 1599 1600 /** 1601 * \brief Set wireframe rendering for the specified DataSet 1602 */ 1603 void Renderer::setContour3DWireframe(const DataSetId& id, bool state) 1604 { 1605 Contour3DHashmap::iterator itr; 1606 1607 bool doAll = false; 1608 1609 if (id.compare("all") == 0) { 1610 itr = _contour3Ds.begin(); 1611 doAll = true; 1612 } else { 1613 itr = _contour3Ds.find(id); 1614 } 1615 if (itr == _contour3Ds.end()) { 1616 ERROR("Contour3D not found: %s", id.c_str()); 1617 return; 1618 } 1619 1620 do { 1621 itr->second->setWireframe(state); 1622 } while (doAll && ++itr != _contour3Ds.end()); 1623 1624 _needsRedraw = true; 1625 } 1626 1627 /** 1628 * \brief Turn contour lighting on/off for the specified DataSet 1629 */ 1630 void Renderer::setContour3DLighting(const DataSetId& id, bool state) 1631 { 1632 Contour3DHashmap::iterator itr; 1633 1634 bool doAll = false; 1635 1636 if (id.compare("all") == 0) { 1637 itr = _contour3Ds.begin(); 1638 doAll = true; 1639 } else { 1640 itr = _contour3Ds.find(id); 1641 } 1642 if (itr == _contour3Ds.end()) { 1643 ERROR("Contour3D not found: %s", id.c_str()); 1644 return; 1645 } 1646 1647 do { 1648 itr->second->setLighting(state); 1649 } while (doAll && ++itr != _contour3Ds.end()); 1201 1650 _needsRedraw = true; 1202 1651 } … … 3402 3851 bounds[5] = -DBL_MAX; 3403 3852 3404 for (Contour2DHashmap::iterator itr = _contours.begin(); 3405 itr != _contours.end(); ++itr) { 3853 for (Contour2DHashmap::iterator itr = _contour2Ds.begin(); 3854 itr != _contour2Ds.end(); ++itr) { 3855 if (!onlyVisible || itr->second->getVisibility()) 3856 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 3857 } 3858 for (Contour3DHashmap::iterator itr = _contour3Ds.begin(); 3859 itr != _contour3Ds.end(); ++itr) { 3406 3860 if (!onlyVisible || itr->second->getVisibility()) 3407 3861 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); … … 3457 3911 void Renderer::updateRanges(bool useCumulative) 3458 3912 { 3459 for (Contour2DHashmap::iterator itr = _contours.begin(); 3460 itr != _contours.end(); ++itr) { 3913 for (Contour2DHashmap::iterator itr = _contour2Ds.begin(); 3914 itr != _contour2Ds.end(); ++itr) { 3915 // Only need to update range if using evenly spaced contours 3916 if (itr->second->getContourList().empty()) { 3917 if (useCumulative) { 3918 itr->second->setContours(itr->second->getNumContours(), _cumulativeDataRange); 3919 } else { 3920 itr->second->setContours(itr->second->getNumContours()); 3921 } 3922 } 3923 } 3924 for (Contour3DHashmap::iterator itr = _contour3Ds.begin(); 3925 itr != _contour3Ds.end(); ++itr) { 3461 3926 // Only need to update range if using evenly spaced contours 3462 3927 if (itr->second->getContourList().empty()) { … … 3656 4121 { 3657 4122 if (id.compare("all") == 0 || getContour2D(id) != NULL) 3658 setContourOpacity(id, opacity); 4123 setContour2DOpacity(id, opacity); 4124 if (id.compare("all") == 0 || getContour3D(id) != NULL) 4125 setContour3DOpacity(id, opacity); 3659 4126 if (id.compare("all") == 0 || getGlyphs(id) != NULL) 3660 4127 setGlyphsOpacity(id, opacity); … … 3694 4161 3695 4162 if (id.compare("all") == 0 || getContour2D(id) != NULL) 3696 setContourVisibility(id, state); 4163 setContour2DVisibility(id, state); 4164 if (id.compare("all") == 0 || getContour3D(id) != NULL) 4165 setContour3DVisibility(id, state); 3697 4166 if (id.compare("all") == 0 || getGlyphs(id) != NULL) 3698 4167 setGlyphsVisibility(id, state); … … 3732 4201 * Mappers already using the PlaneCollection 3733 4202 */ 3734 for (Contour2DHashmap::iterator itr = _contours.begin(); 3735 itr != _contours.end(); ++itr) { 4203 for (Contour2DHashmap::iterator itr = _contour2Ds.begin(); 4204 itr != _contour2Ds.end(); ++itr) { 4205 itr->second->setClippingPlanes(_activeClipPlanes); 4206 } 4207 for (Contour3DHashmap::iterator itr = _contour3Ds.begin(); 4208 itr != _contour3Ds.end(); ++itr) { 3736 4209 itr->second->setClippingPlanes(_activeClipPlanes); 3737 4210 } … … 3756 4229 itr->second->setClippingPlanes(_activeClipPlanes); 3757 4230 } 4231 } 4232 4233 /** 4234 * \brief Control the use of the depth peeling algorithm for transparency 4235 */ 4236 void Renderer::setUseDepthPeeling(bool state) 4237 { 4238 _renderer->SetUseDepthPeeling(state ? 1 : 0); 4239 _needsRedraw = true; 3758 4240 } 3759 4241 -
trunk/packages/vizservers/vtkvis/RpVtkRenderer.h
r2270 r2290 28 28 #include "RpVtkDataSet.h" 29 29 #include "RpContour2D.h" 30 #include "RpContour3D.h" 30 31 #include "RpGlyphs.h" 31 32 #include "RpHeightMap.h" … … 76 77 typedef std::tr1::unordered_map<ColorMapId, ColorMap *> ColorMapHashmap; 77 78 typedef std::tr1::unordered_map<DataSetId, Contour2D *> Contour2DHashmap; 79 typedef std::tr1::unordered_map<DataSetId, Contour3D *> Contour3DHashmap; 78 80 typedef std::tr1::unordered_map<DataSetId, Glyphs *> GlyphsHashmap; 79 81 typedef std::tr1::unordered_map<DataSetId, HeightMap *> HeightMapHashmap; … … 146 148 void setBackgroundColor(float color[3]); 147 149 150 void setUseDepthPeeling(bool state); 151 148 152 bool render(); 149 153 … … 182 186 vtkUnsignedCharArray *imgData); 183 187 184 // Contour plots188 // 2D Contour plots 185 189 186 190 void addContour2D(const DataSetId& id); … … 190 194 Contour2D *getContour2D(const DataSetId& id); 191 195 192 void setContours(const DataSetId& id, int numContours); 193 194 void setContourList(const DataSetId& id, const std::vector<double>& contours); 195 196 void setContourOpacity(const DataSetId& id, double opacity); 197 198 void setContourVisibility(const DataSetId& id, bool state); 199 200 void setContourEdgeColor(const DataSetId& id, float color[3]); 201 202 void setContourEdgeWidth(const DataSetId& id, float edgeWidth); 203 204 void setContourLighting(const DataSetId& id, bool state); 196 void setContour2DContours(const DataSetId& id, int numContours); 197 198 void setContour2DContourList(const DataSetId& id, const std::vector<double>& contours); 199 200 void setContour2DOpacity(const DataSetId& id, double opacity); 201 202 void setContour2DVisibility(const DataSetId& id, bool state); 203 204 void setContour2DEdgeColor(const DataSetId& id, float color[3]); 205 206 void setContour2DEdgeWidth(const DataSetId& id, float edgeWidth); 207 208 void setContour2DLighting(const DataSetId& id, bool state); 209 210 // 3D Contour (isosurface) plots 211 212 void addContour3D(const DataSetId& id); 213 214 void deleteContour3D(const DataSetId& id); 215 216 Contour3D *getContour3D(const DataSetId& id); 217 218 void setContour3DContours(const DataSetId& id, int numContours); 219 220 void setContour3DContourList(const DataSetId& id, const std::vector<double>& contours); 221 222 void setContour3DColorMap(const DataSetId& id, const ColorMapId& colorMapId); 223 224 void setContour3DOpacity(const DataSetId& id, double opacity); 225 226 void setContour3DVisibility(const DataSetId& id, bool state); 227 228 void setContour3DColor(const DataSetId& id, float color[3]); 229 230 void setContour3DEdgeVisibility(const DataSetId& id, bool state); 231 232 void setContour3DEdgeColor(const DataSetId& id, float color[3]); 233 234 void setContour3DEdgeWidth(const DataSetId& id, float edgeWidth); 235 236 void setContour3DWireframe(const DataSetId& id, bool state); 237 238 void setContour3DLighting(const DataSetId& id, bool state); 205 239 206 240 // Glyphs … … 376 410 ColorMapHashmap _colorMaps; 377 411 DataSetHashmap _dataSets; 378 Contour2DHashmap _contours; 412 Contour2DHashmap _contour2Ds; 413 Contour3DHashmap _contour3Ds; 379 414 GlyphsHashmap _glyphs; 380 415 HeightMapHashmap _heightMaps; -
trunk/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp
r2278 r2290 551 551 const char *name = Tcl_GetString(objv[4]); 552 552 g_renderer->addContour2D(name); 553 g_renderer->setContour List(name, contourList);553 g_renderer->setContour2DContourList(name, contourList); 554 554 } else { 555 555 g_renderer->addContour2D("all"); 556 g_renderer->setContour List("all", contourList);556 g_renderer->setContour2DContourList("all", contourList); 557 557 } 558 558 return TCL_OK; … … 570 570 const char *name = Tcl_GetString(objv[4]); 571 571 g_renderer->addContour2D(name); 572 g_renderer->setContour s(name, numContours);572 g_renderer->setContour2DContours(name, numContours); 573 573 } else { 574 574 g_renderer->addContour2D("all"); 575 g_renderer->setContour s("all", numContours);575 g_renderer->setContour2DContours("all", numContours); 576 576 } 577 577 return TCL_OK; … … 621 621 if (objc == 4) { 622 622 const char *name = Tcl_GetString(objv[3]); 623 g_renderer->setContour Lighting(name, state);624 } else { 625 g_renderer->setContour Lighting("all", state);623 g_renderer->setContour2DLighting(name, state); 624 } else { 625 g_renderer->setContour2DLighting("all", state); 626 626 } 627 627 return TCL_OK; … … 640 640 if (objc == 6) { 641 641 const char *name = Tcl_GetString(objv[5]); 642 g_renderer->setContour EdgeColor(name, color);643 } else { 644 g_renderer->setContour EdgeColor("all", color);642 g_renderer->setContour2DEdgeColor(name, color); 643 } else { 644 g_renderer->setContour2DEdgeColor("all", color); 645 645 } 646 646 return TCL_OK; … … 657 657 if (objc == 4) { 658 658 const char *name = Tcl_GetString(objv[3]); 659 g_renderer->setContour EdgeWidth(name, width);660 } else { 661 g_renderer->setContour EdgeWidth("all", width);659 g_renderer->setContour2DEdgeWidth(name, width); 660 } else { 661 g_renderer->setContour2DEdgeWidth("all", width); 662 662 } 663 663 return TCL_OK; … … 674 674 if (objc == 4) { 675 675 const char *name = Tcl_GetString(objv[3]); 676 g_renderer->setContour Opacity(name, opacity);677 } else { 678 g_renderer->setContour Opacity("all", opacity);676 g_renderer->setContour2DOpacity(name, opacity); 677 } else { 678 g_renderer->setContour2DOpacity("all", opacity); 679 679 } 680 680 return TCL_OK; … … 691 691 if (objc == 4) { 692 692 const char *name = Tcl_GetString(objv[3]); 693 g_renderer->setContour Visibility(name, state);694 } else { 695 g_renderer->setContour Visibility("all", state);693 g_renderer->setContour2DVisibility(name, state); 694 } else { 695 g_renderer->setContour2DVisibility("all", state); 696 696 } 697 697 return TCL_OK; … … 724 724 725 725 static int 726 Contour3DAddContourListOp(ClientData clientData, Tcl_Interp *interp, int objc, 727 Tcl_Obj *const *objv) 728 { 729 std::vector<double> contourList; 730 731 int clistc; 732 Tcl_Obj **clistv; 733 734 if (Tcl_ListObjGetElements(interp, objv[3], &clistc, &clistv) != TCL_OK) { 735 return TCL_ERROR; 736 } 737 738 for (int i = 0; i < clistc; i++) { 739 double val; 740 if (Tcl_GetDoubleFromObj(interp, clistv[i], &val) != TCL_OK) { 741 return TCL_ERROR; 742 } 743 contourList.push_back(val); 744 } 745 746 if (objc == 5) { 747 const char *name = Tcl_GetString(objv[4]); 748 g_renderer->addContour3D(name); 749 g_renderer->setContour3DContourList(name, contourList); 750 } else { 751 g_renderer->addContour3D("all"); 752 g_renderer->setContour3DContourList("all", contourList); 753 } 754 return TCL_OK; 755 } 756 757 static int 758 Contour3DAddNumContoursOp(ClientData clientData, Tcl_Interp *interp, int objc, 759 Tcl_Obj *const *objv) 760 { 761 int numContours; 762 if (Tcl_GetIntFromObj(interp, objv[3], &numContours) != TCL_OK) { 763 return TCL_ERROR; 764 } 765 if (objc == 5) { 766 const char *name = Tcl_GetString(objv[4]); 767 g_renderer->addContour3D(name); 768 g_renderer->setContour3DContours(name, numContours); 769 } else { 770 g_renderer->addContour3D("all"); 771 g_renderer->setContour3DContours("all", numContours); 772 } 773 return TCL_OK; 774 } 775 776 static Rappture::CmdSpec contour3dAddOps[] = { 777 {"contourlist", 1, Contour3DAddContourListOp, 4, 5, "contourList ?dataSetName?"}, 778 {"numcontours", 1, Contour3DAddNumContoursOp, 4, 5, "numContours ?dataSetName?"} 779 }; 780 static int nContour3dAddOps = NumCmdSpecs(contour3dAddOps); 781 782 static int 783 Contour3DAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 784 Tcl_Obj *const *objv) 785 { 786 Tcl_ObjCmdProc *proc; 787 788 proc = Rappture::GetOpFromObj(interp, nContour3dAddOps, contour3dAddOps, 789 Rappture::CMDSPEC_ARG2, objc, objv, 0); 790 if (proc == NULL) { 791 return TCL_ERROR; 792 } 793 return (*proc) (clientData, interp, objc, objv); 794 } 795 796 static int 797 Contour3DColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 798 Tcl_Obj *const *objv) 799 { 800 float color[3]; 801 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 802 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 803 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 804 return TCL_ERROR; 805 } 806 if (objc == 6) { 807 const char *name = Tcl_GetString(objv[5]); 808 g_renderer->setContour3DColor(name, color); 809 } else { 810 g_renderer->setContour3DColor("all", color); 811 } 812 return TCL_OK; 813 } 814 815 static int 816 Contour3DColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc, 817 Tcl_Obj *const *objv) 818 { 819 const char *colorMapName = Tcl_GetString(objv[2]); 820 if (objc == 4) { 821 const char *dataSetName = Tcl_GetString(objv[3]); 822 g_renderer->setContour3DColorMap(dataSetName, colorMapName); 823 } else { 824 g_renderer->setContour3DColorMap("all", colorMapName); 825 } 826 return TCL_OK; 827 } 828 829 static int 830 Contour3DDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 831 Tcl_Obj *const *objv) 832 { 833 if (objc == 3) { 834 const char *name = Tcl_GetString(objv[2]); 835 g_renderer->deleteContour3D(name); 836 } else { 837 g_renderer->deleteContour3D("all"); 838 } 839 return TCL_OK; 840 } 841 842 static int 843 Contour3DEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc, 844 Tcl_Obj *const *objv) 845 { 846 bool state; 847 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 848 return TCL_ERROR; 849 } 850 if (objc == 4) { 851 const char *name = Tcl_GetString(objv[3]); 852 g_renderer->setContour3DEdgeVisibility(name, state); 853 } else { 854 g_renderer->setContour3DEdgeVisibility("all", state); 855 } 856 return TCL_OK; 857 } 858 859 static int 860 Contour3DLightingOp(ClientData clientData, Tcl_Interp *interp, int objc, 861 Tcl_Obj *const *objv) 862 { 863 bool state; 864 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 865 return TCL_ERROR; 866 } 867 if (objc == 4) { 868 const char *name = Tcl_GetString(objv[3]); 869 g_renderer->setContour3DLighting(name, state); 870 } else { 871 g_renderer->setContour3DLighting("all", state); 872 } 873 return TCL_OK; 874 } 875 876 static int 877 Contour3DLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 878 Tcl_Obj *const *objv) 879 { 880 float color[3]; 881 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 882 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 883 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 884 return TCL_ERROR; 885 } 886 if (objc == 6) { 887 const char *name = Tcl_GetString(objv[5]); 888 g_renderer->setContour3DEdgeColor(name, color); 889 } else { 890 g_renderer->setContour3DEdgeColor("all", color); 891 } 892 return TCL_OK; 893 } 894 895 static int 896 Contour3DLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc, 897 Tcl_Obj *const *objv) 898 { 899 float width; 900 if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) { 901 return TCL_ERROR; 902 } 903 if (objc == 4) { 904 const char *name = Tcl_GetString(objv[3]); 905 g_renderer->setContour3DEdgeWidth(name, width); 906 } else { 907 g_renderer->setContour3DEdgeWidth("all", width); 908 } 909 return TCL_OK; 910 } 911 912 static int 913 Contour3DOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc, 914 Tcl_Obj *const *objv) 915 { 916 double opacity; 917 if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) { 918 return TCL_ERROR; 919 } 920 if (objc == 4) { 921 const char *name = Tcl_GetString(objv[3]); 922 g_renderer->setContour3DOpacity(name, opacity); 923 } else { 924 g_renderer->setContour3DOpacity("all", opacity); 925 } 926 return TCL_OK; 927 } 928 929 static int 930 Contour3DVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 931 Tcl_Obj *const *objv) 932 { 933 bool state; 934 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 935 return TCL_ERROR; 936 } 937 if (objc == 4) { 938 const char *name = Tcl_GetString(objv[3]); 939 g_renderer->setContour3DVisibility(name, state); 940 } else { 941 g_renderer->setContour3DVisibility("all", state); 942 } 943 return TCL_OK; 944 } 945 946 static int 947 Contour3DWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc, 948 Tcl_Obj *const *objv) 949 { 950 bool state; 951 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 952 return TCL_ERROR; 953 } 954 if (objc == 4) { 955 const char *name = Tcl_GetString(objv[3]); 956 g_renderer->setContour3DWireframe(name, state); 957 } else { 958 g_renderer->setContour3DWireframe("all", state); 959 } 960 return TCL_OK; 961 } 962 963 static Rappture::CmdSpec contour3dOps[] = { 964 {"add", 1, Contour3DAddOp, 4, 5, "oper value ?dataSetName?"}, 965 {"color", 6, Contour3DColorOp, 5, 6, "r g b ?dataSetName?"}, 966 {"colormap", 6, Contour3DColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 967 {"delete", 1, Contour3DDeleteOp, 2, 3, "?dataSetName?"}, 968 {"edges", 1, Contour3DEdgeVisibilityOp, 3, 4, "bool ?dataSetName?"}, 969 {"lighting", 3, Contour3DLightingOp, 3, 4, "bool ?dataSetName?"}, 970 {"linecolor", 5, Contour3DLineColorOp, 5, 6, "r g b ?dataSetName?"}, 971 {"linewidth", 5, Contour3DLineWidthOp, 3, 4, "width ?dataSetName?"}, 972 {"opacity", 1, Contour3DOpacityOp, 3, 4, "value ?dataSetName?"}, 973 {"visible", 1, Contour3DVisibleOp, 3, 4, "bool ?dataSetName?"}, 974 {"wireframe", 1, Contour3DWireframeOp, 3, 4, "bool ?dataSetName?"} 975 }; 976 static int nContour3dOps = NumCmdSpecs(contour3dOps); 977 978 static int 979 Contour3DCmd(ClientData clientData, Tcl_Interp *interp, int objc, 980 Tcl_Obj *const *objv) 981 { 982 Tcl_ObjCmdProc *proc; 983 984 proc = Rappture::GetOpFromObj(interp, nContour3dOps, contour3dOps, 985 Rappture::CMDSPEC_ARG1, objc, objv, 0); 986 if (proc == NULL) { 987 return TCL_ERROR; 988 } 989 return (*proc) (clientData, interp, objc, objv); 990 } 991 992 static int 726 993 DataSetAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 727 994 Tcl_Obj *const *objv) … … 758 1025 TRACE("bytesRead: %d", ofs); 759 1026 if (bytesRead < 0) { 1027 free(data); 760 1028 return TCL_ERROR; 761 1029 } … … 764 1032 TRACE("bytesRead: %d '%c'", bytesRead, data[0]); 765 1033 if (bytesRead < (size_t)nbytes) { 1034 free(data); 766 1035 return TCL_ERROR; 767 1036 } … … 1886 2155 1887 2156 proc = Rappture::GetOpFromObj(interp, nPolyDataOps, polyDataOps, 2157 Rappture::CMDSPEC_ARG1, objc, objv, 0); 2158 if (proc == NULL) { 2159 return TCL_ERROR; 2160 } 2161 return (*proc) (clientData, interp, objc, objv); 2162 } 2163 2164 static int 2165 RendererDepthPeelingOp(ClientData clientData, Tcl_Interp *interp, int objc, 2166 Tcl_Obj *const *objv) 2167 { 2168 bool state; 2169 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 2170 return TCL_ERROR; 2171 } 2172 g_renderer->setUseDepthPeeling(state); 2173 return TCL_OK; 2174 } 2175 2176 static Rappture::CmdSpec rendererOps[] = { 2177 {"depthpeel", 1, RendererDepthPeelingOp, 3, 3, "bool"} 2178 }; 2179 static int nRendererOps = NumCmdSpecs(rendererOps); 2180 2181 static int 2182 RendererCmd(ClientData clientData, Tcl_Interp *interp, int objc, 2183 Tcl_Obj *const *objv) 2184 { 2185 Tcl_ObjCmdProc *proc; 2186 2187 proc = Rappture::GetOpFromObj(interp, nRendererOps, rendererOps, 1888 2188 Rappture::CMDSPEC_ARG1, objc, objv, 0); 1889 2189 if (proc == NULL) { … … 2232 2532 Tcl_CreateObjCommand(interp, "colormap", ColorMapCmd, NULL, NULL); 2233 2533 Tcl_CreateObjCommand(interp, "contour2d", Contour2DCmd, NULL, NULL); 2534 Tcl_CreateObjCommand(interp, "contour3d", Contour3DCmd, NULL, NULL); 2234 2535 Tcl_CreateObjCommand(interp, "dataset", DataSetCmd, NULL, NULL); 2235 2536 Tcl_CreateObjCommand(interp, "glyphs", GlyphsCmd, NULL, NULL); … … 2238 2539 Tcl_CreateObjCommand(interp, "polydata", PolyDataCmd, NULL, NULL); 2239 2540 Tcl_CreateObjCommand(interp, "pseudocolor", PseudoColorCmd, NULL, NULL); 2541 Tcl_CreateObjCommand(interp, "renderer", RendererCmd, NULL, NULL); 2240 2542 Tcl_CreateObjCommand(interp, "screen", ScreenCmd, NULL, NULL); 2241 2543 Tcl_CreateObjCommand(interp, "volume", VolumeCmd, NULL, NULL); … … 2254 2556 Tcl_DeleteCommand(interp, "colormap"); 2255 2557 Tcl_DeleteCommand(interp, "contour2d"); 2558 Tcl_DeleteCommand(interp, "contour3d"); 2256 2559 Tcl_DeleteCommand(interp, "dataset"); 2257 2560 Tcl_DeleteCommand(interp, "glyphs"); … … 2260 2563 Tcl_DeleteCommand(interp, "polydata"); 2261 2564 Tcl_DeleteCommand(interp, "pseudocolor"); 2565 Tcl_DeleteCommand(interp, "renderer"); 2262 2566 Tcl_DeleteCommand(interp, "screen"); 2263 2567 Tcl_DeleteCommand(interp, "volume"); -
trunk/packages/vizservers/vtkvis/protocol.txt
r2269 r2290 7 7 screen bgcolor <r> <g> <b> 8 8 screen size <width> <height> 9 10 renderer depthpeel <bool> 11 Set use of depth peeling algorithm for transparency 9 12 10 13 axis color <r> <g> <b> … … 73 76 contour2d opacity <val> <?datasetName?> 74 77 contour2d visible <bool> <?datasetName?> 78 79 contour3d add numcontours <n> <?datasetName?> 80 Generate evenly spaced contours including range endpoints. See also 81 'dataset maprange' command. 82 contour3d add contourlist <list> <?datasetName?> 83 list = {isoval1 isoval2 isoval3...} 84 contour3d color r g b <?datasetName?> 85 contour3d colormap <colorMapName> <?dataSetName?> 86 contour3d delete <?datasetName?> 87 contour3d edges <bool> <?datasetName?> 88 contour3d lighting <bool> <?datasetName?> 89 contour3d linecolor <r> <g> <b> <?datasetName?> 90 contour3d linewidth <val> <?datasetName?> 91 contour3d opacity <val> <?datasetName?> 92 contour3d visible <bool> <?datasetName?> 93 contour3d wireframe <bool> <?datasetName?> 75 94 76 95 glyphs add <?dataSetName?>
Note: See TracChangeset
for help on using the changeset viewer.