@doe-casl/verain-view
Advanced tools
Comparing version 1.3.22 to 1.3.23
{ | ||
"name": "@doe-casl/verain-view", | ||
"version": "1.3.22", | ||
"version": "1.3.23", | ||
"description": "VeraInView is a standalone HTML file that can act as an application to visualize your VERAin XML files.", | ||
@@ -5,0 +5,0 @@ "author": "Kitware, Inc.", |
@@ -27,5 +27,18 @@ import macro from 'vtk.js/Sources/macro'; | ||
function quadrantMirror(size, i, j) { | ||
const iComp = size - i - 1; | ||
const jComp = size - j - 1; | ||
return [[i, j], [iComp, j], [i, jComp], [iComp, jComp]]; | ||
} | ||
function quadrantRotation(size, i, j) { | ||
const iComp = size - i - 1; | ||
const jComp = size - j - 1; | ||
return [[i, j], [jComp, i], [j, iComp], [iComp, jComp]]; | ||
} | ||
function octant(size, i, j) { | ||
const iComp = size - i - 1; | ||
const jComp = size - j - 1; | ||
if (i === j) return quadrantMirror(size, i, j); | ||
return [ | ||
@@ -43,17 +56,2 @@ [i, j], | ||
function quadrantMirror(size, i, j) { | ||
const iComp = size - i - 1; | ||
const jComp = size - j - 1; | ||
return [[i, j], [iComp, j], [i, jComp], [iComp, jComp]]; | ||
} | ||
function quadrantRotation(size, i, j) { | ||
return [ | ||
[i, j], | ||
[size - 1 - j, i], | ||
[size - 1 - i, size - 1 - j], | ||
[j, size - 1 - i], | ||
]; | ||
} | ||
const SymmetryFn = [none, quadrantMirror, quadrantRotation, octant]; | ||
@@ -60,0 +58,0 @@ |
@@ -216,3 +216,3 @@ import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; | ||
// default to match the input map, but interactive cell maps might be shorter | ||
const width = numPins || Math.sqrt(cellMap.length); | ||
const width = +numPins || Math.sqrt(cellMap.length); | ||
const recSide = Math.floor(size / width); | ||
@@ -250,3 +250,3 @@ const pointSets = {}; | ||
ctx.stroke(); | ||
} else if (item.symmetry === 'quad') { | ||
} else if (item.symmetry === 'quad_mir' || item.symmetry === 'quad_rot') { | ||
ctx.beginPath(); | ||
@@ -325,4 +325,5 @@ ctx.moveTo(center, 0); | ||
const halfJ = j < width / 2 ? j : width - j - 1; | ||
const prevHalfJ = j - 1 < width / 2 ? j - 1 : width - j; | ||
// symmetric, top and bottom half. Not sure about non-symmetric assembly maps? | ||
const [prevMin, prevMax] = minmax[j < width / 2 ? halfJ - 1 : halfJ + 1]; | ||
const [prevMin, prevMax] = minmax[prevHalfJ]; | ||
let [minI, maxI] = minmax[halfJ]; | ||
@@ -329,0 +330,0 @@ if (prevMax !== -1) { |
@@ -20,3 +20,6 @@ function getNumPins(rodmap, params) { | ||
} | ||
} else if (halfPins > 0 && symmetry === 'quad') { | ||
} else if ( | ||
halfPins > 0 && | ||
(symmetry === 'quad_mir' || symmetry === 'quad_rot') | ||
) { | ||
for (let j = halfPins; j < numPins; ++j) { | ||
@@ -52,3 +55,4 @@ // i range is halfPins -> end of row | ||
const halfPins = Math.ceil(numPins * 0.5); | ||
if (symmetry === 'oct' || symmetry === 'quad') { | ||
const even = mapSize % 2 === 0; | ||
if (symmetry !== 'none') { | ||
// mapSize = halfPins * (halfPins + 1) / 2; | ||
@@ -76,7 +80,8 @@ mapSize = halfPins; | ||
} | ||
if (symmetry === 'oct' || symmetry === 'quad') { | ||
if (symmetry === 'oct' || symmetry === 'quad_mir') { | ||
// we have the bottom-right - add the bottom-left, as a mirror | ||
// odd maps drop the duplicate center item/row. | ||
for (let j = 0; j < halfPins; ++j) { | ||
cellMap[j] = cellMap[j] | ||
.slice(1) | ||
.slice(even ? 0 : 1) | ||
.reverse() | ||
@@ -87,5 +92,25 @@ .concat(cellMap[j]); | ||
cellMap = cellMap | ||
.slice(1) // this is a copy, with the duplicate center row dropped. | ||
.slice(even ? 0 : 1) | ||
.reverse() | ||
.concat(cellMap); | ||
} else if (symmetry === 'quad_rot') { | ||
// we have the bottom-right - add the bottom-left, as a rotation | ||
// odd maps drop the duplicate center item/row. | ||
const bottomLeft = []; | ||
for (let j = 0; j < halfPins; ++j) { | ||
bottomLeft[j] = cellMap.slice(0); | ||
for (let i = 0; i < halfPins; ++i) { | ||
bottomLeft[j][i] = cellMap[halfPins - i - 1][j]; | ||
} | ||
} | ||
for (let j = 0; j < halfPins; ++j) { | ||
cellMap[j] = bottomLeft[j].concat(cellMap[j].slice(even ? 0 : 1)); | ||
} | ||
// add the top half, mirror + mirror rows works for rotation. | ||
const topHalf = cellMap | ||
.slice(even ? 0 : 1) | ||
.reverse() | ||
.map((row) => row.slice(0).reverse()); | ||
cellMap = topHalf.concat(cellMap); | ||
} | ||
@@ -117,24 +142,16 @@ // now flatten. | ||
} | ||
const symList = ['none', 'quad_mir', 'quad_rot', 'oct']; | ||
const saveTextMap = rodmap.cellMap; | ||
rodmap.symmetry = 'oct'; | ||
rodmap.symmetry = symList.pop(); | ||
rodmap.cellMap = getTextMap(rodmap, params); | ||
let testMap = getFullMap(rodmap, params); | ||
if ( | ||
!rodmap.cell_map.reduce( | ||
(prev, cell, i) => cell === testMap[i] && prev, | ||
true | ||
) | ||
) { | ||
rodmap.symmetry = 'quad'; | ||
const doTest = (cellMap, test) => | ||
cellMap.reduce((prev, cell, i) => cell === test[i] && prev, true); | ||
while (!doTest(rodmap.cell_map, testMap) && symList.length) { | ||
rodmap.symmetry = symList.pop(); | ||
rodmap.cellMap = getTextMap(rodmap, params); | ||
testMap = getFullMap(rodmap, params); | ||
if ( | ||
!rodmap.cell_map.reduce( | ||
(prev, cell, i) => cell === testMap[i] && prev, | ||
true | ||
) | ||
) { | ||
rodmap.symmetry = 'none'; | ||
rodmap.cellMap = saveTextMap || getTextMap(rodmap, params); | ||
} | ||
// special handling if we get to 'none' | ||
if (symList.length) testMap = getFullMap(rodmap, params); | ||
else rodmap.cellMap = saveTextMap || rodmap.cellMap; | ||
} | ||
@@ -141,0 +158,0 @@ } |
@@ -104,3 +104,3 @@ import React from 'react'; | ||
item.cell_map[index] = this.state.paintCell; | ||
if (item.symmetry === 'oct' || item.symmetry === 'quad') { | ||
if (item.symmetry !== 'none') { | ||
// replace other cells based on symmetry. | ||
@@ -136,20 +136,23 @@ this.getSymCells(i, j).forEach((k) => { | ||
// i, j are from upper-left, coords in full cell map. | ||
// Mirror to upper quad. | ||
// Mirror to all quads/octs. | ||
const numPins = this.getNumPins(); | ||
const { symmetry } = this.props.content; | ||
const halfPins = Math.floor(numPins * 0.5); | ||
if (i > halfPins) i = numPins - i - 1; | ||
if (j > halfPins) j = numPins - j - 1; | ||
if (symmetry === 'oct' && i < j) { | ||
// swap - we want the upper-right triangle. | ||
const k = i; | ||
i = j; | ||
j = k; | ||
} | ||
let result = [ | ||
j * numPins + i, | ||
j * numPins + (numPins - i - 1), | ||
(numPins - j - 1) * numPins + i, | ||
(numPins - j - 1) * numPins + (numPins - i - 1), | ||
]; | ||
const iComp = numPins - i - 1; | ||
const jComp = numPins - j - 1; | ||
let result = | ||
symmetry === 'quad_mir' | ||
? [ | ||
j * numPins + i, | ||
j * numPins + iComp, | ||
jComp * numPins + i, | ||
jComp * numPins + iComp, | ||
] | ||
: [ | ||
j * numPins + i, | ||
i * numPins + jComp, | ||
iComp * numPins + j, | ||
jComp * numPins + iComp, | ||
]; | ||
if (symmetry === 'oct' && i !== j) { | ||
@@ -162,5 +165,5 @@ // swap and repeat for octant mirror. | ||
j * numPins + i, | ||
j * numPins + (numPins - i - 1), | ||
(numPins - j - 1) * numPins + i, | ||
(numPins - j - 1) * numPins + (numPins - i - 1), | ||
j * numPins + iComp, | ||
jComp * numPins + i, | ||
jComp * numPins + iComp, | ||
]); | ||
@@ -292,5 +295,8 @@ } | ||
</Radio.Button> | ||
<Radio.Button data-id="symmetry" value="quad"> | ||
Quadrant | ||
<Radio.Button data-id="symmetry" value="quad_rot"> | ||
Quadrant Rotate | ||
</Radio.Button> | ||
<Radio.Button data-id="symmetry" value="quad_mir"> | ||
Quadrant Mirror | ||
</Radio.Button> | ||
<Radio.Button data-id="symmetry" value="none"> | ||
@@ -297,0 +303,0 @@ None |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
6244563
19039