dcmdata/include/dcmtk/dcmdata/dcpixel.h

00001 /*
00002  *
00003  *  Copyright (C) 1994-2010, OFFIS e.V.
00004  *  All rights reserved.  See COPYRIGHT file for details.
00005  *
00006  *  This software and supporting documentation were developed by
00007  *
00008  *    OFFIS e.V.
00009  *    R&D Division Health
00010  *    Escherweg 2
00011  *    D-26121 Oldenburg, Germany
00012  *
00013  *
00014  *  Module:  dcmdata
00015  *
00016  *  Author:  Andreas Barth
00017  *
00018  *  Purpose: Interface of class DcmPixelData
00019  *
00020  *  Last Update:      $Author: joergr $
00021  *  Update Date:      $Date: 2010-10-14 13:15:41 $
00022  *  CVS/RCS Revision: $Revision: 1.40 $
00023  *  Status:           $State: Exp $
00024  *
00025  *  CVS/RCS Log at end of file
00026  *
00027  */
00028 
00029 #ifndef DCPIXEL_H
00030 #define DCPIXEL_H
00031 
00032 #include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */
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 ** CVS/RCS Log:
00611 ** $Log: dcpixel.h,v $
00612 ** Revision 1.40  2010-10-14 13:15:41  joergr
00613 ** Updated copyright header. Added reference to COPYRIGHT file.
00614 **
00615 ** Revision 1.39  2010-07-02 12:34:42  uli
00616 ** Added comment explaining why an even buffer size is required.
00617 **
00618 ** Revision 1.38  2010-02-22 11:39:54  uli
00619 ** Remove some unneeded includes.
00620 **
00621 ** Revision 1.37  2009-11-17 16:36:51  joergr
00622 ** Added new method that allows for determining the color model of the
00623 ** decompressed image.
00624 **
00625 ** Revision 1.36  2008-11-03 14:32:50  joergr
00626 ** Added method createValueFromTempFile() - overrides method in DcmElement.
00627 **
00628 ** Revision 1.35  2008-07-17 11:19:49  onken
00629 ** Updated copyFrom() documentation.
00630 **
00631 ** Revision 1.34  2008-07-17 10:30:23  onken
00632 ** Implemented copyFrom() method for complete DcmObject class hierarchy, which
00633 ** permits setting an instance's value from an existing object. Implemented
00634 ** assignment operator where necessary.
00635 **
00636 ** Revision 1.33  2008-06-23 12:09:13  joergr
00637 ** Fixed inconsistencies in Doxygen API documentation.
00638 **
00639 ** Revision 1.32  2008-05-29 10:46:13  meichel
00640 ** Implemented new method DcmPixelData::getUncompressedFrame
00641 **   that permits frame-wise access to compressed and uncompressed
00642 **   objects without ever loading the complete object into main memory.
00643 **   For this new method to work with compressed images, all classes derived from
00644 **   DcmCodec need to implement a new method decodeFrame(). For now, only
00645 **   dummy implementations returning an error code have been defined.
00646 **
00647 ** Revision 1.31  2007/11/29 14:30:19  meichel
00648 ** Write methods now handle large raw data elements (such as pixel data)
00649 **   without loading everything into memory. This allows very large images to
00650 **   be sent over a network connection, or to be copied without ever being
00651 **   fully in memory.
00652 **
00653 ** Revision 1.30  2007/06/29 14:17:49  meichel
00654 ** Code clean-up: Most member variables in module dcmdata are now private,
00655 **   not protected anymore.
00656 **
00657 ** Revision 1.29  2006/08/15 15:49:56  meichel
00658 ** Updated all code in module dcmdata to correctly compile when
00659 **   all standard C++ classes remain in namespace std.
00660 **
00661 ** Revision 1.28  2005/12/08 16:28:30  meichel
00662 ** Changed include path schema for all DCMTK header files
00663 **
00664 ** Revision 1.27  2005/05/26 09:06:53  meichel
00665 ** Renamed isIconImage flag to alwaysUnencapsulated to clarify meaning.
00666 **   Added public method DcmPixelData::setNonEncapsulationFlag() that allows
00667 **   DcmCodec instances to enable the flag. Improved documentation.
00668 **
00669 ** Revision 1.26  2004/07/01 12:28:25  meichel
00670 ** Introduced virtual clone method for DcmObject and derived classes.
00671 **
00672 ** Revision 1.25  2004/04/07 13:55:56  meichel
00673 ** Compressed image datasets containing uncompressed icon images
00674 **   are now correctly handled by the parser.
00675 **
00676 ** Revision 1.24  2004/01/16 14:06:20  joergr
00677 ** Removed acknowledgements with e-mail addresses from CVS log.
00678 **
00679 ** Revision 1.23  2003/06/12 18:21:24  joergr
00680 ** Modified code to use const_iterators where appropriate (required for STL).
00681 **
00682 ** Revision 1.22  2003/06/12 14:03:24  joergr
00683 ** Fixed inconsistent API documentation reported by Doxygen.
00684 **
00685 ** Revision 1.21  2003/06/02 16:55:34  meichel
00686 ** Cleaned up implementation of DcmRepresentationEntry, added doc++ comments
00687 **
00688 ** Revision 1.20  2003/04/17 15:56:59  joergr
00689 ** Corrected API documentation of createUint8/16Array() methods.
00690 **
00691 ** Revision 1.19  2003/04/01 12:35:12  joergr
00692 ** Added implementation of createUint8/16Array() methods to DcmPixelData.
00693 ** Required to work properly with chooseRepresentation() for pixel compression.
00694 **
00695 ** Revision 1.18  2002/12/09 09:31:16  wilkens
00696 ** Modified/Added doc++ documentation.
00697 **
00698 ** Revision 1.17  2002/12/06 12:49:12  joergr
00699 ** Enhanced "print()" function by re-working the implementation and replacing
00700 ** the boolean "showFullData" parameter by a more general integer flag.
00701 ** Added doc++ documentation.
00702 ** Made source code formatting more consistent with other modules/files.
00703 **
00704 ** Revision 1.16  2002/08/27 16:55:37  meichel
00705 ** Initial release of new DICOM I/O stream classes that add support for stream
00706 **   compression (deflated little endian explicit VR transfer syntax)
00707 **
00708 ** Revision 1.15  2002/04/25 09:38:48  joergr
00709 ** Added support for XML output of DICOM objects.
00710 **
00711 ** Revision 1.14  2001/09/25 17:18:34  meichel
00712 ** Updated abstract class DcmRepresentationParameter for use with dcmjpeg
00713 **
00714 ** Revision 1.13  2001/06/01 15:48:42  meichel
00715 ** Updated copyright header
00716 **
00717 ** Revision 1.12  2000/11/07 16:56:08  meichel
00718 ** Initial release of dcmsign module for DICOM Digital Signatures
00719 **
00720 ** Revision 1.11  2000/09/27 08:19:55  meichel
00721 ** Minor changes in DcmCodec interface, required for future dcmjpeg module.
00722 **
00723 ** Revision 1.10  2000/04/14 15:31:33  meichel
00724 ** Removed default value from output stream passed to print() method.
00725 **   Required for use in multi-thread environments.
00726 **
00727 ** Revision 1.9  2000/03/08 16:26:17  meichel
00728 ** Updated copyright header.
00729 **
00730 ** Revision 1.8  2000/03/03 14:05:25  meichel
00731 ** Implemented library support for redirecting error messages into memory
00732 **   instead of printing them to stdout/stderr for GUI applications.
00733 **
00734 ** Revision 1.7  2000/02/10 10:50:52  joergr
00735 ** Added new feature to dcmdump (enhanced print method of dcmdata): write
00736 ** pixel data/item value fields to raw files.
00737 **
00738 ** Revision 1.6  2000/02/03 16:28:10  joergr
00739 ** Fixed bug: encapsulated data (pixel items) have never been loaded using
00740 ** method 'loadAllDataIntoMemory'. Therefore, encapsulated pixel data was
00741 ** never printed with 'dcmdump'.
00742 **
00743 ** Revision 1.5  1999/03/31 09:24:44  meichel
00744 ** Updated copyright header in module dcmdata
00745 **
00746 ** Revision 1.4  1998/11/12 16:47:42  meichel
00747 ** Implemented operator= for all classes derived from DcmObject.
00748 **
00749 ** Revision 1.3  1998/07/15 15:48:50  joergr
00750 ** Removed several compiler warnings reported by gcc 2.8.1 with
00751 ** additional options, e.g. missing copy constructors and assignment
00752 ** operators, initialization of member variables in the body of a
00753 ** constructor instead of the member initialization list, hiding of
00754 ** methods by use of identical names, uninitialized member variables,
00755 ** missing const declaration of char pointers. Replaced tabs by spaces.
00756 **
00757 ** Revision 1.2  1997/07/24 13:08:24  andreas
00758 ** - Removed const for method DcmRepresentationParameter::copy
00759 **
00760 ** Revision 1.1  1997/07/21 07:54:57  andreas
00761 ** - New environment for encapsulated pixel representations. DcmPixelData
00762 **   can contain different representations and uses codecs to convert
00763 **   between them. Codecs are derived from the DcmCodec class. New error
00764 **   codes are introduced for handling of representations. New internal
00765 **   value representation (only for ident()) for PixelData
00766 **
00767 */


Generated on 6 Jan 2011 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.5.1