1 /* 2 * 3 * Copyright (C) 1994-2002, OFFIS 4 * 5 * This software and supporting documentation were developed by 6 * 7 * Kuratorium OFFIS e.V. 8 * Healthcare Information and Communication Systems 9 * Escherweg 2 10 * D-26121 Oldenburg, Germany 11 * 12 * THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND OFFIS MAKES NO WARRANTY 13 * REGARDING THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR 14 * FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR 15 * ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND 16 * PERFORMANCE OF THE SOFTWARE IS WITH THE USER. 17 * 18 * Module: dcmdata 19 * 20 * Author: Gerd Ehlers, Andreas Barth 21 * 22 * Purpose: Interface of the class DcmDataset 23 * 24 */ 25 26 27 #ifndef DCDATSET_H 28 #define DCDATSET_H 29 30 #include "osconfig.h" /* make sure OS specific configuration is included first */ 31 32 #include "ofconsol.h" 33 #include "dcerror.h" 34 #include "dctypes.h" 35 #include "dcitem.h" 36 37 38 // forward declarations 39 class DcmInputStream; 40 class DcmOutputStream; 41 class DcmRepresentationParameter; 42 43 44 /** a class handling the DICOM dataset format (files without meta header) 45 */ 46 class DcmDataset 47 : public DcmItem 48 { 49 50 public: 51 52 /** default constructor 53 */ 54 DcmDataset(); 55 56 /** copy constructor 57 * @param old dataset to be copied 58 */ 59 DcmDataset(const DcmDataset &old); 60 61 /** destructor 62 */ 63 virtual ~DcmDataset(); 64 65 /** get type identifier 66 * @return type identifier of this class (EVR_dataset) 67 */ 68 virtual DcmEVR ident() const; 69 70 E_TransferSyntax getOriginalXfer() const; 71 72 /** print all elements of the dataset to a stream 73 * @param out output stream 74 * @param flags optional flag used to customize the output (see DCMTypes::PF_xxx) 75 * @param level current level of nested items. Used for indentation. 76 * @param pixelFileName not used 77 * @param pixelCounter not used 78 */ 79 virtual void print(ostream &out, 80 const size_t flags = 0, 81 const int level = 0, 82 const char *pixelFileName = NULL, 83 size_t *pixelCounter = NULL); 84 85 Uint32 calcElementLength(const E_TransferSyntax xfer, 86 const E_EncodingType enctype); 87 88 virtual OFBool canWriteXfer(const E_TransferSyntax newXfer, 89 const E_TransferSyntax oldXfer = EXS_Unknown); 90 91 /** This function reads the information of all attributes which 92 * are captured in the input stream and captures this information 93 * in this->elementList. Each attribute is represented as an 94 * element in this list. Having read all information for this 95 * particular data set or command, this function will also take 96 * care of group length (according to what is specified in glenc) 97 * and padding elements (don't change anything). 98 * @param inStream The stream which contains the information. 99 * @param xfer The transfer syntax which was used to encode 100 * the information in inStream. 101 * @param glenc Encoding type for group length; specifies what 102 * will be done with group length tags. 103 * @param maxReadLength Maximum read length for reading an attribute value. 104 * @return status, EC_Normal if successful, an error code otherwise 105 */ 106 virtual OFCondition read(DcmInputStream &inStream, 107 const E_TransferSyntax xfer = EXS_Unknown, 108 const E_GrpLenEncoding glenc = EGL_noChange, 109 const Uint32 maxReadLength = DCM_MaxReadLength); 110 111 /** write dataset to a stream 112 * @param outStream DICOM output stream 113 * @param oxfer output transfer syntax 114 * @param enctype encoding types (undefined or explicit length) 115 * @return status, EC_Normal if successful, an error code otherwise 116 */ 117 virtual OFCondition write(DcmOutputStream &outStream, 118 const E_TransferSyntax oxfer, 119 const E_EncodingType enctype = EET_UndefinedLength); 120 121 /** This function writes data values which are contained in this 122 * DcmDataset object to the stream which is passed as first argument. 123 * With regard to the writing of information, the other parameters 124 * which are passed are accounted for. The function will return 125 * EC_Normal, if the information from all elements of this data 126 * set has been written to the buffer, it will return EC_StreamNotifyClient, 127 * if there is no more space in the buffer and _not_ all elements 128 * have been written to it, and it will return some other (error) 129 * value if there was an error. 130 * @param outStream The stream that the information will be written to. 131 * @param oxfer The transfer syntax which shall be used. 132 * @param enctype Encoding type for sequences; specifies how sequences 133 * will be handled. 134 * @param glenc Encoding type for group length; specifies what will 135 * be done with group length tags. 136 * @param padenc Encoding type for padding. Specifies what will be done 137 * with padding tags. 138 * @param padlen The length up to which the dataset shall be padded, if 139 * padding is desired. 140 * @param subPadlen For sequences (ie sub elements), the length up to which 141 * item shall be padded, if padding is desired. 142 * @param instanceLength Number of extra bytes added to the item/dataset length 143 * used when computing the padding; this parameter is for 144 * instance used to pass the length of the file meta header 145 * from the DcmFileFormat to the DcmDataset object. 146 * @return status, EC_Normal if successful, an error code otherwise 147 */ 148 virtual OFCondition write(DcmOutputStream &outStream, 149 const E_TransferSyntax oxfer, 150 const E_EncodingType enctype, 151 const E_GrpLenEncoding glenc, 152 const E_PaddingEncoding padenc = EPD_noChange, 153 const Uint32 padlen = 0, 154 const Uint32 subPadlen = 0, 155 Uint32 instanceLength = 0); 156 157 /** special write method for creation of digital signatures 158 * @param outStream DICOM output stream 159 * @param oxfer output transfer syntax 160 * @param enctype encoding types (undefined or explicit length) 161 * @return status, EC_Normal if successful, an error code otherwise 162 */ 163 virtual OFCondition writeSignatureFormat(DcmOutputStream &outStream, 164 const E_TransferSyntax oxfer, 165 const E_EncodingType enctype = EET_UndefinedLength); 166 167 /** write object in XML format. 168 * The XML declaration (e.g. <?xml version="1.0"?>) is not written by this function. 169 * @param out output stream to which the XML document is written 170 * @param flags optional flag used to customize the output (see DCMTypes::XF_xxx) 171 * @return status, EC_Normal if successful, an error code otherwise 172 */ 173 virtual OFCondition writeXML(ostream &out, 174 const size_t flags = 0); 175 176 /** load object from a DICOM file. 177 * This method only supports DICOM objects stored as a dataset, i.e. without meta header. 178 * Use DcmFileFormat::loadFile() to load files with meta header. 179 * @param fileName name of the file to load 180 * @param readXfer transfer syntax used to read the data (auto detection if EXS_Unknown) 181 * @param groupLength flag, specifying how to handle the group length tags 182 * @param maxReadLength maximum number of bytes to be read for an element value. 183 * Element values with a larger size are not loaded until their value is retrieved 184 * (with getXXX()) or loadAllDataElements() is called. 185 * @return status, EC_Normal if successful, an error code otherwise 186 */ 187 virtual OFCondition loadFile(const char *fileName, 188 const E_TransferSyntax readXfer = EXS_Unknown, 189 const E_GrpLenEncoding groupLength = EGL_noChange, 190 const Uint32 maxReadLength = DCM_MaxReadLength); 191 192 /** save object to a DICOM file. 193 * This method only supports DICOM objects stored as a dataset, i.e. without meta header. 194 * Use DcmFileFormat::saveFile() to save files with meta header. 195 * @param fileName name of the file to save 196 * @param writeXfer transfer syntax used to write the data (EXS_Unknown means use current) 197 * @param encodingType flag, specifying the encoding with undefined or explicit length 198 * @param groupLength flag, specifying how to handle the group length tags 199 * @param padEncoding flag, specifying how to handle the padding tags 200 * @param padLength number of bytes used for the dataset padding (has to be an even number) 201 * @param subPadLength number of bytes used for the item padding (has to be an even number) 202 * @return status, EC_Normal if successful, an error code otherwise 203 */ 204 virtual OFCondition saveFile(const char *fileName, 205 const E_TransferSyntax writeXfer = EXS_Unknown, 206 const E_EncodingType encodingType = EET_UndefinedLength, 207 const E_GrpLenEncoding groupLength = EGL_recalcGL, 208 const E_PaddingEncoding padEncoding = EPD_noChange, 209 const Uint32 padLength = 0, 210 const Uint32 subPadLength = 0); 211 212 // methods for different pixel representations 213 214 // choose Representation changes the representation of 215 // PixelData Elements in the data set to the given representation 216 // If the representation does not exists it creates one. 217 OFCondition chooseRepresentation(const E_TransferSyntax repType, 218 const DcmRepresentationParameter *repParam); 219 220 // checks if all PixelData elements have a conforming representation 221 // (for definition of conforming representation see dcpixel.h). 222 // if one PixelData element has no conforming representation 223 // OFFalse is returned. 224 OFBool hasRepresentation(const E_TransferSyntax repType, 225 const DcmRepresentationParameter *repParam); 226 227 /** removes all but the original representation in all pixel data elements 228 */ 229 void removeAllButOriginalRepresentations(); 230 231 /** removes all but the current representation and sets the original 232 * representation to current 233 */ 234 void removeAllButCurrentRepresentations(); 235 236 237 private: 238 239 /// current transfer syntax of the dataset 240 E_TransferSyntax Xfer; 241 }; 242 243 244 #endif // DCDATSET_H 245