Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages

dcpixel.h

00001 /*
00002  *
00003  *  Copyright (C) 1994-2004, 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: 2004/04/07 13:55:56 $
00026  *  CVS/RCS Revision: $Revision: 1.25 $
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 "osconfig.h"    /* make sure OS specific configuration is included first */
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 ** CVS/RCS Log:
00443 ** $Log: dcpixel.h,v $
00444 ** Revision 1.25  2004/04/07 13:55:56  meichel
00445 ** Compressed image datasets containing uncompressed icon images
00446 **   are now correctly handled by the parser.
00447 **
00448 ** Revision 1.24  2004/01/16 14:06:20  joergr
00449 ** Removed acknowledgements with e-mail addresses from CVS log.
00450 **
00451 ** Revision 1.23  2003/06/12 18:21:24  joergr
00452 ** Modified code to use const_iterators where appropriate (required for STL).
00453 **
00454 ** Revision 1.22  2003/06/12 14:03:24  joergr
00455 ** Fixed inconsistent API documentation reported by Doxygen.
00456 **
00457 ** Revision 1.21  2003/06/02 16:55:34  meichel
00458 ** Cleaned up implementation of DcmRepresentationEntry, added doc++ comments
00459 **
00460 ** Revision 1.20  2003/04/17 15:56:59  joergr
00461 ** Corrected API documentation of createUint8/16Array() methods.
00462 **
00463 ** Revision 1.19  2003/04/01 12:35:12  joergr
00464 ** Added implementation of createUint8/16Array() methods to DcmPixelData.
00465 ** Required to work properly with chooseRepresentation() for pixel compression.
00466 **
00467 ** Revision 1.18  2002/12/09 09:31:16  wilkens
00468 ** Modified/Added doc++ documentation.
00469 **
00470 ** Revision 1.17  2002/12/06 12:49:12  joergr
00471 ** Enhanced "print()" function by re-working the implementation and replacing
00472 ** the boolean "showFullData" parameter by a more general integer flag.
00473 ** Added doc++ documentation.
00474 ** Made source code formatting more consistent with other modules/files.
00475 **
00476 ** Revision 1.16  2002/08/27 16:55:37  meichel
00477 ** Initial release of new DICOM I/O stream classes that add support for stream
00478 **   compression (deflated little endian explicit VR transfer syntax)
00479 **
00480 ** Revision 1.15  2002/04/25 09:38:48  joergr
00481 ** Added support for XML output of DICOM objects.
00482 **
00483 ** Revision 1.14  2001/09/25 17:18:34  meichel
00484 ** Updated abstract class DcmRepresentationParameter for use with dcmjpeg
00485 **
00486 ** Revision 1.13  2001/06/01 15:48:42  meichel
00487 ** Updated copyright header
00488 **
00489 ** Revision 1.12  2000/11/07 16:56:08  meichel
00490 ** Initial release of dcmsign module for DICOM Digital Signatures
00491 **
00492 ** Revision 1.11  2000/09/27 08:19:55  meichel
00493 ** Minor changes in DcmCodec interface, required for future dcmjpeg module.
00494 **
00495 ** Revision 1.10  2000/04/14 15:31:33  meichel
00496 ** Removed default value from output stream passed to print() method.
00497 **   Required for use in multi-thread environments.
00498 **
00499 ** Revision 1.9  2000/03/08 16:26:17  meichel
00500 ** Updated copyright header.
00501 **
00502 ** Revision 1.8  2000/03/03 14:05:25  meichel
00503 ** Implemented library support for redirecting error messages into memory
00504 **   instead of printing them to stdout/stderr for GUI applications.
00505 **
00506 ** Revision 1.7  2000/02/10 10:50:52  joergr
00507 ** Added new feature to dcmdump (enhanced print method of dcmdata): write
00508 ** pixel data/item value fields to raw files.
00509 **
00510 ** Revision 1.6  2000/02/03 16:28:10  joergr
00511 ** Fixed bug: encapsulated data (pixel items) have never been loaded using
00512 ** method 'loadAllDataIntoMemory'. Therefore, encapsulated pixel data was
00513 ** never printed with 'dcmdump'.
00514 **
00515 ** Revision 1.5  1999/03/31 09:24:44  meichel
00516 ** Updated copyright header in module dcmdata
00517 **
00518 ** Revision 1.4  1998/11/12 16:47:42  meichel
00519 ** Implemented operator= for all classes derived from DcmObject.
00520 **
00521 ** Revision 1.3  1998/07/15 15:48:50  joergr
00522 ** Removed several compiler warnings reported by gcc 2.8.1 with
00523 ** additional options, e.g. missing copy constructors and assignment
00524 ** operators, initialization of member variables in the body of a
00525 ** constructor instead of the member initialization list, hiding of
00526 ** methods by use of identical names, uninitialized member variables,
00527 ** missing const declaration of char pointers. Replaced tabs by spaces.
00528 **
00529 ** Revision 1.2  1997/07/24 13:08:24  andreas
00530 ** - Removed const for method DcmRepresentationParameter::copy
00531 **
00532 ** Revision 1.1  1997/07/21 07:54:57  andreas
00533 ** - New environment for encapsulated pixel representations. DcmPixelData
00534 **   can contain different representations and uses codecs to convert
00535 **   between them. Codecs are derived from the DcmCodec class. New error
00536 **   codes are introduced for handling of representations. New internal
00537 **   value representation (only for ident()) for PixelData
00538 **
00539 */
00540 
00541 
00542 
00543 


Generated on 26 Apr 2005 for OFFIS DCMTK Version 3.5.3 by Doxygen 1.4.2