Changeset 3695 for trunk/packages


Ignore:
Timestamp:
Jun 16, 2013 9:47:15 PM (11 years ago)
Author:
ldelgass
Message:

Add protocol for setting glyphs tesselation quality

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

Legend:

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

    r3683 r3695  
    4040
    4141    vtkSmartPointer<vtkPolyDataNormals> normalFilter = vtkSmartPointer<vtkPolyDataNormals>::New();
     42    normalFilter->SetFeatureAngle(90.);
    4243    normalFilter->SetInputConnection(_arrow->GetOutputPort());
    43     normalFilter->AutoOrientNormalsOff();
    4444
    4545    _pdMapper->SetInputConnection(_arrow->GetOutputPort());
  • trunk/packages/vizservers/vtkvis/Cone.cpp

    r3683 r3695  
    4040
    4141    vtkSmartPointer<vtkPolyDataNormals> normalFilter = vtkSmartPointer<vtkPolyDataNormals>::New();
     42    normalFilter->SetFeatureAngle(90.);
    4243    normalFilter->SetInputConnection(_cone->GetOutputPort());
    43     normalFilter->AutoOrientNormalsOff();
    4444
    4545    _pdMapper->SetInputConnection(_cone->GetOutputPort());
  • trunk/packages/vizservers/vtkvis/Disk.cpp

    r3683 r3695  
    4141    vtkSmartPointer<vtkPolyDataNormals> normalFilter = vtkSmartPointer<vtkPolyDataNormals>::New();
    4242    normalFilter->SetInputConnection(_disk->GetOutputPort());
    43     normalFilter->AutoOrientNormalsOff();
    4443
    4544    _pdMapper->SetInputConnection(normalFilter->GetOutputPort());
  • trunk/packages/vizservers/vtkvis/Glyphs.cpp

    r3677 r3695  
    2727#include <vtkPolyDataMapper.h>
    2828#include <vtkTransformPolyDataFilter.h>
     29#include <vtkPolyDataNormals.h>
    2930
    3031#include "Glyphs.h"
     
    104105    // by the SourceTransform, so the lighting would be wrong
    105106
     107    bool needsNormals = false;
     108    double featureAngle = 90.;
     109
    106110    switch (_glyphShape) {
    107111    case LINE:
     
    113117        arrow->SetTipResolution(8);
    114118        arrow->SetShaftResolution(8);
     119        needsNormals = true;
    115120    }
    116121        break;
     
    119124        vtkSmartPointer<vtkConeSource> cone = vtkConeSource::SafeDownCast(_glyphSource);
    120125        cone->SetResolution(8);
     126        needsNormals = true;
    121127    }
    122128        break;
     
    138144        _glyphSource = vtkSmartPointer<vtkPlatonicSolidSource>::New();
    139145        vtkPlatonicSolidSource::SafeDownCast(_glyphSource)->SetSolidTypeToDodecahedron();
     146        needsNormals = true;
     147        featureAngle = 30.;
    140148        break;
    141149    case ICOSAHEDRON:
    142150        _glyphSource = vtkSmartPointer<vtkPlatonicSolidSource>::New();
    143151        vtkPlatonicSolidSource::SafeDownCast(_glyphSource)->SetSolidTypeToIcosahedron();
     152        needsNormals = true;
     153        featureAngle = 30.;
    144154        break;
    145155    case OCTAHEDRON:
    146156        _glyphSource = vtkSmartPointer<vtkPlatonicSolidSource>::New();
    147157        vtkPlatonicSolidSource::SafeDownCast(_glyphSource)->SetSolidTypeToOctahedron();
     158        needsNormals = true;
     159        featureAngle = 30.;
    148160        break;
    149161    case POINT:
     
    165177        _glyphSource = vtkSmartPointer<vtkPlatonicSolidSource>::New();
    166178        vtkPlatonicSolidSource::SafeDownCast(_glyphSource)->SetSolidTypeToTetrahedron();
     179        needsNormals = true;
     180        featureAngle = 30.;
    167181        break;
    168182    default:
     
    179193    }
    180194
    181     if (_glyphMapper != NULL) {
     195    if (needsNormals && _glyphMapper != NULL) {
     196        vtkSmartPointer<vtkPolyDataNormals> normalFilter = vtkSmartPointer<vtkPolyDataNormals>::New();
     197        normalFilter->SetFeatureAngle(featureAngle);
     198        normalFilter->SetInputConnection(_glyphSource->GetOutputPort());
     199        _glyphMapper->SetSourceConnection(normalFilter->GetOutputPort());
     200    } else if (_glyphMapper != NULL) {
    182201        _glyphMapper->SetSourceConnection(_glyphSource->GetOutputPort());
    183202    }
    184 
    185     //setQuality(0.8);
    186203}
    187204
     
    191208    case ARROW: {
    192209        vtkSmartPointer<vtkArrowSource> arrow = vtkArrowSource::SafeDownCast(_glyphSource);
    193         int res = (int)(quality * 25);
    194         if (res < 5) res = 5;
     210        int res = (int)(quality * 8.);
     211        if (res < 3) res = 3;
    195212        arrow->SetTipResolution(res);
    196213        arrow->SetShaftResolution(res);
     
    199216    case CONE: {
    200217        vtkSmartPointer<vtkConeSource> cone = vtkConeSource::SafeDownCast(_glyphSource);
    201         int res = (int)(quality * 25);
    202         if (res < 5) res = 5;
     218        int res = (int)(quality * 8.);
     219        if (res < 3) res = 3;
    203220        cone->SetResolution(res);
     221    }
     222        break;
     223    case CYLINDER: {
     224        vtkSmartPointer<vtkCylinderSource> csource =
     225            vtkCylinderSource::SafeDownCast(_glyphSource->GetInputAlgorithm(0, 0));
     226        if (csource == NULL) {
     227            ERROR("Can't get cylinder glyph source");
     228            return;
     229        }
     230        int res = (int)(quality * 8.);
     231        if (res < 3) res = 3;
     232        csource->SetResolution(res);
    204233    }
    205234        break;
    206235    case SPHERE: {
    207236        vtkSmartPointer<vtkSphereSource> sphere = vtkSphereSource::SafeDownCast(_glyphSource);
    208         int res = (int)(quality * 50);
    209         if (res < 5) res = 5;
    210         sphere->SetThetaResolution(res);
    211         sphere->SetPhiResolution(res);
    212     }
    213         break;
    214     case CYLINDER: {
    215         assert(vtkTransformPolyDataFilter::SafeDownCast(_glyphSource) != NULL);
    216         assert(vtkTransformPolyDataFilter::SafeDownCast(_glyphSource)->GetInputConnection(0, 0) != NULL);
    217         vtkSmartPointer<vtkCylinderSource> csource = vtkCylinderSource::SafeDownCast(vtkTransformPolyDataFilter::SafeDownCast(_glyphSource)->GetInputConnection(0, 0));
    218         int res = (int)(quality * 25);
    219         if (res < 5) res = 5;
    220         csource->SetResolution(res);
     237        int thetaRes = (int)(quality * 14.);
     238        int phiRes = thetaRes;
     239        if (thetaRes < 4) thetaRes = 4;
     240        if (phiRes < 3) phiRes = 3;
     241
     242        sphere->SetThetaResolution(thetaRes);
     243        sphere->SetPhiResolution(phiRes);
    221244    }
    222245        break;
    223246    default:
    224247        break;
     248    }
     249    if (_glyphMapper != NULL) {
     250        _glyphMapper->Modified();
     251        _glyphMapper->Update();
    225252    }
    226253}
  • trunk/packages/vizservers/vtkvis/Polygon.cpp

    r3683 r3695  
    4141    vtkSmartPointer<vtkPolyDataNormals> normalFilter = vtkSmartPointer<vtkPolyDataNormals>::New();
    4242    normalFilter->SetInputConnection(_polygon->GetOutputPort());
    43     normalFilter->AutoOrientNormalsOff();
    4443
    4544    _pdMapper->SetInputConnection(_polygon->GetOutputPort());
  • trunk/packages/vizservers/vtkvis/Renderer.h

    r3693 r3695  
    679679    void setGlyphsOrientMode(const DataSetId& id, bool state, const char *name);
    680680
     681    void setGlyphsQuality(const DataSetId& id, double quality);
     682
    681683    void setGlyphsColorMode(const DataSetId& id,
    682684                            Glyphs::ColorMode mode,
  • trunk/packages/vizservers/vtkvis/RendererCmd.cpp

    r3693 r3695  
    56665666
    56675667static int
     5668GlyphsQualityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5669                Tcl_Obj *const *objv)
     5670{
     5671    double quality;
     5672    if (Tcl_GetDoubleFromObj(interp, objv[2], &quality) != TCL_OK) {
     5673        return TCL_ERROR;
     5674    }
     5675    if (objc == 4) {
     5676        const char *name = Tcl_GetString(objv[3]);
     5677        g_renderer->setGlyphsQuality(name, quality);
     5678    } else {
     5679        g_renderer->setGlyphsQuality("all", quality);
     5680    }
     5681    return TCL_OK;
     5682}
     5683
     5684static int
    56685685GlyphsScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
    56695686              Tcl_Obj *const *objv)
     
    58255842    {"pos",          2, GlyphsPositionOp, 5, 6, "x y z ?dataSetName?"},
    58265843    {"ptsize",       2, GlyphsPointSizeOp, 3, 4, "size ?dataSetName?"},
     5844    {"quality",      1, GlyphsQualityOp, 3, 4, "val ?dataSetName?"},
    58275845    {"scale",        2, GlyphsScaleOp, 5, 6, "sx sy sz ?dataSetName?"},
    58285846    {"shape",        2, GlyphsShapeOp, 3, 4, "shapeVal ?dataSetName?"},
  • trunk/packages/vizservers/vtkvis/RendererGraphicsObjs.cpp

    r3693 r3695  
    16181618
    16191619/**
     1620 * \brief Set glyph shape resolution
     1621 */
     1622void Renderer::setGlyphsQuality(const DataSetId& id, double quality)
     1623{
     1624    GlyphsHashmap::iterator itr;
     1625
     1626    bool doAll = false;
     1627
     1628    if (id.compare("all") == 0) {
     1629        itr = _glyphs.begin();
     1630        if (itr == _glyphs.end())
     1631            return;
     1632        doAll = true;
     1633    } else {
     1634        itr = _glyphs.find(id);
     1635    }
     1636    if (itr == _glyphs.end()) {
     1637        ERROR("Glyphs not found: %s", id.c_str());
     1638        return;
     1639    }
     1640
     1641    do {
     1642        itr->second->setQuality(quality);
     1643    } while (doAll && ++itr != _glyphs.end());
     1644
     1645    sceneBoundsChanged();
     1646    _needsRedraw = true;
     1647}
     1648
     1649/**
    16201650 * \brief Set the shape of Glyphs for the given DataSet
    16211651 */
     
    22982328}
    22992329
    2300 
    23012330/**
    23022331 * \brief Set bond cylinder resolution
     
    23282357    _needsRedraw = true;
    23292358}
    2330 
    23312359
    23322360/**
Note: See TracChangeset for help on using the changeset viewer.