Changeset 3189 for trunk/packages/vizservers/vtkvis/RpHeightMap.cpp
- Timestamp:
- Nov 15, 2012 6:18:44 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/vtkvis/RpHeightMap.cpp
r3177 r3189 8 8 #include <cassert> 9 9 10 #include <vtkVersion.h> 11 #if (VTK_MAJOR_VERSION >= 6) 12 #define USE_VTK6 13 #endif 10 14 #include <vtkDataSet.h> 11 15 #include <vtkPointData.h> … … 189 193 cellToPtData = 190 194 vtkSmartPointer<vtkCellDataToPointData>::New(); 195 #ifdef USE_VTK6 196 cellToPtData->SetInputData(ds); 197 #else 191 198 cellToPtData->SetInput(ds); 199 #endif 192 200 //cellToPtData->PassCellDataOn(); 193 201 cellToPtData->Update(); … … 234 242 mesher->SetTransform(trans); 235 243 } 244 #ifdef USE_VTK6 245 mesher->SetInputData(pd); 246 #else 236 247 mesher->SetInput(pd); 248 #endif 237 249 vtkAlgorithmOutput *warpOutput = initWarp(mesher->GetOutputPort()); 238 250 _dsMapper->SetInputConnection(warpOutput); … … 243 255 if (_volumeSlicer == NULL) 244 256 _volumeSlicer = vtkSmartPointer<vtkExtractVOI>::New(); 257 #ifdef USE_VTK6 258 _pointSplatter->SetInputData(pd); 259 #else 245 260 _pointSplatter->SetInput(pd); 261 #endif 246 262 int dims[3]; 247 263 _pointSplatter->GetSampleDimensions(dims); … … 281 297 // Result of Delaunay3D mesher is unstructured grid 282 298 vtkSmartPointer<vtkDelaunay3D> mesher = vtkSmartPointer<vtkDelaunay3D>::New(); 299 #ifdef USE_VTK6 300 mesher->SetInputData(pd); 301 #else 283 302 mesher->SetInput(pd); 303 #endif 284 304 // Run the mesher 285 305 mesher->Update(); … … 304 324 if (_pointSplatter == NULL) 305 325 _pointSplatter = vtkSmartPointer<vtkGaussianSplatter>::New(); 326 #ifdef USE_VTK6 327 _pointSplatter->SetInputData(pd); 328 #else 306 329 _pointSplatter->SetInput(pd); 330 #endif 307 331 int dims[3]; 308 332 _pointSplatter->GetSampleDimensions(dims); … … 337 361 _contourFilter->SetInputConnection(warpOutput); 338 362 } else { 363 #ifdef USE_VTK6 364 _dsMapper->SetInputData(pd); 365 _contourFilter->SetInputData(pd); 366 #else 339 367 _dsMapper->SetInput(pd); 340 368 _contourFilter->SetInput(pd); 369 #endif 370 341 371 } 342 372 } … … 354 384 imageData->GetDimensions(dims); 355 385 TRACE("Image data dimensions: %d %d %d", dims[0], dims[1], dims[2]); 386 #ifdef USE_VTK6 387 _volumeSlicer->SetInputData(ds); 388 #else 356 389 _volumeSlicer->SetInput(ds); 390 #endif 357 391 _volumeSlicer->SetVOI(0, dims[0]-1, 0, dims[1]-1, (dims[2]-1)/2, (dims[2]-1)/2); 358 392 _volumeSlicer->SetSampleRate(1, 1, 1); … … 364 398 // Sample a plane within the grid bounding box 365 399 vtkSmartPointer<vtkCutter> cutter = vtkSmartPointer<vtkCutter>::New(); 400 #ifdef USE_VTK6 401 cutter->SetInputData(ds); 402 #else 366 403 cutter->SetInput(ds); 404 #endif 367 405 if (_cutPlane == NULL) { 368 406 _cutPlane = vtkSmartPointer<vtkPlane>::New(); … … 376 414 } else { 377 415 // 2D data 416 #ifdef USE_VTK6 417 gf->SetInputData(ds); 418 #else 378 419 gf->SetInput(ds); 420 #endif 379 421 } 380 422 vtkAlgorithmOutput *warpOutput = initWarp(gf->GetOutputPort()); … … 424 466 } 425 467 468 //setAspect(1.0); 469 426 470 _dsActor->SetMapper(_dsMapper); 427 471 428 472 _dsMapper->Update(); 429 473 _contourMapper->Update(); 474 } 475 476 void HeightMap::setAspect(double aspect) 477 { 478 double bounds[6]; 479 vtkDataSet *ds = _dataSet->getVtkDataSet(); 480 ds->GetBounds(bounds); 481 double size[3]; 482 size[0] = bounds[1] - bounds[0]; 483 size[1] = bounds[3] - bounds[2]; 484 size[2] = bounds[5] - bounds[4]; 485 double scale[3]; 486 scale[0] = scale[1] = scale[2] = 1.; 487 488 if (aspect == 1.0) { 489 // Square 490 switch (_sliceAxis) { 491 case X_AXIS: { 492 if (size[1] > size[2] && size[2] > 1.0e-6) { 493 scale[2] = size[1] / size[2]; 494 } else if (size[2] > size[1] && size[1] > 1.0e-6) { 495 scale[1] = size[2] / size[1]; 496 } 497 } 498 break; 499 case Y_AXIS: { 500 if (size[0] > size[2] && size[2] > 1.0e-6) { 501 scale[2] = size[0] / size[2]; 502 } else if (size[2] > size[0] && size[0] > 1.0e-6) { 503 scale[0] = size[2] / size[0]; 504 } 505 } 506 break; 507 case Z_AXIS: { 508 if (size[0] > size[1] && size[1] > 1.0e-6) { 509 scale[1] = size[0] / size[1]; 510 } else if (size[1] > size[0] && size[0] > 1.0e-6) { 511 scale[0] = size[1] / size[0]; 512 } 513 } 514 break; 515 } 516 } else if (aspect != 0.0) { 517 switch (_sliceAxis) { 518 case X_AXIS: { 519 if (aspect > 1.0) { 520 if (size[2] > size[1]) { 521 scale[1] = (size[2] / aspect) / size[1]; 522 } else { 523 scale[2] = (size[1] * aspect) / size[2]; 524 } 525 } else { 526 if (size[1] > size[2]) { 527 scale[2] = (size[1] * aspect) / size[2]; 528 } else { 529 scale[1] = (size[2] / aspect) / size[1]; 530 } 531 } 532 } 533 break; 534 case Y_AXIS: { 535 if (aspect > 1.0) { 536 if (size[0] > size[2]) { 537 scale[2] = (size[0] / aspect) / size[2]; 538 } else { 539 scale[0] = (size[2] * aspect) / size[0]; 540 } 541 } else { 542 if (size[2] > size[0]) { 543 scale[0] = (size[2] * aspect) / size[0]; 544 } else { 545 scale[2] = (size[0] / aspect) / size[2]; 546 } 547 } 548 } 549 break; 550 case Z_AXIS: { 551 if (aspect > 1.0) { 552 if (size[0] > size[1]) { 553 scale[1] = (size[0] / aspect) / size[1]; 554 } else { 555 scale[0] = (size[1] * aspect) / size[0]; 556 } 557 } else { 558 if (size[1] > size[0]) { 559 scale[0] = (size[1] * aspect) / size[0]; 560 } else { 561 scale[1] = (size[0] / aspect) / size[1]; 562 } 563 } 564 } 565 break; 566 } 567 } 568 569 TRACE("obj %g,%g,%g", size[0], size[1], size[2]); 570 TRACE("Setting scale to %g,%g,%g", scale[0], scale[1], scale[2]); 571 setScale(scale); 430 572 } 431 573 … … 483 625 _warp->UseNormalOn(); 484 626 _warp->SetScaleFactor(_warpScale * _dataScale); 627 #ifdef USE_VTK6 628 _warp->SetInputData(pdInput); 629 #else 485 630 _warp->SetInput(pdInput); 631 #endif 486 632 return _warp->GetOutputPort(); 487 633 }
Note: See TracChangeset
for help on using the changeset viewer.