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_HEIGHTMAP_H__ |
---|
9 | #define __RAPPTURE_VTKVIS_HEIGHTMAP_H__ |
---|
10 | |
---|
11 | #include <vtkSmartPointer.h> |
---|
12 | #include <vtkAlgorithmOutput.h> |
---|
13 | #include <vtkContourFilter.h> |
---|
14 | #include <vtkLookupTable.h> |
---|
15 | #include <vtkDataSetMapper.h> |
---|
16 | #include <vtkActor.h> |
---|
17 | #include <vtkPlaneCollection.h> |
---|
18 | #include <vtkGaussianSplatter.h> |
---|
19 | #include <vtkExtractVOI.h> |
---|
20 | #include <vtkWarpScalar.h> |
---|
21 | #include <vtkAssembly.h> |
---|
22 | #include <vtkPolyData.h> |
---|
23 | #include <vtkPlane.h> |
---|
24 | |
---|
25 | #include <vector> |
---|
26 | |
---|
27 | #include "ColorMap.h" |
---|
28 | #include "RpVtkGraphicsObject.h" |
---|
29 | |
---|
30 | namespace Rappture { |
---|
31 | namespace VtkVis { |
---|
32 | |
---|
33 | /** |
---|
34 | * \brief Color-mapped plot of data set |
---|
35 | */ |
---|
36 | class HeightMap : public VtkGraphicsObject { |
---|
37 | public: |
---|
38 | enum Axis { |
---|
39 | X_AXIS, |
---|
40 | Y_AXIS, |
---|
41 | Z_AXIS |
---|
42 | }; |
---|
43 | |
---|
44 | HeightMap(int numContours, double heightScale = 1.0); |
---|
45 | |
---|
46 | HeightMap(const std::vector<double>& contours, double heightScale = 1.0); |
---|
47 | |
---|
48 | virtual ~HeightMap(); |
---|
49 | |
---|
50 | virtual const char *getClassName() const |
---|
51 | { |
---|
52 | return "HeightMap"; |
---|
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 setEdgeVisibility(bool state); |
---|
64 | |
---|
65 | virtual void setEdgeColor(float color[3]); |
---|
66 | |
---|
67 | virtual void setEdgeWidth(float edgeWidth); |
---|
68 | |
---|
69 | virtual void setClippingPlanes(vtkPlaneCollection *planes); |
---|
70 | |
---|
71 | void selectVolumeSlice(Axis axis, double ratio); |
---|
72 | |
---|
73 | void setHeightScale(double scale); |
---|
74 | |
---|
75 | double getHeightScale() |
---|
76 | { |
---|
77 | return _warpScale; |
---|
78 | } |
---|
79 | |
---|
80 | void setNumContours(int numContours); |
---|
81 | |
---|
82 | void setContourList(const std::vector<double>& contours); |
---|
83 | |
---|
84 | int getNumContours() const; |
---|
85 | |
---|
86 | const std::vector<double>& getContourList() const; |
---|
87 | |
---|
88 | void setColorMap(ColorMap *colorMap); |
---|
89 | |
---|
90 | /** |
---|
91 | * \brief Return the ColorMap in use |
---|
92 | */ |
---|
93 | ColorMap *getColorMap() |
---|
94 | { |
---|
95 | return _colorMap; |
---|
96 | } |
---|
97 | |
---|
98 | void updateColorMap(); |
---|
99 | |
---|
100 | virtual void updateRanges(bool useCumulative, |
---|
101 | double scalarRange[2], |
---|
102 | double vectorMagnitudeRange[2], |
---|
103 | double vectorComponentRange[3][2]); |
---|
104 | |
---|
105 | void setContourLineVisibility(bool state); |
---|
106 | |
---|
107 | void setContourSurfaceVisibility(bool state); |
---|
108 | |
---|
109 | void setContourEdgeColor(float color[3]); |
---|
110 | |
---|
111 | void setContourEdgeWidth(float edgeWidth); |
---|
112 | |
---|
113 | private: |
---|
114 | HeightMap(); |
---|
115 | |
---|
116 | virtual void initProp(); |
---|
117 | virtual void update(); |
---|
118 | |
---|
119 | vtkAlgorithmOutput *initWarp(vtkAlgorithmOutput *input); |
---|
120 | vtkAlgorithmOutput *initWarp(vtkPolyData *input); |
---|
121 | |
---|
122 | int _numContours; |
---|
123 | std::vector<double> _contours; |
---|
124 | ColorMap *_colorMap; |
---|
125 | |
---|
126 | float _contourEdgeColor[3]; |
---|
127 | float _contourEdgeWidth; |
---|
128 | double _warpScale; |
---|
129 | double _dataScale; |
---|
130 | Axis _sliceAxis; |
---|
131 | bool _pipelineInitialized; |
---|
132 | |
---|
133 | vtkSmartPointer<vtkLookupTable> _lut; |
---|
134 | vtkSmartPointer<vtkDataSetMapper> _dsMapper; |
---|
135 | vtkSmartPointer<vtkContourFilter> _contourFilter; |
---|
136 | vtkSmartPointer<vtkPolyDataMapper> _contourMapper; |
---|
137 | vtkSmartPointer<vtkGaussianSplatter> _pointSplatter; |
---|
138 | vtkSmartPointer<vtkExtractVOI> _volumeSlicer; |
---|
139 | vtkSmartPointer<vtkPlane> _cutPlane; |
---|
140 | vtkSmartPointer<vtkWarpScalar> _warp; |
---|
141 | vtkSmartPointer<vtkActor> _dsActor; |
---|
142 | vtkSmartPointer<vtkActor> _contourActor; |
---|
143 | }; |
---|
144 | |
---|
145 | } |
---|
146 | } |
---|
147 | |
---|
148 | #endif |
---|