All files / Sources/Rendering/Core/Mapper index.js

75.35% Statements 214/284
63.41% Branches 78/123
68.75% Functions 22/32
77.61% Lines 208/268

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 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678                              1x   1x   1x 1x 1x         3930x                 786x   786x 730x 730x     730x 730x   730x   730x     786x         786x 817x           786x 29x     786x 1x   786x 786x 786x   786x 1x   786x 786x 786x 786x 786x 786x   786x               8742x 3x     8739x 8739x     8739x 8352x 8352x 7531x 7531x   387x   387x     387x 387x 387x     387x                                     8739x     786x 898x               898x 754x 754x 754x 754x       144x 144x   144x 140x               144x 130x   14x 14x   14x 14x   14x 14x             144x       786x           944x 944x 944x               912x   912x                 912x   912x       944x       786x                             130x   130x 130x 130x 130x   130x 130x   130x 130x 130x                                                 130x 130x 944x 944x             944x         944x 944x 944x 944x         786x 130x 130x 130x         130x         130x       130x           130x 130x         130x 130x 130x 127x   130x 1x   130x 130x   130x   130x 520780x 520780x         130x 520780x     130x 130x   130x         130x     130x         130x               130x     130x 130x     130x         130x     130x             130x                               786x 7629x 7629x             7629x 7629x   6872x   757x 757x   757x 757x         786x 144x 13x       131x 1x     130x             130x   130x         130x       130x                   130x     786x           786x 1082x 29x   1082x     786x 7355x 7355x 1249x 1249x   7355x     786x                                 786x     786x 786x 786x 786x   786x   327x               327x 327x 327x 327x   327x 327x 306x 21x 21x     327x       327x 61476x 20492x 20492x       20492x 20492x 20492x 20492x 20492x   20492x 20492x 20492x 20492x 20492x 40984x                                             1x                                                                           786x     786x   786x           786x                             786x   786x     786x         1x                      
import macro from 'vtk.js/Sources/macros';
import vtkAbstractMapper3D from 'vtk.js/Sources/Rendering/Core/AbstractMapper3D';
import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray';
import vtkImageData from 'vtk.js/Sources/Common/DataModel/ImageData';
import vtkLookupTable from 'vtk.js/Sources/Common/Core/LookupTable';
import * as vtkMath from 'vtk.js/Sources/Common/Core/Math';
import vtkScalarsToColors from 'vtk.js/Sources/Common/Core/ScalarsToColors/Constants'; // Need to go inside Constants otherwise dependency loop
 
import CoincidentTopologyHelper from 'vtk.js/Sources/Rendering/Core/Mapper/CoincidentTopologyHelper';
import Constants from 'vtk.js/Sources/Rendering/Core/Mapper/Constants';
 
import vtkDataSet from 'vtk.js/Sources/Common/DataModel/DataSet';
 
import { PassTypes } from 'vtk.js/Sources/Rendering/OpenGL/HardwareSelector/Constants';
 
const { FieldAssociations } = vtkDataSet;
 
const { staticOffsetAPI, otherStaticMethods } = CoincidentTopologyHelper;
 
const { ColorMode, ScalarMode, GetArray } = Constants;
const { VectorMode } = vtkScalarsToColors;
const { VtkDataTypes } = vtkDataArray;
 
// ----------------------------------------------------------------------------
 
function notImplemented(method) {
  return () => macro.vtkErrorMacro(`vtkMapper::${method} - NOT IMPLEMENTED`);
}
 
// ----------------------------------------------------------------------------
// vtkMapper methods
// ----------------------------------------------------------------------------
 
function vtkMapper(publicAPI, model) {
  // Set our className
  model.classHierarchy.push('vtkMapper');
 
  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.setForceCompileOnly = (v) => {
    model.forceCompileOnly = v;
    // make sure we do NOT call modified()
  };
 
  publicAPI.setSelectionWebGLIdsToVTKIds = (selectionWebGLIdsToVTKIds) => {
    model.selectionWebGLIdsToVTKIds = selectionWebGLIdsToVTKIds;
    // make sure we do NOT call modified()
    // this attribute is only used when processing a selection made with the hardware selector
    // the mtime of the mapper doesn't need to be changed
  };
 
  publicAPI.createDefaultLookupTable = () => {
    model.lookupTable = vtkLookupTable.newInstance();
  };
 
  publicAPI.getColorModeAsString = () =>
    macro.enumToString(ColorMode, model.colorMode);
 
  publicAPI.setColorModeToDefault = () => publicAPI.setColorMode(0);
  publicAPI.setColorModeToMapScalars = () => publicAPI.setColorMode(1);
  publicAPI.setColorModeToDirectScalars = () => publicAPI.setColorMode(2);
 
  publicAPI.getScalarModeAsString = () =>
    macro.enumToString(ScalarMode, model.scalarMode);
 
  publicAPI.setScalarModeToDefault = () => publicAPI.setScalarMode(0);
  publicAPI.setScalarModeToUsePointData = () => publicAPI.setScalarMode(1);
  publicAPI.setScalarModeToUseCellData = () => publicAPI.setScalarMode(2);
  publicAPI.setScalarModeToUsePointFieldData = () => publicAPI.setScalarMode(3);
  publicAPI.setScalarModeToUseCellFieldData = () => publicAPI.setScalarMode(4);
  publicAPI.setScalarModeToUseFieldData = () => publicAPI.setScalarMode(5);
 
  publicAPI.getAbstractScalars = (
    input,
    scalarMode,
    arrayAccessMode,
    arrayId,
    arrayName
  ) => {
    // make sure we have an input
    if (!input || !model.scalarVisibility) {
      return { scalars: null, cellFLag: false };
    }
 
    let scalars = null;
    let cellFlag = false;
 
    // get and scalar data according to scalar mode
    if (scalarMode === ScalarMode.DEFAULT) {
      scalars = input.getPointData().getScalars();
      if (!scalars) {
        scalars = input.getCellData().getScalars();
        cellFlag = true;
      }
    } else Iif (scalarMode === ScalarMode.USE_POINT_DATA) {
      scalars = input.getPointData().getScalars();
    } else Iif (scalarMode === ScalarMode.USE_CELL_DATA) {
      scalars = input.getCellData().getScalars();
      cellFlag = true;
    } else if (scalarMode === ScalarMode.USE_POINT_FIELD_DATA) {
      const pd = input.getPointData();
      Iif (arrayAccessMode === GetArray.BY_ID) {
        scalars = pd.getArrayByIndex(arrayId);
      } else {
        scalars = pd.getArrayByName(arrayName);
      }
    } else Eif (scalarMode === ScalarMode.USE_CELL_FIELD_DATA) {
      const cd = input.getCellData();
      cellFlag = true;
      if (arrayAccessMode === GetArray.BY_ID) {
        scalars = cd.getArrayByIndex(arrayId);
      } else {
        scalars = cd.getArrayByName(arrayName);
      }
    } else if (scalarMode === ScalarMode.USE_FIELD_DATA) {
      const fd = input.getFieldData();
      if (arrayAccessMode === GetArray.BY_ID) {
        scalars = fd.getArrayByIndex(arrayId);
      } else {
        scalars = fd.getArrayByName(arrayName);
      }
    }
 
    return { scalars, cellFlag };
  };
 
  publicAPI.mapScalars = (input, alpha) => {
    const scalars = publicAPI.getAbstractScalars(
      input,
      model.scalarMode,
      model.arrayAccessMode,
      model.arrayId,
      model.colorByArrayName
    ).scalars;
 
    if (!scalars) {
      model.colorCoordinates = null;
      model.colorTextureMap = null;
      model.colorMapColors = null;
      return;
    }
 
    // we want to only recompute when something has changed
    const toString = `${publicAPI.getMTime()}${scalars.getMTime()}${alpha}`;
    Iif (model.colorBuildString === toString) return;
 
    if (!model.useLookupTableScalarRange) {
      publicAPI
        .getLookupTable()
        .setRange(model.scalarRange[0], model.scalarRange[1]);
    }
 
    // Decide between texture color or vertex color.
    // Cell data always uses vertex color.
    // Only point data can use both texture and vertex coloring.
    if (publicAPI.canUseTextureMapForColoring(input)) {
      publicAPI.mapScalarsToTexture(scalars, alpha);
    } else {
      model.colorCoordinates = null;
      model.colorTextureMap = null;
 
      const lut = publicAPI.getLookupTable();
      if (lut) {
        // Ensure that the lookup table is built
        lut.build();
        model.colorMapColors = lut.mapScalars(
          scalars,
          model.colorMode,
          model.fieldDataTupleId
        );
      }
    }
    model.colorBuildString = `${publicAPI.getMTime()}${scalars.getMTime()}${alpha}`;
  };
 
  //-----------------------------------------------------------------------------
  publicAPI.scalarToTextureCoordinate = (
    scalarValue, // Input scalar
    rangeMin, // range[0]
    invRangeWidth
  ) => {
    // 1/(range[1]-range[0])
    let texCoordS = 0.5; // Scalar value is arbitrary when NaN
    let texCoordT = 1.0; // 1.0 in t coordinate means NaN
    if (!vtkMath.isNan(scalarValue)) {
      // 0.0 in t coordinate means not NaN.  So why am I setting it to 0.49?
      // Because when you are mapping scalars and you have a NaN adjacent to
      // anything else, the interpolation everywhere should be NaN.  Thus, I
      // want the NaN color everywhere except right on the non-NaN neighbors.
      // To simulate this, I set the t coord for the real numbers close to
      // the threshold so that the interpolation almost immediately looks up
      // the NaN value.
      texCoordT = 0.49;
 
      texCoordS = (scalarValue - rangeMin) * invRangeWidth;
 
      // Some implementations apparently don't handle relatively large
      // numbers (compared to the range [0.0, 1.0]) very well. In fact,
      // values above 1122.0f appear to cause texture wrap-around on
      // some systems even when edge clamping is enabled. Why 1122.0f? I
      // don't know. For safety, we'll clamp at +/- 1000. This will
      // result in incorrect images when the texture value should be
      // above or below 1000, but I don't have a better solution.
      Iif (texCoordS > 1000.0) {
        texCoordS = 1000.0;
      } else Iif (texCoordS < -1000.0) {
        texCoordS = -1000.0;
      }
    }
    return { texCoordS, texCoordT };
  };
 
  //-----------------------------------------------------------------------------
  publicAPI.createColorTextureCoordinates = (
    input,
    output,
    numScalars,
    numComps,
    component,
    range,
    tableRange,
    tableNumberOfColors,
    useLogScale
  ) => {
    // We have to change the range used for computing texture
    // coordinates slightly to accommodate the special above- and
    // below-range colors that are the first and last texels,
    // respectively.
    const scalarTexelWidth = (range[1] - range[0]) / tableNumberOfColors;
 
    const paddedRange = [];
    paddedRange[0] = range[0] - scalarTexelWidth;
    paddedRange[1] = range[1] + scalarTexelWidth;
    const invRangeWidth = 1.0 / (paddedRange[1] - paddedRange[0]);
 
    const outputV = output.getData();
    const inputV = input.getData();
 
    let count = 0;
    let outputCount = 0;
    Iif (component < 0 || component >= numComps) {
      for (let scalarIdx = 0; scalarIdx < numScalars; ++scalarIdx) {
        let sum = 0;
        for (let compIdx = 0; compIdx < numComps; ++compIdx) {
          sum += inputV[count] * inputV[count];
          count++;
        }
        let magnitude = Math.sqrt(sum);
        if (useLogScale) {
          magnitude = vtkLookupTable.applyLogScale(
            magnitude,
            tableRange,
            range
          );
        }
        const outputs = publicAPI.scalarToTextureCoordinate(
          magnitude,
          paddedRange[0],
          invRangeWidth
        );
        outputV[outputCount] = outputs.texCoordS;
        outputV[outputCount + 1] = outputs.texCoordT;
        outputCount += 2;
      }
    } else {
      count += component;
      for (let scalarIdx = 0; scalarIdx < numScalars; ++scalarIdx) {
        let inputValue = inputV[count];
        Iif (useLogScale) {
          inputValue = vtkLookupTable.applyLogScale(
            inputValue,
            tableRange,
            range
          );
        }
        const outputs = publicAPI.scalarToTextureCoordinate(
          inputValue,
          paddedRange[0],
          invRangeWidth
        );
        outputV[outputCount] = outputs.texCoordS;
        outputV[outputCount + 1] = outputs.texCoordT;
        outputCount += 2;
        count += numComps;
      }
    }
  };
 
  publicAPI.mapScalarsToTexture = (scalars, alpha) => {
    const range = model.lookupTable.getRange();
    const useLogScale = model.lookupTable.usingLogScale();
    Iif (useLogScale) {
      // convert range to log.
      vtkLookupTable.getLogRange(range, range);
    }
 
    const origAlpha = model.lookupTable.getAlpha();
 
    // Get rid of vertex color array.  Only texture or vertex coloring
    // can be active at one time.  The existence of the array is the
    // signal to use that technique.
    model.colorMapColors = null;
 
    // If the lookup table has changed, then recreate the color texture map.
    // Set a new lookup table changes this->MTime.
    if (
      model.colorTextureMap == null ||
      publicAPI.getMTime() > model.colorTextureMap.getMTime() ||
      model.lookupTable.getMTime() > model.colorTextureMap.getMTime() ||
      model.lookupTable.getAlpha() !== alpha
    ) {
      model.lookupTable.setAlpha(alpha);
      model.colorTextureMap = null;
 
      // Get the texture map from the lookup table.
      // Create a dummy ramp of scalars.
      // In the future, we could extend vtkScalarsToColors.
      model.lookupTable.build();
      let numberOfColors = model.lookupTable.getNumberOfAvailableColors();
      if (numberOfColors > 4094) {
        numberOfColors = 4094;
      }
      if (numberOfColors < 64) {
        numberOfColors = 64;
      }
      numberOfColors += 2;
      const k = (range[1] - range[0]) / (numberOfColors - 2);
 
      const newArray = new Float64Array(numberOfColors * 2);
 
      for (let i = 0; i < numberOfColors; ++i) {
        newArray[i] = range[0] + i * k - k / 2.0; // minus k / 2 to start at below range color
        Iif (useLogScale) {
          newArray[i] = 10.0 ** newArray[i];
        }
      }
      // Dimension on NaN.
      for (let i = 0; i < numberOfColors; ++i) {
        newArray[i + numberOfColors] = NaN;
      }
 
      model.colorTextureMap = vtkImageData.newInstance();
      model.colorTextureMap.setExtent(0, numberOfColors - 1, 0, 1, 0, 0);
 
      const tmp = vtkDataArray.newInstance({
        numberOfComponents: 1,
        values: newArray,
      });
 
      model.colorTextureMap
        .getPointData()
        .setScalars(model.lookupTable.mapScalars(tmp, model.colorMode, 0));
      model.lookupTable.setAlpha(origAlpha);
    }
 
    // Create new coordinates if necessary.
    // Need to compare lookup table in case the range has changed.
    if (
      !model.colorCoordinates ||
      publicAPI.getMTime() > model.colorCoordinates.getMTime() ||
      publicAPI.getInputData(0).getMTime() >
        model.colorCoordinates.getMTime() ||
      model.lookupTable.getMTime() > model.colorCoordinates.getMTime()
    ) {
      // Get rid of old colors
      model.colorCoordinates = null;
 
      // Now create the color texture coordinates.
      const numComps = scalars.getNumberOfComponents();
      const num = scalars.getNumberOfTuples();
 
      // const fArray = new FloatArray(num * 2);
      model.colorCoordinates = vtkDataArray.newInstance({
        numberOfComponents: 2,
        values: new Float32Array(num * 2),
      });
 
      let scalarComponent = model.lookupTable.getVectorComponent();
      // Although I like the feature of applying magnitude to single component
      // scalars, it is not how the old MapScalars for vertex coloring works.
      Iif (
        model.lookupTable.getVectorMode() === VectorMode.MAGNITUDE &&
        scalars.getNumberOfComponents() > 1
      ) {
        scalarComponent = -1;
      }
 
      publicAPI.createColorTextureCoordinates(
        scalars,
        model.colorCoordinates,
        num,
        numComps,
        scalarComponent,
        range,
        model.lookupTable.getRange(),
        model.colorTextureMap.getPointData().getScalars().getNumberOfTuples() /
          2 -
          2,
        useLogScale
      );
    }
  };
 
  publicAPI.getIsOpaque = () => {
    const input = publicAPI.getInputData();
    const gasResult = publicAPI.getAbstractScalars(
      input,
      model.scalarMode,
      model.arrayAccessMode,
      model.arrayId,
      model.colorByArrayName
    );
    const scalars = gasResult.scalars;
    if (!model.scalarVisibility || scalars == null) {
      // No scalar colors.
      return true;
    }
    const lut = publicAPI.getLookupTable();
    if (lut) {
      // Ensure that the lookup table is built
      lut.build();
      return lut.areScalarsOpaque(scalars, model.colorMode, -1);
    }
    return true;
  };
 
  publicAPI.canUseTextureMapForColoring = (input) => {
    if (!model.interpolateScalarsBeforeMapping) {
      return false; // user doesn't want us to use texture maps at all.
    }
 
    // index color does not use textures
    if (model.lookupTable && model.lookupTable.getIndexedLookup()) {
      return false;
    }
 
    const gasResult = publicAPI.getAbstractScalars(
      input,
      model.scalarMode,
      model.arrayAccessMode,
      model.arrayId,
      model.colorByArrayName
    );
    const scalars = gasResult.scalars;
 
    Iif (!scalars) {
      // no scalars on this dataset, we don't care if texture is used at all.
      return false;
    }
 
    Iif (gasResult.cellFlag) {
      return false; // cell data colors, don't use textures.
    }
 
    Iif (
      (model.colorMode === ColorMode.DEFAULT &&
        scalars.getDataType() === VtkDataTypes.UNSIGNED_CHAR) ||
      model.colorMode === ColorMode.DIRECT_SCALARS
    ) {
      // Don't use texture is direct coloring using RGB unsigned chars is
      // requested.
      return false;
    }
 
    return true;
  };
 
  publicAPI.clearColorArrays = () => {
    model.colorMapColors = null;
    model.colorCoordinates = null;
    model.colorTextureMap = null;
  };
 
  publicAPI.getLookupTable = () => {
    if (!model.lookupTable) {
      publicAPI.createDefaultLookupTable();
    }
    return model.lookupTable;
  };
 
  publicAPI.getMTime = () => {
    let mt = model.mtime;
    if (model.lookupTable !== null) {
      const time = model.lookupTable.getMTime();
      mt = time > mt ? time : mt;
    }
    return mt;
  };
 
  publicAPI.getPrimitiveCount = () => {
    const input = publicAPI.getInputData();
    const pcount = {
      points: input.getPoints().getNumberOfValues() / 3,
      verts:
        input.getVerts().getNumberOfValues() -
        input.getVerts().getNumberOfCells(),
      lines:
        input.getLines().getNumberOfValues() -
        2 * input.getLines().getNumberOfCells(),
      triangles:
        input.getPolys().getNumberOfValues() -
        3 * input.getPolys().getNumberOfCells(),
    };
    return pcount;
  };
 
  publicAPI.acquireInvertibleLookupTable = notImplemented(
    'AcquireInvertibleLookupTable'
  );
  publicAPI.valueToColor = notImplemented('ValueToColor');
  publicAPI.colorToValue = notImplemented('ColorToValue');
  publicAPI.useInvertibleColorFor = notImplemented('UseInvertibleColorFor');
  publicAPI.clearInvertibleColor = notImplemented('ClearInvertibleColor');
 
  publicAPI.processSelectorPixelBuffers = (selector, pixelOffsets) => {
    /* eslint-disable no-bitwise */
    Iif (
      !selector ||
      !model.selectionWebGLIdsToVTKIds ||
      !model.populateSelectionSettings
    ) {
      return;
    }
 
    const rawLowData = selector.getRawPixelBuffer(PassTypes.ID_LOW24);
    const rawHighData = selector.getRawPixelBuffer(PassTypes.ID_HIGH24);
    const currentPass = selector.getCurrentPass();
    const fieldAssociation = selector.getFieldAssociation();
 
    let idMap = null;
    if (fieldAssociation === FieldAssociations.FIELD_ASSOCIATION_POINTS) {
      idMap = model.selectionWebGLIdsToVTKIds.points;
    } else if (fieldAssociation === FieldAssociations.FIELD_ASSOCIATION_CELLS) {
      idMap = model.selectionWebGLIdsToVTKIds.cells;
    }
 
    Iif (!idMap) {
      return;
    }
 
    pixelOffsets.forEach((pos) => {
      if (currentPass === PassTypes.ID_LOW24) {
        let inValue = 0;
        Iif (rawHighData) {
          inValue += rawHighData[pos];
          inValue *= 256;
        }
        inValue += rawLowData[pos + 2];
        inValue *= 256;
        inValue += rawLowData[pos + 1];
        inValue *= 256;
        inValue += rawLowData[pos];
 
        const outValue = idMap[inValue];
        const lowData = selector.getPixelBuffer(PassTypes.ID_LOW24);
        lowData[pos] = outValue & 0xff;
        lowData[pos + 1] = (outValue & 0xff00) >> 8;
        lowData[pos + 2] = (outValue & 0xff0000) >> 16;
      } else Iif (currentPass === PassTypes.ID_HIGH24 && rawHighData) {
        let inValue = 0;
        inValue += rawHighData[pos];
        inValue *= 256;
        inValue += rawLowData[pos];
        inValue *= 256;
        inValue += rawLowData[pos + 1];
        inValue *= 256;
        inValue += rawLowData[pos + 2];
 
        const outValue = idMap[inValue];
        const highData = selector.getPixelBuffer(PassTypes.ID_HIGH24);
        highData[pos] = (outValue & 0xff000000) >> 24;
      }
    });
    /* eslint-enable no-bitwise */
  };
}
 
// ----------------------------------------------------------------------------
// Object factory
// ----------------------------------------------------------------------------
 
const DEFAULT_VALUES = {
  colorMapColors: null, // Same as this->Colors
 
  static: false,
  lookupTable: null,
 
  scalarVisibility: true,
  scalarRange: [0, 1],
  useLookupTableScalarRange: false,
 
  colorMode: 0,
  scalarMode: 0,
  arrayAccessMode: 1, // By_NAME
 
  renderTime: 0,
 
  colorByArrayName: null,
 
  fieldDataTupleId: -1,
 
  populateSelectionSettings: true,
  selectionWebGLIdsToVTKIds: null,
 
  interpolateScalarsBeforeMapping: false,
  colorCoordinates: null,
  colorTextureMap: null,
 
  forceCompileOnly: 0,
 
  useInvertibleColors: false,
  invertibleScalars: null,
 
  customShaderAttributes: [],
};
 
// ----------------------------------------------------------------------------
 
export function extend(publicAPI, model, initialValues = {}) {
  Object.assign(model, DEFAULT_VALUES, initialValues);
 
  // Inheritance
  vtkAbstractMapper3D.extend(publicAPI, model, initialValues);
 
  macro.get(publicAPI, model, [
    'colorCoordinates',
    'colorMapColors',
    'colorTextureMap',
    'selectionWebGLIdsToVTKIds',
  ]);
  macro.setGet(publicAPI, model, [
    'colorByArrayName',
    'arrayAccessMode',
    'colorMode',
    'fieldDataTupleId',
    'interpolateScalarsBeforeMapping',
    'lookupTable',
    'populateSelectionSettings',
    'renderTime',
    'scalarMode',
    'scalarVisibility',
    'static',
    'useLookupTableScalarRange',
    'customShaderAttributes', // point data array names that will be transferred to the VBO
  ]);
  macro.setGetArray(publicAPI, model, ['scalarRange'], 2);
 
  CoincidentTopologyHelper.implementCoincidentTopologyMethods(publicAPI, model);
 
  // Object methods
  vtkMapper(publicAPI, model);
}
 
// ----------------------------------------------------------------------------
 
export const newInstance = macro.newInstance(extend, 'vtkMapper');
 
// ----------------------------------------------------------------------------
 
export default {
  newInstance,
  extend,
  ...staticOffsetAPI,
  ...otherStaticMethods,
  ...Constants,
};