1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | /* |
---|
3 | * Copyright (C) 2004-2012 HUBzero Foundation, LLC |
---|
4 | * |
---|
5 | * Author: Leif Delgass <ldelgass@purdue.edu> |
---|
6 | */ |
---|
7 | |
---|
8 | #ifndef VTKVIS_HEIGHTMAP_H |
---|
9 | #define VTKVIS_HEIGHTMAP_H |
---|
10 | |
---|
11 | #include <vtkSmartPointer.h> |
---|
12 | #include <vtkAlgorithmOutput.h> |
---|
13 | #include <vtkContourFilter.h> |
---|
14 | #include <vtkLookupTable.h> |
---|
15 | #include <vtkPolyDataMapper.h> |
---|
16 | #include <vtkActor.h> |
---|
17 | #include <vtkPlaneCollection.h> |
---|
18 | #include <vtkGaussianSplatter.h> |
---|
19 | #include <vtkExtractVOI.h> |
---|
20 | #include <vtkWarpScalar.h> |
---|
21 | #include <vtkPolyDataNormals.h> |
---|
22 | #include <vtkAssembly.h> |
---|
23 | #include <vtkDataSet.h> |
---|
24 | #include <vtkPlane.h> |
---|
25 | |
---|
26 | #include <vector> |
---|
27 | |
---|
28 | #include "ColorMap.h" |
---|
29 | #include "Types.h" |
---|
30 | #include "GraphicsObject.h" |
---|
31 | |
---|
32 | namespace VtkVis { |
---|
33 | |
---|
34 | /** |
---|
35 | * \brief Color-mapped plot of data set |
---|
36 | */ |
---|
37 | class HeightMap : public GraphicsObject { |
---|
38 | public: |
---|
39 | enum CloudStyle { |
---|
40 | CLOUD_MESH, |
---|
41 | CLOUD_SPLAT |
---|
42 | }; |
---|
43 | enum ColorMode { |
---|
44 | COLOR_BY_SCALAR, |
---|
45 | COLOR_BY_VECTOR_MAGNITUDE, |
---|
46 | COLOR_BY_VECTOR_X, |
---|
47 | COLOR_BY_VECTOR_Y, |
---|
48 | COLOR_BY_VECTOR_Z, |
---|
49 | COLOR_CONSTANT |
---|
50 | }; |
---|
51 | |
---|
52 | HeightMap(int numContours, double heightScale = 1.0); |
---|
53 | |
---|
54 | HeightMap(const std::vector<double>& contours, double heightScale = 1.0); |
---|
55 | |
---|
56 | virtual ~HeightMap(); |
---|
57 | |
---|
58 | virtual const char *getClassName() const |
---|
59 | { |
---|
60 | return "HeightMap"; |
---|
61 | } |
---|
62 | |
---|
63 | virtual void setDataSet(DataSet *dataSet, |
---|
64 | Renderer *renderer); |
---|
65 | |
---|
66 | virtual void setLighting(bool state); |
---|
67 | |
---|
68 | virtual void setColor(float color[3]); |
---|
69 | |
---|
70 | virtual void setEdgeVisibility(bool state); |
---|
71 | |
---|
72 | virtual void setEdgeColor(float color[3]); |
---|
73 | |
---|
74 | virtual void setEdgeWidth(float edgeWidth); |
---|
75 | |
---|
76 | virtual void setClippingPlanes(vtkPlaneCollection *planes); |
---|
77 | |
---|
78 | virtual void setAspect(double aspect); |
---|
79 | |
---|
80 | void setCloudStyle(CloudStyle style); |
---|
81 | |
---|
82 | void selectVolumeSlice(Axis axis, double ratio); |
---|
83 | |
---|
84 | void setHeightScale(double scale); |
---|
85 | |
---|
86 | double getHeightScale() |
---|
87 | { |
---|
88 | return _warpScale; |
---|
89 | } |
---|
90 | |
---|
91 | void setInterpolateBeforeMapping(bool state); |
---|
92 | |
---|
93 | void setNumContours(int numContours); |
---|
94 | |
---|
95 | void setContourList(const std::vector<double>& contours); |
---|
96 | |
---|
97 | int getNumContours() const; |
---|
98 | |
---|
99 | const std::vector<double>& getContourList() const; |
---|
100 | |
---|
101 | void setContourLineColorMapEnabled(bool mode); |
---|
102 | |
---|
103 | void setColorMode(ColorMode mode, DataSet::DataAttributeType type, |
---|
104 | const char *name, double range[2] = NULL); |
---|
105 | |
---|
106 | void setColorMode(ColorMode mode, |
---|
107 | const char *name, double range[2] = NULL); |
---|
108 | |
---|
109 | void setColorMode(ColorMode mode); |
---|
110 | |
---|
111 | void setColorMap(ColorMap *colorMap); |
---|
112 | |
---|
113 | /** |
---|
114 | * \brief Return the ColorMap in use |
---|
115 | */ |
---|
116 | ColorMap *getColorMap() |
---|
117 | { |
---|
118 | return _colorMap; |
---|
119 | } |
---|
120 | |
---|
121 | void updateColorMap(); |
---|
122 | |
---|
123 | virtual void updateRanges(Renderer *renderer); |
---|
124 | |
---|
125 | void setContourLineVisibility(bool state); |
---|
126 | |
---|
127 | void setContourSurfaceVisibility(bool state); |
---|
128 | |
---|
129 | void setContourEdgeColor(float color[3]); |
---|
130 | |
---|
131 | void setContourEdgeWidth(float edgeWidth); |
---|
132 | |
---|
133 | private: |
---|
134 | HeightMap(); |
---|
135 | |
---|
136 | virtual void initProp(); |
---|
137 | virtual void update(); |
---|
138 | |
---|
139 | void computeDataScale(); |
---|
140 | |
---|
141 | vtkAlgorithmOutput *initWarp(vtkAlgorithmOutput *input); |
---|
142 | vtkAlgorithmOutput *initWarp(vtkDataSet *input); |
---|
143 | |
---|
144 | int _numContours; |
---|
145 | std::vector<double> _contours; |
---|
146 | |
---|
147 | bool _contourColorMap; |
---|
148 | float _contourEdgeColor[3]; |
---|
149 | float _contourEdgeWidth; |
---|
150 | double _warpScale; |
---|
151 | double _dataScale; |
---|
152 | Axis _sliceAxis; |
---|
153 | bool _pipelineInitialized; |
---|
154 | |
---|
155 | CloudStyle _cloudStyle; |
---|
156 | ColorMap *_colorMap; |
---|
157 | ColorMode _colorMode; |
---|
158 | std::string _colorFieldName; |
---|
159 | DataSet::DataAttributeType _colorFieldType; |
---|
160 | double _colorFieldRange[2]; |
---|
161 | double _vectorMagnitudeRange[2]; |
---|
162 | double _vectorComponentRange[3][2]; |
---|
163 | Renderer *_renderer; |
---|
164 | |
---|
165 | vtkSmartPointer<vtkLookupTable> _lut; |
---|
166 | vtkSmartPointer<vtkPolyDataMapper> _mapper; |
---|
167 | vtkSmartPointer<vtkContourFilter> _contourFilter; |
---|
168 | vtkSmartPointer<vtkPolyDataMapper> _contourMapper; |
---|
169 | vtkSmartPointer<vtkGaussianSplatter> _splatter; |
---|
170 | vtkSmartPointer<vtkExtractVOI> _volumeSlicer; |
---|
171 | vtkSmartPointer<vtkPlane> _cutPlane; |
---|
172 | vtkSmartPointer<vtkWarpScalar> _warp; |
---|
173 | vtkSmartPointer<vtkPolyDataNormals> _normalsGenerator; |
---|
174 | vtkSmartPointer<vtkActor> _dsActor; |
---|
175 | vtkSmartPointer<vtkActor> _contourActor; |
---|
176 | }; |
---|
177 | |
---|
178 | } |
---|
179 | |
---|
180 | #endif |
---|