Skip to content

Commit 8dc3206

Browse files
authored
Merge branch 'master' into master
2 parents 026d903 + 2ae9bb2 commit 8dc3206

Some content is hidden

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

63 files changed

+997
-467
lines changed

.github/workflows/Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
# Based on old ubuntu to create more compatible binaries
22

33
# To build (e.g. for ShapeWorks 6.5):
4-
# docker build --progress=plain -t akenmorris/ubuntu-build-box-sw65 .
4+
# docker build --progress=plain -t akenmorris/ubuntu-build-box-focal-sw65 .
55
# To publish:
6-
# docker push akenmorris/ubuntu-build-box-sw65
6+
# docker push akenmorris/ubuntu-build-box-focal-sw65
77

8-
FROM ubuntu:bionic-20230308 AS env
8+
FROM ubuntu:focal-20240123 AS env
99
1010

1111
# Set environment variables
1212
ENV PATH=/opt/conda/bin:/opt/rh/devtoolset-9/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
1313
ENV LDFLAGS=-L/opt/conda/lib
1414

15+
ARG DEBIAN_FRONTEND=noninteractive
16+
ENV TZ=Etc/UTC
17+
1518
# Update
1619
RUN apt-get update -y && apt-get upgrade -y && apt-get dist-upgrade -y && apt-get install build-essential software-properties-common -y && add-apt-repository ppa:ubuntu-toolchain-r/test -y && apt-get update -y
1720

.github/workflows/build-linux-debug.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ jobs:
2424
build:
2525

2626
runs-on: ubuntu-latest
27-
container: akenmorris/ubuntu-build-box-sw65
27+
container: akenmorris/ubuntu-build-box-focal-sw65
2828

2929
steps:
3030

3131
- name: Install SSH Key
32-
uses: shimataro/ssh-key-action@v2
32+
uses: shimataro/ssh-key-action@v2.7.0
3333
with:
3434
key: ${{ secrets.SSH_PRIVATE_KEY }}
3535
known_hosts: ${{ secrets.KNOWN_HOSTS }}
@@ -41,7 +41,10 @@ jobs:
4141
run: df -h
4242

4343
- name: Free some space
44-
run: cd /__t ; rm -rf CodeQL go
44+
run: cd /__t ; rm -rf CodeQL go PyPy Python Ruby
45+
46+
- name: Check usage
47+
run: cd /__t ; du -sh *
4548

4649
- name: Check space2
4750
run: df -h
@@ -61,35 +64,35 @@ jobs:
6164
shell: bash -l {0}
6265
run: .github/workflows/restore_caches.sh
6366

64-
- name: Check space2
67+
- name: Check space3
6568
run: df -h
6669

6770
- name: Conda Installs
6871
shell: bash -l {0}
6972
run: .github/workflows/gha_conda.sh
7073

71-
- name: Check space3
74+
- name: Check space4
7275
run: df -h
7376

7477
- name: Build Dependencies
7578
shell: bash -l {0}
7679
run: .github/workflows/gha_deps.sh
7780

78-
- name: Check space4
81+
- name: Check space5
7982
run: df -h
8083

8184
- name: cmake
8285
shell: bash -l {0}
8386
run: conda activate shapeworks && mkdir build && cd build && cmake -DCMAKE_CXX_FLAGS=-g -DITK_DIR=$HOME/install/lib/cmake/ITK-5.2 -DVTK_DIR=$HOME/install/lib/cmake/vtk-9.1 -DXLNT_DIR=$HOME/install -DLIBIGL_DIR=$HOME/install -DOpenVDB_DIR=$HOME/install/lib/cmake/OpenVDB -DGEOMETRYCENTRAL_DIR=$HOME/install -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBuild_Studio=ON -DJKQTCommonSharedLib_DIR=$HOME/install/lib/cmake/JKQTCommonSharedLib -DJKQTMathTextSharedLib_DIR=$HOME/install/lib/cmake/JKQTMathTextSharedLib -DJKQTPlotterSharedLib_DIR=$HOME/install/lib/cmake/JKQTPlotterSharedLib -DACVD_DIR=$HOME/install -DCMAKE_PREFIX_PATH=${CONDA_PREFIX} -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/shapeworks-install -DUSE_ORIGIN_RPATH=ON ..
8487

85-
- name: Check space5
88+
- name: Check space6
8689
run: df -h
8790

8891
- name: make
8992
shell: bash -l {0}
9093
run: conda activate shapeworks && cd build && make -j2
9194

92-
- name: Check space6
95+
- name: Check space7
9396
run: df -h
9497

9598
- name: make install

.github/workflows/build-linux.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ jobs:
2525
build:
2626

2727
runs-on: ubuntu-latest
28-
container: akenmorris/ubuntu-build-box-sw65
28+
container: akenmorris/ubuntu-build-box-focal-sw65
2929

3030
steps:
3131

3232
- name: Install SSH Key
33-
uses: shimataro/ssh-key-action@v2
33+
uses: shimataro/ssh-key-action@v2.7.0
3434
with:
3535
key: ${{ secrets.SSH_PRIVATE_KEY }}
3636
known_hosts: ${{ secrets.KNOWN_HOSTS }}

.github/workflows/copy_artifact.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ if [[ "$PLATFORM" == "windows" ]]; then
1414
# install rsync on for windows/msys2 (the one from chocolatey doesn't work)
1515
# (adapted from https://github.com/GuillaumeFalourd/setup-rsync)
1616
echo "Installing rsync for Windows/msys2"
17-
curl.exe --output rsync-3.2.3-2-x86_64.pkg.tar.zst --url https://repo.msys2.org/msys/x86_64/rsync-3.2.3-1-x86_64.pkg.tar.zst
18-
zstd -d rsync-3.2.3-2-x86_64.pkg.tar.zst
19-
tar -xvf rsync-3.2.3-2-x86_64.pkg.tar
20-
mv usr/bin/rsync.exe "C:\Program Files\Git\usr\bin\\"
21-
curl.exe --output libzstd-1.5.2-1-x86_64.pkg.tar.zst https://repo.msys2.org/msys/x86_64/libzstd-1.5.2-1-x86_64.pkg.tar.zst
22-
zstd -d libzstd-1.5.2-1-x86_64.pkg.tar.zst
23-
tar -xvf libzstd-1.5.2-1-x86_64.pkg.tar
24-
mv usr/bin/msys-zstd-1.dll "C:\Program Files\Git\usr\bin\\"
25-
curl.exe --output libxxhash-0.8.0-1-x86_64.pkg.tar.zst https://repo.msys2.org/msys/x86_64/libxxhash-0.8.0-1-x86_64.pkg.tar.zst
26-
zstd -d libxxhash-0.8.0-1-x86_64.pkg.tar.zst
27-
tar -xvf libxxhash-0.8.0-1-x86_64.pkg.tar
28-
mv usr/bin/msys-xxhash-0.8.0.dll "C:\Program Files\Git\usr\bin\\"
17+
18+
# These were the original URLs, but they keep changing and it's time consuming to keep up
19+
# So I have just combined them in this windows_rsync.tar.gz that I'm hosting myself
20+
21+
# https://repo.msys2.org/msys/x86_64/rsync-3.2.3-1-x86_64.pkg.tar.zst
22+
# https://repo.msys2.org/msys/x86_64/libzstd-1.5.2-1-x86_64.pkg.tar.zst
23+
# https://repo.msys2.org/msys/x86_64/libxxhash-0.8.1-1-x86_64.pkg.tar.zst
24+
curl.exe --output windows_rsync.tar.gz http://www.sci.utah.edu/~amorris/windows_rsync.tar.gz
25+
26+
tar -xzvf windows_rsync.tar.gz
27+
28+
mv usr/bin/* "C:\Program Files\Git\usr\bin\\"
2929
echo "rsync installed on windows runner"
3030
fi
3131

Applications/shapeworks/MeshCommands.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,7 @@ bool WarpMesh::execute(const optparse::Values &options, SharedCommandData &share
14321432
try {
14331433
MeshWarper warper;
14341434
Mesh inputMesh(inputMeshFilename);
1435+
inputMesh.clean();
14351436
targetPointsFilenames.push_back(inputPointsFilename);
14361437
ParticleSystemEvaluation particlesystem(targetPointsFilenames);
14371438
Eigen::MatrixXd landmarks;

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.20)
66
SET(SHAPEWORKS_MAJOR_VERSION 6 CACHE INTERNAL "Major version number" FORCE)
77
SET(SHAPEWORKS_MINOR_VERSION 5 CACHE INTERNAL "Minor version number" FORCE)
88
SET(SHAPEWORKS_PATCH_VERSION 0 CACHE INTERNAL "Patch version number" FORCE)
9-
SET(SHAPEWORKS_VERSION_STRING "6.5.0-dev")
9+
SET(SHAPEWORKS_VERSION_STRING "6.5.0")
1010
SET(SHAPEWORKS_VERSION "${SHAPEWORKS_MAJOR_VERSION}.${SHAPEWORKS_MINOR_VERSION}.${SHAPEWORKS_PATCH_VERSION}")
1111

1212
# First, check that files were checked out properly using git-lfs

Libs/Analyze/Shape.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,15 @@ bool Shape::import_global_point_files(std::vector<std::string> filenames) {
148148
global_point_filenames_.clear();
149149
for (int i = 0; i < filenames.size(); i++) {
150150
Eigen::VectorXd points;
151-
if (filenames[i] != "") {
152-
if (!Shape::import_point_file(filenames[i], points)) {
151+
auto filename = filenames[i];
152+
// replace \ with /
153+
filename = StringUtils::replace_string(filename, "\\", "/");
154+
if (filename != "") {
155+
if (!Shape::import_point_file(filename, points)) {
153156
throw std::invalid_argument("Unable to import point file: " + filenames[i]);
154157
}
155158
}
156-
global_point_filenames_.push_back(filenames[i]);
159+
global_point_filenames_.push_back(filename);
157160
particles_.set_world_particles(i, points);
158161
}
159162
subject_->set_world_particle_filenames(global_point_filenames_);
@@ -165,12 +168,15 @@ bool Shape::import_local_point_files(std::vector<std::string> filenames) {
165168
local_point_filenames_.clear();
166169
for (int i = 0; i < filenames.size(); i++) {
167170
Eigen::VectorXd points;
168-
if (filenames[i] != "") {
169-
if (!Shape::import_point_file(filenames[i], points)) {
171+
auto filename = filenames[i];
172+
// replace \ with /
173+
filename = StringUtils::replace_string(filename, "\\", "/");
174+
if (filename != "") {
175+
if (!Shape::import_point_file(filename, points)) {
170176
throw std::invalid_argument("Unable to import point file: " + filenames[i]);
171177
}
172178
}
173-
local_point_filenames_.push_back(filenames[i]);
179+
local_point_filenames_.push_back(filename);
174180
particles_.set_local_particles(i, points);
175181
}
176182
subject_->set_local_particle_filenames(local_point_filenames_);

Libs/Common/Logging.h

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <QString>
66
#include <functional>
7+
#include <iostream>
78

89
template <>
910
struct fmt::formatter<QString> {
@@ -15,6 +16,18 @@ struct fmt::formatter<QString> {
1516
}
1617
};
1718

19+
template <typename... Args>
20+
std::string safe_format(const std::string& fmt_str, const Args&... args) {
21+
std::string result;
22+
try {
23+
result = fmt::format(fmt_str, args...);
24+
} catch (const std::exception& e) {
25+
// Handle formatting errors here, example:
26+
std::cerr << "Error formatting string: " << fmt_str << " : " << e.what() << std::endl;
27+
}
28+
return result;
29+
}
30+
1831
namespace shapeworks {
1932

2033
/**
@@ -105,7 +118,7 @@ class Logging {
105118
void show_progress(double value, const std::string& message);
106119

107120
//! Log a debug message, use SW_DEBUG macro
108-
void log_debug(const std::string& message, const int line, const char* file, const char *function) const;
121+
void log_debug(const std::string& message, const int line, const char* file, const char* function) const;
109122

110123
//! Log a warning message, use SW_WARN macro
111124
void log_warning(const std::string& message, const int line, const char* file) const;
@@ -156,44 +169,44 @@ class Logging {
156169

157170
//! Log message macro
158171
#define SW_LOG(message, ...) \
159-
shapeworks::Logging::Instance().log_message(fmt::format(message, ##__VA_ARGS__), __LINE__, __FILE__)
172+
shapeworks::Logging::Instance().log_message(safe_format(message, ##__VA_ARGS__), __LINE__, __FILE__);
160173

161174
//! Log warning macro
162175
#define SW_WARN(message, ...) \
163-
shapeworks::Logging::Instance().log_warning(fmt::format(message, ##__VA_ARGS__), __LINE__, __FILE__)
176+
shapeworks::Logging::Instance().log_warning(safe_format(message, ##__VA_ARGS__), __LINE__, __FILE__)
164177

165178
//! Log error macro
166179
#define SW_ERROR(message, ...) \
167-
shapeworks::Logging::Instance().log_error(fmt::format(message, ##__VA_ARGS__), __LINE__, __FILE__)
180+
shapeworks::Logging::Instance().log_error(safe_format(message, ##__VA_ARGS__), __LINE__, __FILE__)
168181

169182
//! Log debug macro
170183
#define SW_DEBUG(message, ...) \
171-
shapeworks::Logging::Instance().log_debug(fmt::format(message, ##__VA_ARGS__), __LINE__, __FILE__, __FUNCTION__)
184+
shapeworks::Logging::Instance().log_debug(safe_format(message, ##__VA_ARGS__), __LINE__, __FILE__, __FUNCTION__)
172185

173186
//! Variable trace macro (e.g. output variable name = <variable value>)
174187
#define SW_TRACE(x) SW_DEBUG(#x " = {}", x);
175188

176189
//! Log show message macro
177190
#define SW_MESSAGE(message, ...) \
178-
shapeworks::Logging::Instance().show_message(fmt::format(message, ##__VA_ARGS__), __LINE__, __FILE__)
191+
shapeworks::Logging::Instance().show_message(safe_format(message, ##__VA_ARGS__), __LINE__, __FILE__)
179192

180193
//! Don't write to log, but set status (e.g. in the Studio statusbar)
181194
#define SW_STATUS(message, ...) \
182-
shapeworks::Logging::Instance().show_status(fmt::format(message, ##__VA_ARGS__), __LINE__, __FILE__)
195+
shapeworks::Logging::Instance().show_status(safe_format(message, ##__VA_ARGS__), __LINE__, __FILE__)
183196

184197
#define SW_PROGRESS(value, message, ...) \
185-
shapeworks::Logging::Instance().show_progress(value, fmt::format(message, ##__VA_ARGS__));
198+
shapeworks::Logging::Instance().show_progress(value, safe_format(message, ##__VA_ARGS__));
186199

187200
//! Close session macro
188201
#define SW_CLOSE_LOG() shapeworks::Logging::Instance().close_log();
189202

190203
//! Log once macro, will only log the message once
191-
#define SW_LOG_ONCE(message, ...) \
192-
{ \
193-
static bool logged = false; \
194-
if (!logged) { \
204+
#define SW_LOG_ONCE(message, ...) \
205+
{ \
206+
static bool logged = false; \
207+
if (!logged) { \
195208
SW_LOG(message, ##__VA_ARGS__); \
196-
logged = true; \
197-
} \
198-
}
209+
logged = true; \
210+
} \
211+
}
199212
} // namespace shapeworks

Libs/Groom/Groom.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -727,13 +727,11 @@ std::string Groom::get_output_filename(std::string input, DomainType domain_type
727727
// check for and handle name clashes, e.g. a/foo.vtk, b/foo.vtk (see #1387)
728728
auto base_name = name;
729729
int count = 2;
730-
while (used_names_.find(name) != used_names_.end()) {
731-
name = base_name + std::to_string(count++);
730+
while (used_names_.find(name + suffix) != used_names_.end()) {
731+
name = base_name + "_" + std::to_string(count++);
732732
}
733-
used_names_.insert(name);
734-
735733
auto output = name + suffix;
736-
734+
used_names_.insert(output);
737735
return output;
738736
}
739737

Libs/Mesh/Mesh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ Mesh& Mesh::fixElement() {
488488
FEMesh* meshFE = import.Load(this->poly_data_);
489489

490490
if (meshFE == nullptr) {
491-
throw std::invalid_argument("Unable to read file");
491+
throw std::runtime_error("Unable to read mesh file");
492492
}
493493

494494
FEFixMesh fix;

0 commit comments

Comments
 (0)