diovpln.h

00001 /*
00002  *
00003  *  Copyright (C) 1996-2005, 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:  dcmimgle
00019  *
00020  *  Author:  Joerg Riesmeier
00021  *
00022  *  Purpose: DicomOverlayPlane (Header) - Multiframe Overlays UNTESTED !
00023  *
00024  *  Last Update:      $Author: meichel $
00025  *  Update Date:      $Date: 2005/12/08 16:48:03 $
00026  *  CVS/RCS Revision: $Revision: 1.26 $
00027  *  Status:           $State: Exp $
00028  *
00029  *  CVS/RCS Log at end of file
00030  *
00031  */
00032 
00033 
00034 #ifndef DIOVPLN_H
00035 #define DIOVPLN_H
00036 
00037 #include "dcmtk/config/osconfig.h"
00038 #include "dcmtk/dcmdata/dctypes.h"
00039 #include "dcmtk/ofstd/ofstring.h"
00040 #include "dcmtk/ofstd/ofstream.h"
00041 #include "dcmtk/ofstd/ofcast.h"
00042 
00043 #include "dcmtk/dcmimgle/diutils.h"
00044 
00045 #define INCLUDE_CSTDDEF
00046 #include "dcmtk/ofstd/ofstdinc.h"
00047 
00048 
00049 /*------------------------*
00050  *  forward declarations  *
00051  *------------------------*/
00052 
00053 class DcmOverlayData;
00054 class DcmLongString;
00055 
00056 class DiDocument;
00057 
00058 
00059 /*---------------------*
00060  *  class declaration  *
00061  *---------------------*/
00062 
00065 class DiOverlayPlane
00066 {
00067 
00068  public:
00069 
00076     DiOverlayPlane(const DiDocument *docu,
00077                    const unsigned int group,
00078                    Uint16 alloc);
00079 
00092     DiOverlayPlane(const unsigned int group,
00093                    const Sint16 left_pos,
00094                    const Sint16 top_pos,
00095                    const Uint16 columns,
00096                    const Uint16 rows,
00097                    const DcmOverlayData &data,
00098                    const DcmLongString &label,
00099                    const DcmLongString &description,
00100                    const EM_Overlay mode);
00101 
00113     DiOverlayPlane(DiOverlayPlane *plane,
00114                    const unsigned int bit,
00115                    Uint16 *data,
00116                    Uint16 *temp,
00117                    const Uint16 width,
00118                    const Uint16 height,
00119                    const Uint16 columns,
00120                    const Uint16 rows);
00121 
00124     ~DiOverlayPlane();
00125 
00132     inline Sint16 getLeft(const Sint32 left_pos = 0) const
00133     {
00134         return OFstatic_cast(Sint16, OFstatic_cast(Sint32, Left) - left_pos);
00135     }
00136 
00143     inline Sint16 getTop(const Sint32 top_pos = 0) const
00144     {
00145         return OFstatic_cast(Sint16, OFstatic_cast(Sint32, Top) - top_pos);
00146     }
00147 
00152     inline Uint16 getWidth() const
00153     {
00154         return Width;
00155     }
00156 
00161     inline Uint16 getHeight() const
00162     {
00163         return Height;
00164     }
00165 
00172     inline Uint16 getRight(const Sint32 left_pos = 0) const
00173     {
00174         return (OFstatic_cast(Sint32, Left) + OFstatic_cast(Sint32, Width) - left_pos > 0) ?
00175             OFstatic_cast(Uint16, OFstatic_cast(Sint32, Left) + OFstatic_cast(Sint32, Width) - left_pos) : 0;
00176     }
00177 
00184     inline Uint16 getBottom(const Sint32 top_pos = 0) const
00185     {
00186         return (OFstatic_cast(Sint32, Top) + OFstatic_cast(Sint32, Height) - top_pos > 0) ?
00187             OFstatic_cast(Uint16, OFstatic_cast(Sint32, Top) + OFstatic_cast(Sint32, Height) - top_pos) : 0;
00188     }
00189 
00194     inline int isValid() const
00195     {
00196         return Valid;
00197     }
00198 
00203     inline int isVisible() const
00204     {
00205         return Visible;
00206     }
00207 
00210     inline void show()
00211     {
00212         Visible = 1;
00213     }
00214 
00217     inline void hide()
00218     {
00219         Visible = 0;
00220     }
00221 
00227     inline void place(const signed int left_pos,
00228                       const signed int top_pos)
00229     {
00230         Left = left_pos; Top = top_pos;
00231     }
00232 
00238     void setScaling(const double xfactor,
00239                     const double yfactor);
00240 
00248     void setFlipping(const int horz,
00249                      const int vert,
00250                      const signed long columns,
00251                      const signed long rows);
00252 
00261     void setRotation(const int degree,
00262                      const signed long left_pos,
00263                      const signed long top_pos,
00264                      const Uint16 columns,
00265                      const Uint16 rows);
00266 
00273     void show(const double fore,
00274               const double thresh,
00275               const EM_Overlay mode);
00276 
00284     int show(const Uint16 pvalue);
00285 
00290     inline unsigned long getNumberOfFrames() const
00291     {
00292         return NumberOfFrames;
00293     }
00294 
00299     inline double getForeground() const
00300     {
00301         return Foreground;
00302     }
00303 
00308     inline double getThreshold() const
00309     {
00310         return Threshold;
00311     }
00312 
00318     inline Uint16 getPValue() const
00319     {
00320         return PValue;
00321     }
00322 
00327     inline EM_Overlay getMode() const
00328     {
00329         return Mode;
00330     }
00331 
00336     inline int isEmbedded() const
00337     {
00338         return EmbeddedData;
00339     }
00340 
00345     const char *getLabel() const
00346     {
00347         return (Label.empty()) ? OFstatic_cast(const char *, NULL) : Label.c_str();
00348     }
00349 
00354     const char *getDescription() const
00355     {
00356         return (Description.empty()) ? OFstatic_cast(const char *, NULL) : Description.c_str();
00357     }
00358 
00363     Uint16 getGroupNumber() const
00364     {
00365         return GroupNumber;
00366     }
00367 
00383     void *getData(const unsigned long frame,
00384                   const Uint16 xmin,
00385                   const Uint16 ymin,
00386                   const Uint16 xmax,
00387                   const Uint16 ymax,
00388                   const int bits,
00389                   const Uint16 fore,
00390                   const Uint16 back);
00391 
00404     unsigned long create6xxx3000Data(Uint8 *&buffer,
00405                                      unsigned int &width,
00406                                      unsigned int &height,
00407                                      unsigned long &frames);
00408 
00415     inline int reset(const unsigned long frame);
00416 
00421     inline int getNextBit();
00422 
00428     inline void setStart(const Uint16 x,
00429                          const Uint16 y);
00430 
00431 
00432  protected:
00433 
00435     Uint32 NumberOfFrames;
00437     Uint16 ImageFrameOrigin;
00438 
00440     Sint16 Top;
00442     Sint16 Left;
00444     Uint16 Height;
00446     Uint16 Width;
00448     Uint16 Rows;
00450     Uint16 Columns;
00452     Uint16 BitsAllocated;
00454     Uint16 BitPosition;
00455 
00457     double Foreground;
00459     double Threshold;
00461     Uint16 PValue;
00462 
00464     EM_Overlay Mode;
00466     EM_Overlay DefaultMode;
00467 
00469     OFString Label;
00471     OFString Description;
00472 
00474     Uint16 GroupNumber;
00475 
00477     int Valid;
00479     int Visible;
00480 
00481 
00482  private:
00483 
00485     unsigned long BitPos;
00487     unsigned long StartBitPos;
00488 
00490     unsigned int StartLeft;
00492     unsigned int StartTop;
00493 
00495     int EmbeddedData;
00496 
00498     const Uint16 *Ptr;
00500     const Uint16 *StartPtr;
00502     const Uint16 *Data;
00503 
00504  // --- declarations to avoid compiler warnings
00505 
00506     DiOverlayPlane(const DiOverlayPlane &);
00507     DiOverlayPlane &operator=(const DiOverlayPlane &);
00508 };
00509 
00510 
00511 /********************************************************************/
00512 
00513 
00514 inline int DiOverlayPlane::reset(const unsigned long frame)
00515 {
00516     int result = 0;
00517     if (Valid && (Data != NULL) && (frame >= ImageFrameOrigin) && (frame < ImageFrameOrigin + NumberOfFrames))
00518     {
00519         const unsigned long bits = (OFstatic_cast(unsigned long, StartLeft) + OFstatic_cast(unsigned long, StartTop) *
00520             OFstatic_cast(unsigned long, Columns) + frame * OFstatic_cast(unsigned long, Rows) *
00521             OFstatic_cast(unsigned long, Columns)) * OFstatic_cast(unsigned long, BitsAllocated);
00522         StartBitPos = BitPos = OFstatic_cast(unsigned long, BitPosition) + bits;
00523         StartPtr = Ptr = Data + (bits >> 4);
00524         result = (getRight() > 0) && (getBottom() > 0);
00525     }
00526     return result;
00527 }
00528 
00529 
00530 inline int DiOverlayPlane::getNextBit()
00531 {
00532     int result;
00533     if (BitsAllocated == 16)                                       // optimization
00534         result = OFstatic_cast(int, *(Ptr++) & (1 << BitPosition));
00535     else
00536     {
00537        Ptr = StartPtr + (BitPos >> 4);                             // div 16
00538        result = OFstatic_cast(int, *Ptr & (1 << (BitPos & 0xf)));  // mod 16
00539        BitPos += BitsAllocated;                                    // next bit
00540     }
00541     return result;
00542 }
00543 
00544 
00545 inline void DiOverlayPlane::setStart(const Uint16 x,
00546                                      const Uint16 y)
00547 {
00548     if (BitsAllocated == 16)
00549         Ptr = StartPtr + OFstatic_cast(unsigned long, y - Top) * OFstatic_cast(unsigned long, Columns) +
00550             OFstatic_cast(unsigned long, x - Left);
00551     else
00552         BitPos = StartBitPos + (OFstatic_cast(unsigned long, y - Top) * OFstatic_cast(unsigned long, Columns) +
00553             OFstatic_cast(unsigned long, x - Left)) * OFstatic_cast(unsigned long, BitsAllocated);
00554 }
00555 
00556 
00557 #endif
00558 
00559 
00560 /*
00561  *
00562  * CVS/RCS Log:
00563  * $Log: diovpln.h,v $
00564  * Revision 1.26  2005/12/08 16:48:03  meichel
00565  * Changed include path schema for all DCMTK header files
00566  *
00567  * Revision 1.25  2004/01/05 14:52:20  joergr
00568  * Removed acknowledgements with e-mail addresses from CVS log.
00569  *
00570  * Revision 1.24  2003/12/09 10:11:28  joergr
00571  * Adapted type casts to new-style typecast operators defined in ofcast.h.
00572  * Removed leading underscore characters from preprocessor symbols (reserved
00573  * symbols). Updated copyright header.
00574  *
00575  * Revision 1.23  2003/06/12 15:08:34  joergr
00576  * Fixed inconsistent API documentation reported by Doxygen.
00577  *
00578  * Revision 1.22  2002/12/09 13:32:55  joergr
00579  * Renamed parameter/local variable to avoid name clashes with global
00580  * declaration left and/or right (used for as iostream manipulators).
00581  *
00582  * Revision 1.21  2002/11/27 14:08:07  meichel
00583  * Adapted module dcmimgle to use of new header file ofstdinc.h
00584  *
00585  * Revision 1.20  2002/04/16 13:53:12  joergr
00586  * Added configurable support for C++ ANSI standard includes (e.g. streams).
00587  *
00588  * Revision 1.19  2001/09/28 13:10:32  joergr
00589  * Added method to extract embedded overlay planes from pixel data and store
00590  * them in group (6xxx,3000) format.
00591  *
00592  * Revision 1.18  2001/06/01 15:49:49  meichel
00593  * Updated copyright header
00594  *
00595  * Revision 1.17  2001/05/22 13:20:44  joergr
00596  * Enhanced checking routines for corrupt overlay data (e.g. invalid value for
00597  * OverlayBitsAllocated).
00598  *
00599  * Revision 1.16  2000/03/08 16:24:22  meichel
00600  * Updated copyright header.
00601  *
00602  * Revision 1.15  2000/02/02 11:02:39  joergr
00603  * Removed space characters before preprocessor directives.
00604  *
00605  * Revision 1.14  1999/10/20 10:34:06  joergr
00606  * Enhanced method getOverlayData to support 12 bit data for print.
00607  *
00608  * Revision 1.13  1999/09/17 12:46:59  joergr
00609  * Added/changed/completed DOC++ style comments in the header files.
00610  *
00611  * Revision 1.12  1999/08/25 16:41:55  joergr
00612  * Added new feature: Allow clipping region to be outside the image
00613  * (overlapping).
00614  *
00615  * Revision 1.11  1999/05/03 11:09:31  joergr
00616  * Minor code purifications to keep Sun CC 2.0.1 quiet.
00617  *
00618  * Revision 1.10  1999/04/29 16:46:47  meichel
00619  * Minor code purifications to keep DEC cxx 6 quiet.
00620  *
00621  * Revision 1.9  1999/03/24 17:20:21  joergr
00622  * Added/Modified comments and formatting.
00623  *
00624  * Revision 1.8  1999/03/22 08:52:18  joergr
00625  * Added parameter to specify (transparent) background color for method
00626  * getOverlayData().
00627  *
00628  * Revision 1.7  1999/02/03 17:34:36  joergr
00629  * Added BEGIN_EXTERN_C and END_EXTERN_C to some C includes.
00630  * Added support for calibration according to Barten transformation (incl.
00631  * a DISPLAY file describing the monitor characteristic).
00632  *
00633  * Revision 1.6  1998/12/23 13:21:29  joergr
00634  * Changed parameter type (long to int) to avoid warning reported by MSVC5.
00635  *
00636  * Revision 1.5  1998/12/23 11:37:42  joergr
00637  * Changed order of parameters for addOverlay() and getOverlayData().
00638  * Changed behaviour of getLabel/Description/Explanation() methods: return
00639  * NULL if string empty, no empty string "".
00640  *
00641  * Revision 1.4  1998/12/22 14:36:30  joergr
00642  * Added method to check whether plane is visible, to get plane mode and to
00643  * remove all planes. Set 'value' used for getOverlay/PlaneData().
00644  *
00645  * Revision 1.3  1998/12/16 16:37:51  joergr
00646  * Added method to export overlay planes (create 8-bit bitmap).
00647  * Implemented flipping and rotation of overlay planes.
00648  *
00649  * Revision 1.2  1998/12/14 17:28:18  joergr
00650  * Added methods to add and remove additional overlay planes (still untested).
00651  * Added methods to support overlay labels and descriptions.
00652  *
00653  * Revision 1.1  1998/11/27 15:45:09  joergr
00654  * Added copyright message.
00655  * Added method to detach pixel data if it is no longer needed.
00656  * Added methods and constructors for flipping and rotating, changed for
00657  * scaling and clipping.
00658  *
00659  * Revision 1.7  1998/07/01 08:39:26  joergr
00660  * Minor changes to avoid compiler warnings (gcc 2.8.1 with additional
00661  * options), e.g. add copy constructors.
00662  *
00663  * Revision 1.6  1998/05/11 14:53:26  joergr
00664  * Added CVS/RCS header to each file.
00665  *
00666  *
00667  */


Generated on 20 Dec 2005 for OFFIS DCMTK Version 3.5.4 by Doxygen 1.4.5