All files / Sources/Common/DataModel/StructuredData index.js

56.52% Statements 13/23
52.38% Branches 11/21
100% Functions 1/1
54.54% Lines 12/22

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    1x     290x 290x 870x 601x       290x       290x 21x     269x 269x       269x     269x                                      
import Constants from 'vtk.js/Sources/Common/DataModel/StructuredData/Constants';
 
const { StructuredType } = Constants;
 
export function getDataDescriptionFromExtent(inExt) {
  let dataDim = 0;
  for (let i = 0; i < 3; ++i) {
    if (inExt[i * 2] < inExt[i * 2 + 1]) {
      dataDim++;
    }
  }
 
  Iif (inExt[0] > inExt[1] || inExt[2] > inExt[3] || inExt[4] > inExt[5]) {
    return StructuredType.EMPTY;
  }
 
  if (dataDim === 3) {
    return StructuredType.XYZ_GRID;
  }
 
  if (dataDim === 2) {
    Iif (inExt[0] === inExt[1]) {
      return StructuredType.YZ_PLANE;
    }
 
    Iif (inExt[2] === inExt[3]) {
      return StructuredType.XZ_PLANE;
    }
    return StructuredType.XY_PLANE;
  }
 
  if (dataDim === 1) {
    if (inExt[0] < inExt[1]) {
      return StructuredType.X_LINE;
    }
 
    if (inExt[2] < inExt[3]) {
      return StructuredType.Y_LINE;
    }
 
    return StructuredType.Z_LINE;
  }
 
  return StructuredType.SINGLE_POINT;
}
 
export default { getDataDescriptionFromExtent, ...Constants };