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

69.56% Statements 16/23
66.66% Branches 14/21
100% Functions 1/1
68.18% Lines 15/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     297x 297x 891x 617x       297x       297x 26x     271x 268x       268x     268x     3x 3x 3x                            
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 };