dcddirif.h

00001 /*
00002  *
00003  *  Copyright (C) 2002-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:  Joerg Riesmeier
00021  *
00022  *  Purpose: Interface class for simplified creation of a DICOMDIR
00023  *
00024  *  Last Update:      $Author: joergr $
00025  *  Update Date:      $Date: 2005/12/15 15:40:48 $
00026  *  CVS/RCS Revision: $Revision: 1.8 $
00027  *  Status:           $State: Exp $
00028  *
00029  *  CVS/RCS Log at end of file
00030  *
00031  */
00032 
00033 
00034 #ifndef DCDDIRIF_H
00035 #define DCDDIRIF_H
00036 
00037 #include "dcmtk/config/osconfig.h"
00038 
00039 #include "dcmtk/dcmdata/dcdicdir.h"
00040 
00041 
00042 /*-----------------------------------*
00043  *  contant declarations and macros  *
00044  *-----------------------------------*/
00045 
00046 // default fileset ID
00047 #define DEFAULT_FILESETID "DCMTK_MEDIA_DEMO"
00048 // default specific character set of fileset descriptor file
00049 #define DEFAULT_DESCRIPTOR_CHARSET "ISO_IR 100"
00050 
00051 
00052 /*----------------------*
00053  *  class declarations  *
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_GeneralPurpose,
00125         AP_Default = AP_GeneralPurpose,
00127         AP_GeneralPurposeDVD,
00129         AP_GeneralPurposeMIME,
00131         AP_USBandFlash,
00133         AP_MPEG2MPatML,
00135         AP_BasicCardiac,
00137         AP_XrayAngiographic,
00139         AP_XrayAngiographicDVD,
00141         AP_DentalRadiograph,
00143         AP_CTandMR,
00145         AP_UltrasoundIDSF,
00147         AP_UltrasoundSCSF,
00149         AP_UltrasoundCCSF,
00151         AP_UltrasoundIDMF,
00153         AP_UltrasoundSCMF,
00155         AP_UltrasoundCCMF,
00157         AP_TwelveLeadECG,
00159         AP_HemodynamicWaveform
00160     };
00161 
00166     DicomDirInterface();
00167 
00171     virtual ~DicomDirInterface();
00172 
00176     void cleanup();
00177 
00182     OFBool isDicomDirValid() const;
00183 
00195     OFCondition createNewDicomDir(const E_ApplicationProfile profile = AP_GeneralPurpose,
00196                                   const char *filename = DEFAULT_DICOMDIR_NAME,
00197                                   const char *filesetID = DEFAULT_FILESETID);
00198 
00210     OFCondition appendToDicomDir(const E_ApplicationProfile profile,
00211                                  const char *filename);
00212 
00219     OFCondition writeDicomDir(const E_EncodingType encodingType = EET_UndefinedLength,
00220                               const E_GrpLenEncoding groupLength = EGL_withoutGL);
00221 
00231     OFBool isFilenameValid(const char *filename,
00232                            const OFBool allowEmpty = OFFalse);
00233 
00241     OFBool isCharsetValid(const char *charset);
00242 
00253     OFCondition checkDicomFile(const char *filename,
00254                                const char *directory = NULL);
00255 
00265     OFCondition addDicomFile(const char *filename,
00266                              const char *directory = NULL);
00267 
00277     OFCondition setFilesetDescriptor(const char *filename,
00278                                      const char *charset = DEFAULT_DESCRIPTOR_CHARSET);
00279 
00286     OFCondition setIconSize(const unsigned int size);
00287 
00296     OFCondition setIconPrefix(const char *prefix);
00297 
00305     OFCondition setDefaultIcon(const char *filename);
00306 
00310     OFBool verboseMode() const
00311     {
00312         return VerboseMode;
00313     }
00314 
00319     OFBool abortMode() const
00320     {
00321         return AbortMode;
00322     }
00323 
00328     OFBool mapFilenamesMode() const
00329     {
00330         return MapFilenamesMode;
00331     }
00332 
00337     OFBool inventMode() const
00338     {
00339         return InventMode;
00340     }
00341 
00346     OFBool inventPatientIDMode() const
00347     {
00348         return InventPatientIDMode;
00349     }
00350 
00355     OFBool iconImageMode() const
00356     {
00357         return IconImageMode;
00358     }
00359 
00364     OFBool backupMode() const
00365     {
00366         return BackupMode;
00367     }
00368 
00373     OFBool encodingCheck() const
00374     {
00375         return EncodingCheck;
00376     }
00377 
00382     OFBool resolutionCheck() const
00383     {
00384         return ResolutionCheck;
00385     }
00386 
00391     OFBool transferSyntaxCheck() const
00392     {
00393         return TransferSyntaxCheck;
00394     }
00395 
00400     OFBool consistencyCheck() const
00401     {
00402         return ConsistencyCheck;
00403     }
00404 
00412     OFBool enableVerboseMode(const OFBool newMode = OFTrue);
00413 
00421     OFBool enableAbortMode(const OFBool newMode = OFTrue);
00422 
00430     OFBool enableMapFilenamesMode(const OFBool newMode = OFTrue);
00431 
00439     OFBool enableInventMode(const OFBool newMode = OFTrue);
00440 
00449     OFBool enableInventPatientIDMode(const OFBool newMode = OFTrue);
00450 
00460     OFBool enableIconImageMode(const OFBool newMode = OFTrue);
00461 
00470     OFBool disableBackupMode(const OFBool newMode = OFFalse);
00471 
00481     OFBool disableEncodingCheck(const OFBool newMode = OFFalse);
00482 
00492     OFBool disableResolutionCheck(const OFBool newMode = OFFalse);
00493 
00503     OFBool disableTransferSyntaxCheck(const OFBool newMode = OFFalse);
00504 
00513     OFBool disableConsistencyCheck(const OFBool newMode = OFFalse);
00514 
00521     OFBool addImageSupport(DicomDirImagePlugin *plugin);
00522 
00527     void setLogStream(OFConsole *stream);
00528 
00529     /* -- static function -- */
00530 
00535     static const char *getProfileName(const E_ApplicationProfile profile);
00536 
00537 
00538   protected:
00539 
00544     OFCondition selectApplicationProfile(const E_ApplicationProfile profile);
00545 
00552     OFCondition loadAndCheckDicomFile(const char *filename,
00553                                       const char *directory,
00554                                       DcmFileFormat &fileformat);
00555 
00562     OFCondition checkSOPClassAndXfer(DcmMetaInfo *metainfo,
00563                                      DcmItem *dataset,
00564                                      const char *filename);
00565 
00571     OFCondition checkBasicCardiacAttributes(DcmItem *dataset,
00572                                             const char *filename);
00573 
00580     OFCondition checkXrayAngiographicAttributes(DcmItem *dataset,
00581                                                 const OFString &sopClass,
00582                                                 const char *filename);
00583 
00589     OFCondition checkDentalRadiographAttributes(DcmItem *dataset,
00590                                                 const char *filename);
00591 
00598     OFCondition checkCTandMRAttributes(DcmItem *dataset,
00599                                        const OFString &sopClass,
00600                                        const char *filename);
00601 
00608     OFCondition checkUltrasoundAttributes(DcmItem *dataset,
00609                                           const OFString &transferSyntax,
00610                                           const char *filename);
00611 
00618     OFCondition checkMandatoryAttributes(DcmMetaInfo *metainfo,
00619                                          DcmItem *dataset,
00620                                          const char *filename);
00621 
00631     OFBool recordMatchesDataset(DcmDirectoryRecord *record,
00632                                 DcmItem *dataset);
00633 
00640     DcmDirectoryRecord *findExistingRecord(DcmDirectoryRecord *parent,
00641                                            const E_DirRecType recordType,
00642                                            DcmItem* dataset);
00643 
00649     DcmDirectoryRecord *buildPatientRecord(DcmItem *dataset,
00650                                            const OFString &sourceFilename);
00651 
00657     DcmDirectoryRecord *buildStudyRecord(DcmItem *dataset,
00658                                          const OFString &sourceFilename);
00659 
00665     DcmDirectoryRecord *buildSeriesRecord(DcmItem *dataset,
00666                                           const OFString &sourceFilename);
00667 
00674     DcmDirectoryRecord *buildOverlayRecord(DcmItem *dataset,
00675                                            const OFString &referencedFileID,
00676                                            const OFString &sourceFilename);
00677 
00684     DcmDirectoryRecord *buildModalityLutRecord(DcmItem *dataset,
00685                                                const OFString &referencedFileID,
00686                                                const OFString &sourceFilename);
00687 
00694     DcmDirectoryRecord *buildVoiLutRecord(DcmItem *dataset,
00695                                           const OFString &referencedFileID,
00696                                           const OFString &sourceFilename);
00697 
00704     DcmDirectoryRecord *buildCurveRecord(DcmItem *dataset,
00705                                          const OFString &referencedFileID,
00706                                          const OFString &sourceFilename);
00707 
00714     DcmDirectoryRecord *buildStructReportRecord(DcmItem *dataset,
00715                                                 const OFString &referencedFileID,
00716                                                 const OFString &sourceFilename);
00717 
00724     DcmDirectoryRecord *buildPresentationRecord(DcmItem *dataset,
00725                                                 const OFString &referencedFileID,
00726                                                 const OFString &sourceFilename);
00727 
00734     DcmDirectoryRecord *buildWaveformRecord(DcmItem *dataset,
00735                                             const OFString &referencedFileID,
00736                                             const OFString &sourceFilename);
00737 
00744     DcmDirectoryRecord *buildRTDoseRecord(DcmItem *dataset,
00745                                           const OFString &referencedFileID,
00746                                           const OFString &sourceFilename);
00747 
00754     DcmDirectoryRecord *buildRTStructureSetRecord(DcmItem *dataset,
00755                                                   const OFString &referencedFileID,
00756                                                   const OFString &sourceFilename);
00757 
00764     DcmDirectoryRecord *buildRTPlanRecord(DcmItem *dataset,
00765                                           const OFString &referencedFileID,
00766                                           const OFString &sourceFilename);
00767 
00774     DcmDirectoryRecord *buildRTTreatmentRecord(DcmItem *dataset,
00775                                                const OFString &referencedFileID,
00776                                                const OFString &sourceFilename);
00777 
00784     DcmDirectoryRecord *buildStoredPrintRecord(DcmItem *dataset,
00785                                                const OFString &referencedFileID,
00786                                                const OFString &sourceFilename);
00787 
00794     DcmDirectoryRecord *buildKeyObjectDocRecord(DcmItem *dataset,
00795                                                 const OFString &referencedFileID,
00796                                                 const OFString &sourceFilename);
00797 
00804     DcmDirectoryRecord *buildRegistrationRecord(DcmItem *dataset,
00805                                                 const OFString &referencedFileID,
00806                                                 const OFString &sourceFilename);
00807 
00814     DcmDirectoryRecord *buildFiducialRecord(DcmItem *dataset,
00815                                             const OFString &referencedFileID,
00816                                             const OFString &sourceFilename);
00817 
00824     DcmDirectoryRecord *buildRawDataRecord(DcmItem *dataset,
00825                                            const OFString &referencedFileID,
00826                                            const OFString &sourceFilename);
00827 
00834     DcmDirectoryRecord *buildSpectroscopyRecord(DcmItem *dataset,
00835                                                 const OFString &referencedFileID,
00836                                                 const OFString &sourceFilename);
00837 
00844     DcmDirectoryRecord *buildEncapDocRecord(DcmItem *dataset,
00845                                             const OFString &referencedFileID,
00846                                             const OFString &sourceFilename);
00847 
00854     DcmDirectoryRecord *buildValueMapRecord(DcmItem *dataset,
00855                                             const OFString &referencedFileID,
00856                                             const OFString &sourceFilename);
00857 
00864     DcmDirectoryRecord *buildImageRecord(DcmItem *dataset,
00865                                          const OFString &referencedFileID,
00866                                          const OFString &sourceFilename);
00867 
00874     DcmDirectoryRecord *buildHangingProtocolRecord(DcmItem *dataset,
00875                                                    const OFString &referencedFileID,
00876                                                    const OFString &sourceFilename);
00877 
00888     OFBool getIconFromFile(const OFString &filename,
00889                            Uint8 *pixel,
00890                            const unsigned long count,
00891                            const unsigned int width,
00892                            const unsigned int height);
00893 
00903     OFBool getIconFromDataset(DcmItem *dataset,
00904                               Uint8 *pixel,
00905                               const unsigned long count,
00906                               const unsigned int width,
00907                               const unsigned int height);
00908 
00919     OFCondition addIconImage(DcmDirectoryRecord *record,
00920                              DcmItem *dataset,
00921                              const unsigned int size,
00922                              const OFString &sourceFilename);
00923 
00933     DcmDirectoryRecord *addRecord(DcmDirectoryRecord *parent,
00934                                   const E_DirRecType recordType,
00935                                   DcmItem *dataset,
00936                                   const OFString &referencedFileID,
00937                                   const OFString &sourceFilename);
00938 
00944     void inventMissingAttributes(DcmDirectoryRecord *parent,
00945                                  const OFBool recurse = OFTrue);
00946 
00950     void inventMissingStudyLevelAttributes(DcmDirectoryRecord *parent);
00951 
00955     void inventMissingSeriesLevelAttributes(DcmDirectoryRecord *parent);
00956 
00960     void inventMissingInstanceLevelAttributes(DcmDirectoryRecord *parent);
00961 
00965     void createDicomDirBackup(const char *filename);
00966 
00969     void deleteDicomDirBackup();
00970 
00975     void printMessage(const char *message,
00976                       const char *suffix = NULL);
00977 
00983     void printWarningMessage(const char *message,
00984                              const char *suffix = NULL);
00985 
00991     void printErrorMessage(const char *message,
00992                            const char *suffix = NULL);
00993 
01001     void printUnexpectedValueMessage(const DcmTagKey &key,
01002                                      const char *filename = NULL,
01003                                      const OFBool errorMsg = OFTrue);
01004 
01012     void printRequiredAttributeMessage(const DcmTagKey &key,
01013                                        const char *filename = NULL,
01014                                        const OFBool emptyMsg = OFFalse);
01015 
01023     void printAttributeErrorMessage(const DcmTagKey &key,
01024                                     const OFCondition &error,
01025                                     const char *operation);
01026 
01034     void printRecordErrorMessage(const OFCondition &error,
01035                                  const E_DirRecType recordType,
01036                                  const char *operation);
01037 
01044     void printFileErrorMessage(const OFCondition &error,
01045                                const char *operation,
01046                                const char *filename);
01047 
01053     OFBool copyFile(const char *fromFilename,
01054                     const char *toFilename);
01055 
01063     OFBool warnAboutInconsistentAttributes(DcmDirectoryRecord *record,
01064                                            DcmItem *dataset,
01065                                            const OFString &sourceFilename,
01066                                            const OFBool abortCheck = OFFalse);
01067 
01072     OFBool checkFilesetID(const OFString &filesetID);
01073 
01080     OFBool checkExists(DcmItem *dataset,
01081                        const DcmTagKey &key,
01082                        const char *filename = NULL);
01083 
01090     OFBool checkExistsWithValue(DcmItem *dataset,
01091                                 const DcmTagKey &key,
01092                                 const char *filename = NULL);
01093 
01101     OFBool checkExistsWithStringValue(DcmItem *dataset,
01102                                       const DcmTagKey &key,
01103                                       const OFString &value,
01104                                       const char *filename = NULL);
01105 
01114     OFBool checkExistsWithIntegerValue(DcmItem *dataset,
01115                                        const DcmTagKey &key,
01116                                        const long value,
01117                                        const char *filename = NULL,
01118                                        const OFBool reject = OFTrue);
01119 
01129     OFBool checkExistsWithMinMaxValue(DcmItem *dataset,
01130                                       const DcmTagKey &key,
01131                                       const long min,
01132                                       const long max,
01133                                       const char *filename = NULL,
01134                                       const OFBool reject = OFTrue);
01135 
01143     OFString &getStringFromDataset(DcmItem *dataset,
01144                                    const DcmTagKey &key,
01145                                    OFString &result,
01146                                    OFBool searchIntoSub = OFFalse);
01147 
01155     OFString &getStringFromFile(const char *filename,
01156                                 const DcmTagKey &key,
01157                                 OFString &result,
01158                                 OFBool searchIntoSub = OFFalse);
01159 
01167     void copyElement(DcmItem *dataset,
01168                      const DcmTagKey &key,
01169                      DcmDirectoryRecord *record,
01170                      const OFBool optional = OFFalse,
01171                      const OFBool copyEmpty = OFTrue);
01172 
01181     void copyStringWithDefault(DcmItem *dataset,
01182                                const DcmTagKey &key,
01183                                DcmDirectoryRecord *record,
01184                                const char *defaultValue = "",
01185                                const OFBool printWarning = OFFalse);
01186 
01194     OFBool compareStringAttributes(DcmItem *dataset,
01195                                    DcmTagKey &key,
01196                                    DcmDirectoryRecord *record,
01197                                    const OFString &sourceFilename);
01198 
01206     OFBool compareSequenceAttributes(DcmItem *dataset,
01207                                      DcmTagKey &key,
01208                                      DcmDirectoryRecord *record,
01209                                      const OFString &sourceFilename);
01210 
01217     void setDefaultValue(DcmDirectoryRecord *record,
01218                          const DcmTagKey &key,
01219                          const unsigned long number,
01220                          const char *prefix = NULL);
01221 
01222 
01223   private:
01224 
01226     OFConsole *LogStream;
01227 
01229     DcmDicomDir *DicomDir;
01230 
01232     DicomDirImagePlugin *ImagePlugin;
01233 
01235     E_ApplicationProfile ApplicationProfile;
01236 
01238     OFBool VerboseMode;
01240     OFBool BackupMode;
01242     OFBool AbortMode;
01244     OFBool MapFilenamesMode;
01246     OFBool InventMode;
01248     OFBool InventPatientIDMode;
01250     OFBool EncodingCheck;
01252     OFBool ResolutionCheck;
01254     OFBool TransferSyntaxCheck;
01256     OFBool ConsistencyCheck;
01258     OFBool IconImageMode;
01259 
01261     OFString BackupFilename;
01263     OFBool BackupCreated;
01264 
01266     unsigned int IconSize;
01268     OFString IconPrefix;
01270     OFString DefaultIcon;
01271 
01273     OFBool JPEGSupport;
01275     OFBool RLESupport;
01276 
01278     unsigned long AutoPatientNumber;
01280     unsigned long AutoStudyNumber;
01282     unsigned long AutoSeriesNumber;
01284     unsigned long AutoInstanceNumber;
01286     unsigned long AutoOverlayNumber;
01288     unsigned long AutoLutNumber;
01290     unsigned long AutoCurveNumber;
01291 
01293     DicomDirInterface(const DicomDirInterface &obj);
01294 
01296     DicomDirInterface &operator=(const DicomDirInterface &obj);
01297 };
01298 
01299 
01300 #endif
01301 
01302 
01303 /*
01304  *
01305  * CVS/RCS Log:
01306  * $Log: dcddirif.h,v $
01307  * Revision 1.8  2005/12/15 15:40:48  joergr
01308  * Removed unsused parameter.
01309  *
01310  * Revision 1.7  2005/12/08 16:28:03  meichel
01311  * Changed include path schema for all DCMTK header files
01312  *
01313  * Revision 1.6  2005/10/27 13:31:21  joergr
01314  * Added support for Encapsulated Document, Real World Value Mapping and
01315  * Hanging Protocol objects to DICOMDIR tools.
01316  *
01317  * Revision 1.5  2005/06/13 14:36:41  joergr
01318  * Added new options to disable check on pixel encoding and transfer syntax.
01319  *
01320  * Revision 1.4  2005/03/09 17:53:34  joergr
01321  * Added support for new Media Storage Application Profiles according to DICOM
01322  * PS 3.12-2004. Removed support for non-standard conformant "No profile".
01323  * Added support for UTF-8 for the contents of the fileset descriptor file.
01324  *
01325  * Revision 1.3  2004/02/13 17:36:46  joergr
01326  * Added support for new directory records RAW DATA and SPECTROSCOPY introduced
01327  * with CP 343.
01328  *
01329  * Revision 1.2  2004/02/13 14:11:15  joergr
01330  * Added support for new directory records REGISTRATION and FIDUCIAL introduced
01331  * with supplement 73 (Spatial Registration Storage SOP Classes).
01332  *
01333  * Revision 1.1  2003/08/12 14:35:00  joergr
01334  * Added new interface class for simplified creation of a DICOMDIR.
01335  *
01336  *
01337  */


Generated on 20 Dec 2005 for OFFIS DCMTK Version 3.5.4 by Doxygen 1.4.5