source: branches/blt4/packages/vizservers/vtkvis/RpStreamlines.h @ 2542

Last change on this file since 2542 was 2542, checked in by gah, 13 years ago

update from trunk

File size: 4.3 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright (C) 2011, Purdue Research Foundation
4 *
5 * Author: Leif Delgass <ldelgass@purdue.edu>
6 */
7
8#ifndef __RAPPTURE_VTKVIS_STREAMLINES_H__
9#define __RAPPTURE_VTKVIS_STREAMLINES_H__
10
11#include <vtkSmartPointer.h>
12#include <vtkProp.h>
13#include <vtkPlaneCollection.h>
14#include <vtkStreamTracer.h>
15#include <vtkPolyDataAlgorithm.h>
16#include <vtkPolyDataMapper.h>
17#include <vtkLookupTable.h>
18#include <vtkAssembly.h>
19
20#include "ColorMap.h"
21#include "RpVtkGraphicsObject.h"
22
23namespace Rappture {
24namespace VtkVis {
25
26/**
27 * \brief Streamline visualization of vector fields
28 *
29 * The DataSet must contain vectors
30 */
31class Streamlines : public VtkGraphicsObject {
32public:
33    enum LineType {
34        LINES,
35        TUBES,
36        RIBBONS
37    };
38    enum ColorMode {
39        COLOR_BY_SCALAR,
40        COLOR_BY_VECTOR_MAGNITUDE,
41        COLOR_BY_VECTOR_X,
42        COLOR_BY_VECTOR_Y,
43        COLOR_BY_VECTOR_Z,
44        COLOR_CONSTANT
45    };
46
47    Streamlines();
48    virtual ~Streamlines();
49
50    virtual const char *getClassName() const
51    {
52        return "Streamlines";
53    }
54
55    virtual void setDataSet(DataSet *dataSet,
56                            bool useCumulative,
57                            double scalarRange[2],
58                            double vectorMagnitudeRange[2],
59                            double vectorComponentRange[3][2]);
60
61    virtual void setLighting(bool state);
62
63    virtual void setOpacity(double opacity);
64
65    virtual void setVisibility(bool state);
66
67    virtual bool getVisibility();
68
69    virtual void setColor(float color[3]);
70
71    virtual void setEdgeVisibility(bool state);
72
73    virtual void setEdgeColor(float color[3]);
74
75    virtual void setEdgeWidth(float edgeWidth);
76
77    virtual void setClippingPlanes(vtkPlaneCollection *planes);
78
79    void setSeedToRandomPoints(int numPoints);
80
81    void setSeedToRake(double start[3], double end[3], int numPoints);
82
83    void setSeedToDisk(double center[3], double normal[3],
84                       double radius, double innerRadius, int numPoints);
85
86    void setSeedToPolygon(double center[3], double normal[3],
87                          double angle, double radius,
88                          int numSides);
89
90    void setSeedToFilledPolygon(double center[3], double normal[3],
91                                double angle, double radius,
92                                int numSides, int numPoints);
93
94    void setMaxPropagation(double length);
95
96    void setLineTypeToLines();
97
98    void setLineTypeToTubes(int numSides, double radius);
99
100    void setLineTypeToRibbons(double width, double angle);
101
102    void setColorMode(ColorMode mode);
103
104    void setColorMap(ColorMap *colorMap);
105
106    /**
107     * \brief Return the ColorMap in use
108     */
109    ColorMap *getColorMap()
110    {
111        return _colorMap;
112    }
113
114    void updateColorMap();
115
116    virtual void updateRanges(bool useCumulative,
117                              double scalarRange[2],
118                              double vectorMagnitudeRange[2],
119                              double vectorComponentRange[3][2]);
120
121    void setSeedVisibility(bool state);
122
123    void setSeedColor(float color[3]);
124
125private:
126    virtual void initProp();
127    virtual void update();
128
129    static double getRandomNum(double min, double max);
130    static void getRandomPoint(double pt[3], const double bounds[6]);
131    static void getRandomPointInTriangle(double pt[3],
132                                         const double v1[3],
133                                         const double v2[3],
134                                         const double v3[3]);
135    static void getRandomPointOnLineSegment(double pt[3],
136                                            const double endpt[3],
137                                            const double endpt2[3]);
138    static void getRandomCellPt(double pt[3], vtkDataSet *ds);
139
140    LineType _lineType;
141    ColorMode _colorMode;
142    ColorMap *_colorMap;
143    float _seedColor[3];
144    bool _seedVisible;
145    double _vectorMagnitudeRange[2];
146    double _vectorComponentRange[3][2];
147    double _dataScale;
148
149    vtkSmartPointer<vtkLookupTable> _lut;
150    vtkSmartPointer<vtkActor> _linesActor;
151    vtkSmartPointer<vtkActor> _seedActor;
152    vtkSmartPointer<vtkStreamTracer> _streamTracer;
153    vtkSmartPointer<vtkPolyDataAlgorithm> _lineFilter;
154    vtkSmartPointer<vtkPolyDataMapper> _pdMapper;
155    vtkSmartPointer<vtkPolyDataMapper> _seedMapper;
156};
157
158}
159}
160
161#endif
Note: See TracBrowser for help on using the repository browser.