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 DcmDicomDir 00019 * 00020 * Last Update: $Author: uli $ 00021 * Update Date: $Date: 2010-11-15 13:58:43 $ 00022 * CVS/RCS Revision: $Revision: 1.28 $ 00023 * Status: $State: Exp $ 00024 * 00025 * CVS/RCS Log at end of file 00026 * 00027 */ 00028 00029 #ifndef DCDICDIR_H 00030 #define DCDICDIR_H 00031 00032 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 00033 00034 #include "dcmtk/dcmdata/dcdirrec.h" 00035 #include "dcmtk/dcmdata/dcvrulup.h" 00036 00037 00038 #define DEFAULT_DICOMDIR_NAME "DICOMDIR" 00039 #define TEMPNAME_TEMPLATE "DDXXXXXX" 00040 #define DICOMDIR_BACKUP_SUFFIX ".$$$" 00041 #define DICOMDIR_DEFAULT_TRANSFERSYNTAX EXS_LittleEndianExplicit 00042 00045 typedef struct 00046 { 00048 DcmItem *item; 00050 Uint32 fileOffset; 00051 } ItemOffset; 00052 00053 00058 class DcmDicomDir 00059 { 00060 public: 00062 DcmDicomDir(); 00063 00069 DcmDicomDir( const char *fileName, 00070 const char *fileSetID = NULL ); // only used for new DICOMDIR 00071 00073 virtual ~DcmDicomDir(); 00074 00082 virtual void print(STD_NAMESPACE ostream&out, 00083 const size_t flags = 0, 00084 const int level = 0, 00085 const char *pixelFileName = NULL, 00086 size_t *pixelCounter = NULL); 00087 00089 virtual OFCondition error(); 00090 00095 virtual DcmFileFormat& getDirFileFormat(); 00096 00100 virtual const char* getDirFileName(); 00101 00103 virtual DcmDirectoryRecord& getRootRecord(); 00104 00106 virtual DcmSequenceOfItems& getMRDRSequence(); 00107 00111 virtual DcmDirectoryRecord* matchFilename( const char *filename ); 00112 00117 virtual DcmDirectoryRecord* matchOrCreateMRDR( const char *filename ); 00118 00125 virtual OFCondition write( 00126 const E_TransferSyntax oxfer = DICOMDIR_DEFAULT_TRANSFERSYNTAX, 00127 const E_EncodingType enctype = EET_UndefinedLength, 00128 const E_GrpLenEncoding glenc = EGL_withoutGL ); 00129 00134 virtual OFCondition verify( OFBool autocorrect = OFFalse ); 00135 00136 protected: 00137 00138 // Manipulation of member variables 00139 OFCondition createNewElements(const char* fileSetID); // in 00140 DcmDataset& getDataset(void); 00141 00142 // side-effect free methods for manipulation and conversion 00143 DcmSequenceOfItems& getDirRecSeq( DcmDataset &dset ); // inout 00144 DcmUnsignedLongOffset* lookForOffsetElem( DcmObject *obj, // in 00145 const DcmTagKey &offsetTag ); // in 00146 DcmDirectoryRecord* recurseMatchFile( DcmDirectoryRecord* startRec, // in 00147 const char *filename ); // in 00148 DcmDirectoryRecord* searchMatchFile( DcmSequenceOfItems& recSeq, // in 00149 const char *filename ); // in 00150 OFCondition resolveGivenOffsets( DcmObject *startPoint, // inout 00151 ItemOffset *itOffsets, // in 00152 const unsigned long numOffsets, // in 00153 const DcmTagKey &offsetTag ); // in 00154 OFCondition resolveAllOffsets( DcmDataset &dset ); // inout 00155 OFCondition linkMRDRtoRecord( DcmDirectoryRecord *dRec ); // inout 00156 OFCondition moveRecordToTree( DcmDirectoryRecord *startRec, // in 00157 DcmSequenceOfItems &fromDirSQ, // inout 00158 DcmDirectoryRecord *toRecord ); // inout 00159 OFCondition moveMRDRbetweenSQs( DcmSequenceOfItems &fromSQ, // in 00160 DcmSequenceOfItems &toDirSQ ); // inout 00161 Uint32 lengthUntilSQ( DcmDataset &dset, // in 00162 E_TransferSyntax oxfer, // in 00163 E_EncodingType enctype ); // in 00164 Uint32 lengthOfRecord( DcmItem *item, // in 00165 E_TransferSyntax oxfer, // in 00166 E_EncodingType enctype ); // in 00167 OFCondition convertGivenPointer( DcmObject *startPoint, // inout 00168 ItemOffset *itOffsets, // in 00169 const unsigned long numOffsets, // in 00170 const DcmTagKey &offsetTag ); // in 00171 OFCondition convertAllPointer( DcmDataset &dset, // inout 00172 Uint32 beginOfFileSet, // in 00173 E_TransferSyntax oxfer, // in 00174 E_EncodingType enctype ); // in 00175 OFCondition copyRecordPtrToSQ( DcmDirectoryRecord *record, // in 00176 DcmSequenceOfItems &toDirSQ, // inout 00177 DcmDirectoryRecord **firstRec, // out 00178 DcmDirectoryRecord **lastRec ); // out 00179 OFCondition insertMediaSOPUID( DcmMetaInfo &metaInfo ); // inout 00180 OFCondition countMRDRRefs( DcmDirectoryRecord *startRec, // in 00181 ItemOffset *refCounter, // inout 00182 const unsigned long numCounters ); // in 00183 OFCondition checkMRDRRefCounter( DcmDirectoryRecord *startRec, // in 00184 ItemOffset *refCounter, // inout 00185 const unsigned long numCounters ); // in 00186 00187 // complete re-organization of the managed directory records (side effect) 00188 OFCondition convertLinearToTree(); 00189 00190 OFCondition convertTreeToLinear( Uint32 beginOfFileSet, // in 00191 E_TransferSyntax oxfer, // in 00192 E_EncodingType enctype, // in 00193 E_GrpLenEncoding glenc, // in 00194 DcmSequenceOfItems &unresRecs);// inout 00195 00196 private: 00197 00199 DcmDicomDir &operator=(const DcmDicomDir &); 00200 00202 DcmDicomDir( const DcmDicomDir &newDir ); 00203 00205 OFCondition errorFlag; 00206 00208 char * dicomDirFileName; 00209 00213 OFBool modified; 00214 00216 OFBool mustCreateNewDir; 00217 00221 DcmFileFormat * DirFile; 00222 00224 DcmDirectoryRecord * RootRec; 00225 00227 DcmSequenceOfItems * MRDRSeq; 00228 }; 00229 00230 #endif // DCDICDIR_H 00231 00232 /* 00233 ** CVS/RCS Log: 00234 ** $Log: dcdicdir.h,v $ 00235 ** Revision 1.28 2010-11-15 13:58:43 uli 00236 ** Fixed some errors in doxygen comments. 00237 ** 00238 ** Revision 1.27 2010-10-14 13:15:40 joergr 00239 ** Updated copyright header. Added reference to COPYRIGHT file. 00240 ** 00241 ** Revision 1.26 2010-08-18 15:13:26 joergr 00242 ** Added const specifier to char pointers where appropriate. Thanks to forum 00243 ** user "takeos" for the report. 00244 ** 00245 ** Revision 1.25 2010-03-01 09:08:44 uli 00246 ** Removed some unnecessary include directives in the headers. 00247 ** 00248 ** Revision 1.24 2010-02-22 11:39:53 uli 00249 ** Remove some unneeded includes. 00250 ** 00251 ** Revision 1.23 2009-11-04 09:58:07 uli 00252 ** Switched to logging mechanism provided by the "new" oflog module 00253 ** 00254 ** Revision 1.22 2007-11-29 14:30:19 meichel 00255 ** Write methods now handle large raw data elements (such as pixel data) 00256 ** without loading everything into memory. This allows very large images to 00257 ** be sent over a network connection, or to be copied without ever being 00258 ** fully in memory. 00259 ** 00260 ** Revision 1.21 2007/06/29 14:17:49 meichel 00261 ** Code clean-up: Most member variables in module dcmdata are now private, 00262 ** not protected anymore. 00263 ** 00264 ** Revision 1.20 2006/08/15 15:49:56 meichel 00265 ** Updated all code in module dcmdata to correctly compile when 00266 ** all standard C++ classes remain in namespace std. 00267 ** 00268 ** Revision 1.19 2005/12/08 16:28:07 meichel 00269 ** Changed include path schema for all DCMTK header files 00270 ** 00271 ** Revision 1.18 2005/11/07 16:59:24 meichel 00272 ** Cleaned up some copy constructors in the DcmObject hierarchy. 00273 ** 00274 ** Revision 1.17 2003/08/14 09:00:56 meichel 00275 ** Adapted type casts to new-style typecast operators defined in ofcast.h 00276 ** 00277 ** Revision 1.16 2002/12/06 12:49:09 joergr 00278 ** Enhanced "print()" function by re-working the implementation and replacing 00279 ** the boolean "showFullData" parameter by a more general integer flag. 00280 ** Added doc++ documentation. 00281 ** Made source code formatting more consistent with other modules/files. 00282 ** 00283 ** Revision 1.15 2001/09/25 17:19:25 meichel 00284 ** Adapted dcmdata to class OFCondition 00285 ** 00286 ** Revision 1.14 2001/06/01 15:48:36 meichel 00287 ** Updated copyright header 00288 ** 00289 ** Revision 1.13 2000/04/14 15:31:31 meichel 00290 ** Removed default value from output stream passed to print() method. 00291 ** Required for use in multi-thread environments. 00292 ** 00293 ** Revision 1.12 2000/03/08 16:26:12 meichel 00294 ** Updated copyright header. 00295 ** 00296 ** Revision 1.11 2000/03/03 14:05:23 meichel 00297 ** Implemented library support for redirecting error messages into memory 00298 ** instead of printing them to stdout/stderr for GUI applications. 00299 ** 00300 ** Revision 1.10 2000/02/10 10:50:50 joergr 00301 ** Added new feature to dcmdump (enhanced print method of dcmdata): write 00302 ** pixel data/item value fields to raw files. 00303 ** 00304 ** Revision 1.9 1999/03/31 09:24:34 meichel 00305 ** Updated copyright header in module dcmdata 00306 ** 00307 ** Revision 1.8 1998/07/15 15:48:44 joergr 00308 ** Removed several compiler warnings reported by gcc 2.8.1 with 00309 ** additional options, e.g. missing copy constructors and assignment 00310 ** operators, initialization of member variables in the body of a 00311 ** constructor instead of the member initialization list, hiding of 00312 ** methods by use of identical names, uninitialized member variables, 00313 ** missing const declaration of char pointers. Replaced tabs by spaces. 00314 ** 00315 ** Revision 1.7 1997/09/11 15:02:16 hewett 00316 ** Changed DcmDicomDir constructor to take const char* arguments. 00317 ** 00318 ** Revision 1.6 1997/07/21 08:25:06 andreas 00319 ** - Replace all boolean types (BOOLEAN, CTNBOOLEAN, DICOM_BOOL, BOOL) 00320 ** with one unique boolean type OFBool. 00321 ** 00322 ** Revision 1.5 1997/05/16 08:31:19 andreas 00323 ** - Revised handling of GroupLength elements and support of 00324 ** DataSetTrailingPadding elements. The enumeratio E_GrpLenEncoding 00325 ** got additional enumeration values (for a description see dctypes.h). 00326 ** addGroupLength and removeGroupLength methods are replaced by 00327 ** computeGroupLengthAndPadding. To support Padding, the parameters of 00328 ** element and sequence write functions changed. 00329 ** 00330 ** Revision 1.4 1997/04/24 12:08:28 hewett 00331 ** Fixed DICOMDIR generation bug affecting inclusion of Group Length 00332 ** attributes (file offsets were not being computed correctly). 00333 ** 00334 ** Revision 1.3 1996/08/05 08:45:18 andreas 00335 ** new print routine with additional parameters: 00336 ** - print into files 00337 ** - fix output length for elements 00338 ** corrected error in search routine with parameter ESM_fromStackTop 00339 ** 00340 ** Revision 1.2 1996/01/05 13:22:54 andreas 00341 ** - changed to support new streaming facilities 00342 ** - more cleanups 00343 ** - merged read / write methods for block and file transfer 00344 ** 00345 */ 00346