Skip to content

Commit fe39191

Browse files
GDCM Upstreamseanm
authored andcommitted
GDCM 2025-09-11 (ad32c844)
Code extracted from: https://github.com/malaterre/GDCM.git at commit ad32c84455296a204192342dd0fa03bcbfaed479 (v3.2.1).
1 parent d54614b commit fe39191

261 files changed

Lines changed: 3206 additions & 3744 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ endif()
1010
#----------------------------------------------------------------------------
1111

1212
project(GDCM
13-
VERSION 3.0.25
13+
VERSION 3.2.1
1414
LANGUAGES CXX C
1515
)
1616
## NOTE: the "DESCRIPTION" feature of project() was introduced in cmake 3.10.0
@@ -521,7 +521,7 @@ if(GDCM_STANDALONE)
521521
endif()
522522
if(NOT DEFINED GDCM_DEFAULT_JAVA_VERSION)
523523
# override with cmake -DGDCM_DEFAULT_JAVA_VERSION:STRING=1.5 if you dare
524-
set(GDCM_DEFAULT_JAVA_VERSION 1.7)
524+
set(GDCM_DEFAULT_JAVA_VERSION 1.8)
525525
endif()
526526
if(GDCM_WRAP_JAVA)
527527
set(GDCM_JAVA_SOURCE_VERSION "${GDCM_DEFAULT_JAVA_VERSION}" CACHE STRING "javac source version")
@@ -693,24 +693,45 @@ if(GDCM_STANDALONE)
693693
)
694694

695695
# documented at https://vtk.org/doc/nightly/html/group__module.html
696-
vtk_module_build(
697-
MODULES ${vtkgdcm_modules}
698-
INSTALL_EXPORT GDCM
699-
ARCHIVE_DESTINATION "${GDCM_INSTALL_LIB_DIR}"
700-
HEADERS_DESTINATION "${GDCM_INSTALL_INCLUDE_DIR}/vtk${vtk_version_suffix}"
701-
CMAKE_DESTINATION "${GDCM_INSTALL_PACKAGE_DIR}"
702-
LICENSE_DESTINATION "${GDCM_INSTALL_DATA_DIR}/vtkgdcm-${GDCM_SHORT_VERSION}"
703-
SPDX_DESTINATION "${GDCM_INSTALL_DATA_DIR}/vtkgdcm-${GDCM_SHORT_VERSION}"
704-
HIERARCHY_DESTINATION "${GDCM_INSTALL_LIB_DIR}/vtk${vtk_version_suffix}/hierarchy/vtkgdcm"
705-
LIBRARY_NAME_SUFFIX "${vtkgdcm_library_suffix}"
706-
VERSION "${GDCM_VERSION}"
707-
SOVERSION "1"
708-
# TODO: these are probably not set as they should be
709-
#USE_EXTERNAL "${GDCM_USE_EXTERNAL}"
710-
#TEST_DATA_TARGET vtkgdcmData
711-
#TEST_INPUT_DATA_DIRECTORY "${vtkgdcm_test_data_directory_input}"
712-
#TEST_OUTPUT_DATA_DIRECTORY "${vtkgdcm_test_data_directory_output}"
713-
)
696+
if(VTK_VERSION VERSION_LESS 9.3)
697+
vtk_module_build(
698+
MODULES ${vtkgdcm_modules}
699+
INSTALL_EXPORT GDCM
700+
ARCHIVE_DESTINATION "${GDCM_INSTALL_LIB_DIR}"
701+
HEADERS_DESTINATION "${GDCM_INSTALL_INCLUDE_DIR}/vtk${vtk_version_suffix}"
702+
CMAKE_DESTINATION "${GDCM_INSTALL_PACKAGE_DIR}"
703+
LICENSE_DESTINATION "${GDCM_INSTALL_DATA_DIR}/vtkgdcm-${GDCM_SHORT_VERSION}"
704+
#SPDX_DESTINATION "${GDCM_INSTALL_DATA_DIR}/vtkgdcm-${GDCM_SHORT_VERSION}"
705+
HIERARCHY_DESTINATION "${GDCM_INSTALL_LIB_DIR}/vtk${vtk_version_suffix}/hierarchy/vtkgdcm"
706+
LIBRARY_NAME_SUFFIX "${vtkgdcm_library_suffix}"
707+
VERSION "${GDCM_VERSION}"
708+
SOVERSION "1"
709+
# TODO: these are probably not set as they should be
710+
#USE_EXTERNAL "${GDCM_USE_EXTERNAL}"
711+
#TEST_DATA_TARGET vtkgdcmData
712+
#TEST_INPUT_DATA_DIRECTORY "${vtkgdcm_test_data_directory_input}"
713+
#TEST_OUTPUT_DATA_DIRECTORY "${vtkgdcm_test_data_directory_output}"
714+
)
715+
else()
716+
vtk_module_build(
717+
MODULES ${vtkgdcm_modules}
718+
INSTALL_EXPORT GDCM
719+
ARCHIVE_DESTINATION "${GDCM_INSTALL_LIB_DIR}"
720+
HEADERS_DESTINATION "${GDCM_INSTALL_INCLUDE_DIR}/vtk${vtk_version_suffix}"
721+
CMAKE_DESTINATION "${GDCM_INSTALL_PACKAGE_DIR}"
722+
LICENSE_DESTINATION "${GDCM_INSTALL_DATA_DIR}/vtkgdcm-${GDCM_SHORT_VERSION}"
723+
SPDX_DESTINATION "${GDCM_INSTALL_DATA_DIR}/vtkgdcm-${GDCM_SHORT_VERSION}"
724+
HIERARCHY_DESTINATION "${GDCM_INSTALL_LIB_DIR}/vtk${vtk_version_suffix}/hierarchy/vtkgdcm"
725+
LIBRARY_NAME_SUFFIX "${vtkgdcm_library_suffix}"
726+
VERSION "${GDCM_VERSION}"
727+
SOVERSION "1"
728+
# TODO: these are probably not set as they should be
729+
#USE_EXTERNAL "${GDCM_USE_EXTERNAL}"
730+
#TEST_DATA_TARGET vtkgdcmData
731+
#TEST_INPUT_DATA_DIRECTORY "${vtkgdcm_test_data_directory_input}"
732+
#TEST_OUTPUT_DATA_DIRECTORY "${vtkgdcm_test_data_directory_output}"
733+
)
734+
endif()
714735

715736
if(VTKGDCM_WRAP_PYTHON)
716737
find_package(PythonInterp ${VTK_PYTHON_VERSION} QUIET)

Source/Common/gdcmASN1.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ bool ASN1::ParseDump(const char *array, size_t length)
7373
BIO *out=NULL;
7474

7575
out=BIO_new(BIO_s_file());
76-
assert( out );
76+
gdcm_assert( out );
7777
BIO_set_fp(out,stdout,BIO_NOCLOSE|BIO_FP_TEXT);
7878
if (!ASN1_parse_dump(out,(const unsigned char*)array,length,indent,dump) )
7979
{

Source/Common/gdcmBoxRegion.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Region *BoxRegion::Clone() const
6767

6868
bool BoxRegion::Empty() const
6969
{
70-
assert( 0 );
70+
gdcm_assert( 0 );
7171
return false;
7272
}
7373

@@ -146,14 +146,14 @@ BoxRegion BoxRegion::BoundingBox(BoxRegion const & b1, BoxRegion const & b2 )
146146

147147
BoxRegion::BoxRegion(const BoxRegion& b)
148148
{
149-
assert( b.Internals );
149+
gdcm_assert( b.Internals );
150150
Internals = new BoxRegionInternals;
151151
*Internals = *b.Internals;
152152
}
153153

154154
void BoxRegion::operator=(const BoxRegion& b)
155155
{
156-
assert( b.Internals );
156+
gdcm_assert( b.Internals );
157157
*Internals = *b.Internals;
158158
}
159159

Source/Common/gdcmCAPICryptographicMessageSyntax.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ bool CAPICryptographicMessageSyntax::Decrypt(char *output, size_t &outlen, const
313313
keyBlob.header.reserved = 0;
314314
keyBlob.header.aiKeyAlg = GetAlgIdByObjId(cekAlg->pszObjId);
315315
keyBlob.cbKeySize = cekLen;
316-
assert(cekLen <= 32);
316+
gdcm_assert(cekLen <= 32);
317317
memcpy(keyBlob.rgbKeyData, cek, cekLen);
318318

319319
if (!CryptImportKey(hProv, (unsigned char*)&keyBlob, sizeof(keyBlob), 0, 0, &hCEK))
@@ -480,7 +480,7 @@ void CAPICryptographicMessageSyntax::ReverseBytes(unsigned char* data, DWORD len
480480

481481
bool CAPICryptographicMessageSyntax::LoadFile(const char * filename, unsigned char* & buffer, DWORD & bufLen)
482482
{
483-
assert( !buffer );
483+
gdcm_assert( !buffer );
484484
FILE * f = fopen(filename, "rb");
485485
if (f == NULL)
486486
{

Source/Common/gdcmCommand.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class MemberCommand : public Command
115115
T* m_This;
116116
TMemberFunctionPointer m_MemberFunction;
117117
TConstMemberFunctionPointer m_ConstMemberFunction;
118-
MemberCommand():m_MemberFunction(nullptr),m_ConstMemberFunction(nullptr) {}
118+
MemberCommand():m_This(nullptr),m_MemberFunction(nullptr),m_ConstMemberFunction(nullptr) {}
119119
~MemberCommand() override= default;
120120

121121
};

Source/Common/gdcmCryptoFactory.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ CryptoFactory* CryptoFactory::GetFactoryInstance(CryptoLib id)
6161
gdcmErrorMacro( "No crypto factory registered with id " << (int)id );
6262
return nullptr;
6363
}
64-
assert(it->second);
64+
gdcm_assert(it->second);
6565
return it->second;
6666
}
6767

Source/Common/gdcmDataEvent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class DataEvent : public AnyEvent
2929
typedef AnyEvent Superclass;
3030
DataEvent(const char *bytes = nullptr, size_t len = 0):Bytes(bytes),Length(len) {}
3131
~DataEvent() override = default;
32-
DataEvent(const Self&s) : AnyEvent(s){};
32+
DataEvent(const Self&s) : AnyEvent(s), Bytes(nullptr), Length(0) {}
3333
void operator=(const Self&) = delete;
3434

3535
const char * GetEventName() const override { return "DataEvent"; }

Source/Common/gdcmDirectory.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ unsigned int Directory::Explore(FilenameType const &name, bool recursive)
6868
if ('\\' == dirName[dirName.size() - 1])
6969
dirName = dirName.substr(0, dirName.size() - 1);
7070
if ('/' != dirName[dirName.size() - 1]) dirName.push_back('/');
71-
assert( '/' == dirName[dirName.size()-1] );
71+
gdcm_assert( '/' == dirName[dirName.size()-1] );
7272
const std::wstring firstfile = dirName+L"*";
7373
HANDLE hFile = FindFirstFileW(firstfile.c_str(), &fileData);
7474

@@ -106,7 +106,7 @@ unsigned int Directory::Explore(FilenameType const &name, bool recursive)
106106
#else
107107
std::string fileName;
108108
std::string dirName = name;
109-
// assert( System::FileIsDirectory( dirName ) );
109+
// gdcm_assert( System::FileIsDirectory( dirName ) );
110110
Directories.push_back(dirName);
111111
// Real POSIX implementation: scandir is a BSD extension only, and doesn't
112112
// work on debian for example
@@ -127,7 +127,7 @@ unsigned int Directory::Explore(FilenameType const &name, bool recursive)
127127
struct stat buf;
128128
dirent *d;
129129
if ('/' != dirName[dirName.size()-1]) dirName.push_back('/');
130-
assert( '/' == dirName[dirName.size()-1] );
130+
gdcm_assert( '/' == dirName[dirName.size()-1] );
131131
for (d = readdir(dir); d; d = readdir(dir))
132132
{
133133
fileName = dirName + d->d_name;
@@ -152,7 +152,7 @@ unsigned int Directory::Explore(FilenameType const &name, bool recursive)
152152
|| strcmp( d->d_name, ".." ) == 0
153153
|| d->d_name[0] == '.' ) // discard any hidden dir
154154
continue;
155-
assert( d->d_name[0] != '.' ); // hidden directory ??
155+
gdcm_assert( d->d_name[0] != '.' ); // hidden directory ??
156156
if ( recursive )
157157
{
158158
nFiles += Explore( fileName, recursive);

Source/Common/gdcmDirectory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public :
5656

5757
/// Set/Get the file names within the directory
5858
FilenamesType const &GetFilenames() const {
59-
assert( !(Toplevel.empty()) && "Need to call Explore first" );
59+
gdcm_assert( !(Toplevel.empty()) && "Need to call Explore first" );
6060
return Filenames; }
6161

6262
/// Return the Directories traversed

Source/Common/gdcmException.h

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
# endif
3232
#endif
3333

34+
#define gdcm_forced_assert(cond) assert(cond)
35+
3436
namespace gdcm
3537
{
3638

@@ -54,9 +56,9 @@ class Exception : public std::exception
5456
const unsigned int lineNumber,
5557
const char* const func)
5658
{
57-
assert(desc != nullptr);
58-
assert(file != nullptr);
59-
assert(func != nullptr);
59+
gdcm_forced_assert(desc != nullptr);
60+
gdcm_forced_assert(file != nullptr);
61+
gdcm_forced_assert(func != nullptr);
6062
std::ostringstream oswhat;
6163
oswhat << file << ":" << lineNumber << " (" << func << "):\n";
6264
oswhat << desc;
@@ -98,6 +100,17 @@ class Exception : public std::exception
98100

99101
} // end namespace gdcm
100102

103+
// Always defined
104+
#define gdcm_assert(cond) \
105+
if (!(cond)) throw gdcm::Exception("An invalid logic behavior occurred" #cond, __FILE__ , __LINE__)
106+
107+
/* Asserts that should only exist in debug builds. */
108+
#ifndef NDEBUG // checks in debug builds and elision in release builds (like assert)
109+
#define gdcm_debug_assert(cond) gdcm_assert(cond)
110+
#else
111+
#define gdcm_debug_assert(cond) ((void)0)
112+
#endif
113+
101114
// Undo warning suppression.
102115
#if defined(__clang__) && defined(__has_warning)
103116
# if __has_warning("-Wdeprecated")

0 commit comments

Comments
 (0)