Creating a 3D Object Tutorial

Show in webframe

This tutorial teaches you how to create a 3D object.

  1. Open Visual Studio 2005 or later.
  2. From File menu > choose Project.
  3. The new project dialog appears.
  4. From project types, expand the Other languages node, and click on the Visual C# node.
  5. From the template list on the left side of the dialog, choose Windows Forms Application.
  6. Type the project name as "Creating a 3D Object" in the Project Name field, and then choose OK.
  7. Select OK to create the project.
  8. From View menu > choose Solution explorer.
  9. On the Solution explorer tree, right click on the References node and select Add Reference.
  10. On the Add Reference dialog, select the Browse tab, and add the following dll's:
    • Leadtools.dll
    • Leadtools.Codecs.dll
    • Leadtools.MedicalViewer.dll
    • Leadtools.Medical3D.dll
    • Leadtools.Dicom.dll
    • Leadtools.Codecs.Cmp.dll
  11. Switch to Form1 code view (right-click Form1 in the solution explorer then select View Code ) and add the following lines at the beginning of the file:
    [Visual Basic]
    
                Imports Leadtools
                Imports Leadtools.Codecs
                Imports Leadtools.MedicalViewer
                Imports Leadtools.Medical3D
                Imports Leadtools.Dicom
                
    
    [C#]
    
                using Leadtools;
                using Leadtools.Codecs;
                using Leadtools.MedicalViewer;
                using Leadtools.Medical3D;
                using Leadtools.Dicom;
                
    
  12. In Form1, create a new method InitClass(). Add the following code in the InitClass() method:
    [Visual Basic]
    
                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.
                   Dim _codecs As RasterCodecs = New RasterCodecs()
                   ' Create a new instance of the Medical Viewer. The layout will be divided to 2X2.
                   Dim viewer As MedicalViewer = 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.
                   Dim control3D As Medical3DControl = New Medical3DControl()
                   control3D.AddAction(MedicalViewerActionType.WindowLevel)
                   control3D.SetAction(MedicalViewerActionType.WindowLevel, MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active)
                   Dim object3D As Medical3DObject = 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)
                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);
                }
                
    

    Note: You may need to change the above path to point to "image1.dcm" located in the LEADTOOLS images directory.

  13. Call the InitClass method from inside the Form1 constructor and place the call after InitializeComponent();
  14. Run the program and you will see a 2x2 layout with one slot filled with a 3D object.

    Note: For more information on how to acquire the above unlock keys, please contact LEAD Technologies support.

    Note: To view higher quality images, we provide DICOMDIR sample files which can be downloaded from here. For more information on building 3D objects from a DICOMDIR, please see Loading a DICOMDIR To Create a 3D Object.

    Note: If you encounter an "Invalid File Format" or "Feature Not Supported" exception, please refer to the topic Invalid File Format/Feature Not Supported.

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.