OFFIS DCMTK  Version 3.6.0
diovpln.h
1 /*
2  *
3  * Copyright (C) 1996-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: dcmimgle
15  *
16  * Author: Joerg Riesmeier
17  *
18  * Purpose: DicomOverlayPlane (Header)
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2010-10-14 13:16:27 $
22  * CVS/RCS Revision: $Revision: 1.32 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 
30 #ifndef DIOVPLN_H
31 #define DIOVPLN_H
32 
33 #include "dcmtk/config/osconfig.h"
34 #include "dcmtk/ofstd/ofstring.h"
35 #include "dcmtk/ofstd/ofcast.h"
36 
37 #include "dcmtk/dcmimgle/diutils.h"
38 
39 #define INCLUDE_CSTDDEF
40 #include "dcmtk/ofstd/ofstdinc.h"
41 
42 
43 /*------------------------*
44  * forward declarations *
45  *------------------------*/
46 
47 class DcmOverlayData;
48 class DcmLongString;
49 
50 class DiDocument;
51 
52 
53 /*---------------------*
54  * class declaration *
55  *---------------------*/
56 
60 {
61 
62  public:
63 
72  DiOverlayPlane(const DiDocument *docu,
73  const unsigned int group,
74  Uint16 alloc,
75  const Uint16 stored,
76  const Uint16 high);
77 
90  DiOverlayPlane(const unsigned int group,
91  const Sint16 left_pos,
92  const Sint16 top_pos,
93  const Uint16 columns,
94  const Uint16 rows,
95  const DcmOverlayData &data,
96  const DcmLongString &label,
97  const DcmLongString &description,
98  const EM_Overlay mode);
99 
112  const unsigned int bit,
113  Uint16 *data,
114  Uint16 *temp,
115  const Uint16 width,
116  const Uint16 height,
117  const Uint16 columns,
118  const Uint16 rows);
119 
122  ~DiOverlayPlane();
123 
130  inline Sint16 getLeft(const Sint32 left_pos = 0) const
131  {
132  return OFstatic_cast(Sint16, OFstatic_cast(Sint32, Left) - left_pos);
133  }
134 
141  inline Sint16 getTop(const Sint32 top_pos = 0) const
142  {
143  return OFstatic_cast(Sint16, OFstatic_cast(Sint32, Top) - top_pos);
144  }
145 
150  inline Uint16 getWidth() const
151  {
152  return Width;
153  }
154 
159  inline Uint16 getHeight() const
160  {
161  return Height;
162  }
163 
170  inline Uint16 getRight(const Sint32 left_pos = 0) const
171  {
172  return (OFstatic_cast(Sint32, Left) + OFstatic_cast(Sint32, Width) - left_pos > 0) ?
173  OFstatic_cast(Uint16, OFstatic_cast(Sint32, Left) + OFstatic_cast(Sint32, Width) - left_pos) : 0;
174  }
175 
182  inline Uint16 getBottom(const Sint32 top_pos = 0) const
183  {
184  return (OFstatic_cast(Sint32, Top) + OFstatic_cast(Sint32, Height) - top_pos > 0) ?
185  OFstatic_cast(Uint16, OFstatic_cast(Sint32, Top) + OFstatic_cast(Sint32, Height) - top_pos) : 0;
186  }
187 
192  inline int isValid() const
193  {
194  return Valid;
195  }
196 
201  inline int isVisible() const
202  {
203  return Visible;
204  }
205 
208  inline void show()
209  {
210  Visible = 1;
211  }
212 
215  inline void hide()
216  {
217  Visible = 0;
218  }
219 
225  void place(const signed int left_pos,
226  const signed int top_pos);
227 
233  void setScaling(const double xfactor,
234  const double yfactor);
235 
243  void setFlipping(const int horz,
244  const int vert,
245  const signed long columns,
246  const signed long rows);
247 
256  void setRotation(const int degree,
257  const signed long left_pos,
258  const signed long top_pos,
259  const Uint16 columns,
260  const Uint16 rows);
261 
268  void show(const double fore,
269  const double thresh,
270  const EM_Overlay mode);
271 
279  int show(const Uint16 pvalue);
280 
285  inline unsigned long getNumberOfFrames() const
286  {
287  return NumberOfFrames;
288  }
289 
294  inline double getForeground() const
295  {
296  return Foreground;
297  }
298 
303  inline double getThreshold() const
304  {
305  return Threshold;
306  }
307 
313  inline Uint16 getPValue() const
314  {
315  return PValue;
316  }
317 
322  inline EM_Overlay getMode() const
323  {
324  return Mode;
325  }
326 
331  inline int isEmbedded() const
332  {
333  return EmbeddedData;
334  }
335 
340  const char *getLabel() const
341  {
342  return (Label.empty()) ? OFstatic_cast(const char *, NULL) : Label.c_str();
343  }
344 
349  const char *getDescription() const
350  {
351  return (Description.empty()) ? OFstatic_cast(const char *, NULL) : Description.c_str();
352  }
353 
358  Uint16 getGroupNumber() const
359  {
360  return GroupNumber;
361  }
362 
378  void *getData(const unsigned long frame,
379  const Uint16 xmin,
380  const Uint16 ymin,
381  const Uint16 xmax,
382  const Uint16 ymax,
383  const int bits,
384  const Uint16 fore,
385  const Uint16 back);
386 
399  unsigned long create6xxx3000Data(Uint8 *&buffer,
400  unsigned int &width,
401  unsigned int &height,
402  unsigned long &frames);
403 
410  inline int reset(const unsigned long frame);
411 
416  inline int getNextBit();
417 
423  inline void setStart(const Uint16 x,
424  const Uint16 y);
425 
426 
427  protected:
428 
433 
435  Sint16 Top;
437  Sint16 Left;
439  Uint16 Height;
441  Uint16 Width;
443  Uint16 Rows;
445  Uint16 Columns;
449  Uint16 BitPosition;
450 
452  double Foreground;
454  double Threshold;
456  Uint16 PValue;
457 
459  EM_Overlay Mode;
461  EM_Overlay DefaultMode;
462 
467 
469  Uint16 GroupNumber;
470 
472  int Valid;
474  int Visible;
475 
476 
477  private:
478 
480  unsigned long BitPos;
482  unsigned long StartBitPos;
483 
485  unsigned int StartLeft;
487  unsigned int StartTop;
488 
491 
493  const Uint16 *Ptr;
495  const Uint16 *StartPtr;
497  const Uint16 *Data;
498 
499  // --- declarations to avoid compiler warnings
500 
502  DiOverlayPlane &operator=(const DiOverlayPlane &);
503 };
504 
505 
506 /********************************************************************/
507 
508 
509 inline int DiOverlayPlane::reset(const unsigned long frame)
510 {
511  int result = 0;
512  if (Valid && (Data != NULL) && (frame >= ImageFrameOrigin) && (frame < ImageFrameOrigin + NumberOfFrames))
513  {
514  const unsigned long bits = (OFstatic_cast(unsigned long, StartLeft) + OFstatic_cast(unsigned long, StartTop) *
515  OFstatic_cast(unsigned long, Columns) + frame * OFstatic_cast(unsigned long, Rows) *
516  OFstatic_cast(unsigned long, Columns)) * OFstatic_cast(unsigned long, BitsAllocated);
517  StartBitPos = BitPos = OFstatic_cast(unsigned long, BitPosition) + bits;
518  /* distinguish between embedded and separate overlay data */
519  if (BitsAllocated == 16)
520  StartPtr = Ptr = Data + (bits >> 4);
521  else
522  StartPtr = Data;
523  result = (getRight() > 0) && (getBottom() > 0);
524  }
525  return result;
526 }
527 
528 
530 {
531  int result;
532  if (BitsAllocated == 16) // optimization
533  result = OFstatic_cast(int, *(Ptr++) & (1 << BitPosition));
534  else
535  {
536  Ptr = StartPtr + (BitPos >> 4); // div 16
537  result = OFstatic_cast(int, *Ptr & (1 << (BitPos & 0xf))); // mod 16
538  BitPos += BitsAllocated; // next bit
539  }
540  return result;
541 }
542 
543 
544 inline void DiOverlayPlane::setStart(const Uint16 x,
545  const Uint16 y)
546 {
547  if (BitsAllocated == 16)
548  Ptr = StartPtr + OFstatic_cast(unsigned long, y - Top) * OFstatic_cast(unsigned long, Columns) +
549  OFstatic_cast(unsigned long, x - Left);
550  else
551  BitPos = StartBitPos + (OFstatic_cast(unsigned long, y - Top) * OFstatic_cast(unsigned long, Columns) +
552  OFstatic_cast(unsigned long, x - Left)) * OFstatic_cast(unsigned long, BitsAllocated);
553 }
554 
555 
556 #endif
557 
558 
559 /*
560  *
561  * CVS/RCS Log:
562  * $Log: diovpln.h,v $
563  * Revision 1.32 2010-10-14 13:16:27 joergr
564  * Updated copyright header. Added reference to COPYRIGHT file.
565  *
566  * Revision 1.31 2010-06-16 08:10:53 joergr
567  * Removed inline declaration from place() function.
568  *
569  * Revision 1.30 2010-06-16 07:08:08 joergr
570  * Added type cast to integer variables in order to avoid compiler warnings
571  * reported by VisualStudio 2008 with warning level 4 (highest).
572  *
573  * Revision 1.29 2010-03-01 09:08:47 uli
574  * Removed some unnecessary include directives in the headers.
575  *
576  * Revision 1.28 2008-11-18 11:01:28 joergr
577  * Fixed issue with incorrectly encoded overlay planes (wrong values for
578  * OverlayBitsAllocated and OverlayBitPosition).
579  *
580  * Revision 1.27 2006/11/09 11:03:51 joergr
581  * Fixed possible program crash when processing multi-frame overlay data stored in
582  * data element OverlayData (60xx,3000).
583  *
584  * Revision 1.26 2005/12/08 16:48:03 meichel
585  * Changed include path schema for all DCMTK header files
586  *
587  * Revision 1.25 2004/01/05 14:52:20 joergr
588  * Removed acknowledgements with e-mail addresses from CVS log.
589  *
590  * Revision 1.24 2003/12/09 10:11:28 joergr
591  * Adapted type casts to new-style typecast operators defined in ofcast.h.
592  * Removed leading underscore characters from preprocessor symbols (reserved
593  * symbols). Updated copyright header.
594  *
595  * Revision 1.23 2003/06/12 15:08:34 joergr
596  * Fixed inconsistent API documentation reported by Doxygen.
597  *
598  * Revision 1.22 2002/12/09 13:32:55 joergr
599  * Renamed parameter/local variable to avoid name clashes with global
600  * declaration left and/or right (used for as iostream manipulators).
601  *
602  * Revision 1.21 2002/11/27 14:08:07 meichel
603  * Adapted module dcmimgle to use of new header file ofstdinc.h
604  *
605  * Revision 1.20 2002/04/16 13:53:12 joergr
606  * Added configurable support for C++ ANSI standard includes (e.g. streams).
607  *
608  * Revision 1.19 2001/09/28 13:10:32 joergr
609  * Added method to extract embedded overlay planes from pixel data and store
610  * them in group (6xxx,3000) format.
611  *
612  * Revision 1.18 2001/06/01 15:49:49 meichel
613  * Updated copyright header
614  *
615  * Revision 1.17 2001/05/22 13:20:44 joergr
616  * Enhanced checking routines for corrupt overlay data (e.g. invalid value for
617  * OverlayBitsAllocated).
618  *
619  * Revision 1.16 2000/03/08 16:24:22 meichel
620  * Updated copyright header.
621  *
622  * Revision 1.15 2000/02/02 11:02:39 joergr
623  * Removed space characters before preprocessor directives.
624  *
625  * Revision 1.14 1999/10/20 10:34:06 joergr
626  * Enhanced method getOverlayData to support 12 bit data for print.
627  *
628  * Revision 1.13 1999/09/17 12:46:59 joergr
629  * Added/changed/completed DOC++ style comments in the header files.
630  *
631  * Revision 1.12 1999/08/25 16:41:55 joergr
632  * Added new feature: Allow clipping region to be outside the image
633  * (overlapping).
634  *
635  * Revision 1.11 1999/05/03 11:09:31 joergr
636  * Minor code purifications to keep Sun CC 2.0.1 quiet.
637  *
638  * Revision 1.10 1999/04/29 16:46:47 meichel
639  * Minor code purifications to keep DEC cxx 6 quiet.
640  *
641  * Revision 1.9 1999/03/24 17:20:21 joergr
642  * Added/Modified comments and formatting.
643  *
644  * Revision 1.8 1999/03/22 08:52:18 joergr
645  * Added parameter to specify (transparent) background color for method
646  * getOverlayData().
647  *
648  * Revision 1.7 1999/02/03 17:34:36 joergr
649  * Added BEGIN_EXTERN_C and END_EXTERN_C to some C includes.
650  * Added support for calibration according to Barten transformation (incl.
651  * a DISPLAY file describing the monitor characteristic).
652  *
653  * Revision 1.6 1998/12/23 13:21:29 joergr
654  * Changed parameter type (long to int) to avoid warning reported by MSVC5.
655  *
656  * Revision 1.5 1998/12/23 11:37:42 joergr
657  * Changed order of parameters for addOverlay() and getOverlayData().
658  * Changed behaviour of getLabel/Description/Explanation() methods: return
659  * NULL if string empty, no empty string "".
660  *
661  * Revision 1.4 1998/12/22 14:36:30 joergr
662  * Added method to check whether plane is visible, to get plane mode and to
663  * remove all planes. Set 'value' used for getOverlay/PlaneData().
664  *
665  * Revision 1.3 1998/12/16 16:37:51 joergr
666  * Added method to export overlay planes (create 8-bit bitmap).
667  * Implemented flipping and rotation of overlay planes.
668  *
669  * Revision 1.2 1998/12/14 17:28:18 joergr
670  * Added methods to add and remove additional overlay planes (still untested).
671  * Added methods to support overlay labels and descriptions.
672  *
673  * Revision 1.1 1998/11/27 15:45:09 joergr
674  * Added copyright message.
675  * Added method to detach pixel data if it is no longer needed.
676  * Added methods and constructors for flipping and rotating, changed for
677  * scaling and clipping.
678  *
679  * Revision 1.7 1998/07/01 08:39:26 joergr
680  * Minor changes to avoid compiler warnings (gcc 2.8.1 with additional
681  * options), e.g. add copy constructors.
682  *
683  * Revision 1.6 1998/05/11 14:53:26 joergr
684  * Added CVS/RCS header to each file.
685  *
686  *
687  */


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