←Select platform

Insert Method

Summary
Inserts a new item in the Value Representation Table.
Syntax
C#
C++/CLI
Java
public DicomVr insert(DicomVrType code, String name, int length, DicomVrRestriction restriction, int unitSize) 

Parameters

code
Code that indicates the type of value to be stored in the data element.

name
The name of the value representation. For examples of Value Representation Names, refer to the Default Value Representation Table.

length
The length of the value to be stored in the data element

restriction
Restrictions on the length.

unitSize
The size of the smallest item to be stored in the value field of the data element

Return Value

DicomVR class if the method was successful; otherwise, null.

Remarks
  • All items are inserted at the bottom of the table
  • To see the default values for the Value Representation Table, refer to the Default Value Representation Table.
  • When evaluating length, you must also consider the values in restriction. If restriction is DicomVRRestriction.BinaryFixed or DicomVRRestriction.StringFixed, then length is a fixed value. Therefore, the data stored in the value Field of a data element would have that length and length and unitSize would be equal.
  • If restriction is DicomVRRestriction.BinaryMaximum, DicomVRRestriction.StringMaximum or DicomVRRestriction.TextMaximum then length is the maximum length of data that can be stored in the Value Field of a Data Element. In this case, unitSize would contain the minimum length of data to be stored in the Value Field of a Data Element.
  • For example, in the Default Value Representation Table, value representation DicomVRType.AE has the following default values:

    length 16
    restriction DicomVRRestriction.StringMaximum
    unitSize 1
Example
C#
using Leadtools; 
using Leadtools.Dicom; 
 
 
public void TestVRTable() 
{ 
 
   //Make sure to initialize the DICOM engine, this needs to be done only once  
   //In the whole application 
   DicomEngine.Startup(); 
 
   //We don't need to call this since the DicomEngine.Startup already does that for us 
   //These calls are for demonstration purposes only 
   DicomVRTable.Instance.Reset(); 
   DicomVRTable.Instance.Default(); 
 
   //We can also call FindByIndex if we know the index of this VR 
   DicomVR vr = DicomVRTable.Instance.Find(DicomVRType.AE); 
   DicomVRTable.Instance.Delete(vr); 
 
   DicomVR vr1 = DicomVRTable.Instance.Insert(DicomVRType.AE, "My AE VR", 16, DicomVRRestriction.StringFixed, 1); 
   Debug.Assert(DicomVRTable.Instance.Exists(vr1) == true); 
   DicomVRTable.Instance.SetName(vr1, "My New AE VR"); 
 
   int count = 0; 
   //If we want to loop through all the VRs in the table we can do this: 
   vr = DicomVRTable.Instance.GetFirst(); 
   while (vr != null) 
   { 
      // We can also access the rest of the properties of DicomVR in here, 
      // such as DicomVRType.Code, DicomVRType.Length, DicomVRType.Name, 
      // DicomVRType.Restriction and DicomVRType.UnitSize 
      if (vr.Code == DicomVRType.AE) 
      { 
         Console.WriteLine(vr.Name); 
      } 
      count++; 
      vr = DicomVRTable.Instance.GetNext(vr); 
   } 
   //We can use GetLast and GetPrevious to achieve the same thing 
 
   Debug.Assert(count == DicomVRTable.Instance.GetCount()); 
 
   DicomEngine.Shutdown(); 
} 
Requirements

Target Platforms

Help Version 22.0.2023.1.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Dicom Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.