/*========================================================================= Program: FusionViewer Module: $RCSfile: SliceConfiguration.java,v $ Language: Java Date: $Date: 2007/02/02 19:25:27 $ Version: $Revision: 1.3 $ Copyright (c) Insightful Corporation. All rights reserved. See Copyright.txt for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ package org.fusionviewer.display; /**\class SliceConfiguration *\brief Identifies the axes of a 3D image to use in extracting slices * for a 2D display. */ public class SliceConfiguration { public static final int AXIAL = 0; public static final int SAGITTAL = 1; public static final int CORONAL = 2; /* * Axis indices for the current view orientation. */ private int[] m_axisIndex = new int[3]; /* * Indicates whether an image axis (in the 2D image plane) * should be viewed as flipped. */ private boolean[] m_axisFlipped = new boolean[2]; /** * Initialize with conventional axial, sagittal, and coronal views * as used in PET/CT (assumes an axially-acquired image). * * @param viewType AXIAL, SAGITTAL, or CORONAL */ public SliceConfiguration(int viewType) { switch (viewType) { case AXIAL: m_axisIndex[0] = 0; m_axisIndex[1] = 1; m_axisIndex[2] = 2; m_axisFlipped[0] = false; m_axisFlipped[1] = false; break; case SAGITTAL: m_axisIndex[0] = 1; m_axisIndex[1] = 2; m_axisIndex[2] = 0; m_axisFlipped[0] = false; m_axisFlipped[1] = true; break; case CORONAL: m_axisIndex[0] = 0; m_axisIndex[1] = 2; m_axisIndex[2] = 1; m_axisFlipped[0] = false; m_axisFlipped[1] = true; break; default: throw new IllegalArgumentException("Invalid view type: " + viewType); } } /** * Initialize with axis indices for x, y, and z and whether * the x and y should be flipped. */ public SliceConfiguration(int x, int y, int z, boolean flipX, boolean flipY) { m_axisIndex[0] = x; m_axisIndex[1] = y; m_axisIndex[2] = z; m_axisFlipped[0] = flipX; m_axisFlipped[1] = flipY; } /** * Get whether the x or y axis in the 2D image plane * should be flipped (index 0 = x axis, index 1 = y axis). * * @param axis axis to check * @return whether the axis should be flipped */ public boolean getAxisFlipped(int axis) { return m_axisFlipped[axis]; } /** * Get the index for an axis (x = 0, y = 1, z = 2). For example, * if we are viewing an x-y plane, the axis index array would be * { 0, 1, 2 }, and an x-z plane would be { 0, 2, 1 }. * * @param axis to check * @return axis index */ public int getAxisIndex(int axis) { return m_axisIndex[axis]; } }