Ignore:
Timestamp:
Sep 2, 2011 1:08:15 AM (13 years ago)
Author:
ldelgass
Message:

LIC fixes: mask out out-of-bounds sample points from probe filter, run a cutter
before probing to make the probe run faster. A few other misc. cleanups.

File:
1 edited

Legend:

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

    r2404 r2459  
    1818#include <vtkPainterPolyDataMapper.h>
    1919#include <vtkDataSetSurfaceFilter.h>
     20#include <vtkCutter.h>
     21#include <vtkImageMask.h>
     22#include <vtkImageCast.h>
    2023
    2124#include "RpLIC.h"
     
    106109        }
    107110
     111        // Need to convert to vtkImageData
    108112        double bounds[6];
    109113        ds->GetBounds(bounds);
     
    116120        if (ySize < xSize && ySize < zSize)
    117121            minDir = 1;
    118         // Sample a plane within the grid bounding box
    119122        if (_probeFilter == NULL)
    120123            _probeFilter = vtkSmartPointer<vtkProbeFilter>::New();
    121         _probeFilter->SetSource(ds);
     124
     125        if (!_dataSet->is2D()) {
     126            // Sample a plane within the grid bounding box
     127            vtkSmartPointer<vtkCutter> cutter = vtkSmartPointer<vtkCutter>::New();
     128            if (_cutPlane == NULL) {
     129                _cutPlane = vtkSmartPointer<vtkPlane>::New();
     130            }
     131            if (minDir == 0) {
     132                _cutPlane->SetNormal(1, 0, 0);
     133                _cutPlane->SetOrigin(bounds[0] + (bounds[1]-bounds[0])/2.,
     134                                     0,
     135                                     0);
     136            } else if (minDir == 1) {
     137                _cutPlane->SetNormal(0, 1, 0);
     138                _cutPlane->SetOrigin(0,
     139                                     bounds[2] + (bounds[3]-bounds[2])/2.,
     140                                     0);
     141            } else {
     142                _cutPlane->SetNormal(0, 0, 1);
     143                _cutPlane->SetOrigin(0,
     144                                     0,
     145                                     bounds[4] + (bounds[5]-bounds[4])/2.);
     146            }
     147            cutter->SetInput(ds);
     148            cutter->SetCutFunction(_cutPlane);
     149            _probeFilter->SetSourceConnection(cutter->GetOutputPort());
     150        } else {
     151            _probeFilter->SetSource(ds);
     152        }
     153
    122154        vtkSmartPointer<vtkImageData> imageData = vtkSmartPointer<vtkImageData>::New();
    123155        int xdim, ydim, zdim;
     
    165197        if (_mapper == NULL) {
    166198            _mapper = vtkSmartPointer<vtkDataSetMapper>::New();
    167         }
    168         _mapper->SetInputConnection(_lic->GetOutputPort());
     199            _mapper->SetColorModeToMapScalars();
     200        }
     201        _lic->Update();
     202        vtkSmartPointer<vtkImageCast> cast = vtkSmartPointer<vtkImageCast>::New();
     203        cast->SetInputConnection(_probeFilter->GetOutputPort());
     204        cast->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS,
     205                                     _probeFilter->GetValidPointMaskArrayName());
     206        cast->SetOutputScalarTypeToUnsignedChar();
     207        vtkSmartPointer<vtkImageMask> mask = vtkSmartPointer<vtkImageMask>::New();
     208        mask->SetInputConnection(0, _lic->GetOutputPort());
     209        mask->SetInputConnection(1, cast->GetOutputPort());
     210        _mapper->SetInputConnection(mask->GetOutputPort());
    169211    } else {
    170212        // DataSet is a PolyData
     
    243285        double bounds[6];
    244286        assert(vtkDataSet::SafeDownCast(_probeFilter->GetSource()) != NULL);
    245         vtkDataSet::SafeDownCast(_probeFilter->GetSource())->GetBounds(bounds);
     287        _dataSet->getBounds(bounds);
    246288        int dim = 128;
    247289
     
    253295                                  (bounds[3]-bounds[2])/((double)(dim-1)),
    254296                                  (bounds[5]-bounds[4])/((double)(dim-1)));
     297            if (_cutPlane != NULL) {
     298                _cutPlane->SetNormal(1, 0, 0);
     299                _cutPlane->SetOrigin(bounds[0] + (bounds[1]-bounds[0])*ratio, 0, 0);
     300            }
    255301            break;
    256302        case Y_AXIS:
     
    260306                                  0,
    261307                                  (bounds[5]-bounds[4])/((double)(dim-1)));
     308            if (_cutPlane != NULL) {
     309                _cutPlane->SetNormal(0, 1, 0);
     310                _cutPlane->SetOrigin(0, bounds[2] + (bounds[3]-bounds[2])*ratio, 0);
     311            }
    262312            break;
    263313        case Z_AXIS:
     
    267317                                  (bounds[3]-bounds[2])/((double)(dim-1)),
    268318                                  0);
     319            if (_cutPlane != NULL) {
     320                _cutPlane->SetNormal(0, 0, 1);
     321                _cutPlane->SetOrigin(0, 0, bounds[4] + (bounds[5]-bounds[4])*ratio);
     322            }
    269323            break;
    270324        default:
     
    305359    }
    306360
     361    if (_lic != NULL)
     362        _lic->Update();
     363
    307364    if (_mapper != NULL)
    308365        _mapper->Update();
     
    330387        _lut = vtkSmartPointer<vtkLookupTable>::New();
    331388        if (_mapper != NULL) {
    332             _mapper->UseLookupTableScalarRangeOn();
     389            _mapper->UseLookupTableScalarRangeOff();
    333390            _mapper->SetLookupTable(_lut);
    334391        }
Note: See TracChangeset for help on using the changeset viewer.