1 /*
2  *
3  *  Copyright (C) 1998-2018, 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: dcmpstat
15  *
16  *  Author: Marco Eichelberg
17  *
18  *  Purpose:
19  *    classes: DVPSVOILUT
20  *
21  */
22 
23 #include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */
24 #include "dcmtk/dcmpstat/dvpsvl.h"
25 #include "dcmtk/dcmpstat/dvpssv.h"      /* for DVPSSoftcopyVOI */
26 #include "dcmtk/dcmpstat/dvpsdef.h"     /* for constants and macros */
27 #include "dcmtk/dcmpstat/dvpsri.h"      /* for DVPSReferencedImage, needed by MSVC5 with STL */
28 
29 
30 /* --------------- class DVPSVOILUT --------------- */
31 
DVPSVOILUT()32 DVPSVOILUT::DVPSVOILUT()
33 : voiLUTDescriptor(DCM_LUTDescriptor)
34 , voiLUTExplanation(DCM_LUTExplanation)
35 , voiLUTData(DCM_LUTData)
36 {
37 }
38 
DVPSVOILUT(const DVPSVOILUT & copy)39 DVPSVOILUT::DVPSVOILUT(const DVPSVOILUT& copy)
40 : voiLUTDescriptor(copy.voiLUTDescriptor)
41 , voiLUTExplanation(copy.voiLUTExplanation)
42 , voiLUTData(copy.voiLUTData)
43 {
44 }
45 
~DVPSVOILUT()46 DVPSVOILUT::~DVPSVOILUT()
47 {
48 }
49 
clear()50 void DVPSVOILUT::clear()
51 {
52   voiLUTDescriptor.clear();
53   voiLUTExplanation.clear();
54   voiLUTData.clear();
55 }
56 
read(DcmItem & dset)57 OFCondition DVPSVOILUT::read(DcmItem &dset)
58 {
59   OFCondition result = EC_Normal;
60   DcmStack stack;
61 
62   READ_FROM_DATASET(DcmUnsignedShort, EVR_US, voiLUTDescriptor)
63   READ_FROM_DATASET(DcmLongString, EVR_LO, voiLUTExplanation)
64   READ_FROM_DATASET(DcmUnsignedShort, EVR_US, voiLUTData)
65 
66   if (EC_Normal == result)
67   {
68     if (voiLUTData.getLength() == 0) result=EC_IllegalCall;
69     if (voiLUTDescriptor.getVM() != 3) result=EC_IllegalCall;
70   }
71   if ((EC_Normal==result) && (voiLUTExplanation.getLength() == 0))
72   {
73     Uint16 numEntries=0, bits=0;
74     voiLUTDescriptor.getUint16(numEntries,0);
75     voiLUTDescriptor.getUint16(bits,2);
76     char descr[100];
77     sprintf(descr, "VOI LUT entries=%u bits=%u", (unsigned int)numEntries, (unsigned int)bits);
78     voiLUTExplanation.putString(descr);
79   }
80   return result;
81 }
82 
getExplanation()83 const char *DVPSVOILUT::getExplanation()
84 {
85   char *value = NULL;
86   if (EC_Normal != voiLUTExplanation.getString(value)) return NULL;
87   return value;
88 }
89 
assign(DVPSSoftcopyVOI & voi)90 OFCondition DVPSVOILUT::assign(DVPSSoftcopyVOI& voi)
91 {
92   return voi.setVOILUT(voiLUTDescriptor, voiLUTData, voiLUTExplanation);
93 }
94