00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef DCDDIRIF_H
00035 #define DCDDIRIF_H
00036
00037 #include "osconfig.h"
00038
00039 #include "dcdicdir.h"
00040
00041
00042
00043
00044
00045
00046
00047 #define DEFAULT_FILESETID "DCMTK_MEDIA_DEMO"
00048
00049 #define DEFAULT_DESCRIPTOR_CHARSET "ISO_IR 100"
00050
00051
00052
00053
00054
00055
00061 class DicomDirImagePlugin
00062 {
00063 public:
00064
00067 virtual ~DicomDirImagePlugin() {}
00068
00079 virtual OFBool scaleData(const Uint8 *srcData,
00080 const unsigned int srcWidth,
00081 const unsigned int srcHeight,
00082 Uint8 *dstData,
00083 const unsigned int dstWidth,
00084 const unsigned int dstHeight) const = 0;
00085
00096 virtual OFBool scaleImage(DcmItem *dataset,
00097 Uint8 *pixel,
00098 const unsigned long count,
00099 const unsigned long frame,
00100 const unsigned int width,
00101 const unsigned int height) const = 0;
00102
00103 protected:
00104
00107 DicomDirImagePlugin() {}
00108 };
00109
00110
00113 class DicomDirInterface
00114 {
00115
00116 public:
00117
00120 enum E_ApplicationProfile
00121 {
00123 AP_None,
00125 AP_GeneralPurpose,
00127 AP_Default = AP_GeneralPurpose,
00129 AP_BasicCardiac,
00131 AP_XrayAngiographic,
00133 AP_CTandMR,
00135 AP_UltrasoundIDSF,
00137 AP_UltrasoundSCSF,
00139 AP_UltrasoundCCSF,
00141 AP_UltrasoundIDMF,
00143 AP_UltrasoundSCMF,
00145 AP_UltrasoundCCMF,
00147 AP_TwelveLeadECG,
00149 AP_HemodynamicWaveform
00150 };
00151
00156 DicomDirInterface();
00157
00161 virtual ~DicomDirInterface();
00162
00166 void cleanup();
00167
00172 OFBool isDicomDirValid() const;
00173
00185 OFCondition createNewDicomDir(const E_ApplicationProfile profile = AP_GeneralPurpose,
00186 const char *filename = DEFAULT_DICOMDIR_NAME,
00187 const char *filesetID = DEFAULT_FILESETID);
00188
00200 OFCondition appendToDicomDir(const E_ApplicationProfile profile,
00201 const char *filename);
00202
00209 OFCondition writeDicomDir(const E_EncodingType encodingType = EET_UndefinedLength,
00210 const E_GrpLenEncoding groupLength = EGL_withoutGL);
00211
00221 OFBool isFilenameValid(const char *filename,
00222 const OFBool allowEmpty = OFFalse);
00223
00231 OFBool isCharsetValid(const char *charset);
00232
00243 OFCondition checkDicomFile(const char *filename,
00244 const char *directory = NULL);
00245
00255 OFCondition addDicomFile(const char *filename,
00256 const char *directory = NULL);
00257
00267 OFCondition setFilesetDescriptor(const char *filename,
00268 const char *charset = DEFAULT_DESCRIPTOR_CHARSET);
00269
00276 OFCondition setIconSize(const unsigned int size);
00277
00286 OFCondition setIconPrefix(const char *prefix);
00287
00295 OFCondition setDefaultIcon(const char *filename);
00296
00300 OFBool verboseMode() const
00301 {
00302 return VerboseMode;
00303 }
00304
00309 OFBool abortMode() const
00310 {
00311 return AbortMode;
00312 }
00313
00318 OFBool mapFilenamesMode() const
00319 {
00320 return MapFilenamesMode;
00321 }
00322
00327 OFBool inventMode() const
00328 {
00329 return InventMode;
00330 }
00331
00336 OFBool inventPatientIDMode() const
00337 {
00338 return InventPatientIDMode;
00339 }
00340
00345 OFBool iconImageMode() const
00346 {
00347 return IconImageMode;
00348 }
00349
00354 OFBool backupMode() const
00355 {
00356 return BackupMode;
00357 }
00358
00363 OFBool resolutionCheck() const
00364 {
00365 return ResolutionCheck;
00366 }
00367
00372 OFBool consistencyCheck() const
00373 {
00374 return ConsistencyCheck;
00375 }
00376
00384 OFBool enableVerboseMode(const OFBool newMode = OFTrue);
00385
00393 OFBool enableAbortMode(const OFBool newMode = OFTrue);
00394
00402 OFBool enableMapFilenamesMode(const OFBool newMode = OFTrue);
00403
00411 OFBool enableInventMode(const OFBool newMode = OFTrue);
00412
00421 OFBool enableInventPatientIDMode(const OFBool newMode = OFTrue);
00422
00432 OFBool enableIconImageMode(const OFBool newMode = OFTrue);
00433
00442 OFBool disableBackupMode(const OFBool newMode = OFFalse);
00443
00453 OFBool disableResolutionCheck(const OFBool newMode = OFFalse);
00454
00463 OFBool disableConsistencyCheck(const OFBool newMode = OFFalse);
00464
00471 OFBool addImageSupport(DicomDirImagePlugin *plugin);
00472
00477 void setLogStream(OFConsole *stream);
00478
00479
00480
00485 static const char *getProfileName(const E_ApplicationProfile profile);
00486
00487
00488 protected:
00489
00494 OFCondition selectApplicationProfile(const E_ApplicationProfile profile);
00495
00502 OFCondition loadAndCheckDicomFile(const char *filename,
00503 const char *directory,
00504 DcmFileFormat &fileformat);
00505
00512 OFCondition checkSOPClassAndXfer(DcmMetaInfo *metainfo,
00513 DcmItem *dataset,
00514 const char *filename);
00515
00521 OFCondition checkBasicCardiacAttributes(DcmItem *dataset,
00522 const char *filename);
00523
00530 OFCondition checkXrayAngiographicAttributes(DcmItem *dataset,
00531 const OFString &sopClass,
00532 const char *filename);
00533
00540 OFCondition checkCTandMRAttributes(DcmItem *dataset,
00541 const OFString &sopClass,
00542 const char *filename);
00543
00550 OFCondition checkUltrasoundAttributes(DcmItem *dataset,
00551 const OFString &transferSyntax,
00552 const char *filename);
00553
00560 OFCondition checkMandatoryAttributes(DcmMetaInfo *metainfo,
00561 DcmItem *dataset,
00562 const char *filename);
00563
00573 OFBool recordMatchesDataset(DcmDirectoryRecord *record,
00574 DcmItem *dataset);
00575
00582 DcmDirectoryRecord *findExistingRecord(DcmDirectoryRecord *parent,
00583 const E_DirRecType recordType,
00584 DcmItem* dataset);
00585
00591 DcmDirectoryRecord *buildPatientRecord(DcmItem *dataset,
00592 const OFString &sourceFilename);
00593
00599 DcmDirectoryRecord *buildStudyRecord(DcmItem *dataset,
00600 const OFString &sourceFilename);
00601
00607 DcmDirectoryRecord *buildSeriesRecord(DcmItem *dataset,
00608 const OFString &sourceFilename);
00609
00616 DcmDirectoryRecord *buildOverlayRecord(DcmItem *dataset,
00617 const OFString &referencedFileID,
00618 const OFString &sourceFilename);
00619
00626 DcmDirectoryRecord *buildModalityLutRecord(DcmItem *dataset,
00627 const OFString &referencedFileID,
00628 const OFString &sourceFilename);
00629
00636 DcmDirectoryRecord *buildVoiLutRecord(DcmItem *dataset,
00637 const OFString &referencedFileID,
00638 const OFString &sourceFilename);
00639
00646 DcmDirectoryRecord *buildCurveRecord(DcmItem *dataset,
00647 const OFString &referencedFileID,
00648 const OFString &sourceFilename);
00649
00656 DcmDirectoryRecord *buildStructReportRecord(DcmItem *dataset,
00657 const OFString &referencedFileID,
00658 const OFString &sourceFilename);
00659
00666 DcmDirectoryRecord *buildPresentationRecord(DcmItem *dataset,
00667 const OFString &referencedFileID,
00668 const OFString &sourceFilename);
00669
00676 DcmDirectoryRecord *buildWaveformRecord(DcmItem *dataset,
00677 const OFString &referencedFileID,
00678 const OFString &sourceFilename);
00679
00686 DcmDirectoryRecord *buildRTDoseRecord(DcmItem *dataset,
00687 const OFString &referencedFileID,
00688 const OFString &sourceFilename);
00689
00696 DcmDirectoryRecord *buildRTStructureSetRecord(DcmItem *dataset,
00697 const OFString &referencedFileID,
00698 const OFString &sourceFilename);
00699
00706 DcmDirectoryRecord *buildRTPlanRecord(DcmItem *dataset,
00707 const OFString &referencedFileID,
00708 const OFString &sourceFilename);
00709
00716 DcmDirectoryRecord *buildRTTreatmentRecord(DcmItem *dataset,
00717 const OFString &referencedFileID,
00718 const OFString &sourceFilename);
00719
00726 DcmDirectoryRecord *buildStoredPrintRecord(DcmItem *dataset,
00727 const OFString &referencedFileID,
00728 const OFString &sourceFilename);
00729
00736 DcmDirectoryRecord *buildKeyObjectDocRecord(DcmItem *dataset,
00737 const OFString &referencedFileID,
00738 const OFString &sourceFilename);
00739
00746 DcmDirectoryRecord *buildRegistrationRecord(DcmItem *dataset,
00747 const OFString &referencedFileID,
00748 const OFString &sourceFilename);
00749
00756 DcmDirectoryRecord *buildFiducialRecord(DcmItem *dataset,
00757 const OFString &referencedFileID,
00758 const OFString &sourceFilename);
00759
00766 DcmDirectoryRecord *buildRawDataRecord(DcmItem *dataset,
00767 const OFString &referencedFileID,
00768 const OFString &sourceFilename);
00769
00776 DcmDirectoryRecord *buildSpectroscopyRecord(DcmItem *dataset,
00777 const OFString &referencedFileID,
00778 const OFString &sourceFilename);
00779
00786 DcmDirectoryRecord *buildImageRecord(DcmItem *dataset,
00787 const OFString &referencedFileID,
00788 const OFString &sourceFilename);
00789
00800 OFBool getIconFromFile(const OFString &filename,
00801 Uint8 *pixel,
00802 const unsigned long count,
00803 const unsigned int width,
00804 const unsigned int height);
00805
00815 OFBool getIconFromDataset(DcmItem *dataset,
00816 Uint8 *pixel,
00817 const unsigned long count,
00818 const unsigned int width,
00819 const unsigned int height);
00820
00831 OFCondition addIconImage(DcmDirectoryRecord *record,
00832 DcmItem *dataset,
00833 const unsigned int size,
00834 const OFString &sourceFilename);
00835
00845 DcmDirectoryRecord *addRecord(DcmDirectoryRecord *parent,
00846 const E_DirRecType recordType,
00847 DcmItem *dataset,
00848 const OFString &referencedFileID,
00849 const OFString &sourceFilename);
00850
00856 void inventMissingAttributes(DcmDirectoryRecord *parent,
00857 const OFBool recurse = OFTrue);
00858
00862 void inventMissingStudyLevelAttributes(DcmDirectoryRecord *parent);
00863
00867 void inventMissingSeriesLevelAttributes(DcmDirectoryRecord *parent);
00868
00872 void inventMissingInstanceLevelAttributes(DcmDirectoryRecord *parent);
00873
00877 void createDicomDirBackup(const char *filename);
00878
00881 void deleteDicomDirBackup();
00882
00887 void printMessage(const char *message,
00888 const char *suffix = NULL);
00889
00895 void printWarningMessage(const char *message,
00896 const char *suffix = NULL);
00897
00903 void printErrorMessage(const char *message,
00904 const char *suffix = NULL);
00905
00913 void printUnexpectedValueMessage(const DcmTagKey &key,
00914 const char *filename = NULL,
00915 const OFBool errorMsg = OFTrue);
00916
00924 void printRequiredAttributeMessage(const DcmTagKey &key,
00925 const char *filename = NULL,
00926 const OFBool emptyMsg = OFFalse);
00927
00935 void printAttributeErrorMessage(const DcmTagKey &key,
00936 const OFCondition &error,
00937 const char *operation);
00938
00946 void printRecordErrorMessage(const OFCondition &error,
00947 const E_DirRecType recordType,
00948 const char *operation);
00949
00956 void printFileErrorMessage(const OFCondition &error,
00957 const char *operation,
00958 const char *filename);
00959
00965 OFBool copyFile(const char *fromFilename,
00966 const char *toFilename);
00967
00975 OFBool warnAboutInconsistantAttributes(DcmDirectoryRecord *record,
00976 DcmItem *dataset,
00977 const OFString &sourceFilename,
00978 const OFBool abortCheck = OFFalse);
00979
00984 OFBool checkFilesetID(const OFString &filesetID);
00985
00992 OFBool checkExists(DcmItem *dataset,
00993 const DcmTagKey &key,
00994 const char *filename = NULL);
00995
01002 OFBool checkExistsWithValue(DcmItem *dataset,
01003 const DcmTagKey &key,
01004 const char *filename = NULL);
01005
01013 OFBool checkExistsWithStringValue(DcmItem *dataset,
01014 const DcmTagKey &key,
01015 const OFString &value,
01016 const char *filename = NULL);
01017
01025 OFBool checkExistsWithIntegerValue(DcmItem *dataset,
01026 const DcmTagKey &key,
01027 const long value,
01028 const char *filename = NULL);
01029
01039 OFBool checkExistsWithMinMaxValue(DcmItem *dataset,
01040 const DcmTagKey &key,
01041 const long min,
01042 const long max,
01043 const char *filename = NULL,
01044 const OFBool reject = OFTrue);
01045
01053 OFString &getStringFromDataset(DcmItem *dataset,
01054 const DcmTagKey &key,
01055 OFString &result,
01056 OFBool searchIntoSub = OFFalse);
01057
01065 OFString &getStringFromFile(const char *filename,
01066 const DcmTagKey &key,
01067 OFString &result,
01068 OFBool searchIntoSub = OFFalse);
01069
01076 void copyElement(DcmItem *dataset,
01077 const DcmTagKey &key,
01078 DcmDirectoryRecord *record,
01079 const OFBool optional = OFFalse);
01080
01089 void copyStringWithDefault(DcmItem *dataset,
01090 const DcmTagKey &key,
01091 DcmDirectoryRecord *record,
01092 const char *defaultValue = "",
01093 const OFBool printWarning = OFFalse);
01094
01102 OFBool compareStringAttributes(DcmItem *dataset,
01103 DcmTagKey &key,
01104 DcmDirectoryRecord *record,
01105 const OFString &sourceFilename);
01106
01114 OFBool compareSequenceAttributes(DcmItem *dataset,
01115 DcmTagKey &key,
01116 DcmDirectoryRecord *record,
01117 const OFString &sourceFilename);
01118
01125 void setDefaultValue(DcmDirectoryRecord *record,
01126 const DcmTagKey &key,
01127 const unsigned long number,
01128 const char *prefix = NULL);
01129
01130
01131 private:
01132
01134 OFConsole *LogStream;
01135
01137 DcmDicomDir *DicomDir;
01138
01140 DicomDirImagePlugin *ImagePlugin;
01141
01143 E_ApplicationProfile ApplicationProfile;
01144
01146 OFBool VerboseMode;
01148 OFBool BackupMode;
01150 OFBool AbortMode;
01152 OFBool MapFilenamesMode;
01154 OFBool InventMode;
01156 OFBool InventPatientIDMode;
01158 OFBool ResolutionCheck;
01160 OFBool ConsistencyCheck;
01162 OFBool IconImageMode;
01163
01165 OFString BackupFilename;
01167 OFBool BackupCreated;
01168
01170 unsigned int IconSize;
01172 OFString IconPrefix;
01174 OFString DefaultIcon;
01175
01177 OFBool JPEGSupport;
01179 OFBool RLESupport;
01180
01182 unsigned long AutoPatientNumber;
01184 unsigned long AutoStudyNumber;
01186 unsigned long AutoSeriesNumber;
01188 unsigned long AutoInstanceNumber;
01190 unsigned long AutoOverlayNumber;
01192 unsigned long AutoLutNumber;
01194 unsigned long AutoCurveNumber;
01195
01197 DicomDirInterface(const DicomDirInterface &obj);
01198
01200 DicomDirInterface &operator=(const DicomDirInterface &obj);
01201 };
01202
01203
01204 #endif
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224