Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Stack): swap image row and column pixel spacing + relaxing isequal compar… #566

Merged
merged 1 commit into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/core/src/RenderingEngine/StackViewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1543,9 +1543,9 @@ class StackViewport extends Viewport implements IStackViewport {
// using spacing, size, and direction only for now
return (
(isSameXSpacing ||
(image.rowPixelSpacing === null && xSpacing === 1.0)) &&
(image.columnPixelSpacing === null && xSpacing === 1.0)) &&
(isSameYSpacing ||
(image.columnPixelSpacing === null && ySpacing === 1.0)) &&
(image.rowPixelSpacing === null && ySpacing === 1.0)) &&
xVoxels === image.columns &&
yVoxels === image.rows &&
isEqual(imagePlaneModule.rowCosines, <Point3>rowCosines) &&
Expand Down
9 changes: 0 additions & 9 deletions packages/core/src/utilities/isEqual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@ export default function isEqual<ValueType>(
return false;
}

// typeof object must have same constructor
if (
typeof v1 === 'object' &&
typeof v2 === 'object' &&
v1.constructor !== v2.constructor
) {
return false;
}

if (isNumberType(v1) && isNumberType(v2)) {
return areNumbersEqualWithTolerance(v1, v2, tolerance);
}
Expand Down
23 changes: 21 additions & 2 deletions packages/core/test/utils_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,36 @@ describe('Cornerstone-render Utilities:', function () {
expect(isEqual(Infinity, Infinity, 0.0001)).toBe(false);
expect(isEqual(NaN, NaN, 0.0001)).toBe(false);

const typedArray0 = new Float32Array([1.0, 2.1]);
const typedArray1 = new Float32Array([1.0, 1.2]);
const typedArray2 = new Float32Array([1.0, 1.2]);
const typedArray3 = new Float64Array([1.0, 1.2]);
const typedArray4 = new Float64Array([1.01, 1.202]);
const typedArray5 = new Int16Array([1, 2]);
const typedArray6 = new Int16Array([1, 2]);
const typedArray7 = new Int16Array([1, 3]);

expect(isEqual(typedArray1, typedArray2, 0.0001)).toBe(true);
expect(isEqual(typedArray3, typedArray4, 0.1)).toBe(true);
expect(isEqual(typedArray5, typedArray6, 0.0001)).toBe(true);
expect(isEqual(typedArray1, typedArray3, 0.1)).toBe(false);
expect(isEqual(typedArray3, typedArray4, 0.0001)).toBe(false);
expect(isEqual(typedArray3, typedArray4, 0.0001)).toEqual(
isEqual(typedArray4, typedArray3, 0.0001)
);
expect(isEqual(typedArray5, typedArray6, 0.1)).toBe(true);
expect(isEqual(typedArray5, typedArray6, 0.001)).toBe(true);
expect(isEqual(typedArray5, typedArray7, 0.1)).toBe(false);
expect(isEqual(typedArray1, typedArray3, 0.1)).toBe(true);
expect(isEqual(typedArray1, typedArray3, 0.0001)).toBe(true);
expect(isEqual(typedArray1, typedArray5, 0.0001)).toBe(false);
expect(isEqual(typedArray1, typedArray5, 0.01)).toBe(false);
expect(isEqual(typedArray0, typedArray5, 0.01)).toBe(false);
expect(isEqual(typedArray0, typedArray5, 0.1)).toBe(true);
expect(isEqual(typedArray0, typedArray5, 0.1)).toEqual(
isEqual(typedArray5, typedArray0, 0.1)
);
expect(isEqual(typedArray0, typedArray5, 0.1)).toEqual(
isEqual(typedArray5, typedArray5, 0.1)
);
});

it('Should correctly calculate line and plane intersection', () => {
Expand Down