OFFIS DCMTK  Version 3.6.0
dcfilefo.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: Gerd Ehlers, Andreas Barth
17  *
18  * Purpose: Interface of class DcmFileFormat
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2010-10-20 16:34:08 $
22  * CVS/RCS Revision: $Revision: 1.38 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 
30 #ifndef DCFILEFO_H
31 #define DCFILEFO_H
32 
33 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
34 
35 #include "dcmtk/dcmdata/dcsequen.h"
36 #include "dcmtk/dcmdata/dcdatset.h"
37 
38 
39 // forward declarations
40 class DcmMetaInfo;
41 class DcmInputStream;
42 class DcmOutputStream;
44 
45 
49  : public DcmSequenceOfItems
50 {
51 
52  public:
53 
56  DcmFileFormat();
57 
61  DcmFileFormat(DcmDataset *dataset);
62 
66  DcmFileFormat(const DcmFileFormat &old);
67 
70  virtual ~DcmFileFormat();
71 
77 
81  virtual DcmObject *clone() const
82  {
83  return new DcmFileFormat(*this);
84  }
85 
98  virtual OFCondition copyFrom(const DcmObject& rhs);
99 
103  virtual DcmEVR ident() const;
104 
108  virtual OFCondition clear();
109 
113  virtual void removeInvalidGroups();
114 
122  virtual void print(STD_NAMESPACE ostream&out,
123  const size_t flags = 0,
124  const int level = 0,
125  const char *pixelFileName = NULL,
126  size_t *pixelCounter = NULL);
127 
133  virtual OFCondition validateMetaInfo(const E_TransferSyntax oxfer,
134  const E_FileWriteMode writeMode = EWM_fileformat);
135 
140 
145 
151 
162  virtual Uint32 calcElementLength(const E_TransferSyntax xfer,
163  const E_EncodingType enctype);
164 
170  virtual OFBool canWriteXfer(const E_TransferSyntax newXfer,
171  const E_TransferSyntax oldXfer = EXS_Unknown);
172 
182  virtual OFCondition read(DcmInputStream &inStream,
183  const E_TransferSyntax xfer = EXS_Unknown,
184  const E_GrpLenEncoding glenc = EGL_noChange,
185  const Uint32 maxReadLength = DCM_MaxReadLength);
186 
194  virtual OFCondition write(DcmOutputStream &outStream,
195  const E_TransferSyntax oxfer,
196  const E_EncodingType enctype,
197  DcmWriteCache *wcache);
198 
216  virtual OFCondition write(DcmOutputStream &outStream,
217  const E_TransferSyntax oxfer,
218  const E_EncodingType enctype,
219  DcmWriteCache *wcache,
220  const E_GrpLenEncoding glenc,
221  const E_PaddingEncoding padenc = EPD_noChange,
222  const Uint32 padlen = 0,
223  const Uint32 subPadlen = 0,
224  Uint32 instanceLength = 0,
225  const E_FileWriteMode writeMode = EWM_fileformat);
226 
233  virtual OFCondition writeXML(STD_NAMESPACE ostream&out,
234  const size_t flags = 0);
235 
250  virtual OFCondition loadFile(const char *fileName,
251  const E_TransferSyntax readXfer = EXS_Unknown,
252  const E_GrpLenEncoding groupLength = EGL_noChange,
253  const Uint32 maxReadLength = DCM_MaxReadLength,
254  const E_FileReadMode readMode = ERM_autoDetect);
255 
268  virtual OFCondition saveFile(const char *fileName,
269  const E_TransferSyntax writeXfer = EXS_Unknown,
270  const E_EncodingType encodingType = EET_UndefinedLength,
271  const E_GrpLenEncoding groupLength = EGL_recalcGL,
272  const E_PaddingEncoding padEncoding = EPD_noChange,
273  const Uint32 padLength = 0,
274  const Uint32 subPadLength = 0,
275  const E_FileWriteMode writeMode = EWM_fileformat);
276 
277  // methods for different pixel representations
278 
286  OFCondition chooseRepresentation(const E_TransferSyntax repType,
287  const DcmRepresentationParameter *repParam)
288  {
289  return getDataset()->chooseRepresentation(repType, repParam);
290  }
291 
299  OFBool hasRepresentation(const E_TransferSyntax repType,
300  const DcmRepresentationParameter *repParam)
301  {
302  return getDataset()->hasRepresentation(repType, repParam);
303  }
304 
308  {
310  }
311 
316  {
318  }
319 
325  E_FileReadMode getReadMode() const
326  {
327  return FileReadMode;
328  }
329 
335  void setReadMode(const E_FileReadMode readMode)
336  {
337  FileReadMode = readMode;
338  }
339 
346  virtual OFCondition insertItem(DcmItem *item, const unsigned long where = DCM_EndOfListIndex);
347 
353  virtual DcmItem *remove(const unsigned long num);
354 
360  virtual DcmItem *remove(DcmItem *item);
361 
362  private:
363 
377  DcmDataset *dataset,
378  const DcmTagKey &atagkey,
379  DcmObject *obj,
380  const E_TransferSyntax oxfer,
381  const E_FileWriteMode writeMode);
382 
387  static E_TransferSyntax lookForXfer(DcmMetaInfo *metainfo);
388 
390  E_FileReadMode FileReadMode;
391 };
392 
393 
394 #endif // DCFILEFO_H
395 
396 
397 /*
398 ** CVS/RCS Log:
399 ** $Log: dcfilefo.h,v $
400 ** Revision 1.38 2010-10-20 16:34:08 joergr
401 ** Renamed method to avoid warnings reported by gcc with additional flags.
402 **
403 ** Revision 1.37 2010-10-20 16:31:25 joergr
404 ** Added missing API documentation.
405 **
406 ** Revision 1.36 2010-10-14 13:15:41 joergr
407 ** Updated copyright header. Added reference to COPYRIGHT file.
408 **
409 ** Revision 1.35 2010-10-08 08:37:01 joergr
410 ** Enhanced documentation on pixel-related parameters.
411 **
412 ** Revision 1.34 2010-03-01 09:08:44 uli
413 ** Removed some unnecessary include directives in the headers.
414 **
415 ** Revision 1.33 2010-02-22 11:39:53 uli
416 ** Remove some unneeded includes.
417 **
418 ** Revision 1.32 2009-08-25 13:00:23 joergr
419 ** Added new methods which remove all data elements with an invalid group number
420 ** from the meta information header, dataset and/or fileformat.
421 ** Fixed wrong comment on clear() method.
422 **
423 ** Revision 1.31 2009-08-21 09:18:07 joergr
424 ** Added parameter 'writeMode' to save/write methods which allows for specifying
425 ** whether to write a dataset or fileformat as well as whether to update the
426 ** file meta information or to create a new file meta information header.
427 **
428 ** Revision 1.30 2008-07-17 11:19:48 onken
429 ** Updated copyFrom() documentation.
430 **
431 ** Revision 1.29 2008-07-17 10:30:23 onken
432 ** Implemented copyFrom() method for complete DcmObject class hierarchy, which
433 ** permits setting an instance's value from an existing object. Implemented
434 ** assignment operator where necessary.
435 **
436 ** Revision 1.28 2008-06-23 12:09:13 joergr
437 ** Fixed inconsistencies in Doxygen API documentation.
438 **
439 ** Revision 1.27 2007/11/29 14:30:19 meichel
440 ** Write methods now handle large raw data elements (such as pixel data)
441 ** without loading everything into memory. This allows very large images to
442 ** be sent over a network connection, or to be copied without ever being
443 ** fully in memory.
444 **
445 ** Revision 1.26 2006/08/15 15:49:56 meichel
446 ** Updated all code in module dcmdata to correctly compile when
447 ** all standard C++ classes remain in namespace std.
448 **
449 ** Revision 1.25 2005/12/08 16:28:13 meichel
450 ** Changed include path schema for all DCMTK header files
451 **
452 ** Revision 1.24 2005/12/02 08:48:17 joergr
453 ** Added new file read mode that makes it possible to distinguish between DICOM
454 ** files, datasets and other non-DICOM files. For this reason, the last
455 ** parameter of method loadFile() changed from OFBool to E_FileReadMode.
456 **
457 ** Revision 1.23 2004/07/01 12:28:25 meichel
458 ** Introduced virtual clone method for DcmObject and derived classes.
459 **
460 ** Revision 1.22 2002/12/06 12:49:10 joergr
461 ** Enhanced "print()" function by re-working the implementation and replacing
462 ** the boolean "showFullData" parameter by a more general integer flag.
463 ** Added doc++ documentation.
464 ** Made source code formatting more consistent with other modules/files.
465 **
466 ** Revision 1.21 2002/08/27 16:55:32 meichel
467 ** Initial release of new DICOM I/O stream classes that add support for stream
468 ** compression (deflated little endian explicit VR transfer syntax)
469 **
470 ** Revision 1.20 2002/08/20 12:18:35 meichel
471 ** Changed parameter list of loadFile and saveFile methods in class
472 ** DcmFileFormat. Removed loadFile and saveFile from class DcmObject.
473 **
474 ** Revision 1.19 2002/04/25 09:39:47 joergr
475 ** Added support for XML output of DICOM objects.
476 **
477 ** Revision 1.18 2002/04/11 12:22:51 joergr
478 ** Added new methods for loading and saving DICOM files.
479 **
480 ** Revision 1.17 2001/09/25 17:19:26 meichel
481 ** Adapted dcmdata to class OFCondition
482 **
483 ** Revision 1.16 2001/06/01 15:48:40 meichel
484 ** Updated copyright header
485 **
486 ** Revision 1.15 2000/04/14 15:31:32 meichel
487 ** Removed default value from output stream passed to print() method.
488 ** Required for use in multi-thread environments.
489 **
490 ** Revision 1.14 2000/03/08 16:26:14 meichel
491 ** Updated copyright header.
492 **
493 ** Revision 1.13 2000/03/03 14:05:23 meichel
494 ** Implemented library support for redirecting error messages into memory
495 ** instead of printing them to stdout/stderr for GUI applications.
496 **
497 ** Revision 1.12 2000/02/10 10:50:51 joergr
498 ** Added new feature to dcmdump (enhanced print method of dcmdata): write
499 ** pixel data/item value fields to raw files.
500 **
501 ** Revision 1.11 1999/03/31 09:24:38 meichel
502 ** Updated copyright header in module dcmdata
503 **
504 ** Revision 1.10 1998/11/12 16:47:39 meichel
505 ** Implemented operator= for all classes derived from DcmObject.
506 **
507 ** Revision 1.9 1997/07/21 08:14:39 andreas
508 ** - New environment for encapsulated pixel representations. DcmPixelData
509 ** can contain different representations and uses codecs to convert
510 ** between them. Codecs are derived from the DcmCodec class. New error
511 ** codes are introduced for handling of representations. New internal
512 ** value representation (only for ident()) for PixelData
513 ** - Replace all boolean types (BOOLEAN, CTNBOOLEAN, DICOM_BOOL, BOOL)
514 ** with one unique boolean type OFBool.
515 **
516 ** Revision 1.8 1997/05/27 13:48:27 andreas
517 ** - Add method canWriteXfer to class DcmObject and all derived classes.
518 ** This method checks whether it is possible to convert the original
519 ** transfer syntax to an new transfer syntax. The check is used in the
520 ** dcmconv utility to prohibit the change of a compressed transfer
521 ** syntax to a uncompressed.
522 **
523 ** Revision 1.7 1997/05/16 08:23:47 andreas
524 ** - Revised handling of GroupLength elements and support of
525 ** DataSetTrailingPadding elements. The enumeratio E_GrpLenEncoding
526 ** got additional enumeration values (for a description see dctypes.h).
527 ** addGroupLength and removeGroupLength methods are replaced by
528 ** computeGroupLengthAndPadding. To support Padding, the parameters of
529 ** element and sequence write functions changed.
530 ** - Added a new method calcElementLength to calculate the length of an
531 ** element, item or sequence. For elements it returns the length of
532 ** tag, length field, vr field, and value length, for item and
533 ** sequences it returns the length of the whole item. sequence including
534 ** the Delimitation tag (if appropriate). It can never return
535 ** UndefinedLength.
536 **
537 ** Revision 1.6 1996/08/05 08:45:21 andreas
538 ** new print routine with additional parameters:
539 ** - print into files
540 ** - fix output length for elements
541 ** corrected error in search routine with parameter ESM_fromStackTop
542 **
543 ** Revision 1.5 1996/07/29 15:46:23 andreas
544 ** Add method getAndRemoveDataset to remove connection of dataset from fileformat
545 **
546 ** Revision 1.4 1996/01/09 11:06:15 andreas
547 ** New Support for Visual C++
548 ** Correct problems with inconsistent const declarations
549 **
550 ** Revision 1.3 1996/01/05 13:22:55 andreas
551 ** - changed to support new streaming facilities
552 ** - more cleanups
553 ** - merged read / write methods for block and file transfer
554 **
555 */
OFCondition chooseRepresentation(const E_TransferSyntax repType, const DcmRepresentationParameter *repParam)
select a specific representation (compressed or uncompressed) of the dataset and create the represent...
Definition: dcfilefo.h:286
a class representing a list of DICOM elements in which each element has a different tag and elements ...
Definition: dcitem.h:51
class maintaining a attribute tag (group and element number)
Definition: dctagkey.h:46
virtual DcmEVR ident() const
get type identifier
virtual Uint32 calcElementLength(const E_TransferSyntax xfer, const E_EncodingType enctype)
calculate the length of this DICOM element when encoded with the given transfer syntax and the given ...
void removeAllButCurrentRepresentations()
removes all but the current representation in all pixel data elements.
Definition: dcfilefo.h:315
virtual OFCondition clear()
clear file meta information header and dataset
class representing a DICOM Sequence of Items (SQ).
Definition: dcsequen.h:47
virtual OFCondition write(DcmOutputStream &outStream, const E_TransferSyntax oxfer, const E_EncodingType enctype, DcmWriteCache *wcache)
write fileformat to a stream
virtual void print(STD_NAMESPACE ostream &out, const size_t flags=0, const int level=0, const char *pixelFileName=NULL, size_t *pixelCounter=NULL)
print meta header and dataset to a stream
abstract base class for codec representation parameter sets.
Definition: dcpixel.h:50
virtual OFCondition loadFile(const char *fileName, const E_TransferSyntax readXfer=EXS_Unknown, const E_GrpLenEncoding groupLength=EGL_noChange, const Uint32 maxReadLength=DCM_MaxReadLength, const E_FileReadMode readMode=ERM_autoDetect)
load object from a DICOM file.
a class handling the DICOM file format (with meta header)
Definition: dcfilefo.h:48
E_FileReadMode getReadMode() const
get current file read mode.
Definition: dcfilefo.h:325
This class implements a buffering mechanism that is used when writing large elements that reside in f...
Definition: dcwcache.h:50
DcmFileFormat & operator=(const DcmFileFormat &obj)
assignment operator
base class for output streams.
Definition: dcostrma.h:119
Abstract base class for most classes in module dcmdata.
Definition: dcobject.h:179
void removeAllButCurrentRepresentations()
removes all but the current representation and sets the original representation to current ...
static E_TransferSyntax lookForXfer(DcmMetaInfo *metainfo)
read DCM_TransferSyntaxUID from meta header dataset and return as E_TransferSyntax value ...
DcmDataset * getAndRemoveDataset()
get dataset part and remove it from the fileformat.
virtual OFBool canWriteXfer(const E_TransferSyntax newXfer, const E_TransferSyntax oldXfer=EXS_Unknown)
check if this DICOM object can be encoded in the given transfer syntax.
void removeAllButOriginalRepresentations()
removes all but the original representation in all pixel data elements
static OFCondition checkMetaHeaderValue(DcmMetaInfo *metainfo, DcmDataset *dataset, const DcmTagKey &atagkey, DcmObject *obj, const E_TransferSyntax oxfer, const E_FileWriteMode writeMode)
This function checks if a particular data element of the file meta information header is existent...
virtual OFCondition saveFile(const char *fileName, const E_TransferSyntax writeXfer=EXS_Unknown, const E_EncodingType encodingType=EET_UndefinedLength, const E_GrpLenEncoding groupLength=EGL_recalcGL, const E_PaddingEncoding padEncoding=EPD_noChange, const Uint32 padLength=0, const Uint32 subPadLength=0, const E_FileWriteMode writeMode=EWM_fileformat)
save object to a DICOM file.
virtual void removeInvalidGroups()
remove all elements with an invalid group number from the meta information header and dataset ...
OFCondition chooseRepresentation(const E_TransferSyntax repType, const DcmRepresentationParameter *repParam)
select a specific representation (compressed or uncompressed) of the dataset and create the represent...
virtual OFCondition writeXML(STD_NAMESPACE ostream &out, const size_t flags=0)
write object in XML format.
virtual OFCondition validateMetaInfo(const E_TransferSyntax oxfer, const E_FileWriteMode writeMode=EWM_fileformat)
make sure that all data elements of the file meta information header are existent in metainfo and con...
E_FileReadMode FileReadMode
file read mode, specifies whether to read the meta header or not
Definition: dcfilefo.h:390
a class handling the DICOM dataset format (files without meta header)
Definition: dcdatset.h:46
OFBool hasRepresentation(const E_TransferSyntax repType, const DcmRepresentationParameter *repParam)
check if all PixelData elements in this dataset have a representation conforming to the given transfe...
DcmFileFormat()
default constructor
void removeAllButOriginalRepresentations()
removes all but the original representation in all pixel data elements
Definition: dcfilefo.h:307
virtual OFCondition read(DcmInputStream &inStream, const E_TransferSyntax xfer=EXS_Unknown, const E_GrpLenEncoding glenc=EGL_noChange, const Uint32 maxReadLength=DCM_MaxReadLength)
read object from a stream.
a class representing the DICOM file meta information header
Definition: dcmetinf.h:53
abstract base class for input streams.
Definition: dcistrma.h:147
virtual OFCondition copyFrom(const DcmObject &rhs)
Virtual object copying.
virtual ~DcmFileFormat()
destructor
virtual OFCondition insertItem(DcmItem *item, const unsigned long where=DCM_EndOfListIndex)
method inherited from base class that shall not be used for instances of this class.
OFBool hasRepresentation(const E_TransferSyntax repType, const DcmRepresentationParameter *repParam)
check if all PixelData elements in this dataset have a representation conforming to the given transfe...
Definition: dcfilefo.h:299
DcmMetaInfo * getMetaInfo()
get file meta information header part of the fileformat
virtual DcmObject * clone() const
clone method
Definition: dcfilefo.h:81
void setReadMode(const E_FileReadMode readMode)
set current file read mode.
Definition: dcfilefo.h:335
DcmDataset * getDataset()
get dataset part of the fileformat
General purpose class for condition codes.
Definition: ofcond.h:305


Generated on Thu Aug 27 2015 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.9.1