Skip to content

Commit

Permalink
convert vis-type to visType at parse time (#393)
Browse files Browse the repository at this point in the history
* convert vis-type to visType at parse time

* remove todo comments

* remove all references to vis-type and use visType

* remove vis-type merge artifact
  • Loading branch information
interim17 authored Jun 13, 2024
1 parent bf80f77 commit 61a8591
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const DEFAULT_FRAME_RATE = 60; // frames per second

export const nullAgent = (): AgentData => {
return {
"vis-type": -1,
visType: -1,
instanceId: -1,
type: -1,
x: 0,
Expand Down
1 change: 0 additions & 1 deletion src/simularium/VisData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class VisData {
const parsedAgentData: AgentData[] = [];
let j = AGENTS_OFFSET;
for (let i = 0; i < expectedNumAgents; i++) {
//TODO use visType in AgentData and convert from "vis-type" here at parse time
const agentData: AgentData = nullAgent();

for (let k = 0; k < AGENT_OBJECT_KEYS.length; ++k) {
Expand Down
5 changes: 2 additions & 3 deletions src/simularium/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ export interface FileReturn {

// IMPORTANT: Order of this array needs to perfectly match the incoming data.
export const AGENT_OBJECT_KEYS = [
// TODO: convert "vis-type" to visType at parse time
"vis-type",
"visType",
"instanceId",
"type",
"x",
Expand All @@ -179,7 +178,7 @@ export interface AgentData {
yrot: number;
zrot: number;
instanceId: number;
["vis-type"]: number;
visType: number;
type: number;
cr: number;
subpoints: number[];
Expand Down
20 changes: 10 additions & 10 deletions src/test/VisData.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const parsedData = [
subpoints: [],
type: 7,
instanceId: 0,
"vis-type": 1000,
visType: 1000,
x: 1,
xrot: 0,
y: 1,
Expand All @@ -63,7 +63,7 @@ const parsedData = [
subpoints: [],
type: 7,
instanceId: 0,
"vis-type": 1000,
visType: 1000,
x: 2,
xrot: 0,
y: 2,
Expand All @@ -79,7 +79,7 @@ const parsedData = [
subpoints: [],
type: 7,
instanceId: 0,
"vis-type": 1000,
visType: 1000,
x: 3,
xrot: 0,
y: 3,
Expand All @@ -95,7 +95,7 @@ const parsedData = [
subpoints: [],
type: 7,
instanceId: 0,
"vis-type": 1000,
visType: 1000,
x: 4,
xrot: 0,
y: 4,
Expand All @@ -111,7 +111,7 @@ const parsedData = [
subpoints: [],
type: 7,
instanceId: 0,
"vis-type": 1000,
visType: 1000,
x: 5,
xrot: 0,
y: 5,
Expand All @@ -126,7 +126,7 @@ describe("VisData module", () => {
describe("VisData parse", () => {
test("it returns an array of objects of agent data and time stamp data", () => {
const testData = [
10, //"vis-type",
10, //"visType",
15, //"instanceId",
20, //"type",
30, //"x",
Expand Down Expand Up @@ -166,7 +166,7 @@ describe("VisData module", () => {
subpoints: [60, 61, 62], //"subpoint-1", "subpoint-2", "subpoint-3"],
type: 20, //"type",
instanceId: 15, //"instanceId",
"vis-type": 10, //"vis-type",
visType: 10, //"visType",
x: 30, //"x",
xrot: 40, //"xrot",
y: 31, //"y",
Expand All @@ -179,7 +179,7 @@ describe("VisData module", () => {
});
test("it throws an error if number of supoints does not match the nSubpoints value", () => {
const tooShort = [
10, //"vis-type",
10, //"visType",
15, //"instanceId",
20, //"type",
30, //"x",
Expand Down Expand Up @@ -209,7 +209,7 @@ describe("VisData module", () => {
fileName: "",
};
const tooLong = [
10, //"vis-type",
10, //"visType",
15, //"instanceId",
20, //"type",
30, //"x",
Expand Down Expand Up @@ -272,7 +272,7 @@ describe("VisData module", () => {
subpoints: [],
type: 7,
instanceId: 0,
"vis-type": 1000,
visType: 1000,
x: 1,
xrot: 0,
y: 1,
Expand Down
6 changes: 3 additions & 3 deletions src/visGeometry/VisAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class VisAgent {
yrot: 0,
zrot: 0,
instanceId: NO_AGENT,
"vis-type": VisTypes.ID_VIS_TYPE_DEFAULT,
visType: VisTypes.ID_VIS_TYPE_DEFAULT,
type: 0,
cr: 1.0,
subpoints: [],
Expand Down Expand Up @@ -62,7 +62,7 @@ export default class VisAgent {
yrot: 0,
zrot: 0,
instanceId: NO_AGENT,
"vis-type": VisTypes.ID_VIS_TYPE_DEFAULT,
visType: VisTypes.ID_VIS_TYPE_DEFAULT,
type: 0,
cr: 1.0,
subpoints: [],
Expand Down Expand Up @@ -165,7 +165,7 @@ export default class VisAgent {
this.agentData.z
);
if (
this.agentData["vis-type"] === VisTypes.ID_VIS_TYPE_FIBER &&
this.agentData.visType === VisTypes.ID_VIS_TYPE_FIBER &&
this.fiberCurve
) {
return this.fiberCurve.getPoint(0.5).add(pos);
Expand Down
2 changes: 1 addition & 1 deletion src/visGeometry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,7 @@ class VisGeometry {
}

agents.forEach((agentData) => {
const visType = agentData["vis-type"];
const visType = agentData.visType;
const instanceId = agentData.instanceId;
const typeId = agentData.type;
lastx = agentData.x;
Expand Down

0 comments on commit 61a8591

Please sign in to comment.