[2260] | 1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
| 2 | /* |
---|
[3177] | 3 | * Copyright (C) 2004-2012 HUBzero Foundation, LLC |
---|
[2260] | 4 | * |
---|
| 5 | * Author: Leif Delgass <ldelgass@purdue.edu> |
---|
| 6 | */ |
---|
| 7 | |
---|
[3615] | 8 | #ifndef VTKVIS_HEIGHTMAP_H |
---|
| 9 | #define VTKVIS_HEIGHTMAP_H |
---|
[2260] | 10 | |
---|
| 11 | #include <vtkSmartPointer.h> |
---|
[2270] | 12 | #include <vtkAlgorithmOutput.h> |
---|
[2260] | 13 | #include <vtkContourFilter.h> |
---|
| 14 | #include <vtkLookupTable.h> |
---|
[3680] | 15 | #include <vtkPolyDataMapper.h> |
---|
[2260] | 16 | #include <vtkActor.h> |
---|
| 17 | #include <vtkPlaneCollection.h> |
---|
| 18 | #include <vtkGaussianSplatter.h> |
---|
| 19 | #include <vtkExtractVOI.h> |
---|
| 20 | #include <vtkWarpScalar.h> |
---|
[3330] | 21 | #include <vtkPolyDataNormals.h> |
---|
[2328] | 22 | #include <vtkAssembly.h> |
---|
[3680] | 23 | #include <vtkDataSet.h> |
---|
[2457] | 24 | #include <vtkPlane.h> |
---|
[2260] | 25 | |
---|
| 26 | #include <vector> |
---|
| 27 | |
---|
[2402] | 28 | #include "ColorMap.h" |
---|
[3616] | 29 | #include "Types.h" |
---|
[3621] | 30 | #include "GraphicsObject.h" |
---|
[2260] | 31 | |
---|
| 32 | namespace VtkVis { |
---|
| 33 | |
---|
| 34 | /** |
---|
| 35 | * \brief Color-mapped plot of data set |
---|
| 36 | */ |
---|
[3621] | 37 | class HeightMap : public GraphicsObject { |
---|
[2260] | 38 | public: |
---|
[3680] | 39 | enum CloudStyle { |
---|
| 40 | CLOUD_MESH, |
---|
| 41 | CLOUD_SPLAT |
---|
| 42 | }; |
---|
[3330] | 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 | |
---|
[2423] | 52 | HeightMap(int numContours, double heightScale = 1.0); |
---|
[2402] | 53 | |
---|
[2423] | 54 | HeightMap(const std::vector<double>& contours, double heightScale = 1.0); |
---|
[2402] | 55 | |
---|
[2260] | 56 | virtual ~HeightMap(); |
---|
| 57 | |
---|
[2328] | 58 | virtual const char *getClassName() const |
---|
| 59 | { |
---|
| 60 | return "HeightMap"; |
---|
| 61 | } |
---|
[2260] | 62 | |
---|
[2580] | 63 | virtual void setDataSet(DataSet *dataSet, |
---|
[2612] | 64 | Renderer *renderer); |
---|
[2260] | 65 | |
---|
[2328] | 66 | virtual void setLighting(bool state); |
---|
[2260] | 67 | |
---|
[3330] | 68 | virtual void setColor(float color[3]); |
---|
| 69 | |
---|
[2328] | 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 | |
---|
[3189] | 78 | virtual void setAspect(double aspect); |
---|
| 79 | |
---|
[3680] | 80 | void setCloudStyle(CloudStyle style); |
---|
| 81 | |
---|
[2260] | 82 | void selectVolumeSlice(Axis axis, double ratio); |
---|
| 83 | |
---|
| 84 | void setHeightScale(double scale); |
---|
| 85 | |
---|
[2517] | 86 | double getHeightScale() |
---|
| 87 | { |
---|
| 88 | return _warpScale; |
---|
| 89 | } |
---|
| 90 | |
---|
[3330] | 91 | void setInterpolateBeforeMapping(bool state); |
---|
| 92 | |
---|
[2423] | 93 | void setNumContours(int numContours); |
---|
[2260] | 94 | |
---|
| 95 | void setContourList(const std::vector<double>& contours); |
---|
| 96 | |
---|
| 97 | int getNumContours() const; |
---|
| 98 | |
---|
| 99 | const std::vector<double>& getContourList() const; |
---|
| 100 | |
---|
[3330] | 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 | |
---|
[2402] | 111 | void setColorMap(ColorMap *colorMap); |
---|
[2260] | 112 | |
---|
[2402] | 113 | /** |
---|
| 114 | * \brief Return the ColorMap in use |
---|
| 115 | */ |
---|
| 116 | ColorMap *getColorMap() |
---|
| 117 | { |
---|
| 118 | return _colorMap; |
---|
| 119 | } |
---|
[2260] | 120 | |
---|
[2402] | 121 | void updateColorMap(); |
---|
| 122 | |
---|
[2612] | 123 | virtual void updateRanges(Renderer *renderer); |
---|
[2402] | 124 | |
---|
[2423] | 125 | void setContourLineVisibility(bool state); |
---|
[2260] | 126 | |
---|
[2423] | 127 | void setContourSurfaceVisibility(bool state); |
---|
| 128 | |
---|
[2260] | 129 | void setContourEdgeColor(float color[3]); |
---|
| 130 | |
---|
| 131 | void setContourEdgeWidth(float edgeWidth); |
---|
| 132 | |
---|
[2328] | 133 | private: |
---|
[2402] | 134 | HeightMap(); |
---|
| 135 | |
---|
[2328] | 136 | virtual void initProp(); |
---|
| 137 | virtual void update(); |
---|
[2260] | 138 | |
---|
[3330] | 139 | void computeDataScale(); |
---|
| 140 | |
---|
[2270] | 141 | vtkAlgorithmOutput *initWarp(vtkAlgorithmOutput *input); |
---|
[3680] | 142 | vtkAlgorithmOutput *initWarp(vtkDataSet *input); |
---|
[2260] | 143 | |
---|
| 144 | int _numContours; |
---|
| 145 | std::vector<double> _contours; |
---|
| 146 | |
---|
[3330] | 147 | bool _contourColorMap; |
---|
[2260] | 148 | float _contourEdgeColor[3]; |
---|
| 149 | float _contourEdgeWidth; |
---|
| 150 | double _warpScale; |
---|
[2290] | 151 | double _dataScale; |
---|
| 152 | Axis _sliceAxis; |
---|
[2270] | 153 | bool _pipelineInitialized; |
---|
[2260] | 154 | |
---|
[3680] | 155 | CloudStyle _cloudStyle; |
---|
[3330] | 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 | |
---|
[2260] | 165 | vtkSmartPointer<vtkLookupTable> _lut; |
---|
[3680] | 166 | vtkSmartPointer<vtkPolyDataMapper> _mapper; |
---|
[2260] | 167 | vtkSmartPointer<vtkContourFilter> _contourFilter; |
---|
| 168 | vtkSmartPointer<vtkPolyDataMapper> _contourMapper; |
---|
[3680] | 169 | vtkSmartPointer<vtkGaussianSplatter> _splatter; |
---|
[2260] | 170 | vtkSmartPointer<vtkExtractVOI> _volumeSlicer; |
---|
[2457] | 171 | vtkSmartPointer<vtkPlane> _cutPlane; |
---|
[2260] | 172 | vtkSmartPointer<vtkWarpScalar> _warp; |
---|
[3330] | 173 | vtkSmartPointer<vtkPolyDataNormals> _normalsGenerator; |
---|
[2260] | 174 | vtkSmartPointer<vtkActor> _dsActor; |
---|
| 175 | vtkSmartPointer<vtkActor> _contourActor; |
---|
| 176 | }; |
---|
| 177 | |
---|
| 178 | } |
---|
| 179 | |
---|
| 180 | #endif |
---|