def create_control_point(cp, sequence, options={})
      cp_item = DICOM::Item.new(:parent => sequence)
      # Some CP attributes will always be written (CP index, BLD positions & Cumulative meterset weight).
      # The other attributes are only written if they are different from the previous control point.
      # Control Point Index:
      DICOM::Element.new('300A,0112', "#{cp.index}", :parent => cp_item)
      # Beam Limiting Device Position Sequence:
      create_beam_limiting_device_positions(cp_item, cp, options)
      # Source to Surface Distance:
      add_ssd(cp.ssd, cp_item)
      # Cumulative Meterset Weight:
      DICOM::Element.new('300A,0134', cp.monitor_units.to_f, :parent => cp_item)
      # Referenced Dose Reference Sequence:
      create_referenced_dose_reference(cp_item) if options[:dose_ref]
      # Attributes that are only added if they carry an updated value:
      # Nominal Beam Energy:
      add_energy(cp.energy, cp_item)
      # Dose Rate Set:
      add_doserate(cp.doserate, cp_item)
      # Gantry Angle & Rotation Direction:
      add_angle(cp_item, '300A,011E', '300A,011F', cp.gantry_angle, cp.gantry_dir, :current_gantry)
      # Beam Limiting Device Angle & Rotation Direction:
      add_angle(cp_item, '300A,0120', '300A,0121', cp.collimator_angle, cp.collimator_dir, :current_collimator)
      # Patient Support Angle & Rotation Direction:
      add_angle(cp_item, '300A,0122', '300A,0123', cp.couch_pedestal, cp.couch_ped_dir, :current_couch_pedestal)
      # Table Top Eccentric Angle & Rotation Direction:
      add_angle(cp_item, '300A,0125', '300A,0126', cp.couch_angle, cp.couch_dir, :current_couch_angle)
      # Table Top Vertical Position:
      add_couch_position(cp_item, '300A,0128', cp.couch_vertical, :current_couch_vertical)
      # Table Top Longitudinal Position:
      add_couch_position(cp_item, '300A,0129', cp.couch_longitudinal, :current_couch_longitudinal)
      # Table Top Lateral Position:
      add_couch_position(cp_item, '300A,012A', cp.couch_lateral, :current_couch_lateral)
      # Isocenter Position (x\y\z):
      add_isosenter(cp.parent.parent.site_setup, cp_item)
      cp_item
    end
def create_control_point(cp, sequence, options={})
      cp_item = DICOM::Item.new(:parent => sequence)
      # Some CP attributes will always be written (CP index, BLD positions & Cumulative meterset weight).
      # The other attributes are only written if they are different from the previous control point.
      # Control Point Index:
      DICOM::Element.new('300A,0112', "#{cp.index}", :parent => cp_item)
      # Beam Limiting Device Position Sequence:
      create_beam_limiting_device_positions(cp_item, cp, options)
      # Source to Surface Distance:
      add_ssd(cp.ssd, cp_item)
      # Cumulative Meterset Weight:
      DICOM::Element.new('300A,0134', cp.monitor_units.to_f, :parent => cp_item)
      # Referenced Dose Reference Sequence:
      create_referenced_dose_reference(cp_item) if options[:dose_ref]
      # Attributes that are only added if they carry an updated value:
      # Nominal Beam Energy:
      add_energy(cp.energy, cp_item)
      # Dose Rate Set:
      add_doserate(cp.doserate, cp_item)
      # Gantry Angle & Rotation Direction:
      add_angle(cp_item, '300A,011E', '300A,011F', cp.gantry_angle, cp.gantry_dir, :current_gantry)
      # Beam Limiting Device Angle & Rotation Direction:
      add_angle(cp_item, '300A,0120', '300A,0121', cp.collimator_angle, cp.collimator_dir, :current_collimator)
      # Patient Support Angle & Rotation Direction:
      add_angle(cp_item, '300A,0122', '300A,0123', cp.couch_pedestal, cp.couch_ped_dir, :current_couch_pedestal)
      # Table Top Eccentric Angle & Rotation Direction:
      add_angle(cp_item, '300A,0125', '300A,0126', cp.couch_angle, cp.couch_dir, :current_couch_angle)
      # Table Top Vertical Position:
      add_couch_position(cp_item, '300A,0128', cp.couch_vertical, :current_couch_vertical)
      # Table Top Longitudinal Position:
      add_couch_position(cp_item, '300A,0129', cp.couch_longitudinal, :current_couch_longitudinal)
      # Table Top Lateral Position:
      add_couch_position(cp_item, '300A,012A', cp.couch_lateral, :current_couch_lateral)
      # Isocenter Position (x\y\z):
      add_isosenter(cp.parent.parent.site_setup, cp_item)
      cp_item
    end
Creates a control point item in the given control point sequence, based
 on an RTP control point record.

 @param [ControlPoint] cp the RTP ControlPoint record to convert
 @param [DICOM::Sequence] sequence the DICOM parent sequence of the item to be created
 @param [Hash] options the options to use for creating the control point
 @option options [Boolean] :dose_ref if set, a Referenced Dose Reference sequence will be included in the generated control point item
 @return [DICOM::Item] the constructed control point DICOM item