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 "osconfig.h"
00037
00038
#include "ofconsol.h"
00039
#include "dcvrpobw.h"
00040
#include "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
00172 OFBool isIconImage;
00173
00175 DcmEVR unencapsulatedVR;
00176
00178 DcmPixelSequence * pixelSeqForWrite;
00179
00187
void clearRepresentationList(
00188 DcmRepresentationListIterator leaveInList);
00189
00193
OFCondition findConformingEncapsulatedRepresentation(
00194
const DcmXfer & repType,
00195
const DcmRepresentationParameter * repParam,
00196 DcmRepresentationListIterator & result);
00197
00204
OFCondition findRepresentationEntry(
00205
const DcmRepresentationEntry & findEntry,
00206 DcmRepresentationListIterator & result);
00207
00210 DcmRepresentationListIterator insertRepresentationEntry(
00211
DcmRepresentationEntry * repEntry);
00212
00215
OFCondition decode(
00216
const DcmXfer & fromType,
00217
const DcmRepresentationParameter * fromParam,
00218 DcmPixelSequence * fromPixSeq,
00219
DcmStack & pixelStack);
00220
00223
OFCondition encode(
00224
const DcmXfer & fromType,
00225
const DcmRepresentationParameter * fromParam,
00226 DcmPixelSequence * fromPixSeq,
00227
const DcmXfer & toType,
00228
const DcmRepresentationParameter *toParam,
00229
DcmStack & pixelStack);
00230
00231
void recalcVR()
00232 {
00233
if (current == repList.
end()) Tag.setVR(unencapsulatedVR);
00234
else Tag.setVR(EVR_OB);
00235 }
00236
00237
public:
00238
DcmPixelData(
const DcmTag & tag,
const Uint32 len = 0);
00239
DcmPixelData(
const DcmPixelData & pixelData);
00240
virtual ~
DcmPixelData();
00241
00242
DcmPixelData &operator=(
const DcmPixelData &obj);
00243
00244
virtual OFCondition setVR(DcmEVR vr);
00245
virtual DcmEVR ident()
const {
return EVR_PixelData; }
00246
00247
virtual void print(ostream &out,
00248
const size_t flags = 0,
00249
const int level = 0,
00250
const char *pixelFileName = NULL,
00251 size_t *pixelCounter = NULL);
00252
00257
virtual OFBool canWriteXfer(
const E_TransferSyntax newXfer,
00258
const E_TransferSyntax oldXfer);
00259
00265
virtual Uint32 calcElementLength(
const E_TransferSyntax xfer,
00266
const E_EncodingType enctype);
00267
00273
virtual Uint32 getLength(
00274
const E_TransferSyntax xfer = EXS_LittleEndianImplicit,
00275
const E_EncodingType enctype = EET_UndefinedLength);
00276
00279
virtual void transferInit();
00280
00294
virtual OFCondition read(
DcmInputStream & inStream,
00295
const E_TransferSyntax ixfer,
00296
const E_GrpLenEncoding glenc = EGL_noChange,
00297
const Uint32 maxReadLength = DCM_MaxReadLength);
00298
00304
virtual OFCondition write(
00305
DcmOutputStream & outStream,
00306
const E_TransferSyntax oxfer,
00307
const E_EncodingType enctype = EET_UndefinedLength);
00308
00314
virtual OFCondition writeXML(ostream &out,
00315
const size_t flags = 0);
00316
00319
virtual OFCondition writeSignatureFormat(
00320
DcmOutputStream & outStream,
00321
const E_TransferSyntax oxfer,
00322
const E_EncodingType enctype = EET_UndefinedLength);
00323
00324
virtual OFCondition loadAllDataIntoMemory(
void);
00325
00328
virtual void transferEnd();
00329
00332 OFBool canChooseRepresentation(
00333
const E_TransferSyntax repType,
00334
const DcmRepresentationParameter * repParam);
00335
00341
OFCondition chooseRepresentation(
00342
const E_TransferSyntax repType,
00343
const DcmRepresentationParameter * repParam,
00344
DcmStack & stack);
00345
00349
void putOriginalRepresentation(
00350
const E_TransferSyntax repType,
00351
const DcmRepresentationParameter * repParam,
00352 DcmPixelSequence * pixSeq);
00353
00358
virtual OFCondition putUint8Array(
00359
const Uint8 * byteValue,
00360
const unsigned long length);
00361
00362
virtual OFCondition putUint16Array(
00363
const Uint16 * wordValue,
00364
const unsigned long length);
00365
00368
virtual OFCondition createUint8Array(
00369
const Uint32 numBytes,
00370 Uint8 * & bytes);
00371
00374
virtual OFCondition createUint16Array(
00375
const Uint32 numWords,
00376 Uint16 * & words);
00377
00382
OFCondition getEncapsulatedRepresentation(
00383
const E_TransferSyntax repType,
00384
const DcmRepresentationParameter * repParam,
00385 DcmPixelSequence * & pixSeq);
00386
00390
void getOriginalRepresentationKey(
00391 E_TransferSyntax & repType,
00392
const DcmRepresentationParameter * & repParam);
00393
00397
void getCurrentRepresentationKey(
00398 E_TransferSyntax & repType,
00399
const DcmRepresentationParameter * & repParam);
00400
00404
OFCondition setCurrentRepresentationParameter(
00405
const DcmRepresentationParameter * repParam);
00406
00409 OFBool hasRepresentation(
00410
const E_TransferSyntax repType,
00411
const DcmRepresentationParameter * repParam = NULL);
00412
00416
OFCondition removeRepresentation(
00417
const E_TransferSyntax repType,
00418
const DcmRepresentationParameter * repParam);
00419
00422
void removeAllButOriginalRepresentations();
00423
00427
void removeAllButCurrentRepresentations();
00428
00433
OFCondition removeOriginalRepresentation(
00434
const E_TransferSyntax repType,
00435
const DcmRepresentationParameter * repParam);
00436 };
00437
00438
#endif
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
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