Skip to content

Commit

Permalink
Merge branch 'master' into mesh_distance_symmetric
Browse files Browse the repository at this point in the history
  • Loading branch information
nawazishkhan1-nk committed Mar 29, 2024
2 parents 5774a01 + b6cd594 commit ef0ba1e
Show file tree
Hide file tree
Showing 274 changed files with 19,270 additions and 9,926 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# Based on old ubuntu to create more compatible binaries

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

FROM ubuntu:bionic-20230308 AS env
FROM ubuntu:focal-20240123 AS env
MAINTAINER akenmorris@gmail.com

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

ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/UTC

# Update
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

Expand Down
19 changes: 11 additions & 8 deletions .github/workflows/build-linux-debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ jobs:
build:

runs-on: ubuntu-latest
container: akenmorris/ubuntu-build-box-sw65
container: akenmorris/ubuntu-build-box-focal-sw65

steps:

- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
uses: shimataro/ssh-key-action@v2.7.0
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
Expand All @@ -41,7 +41,10 @@ jobs:
run: df -h

- name: Free some space
run: cd /__t ; rm -rf CodeQL go
run: cd /__t ; rm -rf CodeQL go PyPy Python Ruby

- name: Check usage
run: cd /__t ; du -sh *

- name: Check space2
run: df -h
Expand All @@ -61,35 +64,35 @@ jobs:
shell: bash -l {0}
run: .github/workflows/restore_caches.sh

- name: Check space2
- name: Check space3
run: df -h

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

- name: Check space3
- name: Check space4
run: df -h

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

- name: Check space4
- name: Check space5
run: df -h

- name: cmake
shell: bash -l {0}
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 ..

- name: Check space5
- name: Check space6
run: df -h

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

- name: Check space6
- name: Check space7
run: df -h

- name: make install
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ jobs:
build:

runs-on: ubuntu-latest
container: akenmorris/ubuntu-build-box-sw65
container: akenmorris/ubuntu-build-box-focal-sw65

steps:

- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
uses: shimataro/ssh-key-action@v2.7.0
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/copy_artifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ if [[ "$PLATFORM" == "windows" ]]; then
# install rsync on for windows/msys2 (the one from chocolatey doesn't work)
# (adapted from https://github.com/GuillaumeFalourd/setup-rsync)
echo "Installing rsync for Windows/msys2"
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
zstd -d rsync-3.2.3-2-x86_64.pkg.tar.zst
tar -xvf rsync-3.2.3-2-x86_64.pkg.tar
mv usr/bin/rsync.exe "C:\Program Files\Git\usr\bin\\"
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
zstd -d libzstd-1.5.2-1-x86_64.pkg.tar.zst
tar -xvf libzstd-1.5.2-1-x86_64.pkg.tar
mv usr/bin/msys-zstd-1.dll "C:\Program Files\Git\usr\bin\\"
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
zstd -d libxxhash-0.8.0-1-x86_64.pkg.tar.zst
tar -xvf libxxhash-0.8.0-1-x86_64.pkg.tar
mv usr/bin/msys-xxhash-0.8.0.dll "C:\Program Files\Git\usr\bin\\"

# These were the original URLs, but they keep changing and it's time consuming to keep up
# So I have just combined them in this windows_rsync.tar.gz that I'm hosting myself

# https://repo.msys2.org/msys/x86_64/rsync-3.2.3-1-x86_64.pkg.tar.zst
# https://repo.msys2.org/msys/x86_64/libzstd-1.5.2-1-x86_64.pkg.tar.zst
# https://repo.msys2.org/msys/x86_64/libxxhash-0.8.1-1-x86_64.pkg.tar.zst
curl.exe --output windows_rsync.tar.gz http://www.sci.utah.edu/~amorris/windows_rsync.tar.gz

tar -xzvf windows_rsync.tar.gz

mv usr/bin/* "C:\Program Files\Git\usr\bin\\"
echo "rsync installed on windows runner"
fi

Expand Down
57 changes: 23 additions & 34 deletions Applications/shapeworks/Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,7 @@ bool Example::execute(const optparse::Values &options, SharedCommandData &shared
}
#endif

static void setup_callbacks(bool show_progress, bool xml_status) {
if (show_progress) {
auto progress_callback = [](double progress, std::string message) {
// show status message and percentage complete
std::cout << fmt::format("{} ({:.1f}%) \r", message, progress);
std::cout.flush();
};
Logging::Instance().set_progress_callback(progress_callback);
}

if (xml_status) {
auto progress_callback = [](double progress, std::string message) {
// print status message and percentage complete
std::cout << fmt::format("<xml><status>{}</status><progress>{:.1f}</progress></xml>\n", message, progress);
std::cout.flush();
};
Logging::Instance().set_progress_callback(progress_callback);

auto error_callback = [](std::string message) {
std::cout << fmt::format("<xml><error>{}</error></xml>\n", message);
std::cout.flush();
};
Logging::Instance().set_error_callback(error_callback);
}
}

///////////////////////////////////////////////////////////////////////////////
// Seed
Expand All @@ -87,7 +63,7 @@ void Seed::buildParser() {
bool Seed::execute(const optparse::Values& options, SharedCommandData& sharedData) {
int value = static_cast<int>(options.get("value"));

ShapeworksUtils::setRngSeed(value);
ShapeWorksUtils::set_rng_seed(value);

return true;
}
Expand All @@ -102,7 +78,10 @@ void OptimizeCommand::buildParser() {

parser.add_option("--name").action("store").type("string").set_default("").help("Path to project file.");
parser.add_option("--progress").action("store_true").set_default(false).help("Show progress [default: false].");
parser.add_option("--xmlconsole").action("store_true").set_default(false).help("XML console output [default: false].");
parser.add_option("--xmlconsole")
.action("store_true")
.set_default(false)
.help("XML console output [default: false].");

Command::buildParser();
}
Expand All @@ -120,13 +99,18 @@ bool OptimizeCommand::execute(const optparse::Values& options, SharedCommandData
bool isProject = StringUtils::hasSuffix(projectFile, "xlsx") || StringUtils::hasSuffix(projectFile, "swproj");

Optimize app;
setup_callbacks(show_progress, xml_status);
ShapeWorksUtils::setup_console_logging(show_progress, xml_status);

if (isProject) {
try {
// load spreadsheet project
ProjectHandle project = std::make_shared<Project>();
project->load(projectFile);
try {
project->load(projectFile);
} catch (std::exception& e) {
SW_ERROR("Project failed to load: {}", e.what());
return false;
}

const auto oldBasePath = boost::filesystem::current_path();
auto base = StringUtils::getPath(projectFile);
Expand All @@ -153,7 +137,7 @@ bool OptimizeCommand::execute(const optparse::Values& options, SharedCommandData

return success;
} catch (std::exception& e) {
SW_ERROR(e.what());
SW_ERROR("{}", e.what());
return false;
}
} else {
Expand All @@ -173,7 +157,10 @@ void GroomCommand::buildParser() {

parser.add_option("--name").action("store").type("string").set_default("").help("Path to project file.");
parser.add_option("--progress").action("store_true").set_default(false).help("Show progress [default: false].");
parser.add_option("--xmlconsole").action("store_true").set_default(false).help("XML console output [default: false].");
parser.add_option("--xmlconsole")
.action("store_true")
.set_default(false)
.help("XML console output [default: false].");

Command::buildParser();
}
Expand All @@ -188,7 +175,7 @@ bool GroomCommand::execute(const optparse::Values& options, SharedCommandData& s
return false;
}

setup_callbacks(show_progress, xml_status);
ShapeWorksUtils::setup_console_logging(show_progress, xml_status);

try {
ProjectHandle project = std::make_shared<Project>();
Expand All @@ -215,7 +202,7 @@ bool GroomCommand::execute(const optparse::Values& options, SharedCommandData& s

return success;
} catch (std::exception& e) {
SW_ERROR(e.what());
SW_ERROR("{}", e.what());
return false;
}
}
Expand All @@ -230,8 +217,10 @@ void AnalyzeCommand::buildParser() {

parser.add_option("--name").action("store").type("string").set_default("").help("Path to project file.");
parser.add_option("--output").action("store").type("string").set_default("").help("Path to output file.");
parser.add_option("--range").action("store").type("float").set_default(3.0f).help("Standard deviation range for PCA [default: 3.0].");
parser.add_option("--steps").action("store").type("int").set_default(21).help("Number of steps to use for PCA [default: 21].");
parser.add_option("--range").action("store").type("float").set_default(3.0f).help(
"Standard deviation range for PCA [default: 3.0].");
parser.add_option("--steps").action("store").type("int").set_default(21).help(
"Number of steps to use for PCA [default: 21].");

Command::buildParser();
}
Expand Down
13 changes: 11 additions & 2 deletions Applications/shapeworks/MeshCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,7 @@ bool WarpMesh::execute(const optparse::Values &options, SharedCommandData &share
try {
MeshWarper warper;
Mesh inputMesh(inputMeshFilename);
inputMesh.clean();
targetPointsFilenames.push_back(inputPointsFilename);
ParticleSystemEvaluation particlesystem(targetPointsFilenames);
Eigen::MatrixXd landmarks;
Expand Down Expand Up @@ -1469,6 +1470,7 @@ bool WarpMesh::execute(const optparse::Values &options, SharedCommandData &share
movingPoints.resize(3, numParticles);
movingPoints.transposeInPlace();
Mesh output = warper.build_mesh(movingPoints);
SW_DEBUG("Writing mesh {} with {} points", filenm, output.numPoints());
output.write(filenm);
if (warp_along_with_landmarks) {
std::string warped_landmarks_filename = targetPointsFilenames[i];
Expand Down Expand Up @@ -1541,6 +1543,11 @@ void ComputeThickness::buildParser() {
.type("double")
.set_default(100000.0)
.help("Maximum distance to determine thickness");
parser.add_option("--median_radius")
.action("store")
.type("double")
.set_default(5.0)
.help("Median radius for smoothing, multiplier of average edge length");
parser.add_option("--distance_mesh")
.action("store")
.type("string")
Expand All @@ -1565,15 +1572,17 @@ bool ComputeThickness::execute(const optparse::Values &options, SharedCommandDat

double max_dist = static_cast<double>(options.get("max_dist"));

double median_radius = static_cast<double>(options.get("median_radius"));

std::string dt_filename = static_cast<std::string>(options.get("distance_transform"));

std::string distance_mesh_filename = static_cast<std::string>(options.get("distance_mesh"));

if (dt_filename == "") {
sharedData.mesh->computeThickness(img, nullptr, max_dist, distance_mesh_filename);
sharedData.mesh->computeThickness(img, nullptr, max_dist, median_radius, distance_mesh_filename);
} else {
Image dt(dt_filename);
sharedData.mesh->computeThickness(img, &dt, max_dist, distance_mesh_filename);
sharedData.mesh->computeThickness(img, &dt, max_dist, median_radius, distance_mesh_filename);
}

return sharedData.validMesh();
Expand Down
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.20)
SET(SHAPEWORKS_MAJOR_VERSION 6 CACHE INTERNAL "Major version number" FORCE)
SET(SHAPEWORKS_MINOR_VERSION 5 CACHE INTERNAL "Minor version number" FORCE)
SET(SHAPEWORKS_PATCH_VERSION 0 CACHE INTERNAL "Patch version number" FORCE)
SET(SHAPEWORKS_VERSION_STRING "6.5.0-dev")
SET(SHAPEWORKS_VERSION_STRING "6.5.0")
SET(SHAPEWORKS_VERSION "${SHAPEWORKS_MAJOR_VERSION}.${SHAPEWORKS_MINOR_VERSION}.${SHAPEWORKS_PATCH_VERSION}")

# First, check that files were checked out properly using git-lfs
Expand Down Expand Up @@ -80,9 +80,12 @@ SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
SET(CMAKE_BUNDLE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

# make it easier to see more important compiler warnings and errors (# TODO: fix the actual cause of the warnings)
if (APPLE)
# make it easier to see more important compiler warnings and errors (# TODO: fix the actual cause of the warnings)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-inconsistent-missing-override")

# workaround for version of boost in use
add_definitions(-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
endif()

if(MSVC)
Expand Down
Loading

0 comments on commit ef0ba1e

Please sign in to comment.