- Timestamp:
- Sep 1, 2011, 3:58:42 PM (13 years ago)
- Location:
- trunk/packages/vizservers/vtkvis
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/vtkvis/RpHeightMap.cpp
r2423 r2457 21 21 #include <vtkDelaunay2D.h> 22 22 #include <vtkDelaunay3D.h> 23 #include <vtkProbeFilter.h>24 23 #include <vtkGaussianSplatter.h> 25 24 #include <vtkExtractVOI.h> … … 29 28 #include <vtkWarpScalar.h> 30 29 #include <vtkPropAssembly.h> 30 #include <vtkCutter.h> 31 #include <vtkPlane.h> 31 32 32 33 #include "RpHeightMap.h" … … 278 279 mesher->GetOutput()->GetBounds(bounds); 279 280 // Sample a plane within the grid bounding box 280 if (_probeFilter == NULL) 281 _probeFilter = vtkSmartPointer<vtkProbeFilter>::New(); 282 _probeFilter->SetSourceConnection(mesher->GetOutputPort()); 283 vtkSmartPointer<vtkImageData> imageData = vtkSmartPointer<vtkImageData>::New(); 284 int xdim = 256; 285 int ydim = 256; 286 int zdim = 1; 287 imageData->SetDimensions(xdim, ydim, zdim); 288 imageData->SetOrigin(bounds[0], bounds[2], bounds[4] + (bounds[5]-bounds[4])/2.); 289 imageData->SetSpacing((bounds[1]-bounds[0])/((double)(xdim-1)), 290 (bounds[3]-bounds[2])/((double)(ydim-1)), 291 0); 292 _probeFilter->SetInput(imageData); 281 vtkSmartPointer<vtkCutter> cutter = vtkSmartPointer<vtkCutter>::New(); 282 cutter->SetInputConnection(mesher->GetOutputPort()); 283 if (_cutPlane == NULL) { 284 _cutPlane = vtkSmartPointer<vtkPlane>::New(); 285 } 286 _cutPlane->SetNormal(0, 0, 1); 287 _cutPlane->SetOrigin(0, 288 0, 289 bounds[4] + (bounds[5]-bounds[4])/2.); 290 cutter->SetCutFunction(_cutPlane); 293 291 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 294 292 gf->UseStripsOn(); 295 gf->SetInputConnection( _probeFilter->GetOutputPort());293 gf->SetInputConnection(cutter->GetOutputPort()); 296 294 #else 297 295 if (_pointSplatter == NULL) … … 351 349 _volumeSlicer->SetSampleRate(1, 1, 1); 352 350 gf->SetInputConnection(_volumeSlicer->GetOutputPort()); 353 } else if ( imageData == NULL) {354 // structured grid, unstructured grid, or rectilinear grid351 } else if (!_dataSet->is2D() && imageData == NULL) { 352 // 3D structured grid, unstructured grid, or rectilinear grid 355 353 double bounds[6]; 356 354 ds->GetBounds(bounds); 357 355 // Sample a plane within the grid bounding box 358 if (_probeFilter == NULL) 359 _probeFilter = vtkSmartPointer<vtkProbeFilter>::New(); 360 _probeFilter->SetSource(ds); 361 vtkSmartPointer<vtkImageData> imageData = vtkSmartPointer<vtkImageData>::New(); 362 DataSet::PrincipalPlane plane; 363 double offset; 364 int xdim = 256; 365 int ydim = 256; 366 int zdim = 1; 367 double origin[3]; 368 double spacing[3]; 369 origin[0] = bounds[0]; 370 origin[1] = bounds[2]; 371 origin[2] = bounds[4] + (bounds[5]-bounds[4])/2.; 372 spacing[0] = (bounds[1]-bounds[0])/((double)(xdim-1)); 373 spacing[1] = (bounds[3]-bounds[2])/((double)(ydim-1)); 374 spacing[2] = 0; 375 if (_dataSet->is2D(&plane, &offset)) { 376 if (plane == DataSet::PLANE_ZY) { 377 xdim = 1; 378 zdim = 256; 379 origin[2] = bounds[4]; 380 spacing[0] = 0; 381 spacing[2] = (bounds[5]-bounds[4])/((double)(zdim-1)); 382 _sliceAxis = X_AXIS; 383 } else if (plane == DataSet::PLANE_XZ) { 384 ydim = 1; 385 zdim = 256; 386 origin[2] = bounds[4]; 387 spacing[1] = 0; 388 spacing[2] = (bounds[5]-bounds[4])/((double)(zdim-1)); 389 _sliceAxis = Y_AXIS; 390 } 356 vtkSmartPointer<vtkCutter> cutter = vtkSmartPointer<vtkCutter>::New(); 357 cutter->SetInput(ds); 358 if (_cutPlane == NULL) { 359 _cutPlane = vtkSmartPointer<vtkPlane>::New(); 391 360 } 392 imageData->SetDimensions(xdim, ydim, zdim); 393 imageData->SetOrigin(origin); 394 imageData->SetSpacing(spacing); 395 _probeFilter->SetInput(imageData); 396 gf->SetInputConnection(_probeFilter->GetOutputPort()); 361 _cutPlane->SetNormal(0, 0, 1); 362 _cutPlane->SetOrigin(0, 363 0, 364 bounds[4] + (bounds[5]-bounds[4])/2.); 365 cutter->SetCutFunction(_cutPlane); 366 gf->SetInputConnection(cutter->GetOutputPort()); 397 367 } else { 398 // 2D imagedata368 // 2D data 399 369 gf->SetInput(ds); 400 370 } … … 556 526 557 527 if (_volumeSlicer == NULL && 558 _ probeFilter== NULL) {528 _cutPlane == NULL) { 559 529 WARN("Called before update() or DataSet is not a volume"); 560 530 return; 561 }562 563 int dims[3];564 565 if (_pointSplatter != NULL) {566 _pointSplatter->GetSampleDimensions(dims);567 } else {568 vtkImageData *imageData = vtkImageData::SafeDownCast(_dataSet->getVtkDataSet());569 if (imageData == NULL) {570 if (_probeFilter != NULL) {571 imageData = vtkImageData::SafeDownCast(_probeFilter->GetInput());572 if (imageData == NULL) {573 ERROR("Couldn't get probe filter input image");574 return;575 }576 } else {577 ERROR("Not a volume data set");578 return;579 }580 }581 imageData->GetDimensions(dims);582 531 } 583 532 … … 600 549 } 601 550 602 if (_probeFilter != NULL) { 603 vtkImageData *imageData = vtkImageData::SafeDownCast(_probeFilter->GetInput()); 551 if (_cutPlane != NULL) { 604 552 double bounds[6]; 605 assert(vtkDataSet::SafeDownCast(_probeFilter->GetSource()) != NULL); 606 vtkDataSet::SafeDownCast(_probeFilter->GetSource())->GetBounds(bounds); 607 int dim = 256; 608 553 _dataSet->getBounds(bounds); 609 554 switch (axis) { 610 555 case X_AXIS: 611 imageData->SetDimensions(1, dim, dim); 612 imageData->SetOrigin(bounds[0] + (bounds[1]-bounds[0])*ratio, bounds[2], bounds[4]); 613 imageData->SetSpacing(0, 614 (bounds[3]-bounds[2])/((double)(dim-1)), 615 (bounds[5]-bounds[4])/((double)(dim-1))); 556 _cutPlane->SetNormal(1, 0, 0); 557 _cutPlane->SetOrigin(bounds[0] + (bounds[1]-bounds[0]) * ratio, 558 0, 559 0); 616 560 break; 617 561 case Y_AXIS: 618 imageData->SetDimensions(dim, 1, dim); 619 imageData->SetOrigin(bounds[0], bounds[2] + (bounds[3]-bounds[2])*ratio, bounds[4]); 620 imageData->SetSpacing((bounds[1]-bounds[0])/((double)(dim-1)), 621 0, 622 (bounds[5]-bounds[4])/((double)(dim-1))); 562 _cutPlane->SetNormal(0, 1, 0); 563 _cutPlane->SetOrigin(0, 564 bounds[2] + (bounds[3]-bounds[2]) * ratio, 565 0); 623 566 break; 624 567 case Z_AXIS: 625 imageData->SetDimensions(dim, dim, 1); 626 imageData->SetOrigin(bounds[0], bounds[2], bounds[4] + (bounds[5]-bounds[4])*ratio); 627 imageData->SetSpacing((bounds[1]-bounds[0])/((double)(dim-1)), 628 (bounds[3]-bounds[2])/((double)(dim-1)), 629 0); 568 _cutPlane->SetNormal(0, 0, 1); 569 _cutPlane->SetOrigin(0, 570 0, 571 bounds[4] + (bounds[5]-bounds[4]) * ratio); 630 572 break; 631 573 default: … … 634 576 } 635 577 } else { 578 int dims[3]; 579 if (_pointSplatter != NULL) { 580 _pointSplatter->GetSampleDimensions(dims); 581 } else { 582 vtkImageData *imageData = vtkImageData::SafeDownCast(_dataSet->getVtkDataSet()); 583 if (imageData == NULL) { 584 ERROR("Not a volume data set"); 585 return; 586 } 587 imageData->GetDimensions(dims); 588 } 636 589 int voi[6]; 637 590 -
trunk/packages/vizservers/vtkvis/RpHeightMap.h
r2423 r2457 12 12 #include <vtkAlgorithmOutput.h> 13 13 #include <vtkContourFilter.h> 14 #include <vtkProbeFilter.h>15 14 #include <vtkLookupTable.h> 16 15 #include <vtkDataSetMapper.h> … … 22 21 #include <vtkAssembly.h> 23 22 #include <vtkPolyData.h> 23 #include <vtkPlane.h> 24 24 25 25 #include <vector> … … 131 131 vtkSmartPointer<vtkPolyDataMapper> _contourMapper; 132 132 vtkSmartPointer<vtkGaussianSplatter> _pointSplatter; 133 vtkSmartPointer<vtkProbeFilter> _probeFilter;134 133 vtkSmartPointer<vtkExtractVOI> _volumeSlicer; 134 vtkSmartPointer<vtkPlane> _cutPlane; 135 135 vtkSmartPointer<vtkWarpScalar> _warp; 136 136 vtkSmartPointer<vtkActor> _dsActor; -
trunk/packages/vizservers/vtkvis/RpVtkDataSet.cpp
r2455 r2457 182 182 { 183 183 TRACE("DataSet class: %s", _dataSet->GetClassName()); 184 185 TRACE("DataSet memory: %g MiB", _dataSet->GetActualMemorySize()/1024.); 184 186 185 187 double bounds[6]; … … 482 484 if (_dataSet != NULL) { 483 485 if (_dataSet->GetPointData() != NULL) { 484 if (_dataSet->GetPointData()->SetActiveScalars(name) >= 0) 486 if (_dataSet->GetPointData()->SetActiveScalars(name) >= 0) { 487 TRACE("Set active point data scalars to %s", name); 485 488 found = true; 489 } 486 490 } 487 491 if (_dataSet->GetCellData() != NULL) { 488 if (_dataSet->GetCellData()->SetActiveScalars(name) >= 0) 492 if (_dataSet->GetCellData()->SetActiveScalars(name) >= 0) { 493 TRACE("Set active cell data scalars to %s", name); 489 494 found = true; 490 } 491 } 495 } 496 } 497 } 498 #ifdef WANT_TRACE 499 if (_dataSet->GetPointData() != NULL) { 500 if (_dataSet->GetPointData()->GetScalars() != NULL) { 501 TRACE("Point data scalars: %s", _dataSet->GetPointData()->GetScalars()->GetName()); 502 } else { 503 TRACE("NULL point data scalars"); 504 } 505 } 506 if (_dataSet->GetCellData() != NULL) { 507 if (_dataSet->GetCellData()->GetScalars() != NULL) { 508 TRACE("Cell data scalars: %s", _dataSet->GetCellData()->GetScalars()->GetName()); 509 } else { 510 TRACE("NULL cell data scalars"); 511 } 512 } 513 #endif 492 514 return found; 493 515 } … … 501 523 if (_dataSet != NULL) { 502 524 if (_dataSet->GetPointData() != NULL) { 503 if (_dataSet->GetPointData()->SetActiveVectors(name) >= 0) 525 if (_dataSet->GetPointData()->SetActiveVectors(name) >= 0) { 526 TRACE("Set active point data vectors to %s", name); 504 527 found = true; 528 } 505 529 } 506 530 if (_dataSet->GetCellData() != NULL) { 507 if (_dataSet->GetCellData()->SetActiveVectors(name) >= 0) 531 if (_dataSet->GetCellData()->SetActiveVectors(name) >= 0) { 532 TRACE("Set active cell data vectors to %s", name); 508 533 found = true; 509 } 510 } 534 } 535 } 536 } 537 511 538 return found; 512 539 }
Note: See TracChangeset
for help on using the changeset viewer.