Changeset 2318 for trunk/packages


Ignore:
Timestamp:
Jul 23, 2011, 10:22:26 AM (13 years ago)
Author:
ldelgass
Message:

Add n-sided polygon seed type to vtkvis streamlines

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

Legend:

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

    r2317 r2318  
    1414#include <vtkCellArray.h>
    1515#include <vtkPolyLine.h>
     16#include <vtkRegularPolygonSource.h>
    1617#include <vtkPointData.h>
    1718#include <vtkCellData.h>
     
    213214    seed->SetVerts(cells);
    214215
    215     TRACE("Seed points: %d", seed->GetNumberOfVerts());
     216    TRACE("Seed points: %d", seed->GetNumberOfPoints());
    216217
    217218    _streamTracer->SetMaximumPropagation(maxBound);
     
    314315        seed->SetVerts(cells);
    315316
    316         TRACE("Seed points: %d", seed->GetNumberOfVerts());
     317        TRACE("Seed points: %d", seed->GetNumberOfPoints());
    317318        vtkSmartPointer<vtkDataSet> oldSeed;
    318319        if (_streamTracer->GetSource() != NULL) {
     
    330331
    331332/**
    332  * \brief Use randomly distributed seed points
     333 * \brief Use seed points along a line
    333334 *
    334335 * \param[in] numPoints Number of random seed points to generate
     
    350351        }
    351352
    352         srand((unsigned int)time(NULL));
    353353        polyline->GetPointIds()->SetNumberOfIds(numPoints);
    354354        for (int i = 0; i < numPoints; i++) {
     
    366366        seed->SetLines(cells);
    367367
    368         TRACE("Seed points: %d", seed->GetNumberOfVerts());
     368        TRACE("Seed points: %d", seed->GetNumberOfPoints());
    369369        vtkSmartPointer<vtkDataSet> oldSeed;
    370370        if (_streamTracer->GetSource() != NULL) {
     
    378378
    379379        _seedMapper->SetInput(seed);
     380    }
     381}
     382
     383/**
     384 * \brief Use seed points from an n-sided polygon
     385 *
     386 * \param[in] numPoints Number of random seed points to generate
     387 */
     388void Streamlines::setSeedToPolygon(double center[3],
     389                                   double normal[3],
     390                                   double radius,
     391                                   int numSides)
     392{
     393    if (_streamTracer != NULL) {
     394        // Set up seed source object
     395        vtkSmartPointer<vtkRegularPolygonSource> seed = vtkSmartPointer<vtkRegularPolygonSource>::New();
     396
     397        seed->SetCenter(center);
     398        seed->SetNormal(normal);
     399        seed->SetRadius(radius);
     400        seed->SetNumberOfSides(numSides);
     401        seed->GeneratePolygonOn();
     402
     403        TRACE("Seed points: %d", numSides);
     404        vtkSmartPointer<vtkDataSet> oldSeed;
     405        if (_streamTracer->GetSource() != NULL) {
     406            oldSeed = _streamTracer->GetSource();
     407        }
     408
     409        _streamTracer->SetSourceConnection(seed->GetOutputPort());
     410        if (oldSeed != NULL) {
     411            oldSeed->SetPipelineInformation(NULL);
     412        }
     413
     414        _seedMapper->SetInputConnection(seed->GetOutputPort());
    380415    }
    381416}
  • trunk/packages/vizservers/vtkvis/RpStreamlines.h

    r2317 r2318  
    4646
    4747    void setSeedToRake(double start[3], double end[3], int numPoints);
     48
     49    void setSeedToPolygon(double center[3], double normal[3],
     50                          double radius, int numSides);
    4851
    4952    void setMaxPropagation(double length);
  • trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp

    r2317 r2318  
    31233123}
    31243124
     3125/**
     3126 * \brief Set the streamlines seed to points distributed randomly inside
     3127 * cells of DataSet
     3128 */
    31253129void Renderer::setStreamlinesSeedToRandomPoints(const DataSetId& id, int numPoints)
    31263130{
     
    31473151}
    31483152
     3153/**
     3154 * \brief Set the streamlines seed to points along a line
     3155 */
    31493156void Renderer::setStreamlinesSeedToRake(const DataSetId& id, double start[3], double end[3], int numPoints)
    31503157{
     
    31663173    do {
    31673174        itr->second->setSeedToRake(start, end, numPoints);
     3175    } while (doAll && ++itr != _streamlines.end());
     3176
     3177    _needsRedraw = true;
     3178}
     3179
     3180/**
     3181 * \brief Set the streamlines seed to vertices of an n-sided polygon
     3182 */
     3183void Renderer::setStreamlinesSeedToPolygon(const DataSetId& id,
     3184                                           double center[3], double normal[3],
     3185                                           double radius, int numSides)
     3186{
     3187    StreamlinesHashmap::iterator itr;
     3188
     3189    bool doAll = false;
     3190
     3191    if (id.compare("all") == 0) {
     3192        itr = _streamlines.begin();
     3193        doAll = true;
     3194    } else {
     3195        itr = _streamlines.find(id);
     3196    }
     3197    if (itr == _streamlines.end()) {
     3198        ERROR("Streamlines not found: %s", id.c_str());
     3199        return;
     3200    }
     3201
     3202    do {
     3203        itr->second->setSeedToPolygon(center, normal, radius, numSides);
    31683204    } while (doAll && ++itr != _streamlines.end());
    31693205
     
    33973433        lut->DeepCopy(cmap->getLookupTable());
    33983434
     3435#if 0
    33993436        if (_useCumulativeRange) {
    34003437            lut->SetRange(_cumulativeDataRange);
     
    34063443            }
    34073444        }
     3445#endif
    34083446
    34093447        itr->second->setLookupTable(lut);
  • trunk/packages/vizservers/vtkvis/RpVtkRenderer.h

    r2317 r2318  
    358358    Streamlines *getStreamlines(const DataSetId& id);
    359359
    360     void setStreamlinesSeedToDataSet(const DataSetId& id, vtkDataSet *seed);
    361 
    362360    void setStreamlinesSeedToRandomPoints(const DataSetId& id, int numPoints);
    363361
    364362    void setStreamlinesSeedToRake(const DataSetId& id, double start[3], double end[3], int numPoints);
     363
     364    void setStreamlinesSeedToPolygon(const DataSetId& id, double center[3], double normal[3],
     365                                           double radius, int numSides);
    365366
    366367    void setStreamlinesLength(const DataSetId& id, double length);
  • trunk/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp

    r2317 r2318  
    24902490
    24912491static int
     2492StreamlinesSeedPolygonOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2493                         Tcl_Obj *const *objv)
     2494{
     2495    double center[3], normal[3], radius;
     2496    int numSides;
     2497    for (int i = 0; i < 3; i++) {
     2498        if (Tcl_GetDoubleFromObj(interp, objv[3+i], &center[i]) != TCL_OK) {
     2499            return TCL_ERROR;
     2500        }
     2501        if (Tcl_GetDoubleFromObj(interp, objv[6+i], &normal[i]) != TCL_OK) {
     2502            return TCL_ERROR;
     2503        }
     2504    }
     2505    if (Tcl_GetDoubleFromObj(interp, objv[9], &radius) != TCL_OK) {
     2506        return TCL_ERROR;
     2507    }
     2508    if (Tcl_GetIntFromObj(interp, objv[10], &numSides) != TCL_OK) {
     2509        return TCL_ERROR;
     2510    }
     2511    if (objc == 12) {
     2512        const char *name = Tcl_GetString(objv[11]);
     2513        g_renderer->setStreamlinesSeedToPolygon(name, center, normal, radius, numSides);
     2514    } else {
     2515        g_renderer->setStreamlinesSeedToPolygon("all", center, normal, radius, numSides);
     2516    }
     2517    return TCL_OK;
     2518}
     2519
     2520static int
    24922521StreamlinesSeedRakeOp(ClientData clientData, Tcl_Interp *interp, int objc,
    24932522                      Tcl_Obj *const *objv)
     
    25512580static Rappture::CmdSpec streamlinesSeedOps[] = {
    25522581    {"color",   1, StreamlinesSeedColorOp, 6, 7, "r g b ?dataSetName?"},
     2582    {"polygon", 1, StreamlinesSeedPolygonOp, 11, 12, "centerX centerY centerZ normalX normalY normalZ radius numSides ?dataSetName?"},
    25532583    {"rake",    3, StreamlinesSeedRakeOp, 10, 11, "startX startY startZ endX endY endZ numPoints ?dataSetName?"},
    25542584    {"random",  3, StreamlinesSeedRandomOp, 4, 5, "numPoints ?dataSetName?"},
  • trunk/packages/vizservers/vtkvis/protocol.txt

    r2317 r2318  
    169169            degrees offset from normal orientation
    170170streamlines seed color <r> <g> <b> <?datasetName?>
     171streamlines seed polygon <centerX> <centerY> <centerZ> <normalX> <normalY> <normalZ> <radius> <numSides> <?dataSetName?>
    171172streamlines seed rake <startX> <startY> <startZ> <endX> <endY> <endZ> <numPoints> <?datasetName?>
    172173streamlines seed random <numPoints> <?datasetName?>
Note: See TracChangeset for help on using the changeset viewer.