Skip to content

Commit

Permalink
⊞ Fix Windows Build (#4)
Browse files Browse the repository at this point in the history
* windows specific changes (optional and filesystem string)

* windows linking error fix, environment (dll)
  • Loading branch information
jiangzhongshi committed Jun 29, 2021
1 parent daf0cc9 commit 44c2040
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 80 deletions.
114 changes: 58 additions & 56 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,60 +98,62 @@ jobs:
# Windows
####################

# Windows:
# name: Windows (${{ matrix.config }})
# runs-on: windows-2019
# env:
# CC: cl.exe
# CXX: cl.exe
# strategy:
# fail-fast: false
# matrix:
# config: [Release]
# steps:
# - name: Stetup Conda
# uses: conda-incubator/setup-miniconda@v2

# - name: Install Dependencies
# shell: powershell
# run: |
# conda install -c conda-forge mpfr hdf5 boost-cpp -y
Windows:
name: Windows (${{ matrix.config }})
runs-on: windows-2019
env:
CC: cl.exe
CXX: cl.exe
strategy:
fail-fast: false
matrix:
config: [Release]
steps:
- name: Stetup Conda
uses: conda-incubator/setup-miniconda@v2

- name: Install Dependencies
shell: powershell
run: |
conda install -c conda-forge mpfr hdf5 boost-cpp -y
# - name: Checkout repository
# uses: actions/checkout@v1
# with:
# fetch-depth: 10
# - uses: seanmiddleditch/gha-setup-ninja@master

# - name: Set env
# run: |
# echo "appdata=$env:LOCALAPPDATA" >> ${env:GITHUB_ENV}
# echo "GMP_INC=C:\Miniconda\Library\include" >> ${env:GITHUB_ENV}
# echo "MPFR_INC=C:\Miniconda\Library\include" >> ${env:GITHUB_ENV}
# echo "GMP_LIB=C:\Miniconda\Library\lib" >> ${env:GITHUB_ENV}

# - name: Cache build
# id: cache-build
# uses: actions/cache@v1
# with:
# path: ${{ env.appdata }}\Mozilla\sccache
# key: ${{ runner.os }}-${{ matrix.config }}-${{ matrix.static }}-cache

# - name: Prepare sccache
# run: |
# Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
# scoop install sccache --global
# # Scoop modifies the PATH so we make it available for the next steps of the job
# echo "${env:PATH}" >> ${env:GITHUB_PATH}
# # We run configure + build in the same step, since they both need to call VsDevCmd
# # Also, cmd uses ^ to break commands into multiple lines (in powershell this is `)
# - name: Configure and build
# shell: cmd
# run: |
# call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=x64
# cmake ^
# -DCMAKE_CXX_COMPILER_LAUNCHER=sccache ^
# -DCMAKE_BUILD_TYPE=${{ matrix.config }} ^
# -B build ^
# -S .
# cmake --build build --target cumin_bin
- name: Checkout repository
uses: actions/checkout@v1
with:
fetch-depth: 10
- uses: seanmiddleditch/gha-setup-ninja@master

- name: Set env
run: |
echo "appdata=$env:LOCALAPPDATA" >> ${env:GITHUB_ENV}
echo "GMP_INC=C:\Miniconda\Library\include" >> ${env:GITHUB_ENV}
echo "MPFR_INC=C:\Miniconda\Library\include" >> ${env:GITHUB_ENV}
echo "GMP_LIB=C:\Miniconda\Library\lib" >> ${env:GITHUB_ENV}
- name: Cache build
id: cache-build
uses: actions/cache@v1
with:
path: ${{ env.appdata }}\Mozilla\sccache
key: ${{ runner.os }}-${{ matrix.config }}-${{ matrix.static }}-cache

- name: Prepare sccache
run: |
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
scoop install sccache --global
# Scoop modifies the PATH so we make it available for the next steps of the job
echo "${env:PATH}" >> ${env:GITHUB_PATH}
# We run configure + build in the same step, since they both need to call VsDevCmd
# Also, cmd uses ^ to break commands into multiple lines (in powershell this is `)
- name: Configure and build
shell: powershell
run: |
cmake -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_BUILD_TYPE=${{ matrix.config }} -B build -S . -DIGL_STATIC_RUNTIME=ON
cmake --build build --target cumin_bin --config ${{ matrix.config }}
$env:PATH += ";C:\Miniconda\Library\bin"
.\build\Release\cumin_bin.exe -h
- name: Test
shell: powershell
run: |
wget https://raw.githubusercontent.com/libigl/libigl-tutorial-data/master/bunny.off -OutFile bunny.off
.\build\Release\cumin_bin.exe -i bunny.off
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Zhongshi Jiang, Ziyi Zhang, Yixin Hu, Teseo Schneider, Denis Zorin, Daniele Pano

[📺 Talk (YouTube)](https://youtu.be/yfztQw78gnE), [📝 Paper](https://cs.nyu.edu/~zhongshi/files/bichon_preview.pdf)
## TL;DR
- 📐 Input: Manifold and watertight triangle mesh, without self intersections.
- 📐 Input: Manifold and watertight triangle mesh, without self-intersections.
- Optional: Constraint Points and Feature Tagging.
- ➰ Output: High Order (Bezier) Tetrahedral Mesh
- Coarsened.
Expand All @@ -14,16 +14,16 @@ Zhongshi Jiang, Ziyi Zhang, Yixin Hu, Teseo Schneider, Denis Zorin, Daniele Pano
- Feature Preserving.
- Bijective High-order Surface to the input.
## News
- 📰 06/17/2021: First version of Bichon code is released!
- 📰 06/17/2021: The first version of Bichon code is released!
## Tips
- 📌
## Dataset
:confetti_ball: We provide generated high order tetrahedral meshes and their surface for
futher research and developement.
:confetti_ball: We provide generated high order tetrahedral meshes and their surface for the
future research and development.
- [Quartic Tetrahedral Meshes (.msh)](https://drive.google.com/file/d/1Gw3vza0GkY0pMf4kLcrOzQeCIlbEp4Cs/view?usp=sharing)

## Installation via CMake [![CMake](https://github.com/jiangzhongshi/bichon/actions/workflows/cmake.yml/badge.svg)](https://github.com/jiangzhongshi/bichon/actions/workflows/cmake.yml)
Our system is developed in a Linux environment, with GCC-9 and Clang-12, and is tested on macOS and ~~Windows~~ (TODO).
Our system is developed in a Linux environment, with GCC-9 and Clang-12, and is tested on macOS and Windows.
Please refer to [cmake.yml](.github/workflows/cmake.yml) for a more detailed setup.

```bash
Expand All @@ -36,13 +36,13 @@ make -j4
## Usage
### Input Format
Basic input is the triangle mesh, in the format of `.obj/.off/.ply/.stl`.
- We ask the mesh to be manifold, watertight, no degenerate triangle, and without self intersection. The precondition checks inside the program include numerical tolerance.
- We ask the mesh to be manifold, watertight, no degenerate triangle, and without self-intersection. The precondition checks inside the program include numerical tolerance.

Optional input is and HDF5 file, encoding feature tagging and constraint points, in the format of `.h5`.
- File might contains the following fields (all optional),
Optional input is an HDF5 file, encoding feature tagging and constraint points, in the format of `.h5`.
- File might contain the following fields (all optional),
- `E` is feature edges. Matrix of `|E|x2`, with each row indicating the endpoints (`v0,v1`) of the marked edge.
- `V` is the additional feature corners (the junction of several features). Corners can be automatically infered if there are three or more features meet. Therefore, `V` is only supplied when there is a corner with two feature lines meet. Vector of `|V|` with vertex indices.
- `P_fid` and `P_bc` for the constraint points where the distance bound is imposed upon. Vector of `|P|` for the list of faces where the points are, and Matrix of `|P|x3` for their corresponding barycentric coordinates on each points.
- `V` is the additional feature corners (the junction of several features). Corners can be automatically inferred if there are three or more features meet. Therefore, `V` is only supplied when there is a corner with two feature lines meeting. Vector of `|V|` with vertex indices.
- `P_fid` and `P_bc` for the constraint points where the distance bound is controlled. Vector of `|P|` for the list of faces where the points are, and Matrix of `|P|x3` for their corresponding barycentric coordinates on each point.
- We typically generate these files with [h5py](https://pypi.org/project/h5py/) or [HighFive (C++)](https://github.com/BlueBrain/HighFive).

### Output Format
Expand All @@ -58,7 +58,7 @@ Our internal ordering of the node (inside each high order element) is generated
Conversion convention to GMSH (`triangle6`, `triangle10`, `triangle15`,`tetra20`, `tetra35`) is manually coded in the same file.

Right now, the conversion of curved tetrahedral mesh from our `.h5` format to gmsh `.msh` format can be done with [format_utils.py](python/format_utils.py).
Further conversion is still on the way and PRs are welcome.
Further conversion is still on the way, and PRs are welcome.
### Command Line Usage
```bash
./cumin_bin -i INPUT_MESH -o OUTPUT_FOLDER/
Expand All @@ -72,16 +72,16 @@ Options:
-g,--graph TEXT feature graph and constraint point file .h5
-o,--output TEXT=./ output dir to save the serialization .h5 file
-l,--logdir TEXT log dir
--curve-distance_threshold FLOAT distance bound for the sampled point. Default on all the vertices, can be specified for the feature h5.
--curve-order INT the order of the surface mesh. Tetrahedral mesh will be of order +1
--feature-dihedral_threshold FLOAT automatic detecting feature based on dihedral angle.
--shell-target_edge_length FLOAT target edge length, only as a heuritic upper bound.
--curve-distance_threshold FLOAT distance bound for the sampled point. Default on all the vertices, and can be specified for the feature h5.
--curve-order INT the order of the surface mesh. The tetrahedral mesh will be of order +1
--feature-dihedral_threshold FLOAT automatic detecting feature based on the dihedral angle.
--shell-target_edge_length FLOAT target edge length, only as a heuristic upper bound.
```

## Visualization
We recommend visualize the high order meshes with jupyterlab and `meshplot`.
We recommend visualizing the high-order meshes with `jupyterlab` and `meshplot`.

`python/` folder contains several scripts to visualize or convert our serialization file. And the following snippet is usually used in jupyter notebook for inspecting the high order surface mesh.
`python/` folder contains several scripts to visualize or convert our serialization file. And the following snippet is usually used in jupyter notebook for inspecting the high-order surface mesh.
```python
import meshplot as mp
from vis_utils import h5reader, highorder_sv
Expand Down
4 changes: 3 additions & 1 deletion cmake/PrismDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ endif()
if(NOT TARGET highfive)
prism_download_HighFive()
option(HIGHFIVE_USE_EIGEN ON)

find_package(HDF5 REQUIRED)
add_library(highfive INTERFACE)
target_include_directories(highfive SYSTEM INTERFACE ${PRISM_EXTERNAL}/HighFive/include/ ${HDF5_INCLUDE_DIRS})
target_link_libraries(highfive INTERFACE ${HDF5_LIBRARIES})
target_compile_definitions(highfive INTERFACE H5_BUILT_AS_DYNAMIC_LIB)
endif()

if(NOT TARGET geogram::geogram)
Expand Down Expand Up @@ -82,7 +84,7 @@ if (NOT TARGET cvc3_rational)
endif()

if (NOT TARGET mitsuba_autodiff)
file(DOWNLOAD https://www.mitsuba-renderer.org/files/eigen/autodiff.h
file(DOWNLOAD https://raw.githubusercontent.com/polyfem/polyfem/master/src/utils/autodiff.h
${PRISM_EXTERNAL}/autodiff/autodiff_mitsuba.h)
add_library(mitsuba_autodiff INTERFACE)
target_include_directories(mitsuba_autodiff INTERFACE ${PRISM_EXTERNAL}/autodiff/)
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ PRIVATE

target_compile_definitions(prism_library PUBLIC CGAL_QP)
target_compile_features(prism_library PUBLIC cxx_std_17)
target_link_libraries(prism_library PUBLIC spdlog::spdlog igl::core osqp highfive geogram mitsuba_autodiff igl::cgal)
target_link_libraries(prism_library PUBLIC spdlog::spdlog igl::core osqpstatic highfive geogram mitsuba_autodiff igl::cgal)
target_include_directories(prism_library PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/)
set_target_properties(prism_library PROPERTIES POSITION_INDEPENDENT_CODE ON)
add_library(prism::prism ALIAS prism_library)
Expand Down
1 change: 1 addition & 0 deletions src/cumin/high_order_optimization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <highfive/H5Easy.hpp>
#include <prism/common.hpp>
#include <queue>
#include <optional>

#include "curve_common.hpp"
#include "curve_utils.hpp"
Expand Down
4 changes: 2 additions & 2 deletions src/curve_in_shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int main(int argc, char **argv) {
->required()
->check(CLI::ExistingFile)
->each([&filename](const std::string &s) {
filename = std::filesystem::path(s).filename();
filename = std::filesystem::path(s).filename().string();
});
program.add_option("-g,--graph", feature_graph_file, "feature graph .fgraph");
program.add_option("-o,--output", output_dir, "output dir")
Expand Down Expand Up @@ -93,7 +93,7 @@ int main(int argc, char **argv) {
dict_to_option(config, program);

program.callback([&]() {
filename = std::filesystem::path(input_file).filename();
filename = std::filesystem::path(input_file).filename().string();
if (log_dir != "") {
auto file_logger = spdlog::basic_logger_mt(
"cumin", log_dir + "/" + filename + suffix + ".log");
Expand Down
9 changes: 7 additions & 2 deletions src/pipeline_schedules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,13 @@ void volume_stage(PrismCage &pc, std::vector<RowMatd> &complete_cp,
Eigen::VectorXi labels;
tetshell_fill(vbase, mB, mT, vtop, mF, Vmsh, Tmsh, labels);
spdlog::debug("Tmsh {}", Tmsh.rows());
Tmsh = igl::slice_mask(
Tmsh, labels.unaryExpr([](const int x) -> bool { return x == 1; }), 1);
std::vector<Eigen::VectorXi> T1;
for (auto l = 0; l < labels.size(); l++) {
if (labels[l] == 1)
T1.emplace_back(Tmsh.row(l));
}
vec2eigen(T1, Tmsh);

spdlog::debug("Tmsh {}", Tmsh.rows());

auto &helper = prism::curve::magic_matrices(-1, -1);
Expand Down
2 changes: 1 addition & 1 deletion src/prism/cage_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <igl/triangle_triangle_adjacency.h>
#include <spdlog/fmt/bundled/ranges.h>
#include <spdlog/spdlog.h>

#include <optional>
#include <highfive/H5Easy.hpp>

#include "PrismCage.hpp"
Expand Down
1 change: 1 addition & 0 deletions src/prism/energy/prism_quality.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define PRISM_ENERGY_PRISM_QUALIY_HPP

#include "../common.hpp"
#include <thread>
#include <autodiff_mitsuba.h>

namespace prism::energy {
Expand Down
1 change: 1 addition & 0 deletions src/prism/energy/smoother_pillar.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef PRISM_ENERGY_SMOOTHER_PILLAR_HPP
#define PRISM_ENERGY_SMOOTHER_PILLAR_HPP
#include <prism/common.hpp>
#include <optional>

namespace prism {
RowMatd one_ring_volumes(const std::vector<Vec3d>& base,
Expand Down
1 change: 1 addition & 0 deletions src/prism/geogram/AABB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define PRISM_CGAL_AABB_HPP

#include <memory>
#include <optional>
#include <prism/common.hpp>

namespace GEO {
Expand Down
18 changes: 18 additions & 0 deletions src/prism/geogram/geogram_utils.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
#include "geogram_utils.hpp"

namespace {

#ifdef WIN32
int setenv(const char* name, const char* value, int overwrite)
{
int errcode = 0;
if (!overwrite) {
size_t envsize = 0;
errcode = getenv_s(&envsize, NULL, 0, name);
if (errcode || envsize) return errcode;
}
return _putenv_s(name, value);
}
#endif

} // namespace

void prism::geo::init_geogram() {
static bool first_time = true;

Expand Down

0 comments on commit 44c2040

Please sign in to comment.