Ejemplo n.º 1
0
        /// <summary>
        /// Adds a single attribute with the tag sequence, VR and values specified.
        /// </summary>
        /// <remarks>
        /// If an attribute already exists with this tag, it is removed first before it is again
        /// added.
        /// <br></br><br></br>
        /// If sequence items (each with a sequence item index) are specified in the tag sequence,
        /// empty sequence items will be added automatically to avoid gaps in the sequence items of sequence
        /// attributes.
        /// </remarks>
        /// <param name="tagSequence">The tag sequence of the attribute.</param>
        /// <param name="vR">The VR of the attribute.</param>
        /// <param name="values">The values, which will be copied from another attribute, for this attribute.</param>
        /// <exception cref="System.ArgumentException">
        /// <paramref name="dvtkDataTag"/> is not valid for setting an attribute.<br></br>
        /// -or-<br></br>
        /// <paramref name="dvtkDataTag"/> is not valid for setting a CommandSet attribute.<br></br>
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="values"/> is a null reference.
        /// </exception>
        public override void Set(String tagSequence, VR vR, Values values)
        {
            TagSequence internalTagSequence = new TagSequence(tagSequence);


            //
            // Sanity checks.
            //

            if (!internalTagSequence.IsSingleAttributeMatching)
            {
                throw new ArgumentException(internalTagSequence.ToString() + " not valid for setting an attribute.");
            }

            // Check if the tag supplied is valid for a CommandSet.
            if (!internalTagSequence.IsValidForCommandSet)
            {
                throw new ArgumentException(internalTagSequence.ToString() + " not valid for setting a CommandSet attribute.", "dvtkDataTag");
            }

            if (values == null)
            {
                throw new ArgumentNullException("values");
            }


            //
            // Perform the actual operation in the base class.
            //

            Set(internalTagSequence, vR, values);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a single attribute with the tag, VR and values specified.
        /// </summary>
        /// <remarks>
        /// If an attribute already exists with this tag, it is removed first before it is again
        /// added.
        /// </remarks>
        /// <param name="dvtkDataTag">The tag of the attribute.</param>
        /// <param name="vR">The VR of the attribute.</param>
        /// <param name="values">The values, which will be copied from another attribute, for this attribute.</param>
        /// <exception cref="System.ArgumentException">
        /// <paramref name="dvtkDataTag"/> is not valid for setting a CommandSet attribute.<br></br>
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="values"/> is a null reference.
        /// </exception>
        public override void Set(DvtkData.Dimse.Tag dvtkDataTag, VR vR, Values values)
        {
            TagSequence internalTagSequence = new TagSequence();

            internalTagSequence.Add(new Tag(dvtkDataTag.GroupNumber, dvtkDataTag.ElementNumber));


            //
            // Sanity checks.
            //

            // Check if the tag supplied is valid for a CommandSet.
            if (!internalTagSequence.IsValidForCommandSet)
            {
                throw new ArgumentException(internalTagSequence.ToString() + " is not valid for setting a CommandSet attribute.", "dvtkDataTag");
            }

            if (values == null)
            {
                throw new ArgumentNullException("values");
            }


            //
            // Perform the actual operation in the base class.
            //

            Set(internalTagSequence, vR, values);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds a single attribute with the tag sequence, VR and value specified.
        /// </summary>
        /// <remarks>
        /// Only use this method for setting an attribute with VR OB, OF or OW.
        /// <br></br><br></br>
        /// If an attribute already exists with this tag, it is removed first before it is again
        /// added.
        /// <br></br><br></br>
        /// If sequence items (each with a sequence item index) are specified in the tag sequence,
        /// empty sequence items will be added automatically to avoid gaps in the sequence items of sequence
        /// attributes.
        /// </remarks>
        /// <param name="tagSequence">The tag sequence of the attribute.</param>
        /// <param name="vR">The VR (may only be OB, OF or OW) of the attribute.</param>
        /// <param name="value">The value of the attribute.</param>
        /// <exception cref="System.ArgumentException">
        /// <paramref name="dvtkDataTag"/> is not valid for setting an attribute.<br></br>
        /// -or-<br></br>
        /// <paramref name="dvtkDataTag"/> is not valid for setting a CommandSet attribute.<br></br>
        /// -or-<br></br>
        /// <paramref name="vR"/> is unequal to OB, OF or OW.
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="value"/> is a null reference.
        /// </exception>
        public override void Set(String tagSequence, VR vR, Byte[] value)
        {
            TagSequence internalTagSequence = new TagSequence(tagSequence);


            //
            // Sanity checks.
            //

            if (!internalTagSequence.IsSingleAttributeMatching)
            {
                throw new ArgumentException(internalTagSequence.ToString() + " not valid for setting an attribute.");
            }

            // Check if the tag supplied is valid for a CommandSet.
            if (!internalTagSequence.IsValidForCommandSet)
            {
                throw new ArgumentException(internalTagSequence.ToString() + " not valid for setting a CommandSet attribute.", "dvtkDataTag");
            }

            // Check the supplied VR.

            if ((vR != VR.OB) && (vR != VR.OF) && (vR != VR.OW))
            {
                throw new ArgumentException("Supplied VR is " + vR.ToString() + ". VR may only be OB, OF or OW.", "vR");
            }

            if (value == null)
            {
                throw new ArgumentNullException("value");
            }


            //
            // Perform the actual operation in the base class.
            //

            Set(internalTagSequence, vR, value);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds a single attribute with the tag, VR and value specified.
        /// </summary>
        /// <remarks>
        /// Only use this method for setting an attribute with VR OB, OF or OW.
        /// <br></br><br></br>
        /// If an attribute already exists with this tag, it is removed first before it is again
        /// added.
        /// </remarks>
        /// <param name="dvtkDataTag">The tag of the attribute.</param>
        /// <param name="vR">The VR (may only be OB, OF or OW) of the attribute.</param>
        /// <param name="value">The value of the attribute.</param>
        /// <exception cref="System.ArgumentException">
        /// <paramref name="dvtkDataTag"/> is not valid for setting a CommandSet attribute.<br></br>
        /// -or-<br></br>
        /// <paramref name="vR"/> is unequal to OB, OF or OW.
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="value"/> is a null reference.
        /// </exception>
        public override void Set(DvtkData.Dimse.Tag dvtkDataTag, VR vR, Byte[] value)
        {
            TagSequence internalTagSequence = new TagSequence();

            internalTagSequence.Add(new Tag(dvtkDataTag.GroupNumber, dvtkDataTag.ElementNumber));


            //
            // Sanity checks.
            //

            // Check if the tag supplied is valid for a CommandSet.
            if (!internalTagSequence.IsValidForCommandSet)
            {
                throw new ArgumentException(internalTagSequence.ToString() + " is not valid for setting a CommandSet attribute.", "dvtkDataTag");
            }

            // Check the supplied VR.

            if ((vR != VR.OB) && (vR != VR.OF) && (vR != VR.OW))
            {
                throw new ArgumentException("Supplied VR is " + vR.ToString() + ". VR may only be OB, OF or OW.", "vR");
            }

            if (value == null)
            {
                throw new ArgumentNullException("value");
            }


            //
            // Perform the actual operation in the base class.
            //

            Set(internalTagSequence, vR, value);
        }
Ejemplo n.º 5
0
        internal void Append(TagSequence tagSequence, VR vR, params Object[] parameters)
        {
            // Check if the supplied parameters correspond with the supplied VR.
            // If the check fails, an exception is thrown.
            CheckParameters(vR, parameters);

            if (tagSequence.IsSingleAttributeMatching)
            // Supplied TagSequence is single attribute matching.
            {
                if (Exists(tagSequence))
                // Attribute already exists.
                {
                    Attribute alreadyExistingAttribute = this[tagSequence];

                    if (alreadyExistingAttribute.VR == vR)
                    // Attribute already exists and has the same VR.
                    {
                        if (vR == VR.SQ)
                        // Attribute already exists and also has VR SQ.
                        {
                            foreach (SequenceItem itemToAdd in parameters)
                            {
                                alreadyExistingAttribute.AddItem(itemToAdd);
                            }
                        }
                        else
                        // Attribute already exists and has the same VR (unequal to SQ).
                        {
                            alreadyExistingAttribute.Values.Add(parameters);
                        }
                    }
                    else
                    // Attribute already exists but has a different VR.
                    {
                        Thread.WriteErrorCurrentThread("While appending, attribute with tag sequence " + tagSequence.ToString() + " already existed with a different VR. Nothing will be appended.");
                    }
                }
                else
                // Attribute does not already exists.
                {
                    // In this case, behaviour should be the same as the Set method.
                    Set(tagSequence, vR, parameters);
                }
            }
            else
            // Supplied TagSequence contains wildcards.
            {
                AttributeCollection existingAttributes = GetAttributes(tagSequence);

                foreach (ValidAttribute existingAttribute in existingAttributes)
                {
                    Append(existingAttribute.TagSequence, vR, parameters);
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Adds a single attribute with the tag sequence, VR and values specified.
        /// </summary>
        /// <remarks>
        /// If an attribute already exists with this tag, it is removed first before it is again
        /// added.
        /// <br></br><br></br>
        /// If sequence items (each with a sequence item index) are specified in the tag sequence,
        /// empty sequence items will be added automatically to avoid gaps in the sequence items of sequence
        /// attributes.
        /// </remarks>
        /// <param name="tagSequence">The tag sequence of the attribute.</param>
        /// <param name="vR">The VR of the attribute.</param>
        /// <param name="values">The values, which will be copied from another attribute, for this attribute.</param>
        /// <exception cref="System.ArgumentException">
        /// <paramref name="dvtkDataTag"/> is not valid for setting an attribute.<br></br>
        /// -or-<br></br>
        /// <paramref name="dvtkDataTag"/> is not valid for setting a CommandSet attribute.<br></br>
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="values"/> is a null reference.
        /// </exception>
        public override void Set(String tagSequence, VR vR, Values values)
        {
            TagSequence internalTagSequence = new TagSequence(tagSequence);

            //
            // Sanity checks.
            //

            if (!internalTagSequence.IsSingleAttributeMatching)
            {
                throw new ArgumentException(internalTagSequence.ToString() + " not valid for setting an attribute.");
            }

            // Check if the tag supplied is valid for a CommandSet.
            if (!internalTagSequence.IsValidForCommandSet)
            {
                throw new ArgumentException(internalTagSequence.ToString() + " not valid for setting a CommandSet attribute.", "dvtkDataTag");
            }

            if (values == null)
            {
                throw new ArgumentNullException("values");
            }

            //
            // Perform the actual operation in the base class.
            //

            Set(internalTagSequence, vR, values);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Adds a single attribute with the tag sequence, VR and value specified.
        /// </summary>
        /// <remarks>
        /// Only use this method for setting an attribute with VR OB, OF or OW.
        /// <br></br><br></br>
        /// If an attribute already exists with this tag, it is removed first before it is again
        /// added.
        /// <br></br><br></br>
        /// If sequence items (each with a sequence item index) are specified in the tag sequence,
        /// empty sequence items will be added automatically to avoid gaps in the sequence items of sequence
        /// attributes.
        /// </remarks>
        /// <param name="tagSequence">The tag sequence of the attribute.</param>
        /// <param name="vR">The VR (may only be OB, OF or OW) of the attribute.</param>
        /// <param name="value">The value of the attribute.</param>
        /// <exception cref="System.ArgumentException">
        /// <paramref name="dvtkDataTag"/> is not valid for setting an attribute.<br></br>
        /// -or-<br></br>
        /// <paramref name="dvtkDataTag"/> is not valid for setting a CommandSet attribute.<br></br>
        /// -or-<br></br>
        /// <paramref name="vR"/> is unequal to OB, OF or OW.
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="value"/> is a null reference.
        /// </exception>
        public override void Set(String tagSequence, VR vR, Byte[] value)
        {
            TagSequence internalTagSequence = new TagSequence(tagSequence);

            //
            // Sanity checks.
            //

            if (!internalTagSequence.IsSingleAttributeMatching)
            {
                throw new ArgumentException(internalTagSequence.ToString() + " not valid for setting an attribute.");
            }

            // Check if the tag supplied is valid for a CommandSet.
            if (!internalTagSequence.IsValidForCommandSet)
            {
                throw new ArgumentException(internalTagSequence.ToString() + " not valid for setting a CommandSet attribute.", "dvtkDataTag");
            }

            // Check the supplied VR.

            if ((vR != VR.OB) && (vR != VR.OF) && (vR != VR.OW))
            {
                throw new ArgumentException("Supplied VR is " + vR.ToString() + ". VR may only be OB, OF or OW.", "vR");
            }

            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            //
            // Perform the actual operation in the base class.
            //

            Set(internalTagSequence, vR, value);
        }
Ejemplo n.º 8
0
        //
        // - Methods -
        //

        /// <summary>
        /// Adds a sequence item to the end of the item list.
        /// </summary>
        /// <remarks>
        /// This method is only meaningfull if this instance has a VR SQ.
        /// </remarks>
        /// <param name="item">The sequence item to add.</param>
        public override void AddItem(SequenceItem item)
        {
            if (this.VR == VR.SQ)
            {
                SequenceItem cloneSequenceItem = item.Clone();

                DvtkDataSequence.Add(cloneSequenceItem.DvtkDataSequenceItem);
            }
            else
            {
                Thread.WriteWarningCurrentThread("Adding a sequence item to an attribute with tag sequence " + TagSequence.ToString() + " and VR " + this.VR.ToString() + ". Doing nothing.");
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Adds a single attribute with the tag, VR and value specified.
        /// </summary>
        /// <remarks>
        /// Only use this method for setting an attribute with VR OB, OF or OW.
        /// <br></br><br></br>
        /// If an attribute already exists with this tag, it is removed first before it is again
        /// added.
        /// </remarks>
        /// <param name="dvtkDataTag">The tag of the attribute.</param>
        /// <param name="vR">The VR (may only be OB, OF or OW) of the attribute.</param>
        /// <param name="value">The value of the attribute.</param>
        /// <exception cref="System.ArgumentException">
        /// <paramref name="dvtkDataTag"/> is not valid for setting a CommandSet attribute.<br></br>
        /// -or-<br></br>
        /// <paramref name="vR"/> is unequal to OB, OF or OW.
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="value"/> is a null reference.
        /// </exception>
        public override void Set(DvtkData.Dimse.Tag dvtkDataTag, VR vR, Byte[] value)
        {
            TagSequence internalTagSequence = new TagSequence();

            internalTagSequence.Add(new Tag(dvtkDataTag.GroupNumber, dvtkDataTag.ElementNumber));

            //
            // Sanity checks.
            //

            // Check if the tag supplied is valid for a CommandSet.
            if (!internalTagSequence.IsValidForCommandSet)
            {
                throw new ArgumentException(internalTagSequence.ToString() + " is not valid for setting a CommandSet attribute.", "dvtkDataTag");
            }

            // Check the supplied VR.

            if ((vR != VR.OB) && (vR != VR.OF) && (vR != VR.OW))
            {
                throw new ArgumentException("Supplied VR is " + vR.ToString() + ". VR may only be OB, OF or OW.", "vR");
            }

            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            //
            // Perform the actual operation in the base class.
            //

            Set(internalTagSequence, vR, value);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Adds a single attribute with the tag sequence, VR and values specified.
        /// </summary>
        /// <remarks>
        /// If an attribute already exists with this tag, it is removed first before it is again
        /// added.
        /// <br></br>
        /// If sequence items (each with a sequence item index) are specified in the tag sequence,
        /// empty sequence items will be added automatically to avoid gaps in the sequence items of sequence
        /// attributes.
        /// </remarks>
        /// <param name="tagSequence">The tag sequence of the attribute.</param>
        /// <param name="vR">The VR of the attribute.</param>
        /// <param name="values">The values, which will be copied from another attribute, for this attribute.</param>
        /// <exception cref="System.ArgumentException">
        /// <paramref name="dvtkDataTag"/> is not valid for setting an attribute.<br></br>
        /// -or-<br></br>
        /// <paramref name="dvtkDataTag"/> is not valid for setting a FileMetaInformation attribute.<br></br>
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="values"/> is a null reference.
        /// </exception>
        public override void Set(String tagSequence, VR vR, Values values)
        {
            TagSequence internalTagSequence = new TagSequence(tagSequence);

            //
            // Sanity checks.
            //

            if (!internalTagSequence.IsSingleAttributeMatching)
            {
                throw new ArgumentException(internalTagSequence.ToString() + " not valid for setting an attribute.");
            }

            // Check if the tag supplied is valid for a FileMetaInformation.
            if (!internalTagSequence.IsValidForFileMetaInformation)
            {
                throw new ArgumentException(internalTagSequence.ToString() + " not valid for setting a FileMetaInformation attribute.", "dvtkDataTag");
            }

            if (values == null)
            {
                throw new ArgumentNullException("values");
            }

            //
            // Perform the actual operation.
            //

            Set(internalTagSequence, vR, values);

            if ((internalTagSequence.ToString() == "0x00020010") && (values.Count == 1))
            {
                this.dvtkDataFileHead.TransferSyntax = new DvtkData.Dul.TransferSyntax(values[0]);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Adds a single attribute with the tag, VR and values specified.
        /// </summary>
        /// <remarks>
        /// If an attribute already exists with this tag, it is removed first before it is again
        /// added.
        /// </remarks>
        /// <param name="dvtkDataTag">The tag of the attribute.</param>
        /// <param name="vR">The VR of the attribute.</param>
        /// <param name="values">
        /// The values of the attribute. Do not use the DICOM delimeter '\' directly. Instead supply
        /// multiple values arguments for this method when adding a single attribute with multiple values.
        /// </param>
        /// <exception cref="System.ArgumentException">
        /// <paramref name="dvtkDataTag"/> is not valid for setting a FileMetaInformation attribute.<br></br>
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="values"/> is a null reference.
        /// </exception>
        public override void Set(DvtkData.Dimse.Tag dvtkDataTag, VR vR, params Object[] values)
        {
            TagSequence internalTagSequence = new TagSequence();

            internalTagSequence.Add(new Tag(dvtkDataTag.GroupNumber, dvtkDataTag.ElementNumber));

            //
            // Sanity checks.
            //

            // Check if the tag supplied is valid for a FileMetaInformation.
            if (!internalTagSequence.IsValidForFileMetaInformation)
            {
                throw new ArgumentException(internalTagSequence.ToString() + " is not valid for setting a FileMetaInformation attribute.", "dvtkDataTag");
            }

            if (values == null)
            {
                throw new ArgumentNullException("values");
            }

            //
            // Perform the actual operation.
            //

            Set(internalTagSequence, vR, values);

            if ((internalTagSequence.ToString() == "0x00020010") && (values.Length == 1))
            {
                this.dvtkDataFileHead.TransferSyntax = new DvtkData.Dul.TransferSyntax(values[0].ToString());
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Removes a sequence item.
 /// </summary>
 /// <param name="oneBasedIndex">The one based index</param>
 public override void RemoveItemAt(int oneBasedIndex)
 {
     if (this.VR == VR.SQ)
     {
         if ((oneBasedIndex >= 1) && (oneBasedIndex <= ItemCount))
         {
             DvtkDataSequence.RemoveAt(oneBasedIndex - 1);
         }
         else
         {
             Thread.WriteWarningCurrentThread("Removing sequence item " + oneBasedIndex.ToString() + " from attribute with tag sequence " + TagSequence.ToString() + " containing " + ItemCount.ToString() + " items. Doing nothing.");
         }
     }
     else
     {
         Thread.WriteWarningCurrentThread("Removing a sequence item from attribute with tag sequence " + TagSequence.ToString() + " and VR " + this.VR.ToString() + ". Doing nothing.");
     }
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Insert a Sequence Item at a specified position.
        /// </summary>
        /// <remarks>
        /// This method is only meaningfull if this instance has a VR SQ. The inserted Sequence
        /// Item will get item number oneBasedIndex.
        /// </remarks>
        /// <param name="oneBasedIndex">The one based index of the position to insert.</param>
        /// <param name="item">The Sequence item to insert.</param>
        public override void InsertItem(int oneBasedIndex, SequenceItem item)
        {
            if (this.VR == VR.SQ)
            {
                if ((oneBasedIndex >= 1) && (oneBasedIndex <= (ItemCount + 1)))
                {
                    SequenceItem cloneSequenceItem = item.Clone();

                    DvtkDataSequence.Insert(oneBasedIndex - 1, cloneSequenceItem.DvtkDataSequenceItem);
                }
                else
                {
                    Thread.WriteWarningCurrentThread("Inserting sequence item at one based position " + oneBasedIndex.ToString() + " fom attribute with tag sequence " + TagSequence.ToString() + " containing " + ItemCount.ToString() + " items. Doing nothing.");
                }
            }
            else
            {
                Thread.WriteWarningCurrentThread("Adding a sequence item to an attribute with tag sequence " + TagSequence.ToString() + " and VR " + this.VR.ToString() + ". Doing nothing.");
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Gets a sequence item.
        /// </summary>
        /// <remarks>
        /// This method is only meaningfull if this instance has a VR SQ.
        /// </remarks>
        /// <param name="oneBasedIndex">The one based index.</param>
        /// <returns>The sequence item.</returns>
        public override SequenceItem GetItem(int oneBasedIndex)
        {
            SequenceItem sequenceItem = null;

            if (this.VR == VR.SQ)
            {
                if ((oneBasedIndex >= 1) && (oneBasedIndex <= ItemCount))
                {
                    TagSequence sequenceItemTagSequence = TagSequence.Clone();
                    Tag         lastTag = sequenceItemTagSequence.Tags[sequenceItemTagSequence.Tags.Count - 1] as Tag;
                    lastTag.IndexNumber = oneBasedIndex;

                    sequenceItem = new SequenceItem(sequenceItemTagSequence, DvtkDataSequence[oneBasedIndex - 1]);
                }
                else
                {
                    sequenceItem = new SequenceItem();
                    Thread.WriteWarningCurrentThread("Getting sequence item " + oneBasedIndex.ToString() + " from attribute with tag sequence " + TagSequence.ToString() + " containing " + ItemCount.ToString() + " items. Returning an empty sequence item.");
                }
            }
            else
            {
                sequenceItem = new SequenceItem();
                Thread.WriteWarningCurrentThread("Getting a sequence item from attribute with tag sequence " + TagSequence.ToString() + " and VR " + this.VR.ToString() + ". Returning an empty sequence item.");
            }

            return(sequenceItem);
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Clears all sequence items present in the attribute.
 /// </summary>
 /// <remarks>
 /// This method is only meaningfull if this instance has a VR SQ.
 /// </remarks>
 public override void ClearItems()
 {
     if (this.VR == VR.SQ)
     {
         DvtkDataSequence.Clear();
     }
     else
     {
         Thread.WriteWarningCurrentThread("Clearing the sequence items of an attribute with tag sequence " + TagSequence.ToString() + " and VR " + this.VR.ToString() + ". Doing nothing.");
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Adds a single attribute with the tag, VR and values specified.
        /// </summary>
        /// <remarks>
        /// If an attribute already exists with this tag, it is removed first before it is again
        /// added.
        /// </remarks>
        /// <param name="dvtkDataTag">The tag of the attribute.</param>
        /// <param name="vR">The VR of the attribute.</param>
        /// <param name="values">The values, which will be copied from another attribute, for this attribute.</param>
        /// <exception cref="System.ArgumentException">
        /// <paramref name="dvtkDataTag"/> is not valid for setting a CommandSet attribute.<br></br>
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="values"/> is a null reference.
        /// </exception>
        public override void Set(DvtkData.Dimse.Tag dvtkDataTag, VR vR, Values values)
        {
            TagSequence internalTagSequence = new TagSequence();

            internalTagSequence.Add(new Tag(dvtkDataTag.GroupNumber, dvtkDataTag.ElementNumber));

            //
            // Sanity checks.
            //

            // Check if the tag supplied is valid for a CommandSet.
            if (!internalTagSequence.IsValidForCommandSet)
            {
                throw new ArgumentException(internalTagSequence.ToString() + " is not valid for setting a CommandSet attribute.", "dvtkDataTag");
            }

            if (values == null)
            {
                throw new ArgumentNullException("values");
            }

            //
            // Perform the actual operation in the base class.
            //

            Set(internalTagSequence, vR, values);
        }
Ejemplo n.º 17
0
        //
        // - Methods -
        //
        /// <summary>
        /// Get the next collection of attributes to compare to each other.
        /// If an attribute is not present, a null pointer is returned in the AttributeCollection.
        /// If all attributes have been compared, null is returned.
        /// </summary>
        /// <returns>The attributes to validate.</returns>
        /// 
        private AttributeList DetermineNextAttributes(TagSequence lowestTagSequence)
        {
            AttributeList nextAttributes = new AttributeList();

            nextAttributes.CompareRule = new CompareRule();

            for (int index = 0; index < this.attributeCollections.Count; index++)
            {
                int attributeSetIndex = (int)this.currentAttributeIndices[index];
                AttributeCollectionBase attributeCollectionBase = this.attributeCollections[index];

                if (attributeCollectionBase == null)
                {
                    nextAttributes.Add(null);
                    nextAttributes.CompareRule.Add(null);
                }
                else if (attributeCollectionBase is Hl7AttributeCollection)
                {
                    nextAttributes.Add(null);
                    nextAttributes.CompareRule.Add(null);
                }
                else if (attributeCollectionBase is DicomAttributeCollection)
                {
                    DicomAttributeCollection dicomAttributeCollection = attributeCollectionBase as DicomAttributeCollection;

                    if (attributeSetIndex < dicomAttributeCollection.AttributeSetOnly.Count)
                        // Still unprocessed attributes left in this dataset.
                    {
                        ValidAttribute attributeOnly = dicomAttributeCollection.AttributeSetOnly[attributeSetIndex] as ValidAttribute;

                        if (attributeOnly.TagSequence.LastTag.AsUInt32 == lowestTagSequence.LastTag.AsUInt32)
                        {
                            // Add entry with existing attribute.
                            ValidationRuleDicomAttribute validationRuleDicomAttribute = new ValidationRuleDicomAttribute(lowestTagSequence.ToString(), dicomAttributeCollection.Flags);
                            nextAttributes.CompareRule.Add(validationRuleDicomAttribute);
                            DicomAttribute dicomAttribute = new DicomAttribute(attributeOnly, validationRuleDicomAttribute);
                            nextAttributes.Add(dicomAttribute);

                            // This attribute will be returned. Increase the attribute index.
                            this.currentAttributeIndices[index] = attributeSetIndex + 1;
                        }
                        else
                        {
                            // Add entry with non-existing attribute.
                            ValidationRuleDicomAttribute validationRuleDicomAttribute = new ValidationRuleDicomAttribute(lowestTagSequence.ToString(), dicomAttributeCollection.Flags);
                            DicomAttribute dicomAttribute = new DicomAttribute(new DvtkHighLevelInterface.Dicom.Other.InvalidAttribute(), validationRuleDicomAttribute);
                            nextAttributes.Add(dicomAttribute);
                        }
                    }
                    else
                        // No more unprocessed attributes left in this dataset.
                    {
                        // Add entry with non-existing attribute.
                        ValidationRuleDicomAttribute validationRuleDicomAttribute = new ValidationRuleDicomAttribute(lowestTagSequence.ToString(), dicomAttributeCollection.Flags);
                        DicomAttribute dicomAttribute = new DicomAttribute(new DvtkHighLevelInterface.Dicom.Other.InvalidAttribute(), validationRuleDicomAttribute);
                        nextAttributes.Add(dicomAttribute);
                    }
                }
            }

            return(nextAttributes);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Adds a single attribute with the tag sequence, VR and values specified.
        /// </summary>
        /// <remarks>
        /// Depending on the group number of the last tag in the tag sequence, the attribute
        /// is set in the CommandSet or DataSet of this instance.
        /// <br></br><br></br>
        /// If an attribute already exists with this tag sequence, it is removed first before it is 
        /// again set.
        /// <br></br><br></br>
        /// If sequence items (each with a sequence item index) are specified in the tag sequence,
        /// empty sequence items will be added automatically to avoid gaps in the sequence items of sequence
        /// attributes.
        /// </remarks>
        /// <param name="tagSequence">The tag sequence that uniquely identifies the attribute.</param>
        /// <param name="vR">The VR of the attribute.</param>
        /// <param name="parameters">
        /// The values of the attribute. Do not use the DICOM delimeter '\' directly. Instead use
        /// multiple parameter arguments for this method when adding a single attribute with multiple values.
        /// </param>
        internal void Set(TagSequence tagSequence, VR vR, params Object[] parameters)
        {
            // Check if the TagSequence supplied uniquely identifies one attribute.
            if (!tagSequence.IsSingleAttributeMatching)
            {
                throw new HliException(tagSequence.ToString() + " not valid for setting an attribute.");
            }

            if (tagSequence.IsValidForCommandSet)
            {
                CommandSet.Set(tagSequence, vR, parameters);
            }
            else if (tagSequence.IsValidForDataSet)
            {
                DataSet.Set(tagSequence, vR, parameters);
            }
            else
            {
                throw new HliException(tagSequence.ToString() + " not valid for setting a DicomMessage attribute.");
            }
        }