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 DCITEM_H
00035 #define DCITEM_H
00036
00037 #include "dcmtk/config/osconfig.h"
00038
00039 #include "dcmtk/ofstd/ofconsol.h"
00040 #include "dcmtk/dcmdata/dctypes.h"
00041 #include "dcmtk/dcmdata/dcobject.h"
00042 #include "dcmtk/dcmdata/dcvrui.h"
00043 #include "dcmtk/dcmdata/dclist.h"
00044 #include "dcmtk/dcmdata/dcstack.h"
00045 #include "dcmtk/dcmdata/dcpcache.h"
00046
00047
00048
00049 class DcmSequenceOfItems;
00050
00051
00054 class DcmItem
00055 : public DcmObject
00056 {
00057
00058 public:
00059
00062 DcmItem();
00063
00069 DcmItem(const DcmTag &tag,
00070 const Uint32 len = 0);
00071
00075 DcmItem(const DcmItem &old);
00076
00079 virtual ~DcmItem();
00080
00084 virtual DcmObject *clone() const
00085 {
00086 return new DcmItem(*this);
00087 }
00088
00092 virtual DcmEVR ident() const;
00093
00097 virtual unsigned long getVM();
00098
00099 virtual unsigned long card() const;
00100
00101 virtual OFBool isLeaf() const { return OFFalse; }
00102
00110 virtual void print(ostream &out,
00111 const size_t flags = 0,
00112 const int level = 0,
00113 const char *pixelFileName = NULL,
00114 size_t *pixelCounter = NULL);
00115
00116 virtual Uint32 calcElementLength(const E_TransferSyntax xfer,
00117 const E_EncodingType enctype);
00118
00119 virtual Uint32 getLength(const E_TransferSyntax xfer = EXS_LittleEndianImplicit,
00120 const E_EncodingType enctype = EET_UndefinedLength);
00121
00122 virtual void transferInit();
00123 virtual void transferEnd();
00124
00125 virtual OFBool canWriteXfer(const E_TransferSyntax newXfer,
00126 const E_TransferSyntax oldXfer);
00127
00141 virtual OFCondition read(DcmInputStream &inStream,
00142 const E_TransferSyntax ixfer,
00143 const E_GrpLenEncoding glenc = EGL_noChange,
00144 const Uint32 maxReadLength = DCM_MaxReadLength);
00145
00152 virtual OFCondition write(DcmOutputStream &outStream,
00153 const E_TransferSyntax oxfer,
00154 const E_EncodingType enctype = EET_UndefinedLength);
00155
00161 virtual OFCondition writeXML(ostream &out,
00162 const size_t flags = 0);
00163
00170 virtual OFCondition writeSignatureFormat(DcmOutputStream &outStream,
00171 const E_TransferSyntax oxfer,
00172 const E_EncodingType enctype = EET_UndefinedLength);
00173
00177 virtual OFBool containsUnknownVR() const;
00178
00191 virtual OFCondition insert(DcmElement *elem,
00192 OFBool replaceOld = OFFalse,
00193 OFBool checkInsertOrder = OFFalse);
00194
00195 virtual DcmElement *getElement(const unsigned long num);
00196
00197
00198
00199
00200
00201 virtual OFCondition nextObject(DcmStack &stack,
00202 const OFBool intoSub);
00203 virtual DcmObject *nextInContainer(const DcmObject *obj);
00204 virtual DcmElement *remove(const unsigned long num);
00205 virtual DcmElement *remove(DcmObject *elem);
00206 virtual DcmElement *remove(const DcmTagKey &tag);
00207 virtual OFCondition clear();
00208 virtual OFCondition verify(const OFBool autocorrect = OFFalse );
00209 virtual OFCondition search(const DcmTagKey &xtag,
00210 DcmStack &resultStack,
00211 E_SearchMode mode = ESM_fromHere,
00212 OFBool searchIntoSub = OFTrue );
00213 virtual OFCondition searchErrors( DcmStack &resultStack );
00214 virtual OFCondition loadAllDataIntoMemory();
00215
00244 virtual OFCondition computeGroupLengthAndPadding(const E_GrpLenEncoding glenc,
00245 const E_PaddingEncoding padenc = EPD_noChange,
00246 const E_TransferSyntax xfer = EXS_Unknown,
00247 const E_EncodingType enctype = EET_ExplicitLength,
00248 const Uint32 padlen = 0,
00249 const Uint32 subPadlen = 0,
00250 Uint32 instanceLength = 0);
00251
00252
00253 OFBool tagExists(const DcmTagKey &key,
00254 OFBool searchIntoSub = OFFalse);
00255 OFBool tagExistsWithValue(const DcmTagKey &key,
00256 OFBool searchIntoSub = OFFalse);
00257
00258
00259
00260
00269 OFCondition findAndGetElement(const DcmTagKey &tagKey,
00270 DcmElement *&element,
00271 const OFBool searchIntoSub = OFFalse);
00272
00280 OFCondition findAndGetElements(const DcmTagKey &tagKey,
00281 DcmStack &resultStack);
00282
00293 OFCondition findAndGetString(const DcmTagKey &tagKey,
00294 const char *&value,
00295 const OFBool searchIntoSub = OFFalse);
00296
00313 OFCondition findAndGetOFString(const DcmTagKey &tagKey,
00314 OFString &value,
00315 const unsigned long pos = 0,
00316 const OFBool searchIntoSub = OFFalse);
00317
00331 OFCondition findAndGetOFStringArray(const DcmTagKey &tagKey,
00332 OFString &value,
00333 const OFBool searchIntoSub = OFFalse);
00334
00344 OFCondition findAndGetUint8(const DcmTagKey &tagKey,
00345 Uint8 &value,
00346 const unsigned long pos = 0,
00347 const OFBool searchIntoSub = OFFalse);
00348
00358 OFCondition findAndGetUint8Array(const DcmTagKey &tagKey,
00359 const Uint8 *&value,
00360 unsigned long *count = NULL,
00361 const OFBool searchIntoSub = OFFalse);
00362
00372 OFCondition findAndGetUint16(const DcmTagKey &tagKey,
00373 Uint16 &value,
00374 const unsigned long pos = 0,
00375 const OFBool searchIntoSub = OFFalse);
00376
00386 OFCondition findAndGetUint16Array(const DcmTagKey &tagKey,
00387 const Uint16 *&value,
00388 unsigned long *count = NULL,
00389 const OFBool searchIntoSub = OFFalse);
00390
00400 OFCondition findAndGetSint16(const DcmTagKey &tagKey,
00401 Sint16 &value,
00402 const unsigned long pos = 0,
00403 const OFBool searchIntoSub = OFFalse);
00404
00414 OFCondition findAndGetSint16Array(const DcmTagKey &tagKey,
00415 const Sint16 *&value,
00416 unsigned long *count = NULL,
00417 const OFBool searchIntoSub = OFFalse);
00418
00428 OFCondition findAndGetUint32(const DcmTagKey &tagKey,
00429 Uint32 &value,
00430 const unsigned long pos = 0,
00431 const OFBool searchIntoSub = OFFalse);
00432
00442 OFCondition findAndGetUint32Array(const DcmTagKey &tagKey,
00443 const Uint32 *&value,
00444 unsigned long *count = NULL,
00445 const OFBool searchIntoSub = OFFalse);
00446
00456 OFCondition findAndGetSint32(const DcmTagKey &tagKey,
00457 Sint32 &value,
00458 const unsigned long pos = 0,
00459 const OFBool searchIntoSub = OFFalse);
00460
00470 OFCondition findAndGetSint32Array(const DcmTagKey &tagKey,
00471 const Sint32 *&value,
00472 unsigned long *count = NULL,
00473 const OFBool searchIntoSub = OFFalse);
00474
00484 OFCondition findAndGetLongInt(const DcmTagKey &tagKey,
00485 long int &value,
00486 const unsigned long pos = 0,
00487 const OFBool searchIntoSub = OFFalse);
00488
00498 OFCondition findAndGetFloat32(const DcmTagKey &tagKey,
00499 Float32 &value,
00500 const unsigned long pos = 0,
00501 const OFBool searchIntoSub = OFFalse);
00502
00512 OFCondition findAndGetFloat32Array(const DcmTagKey &tagKey,
00513 const Float32 *&value,
00514 unsigned long *count = NULL,
00515 const OFBool searchIntoSub = OFFalse);
00516
00526 OFCondition findAndGetFloat64(const DcmTagKey &tagKey,
00527 Float64 &value,
00528 const unsigned long pos = 0,
00529 const OFBool searchIntoSub = OFFalse);
00530
00540 OFCondition findAndGetFloat64Array(const DcmTagKey &tagKey,
00541 const Float64 *&value,
00542 unsigned long *count = NULL,
00543 const OFBool searchIntoSub = OFFalse);
00544
00554 OFCondition findAndGetSequence(const DcmTagKey &seqTagKey,
00555 DcmSequenceOfItems *&sequence,
00556 const OFBool searchIntoSub = OFFalse);
00557
00568 OFCondition findAndGetSequenceItem(const DcmTagKey &seqTagKey,
00569 DcmItem *&item,
00570 const signed long itemNum = 0);
00571
00572
00573
00574
00587 OFCondition findOrCreateSequenceItem(const DcmTag &seqTag,
00588 DcmItem *&item,
00589 const signed long itemNum = 0);
00590
00591
00592
00593
00602 OFCondition findAndDeleteElement(const DcmTagKey &tagKey,
00603 const OFBool allOccurrences = OFFalse,
00604 const OFBool searchIntoSub = OFFalse);
00605
00615 OFCondition findAndCopyElement(const DcmTagKey &tagKey,
00616 DcmElement *&newElement,
00617 const OFBool searchIntoSub = OFFalse);
00618
00619
00620
00629 OFCondition putAndInsertString(const DcmTag &tag,
00630 const char *value,
00631 const OFBool replaceOld = OFTrue);
00632
00640 OFCondition putAndInsertOFStringArray(const DcmTag &tag,
00641 const OFString &value,
00642 const OFBool replaceOld = OFTrue);
00643
00652 OFCondition putAndInsertUint8Array(const DcmTag &tag,
00653 const Uint8 *value,
00654 const unsigned long count,
00655 const OFBool replaceOld = OFTrue);
00656
00665 OFCondition putAndInsertUint16(const DcmTag &tag,
00666 const Uint16 value,
00667 const unsigned long pos = 0,
00668 const OFBool replaceOld = OFTrue);
00669
00678 OFCondition putAndInsertUint16Array(const DcmTag &tag,
00679 const Uint16 *value,
00680 const unsigned long count,
00681 const OFBool replaceOld = OFTrue);
00682
00691 OFCondition putAndInsertSint16(const DcmTag &tag,
00692 const Sint16 value,
00693 const unsigned long pos = 0,
00694 const OFBool replaceOld = OFTrue);
00695
00704 OFCondition putAndInsertSint16Array(const DcmTag &tag,
00705 const Sint16 *value,
00706 const unsigned long count,
00707 const OFBool replaceOld = OFTrue);
00708
00717 OFCondition putAndInsertUint32(const DcmTag &tag,
00718 const Uint32 value,
00719 const unsigned long pos = 0,
00720 const OFBool replaceOld = OFTrue);
00721
00730 OFCondition putAndInsertSint32(const DcmTag &tag,
00731 const Sint32 value,
00732 const unsigned long pos = 0,
00733 const OFBool replaceOld = OFTrue);
00734
00743 OFCondition putAndInsertFloat32(const DcmTag &tag,
00744 const Float32 value,
00745 const unsigned long pos = 0,
00746 const OFBool replaceOld = OFTrue);
00747
00756 OFCondition putAndInsertFloat64(const DcmTag &tag,
00757 const Float64 value,
00758 const unsigned long pos = 0,
00759 const OFBool replaceOld = OFTrue);
00760
00768 OFCondition insertEmptyElement(const DcmTag &tag,
00769 const OFBool replaceOld = OFTrue);
00770
00771
00772 protected:
00773
00775 DcmList *elementList;
00776
00781 OFBool lastElementComplete;
00782
00787 Uint32 fStartPosition;
00788
00807 OFCondition readTagAndLength(DcmInputStream &inStream,
00808 const E_TransferSyntax xfer,
00809 DcmTag &tag,
00810 Uint32 &length,
00811 Uint32 &bytesRead);
00812
00829 OFCondition readSubElement(DcmInputStream &inStream,
00830 DcmTag &newTag,
00831 const Uint32 newLength,
00832 const E_TransferSyntax xfer,
00833 const E_GrpLenEncoding glenc,
00834 const Uint32 maxReadLength = DCM_MaxReadLength);
00835
00845 E_TransferSyntax checkTransferSyntax(DcmInputStream &inStream);
00846
00847
00848 private:
00849
00851 DcmItem &operator=(const DcmItem &);
00852
00853 OFCondition searchSubFromHere(const DcmTagKey &tag,
00854 DcmStack &resultStack,
00855 OFBool searchIntoSub );
00856
00857 OFBool foundVR(char *atposition);
00858
00860 DcmPrivateTagCache privateCreatorCache;
00861 };
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887 OFCondition newDicomElement(DcmElement *&newElement,
00888 DcmTag &tag,
00889 const Uint32 length,
00890 DcmPrivateTagCache *privateCreatorCache,
00891 OFBool& readAsUN);
00892
00893 OFCondition newDicomElement(DcmElement *&newElement,
00894 const DcmTag &tag,
00895 const Uint32 length = 0);
00896
00897
00898
00899
00900 DcmElement *newDicomElement(const DcmTag &tag,
00901 const Uint32 length = 0);
00902
00903
00904
00905 OFCondition nextUp(DcmStack &st);
00906
00907
00908 #endif // DCITEM_H
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145