IMHOTEP Framework
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
DICOMTransformTest.cs
1 using UnityEngine;
2 using System.Collections;
3 using UnityEngine.EventSystems;
4 
5 public class DICOMTransformTest : MonoBehaviour, IPointerClickHandler {
6 
7  public void OnPointerClick(UnityEngine.EventSystems.PointerEventData eventData )
8  {
9  // Get the currently loaded DICOM:
10  DICOM dicom = DICOMLoader.instance.currentDICOM;
11  if( dicom != null )
12  {
13  // The world position which was clicked:
14  Vector3 worldPos = eventData.pointerCurrentRaycast.worldPosition;
15  // Transform the position to the patient coordinate system (i.e. in mm)
16  Vector3 localPos = transform.InverseTransformPoint( worldPos );
17 
18  Debug.Log ("Clicked: " + worldPos + " (local: " + localPos + ")" );
19 
20  // Now we can either transform the position to a continuous pixel position...
21  // (to do so, we use the series Info associated with the DICOM:
22  Vector3 pixel = dicom.transformPatientPosToPixel ( localPos );
23  Debug.Log ("Pixel: " + pixel.x + "," + pixel.y + " on layer " + pixel.z);
24 
25  // ... or we can transform it to a discrete pixel position:
26  Vector3 pixelRounded = dicom.transformPatientPosToDiscretePixel ( localPos );
27  Debug.Log ("Rounded: " + pixelRounded.x + "," + pixelRounded.y + " on layer " + pixelRounded.z);
28  } else {
29  Debug.Log ( "No DICOM loaded." );
30  }
31  }
32 }
Definition: DICOM.cs:8