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 #ifndef DCPIXEL_H
00034 #define DCPIXEL_H
00035
00036 #include "dcmtk/config/osconfig.h"
00037
00038 #include "dcmtk/ofstd/ofconsol.h"
00039 #include "dcmtk/dcmdata/dcvrpobw.h"
00040 #include "dcmtk/ofstd/oflist.h"
00041
00042 class DcmCodec;
00043 class DcmCodecList;
00044 class DcmStack;
00045 class DcmPixelSequence;
00046 class DcmPixelData;
00047 class DcmRepresentationEntry;
00048
00049
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
00133 typedef OFList<DcmRepresentationEntry *> DcmRepresentationList;
00134 typedef OFListIterator(DcmRepresentationEntry *) DcmRepresentationListIterator;
00135 typedef OFListConstIterator(DcmRepresentationEntry *) DcmRepresentationListConstIterator;
00136
00148 class DcmPixelData : public DcmPolymorphOBOW
00149 {
00150 private:
00151 friend class DcmRepresentationEntry;
00152
00154 DcmRepresentationList repList;
00155
00157 DcmRepresentationListIterator repListEnd;
00158
00161 DcmRepresentationListIterator original;
00162
00164 DcmRepresentationListIterator current;
00165
00167 OFBool existUnencapsulated;
00168
00177 OFBool alwaysUnencapsulated;
00178
00180 DcmEVR unencapsulatedVR;
00181
00183 DcmPixelSequence * pixelSeqForWrite;
00184
00192 void clearRepresentationList(
00193 DcmRepresentationListIterator leaveInList);
00194
00198 OFCondition findConformingEncapsulatedRepresentation(
00199 const DcmXfer & repType,
00200 const DcmRepresentationParameter * repParam,
00201 DcmRepresentationListIterator & result);
00202
00209 OFCondition findRepresentationEntry(
00210 const DcmRepresentationEntry & findEntry,
00211 DcmRepresentationListIterator & result);
00212
00215 DcmRepresentationListIterator insertRepresentationEntry(
00216 DcmRepresentationEntry * repEntry);
00217
00220 OFCondition decode(
00221 const DcmXfer & fromType,
00222 const DcmRepresentationParameter * fromParam,
00223 DcmPixelSequence * fromPixSeq,
00224 DcmStack & pixelStack);
00225
00228 OFCondition encode(
00229 const DcmXfer & fromType,
00230 const DcmRepresentationParameter * fromParam,
00231 DcmPixelSequence * fromPixSeq,
00232 const DcmXfer & toType,
00233 const DcmRepresentationParameter *toParam,
00234 DcmStack & pixelStack);
00235
00236 void recalcVR()
00237 {
00238 if (current == repList.end()) Tag.setVR(unencapsulatedVR);
00239 else Tag.setVR(EVR_OB);
00240 }
00241
00242 public:
00243 DcmPixelData(const DcmTag & tag, const Uint32 len = 0);
00244 DcmPixelData(const DcmPixelData & pixelData);
00245 virtual ~DcmPixelData();
00246
00247 DcmPixelData &operator=(const DcmPixelData &obj);
00248
00252 virtual DcmObject *clone() const
00253 {
00254 return new DcmPixelData(*this);
00255 }
00256
00257 virtual OFCondition setVR(DcmEVR vr);
00258 virtual DcmEVR ident() const { return EVR_PixelData; }
00259
00260 virtual void print(ostream &out,
00261 const size_t flags = 0,
00262 const int level = 0,
00263 const char *pixelFileName = NULL,
00264 size_t *pixelCounter = NULL);
00265
00270 virtual OFBool canWriteXfer(const E_TransferSyntax newXfer,
00271 const E_TransferSyntax oldXfer);
00272
00278 virtual Uint32 calcElementLength(const E_TransferSyntax xfer,
00279 const E_EncodingType enctype);
00280
00286 virtual Uint32 getLength(
00287 const E_TransferSyntax xfer = EXS_LittleEndianImplicit,
00288 const E_EncodingType enctype = EET_UndefinedLength);
00289
00292 virtual void transferInit();
00293
00307 virtual OFCondition read(DcmInputStream & inStream,
00308 const E_TransferSyntax ixfer,
00309 const E_GrpLenEncoding glenc = EGL_noChange,
00310 const Uint32 maxReadLength = DCM_MaxReadLength);
00311
00317 virtual OFCondition write(
00318 DcmOutputStream & outStream,
00319 const E_TransferSyntax oxfer,
00320 const E_EncodingType enctype = EET_UndefinedLength);
00321
00327 virtual OFCondition writeXML(ostream &out,
00328 const size_t flags = 0);
00329
00332 virtual OFCondition writeSignatureFormat(
00333 DcmOutputStream & outStream,
00334 const E_TransferSyntax oxfer,
00335 const E_EncodingType enctype = EET_UndefinedLength);
00336
00337 virtual OFCondition loadAllDataIntoMemory(void);
00338
00341 virtual void transferEnd();
00342
00345 OFBool canChooseRepresentation(
00346 const E_TransferSyntax repType,
00347 const DcmRepresentationParameter * repParam);
00348
00354 OFCondition chooseRepresentation(
00355 const E_TransferSyntax repType,
00356 const DcmRepresentationParameter * repParam,
00357 DcmStack & stack);
00358
00362 void putOriginalRepresentation(
00363 const E_TransferSyntax repType,
00364 const DcmRepresentationParameter * repParam,
00365 DcmPixelSequence * pixSeq);
00366
00371 virtual OFCondition putUint8Array(
00372 const Uint8 * byteValue,
00373 const unsigned long length);
00374
00375 virtual OFCondition putUint16Array(
00376 const Uint16 * wordValue,
00377 const unsigned long length);
00378
00381 virtual OFCondition createUint8Array(
00382 const Uint32 numBytes,
00383 Uint8 * & bytes);
00384
00387 virtual OFCondition createUint16Array(
00388 const Uint32 numWords,
00389 Uint16 * & words);
00390
00395 OFCondition getEncapsulatedRepresentation(
00396 const E_TransferSyntax repType,
00397 const DcmRepresentationParameter * repParam,
00398 DcmPixelSequence * & pixSeq);
00399
00403 void getOriginalRepresentationKey(
00404 E_TransferSyntax & repType,
00405 const DcmRepresentationParameter * & repParam);
00406
00410 void getCurrentRepresentationKey(
00411 E_TransferSyntax & repType,
00412 const DcmRepresentationParameter * & repParam);
00413
00417 OFCondition setCurrentRepresentationParameter(
00418 const DcmRepresentationParameter * repParam);
00419
00422 OFBool hasRepresentation(
00423 const E_TransferSyntax repType,
00424 const DcmRepresentationParameter * repParam = NULL);
00425
00429 OFCondition removeRepresentation(
00430 const E_TransferSyntax repType,
00431 const DcmRepresentationParameter * repParam);
00432
00435 void removeAllButOriginalRepresentations();
00436
00440 void removeAllButCurrentRepresentations();
00441
00446 OFCondition removeOriginalRepresentation(
00447 const E_TransferSyntax repType,
00448 const DcmRepresentationParameter * repParam);
00449
00461 void setNonEncapsulationFlag(OFBool flag);
00462
00463 };
00464
00465 #endif
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577