00001 /* 00002 * 00003 * Copyright (C) 1994-2010, OFFIS e.V. 00004 * All rights reserved. See COPYRIGHT file for details. 00005 * 00006 * This software and supporting documentation were developed by 00007 * 00008 * OFFIS e.V. 00009 * R&D Division Health 00010 * Escherweg 2 00011 * D-26121 Oldenburg, Germany 00012 * 00013 * 00014 * Module: dcmdata 00015 * 00016 * Author: Gerd Ehlers, Andreas Barth 00017 * 00018 * Purpose: Interface of class DcmMetaInfo 00019 * 00020 * Last Update: $Author: joergr $ 00021 * Update Date: $Date: 2010-10-14 13:15:41 $ 00022 * CVS/RCS Revision: $Revision: 1.33 $ 00023 * Status: $State: Exp $ 00024 * 00025 * CVS/RCS Log at end of file 00026 * 00027 */ 00028 00029 00030 #ifndef DCMETINF_H 00031 #define DCMETINF_H 00032 00033 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 00034 00035 #include "dcmtk/dcmdata/dcitem.h" 00036 00037 00039 #define DCM_Magic "DICM" 00040 00042 #define DCM_MagicLen 4 00043 00045 #define DCM_PreambleLen 128 00046 00048 #define META_HEADER_DEFAULT_TRANSFERSYNTAX EXS_LittleEndianExplicit 00049 00050 00053 class DcmMetaInfo 00054 : public DcmItem 00055 { 00056 00057 public: 00058 00061 DcmMetaInfo(); 00062 00066 DcmMetaInfo(const DcmMetaInfo &old); 00067 00071 DcmMetaInfo &operator=(const DcmMetaInfo &obj); 00072 00075 virtual ~DcmMetaInfo(); 00076 00080 virtual DcmObject *clone() const 00081 { 00082 return new DcmMetaInfo(*this); 00083 } 00084 00097 virtual OFCondition copyFrom(const DcmObject& rhs); 00098 00102 virtual DcmEVR ident() const; 00103 00106 virtual void removeInvalidGroups(); 00107 00111 E_TransferSyntax getOriginalXfer() const; 00112 00120 virtual void print(STD_NAMESPACE ostream&out, 00121 const size_t flags = 0, 00122 const int level = 0, 00123 const char *pixelFileName = NULL, 00124 size_t *pixelCounter = NULL); 00125 00129 virtual void transferInit(); 00130 00134 virtual void transferEnd(); 00135 00146 virtual Uint32 calcElementLength(const E_TransferSyntax xfer, 00147 const E_EncodingType enctype); 00148 00158 virtual OFCondition read(DcmInputStream &inStream, 00159 const E_TransferSyntax xfer = EXS_Unknown, 00160 const E_GrpLenEncoding glenc = EGL_noChange, 00161 const Uint32 maxReadLength = DCM_MaxReadLength); 00162 00170 virtual OFCondition write(DcmOutputStream &outStream, 00171 const E_TransferSyntax oxfer, 00172 const E_EncodingType enctype, 00173 DcmWriteCache *wcache); 00174 00180 virtual OFCondition writeXML(STD_NAMESPACE ostream&out, 00181 const size_t flags = 0); 00182 00192 virtual OFCondition loadFile(const char *fileName, 00193 const E_TransferSyntax readXfer = EXS_Unknown, 00194 const E_GrpLenEncoding groupLength = EGL_noChange, 00195 const Uint32 maxReadLength = DCM_MaxReadLength); 00196 00197 00198 private: 00199 00201 void setPreamble(); 00202 00213 OFBool checkAndReadPreamble(DcmInputStream &inStream, 00214 E_TransferSyntax &newxfer); // out 00215 00220 OFBool nextTagIsMeta(DcmInputStream &inStream); 00221 00234 OFCondition readGroupLength(DcmInputStream &inStream, // inout 00235 const E_TransferSyntax xfer, // in 00236 const DcmTagKey &xtag, // in 00237 const E_GrpLenEncoding glenc, // in 00238 Uint32 &headerLen, // out 00239 Uint32 &bytesRead, // out 00240 const Uint32 maxReadLength = DCM_MaxReadLength); // in 00241 00243 char filePreamble[DCM_PreambleLen + DCM_MagicLen]; 00244 00246 OFBool preambleUsed; 00247 00249 E_TransferState fPreambleTransferState; 00250 00252 E_TransferSyntax Xfer; 00253 00254 }; 00255 00256 #endif // DCMETINF_H 00257 00258 /* 00259 ** CVS/RCS Log: 00260 ** $Log: dcmetinf.h,v $ 00261 ** Revision 1.33 2010-10-14 13:15:41 joergr 00262 ** Updated copyright header. Added reference to COPYRIGHT file. 00263 ** 00264 ** Revision 1.32 2010-06-07 13:54:13 joergr 00265 ** Added new method that allows for loading the meta-header only. 00266 ** 00267 ** Revision 1.31 2010-03-01 09:08:44 uli 00268 ** Removed some unnecessary include directives in the headers. 00269 ** 00270 ** Revision 1.30 2010-02-22 11:39:54 uli 00271 ** Remove some unneeded includes. 00272 ** 00273 ** Revision 1.29 2009-08-25 13:00:52 joergr 00274 ** Added new methods which remove all data elements with an invalid group number 00275 ** from the meta information header, dataset and/or fileformat. 00276 ** 00277 ** Revision 1.28 2008-07-17 11:19:48 onken 00278 ** Updated copyFrom() documentation. 00279 ** 00280 ** Revision 1.27 2008-07-17 10:30:23 onken 00281 ** Implemented copyFrom() method for complete DcmObject class hierarchy, which 00282 ** permits setting an instance's value from an existing object. Implemented 00283 ** assignment operator where necessary. 00284 ** 00285 ** Revision 1.26 2008-06-23 12:09:13 joergr 00286 ** Fixed inconsistencies in Doxygen API documentation. 00287 ** 00288 ** Revision 1.25 2007/11/29 14:30:19 meichel 00289 ** Write methods now handle large raw data elements (such as pixel data) 00290 ** without loading everything into memory. This allows very large images to 00291 ** be sent over a network connection, or to be copied without ever being 00292 ** fully in memory. 00293 ** 00294 ** Revision 1.24 2007/02/19 14:57:22 meichel 00295 ** Declaration of copy assignment operator now private, as it should be 00296 ** 00297 ** Revision 1.23 2006/08/15 15:49:56 meichel 00298 ** Updated all code in module dcmdata to correctly compile when 00299 ** all standard C++ classes remain in namespace std. 00300 ** 00301 ** Revision 1.22 2005/12/08 16:28:21 meichel 00302 ** Changed include path schema for all DCMTK header files 00303 ** 00304 ** Revision 1.21 2005/11/07 16:59:24 meichel 00305 ** Cleaned up some copy constructors in the DcmObject hierarchy. 00306 ** 00307 ** Revision 1.20 2004/07/01 12:28:25 meichel 00308 ** Introduced virtual clone method for DcmObject and derived classes. 00309 ** 00310 ** Revision 1.19 2003/03/21 13:06:46 meichel 00311 ** Minor code purifications for warnings reported by MSVC in Level 4 00312 ** 00313 ** Revision 1.18 2002/12/06 12:49:11 joergr 00314 ** Enhanced "print()" function by re-working the implementation and replacing 00315 ** the boolean "showFullData" parameter by a more general integer flag. 00316 ** Added doc++ documentation. 00317 ** Made source code formatting more consistent with other modules/files. 00318 ** 00319 ** Revision 1.17 2002/08/27 16:55:35 meichel 00320 ** Initial release of new DICOM I/O stream classes that add support for stream 00321 ** compression (deflated little endian explicit VR transfer syntax) 00322 ** 00323 ** Revision 1.16 2002/04/25 09:40:56 joergr 00324 ** Added support for XML output of DICOM objects. 00325 ** 00326 ** Revision 1.15 2001/09/25 17:19:27 meichel 00327 ** Adapted dcmdata to class OFCondition 00328 ** 00329 ** Revision 1.14 2001/06/01 15:48:41 meichel 00330 ** Updated copyright header 00331 ** 00332 ** Revision 1.13 2000/04/14 15:31:32 meichel 00333 ** Removed default value from output stream passed to print() method. 00334 ** Required for use in multi-thread environments. 00335 ** 00336 ** Revision 1.12 2000/03/08 16:26:16 meichel 00337 ** Updated copyright header. 00338 ** 00339 ** Revision 1.11 2000/03/03 14:05:24 meichel 00340 ** Implemented library support for redirecting error messages into memory 00341 ** instead of printing them to stdout/stderr for GUI applications. 00342 ** 00343 ** Revision 1.10 2000/02/10 10:50:51 joergr 00344 ** Added new feature to dcmdump (enhanced print method of dcmdata): write 00345 ** pixel data/item value fields to raw files. 00346 ** 00347 ** Revision 1.9 1999/03/31 09:24:41 meichel 00348 ** Updated copyright header in module dcmdata 00349 ** 00350 ** Revision 1.8 1997/09/22 14:56:12 hewett 00351 ** Added a method to retreive the original transfer syntax of a read 00352 ** meta-header (getOriginalXfer). This functionality is needed by 00353 ** the DCMCHECK package. 00354 ** 00355 ** Revision 1.7 1997/07/21 08:25:09 andreas 00356 ** - Replace all boolean types (BOOLEAN, CTNBOOLEAN, DICOM_BOOL, BOOL) 00357 ** with one unique boolean type OFBool. 00358 ** 00359 ** Revision 1.6 1997/05/16 08:23:47 andreas 00360 ** - Revised handling of GroupLength elements and support of 00361 ** DataSetTrailingPadding elements. The enumeratio E_GrpLenEncoding 00362 ** got additional enumeration values (for a description see dctypes.h). 00363 ** addGroupLength and removeGroupLength methods are replaced by 00364 ** computeGroupLengthAndPadding. To support Padding, the parameters of 00365 ** element and sequence write functions changed. 00366 ** - Added a new method calcElementLength to calculate the length of an 00367 ** element, item or sequence. For elements it returns the length of 00368 ** tag, length field, vr field, and value length, for item and 00369 ** sequences it returns the length of the whole item. sequence including 00370 ** the Delimitation tag (if appropriate). It can never return 00371 ** UndefinedLength. 00372 ** 00373 ** Revision 1.5 1996/08/05 08:45:24 andreas 00374 ** new print routine with additional parameters: 00375 ** - print into files 00376 ** - fix output length for elements 00377 ** corrected error in search routine with parameter ESM_fromStackTop 00378 ** 00379 ** Revision 1.4 1996/01/09 11:06:16 andreas 00380 ** New Support for Visual C++ 00381 ** Correct problems with inconsistent const declarations 00382 ** 00383 ** Revision 1.3 1996/01/05 13:22:57 andreas 00384 ** - changed to support new streaming facilities 00385 ** - more cleanups 00386 ** - merged read / write methods for block and file transfer 00387 ** 00388 */