Skip to content

Commit afe1f8a

Browse files
committed
[1.3.49] 2025-09-11
## Context - Fixes for zlib and pnglib building on old linux systems ## Radiation - Fixed assigmnment of image IDs in JSON image segementation mask output files
1 parent 0253b6a commit afe1f8a

File tree

97 files changed

+3871
-4210
lines changed

Some content is hidden

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

97 files changed

+3871
-4210
lines changed

core/include/Context.h

Lines changed: 75 additions & 81 deletions
Large diffs are not rendered by default.

core/include/doctest_utils.h

Lines changed: 152 additions & 198 deletions
Large diffs are not rendered by default.

core/include/global.h

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@
1919
//! Macro for marking functions as deprecated with optional custom message.
2020
// MSVC requires __declspec to come BEFORE the function declaration
2121
#if __cplusplus >= 201402L && defined(__has_cpp_attribute) && __has_cpp_attribute(deprecated)
22-
#define DEPRECATED_MSG(msg, func) [[deprecated(msg)]] func
23-
#define DEPRECATED_NOMSG(func) [[deprecated]] func
22+
#define DEPRECATED_MSG(msg, func) [[deprecated(msg)]] func
23+
#define DEPRECATED_NOMSG(func) [[deprecated]] func
2424
#elif defined(__GNUC__) || defined(__clang__)
25-
#define DEPRECATED_MSG(msg, func) func __attribute__((deprecated(msg)))
26-
#define DEPRECATED_NOMSG(func) func __attribute__((deprecated))
25+
#define DEPRECATED_MSG(msg, func) func __attribute__((deprecated(msg)))
26+
#define DEPRECATED_NOMSG(func) func __attribute__((deprecated))
2727
#elif defined(_MSC_VER)
28-
// MSVC has issues with custom deprecation messages, use simple deprecation
29-
#define DEPRECATED_MSG(msg, func) __declspec(deprecated) func
30-
#define DEPRECATED_NOMSG(func) __declspec(deprecated) func
28+
// MSVC has issues with custom deprecation messages, use simple deprecation
29+
#define DEPRECATED_MSG(msg, func) __declspec(deprecated) func
30+
#define DEPRECATED_NOMSG(func) __declspec(deprecated) func
3131
#else
32-
#pragma message("WARNING: You need to implement DEPRECATED for this compiler")
33-
#define DEPRECATED_MSG(msg, func) func
34-
#define DEPRECATED_NOMSG(func) func
32+
#pragma message("WARNING: You need to implement DEPRECATED for this compiler")
33+
#define DEPRECATED_MSG(msg, func) func
34+
#define DEPRECATED_NOMSG(func) func
3535
#endif
3636

3737
// Helper macro to count arguments
@@ -72,13 +72,13 @@ constexpr float PI_F = 3.14159265358979323846f;
7272
#include <map>
7373
#include <memory>
7474
#include <random>
75+
#include <set>
7576
#include <sstream>
7677
#include <stdexcept>
7778
#include <thread>
7879
#include <type_traits>
7980
#include <unordered_map>
8081
#include <vector>
81-
#include <set>
8282

8383
#ifdef USE_OPENMP
8484
#include <omp.h>
@@ -1065,7 +1065,8 @@ namespace helios {
10651065
* \param[in] max_iterations [optional] Maximum number of iterations to allow before exiting solver.
10661066
* \return Value of function zero (best estimate even if not converged).
10671067
*/
1068-
[[nodiscard]] float fzero(float (*function)(float value, std::vector<float> &variables, const void *parameters), std::vector<float> &variables, const void *parameters, float init_guess, bool &converged, float err_tol = 0.0001f, int max_iterations = 100);
1068+
[[nodiscard]] float fzero(float (*function)(float value, std::vector<float> &variables, const void *parameters), std::vector<float> &variables, const void *parameters, float init_guess, bool &converged, float err_tol = 0.0001f,
1069+
int max_iterations = 100);
10691070

10701071
//! Function to perform linear interpolation based on a vector of discrete (x,y) values
10711072
/**
@@ -1177,16 +1178,16 @@ namespace helios {
11771178
* \note This function searches for assets in multiple locations: build directory, system install locations, and custom paths
11781179
* \ingroup functions
11791180
*/
1180-
[[nodiscard]] std::filesystem::path resolveAssetPath(const std::string& relativePath);
1181+
[[nodiscard]] std::filesystem::path resolveAssetPath(const std::string &relativePath);
11811182

1182-
//! Resolve plugin-specific asset path
1183+
//! Resolve plugin-specific asset path
11831184
/**
11841185
* \param[in] pluginName Name of the plugin (e.g., "visualizer", "plantarchitecture", "radiation")
11851186
* \param[in] assetPath Relative path within the plugin's asset directory
11861187
* \return Absolute path to the plugin asset file
11871188
* \ingroup functions
11881189
*/
1189-
[[nodiscard]] std::filesystem::path resolvePluginAsset(const std::string& pluginName, const std::string& assetPath);
1190+
[[nodiscard]] std::filesystem::path resolvePluginAsset(const std::string &pluginName, const std::string &assetPath);
11901191

11911192

11921193
//! Resolve file path using standard Helios resolution hierarchy
@@ -1196,28 +1197,28 @@ namespace helios {
11961197
* 2. Checks relative to current working directory first
11971198
* 3. Falls back to checking relative to HELIOS_BUILD environment variable path
11981199
* 4. Throws helios_runtime_error if file not found in either location
1199-
*
1200+
*
12001201
* \param[in] filename File name with or without path (e.g., "texture.jpg" or "models/texture.jpg")
12011202
* \return Absolute canonical path to the file
12021203
* \ingroup functions
12031204
*/
1204-
[[nodiscard]] std::filesystem::path resolveFilePath(const std::string& filename);
1205+
[[nodiscard]] std::filesystem::path resolveFilePath(const std::string &filename);
12051206

12061207
//! Resolve spectral data file path
12071208
/**
12081209
* \param[in] spectraFile Spectral data filename with or without path (e.g., "camera_spectral_library.xml")
12091210
* \return Absolute path to the spectral data file
12101211
* \ingroup functions
12111212
*/
1212-
[[nodiscard]] std::filesystem::path resolveSpectraPath(const std::string& spectraFile);
1213+
[[nodiscard]] std::filesystem::path resolveSpectraPath(const std::string &spectraFile);
12131214

12141215
//! Validate that an asset file exists and is readable
12151216
/**
12161217
* \param[in] assetPath Path to the asset file to validate
12171218
* \return True if the file exists and is readable, false otherwise
12181219
* \ingroup functions
12191220
*/
1220-
[[nodiscard]] bool validateAssetPath(const std::filesystem::path& assetPath);
1221+
[[nodiscard]] bool validateAssetPath(const std::filesystem::path &assetPath);
12211222

12221223
//! Find the project root directory (directory containing top-level CMakeLists.txt)
12231224
/**
@@ -1226,7 +1227,7 @@ namespace helios {
12261227
* \note Searches upward from startPath for a directory containing CMakeLists.txt
12271228
* \ingroup functions
12281229
*/
1229-
[[nodiscard]] std::filesystem::path findProjectRoot(const std::filesystem::path& startPath = std::filesystem::current_path());
1230+
[[nodiscard]] std::filesystem::path findProjectRoot(const std::filesystem::path &startPath = std::filesystem::current_path());
12301231

12311232
//! Resolve file path using project-based resolution strategy
12321233
/**
@@ -1236,7 +1237,7 @@ namespace helios {
12361237
* \throws std::runtime_error if file cannot be found
12371238
* \ingroup functions
12381239
*/
1239-
[[nodiscard]] std::filesystem::path resolveProjectFile(const std::string& relativePath);
1240+
[[nodiscard]] std::filesystem::path resolveProjectFile(const std::string &relativePath);
12401241

12411242
//! Read values contained in a text file into a one-dimensional vector of floats
12421243
/**

core/lib/libpng/CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
4343
# needed packages
4444
#find_package(ZLIB REQUIRED)
4545

46-
set( ZLIB_INCLUDE_DIR "${PROJECT_BINARY_DIR}/lib/zlib;${CMAKE_CURRENT_SOURCE_DIR}/../zlib" )
46+
# CRITICAL: List build directory FIRST to ensure libpng uses generated zconf.h with z_size_t fixes
47+
set( ZLIB_INCLUDE_DIR "${CMAKE_BINARY_DIR}/lib/zlib;${CMAKE_CURRENT_SOURCE_DIR}/../zlib" )
4748
if( UNIX AND NOT APPLE)
4849
set( ZLIB_LIBRARY ${CMAKE_BINARY_DIR}/lib/libz.a )#BNB 12/6/2022
4950
endif( UNIX AND NOT APPLE)
@@ -55,6 +56,19 @@ if( WIN32 )
5556
endif( WIN32 )
5657
include_directories(${ZLIB_INCLUDE_DIR})
5758

59+
# MANYLINUX COMPATIBILITY FIX - Apply z_size_t fix for libpng
60+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
61+
if(DEFINED ENV{CIBUILDWHEEL} OR DEFINED ENV{AUDITWHEEL_PLAT} OR "$ENV{AUDITWHEEL_PLAT}" MATCHES "manylinux")
62+
message(STATUS "libpng: Applying manylinux z_size_t compatibility fix")
63+
# Force inclusion of stddef.h to ensure size_t is available before any zlib headers
64+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -include stddef.h")
65+
# CRITICAL: Force libpng to use build directory zlib headers with z_size_t fixes
66+
# Use -I to prepend the build directory to the include search path
67+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_BINARY_DIR}/lib/zlib")
68+
message(STATUS "libpng: Applied stddef.h inclusion and forced build zlib headers for manylinux compatibility")
69+
endif()
70+
endif()
71+
5872
if(NOT WIN32)
5973
find_library(M_LIBRARY
6074
NAMES m

core/lib/zlib/CMakeLists.txt

Lines changed: 25 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -59,49 +59,33 @@ endif()
5959
check_include_file(unistd.h Z_HAVE_UNISTD_H)
6060
check_include_file(stdarg.h HAVE_STDARG_H)
6161

62-
# Comprehensive zlib compatibility fixes for manylinux and older containers
63-
# Critical: Force STDC definition BEFORE configure_file() to ensure proper z_size_t typedef
62+
# Targeted zlib compatibility fix for manylinux containers
63+
# Check for multiple indicators of manylinux environment
6464
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
65-
message(STATUS "Applying Linux-specific zlib compatibility fixes")
66-
67-
# CRITICAL: Set STDC in CMAKE_REQUIRED_DEFINITIONS for configure time
68-
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -DSTDC=1)
69-
70-
# Force STDC definition for compile time as well
71-
add_definitions(-DSTDC=1)
72-
73-
# Force __STDC__ definition as backup (some compilers check this instead)
74-
add_definitions(-D__STDC__=1)
75-
76-
# Ensure stdarg.h definitions are available
77-
if(HAVE_STDARG_H)
78-
add_definitions(-DHAVE_STDARG_H)
79-
endif()
80-
81-
# Additional compatibility definitions
82-
add_definitions(-D_GNU_SOURCE)
83-
84-
# Check if we're in a manylinux container and apply additional fixes
85-
if(DEFINED ENV{CIBUILDWHEEL})
86-
message(STATUS "Detected manylinux container - applying enhanced zlib compatibility fixes")
87-
88-
# Force size_t availability by including stddef.h
89-
add_definitions(-DHAVE_STDDEF_H=1)
90-
91-
# Ensure proper include paths for system headers
92-
include_directories(/usr/include)
93-
94-
# Additional manylinux-specific compiler flags
95-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
96-
97-
# CRITICAL: Direct workaround for z_size_t definition issues in manylinux2014
98-
# The conditional logic in zconf.h isn't working correctly with older CentOS 7 headers
99-
# So we bypass it entirely by directly defining z_size_t as size_t
100-
add_definitions(-Dz_size_t=size_t)
101-
message(STATUS "Applied direct z_size_t=size_t workaround for manylinux compatibility")
65+
# Debug: Always show environment detection
66+
message(STATUS "zlib: Linux detected, checking manylinux environment...")
67+
message(STATUS "zlib: CIBUILDWHEEL env var: $ENV{CIBUILDWHEEL}")
68+
message(STATUS "zlib: AUDITWHEEL_PLAT env var: $ENV{AUDITWHEEL_PLAT}")
69+
70+
# Check for manylinux indicators
71+
if(DEFINED ENV{CIBUILDWHEEL} OR DEFINED ENV{AUDITWHEEL_PLAT} OR "$ENV{AUDITWHEEL_PLAT}" MATCHES "manylinux")
72+
message(STATUS "Applying manylinux-specific zlib z_size_t compatibility fix")
73+
74+
# CRITICAL: Force inclusion of stddef.h before any zlib headers are processed
75+
# This ensures size_t is available when zconf.h processes the z_size_t typedef
76+
# The zconf.h logic should then correctly use: typedef size_t z_size_t;
77+
# Apply globally so that libpng and other dependencies also get this fix
78+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -include stddef.h")
79+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include stddef.h")
80+
81+
# Also set parent scope so this applies to the entire build
82+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" PARENT_SCOPE)
83+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" PARENT_SCOPE)
84+
85+
message(STATUS "Applied z_size_t fix: forced stddef.h inclusion for manylinux")
86+
else()
87+
message(STATUS "Not a manylinux environment, skipping z_size_t fix")
10288
endif()
103-
104-
message(STATUS "Linux zlib compatibility: STDC=1, __STDC__=1, HAVE_STDDEF_H=1")
10589
endif()
10690

10791
if(MSVC)

core/lib/zlib/zconf.h.cmakein

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,6 @@
88
#ifndef ZCONF_H
99
#define ZCONF_H
1010

11-
/* Manylinux and older container compatibility fixes */
12-
#ifdef __linux__
13-
/* Ensure STDC compliance detection works in manylinux containers */
14-
#if defined(__GNUC__) && !defined(STDC) && !defined(__STDC__)
15-
#define STDC 1
16-
#define __STDC__ 1
17-
#endif
18-
/* Ensure we have access to size_t */
19-
#ifndef _STDDEF_H
20-
#include <stddef.h>
21-
#endif
22-
#endif
23-
2411
#cmakedefine Z_PREFIX
2512
#cmakedefine Z_HAVE_UNISTD_H
2613

core/lib/zlib/zconf.h.included

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@
250250
# define z_longlong long long
251251
# if defined(NO_SIZE_T)
252252
typedef unsigned NO_SIZE_T z_size_t;
253-
# elif defined(STDC)
253+
# elif defined(STDC) || defined(__STDC__) || defined(__GNUC__) || defined(__linux__)
254+
/* Enhanced STDC detection for manylinux containers and modern compilers */
254255
# include <stddef.h>
255256
typedef size_t z_size_t;
256257
# else

core/src/Context.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ bool Context::doesTextureFileExist(const char *texture_file) const {
7878
try {
7979
auto resolved_path = resolveFilePath(texture_file);
8080
return std::filesystem::exists(resolved_path);
81-
} catch (const std::runtime_error&) {
81+
} catch (const std::runtime_error &) {
8282
return false;
8383
}
8484
}
@@ -460,7 +460,7 @@ std::vector<uint> Context::getAllUUIDs() const {
460460
if (all_uuids_cache_valid) {
461461
return cached_all_uuids;
462462
}
463-
463+
464464
// Rebuild cache
465465
cached_all_uuids.clear();
466466
cached_all_uuids.reserve(primitives.size());
@@ -798,7 +798,7 @@ void Context::getDomainBoundingBox(const std::vector<uint> &UUIDs, vec2 &xbounds
798798

799799
// Parallelize the outer loop over primitives. Use "for" inside the parallel region.
800800
#pragma omp for nowait
801-
for (int i = 0; i < (int)UUIDs.size(); i++) {
801+
for (int i = 0; i < (int) UUIDs.size(); i++) {
802802
// For each primitive:
803803
const std::vector<vec3> &verts = getPrimitivePointer_private(UUIDs[i])->getVertices();
804804
// Update local bounding box for each vertex in this primitive.
@@ -2122,7 +2122,7 @@ std::vector<uint> Context::addTube(uint radial_subdivisions, const std::vector<v
21222122
if (fabs(vec.z) > 0.95f) {
21232123
nvec = vec3(1.0f, 0.0f, 0.0f); // Use horizontal direction for vertical axes
21242124
}
2125-
2125+
21262126
convec = cross(nvec, vec);
21272127
convec.normalize();
21282128
nvec = cross(vec, convec);
@@ -2228,7 +2228,7 @@ std::vector<uint> Context::addTube(uint radial_subdivisions, const std::vector<v
22282228
if (fabs(vec.z) > 0.95f) {
22292229
nvec = vec3(1.0f, 0.0f, 0.0f); // Use horizontal direction for vertical axes
22302230
}
2231-
2231+
22322232
convec = cross(nvec, vec);
22332233
convec.normalize();
22342234
nvec = cross(vec, convec);
@@ -2295,7 +2295,7 @@ std::vector<uint> Context::addTube(uint radial_subdivisions, const std::vector<v
22952295

22962296
// Remove invalid UUIDs (zeros) from the vector
22972297
UUIDs.erase(std::remove(UUIDs.begin(), UUIDs.end(), 0), UUIDs.end());
2298-
2298+
22992299
return UUIDs;
23002300
}
23012301

@@ -2578,8 +2578,8 @@ std::vector<uint> Context::addDisk(const int2 &Ndivs, const vec3 &center, const
25782578

25792579
if (r == 0) {
25802580
uint triangle_uuid = addTriangle(make_vec3(0, 0, 0), make_vec3(rx_plus * cosf(theta), ry_plus * sinf(theta), 0), make_vec3(rx_plus * cosf(theta_plus), ry_plus * sinf(theta_plus), 0), texturefile, make_vec2(0.5, 0.5),
2581-
make_vec2(0.5f * (1.f + cosf(theta) * rx_plus / size.x), 0.5f * (1.f + sinf(theta) * ry_plus / size.y)),
2582-
make_vec2(0.5f * (1.f + cosf(theta_plus) * rx_plus / size.x), 0.5f * (1.f + sinf(theta_plus) * ry_plus / size.y)));
2581+
make_vec2(0.5f * (1.f + cosf(theta) * rx_plus / size.x), 0.5f * (1.f + sinf(theta) * ry_plus / size.y)),
2582+
make_vec2(0.5f * (1.f + cosf(theta_plus) * rx_plus / size.x), 0.5f * (1.f + sinf(theta_plus) * ry_plus / size.y)));
25832583
if (getPrimitiveArea(triangle_uuid) > 0) {
25842584
UUID.push_back(triangle_uuid);
25852585
} else {
@@ -2588,17 +2588,18 @@ std::vector<uint> Context::addDisk(const int2 &Ndivs, const vec3 &center, const
25882588
}
25892589
} else {
25902590
uint triangle_uuid1 = addTriangle(make_vec3(rx * cosf(theta_plus), ry * sinf(theta_plus), 0), make_vec3(rx * cosf(theta), ry * sinf(theta), 0), make_vec3(rx_plus * cosf(theta), ry_plus * sinf(theta), 0), texturefile,
2591-
make_vec2(0.5f * (1.f + cosf(theta_plus) * rx / size.x), 0.5f * (1.f + sinf(theta_plus) * ry / size.y)), make_vec2(0.5f * (1.f + cosf(theta) * rx / size.x), 0.5f * (1.f + sinf(theta) * ry / size.y)),
2592-
make_vec2(0.5f * (1.f + cosf(theta) * rx_plus / size.x), 0.5f * (1.f + sinf(theta) * ry_plus / size.y)));
2591+
make_vec2(0.5f * (1.f + cosf(theta_plus) * rx / size.x), 0.5f * (1.f + sinf(theta_plus) * ry / size.y)), make_vec2(0.5f * (1.f + cosf(theta) * rx / size.x), 0.5f * (1.f + sinf(theta) * ry / size.y)),
2592+
make_vec2(0.5f * (1.f + cosf(theta) * rx_plus / size.x), 0.5f * (1.f + sinf(theta) * ry_plus / size.y)));
25932593
if (getPrimitiveArea(triangle_uuid1) > 0) {
25942594
UUID.push_back(triangle_uuid1);
25952595
} else {
25962596
deletePrimitive(triangle_uuid1);
25972597
}
2598-
2599-
uint triangle_uuid2 = addTriangle(make_vec3(rx * cosf(theta_plus), ry * sinf(theta_plus), 0), make_vec3(rx_plus * cosf(theta), ry_plus * sinf(theta), 0), make_vec3(rx_plus * cosf(theta_plus), ry_plus * sinf(theta_plus), 0), texturefile,
2600-
make_vec2(0.5f * (1.f + cosf(theta_plus) * rx / size.x), 0.5f * (1.f + sinf(theta_plus) * ry / size.y)), make_vec2(0.5f * (1.f + cosf(theta) * rx_plus / size.x), 0.5f * (1.f + sinf(theta) * ry_plus / size.y)),
2601-
make_vec2(0.5f * (1.f + cosf(theta_plus) * rx_plus / size.x), 0.5f * (1.f + sinf(theta_plus) * ry_plus / size.y)));
2598+
2599+
uint triangle_uuid2 =
2600+
addTriangle(make_vec3(rx * cosf(theta_plus), ry * sinf(theta_plus), 0), make_vec3(rx_plus * cosf(theta), ry_plus * sinf(theta), 0), make_vec3(rx_plus * cosf(theta_plus), ry_plus * sinf(theta_plus), 0), texturefile,
2601+
make_vec2(0.5f * (1.f + cosf(theta_plus) * rx / size.x), 0.5f * (1.f + sinf(theta_plus) * ry / size.y)), make_vec2(0.5f * (1.f + cosf(theta) * rx_plus / size.x), 0.5f * (1.f + sinf(theta) * ry_plus / size.y)),
2602+
make_vec2(0.5f * (1.f + cosf(theta_plus) * rx_plus / size.x), 0.5f * (1.f + sinf(theta_plus) * ry_plus / size.y)));
26022603
if (getPrimitiveArea(triangle_uuid2) > 0) {
26032604
UUID.push_back(triangle_uuid2);
26042605
} else {

0 commit comments

Comments
 (0)