Ignore:
Timestamp:
Nov 15, 2012 6:18:44 PM (11 years ago)
Author:
ldelgass
Message:

Adopt API changes for upcoming VTK 6.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/vtkvis/RpHeightMap.cpp

    r3177 r3189  
    88#include <cassert>
    99
     10#include <vtkVersion.h>
     11#if (VTK_MAJOR_VERSION >= 6)
     12#define USE_VTK6
     13#endif
    1014#include <vtkDataSet.h>
    1115#include <vtkPointData.h>
     
    189193                cellToPtData =
    190194                    vtkSmartPointer<vtkCellDataToPointData>::New();
     195#ifdef USE_VTK6
     196                cellToPtData->SetInputData(ds);
     197#else
    191198                cellToPtData->SetInput(ds);
     199#endif
    192200                //cellToPtData->PassCellDataOn();
    193201                cellToPtData->Update();
     
    234242                        mesher->SetTransform(trans);
    235243                    }
     244#ifdef USE_VTK6
     245                    mesher->SetInputData(pd);
     246#else
    236247                    mesher->SetInput(pd);
     248#endif
    237249                    vtkAlgorithmOutput *warpOutput = initWarp(mesher->GetOutputPort());
    238250                    _dsMapper->SetInputConnection(warpOutput);
     
    243255                    if (_volumeSlicer == NULL)
    244256                        _volumeSlicer = vtkSmartPointer<vtkExtractVOI>::New();
     257#ifdef USE_VTK6
     258                    _pointSplatter->SetInputData(pd);
     259#else
    245260                    _pointSplatter->SetInput(pd);
     261#endif
    246262                    int dims[3];
    247263                    _pointSplatter->GetSampleDimensions(dims);
     
    281297                    // Result of Delaunay3D mesher is unstructured grid
    282298                    vtkSmartPointer<vtkDelaunay3D> mesher = vtkSmartPointer<vtkDelaunay3D>::New();
     299#ifdef USE_VTK6
     300                    mesher->SetInputData(pd);
     301#else
    283302                    mesher->SetInput(pd);
     303#endif
    284304                    // Run the mesher
    285305                    mesher->Update();
     
    304324                    if (_pointSplatter == NULL)
    305325                        _pointSplatter = vtkSmartPointer<vtkGaussianSplatter>::New();
     326#ifdef USE_VTK6
     327                    _pointSplatter->SetInputData(pd);
     328#else
    306329                    _pointSplatter->SetInput(pd);
     330#endif
    307331                    int dims[3];
    308332                    _pointSplatter->GetSampleDimensions(dims);
     
    337361                    _contourFilter->SetInputConnection(warpOutput);
    338362                } else {
     363#ifdef USE_VTK6
     364                    _dsMapper->SetInputData(pd);
     365                    _contourFilter->SetInputData(pd);
     366#else
    339367                    _dsMapper->SetInput(pd);
    340368                    _contourFilter->SetInput(pd);
     369#endif
     370
    341371                }
    342372            }
     
    354384                imageData->GetDimensions(dims);
    355385                TRACE("Image data dimensions: %d %d %d", dims[0], dims[1], dims[2]);
     386#ifdef USE_VTK6
     387                _volumeSlicer->SetInputData(ds);
     388#else
    356389                _volumeSlicer->SetInput(ds);
     390#endif
    357391                _volumeSlicer->SetVOI(0, dims[0]-1, 0, dims[1]-1, (dims[2]-1)/2, (dims[2]-1)/2);
    358392                _volumeSlicer->SetSampleRate(1, 1, 1);
     
    364398                // Sample a plane within the grid bounding box
    365399                vtkSmartPointer<vtkCutter> cutter = vtkSmartPointer<vtkCutter>::New();
     400#ifdef USE_VTK6
     401                cutter->SetInputData(ds);
     402#else
    366403                cutter->SetInput(ds);
     404#endif
    367405                if (_cutPlane == NULL) {
    368406                    _cutPlane = vtkSmartPointer<vtkPlane>::New();
     
    376414            } else {
    377415                // 2D data
     416#ifdef USE_VTK6
     417                gf->SetInputData(ds);
     418#else
    378419                gf->SetInput(ds);
     420#endif
    379421            }
    380422            vtkAlgorithmOutput *warpOutput = initWarp(gf->GetOutputPort());
     
    424466    }
    425467
     468    //setAspect(1.0);
     469
    426470    _dsActor->SetMapper(_dsMapper);
    427471
    428472    _dsMapper->Update();
    429473    _contourMapper->Update();
     474}
     475
     476void 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);
    430572}
    431573
     
    483625        _warp->UseNormalOn();
    484626        _warp->SetScaleFactor(_warpScale * _dataScale);
     627#ifdef USE_VTK6
     628        _warp->SetInputData(pdInput);
     629#else
    485630        _warp->SetInput(pdInput);
     631#endif
    486632        return _warp->GetOutputPort();
    487633    }
Note: See TracChangeset for help on using the changeset viewer.