dcpixel.h

00001 /*
00002  *
00003  *  Copyright (C) 1994-2005, OFFIS
00004  *
00005  *  This software and supporting documentation were developed by
00006  *
00007  *    Kuratorium OFFIS e.V.
00008  *    Healthcare Information and Communication Systems
00009  *    Escherweg 2
00010  *    D-26121 Oldenburg, Germany
00011  *
00012  *  THIS SOFTWARE IS MADE AVAILABLE,  AS IS,  AND OFFIS MAKES NO  WARRANTY
00013  *  REGARDING  THE  SOFTWARE,  ITS  PERFORMANCE,  ITS  MERCHANTABILITY  OR
00014  *  FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES  OR
00015  *  ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND
00016  *  PERFORMANCE OF THE SOFTWARE IS WITH THE USER.
00017  *
00018  *  Module:  dcmdata
00019  *
00020  *  Author:  Andreas Barth
00021  *
00022  *  Purpose: Interface of class DcmPixelData
00023  *
00024  *  Last Update:      $Author: meichel $
00025  *  Update Date:      $Date: 2005/12/08 16:28:30 $
00026  *  CVS/RCS Revision: $Revision: 1.28 $
00027  *  Status:           $State: Exp $
00028  *
00029  *  CVS/RCS Log at end of file
00030  *
00031  */
00032 
00033 #ifndef DCPIXEL_H
00034 #define DCPIXEL_H
00035 
00036 #include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */
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 ** CVS/RCS Log:
00470 ** $Log: dcpixel.h,v $
00471 ** Revision 1.28  2005/12/08 16:28:30  meichel
00472 ** Changed include path schema for all DCMTK header files
00473 **
00474 ** Revision 1.27  2005/05/26 09:06:53  meichel
00475 ** Renamed isIconImage flag to alwaysUnencapsulated to clarify meaning.
00476 **   Added public method DcmPixelData::setNonEncapsulationFlag() that allows
00477 **   DcmCodec instances to enable the flag. Improved documentation.
00478 **
00479 ** Revision 1.26  2004/07/01 12:28:25  meichel
00480 ** Introduced virtual clone method for DcmObject and derived classes.
00481 **
00482 ** Revision 1.25  2004/04/07 13:55:56  meichel
00483 ** Compressed image datasets containing uncompressed icon images
00484 **   are now correctly handled by the parser.
00485 **
00486 ** Revision 1.24  2004/01/16 14:06:20  joergr
00487 ** Removed acknowledgements with e-mail addresses from CVS log.
00488 **
00489 ** Revision 1.23  2003/06/12 18:21:24  joergr
00490 ** Modified code to use const_iterators where appropriate (required for STL).
00491 **
00492 ** Revision 1.22  2003/06/12 14:03:24  joergr
00493 ** Fixed inconsistent API documentation reported by Doxygen.
00494 **
00495 ** Revision 1.21  2003/06/02 16:55:34  meichel
00496 ** Cleaned up implementation of DcmRepresentationEntry, added doc++ comments
00497 **
00498 ** Revision 1.20  2003/04/17 15:56:59  joergr
00499 ** Corrected API documentation of createUint8/16Array() methods.
00500 **
00501 ** Revision 1.19  2003/04/01 12:35:12  joergr
00502 ** Added implementation of createUint8/16Array() methods to DcmPixelData.
00503 ** Required to work properly with chooseRepresentation() for pixel compression.
00504 **
00505 ** Revision 1.18  2002/12/09 09:31:16  wilkens
00506 ** Modified/Added doc++ documentation.
00507 **
00508 ** Revision 1.17  2002/12/06 12:49:12  joergr
00509 ** Enhanced "print()" function by re-working the implementation and replacing
00510 ** the boolean "showFullData" parameter by a more general integer flag.
00511 ** Added doc++ documentation.
00512 ** Made source code formatting more consistent with other modules/files.
00513 **
00514 ** Revision 1.16  2002/08/27 16:55:37  meichel
00515 ** Initial release of new DICOM I/O stream classes that add support for stream
00516 **   compression (deflated little endian explicit VR transfer syntax)
00517 **
00518 ** Revision 1.15  2002/04/25 09:38:48  joergr
00519 ** Added support for XML output of DICOM objects.
00520 **
00521 ** Revision 1.14  2001/09/25 17:18:34  meichel
00522 ** Updated abstract class DcmRepresentationParameter for use with dcmjpeg
00523 **
00524 ** Revision 1.13  2001/06/01 15:48:42  meichel
00525 ** Updated copyright header
00526 **
00527 ** Revision 1.12  2000/11/07 16:56:08  meichel
00528 ** Initial release of dcmsign module for DICOM Digital Signatures
00529 **
00530 ** Revision 1.11  2000/09/27 08:19:55  meichel
00531 ** Minor changes in DcmCodec interface, required for future dcmjpeg module.
00532 **
00533 ** Revision 1.10  2000/04/14 15:31:33  meichel
00534 ** Removed default value from output stream passed to print() method.
00535 **   Required for use in multi-thread environments.
00536 **
00537 ** Revision 1.9  2000/03/08 16:26:17  meichel
00538 ** Updated copyright header.
00539 **
00540 ** Revision 1.8  2000/03/03 14:05:25  meichel
00541 ** Implemented library support for redirecting error messages into memory
00542 **   instead of printing them to stdout/stderr for GUI applications.
00543 **
00544 ** Revision 1.7  2000/02/10 10:50:52  joergr
00545 ** Added new feature to dcmdump (enhanced print method of dcmdata): write
00546 ** pixel data/item value fields to raw files.
00547 **
00548 ** Revision 1.6  2000/02/03 16:28:10  joergr
00549 ** Fixed bug: encapsulated data (pixel items) have never been loaded using
00550 ** method 'loadAllDataIntoMemory'. Therefore, encapsulated pixel data was
00551 ** never printed with 'dcmdump'.
00552 **
00553 ** Revision 1.5  1999/03/31 09:24:44  meichel
00554 ** Updated copyright header in module dcmdata
00555 **
00556 ** Revision 1.4  1998/11/12 16:47:42  meichel
00557 ** Implemented operator= for all classes derived from DcmObject.
00558 **
00559 ** Revision 1.3  1998/07/15 15:48:50  joergr
00560 ** Removed several compiler warnings reported by gcc 2.8.1 with
00561 ** additional options, e.g. missing copy constructors and assignment
00562 ** operators, initialization of member variables in the body of a
00563 ** constructor instead of the member initialization list, hiding of
00564 ** methods by use of identical names, uninitialized member variables,
00565 ** missing const declaration of char pointers. Replaced tabs by spaces.
00566 **
00567 ** Revision 1.2  1997/07/24 13:08:24  andreas
00568 ** - Removed const for method DcmRepresentationParameter::copy
00569 **
00570 ** Revision 1.1  1997/07/21 07:54:57  andreas
00571 ** - New environment for encapsulated pixel representations. DcmPixelData
00572 **   can contain different representations and uses codecs to convert
00573 **   between them. Codecs are derived from the DcmCodec class. New error
00574 **   codes are introduced for handling of representations. New internal
00575 **   value representation (only for ident()) for PixelData
00576 **
00577 */


Generated on 20 Dec 2005 for OFFIS DCMTK Version 3.5.4 by Doxygen 1.4.5