Changeset 4234
- Timestamp:
- Mar 11, 2014 11:24:01 AM (10 years ago)
- Location:
- branches/1.3
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3
-
branches/1.3/packages/vizservers/vtkvis/ColorMap.cpp
r4233 r4234 37 37 } 38 38 39 ColorMap::ColorMap(const ColorMap& other) : 40 _name(other._name), 41 _controlPoints(other._controlPoints), 42 _opacityControlPoints(other._opacityControlPoints), 43 _needsBuild(other._needsBuild), 44 _numTableEntries(other._numTableEntries) 45 { 46 _colorTF = vtkSmartPointer<vtkColorTransferFunction>::New(); 47 _colorTF->ClampingOn(); 48 _opacityTF = vtkSmartPointer<vtkPiecewiseFunction>::New(); 49 _opacityTF->ClampingOn(); 50 _colorTF->DeepCopy(other._colorTF); 51 _opacityTF->DeepCopy(other._opacityTF); 52 if (other._lookupTable != NULL) { 53 _lookupTable = vtkSmartPointer<vtkLookupTable>::New(); 54 _lookupTable->DeepCopy(other._lookupTable); 55 } 56 } 57 58 ColorMap& ColorMap::operator=(const ColorMap& other) 59 { 60 if (&other != this) { 61 _name = other._name; 62 _controlPoints = other._controlPoints; 63 _opacityControlPoints = other._opacityControlPoints; 64 _needsBuild = other._needsBuild; 65 _numTableEntries = other._numTableEntries; 66 _colorTF->DeepCopy(other._colorTF); 67 _opacityTF->DeepCopy(other._opacityTF); 68 if (other._lookupTable != NULL) { 69 _lookupTable = vtkSmartPointer<vtkLookupTable>::New(); 70 _lookupTable->DeepCopy(other._lookupTable); 71 } 72 } 73 return *this; 74 } 75 39 76 ColorMap::~ColorMap() 40 77 { … … 70 107 for (int i = 0; i < _colorTF->GetSize(); i++) { 71 108 _colorTF->GetNodeValue(i, tmp); 109 //TRACE("Norm: %d: %g %g,%g,%g", i, tmp[0], tmp[1], tmp[2], tmp[3]); 72 110 tmp[0] = range[0] + tmp[0] * (range[1] - range[0]); 73 111 tf->AddRGBPoint(tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5]); 112 //TRACE("New : %d: %g %g,%g,%g", i, tmp[0], tmp[1], tmp[2], tmp[3]); 74 113 } 75 114 return tf; … … 81 120 */ 82 121 vtkSmartPointer<vtkPiecewiseFunction> 83 ColorMap::getOpacityTransferFunction(double range[2] )122 ColorMap::getOpacityTransferFunction(double range[2], double opacityScale) 84 123 { 85 124 vtkSmartPointer<vtkPiecewiseFunction> tf = vtkSmartPointer<vtkPiecewiseFunction>::New(); … … 87 126 for (int i = 0; i < _opacityTF->GetSize(); i++) { 88 127 _opacityTF->GetNodeValue(i, tmp); 128 //TRACE("Norm: %d: %g %g", i, tmp[0], tmp[1]); 89 129 tmp[0] = range[0] + tmp[0] * (range[1] - range[0]); 130 if (opacityScale < 1.0) { 131 tmp[1] *= opacityScale; 132 } 90 133 tf->AddPoint(tmp[0], tmp[1], tmp[2], tmp[3]); 134 //TRACE("New : %d: %g %g", i, tmp[0], tmp[1]); 91 135 } 92 136 return tf; … … 106 150 107 151 #ifdef DEBUG 108 TRACE("New control point: %g 152 TRACE("New control point: %g = %g %g %g", 109 153 cp.value, cp.color[0], cp.color[1], cp.color[2]); 110 154 #endif … … 137 181 138 182 #ifdef DEBUG 139 TRACE("New opacity control point: %g 183 TRACE("New opacity control point: %g = %g", 140 184 cp.value, cp.alpha); 141 185 #endif -
branches/1.3/packages/vizservers/vtkvis/ColorMap.h
r3616 r4234 83 83 84 84 ColorMap(const std::string& name); 85 86 ColorMap(const ColorMap& other); 87 88 ColorMap& operator=(const ColorMap& other); 89 85 90 virtual ~ColorMap(); 86 91 … … 91 96 vtkSmartPointer<vtkColorTransferFunction> getColorTransferFunction(double range[2]); 92 97 93 vtkSmartPointer<vtkPiecewiseFunction> getOpacityTransferFunction(double range[2] );98 vtkSmartPointer<vtkPiecewiseFunction> getOpacityTransferFunction(double range[2], double opacityScale = 1.0); 94 99 95 100 void setNumberOfTableEntries(int numEntries); -
branches/1.3/packages/vizservers/vtkvis/Image.cpp
r3844 r4234 9 9 #include <vtkImageData.h> 10 10 #include <vtkImageActor.h> 11 #include <vtkImageSlice.h> 11 12 #include <vtkImageProperty.h> 12 13 #include <vtkImageMapper3D.h> 14 #include <vtkImageResliceMapper.h> 13 15 #include <vtkLookupTable.h> 14 16 … … 17 19 18 20 using namespace VtkVis; 21 22 #define USE_RESLICE_MAPPER 19 23 20 24 Image::Image() : … … 32 36 { 33 37 if (_prop == NULL) { 38 #ifdef USE_RESLICE_MAPPER 39 _prop = vtkSmartPointer<vtkImageSlice>::New(); 40 #else 34 41 _prop = vtkSmartPointer<vtkImageActor>::New(); 42 #endif 35 43 vtkImageProperty *property = getImageProperty(); 36 44 property->SetInterpolationTypeToLinear(); … … 64 72 65 73 vtkImageActor *actor = getImageActor(); 66 actor->SetInputData(imageData); 67 actor->InterpolateOn(); 74 vtkImageMapper3D *mapper = getImageMapper(); 75 if (mapper == NULL) { 76 TRACE("Creating mapper"); 77 vtkSmartPointer<vtkImageResliceMapper> newMapper = vtkSmartPointer<vtkImageResliceMapper>::New(); 78 getImageSlice()->SetMapper(newMapper); 79 mapper = getImageMapper(); 80 assert(mapper != NULL); 81 } 82 if (actor != NULL) { 83 TRACE("Have actor"); 84 actor->SetInputData(imageData); 85 actor->InterpolateOn(); 86 } else { 87 TRACE("No actor"); 88 mapper->SetInputData(imageData); 89 } 68 90 69 vtkImageMapper3D *mapper = getImageMapper(); 91 mapper->SliceAtFocalPointOn(); 92 mapper->SliceFacesCameraOn(); 93 94 vtkImageResliceMapper *resliceMapper = getImageResliceMapper(); 95 if (resliceMapper) { 96 TRACE("Mapper is a vtkImageResliceMapper"); 97 resliceMapper->AutoAdjustImageQualityOff(); 98 resliceMapper->ResampleToScreenPixelsOff(); 99 } else { 100 TRACE("Mapper is a %s", mapper->GetClassName()); 101 } 102 70 103 mapper->Update(); 71 104 } -
branches/1.3/packages/vizservers/vtkvis/Image.h
r4231 r4234 10 10 11 11 #include <vtkSmartPointer.h> 12 #include <vtkImageSlice.h> 12 13 #include <vtkImageActor.h> 13 14 #include <vtkImageMapper3D.h> 15 #include <vtkImageResliceMapper.h> 16 #include <vtkImageSliceMapper.h> 14 17 #include <vtkLookupTable.h> 15 18 #include <vtkPlaneCollection.h> … … 141 144 vtkImageProperty *getImageProperty() 142 145 { 143 if (getImage Actor() != NULL) {144 return getImage Actor()->GetProperty();146 if (getImageSlice() != NULL) { 147 return getImageSlice()->GetProperty(); 145 148 } else { 146 149 return NULL; … … 150 153 vtkImageMapper3D *getImageMapper() 151 154 { 152 if (getImageActor() != NULL) { 153 return getImageActor()->GetMapper(); 155 if (getImageSlice() != NULL) { 156 return getImageSlice()->GetMapper(); 157 } else { 158 return NULL; 159 } 160 } 161 162 vtkImageResliceMapper *getImageResliceMapper() 163 { 164 if (getImageSlice() != NULL) { 165 return vtkImageResliceMapper::SafeDownCast(getImageSlice()->GetMapper()); 166 } else { 167 return NULL; 168 } 169 } 170 171 vtkImageSliceMapper *getImageSliceMapper() 172 { 173 if (getImageSlice() != NULL) { 174 return vtkImageSliceMapper::SafeDownCast(getImageSlice()->GetMapper()); 154 175 } else { 155 176 return NULL; -
branches/1.3/packages/vizservers/vtkvis/RendererCmd.cpp
r4231 r4234 2509 2509 static Rappture::CmdSpec colorMapOps[] = { 2510 2510 {"add", 1, ColorMapAddOp, 5, 5, "colorMapName colormap alphamap"}, 2511 {"delete", 1, ColorMapDeleteOp, 2, 3, "?colorMapName?"}, 2511 {"define", 3, ColorMapAddOp, 5, 5, "colorMapName colormap alphamap"}, 2512 {"delete", 3, ColorMapDeleteOp, 2, 3, "?colorMapName?"}, 2512 2513 {"res", 1, ColorMapNumTableEntriesOp, 3, 4, "numTableEntries ?colorMapName?"} 2513 2514 }; … … 7165 7166 range[1] = -DBL_MAX; 7166 7167 7168 bool opaque = true; 7169 7167 7170 if (objc == 9) { 7168 7171 const char *dataSetName = Tcl_GetString(objv[8]); 7169 7172 if (!g_renderer->renderColorMap(colorMapName, dataSetName, legendType, fieldName, title, 7170 range, width, height, true, numLabels, imgData)) {7173 range, width, height, opaque, numLabels, imgData)) { 7171 7174 Tcl_AppendResult(interp, "Color map \"", 7172 7175 colorMapName, "\" or dataset \"", … … 7176 7179 } else { 7177 7180 if (!g_renderer->renderColorMap(colorMapName, "all", legendType, fieldName, title, 7178 range, width, height, true, numLabels, imgData)) {7181 range, width, height, opaque, numLabels, imgData)) { 7179 7182 Tcl_AppendResult(interp, "Color map \"", 7180 7183 colorMapName, "\" was not found", (char*)NULL); … … 7237 7240 vtkSmartPointer<vtkUnsignedCharArray>::New(); 7238 7241 7239 if (!g_renderer->renderColorMap(colorMapName, width, height, true, imgData)) { 7242 bool opaque = true; 7243 7244 if (!g_renderer->renderColorMap(colorMapName, width, height, opaque, imgData)) { 7240 7245 Tcl_AppendResult(interp, "Color map \"", 7241 7246 colorMapName, "\" was not found", (char*)NULL); … … 7273 7278 # endif // USE_THREADS 7274 7279 #endif // DEBUG 7280 7275 7281 return TCL_OK; 7276 7282 } … … 11936 11942 double distance; 11937 11943 double maxFactor = 4.0; 11944 #if 1 11945 distance = 1.0 / (quality * (maxFactor - 1.0) + 1.0); 11946 #else 11938 11947 if (quality >= 0.5) { 11939 11948 distance = 1.0 / ((quality - 0.5) * (maxFactor - 1.0) * 2.0 + 1.0); … … 11941 11950 distance = ((0.5 - quality) * (maxFactor - 1.0) * 2.0 + 1.0); 11942 11951 } 11952 #endif 11943 11953 if (objc == 4) { 11944 11954 const char *name = Tcl_GetString(objv[3]); -
branches/1.3/packages/vizservers/vtkvis/Volume.cpp
r4231 r4234 213 213 if (getVolume() != NULL) { 214 214 getVolume()->GetProperty()->SetColor(_colorMap->getColorTransferFunction(_dataRange)); 215 #ifdef USE_GPU_RAYCAST_MAPPER 216 getVolume()->GetProperty()->SetScalarOpacity(_colorMap->getOpacityTransferFunction(_dataRange, _opacity)); 217 #else 215 218 getVolume()->GetProperty()->SetScalarOpacity(_colorMap->getOpacityTransferFunction(_dataRange)); 219 #endif 216 220 } 217 221 } … … 234 238 if (getVolume() != NULL) { 235 239 getVolume()->GetProperty()->SetColor(_colorMap->getColorTransferFunction(_dataRange)); 240 #ifdef USE_GPU_RAYCAST_MAPPER 241 getVolume()->GetProperty()->SetScalarOpacity(_colorMap->getOpacityTransferFunction(_dataRange, _opacity)); 242 #else 236 243 getVolume()->GetProperty()->SetScalarOpacity(_colorMap->getOpacityTransferFunction(_dataRange)); 244 #endif 237 245 } 238 246 } … … 256 264 // 3D texture mapper, not the GPU raycast mapper 257 265 if (getVolume() != NULL) { 266 #ifdef USE_GPU_RAYCAST_MAPPER 267 getVolume()->GetProperty()->SetScalarOpacity(_colorMap->getOpacityTransferFunction(_dataRange, opacity)); 268 #else 258 269 if (opacity < 1.0e-6) 259 270 opacity = 1.0e-6; 260 271 getVolume()->GetProperty()->SetScalarOpacityUnitDistance(1.0/opacity); 272 #endif 261 273 } 262 274 } -
branches/1.3/packages/vizservers/vtkvis/protocol.txt
r4231 r4234 189 189 190 190 colormap add <colorMapName> <colorMap> <opacityMap> 191 (Re-)define a colormap. If colorMapName doesn't exist, it is created, 192 otherwise the colormap is redefined and all users will be updated. 191 193 colorMap = Tcl list of {value r g b} control points 192 194 opacityMap = Tcl list of {value alpha} control points 195 colormap define <colorMapName> <colorMap> <opacityMap> 196 (Re-)define a colormap (same as 'add') 193 197 colormap delete <?colorMapName?> 194 198 colormap res <numberOfTableEntries>
Note: See TracChangeset
for help on using the changeset viewer.