Ignore:
Timestamp:
Aug 23, 2012 2:55:39 PM (12 years ago)
Author:
ldelgass
Message:

Add protocol for sphere resolution and section

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

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/vtkvis/RpVtkRenderer.h

    r3148 r3149  
    476476                                 const char *name, double range[2] = NULL);
    477477
     478    // Spheres
     479
     480    void setSphereSection(const DataSetId& id, double thetaStart, double thetaEnd,
     481                          double phiStart, double phiEnd);
     482
     483    void setSphereResolution(const DataSetId& id, int thetaRes, int phiRes);
     484
    478485    // Streamlines
    479486
  • trunk/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp

    r3148 r3149  
    51895189
    51905190static int
     5191SphereResolutionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5192                   Tcl_Obj *const *objv)
     5193{
     5194    int theta, phi;
     5195    if (Tcl_GetIntFromObj(interp, objv[2], &theta) != TCL_OK ||
     5196        Tcl_GetIntFromObj(interp, objv[3], &phi) != TCL_OK) {
     5197        return TCL_ERROR;
     5198    }
     5199    if (objc == 5) {
     5200        const char *name = Tcl_GetString(objv[4]);
     5201        g_renderer->setSphereResolution(name, theta, phi);
     5202    } else {
     5203        g_renderer->setSphereResolution("all", theta, phi);
     5204    }
     5205    return TCL_OK;
     5206}
     5207
     5208static int
    51915209SphereScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
    51925210              Tcl_Obj *const *objv)
     
    52035221    } else {
    52045222        g_renderer->setGraphicsObjectScale<Sphere>("all", scale);
     5223    }
     5224    return TCL_OK;
     5225}
     5226
     5227static int
     5228SphereSectionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5229                Tcl_Obj *const *objv)
     5230{
     5231    double thetaStart, thetaEnd, phiStart, phiEnd;
     5232    if (Tcl_GetDoubleFromObj(interp, objv[2], &thetaStart) != TCL_OK ||
     5233        Tcl_GetDoubleFromObj(interp, objv[3], &thetaEnd) != TCL_OK ||
     5234        Tcl_GetDoubleFromObj(interp, objv[4], &phiStart) != TCL_OK ||
     5235        Tcl_GetDoubleFromObj(interp, objv[5], &phiEnd) != TCL_OK) {
     5236        return TCL_ERROR;
     5237    }
     5238    if (objc == 7) {
     5239        const char *name = Tcl_GetString(objv[6]);
     5240        g_renderer->setSphereSection(name, thetaStart, thetaEnd, phiStart, phiEnd);
     5241    } else {
     5242        g_renderer->setSphereSection("all", thetaStart, thetaEnd, phiStart, phiEnd);
    52055243    }
    52065244    return TCL_OK;
     
    52535291    {"orient",    2, SphereOrientOp, 6, 7, "qw qx qy qz ?name?"},
    52545292    {"pos",       2, SpherePositionOp, 5, 6, "x y z ?name?"},
    5255     {"scale",     1, SphereScaleOp, 5, 6, "sx sy sz ?name?"},
     5293    {"resolution",1, SphereResolutionOp, 4, 5, "thetaRes phiRes ?name?"},
     5294    {"scale",     2, SphereScaleOp, 5, 6, "sx sy sz ?name?"},
     5295    {"section",   2, SphereSectionOp, 6, 7, "thetaStart thetaEnd phiStart phiEnd ?name?"},
    52565296    {"visible",   1, SphereVisibleOp, 3, 4, "bool ?name?"},
    52575297    {"wireframe", 1, SphereWireframeOp, 3, 4, "bool ?name?"}
  • trunk/packages/vizservers/vtkvis/RpVtkRendererGraphicsObjs.cpp

    r3148 r3149  
    15221522
    15231523/**
     1524 * \brief Set Sphere resolution
     1525 */
     1526void Renderer::setSphereResolution(const DataSetId& id, int thetaRes, int phiRes)
     1527{
     1528    SphereHashmap::iterator itr;
     1529
     1530    bool doAll = false;
     1531
     1532    if (id.compare("all") == 0) {
     1533        itr = _spheres.begin();
     1534        doAll = true;
     1535    } else {
     1536        itr = _spheres.find(id);
     1537    }
     1538    if (itr == _spheres.end()) {
     1539        ERROR("Sphere not found: %s", id.c_str());
     1540        return;
     1541    }
     1542
     1543    do {
     1544        itr->second->setThetaResolution(thetaRes);
     1545        itr->second->setPhiResolution(phiRes);
     1546    } while (doAll && ++itr != _spheres.end());
     1547
     1548    _needsRedraw = true;
     1549}
     1550
     1551
     1552/**
     1553 * \brief Set Sphere section
     1554 */
     1555void Renderer::setSphereSection(const DataSetId& id, double thetaStart, double thetaEnd,
     1556                                double phiStart, double phiEnd)
     1557{
     1558    SphereHashmap::iterator itr;
     1559
     1560    bool doAll = false;
     1561
     1562    if (id.compare("all") == 0) {
     1563        itr = _spheres.begin();
     1564        doAll = true;
     1565    } else {
     1566        itr = _spheres.find(id);
     1567    }
     1568    if (itr == _spheres.end()) {
     1569        ERROR("Sphere not found: %s", id.c_str());
     1570        return;
     1571    }
     1572
     1573    do {
     1574        itr->second->setStartTheta(thetaStart);
     1575        itr->second->setEndTheta(thetaEnd);
     1576        itr->second->setStartPhi(phiStart);
     1577        itr->second->setEndPhi(phiEnd);
     1578    } while (doAll && ++itr != _spheres.end());
     1579
     1580    _needsRedraw = true;
     1581}
     1582
     1583/**
    15241584 * \brief Set the streamlines seed to points of the streamlines DataSet
    15251585 */
  • trunk/packages/vizservers/vtkvis/protocol.txt

    r3148 r3149  
    373373sphere orient <qw> <qx> <qy> <qz> <?name?>
    374374sphere pos <x> <y> <z> <?name?>
     375sphere resolution <thetaRes> <phiRes> <?name?>
    375376sphere scale <sx> <sy> <sz> <?name?>
     377sphere section <thetaStart> <thetaEnd> <phiStart> <phiEnd>
     378       Angles are in degrees
    376379sphere visible <bool> <?name?>
    377380sphere wireframe <bool> <?name?>
Note: See TracChangeset for help on using the changeset viewer.