Changeset 2454 for trunk


Ignore:
Timestamp:
Aug 31, 2011, 3:52:05 PM (13 years ago)
Author:
ldelgass
Message:

Apply a scaling heuristic to streamline tubes and ribbons based on cell sizes.
Protocol scale values are now relative. Also cache cell size info in
DataSet? class.

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

Legend:

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

    r2402 r2454  
    3737    _colorMode(COLOR_BY_VECTOR_MAGNITUDE),
    3838    _colorMap(NULL),
    39     _seedVisible(true)
     39    _seedVisible(true),
     40    _dataScale(1)
    4041{
    4142    _faceCulling = true;
     
    246247    }
    247248
     249    double cellSizeRange[2];
     250    double avgSize;
     251    _dataSet->getCellSizeRange(cellSizeRange, &avgSize);
     252    _dataScale = avgSize / 8.;
     253
    248254    vtkSmartPointer<vtkCellDataToPointData> cellToPtData;
    249255
     
    746752            numSides = 3;
    747753        tubeFilter->SetNumberOfSides(numSides);
    748         tubeFilter->SetRadius(radius);
     754        tubeFilter->SetRadius(_dataScale * radius);
    749755        _pdMapper->SetInputConnection(_lineFilter->GetOutputPort());
    750756        if (_faceCulling && _opacity == 1.0)
     
    771777        }
    772778        vtkRibbonFilter *ribbonFilter = vtkRibbonFilter::SafeDownCast(_lineFilter);
    773         ribbonFilter->SetWidth(width);
     779        ribbonFilter->SetWidth(_dataScale * width);
    774780        ribbonFilter->SetAngle(angle);
    775781        ribbonFilter->UseDefaultNormalOn();
  • trunk/packages/vizservers/vtkvis/RpStreamlines.h

    r2402 r2454  
    145145    double _vectorMagnitudeRange[2];
    146146    double _vectorComponentRange[3][2];
     147    double _dataScale;
    147148
    148149    vtkSmartPointer<vtkLookupTable> _lut;
  • trunk/packages/vizservers/vtkvis/RpVtkDataSet.cpp

    r2423 r2454  
    3131DataSet::DataSet(const std::string& name) :
    3232    _name(name),
    33     _visible(true)
    34 {
     33    _visible(true),
     34    _cellSizeAverage(0)
     35{
     36    _cellSizeRange[0] = -1;
     37    _cellSizeRange[1] = -1;
    3538}
    3639
     
    8083    //reader->ReadAllTensorsOn();
    8184    reader->ReadAllFieldsOn();
     85
    8286    return setData(reader);
    8387}
     
    8892bool DataSet::setData(char *data, int nbytes)
    8993{
    90     TRACE("Entering");
    91 
    9294    vtkSmartPointer<vtkDataSetReader> reader = vtkSmartPointer<vtkDataSetReader>::New();
    9395    vtkSmartPointer<vtkCharArray> dataSetString = vtkSmartPointer<vtkCharArray>::New();
     
    109111    reader->ReadAllFieldsOn();
    110112
    111     bool status = setData(reader);
    112 
    113     TRACE("Leaving");
    114     return status;
     113    return setData(reader);
    115114}
    116115
     
    220219bool DataSet::setData(vtkDataSetReader *reader)
    221220{
     221    TRACE("Enter");
    222222    // Force reading data set
    223223    reader->SetLookupTableName("");
     
    238238    print();
    239239#endif
     240    TRACE("Leave");
    240241    return true;
    241242}
     
    515516 * \brief Get the range of cell AABB diagonal lengths in the DataSet
    516517 */
    517 void DataSet::getCellSizeRange(double minmax[6], double *average) const
     518void DataSet::getCellSizeRange(double minmax[2], double *average)
    518519{
    519520    if (_dataSet == NULL ||
     
    522523        minmax[1] = 1;
    523524        *average = 1;
     525        return;
     526    }
     527
     528    if (_cellSizeRange[0] >= 0.0) {
     529        minmax[0] = _cellSizeRange[0];
     530        minmax[1] = _cellSizeRange[1];
     531        *average = _cellSizeAverage;
    524532        return;
    525533    }
     
    545553    minmax[1] = sqrt(minmax[1]);
    546554    *average = sqrt(*average/((double)_dataSet->GetNumberOfCells()));
     555    _cellSizeRange[0] = minmax[0];
     556    _cellSizeRange[1] = minmax[1];
     557    _cellSizeAverage = *average;
    547558}
    548559
  • trunk/packages/vizservers/vtkvis/RpVtkDataSet.h

    r2423 r2454  
    6868    void getBounds(double bounds[6]) const;
    6969
    70     void getCellSizeRange(double minmax[6], double *average) const;
     70    void getCellSizeRange(double minmax[2], double *average);
    7171
    7272    bool getScalarValue(double x, double y, double z, double *value) const;
     
    8787    vtkSmartPointer<vtkDataSet> _dataSet;
    8888    bool _visible;
     89    double _cellSizeRange[2];
     90    double _cellSizeAverage;
    8991};
    9092
Note: See TracChangeset for help on using the changeset viewer.