LT-123: Add missing files

-Replace mathUtils.js functions with existed functions in cornerstoneMath.js
-Add rectToPoints, doesIntersect, getIntersectionRect methods in cornerstoneMath.rect,
-Add intersectLine method in cornerstoneMath.lineSegment
This commit is contained in:
Aysel Afsar committed 2016-01-14 00:10:24 -05:00
1 parent 3812def9cc
commit 12a326c7fe
6 files changed
+342 -146

No files matched your search

@@ -113,98 +113,12 @@
}
function doesIntersect(canvasBounds, imageBounds) {
var intersectLeftRight;
var intersectTopBottom;
if (canvasBounds.width >= 0) {
if (imageBounds.width >= 0)
intersectLeftRight = !((canvasBounds.right <= imageBounds.left) || (imageBounds.right <= canvasBounds.left));
else
intersectLeftRight = !((canvasBounds.right <= imageBounds.right) || (imageBounds.left <= canvasBounds.left));
} else {
if (imageBounds.width >= 0)
intersectLeftRight = !((canvasBounds.left <= imageBounds.left) || (imageBounds.right <= canvasBounds.right));
else
intersectLeftRight = !((canvasBounds.left <= imageBounds.right) || (imageBounds.left <= canvasBounds.right));
}
if (canvasBounds.height >= 0) {
if (imageBounds.height >= 0)
intersectTopBottom = !((canvasBounds.bottom <= imageBounds.top) || (imageBounds.bottom <= canvasBounds.top));
else
intersectTopBottom = !((canvasBounds.bottom <= imageBounds.bottom) || (imageBounds.top <= canvasBounds.top));
} else {
if (imageBounds.height >= 0)
intersectTopBottom = !((canvasBounds.top <= imageBounds.top) || (imageBounds.bottom <= canvasBounds.bottom));
else
intersectTopBottom = !((canvasBounds.top <= imageBounds.bottom) || (imageBounds.top <= canvasBounds.bottom));
}
return intersectLeftRight && intersectTopBottom;
}
function getIntersectionRectangle(canvasBounds, imageBounds) {
var intersectPoints = {
left: 0,
top: 0,
right: 0,
bottom: 0
};
if (!doesIntersect(canvasBounds, imageBounds)) {
return intersectPoints;
}
if (canvasBounds.width >= 0) {
if (imageBounds.width >= 0) {
intersectPoints.left = Math.max(canvasBounds.left, imageBounds.left);
intersectPoints.right = Math.min(canvasBounds.right, imageBounds.right);
} else {
intersectPoints.left = Math.max(canvasBounds.left, imageBounds.right);
intersectPoints.right = Math.min(canvasBounds.right, imageBounds.left);
}
} else {
if (imageBounds.width >= 0) {
intersectPoints.left = Math.min(canvasBounds.left, imageBounds.right);
intersectPoints.right = Math.max(canvasBounds.right, imageBounds.left);
} else {
intersectPoints.left = Math.min(canvasBounds.left, imageBounds.left);
intersectPoints.right = Math.max(canvasBounds.right, imageBounds.right);
}
}
if (canvasBounds.height >= 0) {
if (imageBounds.height >= 0) {
intersectPoints.top = Math.max(canvasBounds.top, imageBounds.top);
intersectPoints.bottom = Math.min(canvasBounds.bottom, imageBounds.bottom);
} else {
intersectPoints.top = Math.max(canvasBounds.top, imageBounds.bottom);
intersectPoints.bottom = Math.min(canvasBounds.bottom, imageBounds.top);
}
} else {
if (imageBounds.height >= 0) {
intersectPoints.top = Math.min(canvasBounds.top, imageBounds.bottom);
intersectPoints.bottom = Math.max(canvasBounds.bottom, imageBounds.top);
} else {
intersectPoints.top = Math.min(canvasBounds.top, imageBounds.top);
intersectPoints.bottom = Math.max(canvasBounds.bottom, imageBounds.bottom);
}
}
return intersectPoints;
}
// Computes the max bound for scales on the image
function computeScaleBounds(eventData, canvasSize, imageSize, horizontalReduction, verticalReduction) {
var canvasBounds = {
left: 0,
top: 0,
right: canvasSize.width,
bottom: canvasSize.height,
width: canvasSize.width,
height: canvasSize.height
};
@@ -214,8 +128,6 @@
canvasBounds = {
left: canvasBounds.left + hReduction,
top: canvasBounds.top + vReduction,
right: (canvasBounds.left + hReduction) + (canvasBounds.width - 2 * hReduction),
bottom: (canvasBounds.top + vReduction) + (canvasBounds.height - 2 * vReduction),
width: canvasBounds.width - 2 * hReduction,
height: canvasBounds.height - 2 * vReduction
};
@@ -245,14 +157,11 @@
var imageBounds = {
left: startPointCanvasImageBounds.x + hReduction,
top: startPointCanvasImageBounds.y + vReduction,
right: (startPointCanvasImageBounds.x + hReduction) + (imageBoundsWidth - 2 * hReduction),
bottom: (startPointCanvasImageBounds.y + vReduction) + (imageBoundsHeight - 2 * vReduction),
width: imageBoundsWidth - 2 * hReduction,
height: imageBoundsHeight - 2 * vReduction
};
return getIntersectionRectangle(canvasBounds, imageBounds);
return cornerstoneMath.rect.getIntersectionRect(canvasBounds, imageBounds);
}
@@ -281,17 +190,15 @@
var verticalIntervalScale = (10.0 / eventData.enabledElement.image.rowPixelSpacing) * eventData.viewport.scale;
var horizontalIntervalScale = (10.0 / eventData.enabledElement.image.rowPixelSpacing) * eventData.viewport.scale;
if (!canvasSize.width || !canvasSize.height || !imageSize.width || !imageSize.height ) {
return false;
}
// 0.1 and 0.05 gives margin to horizontal and vertical lines
var hscaleBounds = computeScaleBounds(eventData, canvasSize, imageSize, 0.1, 0.05);
var vscaleBounds = computeScaleBounds(eventData, canvasSize, imageSize, 0.05, 0.1);
if (!canvasSize.width || !canvasSize.height || !imageSize.width || !imageSize.height || !hscaleBounds || !vscaleBounds) {
return;
}
var config = {
width: imageSize.width,
height: imageSize.height,
hscaleBounds: hscaleBounds,
vscaleBounds: vscaleBounds,
verticalMinorTick: verticalIntervalScale,