Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | 1x 1x 16x 16x 16x 24x 24x 24x 24x 24x 24x 16x 42x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 1x 16x 1x 16x 16x 16x 16x 1x 16x 16x 16x 16x 16x 16x 1x | import macro from 'vtk.js/Sources/macros'; import * as vtkMath from 'vtk.js/Sources/Common/Core/Math'; import Constants from 'vtk.js/Sources/Rendering/Core/VolumeMapper/Constants'; import vtkAbstractMapper3D from 'vtk.js/Sources/Rendering/Core/AbstractMapper3D'; import vtkPiecewiseFunction from 'vtk.js/Sources/Common/DataModel/PiecewiseFunction'; const { BlendMode, FilterMode } = Constants; function createRadonTransferFunction( firstAbsorbentMaterialHounsfieldValue, firstAbsorbentMaterialAbsorption, maxAbsorbentMaterialHounsfieldValue, maxAbsorbentMaterialAbsorption, outputTransferFunction ) { let ofun = null; if (outputTransferFunction) { ofun = outputTransferFunction; ofun.removeAllPoints(); } else { ofun = vtkPiecewiseFunction.newInstance(); } ofun.addPointLong(-1024, 0, 1, 1); // air (i.e. material with no absorption) ofun.addPoint( firstAbsorbentMaterialHounsfieldValue, firstAbsorbentMaterialAbsorption ); ofun.addPoint( maxAbsorbentMaterialHounsfieldValue, maxAbsorbentMaterialAbsorption ); return ofun; } // ---------------------------------------------------------------------------- // Static API // ---------------------------------------------------------------------------- export const STATIC = { createRadonTransferFunction, }; // ---------------------------------------------------------------------------- // vtkVolumeMapper methods // ---------------------------------------------------------------------------- function vtkVolumeMapper(publicAPI, model) { // Set our className model.classHierarchy.push('vtkVolumeMapper'); const superClass = { ...publicAPI }; publicAPI.getBounds = () => { const input = publicAPI.getInputData(); Iif (!input) { model.bounds = vtkMath.createUninitializedBounds(); } else { if (!model.static) { publicAPI.update(); } model.bounds = input.getBounds(); } return model.bounds; }; publicAPI.update = () => { publicAPI.getInputData(); }; publicAPI.setBlendModeToComposite = () => { publicAPI.setBlendMode(BlendMode.COMPOSITE_BLEND); }; publicAPI.setBlendModeToMaximumIntensity = () => { publicAPI.setBlendMode(BlendMode.MAXIMUM_INTENSITY_BLEND); }; publicAPI.setBlendModeToMinimumIntensity = () => { publicAPI.setBlendMode(BlendMode.MINIMUM_INTENSITY_BLEND); }; publicAPI.setBlendModeToAverageIntensity = () => { publicAPI.setBlendMode(BlendMode.AVERAGE_INTENSITY_BLEND); }; publicAPI.setBlendModeToAdditiveIntensity = () => { publicAPI.setBlendMode(BlendMode.ADDITIVE_INTENSITY_BLEND); }; publicAPI.setBlendModeToRadonTransform = () => { publicAPI.setBlendMode(BlendMode.RADON_TRANSFORM_BLEND); }; publicAPI.getBlendModeAsString = () => macro.enumToString(BlendMode, model.blendMode); publicAPI.setAverageIPScalarRange = (min, max) => { console.warn('setAverageIPScalarRange is deprecated use setIpScalarRange'); publicAPI.setIpScalarRange(min, max); }; publicAPI.getFilterModeAsString = () => macro.enumToString(FilterMode, model.filterMode); publicAPI.setFilterModeToOff = () => { publicAPI.setFilterMode(FilterMode.OFF); }; publicAPI.setFilterModeToNormalized = () => { publicAPI.setFilterMode(FilterMode.NORMALIZED); }; publicAPI.setFilterModeToRaw = () => { publicAPI.setFilterMode(FilterMode.RAW); }; publicAPI.setGlobalIlluminationReach = (gl) => superClass.setGlobalIlluminationReach(vtkMath.clampValue(gl, 0.0, 1.0)); publicAPI.setVolumetricScatteringBlending = (vsb) => superClass.setVolumetricScatteringBlending( vtkMath.clampValue(vsb, 0.0, 1.0) ); publicAPI.setVolumeShadowSamplingDistFactor = (vsdf) => superClass.setVolumeShadowSamplingDistFactor(vsdf >= 1.0 ? vsdf : 1.0); publicAPI.setAnisotropy = (at) => superClass.setAnisotropy(vtkMath.clampValue(at, -0.99, 0.99)); publicAPI.setLAOKernelSize = (ks) => superClass.setLAOKernelSize(vtkMath.floor(vtkMath.clampValue(ks, 1, 32))); publicAPI.setLAOKernelRadius = (kr) => superClass.setLAOKernelRadius(kr >= 1 ? kr : 1); } // ---------------------------------------------------------------------------- // Object factory // ---------------------------------------------------------------------------- // TODO: what values to use for averageIPScalarRange to get GLSL to use max / min values like [-Math.inf, Math.inf]? const DEFAULT_VALUES = { bounds: [1, -1, 1, -1, 1, -1], sampleDistance: 1.0, imageSampleDistance: 1.0, maximumSamplesPerRay: 1000, autoAdjustSampleDistances: true, initialInteractionScale: 1.0, interactionSampleDistanceFactor: 1.0, blendMode: BlendMode.COMPOSITE_BLEND, ipScalarRange: [-1000000.0, 1000000.0], filterMode: FilterMode.OFF, // ignored by WebGL so no behavior change preferSizeOverAccuracy: false, // Whether to use halfFloat representation of float, when it is inaccurate computeNormalFromOpacity: false, // volume shadow parameters volumetricScatteringBlending: 0.0, globalIlluminationReach: 0.0, volumeShadowSamplingDistFactor: 5.0, anisotropy: 0.0, // local ambient occlusion localAmbientOcclusion: false, LAOKernelSize: 15, LAOKernelRadius: 7, }; // ---------------------------------------------------------------------------- export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); vtkAbstractMapper3D.extend(publicAPI, model, initialValues); macro.setGet(publicAPI, model, [ 'sampleDistance', 'imageSampleDistance', 'maximumSamplesPerRay', 'autoAdjustSampleDistances', 'initialInteractionScale', 'interactionSampleDistanceFactor', 'blendMode', 'filterMode', 'preferSizeOverAccuracy', 'computeNormalFromOpacity', 'volumetricScatteringBlending', 'globalIlluminationReach', 'volumeShadowSamplingDistFactor', 'anisotropy', 'localAmbientOcclusion', 'LAOKernelSize', 'LAOKernelRadius', ]); macro.setGetArray(publicAPI, model, ['ipScalarRange'], 2); macro.event(publicAPI, model, 'lightingActivated'); // Object methods vtkVolumeMapper(publicAPI, model); } // ---------------------------------------------------------------------------- export const newInstance = macro.newInstance(extend, 'vtkVolumeMapper'); // ---------------------------------------------------------------------------- export default { newInstance, extend, ...STATIC }; |