[med-svn] [gdcm] 01/01: New upstream version 2.8.4
Gert Wollny
gewo at moszumanska.debian.org
Sun Nov 19 10:37:22 UTC 2017
This is an automated email from the git hooks/post-receive script.
gewo pushed a commit to branch upstream
in repository gdcm.
commit f6fc1622accc08bfdb00eaa3df1ae9a09155e33a
Author: Gert Wollny <gewo at debian.org>
Date: Sun Nov 19 08:52:07 2017 +0100
New upstream version 2.8.4
---
Applications/Cxx/gdcmdump.cxx | 1 +
Applications/Cxx/gdcmimg.cxx | 4 +
CMakeLists.txt | 24 ++++-
Examples/Cxx/DumpExamCard.cxx | 2 +-
Examples/Java/ScanDirectory.java | 9 ++
Source/Common/CMakeLists.txt | 1 -
.../Common/gdcmCAPICryptographicMessageSyntax.cxx | 8 +-
Source/DataDictionary/CMakeLists.txt | 3 +-
Source/DataDictionary/Part6.xml | 6 +-
Source/DataDictionary/Part6.xsl | 6 +-
Source/DataDictionary/{Part7.xml => Part7a.xml} | 24 -----
Source/DataDictionary/Part7b.xml | 36 +++++++
.../gdcmJPEG2000Codec.cxx | 2 +-
Source/MediaStorageAndFileFormat/gdcmPixelFormat.h | 26 +++++
.../MediaStorageAndFileFormat/gdcmSegmentHelper.h | 4 +-
.../MediaStorageAndFileFormat/gdcmStringFilter.cxx | 17 ++--
.../MediaStorageAndFileFormat/gdcmSurfaceHelper.h | 70 ++++++-------
.../gdcmULTransitionTable.cxx | 2 +-
Testing/Source/Data/CMakeLists.txt | 3 +
.../Cxx/TestAttribute1.cxx | 3 +-
.../Java/CMakeLists.txt | 2 +
.../Java/TestReaderUpToTag.java | 100 ++++++++++++++++++
.../Java/TestTag.java | 58 +++++++++++
Utilities/C99/stdint.h | 40 +++++---
Utilities/VTK/CMakeLists.txt | 2 +-
Utilities/gdcmcharls/encoderstrategy.h | 12 +--
Utilities/gdcmcharls/header.cpp | 2 +-
Utilities/gdcmcharls/header.h | 12 ---
Utilities/gdcmopenjpeg/doc/.gitkeep | 0
Utilities/gdcmutfcpp/utf8.h | 68 ++++++-------
Wrapping/Java/CMakeLists.txt | 38 ++++++-
Wrapping/Java/gdcm.i | 113 ++++++++++++++++++++-
32 files changed, 543 insertions(+), 155 deletions(-)
diff --git a/Applications/Cxx/gdcmdump.cxx b/Applications/Cxx/gdcmdump.cxx
index 8e37cbf..2c1a6b9 100644
--- a/Applications/Cxx/gdcmdump.cxx
+++ b/Applications/Cxx/gdcmdump.cxx
@@ -983,6 +983,7 @@ static int PrintMrProtocol(const std::string & filename)
bool found = false;
namespace kwd = gdcm::Keywords;
kwd::SharedFunctionalGroupsSequence sfgs;
+ (void)sfgs;
if( csa.GetMrProtocol(ds, mrprot))
{
found = true;
diff --git a/Applications/Cxx/gdcmimg.cxx b/Applications/Cxx/gdcmimg.cxx
index 7749c6a..f1f2c90 100644
--- a/Applications/Cxx/gdcmimg.cxx
+++ b/Applications/Cxx/gdcmimg.cxx
@@ -1054,6 +1054,10 @@ int main (int argc, char *argv[])
writer.SetCheckFileMetaInformation( (keepmeta > 0 ? false : true) );
writer.SetFile( reader.GetFile() );
if( !Populate( writer, jpeg, filenames ) ) return 1;
+ if( pinter )
+ {
+ writer.GetPixmap().SetPhotometricInterpretation( refpi );
+ }
if( !AddUIDs(sopclassuid, sopclass, study_uid, series_uid, writer ) ) return 1;
writer.SetFileName( outfilename );
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5c5031c..69d27e7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,7 +11,12 @@ endif()
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()
+if( POLICY CMP0063 )
+ cmake_policy(SET CMP0063 NEW)
+endif()
project(GDCM)
+set(CMAKE_CXX_STANDARD 98)
+set(CMAKE_CXX_EXTENSIONS OFF)
mark_as_advanced(CMAKE_BACKWARDS_COMPATIBILITY CMAKE_BUILD_TYPE CMAKE_INSTALL_PREFIX)
set(GDCM_CMAKE_DIR "${GDCM_SOURCE_DIR}/CMake" CACHE INTERNAL "")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${GDCM_CMAKE_DIR}")
@@ -35,7 +40,7 @@ set(GDCM_PACKAGE_CONTACT "GDCM Developers <gdcm-developers at lists.sourceforge.net
#----------------------------------------------------------------------------
set(GDCM_MAJOR_VERSION 2)
set(GDCM_MINOR_VERSION 8)
-set(GDCM_BUILD_VERSION 3)
+set(GDCM_BUILD_VERSION 4)
set(GDCM_VERSION
"${GDCM_MAJOR_VERSION}.${GDCM_MINOR_VERSION}.${GDCM_BUILD_VERSION}")
# let advanced user the option to define GDCM_API_VERSION:
@@ -535,6 +540,23 @@ if(GDCM_STANDALONE)
find_package(CSharp REQUIRED)
include(${CSharp_USE_FILE})
endif()
+ # Expose a way to pass -fPIC to static libs of gdcm core, while still build wrapped language as shared lib:
+ if(NOT DEFINED GDCM_USE_PIC_FOR_STATIC_LIBS)
+ if(GDCM_WRAP_JAVA)
+ if(NOT BUILD_SHARED_LIBS)
+ if(CMAKE_COMPILER_IS_GNUCXX)
+ set(GDCM_USE_PIC_FOR_STATIC_LIBS ON)
+ endif()
+ endif()
+ endif()
+ endif()
+ if(GDCM_USE_PIC_FOR_STATIC_LIBS)
+ if(BUILD_SHARED_LIBS)
+ message(FATAL_ERROR "Invalid configuration for static/shared lib")
+ else()
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+ endif()
+ endif()
endif()
set(GDCM_LIBRARY_DIR ${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
diff --git a/Examples/Cxx/DumpExamCard.cxx b/Examples/Cxx/DumpExamCard.cxx
index f84ebea..284f06a 100644
--- a/Examples/Cxx/DumpExamCard.cxx
+++ b/Examples/Cxx/DumpExamCard.cxx
@@ -74,7 +74,7 @@ typedef enum
param_integer = 1, // 1 << 0
param_string = 2, // 1 << 1
param_3, // ??
- param_enum = 4, // 1 << 2
+ param_enum = 4 // 1 << 2
} param_type;
static const char *gettypenamefromtype( int i)
diff --git a/Examples/Java/ScanDirectory.java b/Examples/Java/ScanDirectory.java
index 297b21a..34f735d 100644
--- a/Examples/Java/ScanDirectory.java
+++ b/Examples/Java/ScanDirectory.java
@@ -239,6 +239,15 @@ public class ScanDirectory
{
throw new Exception("Could not scan");
}
+ String fn0 = fns.get(0);
+ TagToValue mappings = s.GetMapping( fn0 );
+ System.out.println( "mappings size: " + mappings.size() );
+ for( Tag tag : tagarray ) {
+ if( mappings.has_key( tag ) ) {
+ String val = mappings.get( tag );
+ System.out.println( "tag/val: " + tag + "->" + val );
+ }
+ }
for( long idx = 0; idx < fns.size(); ++idx )
{
diff --git a/Source/Common/CMakeLists.txt b/Source/Common/CMakeLists.txt
index 488cc07..6662752 100644
--- a/Source/Common/CMakeLists.txt
+++ b/Source/Common/CMakeLists.txt
@@ -8,7 +8,6 @@ option(GDCM_SUPPORT_BROKEN_IMPLEMENTATION "Handle broken DICOM" ON)
mark_as_advanced(
GDCM_ALWAYS_TRACE_MACRO
GDCM_SUPPORT_BROKEN_IMPLEMENTATION
- GDCM_AUTOLOAD_GDCMJNI
)
#if(WIN32)
diff --git a/Source/Common/gdcmCAPICryptographicMessageSyntax.cxx b/Source/Common/gdcmCAPICryptographicMessageSyntax.cxx
index 1791a21..5cc6ea6 100644
--- a/Source/Common/gdcmCAPICryptographicMessageSyntax.cxx
+++ b/Source/Common/gdcmCAPICryptographicMessageSyntax.cxx
@@ -485,6 +485,7 @@ bool CAPICryptographicMessageSyntax::LoadFile(const char * filename, BYTE* & buf
if (f == NULL)
{
gdcmErrorMacro("Couldn't open the file: " << filename);
+ fclose(f);
return false;
}
fseek(f, 0L, SEEK_END);
@@ -492,7 +493,11 @@ bool CAPICryptographicMessageSyntax::LoadFile(const char * filename, BYTE* & buf
rewind(f);
buffer = new BYTE[sz];
- if( !buffer ) return false;
+ if( !buffer )
+ {
+ fclose(f);
+ return false;
+ }
bufLen = sz;
while (sz)
@@ -501,6 +506,7 @@ bool CAPICryptographicMessageSyntax::LoadFile(const char * filename, BYTE* & buf
sz -= (long)l;
}
+ fclose(f);
return true;
}
diff --git a/Source/DataDictionary/CMakeLists.txt b/Source/DataDictionary/CMakeLists.txt
index 81c910f..8b071dd 100644
--- a/Source/DataDictionary/CMakeLists.txt
+++ b/Source/DataDictionary/CMakeLists.txt
@@ -112,7 +112,8 @@ install_includes("*.h")
set(XML_FILES
${CMAKE_CURRENT_SOURCE_DIR}/CSAHeader.xml
${CMAKE_CURRENT_SOURCE_DIR}/Part6.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/Part7.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/Part7a.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/Part7b.xml
${CMAKE_CURRENT_SOURCE_DIR}/UIDs.xml
${CMAKE_CURRENT_SOURCE_DIR}/cp699.xml
)
diff --git a/Source/DataDictionary/Part6.xml b/Source/DataDictionary/Part6.xml
index 0c446c8..8f30d81 100644
--- a/Source/DataDictionary/Part6.xml
+++ b/Source/DataDictionary/Part6.xml
@@ -18,10 +18,12 @@ Manual changes:
1. DateTime -> Date Time (0008,002a)
-->
<!DOCTYPE doc [
- <!ENTITY part7 SYSTEM "Part7.xml">
+ <!ENTITY part7a SYSTEM "Part7a.xml">
+ <!ENTITY part7b SYSTEM "Part7b.xml">
]>
<dicts edition="2011">
- &part7;
+ &part7a;
+ &part7b;
<dict ref="6" name="Registry of DICOM Data Elements">
<entry group="0008" element="0001" keyword="LengthToEnd" vr="UL" vm="1" retired="true" name="Length to End"/>
<entry group="0008" element="0005" keyword="SpecificCharacterSet" vr="CS" vm="1-n" name="Specific Character Set"/>
diff --git a/Source/DataDictionary/Part6.xsl b/Source/DataDictionary/Part6.xsl
index 618b269..fe7fe7b 100644
--- a/Source/DataDictionary/Part6.xsl
+++ b/Source/DataDictionary/Part6.xsl
@@ -39,12 +39,14 @@ Manual changes:
</xsl:comment>
<xsl:text disable-output-escaping="yes">
<!DOCTYPE doc [
- <!ENTITY part7 SYSTEM "Part7.xml">
+ <!ENTITY part7a SYSTEM "Part7a.xml">
+ <!ENTITY part7b SYSTEM "Part7b.xml">
]>
</xsl:text>
<dicts edition="2011">
<xsl:text disable-output-escaping="yes">
- &part7;
+ &part7a;
+ &part7b;
</xsl:text>
<xsl:apply-templates select="*/*/dk:table[@xml:id='table_6-1']" mode="m1"/>
<xsl:apply-templates select="*/*/dk:table[@xml:id='table_7-1']" mode="m1"/>
diff --git a/Source/DataDictionary/Part7.xml b/Source/DataDictionary/Part7a.xml
similarity index 75%
rename from Source/DataDictionary/Part7.xml
rename to Source/DataDictionary/Part7a.xml
index aa4e440..1fd6e43 100644
--- a/Source/DataDictionary/Part7.xml
+++ b/Source/DataDictionary/Part7a.xml
@@ -159,27 +159,3 @@
</description>
</entry>
</dict>
- <dict ref="E.2" name="Retired command fields">
- <entry group="0000" element="0001" vr="UL" vm="1" keyword="CommandLengthToEnd" name="Command Length to End" retired="true"/>
- <entry group="0000" element="0010" vr="SH" vm="1" keyword="CommandRecognitionCode" name="Command Recognition Code" retired="true"/>
- <entry group="0000" element="0200" vr="AE" vm="1" keyword="Initiator" name="Initiator" retired="true"/>
- <entry group="0000" element="0300" vr="AE" vm="1" keyword="Receiver" name="Receiver" retired="true"/>
- <entry group="0000" element="0400" vr="AE" vm="1" keyword="FindLocation" name="Find Location" retired="true"/>
- <entry group="0000" element="0850" vr="US" vm="1" keyword="NumberOfMatches" name="Number of Matches" retired="true"/>
- <entry group="0000" element="0860" vr="US" vm="1" keyword="ResponseSequenceNumber" name="Response Sequence Number" retired="true"/>
- <entry group="0000" element="4000" vr="LT" vm="1" keyword="DialogReceiver" name="Dialog Receiver" retired="true"/>
- <entry group="0000" element="4010" vr="LT" vm="1" keyword="TerminalType" name="Terminal Type" retired="true"/>
- <entry group="0000" element="5010" vr="SH" vm="1" keyword="MessageSetID" name="Message Set ID" retired="true"/>
- <entry group="0000" element="5020" vr="SH" vm="1" keyword="EndMessageID" name="End Message ID" retired="true"/>
- <entry group="0000" element="5110" vr="LT" vm="1" keyword="DisplayFormat" name="Display Format" retired="true"/>
- <entry group="0000" element="5120" vr="LT" vm="1" keyword="PagePositionID" name="Page Position ID" retired="true"/>
- <entry group="0000" element="5130" vr="CS" vm="1" keyword="TextFormatID" name="Text Format ID" retired="true"/>
- <entry group="0000" element="5140" vr="CS" vm="1" keyword="NormalReverse" name="Normal/Reverse" retired="true"/>
- <entry group="0000" element="5150" vr="CS" vm="1" keyword="AddGrayScale" name="Add Gray Scale" retired="true"/>
- <entry group="0000" element="5160" vr="CS" vm="1" keyword="Borders" name="Borders" retired="true"/>
- <entry group="0000" element="5170" vr="IS" vm="1" keyword="Copies" name="Copies" retired="true"/>
- <entry group="0000" element="5180" vr="CS" vm="1" keyword="CommandMagnificationType" name="Command Magnification Type" retired="true"/>
- <entry group="0000" element="5190" vr="CS" vm="1" keyword="Erase" name="Erase" retired="true"/>
- <entry group="0000" element="51a0" vr="CS" vm="1" keyword="Print" name="Print" retired="true"/>
- <entry group="0000" element="51b0" vr="US" vm="1-n" keyword="Overlays" name="Overlays" retired="true"/>
- </dict>
diff --git a/Source/DataDictionary/Part7b.xml b/Source/DataDictionary/Part7b.xml
new file mode 100644
index 0000000..27c4f95
--- /dev/null
+++ b/Source/DataDictionary/Part7b.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Program: GDCM (Grassroots DICOM). A DICOM library
+
+ Copyright (c) 2006-2011 Mathieu Malaterre
+ All rights reserved.
+ See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notice for more information.
+-->
+ <dict ref="E.2" name="Retired command fields">
+ <entry group="0000" element="0001" vr="UL" vm="1" keyword="CommandLengthToEnd" name="Command Length to End" retired="true"/>
+ <entry group="0000" element="0010" vr="SH" vm="1" keyword="CommandRecognitionCode" name="Command Recognition Code" retired="true"/>
+ <entry group="0000" element="0200" vr="AE" vm="1" keyword="Initiator" name="Initiator" retired="true"/>
+ <entry group="0000" element="0300" vr="AE" vm="1" keyword="Receiver" name="Receiver" retired="true"/>
+ <entry group="0000" element="0400" vr="AE" vm="1" keyword="FindLocation" name="Find Location" retired="true"/>
+ <entry group="0000" element="0850" vr="US" vm="1" keyword="NumberOfMatches" name="Number of Matches" retired="true"/>
+ <entry group="0000" element="0860" vr="US" vm="1" keyword="ResponseSequenceNumber" name="Response Sequence Number" retired="true"/>
+ <entry group="0000" element="4000" vr="LT" vm="1" keyword="DialogReceiver" name="Dialog Receiver" retired="true"/>
+ <entry group="0000" element="4010" vr="LT" vm="1" keyword="TerminalType" name="Terminal Type" retired="true"/>
+ <entry group="0000" element="5010" vr="SH" vm="1" keyword="MessageSetID" name="Message Set ID" retired="true"/>
+ <entry group="0000" element="5020" vr="SH" vm="1" keyword="EndMessageID" name="End Message ID" retired="true"/>
+ <entry group="0000" element="5110" vr="LT" vm="1" keyword="DisplayFormat" name="Display Format" retired="true"/>
+ <entry group="0000" element="5120" vr="LT" vm="1" keyword="PagePositionID" name="Page Position ID" retired="true"/>
+ <entry group="0000" element="5130" vr="CS" vm="1" keyword="TextFormatID" name="Text Format ID" retired="true"/>
+ <entry group="0000" element="5140" vr="CS" vm="1" keyword="NormalReverse" name="Normal/Reverse" retired="true"/>
+ <entry group="0000" element="5150" vr="CS" vm="1" keyword="AddGrayScale" name="Add Gray Scale" retired="true"/>
+ <entry group="0000" element="5160" vr="CS" vm="1" keyword="Borders" name="Borders" retired="true"/>
+ <entry group="0000" element="5170" vr="IS" vm="1" keyword="Copies" name="Copies" retired="true"/>
+ <entry group="0000" element="5180" vr="CS" vm="1" keyword="CommandMagnificationType" name="Command Magnification Type" retired="true"/>
+ <entry group="0000" element="5190" vr="CS" vm="1" keyword="Erase" name="Erase" retired="true"/>
+ <entry group="0000" element="51a0" vr="CS" vm="1" keyword="Print" name="Print" retired="true"/>
+ <entry group="0000" element="51b0" vr="US" vm="1-n" keyword="Overlays" name="Overlays" retired="true"/>
+ </dict>
diff --git a/Source/MediaStorageAndFileFormat/gdcmJPEG2000Codec.cxx b/Source/MediaStorageAndFileFormat/gdcmJPEG2000Codec.cxx
index 66f4a61..3e54bad 100644
--- a/Source/MediaStorageAndFileFormat/gdcmJPEG2000Codec.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmJPEG2000Codec.cxx
@@ -83,7 +83,7 @@ typedef enum {
CDEF = 0x63646566,
CMAP = 0x636D6170,
PCLR = 0x70636c72,
- RES = 0x72657320,
+ RES = 0x72657320
} OtherType;
static inline bool hasnolength( uint_fast16_t marker )
diff --git a/Source/MediaStorageAndFileFormat/gdcmPixelFormat.h b/Source/MediaStorageAndFileFormat/gdcmPixelFormat.h
index c316816..ebaf421 100644
--- a/Source/MediaStorageAndFileFormat/gdcmPixelFormat.h
+++ b/Source/MediaStorageAndFileFormat/gdcmPixelFormat.h
@@ -103,6 +103,15 @@ public:
{
if( ba )
{
+ switch( ba )
+ {
+ /* some devices (FUJIFILM CR + MONO1) incorrectly set BitsAllocated/BitsStored
+ * as bitmask instead of value. Do what they mean instead of what they say.
+ */
+ case 0xffff: ba = 16; break;
+ case 0x0fff: ba = 12; break;
+ case 0x00ff: ba = 8; break;
+ }
BitsAllocated = ba;
BitsStored = ba;
HighBit = (unsigned short)(ba - 1);
@@ -122,6 +131,14 @@ public:
}
void SetBitsStored(unsigned short bs)
{
+ switch( bs )
+ {
+ /* see SetBitsAllocated for explanation
+ */
+ case 0xffff: bs = 16; break;
+ case 0x0fff: bs = 12; break;
+ case 0x00ff: bs = 8; break;
+ }
if( bs <= BitsAllocated && bs )
{
BitsStored = bs;
@@ -137,6 +154,15 @@ public:
}
void SetHighBit(unsigned short hb)
{
+ switch( hb )
+ {
+ /* broken implementations that use bitmask for BitsAllocated/Stored
+ * nonetheless use (BitsStored-1) for HighBit. correct for this here.
+ */
+ case 0xfffe: hb = 15; break;
+ case 0x0ffe: hb = 11; break;
+ case 0x00fe: hb = 7; break;
+ }
if( hb < BitsStored )
HighBit = hb;
}
diff --git a/Source/MediaStorageAndFileFormat/gdcmSegmentHelper.h b/Source/MediaStorageAndFileFormat/gdcmSegmentHelper.h
index 01ee18e..11f1f78 100644
--- a/Source/MediaStorageAndFileFormat/gdcmSegmentHelper.h
+++ b/Source/MediaStorageAndFileFormat/gdcmSegmentHelper.h
@@ -14,6 +14,8 @@
#ifndef GDCMSEGMENTHELPER_H
#define GDCMSEGMENTHELPER_H
+#include "gdcmTypes.h"
+
#include <string>
namespace gdcm
@@ -27,7 +29,7 @@ namespace SegmentHelper
*
* \see PS 3.3 section 8.8.
*/
-struct BasicCodedEntry
+struct GDCM_EXPORT BasicCodedEntry
{
/**
* \brief Constructor.
diff --git a/Source/MediaStorageAndFileFormat/gdcmStringFilter.cxx b/Source/MediaStorageAndFileFormat/gdcmStringFilter.cxx
index 535543f..4796d10 100644
--- a/Source/MediaStorageAndFileFormat/gdcmStringFilter.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmStringFilter.cxx
@@ -369,15 +369,9 @@ std::pair<std::string, std::string> StringFilter::ToStringPairInternal(const Dat
const VR &vr_read = de.GetVR();
const VR &vr_dict = entry.GetVR();
- if( vr_dict == VR::INVALID )
- {
- // FIXME This is a public element we do not support...
- return ret;
- }
-
VR vr;
// always prefer the vr from the file:
- if( vr_read == VR::INVALID )
+ if( vr_read == VR::INVALID && vr_dict != VR::INVALID )
{
vr = vr_dict;
}
@@ -389,7 +383,14 @@ std::pair<std::string, std::string> StringFilter::ToStringPairInternal(const Dat
{
vr = vr_read;
}
- if( vr.IsDual() ) // This mean vr was read from a dict entry:
+ if( vr == VR::INVALID )
+ {
+ // FIXME This is a public element we do not support...
+ gdcmDebugMacro( "DataElement does not specify the VR." );
+ return ret;
+ }
+
+ if( vr.IsDual() ) // This mean vr was read from a dict entry:
{
vr = DataSetHelper::ComputeVR(*F,ds, t);
}
diff --git a/Source/MediaStorageAndFileFormat/gdcmSurfaceHelper.h b/Source/MediaStorageAndFileFormat/gdcmSurfaceHelper.h
index fe71ed3..5674bcd 100644
--- a/Source/MediaStorageAndFileFormat/gdcmSurfaceHelper.h
+++ b/Source/MediaStorageAndFileFormat/gdcmSurfaceHelper.h
@@ -2,7 +2,7 @@
Program: GDCM (Grassroots DICOM). A DICOM library
- Copyright (c) 2006-2011 Mathieu Malaterre
+ Copyright (c) 2006-2017 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
@@ -136,23 +136,23 @@ SurfaceHelper::ColorArray SurfaceHelper::RGBToRecommendedDisplayCIELab(const std
// Convert to range 0x0000-0xFFFF
// 0xFFFF "=" 127, 0x8080 "=" 0, 0x0000 "=" -128
- CIELab[0] = (unsigned short) ( 0xFFFF * (tmp[0]*0.01f));
- if(tmp[1] >= -128 && tmp[1] <= 0)
- {
- CIELab[1] = (unsigned short)(((float)(0x8080)/128.0f)*tmp[1] + ((float)0x8080));
- }
- else if(tmp[1] <= 127 && tmp[1] > 0)
- {
- CIELab[1] = (unsigned short)(((float)(0xFFFF - 0x8080)/127.0f)*tmp[1] + (float)(0x8080));
- }
- if(tmp[2] >= -128 && tmp[2] <= 0)
- {
- CIELab[2] = (unsigned short)(((float)0x8080/128.0f)*tmp[2] + ((float)0x8080));
- }
- else if(tmp[2] <= 127 && tmp[2] > 0)
- {
- CIELab[2] = (unsigned short)(((float)(0xFFFF - 0x8080)/127.0f)*tmp[2] + (float)(0x8080));
- }
+ CIELab[0] = (unsigned short) ( 0xFFFF * (tmp[0]*0.01f));
+ if(tmp[1] >= -128 && tmp[1] <= 0)
+ {
+ CIELab[1] = (unsigned short)(((float)(0x8080)/128.0f)*tmp[1] + ((float)0x8080));
+ }
+ else if(tmp[1] <= 127 && tmp[1] > 0)
+ {
+ CIELab[1] = (unsigned short)(((float)(0xFFFF - 0x8080)/127.0f)*tmp[1] + (float)(0x8080));
+ }
+ if(tmp[2] >= -128 && tmp[2] <= 0)
+ {
+ CIELab[2] = (unsigned short)(((float)0x8080/128.0f)*tmp[2] + ((float)0x8080));
+ }
+ else if(tmp[2] <= 127 && tmp[2] > 0)
+ {
+ CIELab[2] = (unsigned short)(((float)(0xFFFF - 0x8080)/127.0f)*tmp[2] + (float)(0x8080));
+ }
return CIELab;
}
@@ -168,23 +168,23 @@ std::vector<T> SurfaceHelper::RecommendedDisplayCIELabToRGB(const ColorArray & C
// Convert to range 0-1
- tmp[0] = 100.0f*CIELab[0] /(float)(0xFFFF);
- if(CIELab[1] >= 0x0000 && CIELab[1] <= 0x8080)
- {
- tmp[1] = (float)(((CIELab[1] - 0x8080) * 128.0f)/(float)0x8080);
- }
- else if(CIELab[1] <= 0xFFFF && CIELab[1] > 0x8080)
- {
- tmp[1] = (float)((CIELab[1]-0x8080)*127.0f / (float)(0xFFFF - 0x8080));
- }
- if(CIELab[2] >= 0x0000 && CIELab[2] <= 0x8080)
- {
- tmp[2] = (float)(((CIELab[2] - 0x8080) * 128.0f)/(float)0x8080);
- }
- else if(CIELab[2] <= 0xFFFF && CIELab[2] > 0x8080)
- {
- tmp[2] = (float)((CIELab[2]-0x8080)*127.0f / (float)(0XFFFF - 0x8080));
- }
+ tmp[0] = 100.0f*CIELab[0] /(float)(0xFFFF);
+ if(CIELab[1] <= 0x8080)
+ {
+ tmp[1] = (float)(((CIELab[1] - 0x8080) * 128.0f)/(float)0x8080);
+ }
+ else
+ {
+ tmp[1] = (float)((CIELab[1]-0x8080)*127.0f / (float)(0xFFFF - 0x8080));
+ }
+ if(CIELab[2] <= 0x8080)
+ {
+ tmp[2] = (float)(((CIELab[2] - 0x8080) * 128.0f)/(float)0x8080);
+ }
+ else
+ {
+ tmp[2] = (float)((CIELab[2]-0x8080)*127.0f / (float)(0XFFFF - 0x8080));
+ }
tmp = SurfaceHelper::XYZToRGB( SurfaceHelper::CIELabToXYZ( tmp ) );
diff --git a/Source/MessageExchangeDefinition/gdcmULTransitionTable.cxx b/Source/MessageExchangeDefinition/gdcmULTransitionTable.cxx
index 6a3249f..e9c6fb0 100644
--- a/Source/MessageExchangeDefinition/gdcmULTransitionTable.cxx
+++ b/Source/MessageExchangeDefinition/gdcmULTransitionTable.cxx
@@ -325,7 +325,7 @@ void ULTransitionTable::HandleEvent(Subject *s, ULEvent& inEvent, ULConnection&
bool& outWaitingForEvent, EEventID& outRaisedEvent) const{
//first, find the Event
EEventID eventID = inEvent.GetEvent();
- if (eventID >= 0 && eventID < eEventDoesNotExist)
+ if (eventID < eEventDoesNotExist)
{ //make sure that the event exists
//have to convert the state ID into an index
int stateIndex = GetStateIndex(inConnection.GetState());
diff --git a/Testing/Source/Data/CMakeLists.txt b/Testing/Source/Data/CMakeLists.txt
index 166e2d8..7db915e 100644
--- a/Testing/Source/Data/CMakeLists.txt
+++ b/Testing/Source/Data/CMakeLists.txt
@@ -70,6 +70,9 @@ set(BLACK_LIST_READER
JPEG_LS_InvalidEscapeSequence_COM_padding.dcm
# MITRA_CORNELL
MITRA_CORNELL.dcm
+ EmptyIcon_Bug417.dcm
+ EnhancedWithIPPPerFrameIOPShared.dcm
+ FUJI-ffff-MONO1-J2K.dcm
)
if(NOT GDCM_USE_PVRG)
set(BLACK_LIST_READER
diff --git a/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestAttribute1.cxx b/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestAttribute1.cxx
index b679fb0..5dea1e2 100644
--- a/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestAttribute1.cxx
+++ b/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestAttribute1.cxx
@@ -145,7 +145,8 @@ int TestAttributeDS()
gdcm::DataElement valid = pw.GetAsDataElement();
std::ostringstream os;
os << valid.GetValue();
- size_t l = os.str().size();
+ std::string s = os.str();
+ size_t l = s.size();
if( l > 16 )
{
return 1;
diff --git a/Testing/Source/DataStructureAndEncodingDefinition/Java/CMakeLists.txt b/Testing/Source/DataStructureAndEncodingDefinition/Java/CMakeLists.txt
index 1d0cf53..6e07cdd 100644
--- a/Testing/Source/DataStructureAndEncodingDefinition/Java/CMakeLists.txt
+++ b/Testing/Source/DataStructureAndEncodingDefinition/Java/CMakeLists.txt
@@ -1,6 +1,8 @@
# Define the tests for gdcm-java
set(GDCM_JAVA_TEST_SRCS
TestReader
+ TestTag
+ TestReaderUpToTag
)
# Do not change anything after here:
diff --git a/Testing/Source/DataStructureAndEncodingDefinition/Java/TestReaderUpToTag.java b/Testing/Source/DataStructureAndEncodingDefinition/Java/TestReaderUpToTag.java
new file mode 100644
index 0000000..3d0a87a
--- /dev/null
+++ b/Testing/Source/DataStructureAndEncodingDefinition/Java/TestReaderUpToTag.java
@@ -0,0 +1,100 @@
+/*=========================================================================
+
+ Program: GDCM (Grassroots DICOM). A DICOM library
+
+ Copyright (c) 2006-2011 Mathieu Malaterre
+ All rights reserved.
+ See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notice for more information.
+
+=========================================================================*/
+/*
+ */
+import gdcm.*;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.List;
+import java.util.ArrayList;
+
+public class TestReaderUpToTag
+{
+ private static void PrintTagSet( Set<Tag> s ) {
+ for( Tag t : s ) {
+ System.out.println("Print: " + t);
+ }
+ }
+
+ private static SortedSet<Tag> getTagSet() {
+ Tag tags[] = {
+ new Tag(0x8,0x8),
+ new Tag(0x8,0x16),
+ new Tag(0x8,0x18),
+ new Tag(0x8,0x60),
+ new Tag(0x10,0x20),
+ new Tag(0x28,0x2),
+ new Tag(0x28,0x10),
+ new Tag(0x28,0x11),
+ new Tag(0x10,0x10) };
+ SortedSet<Tag> tagSet = new TreeSet<Tag>();
+ for( Tag tag : tags ) {
+ tagSet.add( tag );
+ }
+ return tagSet;
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ long nfiles = Testing.GetNumberOfFileNames();
+
+ SortedSet<Tag> tagSet = getTagSet();
+ PrintTagSet( tagSet );
+ Tag last = tagSet.last();
+ System.out.println("last: " + last);
+ TagSetType skip = new TagSetType();
+ Tag pixelData = new Tag(0x7fe0,0x0010);
+ skip.insert( pixelData );
+ Trace.DebugOff();
+ Trace.WarningOff();
+ StringFilter sf = new StringFilter();
+ List<Set<Tag>> l = new ArrayList<Set<Tag>>();
+ for( long i = 0; i < nfiles; ++i ) {
+ Set<Tag> s = new HashSet<Tag>();
+ String filename = Testing.GetFileName( i );
+ if( true || filename.contains( "ExplicitVRforPublicElementsImplicitVRforShadowElements" )
+ || filename.contains( "SIEMENS_SOMATOM-12-ACR_NEMA-ZeroLengthUs" )
+ ) {
+ Reader reader = new Reader();
+ reader.SetFileName( filename );
+ if ( !reader.ReadUpToTag(pixelData, skip) )
+ {
+ throw new Exception("Could not read: " + filename );
+ }
+ System.out.println("reading: " + filename);
+ File file = reader.GetFile();
+ sf.SetFile( file );
+ DataSet ds = file.GetDataSet();
+ for( Tag tag : tagSet ) {
+ if( ds.FindDataElement( tag ) ) {
+ s.add( tag );
+ DataElement de = ds.GetDataElement( tag );
+ System.out.println("de: " + tag + " -> " + sf.ToString( de ) );
+ }
+ }
+ }
+ l.add( s );
+ // PrintTagSet( s );
+ System.gc ();
+ }
+ System.gc ();
+ System.runFinalization ();
+ for( Set<Tag> s : l ) {
+ PrintTagSet( s );
+ }
+ PrintTagSet( tagSet );
+ }
+}
diff --git a/Testing/Source/DataStructureAndEncodingDefinition/Java/TestTag.java b/Testing/Source/DataStructureAndEncodingDefinition/Java/TestTag.java
new file mode 100644
index 0000000..7ddc256
--- /dev/null
+++ b/Testing/Source/DataStructureAndEncodingDefinition/Java/TestTag.java
@@ -0,0 +1,58 @@
+/*=========================================================================
+
+ Program: GDCM (Grassroots DICOM). A DICOM library
+
+ Copyright (c) 2006-2011 Mathieu Malaterre
+ All rights reserved.
+ See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notice for more information.
+
+=========================================================================*/
+/*
+ */
+import gdcm.Tag;
+import java.util.Set;
+import java.util.HashSet;
+
+public class TestTag
+{
+ public static void main(String[] args) throws Exception
+ {
+ Tag t1 = new Tag(0x8,0x8);
+ //System.out.println("t1: " + t1.hashCode());
+ Tag t2 = new Tag(0x8,0x8);
+ //System.out.println("t2: " + t2.hashCode());
+ Tag t3 = new Tag(0x8,0x9);
+ if( t1 == t2 )
+ throw new Exception("Instances are identical" );
+ if( !t1.equals(t2) )
+ throw new Exception("Instances are different" );
+ if( !t2.equals(t1) )
+ throw new Exception("Instances are different" );
+ if( t1.equals(t3) )
+ throw new Exception("Instances are equals" );
+ if( t1.hashCode() != t2.hashCode() )
+ throw new Exception("hashCodes are different" );
+ Set<Tag> s = new HashSet<Tag>();
+ s.add(t1);
+ s.add(t2);
+ s.add(t3);
+ if( s.size() != 2 )
+ throw new Exception("Invalid size: " + s.size() );
+ //System.out.println("compareTo: " + t1.compareTo(t2));
+ //System.out.println("compareTo: " + t2.compareTo(t1));
+ //System.out.println("compareTo: " + t1.compareTo(t3));
+ //System.out.println("compareTo: " + t3.compareTo(t1));
+ if( t1.compareTo(t2) != 0 )
+ throw new Exception("Invalid compareTo: " + t1 + " vs " + t2 );
+ if( t2.compareTo(t1) != 0 )
+ throw new Exception("Invalid compareTo: " + t1 + " vs " + t2 );
+ if( t1.compareTo(t3) >= 0 )
+ throw new Exception("Invalid compareTo: " + t1 + " vs " + t3 );
+ if( t3.compareTo(t1) <= 0 )
+ throw new Exception("Invalid compareTo: " + t1 + " vs " + t3 );
+ }
+}
diff --git a/Utilities/C99/stdint.h b/Utilities/C99/stdint.h
index c66fbb8..4fe0ef9 100644
--- a/Utilities/C99/stdint.h
+++ b/Utilities/C99/stdint.h
@@ -1,32 +1,33 @@
// ISO C9x compliant stdint.h for Microsoft Visual Studio
-// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
-//
-// Copyright (c) 2006-2008 Alexander Chemeris
-//
+// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
+//
+// Copyright (c) 2006-2013 Alexander Chemeris
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
-//
+//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
-//
+//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
-//
-// 3. The name of the author may be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
+//
+// 3. Neither the name of the product nor the names of its contributors may
+// be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
+//
///////////////////////////////////////////////////////////////////////////////
#ifndef _MSC_VER // [
@@ -40,6 +41,10 @@
#pragma once
#endif
+#if _MSC_VER >= 1600 // [
+#include <stdint.h>
+#else // ] _MSC_VER >= 1600 [
+
#include <limits.h>
// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
@@ -238,10 +243,17 @@ typedef uint64_t uintmax_t;
#define UINT64_C(val) val##ui64
// 7.18.4.2 Macros for greatest-width integer constants
-#define INTMAX_C INT64_C
-#define UINTMAX_C UINT64_C
+// These #ifndef's are needed to prevent collisions with <boost/cstdint.hpp>.
+// Check out Issue 9 for the details.
+#ifndef INTMAX_C // [
+# define INTMAX_C INT64_C
+#endif // INTMAX_C ]
+#ifndef UINTMAX_C // [
+# define UINTMAX_C UINT64_C
+#endif // UINTMAX_C ]
#endif // __STDC_CONSTANT_MACROS ]
+#endif // _MSC_VER >= 1600 ]
#endif // _MSC_STDINT_H_ ]
diff --git a/Utilities/VTK/CMakeLists.txt b/Utilities/VTK/CMakeLists.txt
index 77fdd96..e4c4d0d 100644
--- a/Utilities/VTK/CMakeLists.txt
+++ b/Utilities/VTK/CMakeLists.txt
@@ -290,7 +290,7 @@ if(GDCM_WRAP_CSHARP)
set(CMAKE_SWIG_FLAGS "-namespace vtkgdcm -dllimport vtkgdcmsharpglue")
separate_arguments(CMAKE_SWIG_FLAGS)
SWIG_ADD_MODULE(vtkgdcmsharpglue csharp vtkgdcm.i)
- SWIG_LINK_LIBRARIES(vtkgdcmsharpglue vtkgdcm)
+ target_link_libraries(${SWIG_MODULE_vtkgdcmsharpglue_REAL_NAME} LINK_PRIVATE vtkgdcm)
# Stupid cmake-swig module is doing that for us, when not needed
if(UNIX)
set_target_properties(${SWIG_MODULE_vtkgdcmsharpglue_REAL_NAME} PROPERTIES PREFIX "lib")
diff --git a/Utilities/gdcmcharls/encoderstrategy.h b/Utilities/gdcmcharls/encoderstrategy.h
index 1c8cb45..f8f71e9 100644
--- a/Utilities/gdcmcharls/encoderstrategy.h
+++ b/Utilities/gdcmcharls/encoderstrategy.h
@@ -91,12 +91,12 @@ protected:
valcurrent |= value >> -bitpos;
Flush();
- // A second flush may be required if extra marker-detect bits were needed and not all bits could be written.
- if (bitpos < 0)
- {
- valcurrent |= value >> -bitpos;
- Flush();
- }
+ // A second flush may be required if extra marker-detect bits were needed and not all bits could be written.
+ if (bitpos < 0)
+ {
+ valcurrent |= value >> -bitpos;
+ Flush();
+ }
ASSERT(bitpos >=0);
valcurrent |= value << bitpos;
diff --git a/Utilities/gdcmcharls/header.cpp b/Utilities/gdcmcharls/header.cpp
index 9ddedc8..96dc538 100644
--- a/Utilities/gdcmcharls/header.cpp
+++ b/Utilities/gdcmcharls/header.cpp
@@ -47,7 +47,7 @@ JLS_ERROR CheckParameterCoherent(const JlsParameters* pparams)
if (pparams->bitspersample < 2 || pparams->bitspersample > 16)
return ParameterValueNotSupported;
- if (pparams->ilv < 0 || pparams->ilv > 2)
+ if (/*pparams->ilv < 0 ||*/ pparams->ilv > 2)
return InvalidCompressedData;
switch (pparams->components)
diff --git a/Utilities/gdcmcharls/header.h b/Utilities/gdcmcharls/header.h
index 9aed4bb..b511a00 100644
--- a/Utilities/gdcmcharls/header.h
+++ b/Utilities/gdcmcharls/header.h
@@ -7,7 +7,6 @@
#define CHARLS_HEADER
#include "jpegmarker.h"
-#include "encoderstrategy.h"
// JPEG Marker codes have the pattern 0xFFaa. The valid 'aa' options are defined by several ITU / IEC standards.
// 0x00, 0x01, 0xFE, 0xC0-0xDF are defined in ITU T.81/IEC 10918-1
@@ -63,17 +62,6 @@ private:
STRATEGY* GetCodecImpl(const JlsParameters& info);
};
-
-#if defined(__clang__)
-# define CHARLS_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__)
-# define CHARLS_USE_EXTERN_TEMPLATES (CHARLS_CLANG_VERSION >= 209)
-#endif
-
-#if CHARLS_USE_EXTERN_TEMPLATES
-extern template class JlsCodecFactory<EncoderStrategy>;
-extern template class JlsCodecFactory<DecoderStrategy>;
-#endif
-
JLS_ERROR CheckParameterCoherent(const JlsParameters* pparams);
JlsCustomParameters ComputeDefault(LONG MAXVAL, LONG NEAR);
diff --git a/Utilities/gdcmopenjpeg/doc/.gitkeep b/Utilities/gdcmopenjpeg/doc/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/Utilities/gdcmutfcpp/utf8.h b/Utilities/gdcmutfcpp/utf8.h
index 4e44514..82b13f5 100644
--- a/Utilities/gdcmutfcpp/utf8.h
+++ b/Utilities/gdcmutfcpp/utf8.h
@@ -1,34 +1,34 @@
-// Copyright 2006 Nemanja Trifunovic
-
-/*
-Permission is hereby granted, free of charge, to any person or organization
-obtaining a copy of the software and accompanying documentation covered by
-this license (the "Software") to use, reproduce, display, distribute,
-execute, and transmit the Software, and to prepare derivative works of the
-Software, and to permit third-parties to whom the Software is furnished to
-do so, all subject to the following:
-
-The copyright notices in the Software and this entire statement, including
-the above license grant, this restriction and the following disclaimer,
-must be included in all copies of the Software, in whole or in part, and
-all derivative works of the Software, unless such copies or derivative
-works are solely in the form of machine-executable object code generated by
-a source language processor.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
-*/
-
-
-#ifndef UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
-#define UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
-
-#include "utf8/checked.h"
-#include "utf8/unchecked.h"
-
-#endif // header guard
+// Copyright 2006 Nemanja Trifunovic
+
+/*
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+*/
+
+
+#ifndef UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
+#define UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
+
+#include "utf8/checked.h"
+#include "utf8/unchecked.h"
+
+#endif // header guard
diff --git a/Wrapping/Java/CMakeLists.txt b/Wrapping/Java/CMakeLists.txt
index ef264f1..7763778 100644
--- a/Wrapping/Java/CMakeLists.txt
+++ b/Wrapping/Java/CMakeLists.txt
@@ -1,6 +1,9 @@
find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})
option(GDCM_AUTOLOAD_GDCMJNI "Automatically load gdcmjni" ON)
+option(GDCM_JAVA_INCLUDE_SRC "Add source (*.java) to jar file" OFF)
+option(GDCM_BUILD_FULL_JAVA_JAR "Build gdcm jar with encapsulated gdcmjni" OFF)
+mark_as_advanced(GDCM_AUTOLOAD_GDCMJNI GDCM_JAVA_INCLUDE_SRC GDCM_BUILD_FULL_JAVA_JAR)
include_directories(
"${GDCM_BINARY_DIR}/Source/Common"
@@ -65,6 +68,10 @@ if(CMAKE_COMPILER_IS_GNUCXX)
PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing")
endif()
+if(GDCM_JAVA_INCLUDE_SRC)
+ set(GDCM_JAVA_SRCS "gdcm/*.java")
+endif()
+
add_custom_command(
OUTPUT ${GDCM_LIBRARY_DIR}/gdcm.jar
# 1. run the custom command only when the gdcmJAVA_wrap.cxx has been generated
@@ -77,15 +84,37 @@ add_custom_command(
# 2. now that the *.class have been generated construct the jar file. We can
# only rely on the gdcm.java / gdcm.class to build dependencie, I am pretty
# sure it will break parallel builds... oh well
- COMMAND ${Java_JAR_EXECUTABLE} ARGS cvf ${GDCM_LIBRARY_DIR}/gdcm.jar gdcm/*.class
+ COMMAND ${Java_JAR_EXECUTABLE} ARGS cf ${GDCM_LIBRARY_DIR}/gdcm.jar gdcm/*.class ${GDCM_JAVA_SRCS}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/java
DEPENDS "${swig_generated_file_fullname}"
- COMMENT "javac *.java; jar cvf -> gdcm.jar"
+ COMMENT "javac *.java; jar cf -> gdcm.jar"
)
+if(GDCM_BUILD_FULL_JAVA_JAR)
+ if(NOT GDCM_AUTOLOAD_GDCMJNI)
+ message(FATAL_ERROR "Dont know how to handle full jar without autoload option")
+ endif()
+ if(BUILD_SHARED_LIBS)
+ message(FATAL_ERROR "Dont know how to package gdcmjni with shared gdcm core libs.")
+ endif()
+ set(GDCM_JAVA_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
+ set(GDCM_JAVA_JAR_FULL gdcm-${GDCM_VERSION}-${GDCM_JAVA_SYSTEM_NAME}.jar)
+ add_custom_command(
+ OUTPUT ${GDCM_LIBRARY_DIR}/${GDCM_JAVA_JAR_FULL}
+ #COMMAND ${CMAKE_COMMAND} ARGS -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/java/lib
+ COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different $<TARGET_FILE:${SWIG_MODULE_gdcmjni_REAL_NAME}> ${CMAKE_CURRENT_BINARY_DIR}/java/
+ COMMAND ${Java_JAR_EXECUTABLE} ARGS cf ${GDCM_LIBRARY_DIR}/${GDCM_JAVA_JAR_FULL} gdcm/*.class ${GDCM_JAVA_SRCS} *gdcmjni*
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/java
+ DEPENDS ${GDCM_LIBRARY_DIR}/gdcm.jar
+ COMMENT "javac *.java; jar cf -> ${GDCM_JAVA_JAR_FULL}"
+ )
+endif()
+
# 3. ok now add the target
add_custom_target(GDCMJavaJar ALL
DEPENDS ${GDCM_LIBRARY_DIR}/gdcm.jar
+ ${SWIG_MODULE_gdcmjni_REAL_NAME}
+ ${GDCM_LIBRARY_DIR}/${GDCM_JAVA_JAR_FULL}
COMMENT "building gdcm.jar"
)
@@ -96,4 +125,9 @@ if(NOT GDCM_INSTALL_NO_LIBRARIES)
install(FILES ${GDCM_LIBRARY_DIR2}/gdcm.jar
DESTINATION ${GDCM_INSTALL_JARMODULE_DIR} COMPONENT JavaModule
)
+ if(GDCM_BUILD_FULL_JAVA_JAR)
+ install(FILES ${GDCM_LIBRARY_DIR2}/${GDCM_JAVA_JAR_FULL}
+ DESTINATION ${GDCM_INSTALL_JARMODULE_DIR} COMPONENT JavaModule
+ )
+ endif()
endif()
diff --git a/Wrapping/Java/gdcm.i b/Wrapping/Java/gdcm.i
index 21126e1..dd1467e 100644
--- a/Wrapping/Java/gdcm.i
+++ b/Wrapping/Java/gdcm.i
@@ -244,11 +244,78 @@ EXTEND_CLASS_PRINT_GENERAL(toString,classname)
// Need to be located *after* gdcmConfigure.h
#ifdef GDCM_AUTOLOAD_GDCMJNI
%pragma(java) jniclasscode=%{
+private final static String GDCMJNI = "gdcmjni";
static {
+ if( isFullJar() ) {
+ loadFromJar();
+ } else {
+ try {
+ // System.out.println(System.getProperty("java.library.path"));
+ System.loadLibrary(GDCMJNI);
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. \n" + e);
+ System.exit(1);
+ }
+ }
+ }
+
+ // https://stackoverflow.com/questions/228477/how-do-i-programmatically-determine-operating-system-in-java
+ private static boolean isWindows() {
+ final String OS = System.getProperty("os.name").toLowerCase();
+ return (OS.indexOf("win") >= 0);
+ }
+ private static boolean isUnix() {
+ final String OS = System.getProperty("os.name").toLowerCase();
+ return (OS.indexOf("nux") >= 0);
+ }
+ private static String getLibName() {
+ if( isWindows() ) {
+ final String name = "/" + GDCMJNI + ".dll";
+ return name;
+ } else if( isUnix() ) {
+ final String name = "/lib" + GDCMJNI + ".so";
+ return name;
+ }
+ return null;
+ }
+
+ // https://stackoverflow.com/questions/1611357/how-to-make-a-jar-file-that-includes-dll-files
+ private static boolean isFullJar() {
+ final String name = getLibName();
+ final java.net.URL u = gdcmJNI.class.getResource(name);
+ if (u != null) {
+ return true;
+ }
+ return false;
+ }
+
+ private static void loadFromJar() {
+ final String path = "GDCM_" + new java.util.Date().getTime();
+ loadLib(path, GDCMJNI);
+ }
+
+/**
+ * Puts library to temp dir and loads to memory
+ */
+ private static void loadLib(String path, String name) {
+ name = getLibName();
try {
- System.loadLibrary("gdcmjni");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
+ java.io.InputStream in = gdcmJNI.class.getResourceAsStream(name);
+ // always write to different location
+ java.io.File fileOut = new java.io.File(System.getProperty("java.io.tmpdir") + "/" + path + name);
+ // create intermediate directory:
+ fileOut.getParentFile().mkdirs();
+ byte[] buffer = new byte[1024];
+ int read = -1;
+ java.io.FileOutputStream fos = new java.io.FileOutputStream(fileOut);
+ while((read = in.read(buffer)) != -1) {
+ fos.write(buffer, 0, read);
+ }
+ in.close();
+ fos.close();
+ System.load(fileOut.getAbsolutePath());
+ } catch (Exception e) {
+ System.err.println("Jar code library failed to load. \n" + e);
System.exit(1);
}
}
@@ -310,10 +377,40 @@ EXTEND_CLASS_PRINT(gdcm::PixelFormat)
//%include "enumtypesafe.swg" // optional as typesafe enums are the default
EXTEND_CLASS_PRINT(gdcm::MediaStorage)
-//%rename(__getitem__) gdcm::Tag::operator[];
-//%rename(this ) gdcm::Tag::operator[];
+%rename(equals) gdcm::Tag::operator==;
+//%typemap(javain, pgcppname="(Tag)$javainput") const gdcm::Tag& _val "$javaclassname.getCPtr((Tag)$javainput)"
+//%typemap(jstype) const gdcm::Tag& _val "java.lang.Object"
+%typemap(javacode) gdcm::Tag %{
+ @Override
+ public boolean equals(java.lang.Object obj) {
+ boolean equal = false;
+ if (obj instanceof $javaclassname)
+ equal = (($javaclassname)obj).equals(this);
+ return equal;
+ }
+%}
+%typemap(javainterfaces) gdcm::Tag "Comparable<Tag>";
%include "gdcmTag.h"
EXTEND_CLASS_PRINT(gdcm::Tag)
+%javamethodmodifiers gdcm::Tag::equals %{@Override
+ public%};
+%javamethodmodifiers gdcm::Tag::hashCode %{@Override
+ public%};
+%javamethodmodifiers gdcm::Tag::compareTo %{@Override
+ public%};
+%extend gdcm::Tag {
+ int hashCode() {
+ return (int)self->GetElementTag();
+ }
+ int compareTo(Tag t) {
+ if( *self == t ) return 0;
+ if( *self < t ) return -1;
+ return 1;
+ }
+};
+%typemap(javacode) gdcm::Tag;
+%typemap(javainterfaces) gdcm::Tag;
+
%include "gdcmPrivateTag.h"
EXTEND_CLASS_PRINT(gdcm::PrivateTag)
@@ -671,11 +768,17 @@ $1 = JNU_GetStringNativeChars(jenv, $input);
%include "gdcmCommand.h"
%template(SmartPtrScan) gdcm::SmartPointer<gdcm::Scanner>;
+%template (TagToValue) std::map<gdcm::Tag, const char*>;
+//%template (TagToValueType) std::map<gdcm::Tag, const char*>::value_type;
+%template (MappingType) std::map<const char*,gdcm::Scanner::TagToValue>;
%include "gdcmScanner.h"
EXTEND_CLASS_PRINT(gdcm::Scanner)
%template(SmartPtrStrictScan) gdcm::SmartPointer<gdcm::StrictScanner>;
%include "gdcmStrictScanner.h"
EXTEND_CLASS_PRINT(gdcm::StrictScanner)
+%clear TagToValue;
+//%clear TagToValueType;
+%clear MappingType;
%template(SmartPtrAno) gdcm::SmartPointer<gdcm::Anonymizer>;
//%ignore gdcm::Anonymizer::Anonymizer;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/gdcm.git
More information about the debian-med-commit
mailing list