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 #ifndef DCPIXEL_H
00030 #define DCPIXEL_H
00031
00032 #include "dcmtk/config/osconfig.h"
00033 #include "dcmtk/dcmdata/dcvrpobw.h"
00034 #include "dcmtk/ofstd/oflist.h"
00035
00036 class DcmCodec;
00037 class DcmCodecList;
00038 class DcmItem;
00039 class DcmPixelData;
00040 class DcmPixelSequence;
00041 class DcmRepresentationEntry;
00042 class DcmStack;
00043
00050 class DcmRepresentationParameter
00051 {
00052 public:
00054 DcmRepresentationParameter() {}
00055
00057 DcmRepresentationParameter(const DcmRepresentationParameter&) {}
00058
00060 virtual ~DcmRepresentationParameter() {}
00061
00066 virtual DcmRepresentationParameter *clone() const = 0;
00067
00071 virtual const char *className() const = 0;
00072
00078 virtual OFBool operator==(const DcmRepresentationParameter &arg) const = 0;
00079 };
00080
00081
00088 class DcmRepresentationEntry
00089 {
00097 DcmRepresentationEntry(
00098 const E_TransferSyntax rt,
00099 const DcmRepresentationParameter * rp,
00100 DcmPixelSequence * pixSeq);
00101
00103 DcmRepresentationEntry(const DcmRepresentationEntry &oldEntry);
00104
00106 ~DcmRepresentationEntry();
00107
00109 OFBool operator==(const DcmRepresentationEntry& x) const;
00110
00112 OFBool operator!=(const DcmRepresentationEntry & x) const
00113 {
00114 return !(*this == x);
00115 }
00116
00117 private:
00119 DcmRepresentationEntry &operator=(const DcmRepresentationEntry &);
00120
00122 E_TransferSyntax repType;
00123
00125 DcmRepresentationParameter * repParam;
00126
00128 DcmPixelSequence * pixSeq;
00129
00130 friend class DcmPixelData;
00131 };
00132
00134 typedef OFList<DcmRepresentationEntry *> DcmRepresentationList;
00135
00137 typedef OFListIterator(DcmRepresentationEntry *) DcmRepresentationListIterator;
00138
00140 typedef OFListConstIterator(DcmRepresentationEntry *) DcmRepresentationListConstIterator;
00141
00153 class DcmPixelData : public DcmPolymorphOBOW
00154 {
00155 private:
00156 friend class DcmRepresentationEntry;
00157
00159 DcmRepresentationList repList;
00160
00162 DcmRepresentationListIterator repListEnd;
00163
00166 DcmRepresentationListIterator original;
00167
00169 DcmRepresentationListIterator current;
00170
00172 OFBool existUnencapsulated;
00173
00182 OFBool alwaysUnencapsulated;
00183
00185 DcmEVR unencapsulatedVR;
00186
00188 DcmPixelSequence * pixelSeqForWrite;
00189
00197 void clearRepresentationList(
00198 DcmRepresentationListIterator leaveInList);
00199
00203 OFCondition findConformingEncapsulatedRepresentation(
00204 const DcmXfer & repType,
00205 const DcmRepresentationParameter * repParam,
00206 DcmRepresentationListIterator & result);
00207
00214 OFCondition findRepresentationEntry(
00215 const DcmRepresentationEntry & findEntry,
00216 DcmRepresentationListIterator & result);
00217
00220 DcmRepresentationListIterator insertRepresentationEntry(
00221 DcmRepresentationEntry * repEntry);
00222
00225 OFCondition decode(
00226 const DcmXfer & fromType,
00227 const DcmRepresentationParameter * fromParam,
00228 DcmPixelSequence * fromPixSeq,
00229 DcmStack & pixelStack);
00230
00233 OFCondition encode(
00234 const DcmXfer & fromType,
00235 const DcmRepresentationParameter * fromParam,
00236 DcmPixelSequence * fromPixSeq,
00237 const DcmXfer & toType,
00238 const DcmRepresentationParameter *toParam,
00239 DcmStack & pixelStack);
00240
00244 void recalcVR()
00245 {
00246 if (current == repList.end()) setTagVR(unencapsulatedVR);
00247 else setTagVR(EVR_OB);
00248 }
00249
00250 public:
00251
00256 DcmPixelData(const DcmTag & tag, const Uint32 len = 0);
00257
00261 DcmPixelData(const DcmPixelData & pixelData);
00262
00264 virtual ~DcmPixelData();
00265
00269 DcmPixelData &operator=(const DcmPixelData &obj);
00270
00274 virtual DcmObject *clone() const
00275 {
00276 return new DcmPixelData(*this);
00277 }
00278
00291 virtual OFCondition copyFrom(const DcmObject& rhs);
00292
00299 virtual OFCondition setVR(DcmEVR vr);
00300
00307 virtual DcmEVR ident() const { return EVR_PixelData; }
00308
00316 virtual void print(STD_NAMESPACE ostream&out,
00317 const size_t flags = 0,
00318 const int level = 0,
00319 const char *pixelFileName = NULL,
00320 size_t *pixelCounter = NULL);
00321
00326 virtual OFBool canWriteXfer(const E_TransferSyntax newXfer,
00327 const E_TransferSyntax oldXfer);
00328
00334 virtual Uint32 calcElementLength(const E_TransferSyntax xfer,
00335 const E_EncodingType enctype);
00336
00342 virtual Uint32 getLength(
00343 const E_TransferSyntax xfer = EXS_LittleEndianImplicit,
00344 const E_EncodingType enctype = EET_UndefinedLength);
00345
00349 virtual void transferInit();
00350
00364 virtual OFCondition read(DcmInputStream & inStream,
00365 const E_TransferSyntax ixfer,
00366 const E_GrpLenEncoding glenc = EGL_noChange,
00367 const Uint32 maxReadLength = DCM_MaxReadLength);
00368
00374 virtual OFCondition write(
00375 DcmOutputStream &outStream,
00376 const E_TransferSyntax oxfer,
00377 const E_EncodingType enctype,
00378 DcmWriteCache *wcache);
00379
00385 virtual OFCondition writeXML(STD_NAMESPACE ostream&out,
00386 const size_t flags = 0);
00387
00395 virtual OFCondition writeSignatureFormat(
00396 DcmOutputStream &outStream,
00397 const E_TransferSyntax oxfer,
00398 const E_EncodingType enctype,
00399 DcmWriteCache *wcache);
00400
00408 virtual OFCondition loadAllDataIntoMemory(void);
00409
00410
00414 virtual void transferEnd();
00415
00418 OFBool canChooseRepresentation(
00419 const E_TransferSyntax repType,
00420 const DcmRepresentationParameter * repParam);
00421
00427 OFCondition chooseRepresentation(
00428 const E_TransferSyntax repType,
00429 const DcmRepresentationParameter * repParam,
00430 DcmStack & stack);
00431
00435 void putOriginalRepresentation(
00436 const E_TransferSyntax repType,
00437 const DcmRepresentationParameter * repParam,
00438 DcmPixelSequence * pixSeq);
00439
00444 virtual OFCondition putUint8Array(
00445 const Uint8 * byteValue,
00446 const unsigned long length);
00447
00452 virtual OFCondition putUint16Array(
00453 const Uint16 * wordValue,
00454 const unsigned long length);
00455
00458 virtual OFCondition createUint8Array(
00459 const Uint32 numBytes,
00460 Uint8 * & bytes);
00461
00464 virtual OFCondition createUint16Array(
00465 const Uint32 numWords,
00466 Uint16 * & words);
00467
00479 virtual OFCondition createValueFromTempFile(
00480 DcmInputStreamFactory *factory,
00481 const Uint32 length,
00482 const E_ByteOrder byteOrder);
00483
00488 OFCondition getEncapsulatedRepresentation(
00489 const E_TransferSyntax repType,
00490 const DcmRepresentationParameter * repParam,
00491 DcmPixelSequence * & pixSeq);
00492
00496 void getOriginalRepresentationKey(
00497 E_TransferSyntax & repType,
00498 const DcmRepresentationParameter * & repParam);
00499
00503 void getCurrentRepresentationKey(
00504 E_TransferSyntax & repType,
00505 const DcmRepresentationParameter * & repParam);
00506
00510 OFCondition setCurrentRepresentationParameter(
00511 const DcmRepresentationParameter * repParam);
00512
00515 OFBool hasRepresentation(
00516 const E_TransferSyntax repType,
00517 const DcmRepresentationParameter * repParam = NULL);
00518
00522 OFCondition removeRepresentation(
00523 const E_TransferSyntax repType,
00524 const DcmRepresentationParameter * repParam);
00525
00528 void removeAllButOriginalRepresentations();
00529
00533 void removeAllButCurrentRepresentations();
00534
00539 OFCondition removeOriginalRepresentation(
00540 const E_TransferSyntax repType,
00541 const DcmRepresentationParameter * repParam);
00542
00554 void setNonEncapsulationFlag(OFBool flag);
00555
00584 virtual OFCondition getUncompressedFrame(
00585 DcmItem *dataset,
00586 Uint32 frameNo,
00587 Uint32& startFragment,
00588 void *buffer,
00589 Uint32 bufSize,
00590 OFString& decompressedColorModel,
00591 DcmFileCache *cache=NULL);
00592
00601 virtual OFCondition getDecompressedColorModel(
00602 DcmItem *dataset,
00603 OFString &decompressedColorModel);
00604 };
00605
00606 #endif
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767