@doe-casl/verain-view
Advanced tools
Comparing version 1.3.34 to 1.3.35
{ | ||
"name": "@doe-casl/verain-view", | ||
"version": "1.3.34", | ||
"version": "1.3.35", | ||
"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.", |
@@ -14,2 +14,3 @@ import macro from 'vtk.js/Sources/macro'; | ||
function processAssembly(assemblyMap, cellMap, rodsCells) { | ||
let resultPitch = 0; | ||
const assemblyIds = Object.keys(assemblyMap); | ||
@@ -19,2 +20,3 @@ while (assemblyIds.length) { | ||
const { pitch, size, grid } = assemblyMap[assemblyId]; | ||
resultPitch = pitch; | ||
@@ -50,2 +52,3 @@ // Fill cell centers | ||
} | ||
return resultPitch / 2; | ||
} | ||
@@ -103,2 +106,7 @@ | ||
model.gridList = [ | ||
vtkRodMapVTKViewer.createGridPipeline(), | ||
vtkRodMapVTKViewer.createGridPipeline(), | ||
]; | ||
// viz = { | ||
@@ -164,4 +172,4 @@ // selected: 'gridAssembly', | ||
publicAPI.setData = (viz) => { | ||
publicAPI.removeAllActors(); | ||
if (!viz || !viz.core || !viz.core[viz.selected]) { | ||
publicAPI.removeAllActors(); | ||
return; | ||
@@ -177,6 +185,17 @@ } | ||
const rodsCells = vtkRodMapVTKViewer.processRods(rods); | ||
processAssembly(assembly, cellMap, rodsCells); | ||
const offset = processAssembly(assembly, cellMap, rodsCells); | ||
processCoreMap(core.pitch, core.size, core[selected], cellMap); | ||
// Adjust bounding box size | ||
const sideLength = core.size * core.pitch; | ||
model.sourceCtx.setXLength(sideLength); | ||
model.sourceCtx.setYLength(sideLength); | ||
model.sourceCtx.setZLength(core.height); | ||
model.sourceCtx.setCenter(sideLength / 2, sideLength / 2, core.height / 2); | ||
// create pipeline | ||
publicAPI.addActor(model.actorCtx); | ||
vtkRodMapVTKViewer | ||
.updateGrids(model.gridList, core.size, sideLength, core.height, offset) | ||
.forEach(publicAPI.addActor); | ||
vtkRodMapVTKViewer.createGlyphPipeline(publicAPI, model, cellMap); | ||
@@ -183,0 +202,0 @@ }; |
@@ -6,2 +6,3 @@ import macro from 'vtk.js/Sources/macro'; | ||
import vtkCubeSource from 'vtk.js/Sources/Filters/Sources/CubeSource'; | ||
import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; | ||
import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; | ||
@@ -90,3 +91,2 @@ import vtkGlyph3DMapper from 'vtk.js/Sources/Rendering/Core/Glyph3DMapper'; | ||
function createGlyphPipeline(publicAPI, model, cellMap) { | ||
publicAPI.removeAllActors(); | ||
model.stack = []; | ||
@@ -162,2 +162,34 @@ | ||
// ---------------------------------------------------------------------------- | ||
function createGridPipeline() { | ||
const source = vtkPlaneSource.newInstance(); | ||
const mapper = vtkMapper.newInstance({ scalarVisibility: false }); | ||
const actor = vtkActor.newInstance(); | ||
actor | ||
.getProperty() | ||
.set(Object.assign({ representation: 1 }, vtkVTKViewer.PROPERTY_SETTINGS)); | ||
actor.setMapper(mapper); | ||
mapper.setInputConnection(source.getOutputPort()); | ||
return { source, mapper, actor }; | ||
} | ||
// ---------------------------------------------------------------------------- | ||
function updateGrids(gridList, size, sideLength, height, offset) { | ||
const actors = []; | ||
const split = gridList.length > 2 ? gridList.length - 1 : 1; | ||
for (let i = 0; i < gridList.length; i++) { | ||
const z = i * height / split; | ||
gridList[i].source.setXResolution(size); | ||
gridList[i].source.setYResolution(size); | ||
gridList[i].source.setOrigin(-offset, -offset, z); | ||
gridList[i].source.setPoint1(sideLength - offset, -offset, z); | ||
gridList[i].source.setPoint2(-offset, sideLength - offset, z); | ||
actors.push(gridList[i].actor); | ||
} | ||
return actors; | ||
} | ||
// ---------------------------------------------------------------------------- | ||
// vtkRodVTKViewer methods | ||
@@ -184,2 +216,4 @@ // ---------------------------------------------------------------------------- | ||
model.gridList = [createGridPipeline(), createGridPipeline()]; | ||
// viz = { | ||
@@ -245,4 +279,4 @@ // selected: 'A', | ||
publicAPI.setData = (viz) => { | ||
publicAPI.removeAllActors(); | ||
if (!viz || !viz.assembly || !viz.assembly[viz.selected]) { | ||
publicAPI.removeAllActors(); | ||
return; | ||
@@ -261,2 +295,3 @@ } | ||
// Fill cell centers | ||
let maxLength = 0; | ||
for (let idx = 0; idx < grid.length; idx++) { | ||
@@ -279,2 +314,6 @@ const x = (idx % size) * pitch; | ||
cell.scale.push(length); | ||
if (maxLength < length) { | ||
maxLength = length; | ||
} | ||
} | ||
@@ -285,3 +324,22 @@ } | ||
if (viz.core && viz.core.height && maxLength < viz.core.height) { | ||
maxLength = viz.core.height; | ||
} | ||
// Adjust bounding box size | ||
const sideLength = size * pitch; | ||
model.sourceCtx.setXLength(sideLength); | ||
model.sourceCtx.setYLength(sideLength); | ||
model.sourceCtx.setZLength(maxLength); | ||
model.sourceCtx.setCenter( | ||
(sideLength - pitch) / 2, | ||
(sideLength - pitch) / 2, | ||
maxLength / 2 | ||
); | ||
// create pipeline | ||
publicAPI.addActor(model.actorCtx); | ||
updateGrids(model.gridList, size, sideLength, maxLength, pitch / 2).forEach( | ||
publicAPI.addActor | ||
); | ||
createGlyphPipeline(publicAPI, model, cellMap); | ||
@@ -347,2 +405,4 @@ }; | ||
applyVisibility, | ||
createGridPipeline, | ||
updateGrids, | ||
}; |
Sorry, the diff of this file is not supported yet
6286731
20285