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 "osconfig.h"
00038
00039
#include "ofconsol.h"
00040
#include "dctypes.h"
00041
#include "dcobject.h"
00042
#include "dcvrui.h"
00043
#include "dclist.h"
00044
#include "dcstack.h"
00045
#include "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 DcmEVR
ident()
const;
00085
00089
virtual unsigned long getVM();
00090
00091
virtual unsigned long card()
const;
00092
00093
virtual OFBool isLeaf()
const {
return OFFalse; }
00094
00102
virtual void print(ostream &out,
00103
const size_t flags = 0,
00104
const int level = 0,
00105
const char *pixelFileName = NULL,
00106 size_t *pixelCounter = NULL);
00107
00108
virtual Uint32 calcElementLength(
const E_TransferSyntax xfer,
00109
const E_EncodingType enctype);
00110
00111
virtual Uint32 getLength(
const E_TransferSyntax xfer = EXS_LittleEndianImplicit,
00112
const E_EncodingType enctype = EET_UndefinedLength);
00113
00114
virtual void transferInit();
00115
virtual void transferEnd();
00116
00117
virtual OFBool canWriteXfer(
const E_TransferSyntax newXfer,
00118
const E_TransferSyntax oldXfer);
00119
00133
virtual OFCondition read(
DcmInputStream &inStream,
00134
const E_TransferSyntax ixfer,
00135
const E_GrpLenEncoding glenc = EGL_noChange,
00136
const Uint32 maxReadLength = DCM_MaxReadLength);
00137
00144
virtual OFCondition write(
DcmOutputStream &outStream,
00145
const E_TransferSyntax oxfer,
00146
const E_EncodingType enctype = EET_UndefinedLength);
00147
00153
virtual OFCondition writeXML(ostream &out,
00154
const size_t flags = 0);
00155
00162
virtual OFCondition writeSignatureFormat(
DcmOutputStream &outStream,
00163
const E_TransferSyntax oxfer,
00164
const E_EncodingType enctype = EET_UndefinedLength);
00165
00169
virtual OFBool
containsUnknownVR()
const;
00170
00183
virtual OFCondition insert(
DcmElement *elem,
00184 OFBool replaceOld = OFFalse,
00185 OFBool checkInsertOrder = OFFalse);
00186
00187
virtual DcmElement *getElement(
const unsigned long num);
00188
00189
00190
00191
00192
00193
virtual OFCondition nextObject(
DcmStack &stack,
00194
const OFBool intoSub);
00195
virtual DcmObject *nextInContainer(
const DcmObject *obj);
00196
virtual DcmElement *remove(
const unsigned long num);
00197
virtual DcmElement *remove(
DcmObject *elem);
00198
virtual DcmElement *remove(
const DcmTagKey &tag);
00199
virtual OFCondition clear();
00200
virtual OFCondition verify(
const OFBool autocorrect = OFFalse );
00201
virtual OFCondition search(
const DcmTagKey &xtag,
00202
DcmStack &resultStack,
00203 E_SearchMode mode = ESM_fromHere,
00204 OFBool searchIntoSub = OFTrue );
00205
virtual OFCondition searchErrors(
DcmStack &resultStack );
00206
virtual OFCondition loadAllDataIntoMemory();
00207
00236
virtual OFCondition computeGroupLengthAndPadding(
const E_GrpLenEncoding glenc,
00237
const E_PaddingEncoding padenc = EPD_noChange,
00238
const E_TransferSyntax xfer = EXS_Unknown,
00239
const E_EncodingType enctype = EET_ExplicitLength,
00240
const Uint32 padlen = 0,
00241
const Uint32 subPadlen = 0,
00242 Uint32 instanceLength = 0);
00243
00244
00245 OFBool tagExists(
const DcmTagKey &key,
00246 OFBool searchIntoSub = OFFalse);
00247 OFBool tagExistsWithValue(
const DcmTagKey &key,
00248 OFBool searchIntoSub = OFFalse);
00249
00250
00251
00252
00261
OFCondition findAndGetElement(
const DcmTagKey &tagKey,
00262
DcmElement *&element,
00263
const OFBool searchIntoSub = OFFalse);
00264
00272
OFCondition findAndGetElements(
const DcmTagKey &tagKey,
00273
DcmStack &resultStack);
00274
00285
OFCondition findAndGetString(
const DcmTagKey &tagKey,
00286
const char *&value,
00287
const OFBool searchIntoSub = OFFalse);
00288
00305
OFCondition findAndGetOFString(
const DcmTagKey &tagKey,
00306
OFString &value,
00307
const unsigned long pos = 0,
00308
const OFBool searchIntoSub = OFFalse);
00309
00323
OFCondition findAndGetOFStringArray(
const DcmTagKey &tagKey,
00324
OFString &value,
00325
const OFBool searchIntoSub = OFFalse);
00326
00336
OFCondition findAndGetUint8(
const DcmTagKey &tagKey,
00337 Uint8 &value,
00338
const unsigned long pos = 0,
00339
const OFBool searchIntoSub = OFFalse);
00340
00350
OFCondition findAndGetUint8Array(
const DcmTagKey &tagKey,
00351
const Uint8 *&value,
00352
unsigned long *count = NULL,
00353
const OFBool searchIntoSub = OFFalse);
00354
00364
OFCondition findAndGetUint16(
const DcmTagKey &tagKey,
00365 Uint16 &value,
00366
const unsigned long pos = 0,
00367
const OFBool searchIntoSub = OFFalse);
00368
00378
OFCondition findAndGetUint16Array(
const DcmTagKey &tagKey,
00379
const Uint16 *&value,
00380
unsigned long *count = NULL,
00381
const OFBool searchIntoSub = OFFalse);
00382
00392
OFCondition findAndGetSint16(
const DcmTagKey &tagKey,
00393 Sint16 &value,
00394
const unsigned long pos = 0,
00395
const OFBool searchIntoSub = OFFalse);
00396
00406
OFCondition findAndGetSint16Array(
const DcmTagKey &tagKey,
00407
const Sint16 *&value,
00408
unsigned long *count = NULL,
00409
const OFBool searchIntoSub = OFFalse);
00410
00420
OFCondition findAndGetUint32(
const DcmTagKey &tagKey,
00421 Uint32 &value,
00422
const unsigned long pos = 0,
00423
const OFBool searchIntoSub = OFFalse);
00424
00434
OFCondition findAndGetUint32Array(
const DcmTagKey &tagKey,
00435
const Uint32 *&value,
00436
unsigned long *count = NULL,
00437
const OFBool searchIntoSub = OFFalse);
00438
00448
OFCondition findAndGetSint32(
const DcmTagKey &tagKey,
00449 Sint32 &value,
00450
const unsigned long pos = 0,
00451
const OFBool searchIntoSub = OFFalse);
00452
00462
OFCondition findAndGetSint32Array(
const DcmTagKey &tagKey,
00463
const Sint32 *&value,
00464
unsigned long *count = NULL,
00465
const OFBool searchIntoSub = OFFalse);
00466
00476
OFCondition findAndGetLongInt(
const DcmTagKey &tagKey,
00477
long int &value,
00478
const unsigned long pos = 0,
00479
const OFBool searchIntoSub = OFFalse);
00480
00490
OFCondition findAndGetFloat32(
const DcmTagKey &tagKey,
00491 Float32 &value,
00492
const unsigned long pos = 0,
00493
const OFBool searchIntoSub = OFFalse);
00494
00504
OFCondition findAndGetFloat32Array(
const DcmTagKey &tagKey,
00505
const Float32 *&value,
00506
unsigned long *count = NULL,
00507
const OFBool searchIntoSub = OFFalse);
00508
00518
OFCondition findAndGetFloat64(
const DcmTagKey &tagKey,
00519 Float64 &value,
00520
const unsigned long pos = 0,
00521
const OFBool searchIntoSub = OFFalse);
00522
00532
OFCondition findAndGetFloat64Array(
const DcmTagKey &tagKey,
00533
const Float64 *&value,
00534
unsigned long *count = NULL,
00535
const OFBool searchIntoSub = OFFalse);
00536
00546
OFCondition findAndGetSequence(
const DcmTagKey &seqTagKey,
00547 DcmSequenceOfItems *&sequence,
00548
const OFBool searchIntoSub = OFFalse);
00549
00560
OFCondition findAndGetSequenceItem(
const DcmTagKey &seqTagKey,
00561
DcmItem *&item,
00562
const signed long itemNum = 0);
00563
00564
00565
00566
00579
OFCondition findOrCreateSequenceItem(
const DcmTag &seqTag,
00580
DcmItem *&item,
00581
const signed long itemNum = 0);
00582
00583
00584
00585
00594
OFCondition findAndDeleteElement(
const DcmTagKey &tagKey,
00595
const OFBool allOccurrences = OFFalse,
00596
const OFBool searchIntoSub = OFFalse);
00597
00607
OFCondition findAndCopyElement(
const DcmTagKey &tagKey,
00608
DcmElement *&newElement,
00609
const OFBool searchIntoSub = OFFalse);
00610
00611
00612
00621
OFCondition putAndInsertString(
const DcmTag &tag,
00622
const char *value,
00623
const OFBool replaceOld = OFTrue);
00624
00632
OFCondition putAndInsertOFStringArray(
const DcmTag &tag,
00633
const OFString &value,
00634
const OFBool replaceOld = OFTrue);
00635
00644
OFCondition putAndInsertUint8Array(
const DcmTag &tag,
00645
const Uint8 *value,
00646
const unsigned long count,
00647
const OFBool replaceOld = OFTrue);
00648
00657
OFCondition putAndInsertUint16(
const DcmTag &tag,
00658
const Uint16 value,
00659
const unsigned long pos = 0,
00660
const OFBool replaceOld = OFTrue);
00661
00670
OFCondition putAndInsertUint16Array(
const DcmTag &tag,
00671
const Uint16 *value,
00672
const unsigned long count,
00673
const OFBool replaceOld = OFTrue);
00674
00683
OFCondition putAndInsertSint16(
const DcmTag &tag,
00684
const Sint16 value,
00685
const unsigned long pos = 0,
00686
const OFBool replaceOld = OFTrue);
00687
00696
OFCondition putAndInsertSint16Array(
const DcmTag &tag,
00697
const Sint16 *value,
00698
const unsigned long count,
00699
const OFBool replaceOld = OFTrue);
00700
00709
OFCondition putAndInsertUint32(
const DcmTag &tag,
00710
const Uint32 value,
00711
const unsigned long pos = 0,
00712
const OFBool replaceOld = OFTrue);
00713
00722
OFCondition putAndInsertSint32(
const DcmTag &tag,
00723
const Sint32 value,
00724
const unsigned long pos = 0,
00725
const OFBool replaceOld = OFTrue);
00726
00735
OFCondition putAndInsertFloat32(
const DcmTag &tag,
00736
const Float32 value,
00737
const unsigned long pos = 0,
00738
const OFBool replaceOld = OFTrue);
00739
00748
OFCondition putAndInsertFloat64(
const DcmTag &tag,
00749
const Float64 value,
00750
const unsigned long pos = 0,
00751
const OFBool replaceOld = OFTrue);
00752
00760
OFCondition insertEmptyElement(
const DcmTag &tag,
00761
const OFBool replaceOld = OFTrue);
00762
00763
00764
protected:
00765
00767 DcmList *
elementList;
00768
00773 OFBool
lastElementComplete;
00774
00779 Uint32
fStartPosition;
00780
00799
OFCondition readTagAndLength(
DcmInputStream &inStream,
00800
const E_TransferSyntax xfer,
00801
DcmTag &tag,
00802 Uint32 &length,
00803 Uint32 &bytesRead);
00804
00821
OFCondition readSubElement(
DcmInputStream &inStream,
00822
DcmTag &newTag,
00823
const Uint32 newLength,
00824
const E_TransferSyntax xfer,
00825
const E_GrpLenEncoding glenc,
00826
const Uint32 maxReadLength = DCM_MaxReadLength);
00827
00837 E_TransferSyntax
checkTransferSyntax(
DcmInputStream &inStream);
00838
00839
00840
private:
00841
00843
DcmItem &
operator=(
const DcmItem &);
00844
00845
DcmObject* copyDcmObject(
DcmObject *oldObj);
00846
00847
OFCondition searchSubFromHere(
const DcmTagKey &tag,
00848
DcmStack &resultStack,
00849 OFBool searchIntoSub );
00850
00851 OFBool foundVR(
char *atposition);
00852
00854 DcmPrivateTagCache privateCreatorCache;
00855 };
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
OFCondition newDicomElement(
DcmElement *&newElement,
00882
const DcmTag &tag,
00883
const Uint32 length = 0);
00884
00885
00886
00887
00888
00889
00890
DcmElement *newDicomElement(
const DcmTag &tag,
00891
const Uint32 length = 0);
00892
00893
00894
00895
OFCondition nextUp(
DcmStack &st);
00896
00897
00898
#endif // DCITEM_H
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
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