Creating a 3D Object with MPR View Tutorial

This tutorial teaches you how to create a 3D object and render the three MPR orthogonal slices ( Axial, Sagittal and Coronal) on a cell window.

  1. Start with the project you created in Creating A 3D Object.
  2. Run the program now and you will see a 2x2 layout with one of the slots filled with a 3D object.
  3. Now, add the three MPR cells: Create a new instance of the MedicalViewerMPRCell and change its properties to accommodate your needs. For this demonstration we will create the axial cell. To do this, add the following lines to the bottom of the InitClass method:

    VB
    ' Create a new cell that will hold the axial frame. 
    Dim axialCell As MedicalViewerMPRCell = New MedicalViewerMPRCell() 
    ' adjust some properties to view the cross hair. 
    axialCell.ShowMPRCrossHair = True 
    axialCell.DistinguishMPRByColor = True 
                     
         

    C#
    // Create a new cell that will hold the axial frame. 
    MedicalViewerMPRCell axialCell = new MedicalViewerMPRCell(); 
    // adjust some properties to view the cross hair. 
    axialCell.ShowMPRCrossHair = true; 
    axialCell.DistinguishMPRByColor = true; 
                     
         

  4. Assign the axial cell to the medical 3D control through the AxialFrame property. To do this, add the following line at the bottom of the InitClass method:

    VB
    ' Assign this cell (axialCell) to the AxialFrame property of the Medical 3D control 
    control3D.AxialFrame = axialCell 
                     
         

    C#
    // Assign this cell (axialCell) to the AxialFrame property of the Medical 3D control 
    control3D.AxialFrame = axialCell; 
                     
         

  5. Finally, add the created instance to the viewer. To do this, add the following line at the bottom of the InitClass method: [Visual Base]

    ' add the axial cell to the viewer 
    viewer.Cells.Add(axialCell) 

    C#
    // add the axial cell to the viewer 
    viewer.Cells.Add(axialCell); 
                     
         

  6. Repeat the steps (3), (4) and (5) above, to create the sagittal and coronal cells. However, note that in step (4), you must assign the sagittal cell to the SagittalFrame property in the Medical3DControl and the coronal cell to the CoronalFrame property of the Medical 3D control.

  7. The InitClass() should look as shown below:

    VB
    Private Sub InitClass() 
         Dim MY_LICENSE_FILE As String = "d:\temp\TestLic.lic" 
                          
         ' Unlock DICOM support 
         Dim MY_DicomDEVELOPER_KEY As String = "xyz123abc" 
         RasterSupport.SetLicense(MY_LICENSE_FILE, MY_DicomDEVELOPER_KEY); 
                          
         ' Unlock Medical support 
         Dim MY_MedicalDEVELOPER_KEY As String = "abc123xyz" 
         RasterSupport.SetLicense(MY_LICENSE_FILE, MY_MedicalDEVELOPER_KEY); 
                          
         ' Unlock Medical 3D support 
         Dim MY_3DDEVELOPER_KEY As String = "123xyzabc" 
         RasterSupport.SetLicense(MY_LICENSE_FILE, MY_3DDEVELOPER_KEY); 
                          
         // Create a new instance of the Codecs class, which will be used to load the images. 
         RasterCodecs _codecs = new RasterCodecs(); 
         // Create a new instance of the Medical Viewer. The layout will be divided to 2X2. 
         MedicalViewer viewer = new MedicalViewer(2, 2); 
         // Fit the view to the whole form 
         viewer.Dock = DockStyle.Fill; 
         // Create the 3D control that will hold the 3D object. 
         Medical3DControl control3D = new Medical3DControl(); 
         control3D.AddAction(MedicalViewerActionType.WindowLevel); 
         control3D.SetAction(MedicalViewerActionType.WindowLevel, MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active); 
         Medical3DObject object3D = new Medical3DObject(); 
         // Add the newly created 3D object to the control. 
         control3D.ObjectsContainer.Objects.Add(object3D); 
         object3D.Image = _codecs.Load(@"C:\Users\Public\Documents\LEADTOOLS Images\image1.dcm"); 
         // Add the cell above to the MedicalViewer. 
         viewer.Cells.Add(control3D); 
         Controls.Add(viewer); 
                          
         // Create a new cell that will hold the axial frame. 
         MedicalViewerMPRCell axialCell = new MedicalViewerMPRCell(); 
         // adjust some properties to view the cross hair. 
         axialCell.ShowMPRCrossHair = true; 
         axialCell.DistinguishMPRByColor = true; 
                          
         // Assign this cell (axialCell) to the AxialFrame property of the Medical 3D control 
         control3D.AxialFrame = axialCell; 
                          
         // add the axial cell to the viewer 
         viewer.Cells.Add(axialCell); 
                          
         // Create a new cell that will hold the coronal frame. 
         MedicalViewerMPRCell coronalCell = new MedicalViewerMPRCell(); 
                          
         // adjust some properties to view the cross hair. 
         coronalCell.ShowMPRCrossHair = true; 
         coronalCell.DistinguishMPRByColor = true; 
                          
         // Assign this cell (coronalCell) to the CoronalFrame property of the Medical 3D control 
         control3D.CoronalFrame = coronalCell; 
                          
         viewer.Cells.Add(coronalCell); 
                          
         // Create a new cell that will hold the sagittal frame. 
         MedicalViewerMPRCell sagittalCell = new MedicalViewerMPRCell(); 
                          
         // adjust some properties to view the cross hair. 
         sagittalCell.ShowMPRCrossHair = true; 
         sagittalCell.DistinguishMPRByColor = true; 
                          
         // Assign this cell (sagittalCell) to the SagittalFrame property of the Medical 3D control 
         control3D.SagittalFrame = sagittalCell; 
                          
         viewer.Cells.Add(sagittalCell); 
                          
         // Add the viewer as a child to the form. 
         this.Controls.Add(viewer); 
    End Sub 
                     
         

    C#
    void InitClass() 
    { 
         string MY_LICENSE_FILE = "d:\\temp\\TestLic.lic"; 
                        
         // Unlock DICOM support 
         string MY_DicomDEVELOPER_KEY = "xyz123abc"; 
         RasterSupport.SetLicense(MY_LICENSE_FILE, MY_DicomDEVELOPER_KEY); 
                          
         // Unlock Medical support 
         string MY_MedicalDEVELOPER_KEY = "abc123xyz"; 
         RasterSupport.SetLicense(MY_LICENSE_FILE, MY_MedicalDEVELOPER_KEY); 
                          
         // Unlock Medical 3D support 
         string MY_3DDEVELOPER_KEY = "123xyzabc"; 
         RasterSupport.SetLicense(MY_LICENSE_FILE, MY_3DDEVELOPER_KEY); 
                       
         // Create a new instance of the Codecs class, which will be used to load the images. 
         RasterCodecs _codecs = new RasterCodecs(); 
         // Create a new instance of the Medical Viewer. The layout will be divided to 2X2. 
         MedicalViewer viewer = new MedicalViewer(2, 2); 
         // Fit the view to the whole form 
         viewer.Dock = DockStyle.Fill; 
         // Create the 3D control that will hold the 3D object. 
         Medical3DControl control3D = new Medical3DControl(); 
         control3D.AddAction(MedicalViewerActionType.WindowLevel); 
         control3D.SetAction(MedicalViewerActionType.WindowLevel, MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active); 
         Medical3DObject object3D = new Medical3DObject(); 
         // Add the newly created 3D object to the control. 
         control3D.ObjectsContainer.Objects.Add(object3D); 
         object3D.Image = _codecs.Load(@"C:\Users\Public\Documents\LEADTOOLS Images\image1.dcm"); 
         // Add the cell above to the MedicalViewer. 
         viewer.Cells.Add(control3D); 
         Controls.Add(viewer); 
                       
         // Create a new cell that will hold the axial frame. 
         MedicalViewerMPRCell axialCell = new MedicalViewerMPRCell(); 
         // adjust some properties to view the cross hair. 
         axialCell.ShowMPRCrossHair = true; 
         axialCell.DistinguishMPRByColor = true; 
                       
         // Assign this cell (axialCell) to the AxialFrame property of the Medical 3D control 
         control3D.AxialFrame = axialCell; 
                       
         // add the axial cell to the viewer 
         viewer.Cells.Add(axialCell); 
                       
         // Create a new cell that will hold the coronal frame. 
         MedicalViewerMPRCell coronalCell = new MedicalViewerMPRCell(); 
                       
         // adjust some properties to view the cross hair. 
         coronalCell.ShowMPRCrossHair = true; 
         coronalCell.DistinguishMPRByColor = true; 
                       
         // Assign this cell (coronalCell) to the CoronalFrame property of the Medical 3D control 
         control3D.CoronalFrame = coronalCell; 
                       
         viewer.Cells.Add(coronalCell); 
                       
         // Create a new cell that will hold the sagittal frame. 
         MedicalViewerMPRCell sagittalCell = new MedicalViewerMPRCell(); 
                       
         // adjust some properties to view the cross hair. 
         sagittalCell.ShowMPRCrossHair = true; 
         sagittalCell.DistinguishMPRByColor = true; 
                       
         // Assign this cell (sagittalCell) to the SagittalFrame property of the Medical 3D control 
         control3D.SagittalFrame = sagittalCell; 
                       
         viewer.Cells.Add(sagittalCell); 
                       
         // Add the viewer as a child to the form. 
         this.Controls.Add(viewer); 
     } 
                     
         

  8. Run the program and you should see four cells: One for the 3D object and the other three for Axial, Sagittal and Coronal cells.

Note:Now you will need to have DICOMDIR files for the next step. You can download a sample from our site. Download the file from here (Download chest_ct_compressed_subset_for_3d_tutorial.zip), and extract the file to "C:\Leadtools_DICOMDIR". For more information on building 3D objects from a DICOMDIR, please see Loading a DICOMDIR To Create a 3D Object.

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Imaging, Medical, and Document