00001 /* 00002 * 00003 * Copyright (C) 1994-2005, OFFIS 00004 * 00005 * This software and supporting documentation were developed by 00006 * 00007 * Kuratorium OFFIS e.V. 00008 * Healthcare Information and Communication Systems 00009 * Escherweg 2 00010 * D-26121 Oldenburg, Germany 00011 * 00012 * THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND OFFIS MAKES NO WARRANTY 00013 * REGARDING THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR 00014 * FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR 00015 * ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND 00016 * PERFORMANCE OF THE SOFTWARE IS WITH THE USER. 00017 * 00018 * Module: dcmdata 00019 * 00020 * Author: Gerd Ehlers, Andreas Barth 00021 * 00022 * Purpose: Interface of class DcmFileFormat 00023 * 00024 * Last Update: $Author: meichel $ 00025 * Update Date: $Date: 2005/12/08 16:28:13 $ 00026 * CVS/RCS Revision: $Revision: 1.25 $ 00027 * Status: $State: Exp $ 00028 * 00029 * CVS/RCS Log at end of file 00030 * 00031 */ 00032 00033 00034 #ifndef DCFILEFO_H 00035 #define DCFILEFO_H 00036 00037 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 00038 00039 #include "dcmtk/ofstd/ofconsol.h" 00040 #include "dcmtk/dcmdata/dctypes.h" 00041 #include "dcmtk/dcmdata/dcerror.h" 00042 #include "dcmtk/dcmdata/dcsequen.h" 00043 #include "dcmtk/dcmdata/dcdatset.h" 00044 00045 00046 // forward declarations 00047 class DcmMetaInfo; 00048 class DcmInputStream; 00049 class DcmOutputStream; 00050 class DcmRepresentationParameter; 00051 00052 00055 class DcmFileFormat 00056 : public DcmSequenceOfItems 00057 { 00058 00059 public: 00060 00063 DcmFileFormat(); 00064 00065 DcmFileFormat(DcmDataset *dataset); 00066 00070 DcmFileFormat(const DcmFileFormat &old); 00071 00074 virtual ~DcmFileFormat(); 00075 00080 DcmFileFormat &operator=(const DcmFileFormat &obj); 00081 00085 virtual DcmObject *clone() const 00086 { 00087 return new DcmFileFormat(*this); 00088 } 00089 00093 virtual DcmEVR ident() const; 00094 00102 virtual void print(ostream &out, 00103 const size_t flags = 0, 00104 const int level = 0, 00105 const char *pixelFileName = NULL, 00106 size_t *pixelCounter = NULL); 00107 00108 virtual OFCondition validateMetaInfo(E_TransferSyntax oxfer); 00109 00110 DcmMetaInfo *getMetaInfo(); 00111 DcmDataset *getDataset(); 00112 DcmDataset *getAndRemoveDataset(); 00113 00114 virtual Uint32 calcElementLength(const E_TransferSyntax xfer, 00115 const E_EncodingType enctype); 00116 00117 virtual OFBool canWriteXfer(const E_TransferSyntax newXfer, 00118 const E_TransferSyntax oldXfer = EXS_Unknown); 00119 00120 virtual OFCondition read(DcmInputStream &inStream, 00121 const E_TransferSyntax xfer = EXS_Unknown, 00122 const E_GrpLenEncoding glenc = EGL_noChange, 00123 const Uint32 maxReadLength = DCM_MaxReadLength); 00124 00131 virtual OFCondition write(DcmOutputStream &outStream, 00132 const E_TransferSyntax oxfer, 00133 const E_EncodingType enctype = EET_UndefinedLength); 00134 00135 virtual OFCondition write(DcmOutputStream &outStream, 00136 const E_TransferSyntax oxfer, 00137 const E_EncodingType enctype, 00138 const E_GrpLenEncoding glenc, 00139 const E_PaddingEncoding padenc = EPD_noChange, 00140 const Uint32 padlen = 0, 00141 const Uint32 subPadlen = 0, 00142 Uint32 instanceLength = 0); 00143 00150 virtual OFCondition writeXML(ostream &out, 00151 const size_t flags = 0); 00152 00167 virtual OFCondition loadFile(const char *fileName, 00168 const E_TransferSyntax readXfer = EXS_Unknown, 00169 const E_GrpLenEncoding groupLength = EGL_noChange, 00170 const Uint32 maxReadLength = DCM_MaxReadLength, 00171 const E_FileReadMode readMode = ERM_autoDetect); 00172 00184 virtual OFCondition saveFile(const char *fileName, 00185 const E_TransferSyntax writeXfer = EXS_Unknown, 00186 const E_EncodingType encodingType = EET_UndefinedLength, 00187 const E_GrpLenEncoding groupLength = EGL_recalcGL, 00188 const E_PaddingEncoding padEncoding = EPD_noChange, 00189 const Uint32 padLength = 0, 00190 const Uint32 subPadLength = 0, 00191 const OFBool isDataset = OFFalse); 00192 00193 // methods for different pixel representations 00194 00195 // choose Representation changes the representation of 00196 // PixelData Elements in the data set to the given representation 00197 // If the representation does not exists it creates one. 00198 OFCondition chooseRepresentation(const E_TransferSyntax repType, 00199 const DcmRepresentationParameter *repParam) 00200 { 00201 return getDataset()->chooseRepresentation(repType, repParam); 00202 } 00203 00204 // checks if all PixelData elements have a conforming representation 00205 // (for definition of conforming representation see dcpixel.h). 00206 // if one PixelData element has no conforming representation 00207 // OFFalse is returned. 00208 OFBool hasRepresentation(const E_TransferSyntax repType, 00209 const DcmRepresentationParameter *repParam) 00210 { 00211 return getDataset()->hasRepresentation(repType, repParam); 00212 } 00213 00216 void removeAllButOriginalRepresentations() 00217 { 00218 getDataset()->removeAllButOriginalRepresentations(); 00219 } 00220 00224 void removeAllButCurrentRepresentations() 00225 { 00226 getDataset()->removeAllButCurrentRepresentations(); 00227 } 00228 00234 E_FileReadMode getReadMode() const 00235 { 00236 return FileReadMode; 00237 } 00238 00244 void setReadMode(const E_FileReadMode readMode) 00245 { 00246 FileReadMode = readMode; 00247 } 00248 00249 // The following methods have no meaning in DcmFileFormat and shall not be 00250 // called. Since it is not possible to delete inherited methods from a class 00251 // stubs are defined that create an error. 00252 00253 virtual OFCondition insertItem(DcmItem *item, 00254 const unsigned long where = DCM_EndOfListIndex); 00255 virtual DcmItem *remove(const unsigned long num); 00256 virtual DcmItem *remove(DcmItem *item); 00257 virtual OFCondition clear(); 00258 00259 00260 private: 00261 00262 OFCondition checkValue(DcmMetaInfo *metainfo, 00263 DcmDataset *dataset, 00264 const DcmTagKey &atagkey, 00265 DcmObject *obj, 00266 const E_TransferSyntax oxfer); 00267 00268 E_TransferSyntax lookForXfer(DcmMetaInfo *metainfo); 00269 00271 E_FileReadMode FileReadMode; 00272 }; 00273 00274 00275 #endif // DCFILEFO_H 00276 00277 00278 /* 00279 ** CVS/RCS Log: 00280 ** $Log: dcfilefo.h,v $ 00281 ** Revision 1.25 2005/12/08 16:28:13 meichel 00282 ** Changed include path schema for all DCMTK header files 00283 ** 00284 ** Revision 1.24 2005/12/02 08:48:17 joergr 00285 ** Added new file read mode that makes it possible to distinguish between DICOM 00286 ** files, datasets and other non-DICOM files. For this reason, the last 00287 ** parameter of method loadFile() changed from OFBool to E_FileReadMode. 00288 ** 00289 ** Revision 1.23 2004/07/01 12:28:25 meichel 00290 ** Introduced virtual clone method for DcmObject and derived classes. 00291 ** 00292 ** Revision 1.22 2002/12/06 12:49:10 joergr 00293 ** Enhanced "print()" function by re-working the implementation and replacing 00294 ** the boolean "showFullData" parameter by a more general integer flag. 00295 ** Added doc++ documentation. 00296 ** Made source code formatting more consistent with other modules/files. 00297 ** 00298 ** Revision 1.21 2002/08/27 16:55:32 meichel 00299 ** Initial release of new DICOM I/O stream classes that add support for stream 00300 ** compression (deflated little endian explicit VR transfer syntax) 00301 ** 00302 ** Revision 1.20 2002/08/20 12:18:35 meichel 00303 ** Changed parameter list of loadFile and saveFile methods in class 00304 ** DcmFileFormat. Removed loadFile and saveFile from class DcmObject. 00305 ** 00306 ** Revision 1.19 2002/04/25 09:39:47 joergr 00307 ** Added support for XML output of DICOM objects. 00308 ** 00309 ** Revision 1.18 2002/04/11 12:22:51 joergr 00310 ** Added new methods for loading and saving DICOM files. 00311 ** 00312 ** Revision 1.17 2001/09/25 17:19:26 meichel 00313 ** Adapted dcmdata to class OFCondition 00314 ** 00315 ** Revision 1.16 2001/06/01 15:48:40 meichel 00316 ** Updated copyright header 00317 ** 00318 ** Revision 1.15 2000/04/14 15:31:32 meichel 00319 ** Removed default value from output stream passed to print() method. 00320 ** Required for use in multi-thread environments. 00321 ** 00322 ** Revision 1.14 2000/03/08 16:26:14 meichel 00323 ** Updated copyright header. 00324 ** 00325 ** Revision 1.13 2000/03/03 14:05:23 meichel 00326 ** Implemented library support for redirecting error messages into memory 00327 ** instead of printing them to stdout/stderr for GUI applications. 00328 ** 00329 ** Revision 1.12 2000/02/10 10:50:51 joergr 00330 ** Added new feature to dcmdump (enhanced print method of dcmdata): write 00331 ** pixel data/item value fields to raw files. 00332 ** 00333 ** Revision 1.11 1999/03/31 09:24:38 meichel 00334 ** Updated copyright header in module dcmdata 00335 ** 00336 ** Revision 1.10 1998/11/12 16:47:39 meichel 00337 ** Implemented operator= for all classes derived from DcmObject. 00338 ** 00339 ** Revision 1.9 1997/07/21 08:14:39 andreas 00340 ** - New environment for encapsulated pixel representations. DcmPixelData 00341 ** can contain different representations and uses codecs to convert 00342 ** between them. Codecs are derived from the DcmCodec class. New error 00343 ** codes are introduced for handling of representations. New internal 00344 ** value representation (only for ident()) for PixelData 00345 ** - Replace all boolean types (BOOLEAN, CTNBOOLEAN, DICOM_BOOL, BOOL) 00346 ** with one unique boolean type OFBool. 00347 ** 00348 ** Revision 1.8 1997/05/27 13:48:27 andreas 00349 ** - Add method canWriteXfer to class DcmObject and all derived classes. 00350 ** This method checks whether it is possible to convert the original 00351 ** transfer syntax to an new transfer syntax. The check is used in the 00352 ** dcmconv utility to prohibit the change of a compressed transfer 00353 ** syntax to a uncompressed. 00354 ** 00355 ** Revision 1.7 1997/05/16 08:23:47 andreas 00356 ** - Revised handling of GroupLength elements and support of 00357 ** DataSetTrailingPadding elements. The enumeratio E_GrpLenEncoding 00358 ** got additional enumeration values (for a description see dctypes.h). 00359 ** addGroupLength and removeGroupLength methods are replaced by 00360 ** computeGroupLengthAndPadding. To support Padding, the parameters of 00361 ** element and sequence write functions changed. 00362 ** - Added a new method calcElementLength to calculate the length of an 00363 ** element, item or sequence. For elements it returns the length of 00364 ** tag, length field, vr field, and value length, for item and 00365 ** sequences it returns the length of the whole item. sequence including 00366 ** the Delimitation tag (if appropriate). It can never return 00367 ** UndefinedLength. 00368 ** 00369 ** Revision 1.6 1996/08/05 08:45:21 andreas 00370 ** new print routine with additional parameters: 00371 ** - print into files 00372 ** - fix output length for elements 00373 ** corrected error in search routine with parameter ESM_fromStackTop 00374 ** 00375 ** Revision 1.5 1996/07/29 15:46:23 andreas 00376 ** Add method getAndRemoveDataset to remove connection of dataset from fileformat 00377 ** 00378 ** Revision 1.4 1996/01/09 11:06:15 andreas 00379 ** New Support for Visual C++ 00380 ** Correct problems with inconsistent const declarations 00381 ** 00382 ** Revision 1.3 1996/01/05 13:22:55 andreas 00383 ** - changed to support new streaming facilities 00384 ** - more cleanups 00385 ** - merged read / write methods for block and file transfer 00386 ** 00387 */