OFFIS DCMTK  Version 3.6.0
dcpixel.h
1 /*
2  *
3  * Copyright (C) 1994-2010, OFFIS e.V.
4  * All rights reserved. See COPYRIGHT file for details.
5  *
6  * This software and supporting documentation were developed by
7  *
8  * OFFIS e.V.
9  * R&D Division Health
10  * Escherweg 2
11  * D-26121 Oldenburg, Germany
12  *
13  *
14  * Module: dcmdata
15  *
16  * Author: Andreas Barth
17  *
18  * Purpose: Interface of class DcmPixelData
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2010-10-14 13:15:41 $
22  * CVS/RCS Revision: $Revision: 1.40 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 #ifndef DCPIXEL_H
30 #define DCPIXEL_H
31 
32 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
33 #include "dcmtk/dcmdata/dcvrpobw.h"
34 #include "dcmtk/ofstd/oflist.h"
35 
36 class DcmCodec;
37 class DcmCodecList;
38 class DcmItem;
39 class DcmPixelData;
40 class DcmPixelSequence;
42 class DcmStack;
43 
51 {
52 public:
55 
58 
61 
66  virtual DcmRepresentationParameter *clone() const = 0;
67 
71  virtual const char *className() const = 0;
72 
78  virtual OFBool operator==(const DcmRepresentationParameter &arg) const = 0;
79 };
80 
81 
89 {
98  const E_TransferSyntax rt,
99  const DcmRepresentationParameter * rp,
101 
104 
107 
109  OFBool operator==(const DcmRepresentationEntry& x) const;
110 
112  OFBool operator!=(const DcmRepresentationEntry & x) const
113  {
114  return !(*this == x);
115  }
116 
117 private:
120 
122  E_TransferSyntax repType;
123 
126 
129 
130  friend class DcmPixelData;
131 };
132 
135 
137 typedef OFListIterator(DcmRepresentationEntry *) DcmRepresentationListIterator;
138 
140 typedef OFListConstIterator(DcmRepresentationEntry *) DcmRepresentationListConstIterator;
141 
154 {
155 private:
156  friend class DcmRepresentationEntry;
157 
160 
162  DcmRepresentationListIterator repListEnd;
163 
166  DcmRepresentationListIterator original;
167 
169  DcmRepresentationListIterator current;
170 
173 
183 
186 
189 
197  void clearRepresentationList(
198  DcmRepresentationListIterator leaveInList);
199 
203  OFCondition findConformingEncapsulatedRepresentation(
204  const DcmXfer & repType,
206  DcmRepresentationListIterator & result);
207 
214  OFCondition findRepresentationEntry(
215  const DcmRepresentationEntry & findEntry,
216  DcmRepresentationListIterator & result);
217 
220  DcmRepresentationListIterator insertRepresentationEntry(
221  DcmRepresentationEntry * repEntry);
222 
225  OFCondition decode(
226  const DcmXfer & fromType,
227  const DcmRepresentationParameter * fromParam,
228  DcmPixelSequence * fromPixSeq,
229  DcmStack & pixelStack);
230 
233  OFCondition encode(
234  const DcmXfer & fromType,
235  const DcmRepresentationParameter * fromParam,
236  DcmPixelSequence * fromPixSeq,
237  const DcmXfer & toType,
238  const DcmRepresentationParameter *toParam,
239  DcmStack & pixelStack);
240 
244  void recalcVR()
245  {
246  if (current == repList.end()) setTagVR(unencapsulatedVR);
247  else setTagVR(EVR_OB);
248  }
249 
250 public:
251 
256  DcmPixelData(const DcmTag & tag, const Uint32 len = 0);
257 
261  DcmPixelData(const DcmPixelData & pixelData);
262 
264  virtual ~DcmPixelData();
265 
269  DcmPixelData &operator=(const DcmPixelData &obj);
270 
274  virtual DcmObject *clone() const
275  {
276  return new DcmPixelData(*this);
277  }
278 
291  virtual OFCondition copyFrom(const DcmObject& rhs);
292 
299  virtual OFCondition setVR(DcmEVR vr);
300 
307  virtual DcmEVR ident() const { return EVR_PixelData; }
308 
316  virtual void print(STD_NAMESPACE ostream&out,
317  const size_t flags = 0,
318  const int level = 0,
319  const char *pixelFileName = NULL,
320  size_t *pixelCounter = NULL);
321 
326  virtual OFBool canWriteXfer(const E_TransferSyntax newXfer,
327  const E_TransferSyntax oldXfer);
328 
334  virtual Uint32 calcElementLength(const E_TransferSyntax xfer,
335  const E_EncodingType enctype);
336 
342  virtual Uint32 getLength(
343  const E_TransferSyntax xfer = EXS_LittleEndianImplicit,
344  const E_EncodingType enctype = EET_UndefinedLength);
345 
349  virtual void transferInit();
350 
364  virtual OFCondition read(DcmInputStream & inStream,
365  const E_TransferSyntax ixfer,
366  const E_GrpLenEncoding glenc = EGL_noChange,
367  const Uint32 maxReadLength = DCM_MaxReadLength);
368 
374  virtual OFCondition write(
375  DcmOutputStream &outStream,
376  const E_TransferSyntax oxfer,
377  const E_EncodingType enctype,
378  DcmWriteCache *wcache);
379 
385  virtual OFCondition writeXML(STD_NAMESPACE ostream&out,
386  const size_t flags = 0);
387 
395  virtual OFCondition writeSignatureFormat(
396  DcmOutputStream &outStream,
397  const E_TransferSyntax oxfer,
398  const E_EncodingType enctype,
399  DcmWriteCache *wcache);
400 
408  virtual OFCondition loadAllDataIntoMemory(void);
409 
410 
414  virtual void transferEnd();
415 
418  OFBool canChooseRepresentation(
419  const E_TransferSyntax repType,
421 
427  OFCondition chooseRepresentation(
428  const E_TransferSyntax repType,
430  DcmStack & stack);
431 
435  void putOriginalRepresentation(
436  const E_TransferSyntax repType,
439 
444  virtual OFCondition putUint8Array(
445  const Uint8 * byteValue,
446  const unsigned long length);
447 
452  virtual OFCondition putUint16Array(
453  const Uint16 * wordValue,
454  const unsigned long length);
455 
458  virtual OFCondition createUint8Array(
459  const Uint32 numBytes,
460  Uint8 * & bytes);
461 
464  virtual OFCondition createUint16Array(
465  const Uint32 numWords,
466  Uint16 * & words);
467 
479  virtual OFCondition createValueFromTempFile(
480  DcmInputStreamFactory *factory,
481  const Uint32 length,
482  const E_ByteOrder byteOrder);
483 
488  OFCondition getEncapsulatedRepresentation(
489  const E_TransferSyntax repType,
492 
496  void getOriginalRepresentationKey(
497  E_TransferSyntax & repType,
499 
503  void getCurrentRepresentationKey(
504  E_TransferSyntax & repType,
506 
510  OFCondition setCurrentRepresentationParameter(
512 
515  OFBool hasRepresentation(
516  const E_TransferSyntax repType,
517  const DcmRepresentationParameter * repParam = NULL);
518 
522  OFCondition removeRepresentation(
523  const E_TransferSyntax repType,
525 
528  void removeAllButOriginalRepresentations();
529 
533  void removeAllButCurrentRepresentations();
534 
539  OFCondition removeOriginalRepresentation(
540  const E_TransferSyntax repType,
542 
554  void setNonEncapsulationFlag(OFBool flag);
555 
584  virtual OFCondition getUncompressedFrame(
585  DcmItem *dataset,
586  Uint32 frameNo,
587  Uint32& startFragment,
588  void *buffer,
589  Uint32 bufSize,
590  OFString& decompressedColorModel,
591  DcmFileCache *cache=NULL);
592 
601  virtual OFCondition getDecompressedColorModel(
602  DcmItem *dataset,
603  OFString &decompressedColorModel);
604 };
605 
606 #endif
607 
608 
609 /*
610 ** CVS/RCS Log:
611 ** $Log: dcpixel.h,v $
612 ** Revision 1.40 2010-10-14 13:15:41 joergr
613 ** Updated copyright header. Added reference to COPYRIGHT file.
614 **
615 ** Revision 1.39 2010-07-02 12:34:42 uli
616 ** Added comment explaining why an even buffer size is required.
617 **
618 ** Revision 1.38 2010-02-22 11:39:54 uli
619 ** Remove some unneeded includes.
620 **
621 ** Revision 1.37 2009-11-17 16:36:51 joergr
622 ** Added new method that allows for determining the color model of the
623 ** decompressed image.
624 **
625 ** Revision 1.36 2008-11-03 14:32:50 joergr
626 ** Added method createValueFromTempFile() - overrides method in DcmElement.
627 **
628 ** Revision 1.35 2008-07-17 11:19:49 onken
629 ** Updated copyFrom() documentation.
630 **
631 ** Revision 1.34 2008-07-17 10:30:23 onken
632 ** Implemented copyFrom() method for complete DcmObject class hierarchy, which
633 ** permits setting an instance's value from an existing object. Implemented
634 ** assignment operator where necessary.
635 **
636 ** Revision 1.33 2008-06-23 12:09:13 joergr
637 ** Fixed inconsistencies in Doxygen API documentation.
638 **
639 ** Revision 1.32 2008-05-29 10:46:13 meichel
640 ** Implemented new method DcmPixelData::getUncompressedFrame
641 ** that permits frame-wise access to compressed and uncompressed
642 ** objects without ever loading the complete object into main memory.
643 ** For this new method to work with compressed images, all classes derived from
644 ** DcmCodec need to implement a new method decodeFrame(). For now, only
645 ** dummy implementations returning an error code have been defined.
646 **
647 ** Revision 1.31 2007/11/29 14:30:19 meichel
648 ** Write methods now handle large raw data elements (such as pixel data)
649 ** without loading everything into memory. This allows very large images to
650 ** be sent over a network connection, or to be copied without ever being
651 ** fully in memory.
652 **
653 ** Revision 1.30 2007/06/29 14:17:49 meichel
654 ** Code clean-up: Most member variables in module dcmdata are now private,
655 ** not protected anymore.
656 **
657 ** Revision 1.29 2006/08/15 15:49:56 meichel
658 ** Updated all code in module dcmdata to correctly compile when
659 ** all standard C++ classes remain in namespace std.
660 **
661 ** Revision 1.28 2005/12/08 16:28:30 meichel
662 ** Changed include path schema for all DCMTK header files
663 **
664 ** Revision 1.27 2005/05/26 09:06:53 meichel
665 ** Renamed isIconImage flag to alwaysUnencapsulated to clarify meaning.
666 ** Added public method DcmPixelData::setNonEncapsulationFlag() that allows
667 ** DcmCodec instances to enable the flag. Improved documentation.
668 **
669 ** Revision 1.26 2004/07/01 12:28:25 meichel
670 ** Introduced virtual clone method for DcmObject and derived classes.
671 **
672 ** Revision 1.25 2004/04/07 13:55:56 meichel
673 ** Compressed image datasets containing uncompressed icon images
674 ** are now correctly handled by the parser.
675 **
676 ** Revision 1.24 2004/01/16 14:06:20 joergr
677 ** Removed acknowledgements with e-mail addresses from CVS log.
678 **
679 ** Revision 1.23 2003/06/12 18:21:24 joergr
680 ** Modified code to use const_iterators where appropriate (required for STL).
681 **
682 ** Revision 1.22 2003/06/12 14:03:24 joergr
683 ** Fixed inconsistent API documentation reported by Doxygen.
684 **
685 ** Revision 1.21 2003/06/02 16:55:34 meichel
686 ** Cleaned up implementation of DcmRepresentationEntry, added doc++ comments
687 **
688 ** Revision 1.20 2003/04/17 15:56:59 joergr
689 ** Corrected API documentation of createUint8/16Array() methods.
690 **
691 ** Revision 1.19 2003/04/01 12:35:12 joergr
692 ** Added implementation of createUint8/16Array() methods to DcmPixelData.
693 ** Required to work properly with chooseRepresentation() for pixel compression.
694 **
695 ** Revision 1.18 2002/12/09 09:31:16 wilkens
696 ** Modified/Added doc++ documentation.
697 **
698 ** Revision 1.17 2002/12/06 12:49:12 joergr
699 ** Enhanced "print()" function by re-working the implementation and replacing
700 ** the boolean "showFullData" parameter by a more general integer flag.
701 ** Added doc++ documentation.
702 ** Made source code formatting more consistent with other modules/files.
703 **
704 ** Revision 1.16 2002/08/27 16:55:37 meichel
705 ** Initial release of new DICOM I/O stream classes that add support for stream
706 ** compression (deflated little endian explicit VR transfer syntax)
707 **
708 ** Revision 1.15 2002/04/25 09:38:48 joergr
709 ** Added support for XML output of DICOM objects.
710 **
711 ** Revision 1.14 2001/09/25 17:18:34 meichel
712 ** Updated abstract class DcmRepresentationParameter for use with dcmjpeg
713 **
714 ** Revision 1.13 2001/06/01 15:48:42 meichel
715 ** Updated copyright header
716 **
717 ** Revision 1.12 2000/11/07 16:56:08 meichel
718 ** Initial release of dcmsign module for DICOM Digital Signatures
719 **
720 ** Revision 1.11 2000/09/27 08:19:55 meichel
721 ** Minor changes in DcmCodec interface, required for future dcmjpeg module.
722 **
723 ** Revision 1.10 2000/04/14 15:31:33 meichel
724 ** Removed default value from output stream passed to print() method.
725 ** Required for use in multi-thread environments.
726 **
727 ** Revision 1.9 2000/03/08 16:26:17 meichel
728 ** Updated copyright header.
729 **
730 ** Revision 1.8 2000/03/03 14:05:25 meichel
731 ** Implemented library support for redirecting error messages into memory
732 ** instead of printing them to stdout/stderr for GUI applications.
733 **
734 ** Revision 1.7 2000/02/10 10:50:52 joergr
735 ** Added new feature to dcmdump (enhanced print method of dcmdata): write
736 ** pixel data/item value fields to raw files.
737 **
738 ** Revision 1.6 2000/02/03 16:28:10 joergr
739 ** Fixed bug: encapsulated data (pixel items) have never been loaded using
740 ** method 'loadAllDataIntoMemory'. Therefore, encapsulated pixel data was
741 ** never printed with 'dcmdump'.
742 **
743 ** Revision 1.5 1999/03/31 09:24:44 meichel
744 ** Updated copyright header in module dcmdata
745 **
746 ** Revision 1.4 1998/11/12 16:47:42 meichel
747 ** Implemented operator= for all classes derived from DcmObject.
748 **
749 ** Revision 1.3 1998/07/15 15:48:50 joergr
750 ** Removed several compiler warnings reported by gcc 2.8.1 with
751 ** additional options, e.g. missing copy constructors and assignment
752 ** operators, initialization of member variables in the body of a
753 ** constructor instead of the member initialization list, hiding of
754 ** methods by use of identical names, uninitialized member variables,
755 ** missing const declaration of char pointers. Replaced tabs by spaces.
756 **
757 ** Revision 1.2 1997/07/24 13:08:24 andreas
758 ** - Removed const for method DcmRepresentationParameter::copy
759 **
760 ** Revision 1.1 1997/07/21 07:54:57 andreas
761 ** - New environment for encapsulated pixel representations. DcmPixelData
762 ** can contain different representations and uses codecs to convert
763 ** between them. Codecs are derived from the DcmCodec class. New error
764 ** codes are introduced for handling of representations. New internal
765 ** value representation (only for ident()) for PixelData
766 **
767 */


Generated on Thu Dec 20 2012 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.2