/src/dcmtk/dcmimgle/libsrc/dibaslut.cc
Line | Count | Source |
1 | | /* |
2 | | * |
3 | | * Copyright (C) 1996-2016, 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: DicomBaseLUT (Source) |
19 | | * |
20 | | */ |
21 | | |
22 | | |
23 | | #include "dcmtk/config/osconfig.h" |
24 | | |
25 | | #include "dcmtk/dcmimgle/dibaslut.h" |
26 | | |
27 | | |
28 | | /*----------------* |
29 | | * constructors * |
30 | | *----------------*/ |
31 | | |
32 | | DiBaseLUT::DiBaseLUT(const Uint32 count, |
33 | | const Uint16 bits) |
34 | 0 | : Count(count), |
35 | 0 | FirstEntry(0), |
36 | 0 | Bits(bits), |
37 | 0 | MinValue(0), |
38 | 0 | MaxValue(0), |
39 | 0 | Valid(0), |
40 | 0 | Explanation(), |
41 | 0 | Data(NULL), |
42 | 0 | DataBuffer(NULL) |
43 | 0 | { |
44 | 0 | } |
45 | | |
46 | | |
47 | | DiBaseLUT::DiBaseLUT(Uint16 *buffer, |
48 | | const Uint32 count, |
49 | | const Uint16 bits) |
50 | 0 | : Count(count), |
51 | 0 | FirstEntry(0), |
52 | 0 | Bits(bits), |
53 | 0 | MinValue(0), |
54 | 0 | MaxValue(0), |
55 | 0 | Valid(0), |
56 | 0 | Explanation(), |
57 | 0 | Data(buffer), |
58 | 0 | DataBuffer(buffer) |
59 | 0 | { |
60 | 0 | } |
61 | | |
62 | | |
63 | | /*--------------* |
64 | | * destructor * |
65 | | *--------------*/ |
66 | | |
67 | | DiBaseLUT::~DiBaseLUT() |
68 | 0 | { |
69 | 0 | delete[] DataBuffer; |
70 | 0 | } |
71 | | |
72 | | |
73 | | /********************************************************************/ |
74 | | |
75 | | |
76 | | OFBool DiBaseLUT::operator==(const DiBaseLUT &lut) |
77 | 0 | { |
78 | 0 | return (compare(&lut) == 0); |
79 | 0 | } |
80 | | |
81 | | |
82 | | int DiBaseLUT::compare(const DiBaseLUT *lut) |
83 | 0 | { |
84 | 0 | int result = 1; // invalid LUT (1) |
85 | 0 | if (Valid && (lut != NULL) && lut->isValid()) |
86 | 0 | { |
87 | 0 | result = 2; // descriptor differs (2) |
88 | 0 | if ((Count == lut->getCount()) && (FirstEntry == lut->getFirstEntry()) && (Bits == lut->getBits())) |
89 | 0 | { // special case: if Count == 0 LUT data is equal |
90 | 0 | Uint32 i = Count; // ... but normally not Valid ! |
91 | 0 | if ((MinValue == lut->getMinValue()) && (MaxValue == lut->getMaxValue())) |
92 | 0 | { // additional check for better performance |
93 | 0 | const Uint16 *p = Data; |
94 | 0 | const Uint16 *q = lut->getData(); |
95 | 0 | while ((i != 0) && (*(p++) == *(q++))) |
96 | 0 | --i; |
97 | 0 | } |
98 | 0 | result = (i != 0) ? 3 : 0; // check whether data is equal (0) |
99 | 0 | } |
100 | 0 | } |
101 | 0 | return result; |
102 | 0 | } |