Changeset 2459


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.

Location:
trunk/packages/vizservers/vtkvis
Files:
15 edited

Legend:

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

    r2423 r2459  
    3131    _numContours(numContours)
    3232{
     33    _edgeColor[0] = _color[0];
     34    _edgeColor[1] = _color[0];
     35    _edgeColor[2] = _color[0];
     36    _lighting = false;
    3337}
    3438
     
    3842    _contours(contours)
    3943{
     44    _edgeColor[0] = _color[0];
     45    _edgeColor[1] = _color[0];
     46    _edgeColor[2] = _color[0];
     47    _lighting = false;
    4048}
    4149
     
    4856        TRACE("Deleting Contour2D with NULL DataSet");
    4957#endif
    50 }
    51 
    52 /**
    53  * \brief Create and initialize a VTK Prop to render isolines
    54  */
    55 void Contour2D::initProp()
    56 {
    57     if (_prop == NULL) {
    58         _prop = vtkSmartPointer<vtkActor>::New();
    59         vtkProperty *property = getActor()->GetProperty();
    60         property->EdgeVisibilityOn();
    61         property->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);
    62         property->SetLineWidth(_edgeWidth);
    63         property->SetOpacity(_opacity);
    64         property->SetAmbient(.2);
    65         property->LightingOff();
    66     }
    6758}
    6859
     
    178169        _contourMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
    179170        _contourMapper->SetResolveCoincidentTopologyToPolygonOffset();
     171        _contourMapper->ScalarVisibilityOff();
    180172        vtkSmartPointer<vtkStripper> stripper = vtkSmartPointer<vtkStripper>::New();
    181173        stripper->SetInputConnection(_contourFilter->GetOutputPort());
  • trunk/packages/vizservers/vtkvis/RpContour2D.h

    r2402 r2459  
    5353                              double vectorComponentRange[3][2]);
    5454
     55    virtual void setColor(float color[3])
     56    {
     57        VtkGraphicsObject::setColor(color);
     58        VtkGraphicsObject::setEdgeColor(color);
     59    }
     60
     61    virtual void setEdgeColor(float color[3])
     62    {
     63        setColor(color);
     64    }
     65
    5566private:
    5667    Contour2D();
    5768
    58     virtual void initProp();
    5969    virtual void update();
    6070
  • trunk/packages/vizservers/vtkvis/RpContour3D.cpp

    r2402 r2459  
    5454        TRACE("Deleting Contour3D with NULL DataSet");
    5555#endif
    56 }
    57 
    58 /**
    59  * \brief Create and initialize a VTK Prop to render isosurfaces
    60  */
    61 void Contour3D::initProp()
    62 {
    63     if (_prop == NULL) {
    64         _prop = vtkSmartPointer<vtkActor>::New();
    65         vtkProperty *property = getActor()->GetProperty();
    66         property->EdgeVisibilityOff();
    67         property->SetColor(_color[0], _color[1], _color[2]);
    68         property->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);
    69         property->SetLineWidth(_edgeWidth);
    70         property->SetOpacity(_opacity);
    71         property->SetAmbient(.2);
    72         if (!_lighting)
    73             property->LightingOff();
    74     }
    7556}
    7657
  • trunk/packages/vizservers/vtkvis/RpContour3D.h

    r2402 r2459  
    7070    Contour3D();
    7171
    72     virtual void initProp();
    7372    virtual void update();
    7473
  • trunk/packages/vizservers/vtkvis/RpHeightMap.cpp

    r2457 r2459  
    138138        _contourActor = vtkSmartPointer<vtkActor>::New();
    139139        _contourActor->GetProperty()->SetOpacity(_opacity);
     140        _contourActor->GetProperty()->SetColor(_contourEdgeColor[0],
     141                                               _contourEdgeColor[1],
     142                                               _contourEdgeColor[2]);
    140143        _contourActor->GetProperty()->SetEdgeColor(_contourEdgeColor[0],
    141144                                                   _contourEdgeColor[1],
    142145                                                   _contourEdgeColor[2]);
    143146        _contourActor->GetProperty()->SetLineWidth(_contourEdgeWidth);
    144         _contourActor->GetProperty()->EdgeVisibilityOn();
     147        _contourActor->GetProperty()->EdgeVisibilityOff();
    145148        _contourActor->GetProperty()->SetAmbient(.2);
    146149        _contourActor->GetProperty()->LightingOff();
     150    }
     151    if (_prop == NULL) {
     152        _prop = vtkSmartPointer<vtkAssembly>::New();
     153        getAssembly()->AddPart(_dsActor);
     154        getAssembly()->AddPart(_contourActor);
    147155    }
    148156}
     
    168176    if (_dsMapper == NULL) {
    169177        _dsMapper = vtkSmartPointer<vtkDataSetMapper>::New();
     178        // Map scalars through lookup table regardless of type
     179        _dsMapper->SetColorModeToMapScalars();
    170180    }
    171181
     
    407417    if (_contourMapper == NULL) {
    408418        _contourMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
     419        _contourMapper->ScalarVisibilityOff();
    409420        _contourMapper->SetResolveCoincidentTopologyToPolygonOffset();
    410421        vtkSmartPointer<vtkStripper> stripper = vtkSmartPointer<vtkStripper>::New();
     
    415426
    416427    _dsActor->SetMapper(_dsMapper);
    417 
    418     if (_prop == NULL) {
    419         _prop = vtkSmartPointer<vtkAssembly>::New();
    420         getAssembly()->AddPart(_dsActor);
    421         getAssembly()->AddPart(_contourActor);
    422     }
    423428
    424429    _dsMapper->Update();
     
    789794    _contourEdgeColor[1] = color[1];
    790795    _contourEdgeColor[2] = color[2];
    791     if (_contourActor != NULL)
     796    if (_contourActor != NULL) {
     797        _contourActor->GetProperty()->SetColor(_contourEdgeColor[0],
     798                                               _contourEdgeColor[1],
     799                                               _contourEdgeColor[2]);
    792800        _contourActor->GetProperty()->SetEdgeColor(_contourEdgeColor[0],
    793801                                                   _contourEdgeColor[1],
    794802                                                   _contourEdgeColor[2]);
     803    }
    795804}
    796805
  • 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        }
  • trunk/packages/vizservers/vtkvis/RpLIC.h

    r2402 r2459  
    1818#include <vtkMapper.h>
    1919#include <vtkLookupTable.h>
     20#include <vtkPlane.h>
    2021
    2122#include "ColorMap.h"
     
    7778    vtkSmartPointer<vtkExtractVOI> _volumeSlicer;
    7879    vtkSmartPointer<vtkProbeFilter> _probeFilter;
     80    vtkSmartPointer<vtkPlane> _cutPlane;
    7981    vtkSmartPointer<vtkImageDataLIC2D> _lic;
    8082    vtkSmartPointer<vtkSurfaceLICPainter> _painter;
  • trunk/packages/vizservers/vtkvis/RpPolyData.cpp

    r2423 r2459  
    4747void PolyData::initProp()
    4848{
    49     if (_prop == NULL) {
    50         _prop = vtkSmartPointer<vtkActor>::New();
    51         vtkProperty *property = getActor()->GetProperty();
    52         property->EdgeVisibilityOn();
    53         property->SetColor(_color[0], _color[1], _color[2]);
    54         property->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);
    55         property->SetLineWidth(_edgeWidth);
    56         property->SetOpacity(_opacity);
    57         property->SetAmbient(.2);
    58         if (!_lighting)
    59             property->LightingOff();
    60     }
     49    VtkGraphicsObject::initProp();
     50    getActor()->GetProperty()->EdgeVisibilityOn();
    6151}
    6252
  • trunk/packages/vizservers/vtkvis/RpPseudoColor.cpp

    r2423 r2459  
    4646
    4747/**
    48  * \brief Create and initialize a VTK Prop to render the colormapped dataset
    49  */
    50 void PseudoColor::initProp()
    51 {
    52     if (_prop == NULL) {
    53         _prop = vtkSmartPointer<vtkActor>::New();
    54         vtkProperty *property = getActor()->GetProperty();
    55         property->SetOpacity(_opacity);
    56         property->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);
    57         property->SetLineWidth(_edgeWidth);
    58         property->EdgeVisibilityOff();
    59         property->SetAmbient(.2);
    60         if (!_lighting)
    61             property->LightingOff();
    62     }
    63 }
    64 
    65 /**
    6648 * \brief Internal method to set up pipeline after a state change
    6749 */
     
    7658    if (_dsMapper == NULL) {
    7759        _dsMapper = vtkSmartPointer<vtkDataSetMapper>::New();
     60        // Map scalars through lookup table regardless of type
     61        _dsMapper->SetColorModeToMapScalars();
    7862    }
    7963
  • trunk/packages/vizservers/vtkvis/RpPseudoColor.h

    r2423 r2459  
    5454
    5555private:
    56     virtual void initProp();
    5756    virtual void update();
    5857
  • trunk/packages/vizservers/vtkvis/RpVtkGraphicsObject.h

    r2423 r2459  
    590590    {
    591591        for (int i = 0; i < 3; i++)
    592             _color[i] = color[i];
     592            _edgeColor[i] = color[i];
    593593        if (getActor() != NULL) {
    594594            getActor()->GetProperty()->SetEdgeColor(color[0], color[1], color[2]);
     
    725725            _prop = vtkSmartPointer<vtkActor>::New();
    726726            vtkProperty *property = getActor()->GetProperty();
     727            property->SetColor(_color[0], _color[1], _color[2]);
     728            property->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);
     729            property->SetLineWidth(_edgeWidth);
     730            property->SetPointSize(_pointSize);
    727731            property->EdgeVisibilityOff();
    728732            property->SetOpacity(_opacity);
  • trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp

    r2455 r2459  
    19071907 * \brief Set the RGB isoline color for the specified DataSet
    19081908 */
    1909 void Renderer::setContour2DEdgeColor(const DataSetId& id, float color[3])
     1909void Renderer::setContour2DColor(const DataSetId& id, float color[3])
    19101910{
    19111911    Contour2DHashmap::iterator itr;
     
    19251925
    19261926    do {
    1927         itr->second->setEdgeColor(color);
     1927        itr->second->setColor(color);
    19281928    } while (doAll && ++itr != _contour2Ds.end());
    19291929
  • trunk/packages/vizservers/vtkvis/RpVtkRenderer.h

    r2455 r2459  
    273273    void setContour2DScale(const DataSetId& id, double scale[3]);
    274274
    275     void setContour2DEdgeColor(const DataSetId& id, float color[3]);
     275    void setContour2DColor(const DataSetId& id, float color[3]);
    276276
    277277    void setContour2DEdgeWidth(const DataSetId& id, float edgeWidth);
  • trunk/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp

    r2455 r2459  
    752752    if (objc == 6) {
    753753        const char *name = Tcl_GetString(objv[5]);
    754         g_renderer->setContour2DEdgeColor(name, color);
    755     } else {
    756         g_renderer->setContour2DEdgeColor("all", color);
     754        g_renderer->setContour2DColor(name, color);
     755    } else {
     756        g_renderer->setContour2DColor("all", color);
    757757    }
    758758    return TCL_OK;
     
    870870static Rappture::CmdSpec contour2dOps[] = {
    871871    {"add",       1, Contour2DAddOp, 4, 5, "oper value ?dataSetName?"},
     872    {"color",     1, Contour2DLineColorOp, 5, 6, "r g b ?dataSetName?"},
    872873    {"delete",    1, Contour2DDeleteOp, 2, 3, "?dataSetName?"},
    873874    {"lighting",  3, Contour2DLightingOp, 3, 4, "bool ?dataSetName?"},
  • trunk/packages/vizservers/vtkvis/protocol.txt

    r2456 r2459  
    109109contour2d add contourlist <list> <?datasetName?>
    110110          list = {isoval1 isoval2 isoval3...}
     111contour2d color <r> <g> <b> <?datasetName?>
     112          synonym for linecolor
    111113contour2d delete <?datasetName?>
    112114contour2d lighting <bool> <?datasetName?>
    113115contour2d linecolor <r> <g> <b> <?datasetName?>
     116          synonym for color
    114117contour2d linewidth <val> <?datasetName?>
    115118contour2d opacity <val> <?datasetName?>
Note: See TracChangeset for help on using the changeset viewer.