1 /* 2 * 3 * Copyright (C) 1998-2012, OFFIS e.V. 4 * All rights reserved. See COPYRIGHT file for details. 5 * 6 * This software and supporting documentation were developed by 7 * 8 * OFFIS e.V. 9 * R&D Division Health 10 * Escherweg 2 11 * D-26121 Oldenburg, Germany 12 * 13 * 14 * Module: dcmpstat 15 * 16 * Author: Marco Eichelberg 17 * 18 * Purpose: 19 * classes: DVPSReferencedImage 20 * 21 */ 22 23 #ifndef DVPSRI_H 24 #define DVPSRI_H 25 26 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 27 #include "dcmtk/dcmpstat/dpdefine.h" 28 #include "dcmtk/dcmdata/dcvrui.h" 29 #include "dcmtk/dcmdata/dcvris.h" 30 31 /** an item of the referenced image sequence in a presentation state (internal use only). 32 * This class manages the data structures comprising one item 33 * of the Reference Image Sequence which is contained 34 * in the Referenced Series Sequence in a Presentation State object. 35 */ 36 37 class DCMTK_DCMPSTAT_EXPORT DVPSReferencedImage 38 { 39 public: 40 /// default constructor 41 DVPSReferencedImage(); 42 43 /// copy constructor 44 DVPSReferencedImage(const DVPSReferencedImage& copy); 45 46 /** clone method. 47 * @return a pointer to a new DVPSReferencedImage object containing 48 * a copy of this object. 49 */ clone()50 DVPSReferencedImage *clone() { return new DVPSReferencedImage(*this); } 51 52 /// destructor 53 virtual ~DVPSReferencedImage(); 54 55 /** reads an image reference from a DICOM dataset. 56 * The DICOM elements of the referenced image item are copied 57 * from the dataset to this object. 58 * The completeness of the item (presence of all required elements, 59 * value multiplicity) is checked. 60 * If this method returns an error code, the object is in undefined state afterwards. 61 * @param dset the item of the ReferencedImageSequence from which the data is to be read 62 * @return EC_Normal if successful, an error code otherwise. 63 */ 64 OFCondition read(DcmItem &dset); 65 66 /** writes the image reference managed by this object to a DICOM dataset. 67 * Copies of the DICOM element managed by this object are inserted into 68 * the DICOM dataset. 69 * @param dset the the item of the ReferencedImageSequence to which the data is written 70 * @return EC_Normal if successful, an error code otherwise. 71 */ 72 OFCondition write(DcmItem &dset); 73 74 /** check if the passed SOP Class UID is equal to the one stored in this object. 75 * If sopclassuid is empty, the referencedSOPClassUID is assigned to it and the method returns 76 * OFTrue. Otherwise the passed UID is compared with the referencedSOPClassUID. 77 * OFTrue is returned if they are equal, OFFalse otherwise. 78 * This method is used to check whether all image references in a presentation state 79 * share the same SOP Class UID. 80 * @param sopclassuid the SOP class UID to be validated 81 * @return OFTrue if successful, OFFalse if unsuccessful. 82 */ 83 OFBool validateSOPClassUID(OFString& sopclassuid); 84 85 /** set SOP Class UID of this image reference. 86 * @param uid a pointer to the UID, which is copied into this object. 87 */ 88 void setSOPClassUID(const char *uid); 89 90 /** set SOP Instance UID of this image reference. 91 * @param uid a pointer to the UID, which is copied into this object. 92 */ 93 void setSOPInstanceUID(const char *uid); 94 95 /** set the list of frame numbers of this image reference. 96 * @param frames a list of frame numbers in DICOM IS format 97 * (integer numbers separated by '\' characters) 98 */ 99 void setFrameNumbers(const char *frames); 100 101 /** compare SOP Instance UID. 102 * @param uid the UID to be compared 103 * @return OFTrue if the referencedSOPInstanceUID of this object is 104 * equal to uid, OFFalse otherwise. 105 */ 106 OFBool isSOPInstanceUID(const char *uid); 107 108 /** gets the image reference managed by this object. 109 * @param sopclassUID the SOP Class UID is returned in this string 110 * @param instanceUID the SOP Instance UID is returned in this string 111 * @param frames the list of frames is returned in this string 112 * @return EC_Normal if successful, an error code otherwise. 113 */ 114 OFCondition getImageReference( 115 OFString& sopclassUID, 116 OFString& instanceUID, 117 OFString& frames); 118 119 /** checks whether this image reference applies to the given frame number. 120 * An image reference applies to a frame if the frame number is explicitly 121 * listed in the referencedFrameNumber attribute or if the referencedFrameNumber 122 * is empty. 123 * @param frame frame number to be checked 124 * @return OFTrue if the image reference applies to the given frame number, OFFalse otherwise. 125 */ 126 OFBool appliesToFrame(unsigned long frame); 127 128 /** checks whether this image reference applies exactly to the given frame number. 129 * This is the case if the referencedFrameNumber only contains the given frame number. 130 * @param frame frame number to be checked 131 * @return OFTrue if the image reference applies only to the given frame number, OFFalse otherwise. 132 */ 133 OFBool appliesOnlyToFrame(unsigned long frame); 134 135 /** checks whether this image reference applies all frames 136 * because the referencedFrameNumber is empty. 137 * @return OFTrue if the image reference applies to all frames, OFFalse otherwise. 138 */ 139 OFBool appliesToAllFrames(); 140 141 /** update the reference such that the given frame is not referenced any more. 142 * @param frame the frame reference 143 * @param numberOfFrames the number of frames of the image reference 144 */ 145 void removeFrameReference(unsigned long frame, unsigned long numberOfFrames); 146 147 private: 148 149 /** undefined private assignment operator 150 */ 151 DVPSReferencedImage& operator=(const DVPSReferencedImage& source); 152 153 /** flushes the frame cache. 154 */ 155 void flushCache(); 156 /** updated the frame cache. 157 */ 158 void updateCache(); 159 160 /// VR=UI, VM=1, Type 1c 161 DcmUniqueIdentifier referencedSOPClassUID; 162 /// VR=UI, VM=1, Type 1c 163 DcmUniqueIdentifier referencedSOPInstanceUID; 164 /// VR=IS, VM=1-n, Type 1c 165 DcmIntegerString referencedFrameNumber; 166 /// if exists, contains binary representation of referencedFrameNumber 167 Sint32 *frameCache; 168 /// describes array size of frameCache 169 unsigned long frameCacheEntries; 170 171 }; 172 173 #endif 174