Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@doe-casl/verain-view

Package Overview
Dependencies
Maintainers
3
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@doe-casl/verain-view - npm Package Compare versions

Comparing version 1.3.27 to 1.3.28

2

package.json
{
"name": "@doe-casl/verain-view",
"version": "1.3.27",
"version": "1.3.28",
"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.",

@@ -98,3 +98,2 @@ import React from 'react';

render() {
console.log(this.props.data);
const viz = this.props.ui.domain;

@@ -101,0 +100,0 @@ const vizData = Object.assign({ selected: this.props.viewData.id }, viz);

@@ -99,5 +99,7 @@ import macro from 'vtk.js/Sources/macro';

publicAPI.setData = (cell) => {
model.activeCell = cell.cells[cell.selected];
model.labels = cell.names;
const pitch = cell.cellPitch;
const { radius, cellFields, RGBPoints } = extractCellSettings(
cell.cells[cell.selected],
model.activeCell,
cell.colors

@@ -113,2 +115,33 @@ );

};
// --------------------------------------------------------------------------
publicAPI.applyVisibility = () => {
if (model.activeCell) {
for (let i = 0; i < model.activeCell.length; i++) {
model.source.setMaskLayer(
i,
!publicAPI.getObjectVisibility(model.activeCell[i].material)
);
}
publicAPI.renderLater();
}
};
// --------------------------------------------------------------------------
publicAPI.getVisibiltyOptions = () => {
const listOfMats = [];
if (model.activeCell) {
for (let i = 0; i < model.activeCell.length; i++) {
const id = model.activeCell[i].material;
listOfMats.push({
id,
label: model.labels[id],
type: 'material',
});
}
}
return listOfMats; // [{ id, label, type }, ] with type = material/cell
};
}

@@ -115,0 +148,0 @@

@@ -9,2 +9,3 @@ import macro from 'vtk.js/Sources/macro';

import vtkRodMapVTKViewer from './RodMapVTKViewer';
import vtkRodVTKViewer from './RodVTKViewer';

@@ -178,3 +179,9 @@ // ----------------------------------------------------------------------------

// --------------------------------------------------------------------------
publicAPI.setSourceResolution = (resolution) => {
if (model.sourceResolution === resolution) {
return;
}
model.sourceResolution = resolution;
for (let i = 0; i < model.stack.length; i++) {

@@ -184,5 +191,6 @@ const { glyph } = model.stack[i];

}
publicAPI.renderLater();
};
// --------------------------------------------------------------------------
publicAPI.resetCamera = () => {

@@ -195,4 +203,23 @@ const camera = model.renderer.getActiveCamera();

publicAPI.renderLater();
publicAPI.renderAnimation();
};
// --------------------------------------------------------------------------
publicAPI.applyVisibility = () =>
vtkRodMapVTKViewer.applyVisibility(publicAPI, model);
// --------------------------------------------------------------------------
publicAPI.getVisibiltyOptions = () =>
vtkRodVTKViewer.getVisibiltyOptions(publicAPI, model);
// --------------------------------------------------------------------------
// Automatic LOD when interacting
publicAPI.onInteraction((interaction) => {
publicAPI.setSourceResolution(
interaction ? model.lodResolution : model.fullResolution
);
});
}

@@ -205,3 +232,5 @@

const DEFAULT_VALUES = {
sourceResolution: 6,
sourceResolution: 60,
lodResolution: 6,
fullResolution: 60,
};

@@ -216,2 +245,7 @@

vtkVTKViewer.extend(publicAPI, model);
macro.setGet(publicAPI, model, [
'lodResolution',
'fullResolution',
'sourceResolution',
]);

@@ -218,0 +252,0 @@ // Object specific methods

@@ -12,2 +12,3 @@ import macro from 'vtk.js/Sources/macro';

import vtkVTKViewer from './VTKViewer';
import vtkRodVTKViewer from './RodVTKViewer';

@@ -41,2 +42,3 @@ // ----------------------------------------------------------------------------

const radii = [];
const materials = [];
const cellFields = [];

@@ -47,2 +49,3 @@

radii.push(radius);
materials.push(material);
cellFields.push(materialIds.indexOf(material));

@@ -54,2 +57,3 @@ }

cellFields,
materials,
center: [],

@@ -95,3 +99,5 @@ scale: [],

const { lookupTable, sourceResolution } = model;
const { radius, cellFields, center, scale } = cellMap[cellNames[i]];
const { radius, cellFields, center, scale, materials } = cellMap[
cellNames[i]
];

@@ -129,3 +135,10 @@ const source = vtkPolyData.newInstance();

model.stack.push({ source, glyph, mapper, actor });
model.stack.push({
id: cellNames[i],
source,
glyph,
mapper,
actor,
materials,
});
publicAPI.addActor(actor);

@@ -137,2 +150,18 @@ }

// ----------------------------------------------------------------------------
function applyVisibility(publicAPI, model) {
if (!model.stack) {
return;
}
for (let i = 0; i < model.stack.length; i++) {
const { id, materials, glyph, actor } = model.stack[i];
actor.setVisibility(publicAPI.getObjectVisibility(id));
for (let j = 0; j < materials.length; j++) {
glyph.setMaskLayer(j, !publicAPI.getObjectVisibility(materials[j]));
}
}
publicAPI.renderLater();
}
// ----------------------------------------------------------------------------
// vtkRodVTKViewer methods

@@ -159,45 +188,2 @@ // ----------------------------------------------------------------------------

// rod = {
// name: '',
// pitch: 1.26,
// colors: {
// mod: [0, 0, 0.5],
// he: [0, 0.5, 0.3],
// zirc: [0.5, 0.5, 0.3],
// ss: [0.4, 0.5, 0.4],
// },
// cells: {
// A: [
// { material: 'mod', radius: 0.2 },
// { material: 'he', radius: 0.3 },
// { material: 'zirc', radius: 0.4 },
// { material: 'ss', radius: 0.5 },
// ],
// B: [],
// C: [],
// },
// rods: {
// 1: [
// { cell: 'A', length: 10 },
// { cell: 'B', length: 200 },
// { cell: 'A', length: 5 },
// { cell: 'C', length: 10 },
// ],
// 2: [
// { cell: 'A', length: 10 },
// { cell: 'B', length: 200 },
// { cell: 'A', length: 5 },
// { cell: 'C', length: 10 },
// ],
// },
// rodsOffset: {
// 1: 0,
// 2: 4.5,
// },
// map: {
// size: 17,
// grid: [1,2,1,2,1,2,1,2,1],
// },
// }
// ==========================================================================
// viz = {

@@ -267,2 +253,4 @@ // selected: 'A',

model.labels = viz.names;
const { colors, cells, rods } = viz;

@@ -302,2 +290,4 @@ const { size, grid, pitch } = viz.assembly[viz.selected];

// --------------------------------------------------------------------------
publicAPI.resetCamera = () => {

@@ -312,2 +302,12 @@ const camera = model.renderer.getActiveCamera();

};
// --------------------------------------------------------------------------
publicAPI.applyVisibility = () =>
vtkRodMapVTKViewer.applyVisibility(publicAPI, model);
// --------------------------------------------------------------------------
publicAPI.getVisibiltyOptions = () =>
vtkRodVTKViewer.getVisibiltyOptions(publicAPI, model);
}

@@ -348,2 +348,3 @@

createGlyphPipeline,
applyVisibility,
};

@@ -12,3 +12,3 @@ import macro from 'vtk.js/Sources/macro';

function createCell(model, center, height, radius, cellFields) {
function createCell(model, center, height, radius, cellFields, materials, id) {
const { lookupTable, zScaling } = model;

@@ -36,3 +36,3 @@

return { source, mapper, actor };
return { source, mapper, actor, id, materials };
}

@@ -68,2 +68,3 @@

const cellFields = [];
const materials = [];

@@ -73,6 +74,7 @@ for (let j = 0; j < cell.length; j++) {

radii.push(radius);
materials.push(material);
cellFields.push(materialIds.indexOf(material));
}
cellMap[name] = { radius: radii, cellFields };
cellMap[name] = { radius: radii, cellFields, materials };
}

@@ -83,2 +85,25 @@ return cellMap;

// ----------------------------------------------------------------------------
function getVisibiltyOptions(publicAPI, model) {
const mats = {};
const list = [];
if (model.stack) {
for (let i = 0; i < model.stack.length; i++) {
const { id, materials } = model.stack[i];
list.push({ id, label: model.labels[id], type: 'cell' });
for (let j = 0; j < materials.length; j++) {
mats[materials[j]] = model.labels[materials[j]];
}
}
const matIds = Object.keys(mats);
while (matIds.length) {
const id = matIds.pop();
const label = model.labels[id];
list.push({ id, label, type: 'materials' });
}
}
return list; // [{ id, label, type }, ] with type = material/cell
}
// ----------------------------------------------------------------------------
// vtkRodVTKViewer methods

@@ -153,2 +178,3 @@ // ----------------------------------------------------------------------------

publicAPI.removeAllActors();
model.labels = viz.names;
model.stack = [];

@@ -159,3 +185,3 @@

const { cell, length } = layers[i];
const { radius, cellFields } = cellMap[cell];
const { radius, cellFields, materials } = cellMap[cell];
const cellPipeline = createCell(

@@ -166,3 +192,5 @@ model,

radius,
cellFields
cellFields,
materials,
cell
);

@@ -183,2 +211,22 @@ model.stack.push(cellPipeline);

};
// --------------------------------------------------------------------------
publicAPI.applyVisibility = () => {
if (!model.stack) {
return;
}
for (let i = 0; i < model.stack.length; i++) {
const { id, materials, source, actor } = model.stack[i];
actor.setVisibility(publicAPI.getObjectVisibility(id));
for (let j = 0; j < materials.length; j++) {
source.setMaskLayer(j, !publicAPI.getObjectVisibility(materials[j]));
}
}
publicAPI.renderLater();
};
// --------------------------------------------------------------------------
publicAPI.getVisibiltyOptions = () => getVisibiltyOptions(publicAPI, model);
}

@@ -210,2 +258,2 @@

export default { newInstance, extend };
export default { newInstance, extend, getVisibiltyOptions };

@@ -31,2 +31,5 @@ import macro from 'vtk.js/Sources/macro';

// Local variables
if (!model.visibilty) {
model.visibilty = {};
}
model.renderWindow = vtkRenderWindow.newInstance();

@@ -49,2 +52,9 @@ model.renderer = vtkRenderer.newInstance({ background: [0, 0, 0, 1] });

model.interactor.onStartAnimation(() => {
publicAPI.invokeInteraction(true);
});
model.interactor.onEndAnimation(() => {
publicAPI.invokeInteraction(false);
});
// Apply default interaction styles

@@ -81,3 +91,3 @@ vtkInteractorStylePresets.applyPreset('3D', model.interactorStyle3D);

);
publicAPI.renderLater();
publicAPI.renderAnimation();
}

@@ -106,3 +116,3 @@ };

model.renderer.resetCameraClippingRange();
publicAPI.renderLater();
publicAPI.renderAnimation();
};

@@ -147,2 +157,15 @@

const cancelAnimation = macro.debounce(() => {
model.interactor.cancelAnimation(publicAPI);
}, model.lodTimeout); // Can't be dynamically set
publicAPI.renderAnimation = () => {
if (!model.interactor.isAnimating()) {
model.interactor.requestAnimation(publicAPI);
}
cancelAnimation();
};
// --------------------------------------------------------------------------
publicAPI.resetCamera = (

@@ -162,3 +185,3 @@ orientation = [0, 0, 1],

publicAPI.renderLater();
publicAPI.renderAnimation();
};

@@ -180,2 +203,30 @@

};
// --------------------------------------------------------------------------
publicAPI.setObjectVisibility = (id, visible) => {
model.visibilty[id] = visible;
};
// --------------------------------------------------------------------------
publicAPI.getObjectVisibility = (id) => {
if (id in model.visibilty) {
return !!model.visibilty[id];
}
return true;
};
// --------------------------------------------------------------------------
publicAPI.applyVisibility = () => {
console.log('applyVisibility should be override');
};
// --------------------------------------------------------------------------
publicAPI.getVisibiltyOptions = () => {
console.log('getVisibiltyOptions should be override');
return []; // { id, label, type } with type = material/cell
};
}

@@ -191,2 +242,3 @@

interactiveBackground: [0, 0, 0, 1],
lodTimeout: 1000,
};

@@ -201,2 +253,3 @@

macro.obj(publicAPI, model);
macro.event(publicAPI, model, 'interaction');

@@ -203,0 +256,0 @@ // Object specific methods

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc