Skip to content

Commit

Permalink
Release 1.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
nodtem66 committed Aug 8, 2021
1 parent 678630d commit 91e6f66
Show file tree
Hide file tree
Showing 29 changed files with 1,343 additions and 999 deletions.
24 changes: 13 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,17 @@ endif()
if(BUILD_SCAFFOLDER)
# Add your project files
file(GLOB MAIN_SOURCES
"${PROJECT_SOURCE_DIR}/include/*.c"
"${PROJECT_SOURCE_DIR}/include/*.cpp"
"${PROJECT_SOURCE_DIR}/include/*.tpp"
"${PROJECT_SOURCE_DIR}/include/*.h"
"${PROJECT_SOURCE_DIR}/include/*.hpp"
"${PROJECT_SOURCE_DIR}/include/*/*.c"
"${PROJECT_SOURCE_DIR}/include/*/*.cpp"
"${PROJECT_SOURCE_DIR}/include/*/*.tpp"
"${PROJECT_SOURCE_DIR}/include/*/*.h"
"${PROJECT_SOURCE_DIR}/include/*/*.hpp"
"${PROJECT_SOURCE_DIR}/src/utils.cpp"
"${PROJECT_SOURCE_DIR}/src/Scaffolder.cpp"
"${VCG_INCLUDE_DIR}/wrap/ply/plylib.cpp"
"${OpenCTM_INCLUDE_DIR}/*.c"
"${OpenCTM_INCLUDE_DIR}/liblzma/*.c"
)
include(update_deps_file)
update_deps_file("main_sources" "${MAIN_SOURCES}")


# Build binary
add_executable(${PROJECT_NAME} ${MAIN_SOURCES} ${PROJECT_SOURCE_DIR}/src/Main.cpp)
Expand All @@ -145,6 +139,7 @@ if(BUILD_SCAFFOLDER)
${SOL2_INCLUDE_DIR}
${LUA_INCLUDE_DIR}
${OpenCTM_INCLUDE_DIR}
${LIBIGL_INCLUDE_DIR}
"${OpenCTM_INCLUDE_DIR}/liblzma/"
)
target_link_libraries(${PROJECT_NAME} PRIVATE
Expand All @@ -155,10 +150,15 @@ if(BUILD_SCAFFOLDER)
${LUA_LIBRARIES}
)

add_executable("${PROJECT_NAME}.SliceTest" ${MAIN_SOURCES} ${PROJECT_SOURCE_DIR}/src/SliceTest.cpp)
add_executable("${PROJECT_NAME}.SliceTest"
${PROJECT_SOURCE_DIR}/src/SliceTest.cpp
${PROJECT_SOURCE_DIR}/src/utils.cpp
${VCG_INCLUDE_DIR}/wrap/ply/plylib.cpp
)
target_include_directories("${PROJECT_NAME}.SliceTest" PRIVATE
"${PROJECT_SOURCE_DIR}/include"
${VCG_INCLUDE_DIR}
${LIBIGL_INCLUDE_DIR}
${EIGEN3_INCLUDE_DIR}
${OpenCTM_INCLUDE_DIR}
"${OpenCTM_INCLUDE_DIR}/liblzma/"
Expand All @@ -177,19 +177,21 @@ if(BUILD_PYSCAFFOLDER)

file(GLOB PYTHON_SOURCES
"${PROJECT_SOURCE_DIR}/src/python/*.cpp"
"${PROJECT_SOURCE_DIR}/src/python/*.hpp"
"${PROJECT_SOURCE_DIR}/src/utils.cpp"
${PROJECT_SOURCE_DIR}/src/Scaffolder.cpp
${PROJECT_SOURCE_DIR}/src/utils.cpp
)
include(update_deps_file)
update_deps_file("python_sources" "${PYTHON_SOURCES}")

pybind11_add_module("Py${PROJECT_NAME}" ${PYTHON_SOURCES})
target_include_directories("Py${PROJECT_NAME}" PRIVATE
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_SOURCE_DIR}/src/python/"
${TBB_INCLUDE_DIR}
${VCG_INCLUDE_DIR}
${EIGEN3_INCLUDE_DIR}
${SOL2_INCLUDE_DIR}
${LIBIGL_INCLUDE_DIR}
${LUA_INCLUDE_DIR}
${PyBind11_INCLUDE_DIR}
${OpenCTM_INCLUDE_DIR}
Expand Down
5 changes: 4 additions & 1 deletion blender/SCAFFOLDER_OP_generate_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def callback(v):
f = read_faces(mesh)

def gen(self):
mesh = PyScaffolder.generate_mesh(v, f, params, callback)
if ('__version__' in PyScaffolder.__dict__):
mesh = PyScaffolder.generate_scaffold(v, f, params, callback)
else:
mesh = PyScaffolder.generate_mesh(v, f, params, callback)
template_str = "Porosity: %.3f\nSurface Area: %.3f\nSurface Area Ratio: %.3f"
props.result1 = template_str % (mesh.porosity, mesh.surface_area, mesh.surface_area_ratio)

Expand Down
4 changes: 2 additions & 2 deletions blender/SCAFFOLDER_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def set_coff(self, context):
is_build_inverse: BoolProperty(name="Build inverse", default=False)

grid_size: IntProperty(name="Grid size", default=100, min=10)
grid_offset: IntProperty(name="Grid offset", default=5, min=0)
smooth_step: IntProperty(name="smooth step", default=5, min=0)
grid_offset: IntProperty(name="Grid offset", default=3, min=0)
smooth_step: IntProperty(name="smooth step", default=0, min=0)
k_slice: IntProperty(name="k slice", default=100, min=1)
k_polygon: IntProperty(name="k polygon", default=4, min=1)

Expand Down
2 changes: 1 addition & 1 deletion cmake/FindLIBIGL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ set(LIBIGL_USE_STATIC_LIBRARY OFF CACHE INTERNAL "prefer STATIC build")
set(LIBIGL_SKIP_DOWNLOAD ON CACHE INTERNAL "Skip download libigl")
# set(HUNTER_ENABLED ON CACHE INTERNAL "Enable Hunter package manager support")

message(STATUS "USE DIR: ${LIBIGL_INCLUDE_DIR}")
message(STATUS "USE IGL DIR: ${LIBIGL_INCLUDE_DIR}")
list(APPEND CMAKE_MODULE_PATH "${LIBIGL_INCLUDE_DIR}/../cmake")
if (NOT EIGEN3_INCLUDE_DIR)
set(EIGEN3_INCLUDE_DIR "${LIBIGL_INCLUDE_DIR}/../external/eigen")
Expand Down
4 changes: 2 additions & 2 deletions cmake/FindSol2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ file(GLOB SOL2_HEADER_SOURCES ${SOL2_INCLUDE_DIR}/sol*.hpp)
source_group(sol2 FILES ${SOL2_HEADER_SOURCES})

list(APPEND CMAKE_MODULE_PATH "${SOL2_INCLUDE_DIR}/../cmake/Modules")
message(STATUS "USE DIR: ${SOL2_INCLUDE_DIR}")
message(STATUS "USE SOL2 DIR: ${SOL2_INCLUDE_DIR}")

# # # Libraries
# Here, we pull in all the necessary libraries for building examples and tests
Expand Down Expand Up @@ -143,4 +143,4 @@ endif()
if (NOT LUA_FOUND AND NOT LUABUILD_FOUND)
message(FATAL_ERROR "sol2 Lua \"${SOL2_LUA_VERSION}\" not found and could not be targeted for building")
endif()
message(STATUS "USE DIR: ${LUA_LIBRARIES} ${LUA_INCLUDE_DIR}")
message(STATUS "USE LUA DIR: ${LUA_LIBRARIES} ${LUA_INCLUDE_DIR}")
34 changes: 21 additions & 13 deletions docs/cmd.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Usage:
Scaffolder [OPTION...] INPUT OUTPUT PARAMETERS
-h, --help Print help
-i, --input INPUT Input file (STL)
-i, --input INPUT Input file (STL/PLY/OFF/OBJ/VMI)
-o, --output OUTPUT Output filename with extension
stl,ply,obj,off [default: out]
stl,ply,obj,off,ctm
--params PARAMETERS Combined parameters list:
surface[,coff,isolevel,grid_size,k_slice,k_polygon]
-q, --quiet Disable verbose output [default: false]
Expand All @@ -17,7 +17,7 @@ Usage:
-n, --surface NAME implicit surface: rectlinear, schwarzp,
schwarzd, gyroid, double-p, double-d,
double-gyroiod, lidinoid, schoen_iwp, neovius, bcc,
tubular_g_ab, tubular_g_c [default: schwarzp]
tubular_g_ab, tubular_g_c (default: bcc)
-g, --grid_size INT (0..60000)
Grid size [default: 100]
-s, --shell INT (0..60000) Outer thickness (layers) [default:0]
Expand All @@ -27,23 +27,31 @@ Usage:
technique ( [default: false]
--export_microstructure Analysis microstructure and export the 2D
contours (for debugging) [default: false]
--export_jpeg [X|Y|Z],INT
Export 2D JPEG (Default: Z,100)
--k_slice INT (0..60000) K_slice: the number of slicing layers in each
direction (used in microstructure analysis)
[default: 100]
(default: 100)
--k_polygon INT (>0) K_polygon: the number of closest outer
contour (used in microstructure analysis) [default: 4]
contour (used in microstructure analysis) (default:
4)
-z, --size_optimize DOUBLE (0..1)
Experimental Quadric simplification [default: 0]
Experimental Quadric simplification (default:
0)
--smooth_step INT (0..60000)
Smooth with laplacian (default: 5)
--dirty Disable autoclean [default false]
Smooth with laplacian (default: 0)
--dirty Disable autoclean
--minimum_diameter DOUBLE (0..1)
used for removing small orphaned (between 0-1) [default: 0.25]
used for removing small orphaned (between
0-1) (default: 0.25)
--format FORMAT (default, csv)
Format of logging output [default: default]
--output_inverse additional output inverse scaffold [default: false]
--fix_self_intersect Experimental fix self-intersect faces
[default: false]
Format of logging output (default: default)
--output_inverse additional output inverse scaffold
--fix_self_intersect INT Experimental fix self-intersect faces
(default: 0)
--mean_curvature INT Size of mean curvature histogram (default: 0)
--no_intersect Generate 3D mesh without intersect with
original mesh (false)
```

## Examples
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ params = PyScaffolder.Parameter()
params.coff = 1.0

# Test the mesh generation from v,f
a = PyScaffolder.[generate_mesh]()(v, f, params)
a = PyScaffolder.generate_scaffold(v, f, params)
print(a.porosity)
print(a.surface_area_ratio)
print(len(a.v), len(a.f))
Expand Down
44 changes: 39 additions & 5 deletions docs/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ namespace PyScaffolder {
}
```
The main core functions are `generate_mesh` and `slice_test` which resemble the standalone program: `Scaffolder` and `Scaffolder.Slice`.
The main core functions are `generate_scaffold` and `slice_test` which resemble the standalone program: `Scaffolder` and `Scaffolder.Slice`.
## generate_mesh
## generate_scaffold
```python
def generate_mesh(vertices, faces, params=Parameter(), callback=None)
def generate_scaffold(vertices, faces, params=Parameter(), callback=None)
```
: Generate 3D mesh from input vertices, faces, and parameters
### Parameters
Expand Down Expand Up @@ -113,7 +113,7 @@ def generate_mesh(vertices, faces, params=Parameter(), callback=None)

# use callback to show % progression
def progression(n):
print(x)
print(n)

mesh_info = generate_mesh(v, f, callback=progression)
```
Expand Down Expand Up @@ -147,11 +147,45 @@ def slice_test(vertices, faces, k_slice=100, k_polygon=4, direction=0, callback=
print(len(pore_size.minFeret), len(pore_size.maxFeret))
```

## marching_cubes
```python
def marching_cubes(f, grid_size=(100,100,100), v_min=(0,0,0), delta=0.01, clean=False, callback=None)
```
: Slice input mesh into pore sizes
### Parameters
* `f`: numpy.array representing a discrete isosurface where F(x,y,z) = 0 is boundary
* `grid_size`: *Optional* array, list, tuple, or int representing the number of voxels
* `v_min`: *Optional* array, list, tuple the coordinate of the corner of grid
* `delta`: *Optional* array, list, tuple or double representing the dimension of a voxel
* `clean` *Optional* boolean that enable mesh cleaning after marching cubes
* `callback`: *Optional* function with one `integer` parameter indicating the progression
###Return
`#!python (v, f)` representing vertices and faces in `np.array`

###Example
```python
import PyScaffolder
Fxyz = [
1,1,1,1,
1,-1,-1,1,
1,-1,-1,1,
1,1,1,1
]*4
(v, f) = PyScaffolder.marching_cubes(
Fxyz,
grid_size=4,
delta=0.25,
v_min=(-.5, -.5, -.5),
callback = lambda x: print(x)
)
```

## Parameter
```python
class Parameter:
is_build_inverse = False
is_intersect = True
verbose = False
shell = 0
grid_offset = 5
smooth_step = 5
Expand Down Expand Up @@ -190,4 +224,4 @@ class MeshInfo:
surface_area = 0.0
surface_area_ratio = 0.0
```
: Collection of triangular mesh resulted from [generate_mesh](#generate_mesh)
: Collection of triangular mesh resulted from [generate_scaffold](#generate_scaffold)
4 changes: 2 additions & 2 deletions docs/tutorial_1.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ angular frequency ($w$), and isolevel ($t$) are required (See [Command line](cmd
## Angular frequency

According to [prior study](https://github.com/nodtem66/Scaffolder/blob/master/data/data_visualization.ipynb),
**$w$ is inversely proportational to the pore size** (see [Tips](tips.md)). That is when $w$ increases,
**$w$ is inversely proportational to the pore size** (see [Tips](tips.md)). That is, when $w$ increases,
the pore size will be decreased. For gyroid, $w \approx \pi/\text{pore size}$. If we want pore size of 0.25
(unit as same as `sphere.stl`), we try to initially set $w = \pi/0.25 \approx 12$

Expand Down Expand Up @@ -107,7 +107,7 @@ We use binary search to adjust the new value of $t$ to find the optimal value wi
| -- | -- | -- | -- | -- | -- | -- | -- | -- |
| Porosity | 0.508 | 0.85 | 0.67 | 0.59 | 0.634 | 0.613 | 0.602 | 0.597

We can also use the classic numerical method called [Secant method](https://en.wikipedia.org/wiki/Secant_method) to find the optimal $t$ for the target porosity.
We can also use the classical numerical method called [Secant method](https://en.wikipedia.org/wiki/Secant_method) to find the optimal $t$ for the target porosity.

$$
F(t) = Porosity(t) - 0.6 = 0
Expand Down
6 changes: 4 additions & 2 deletions include/MaxHeap.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#ifndef MAXHEAP_HPP_INCLUDED
#define MAXHEAP_HPP_INCLUDED

#include <vector>
#include <iostream>
Expand Down Expand Up @@ -42,4 +43,5 @@ class MaxHeap {
(*arr)[0] = d;
heapify(0);
}
};
};
#endif
2 changes: 1 addition & 1 deletion include/Mesh.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#ifndef MESH_INCLUDED
#define MESH_INCLUDED

#include <openctm.h>
#include <vcg/complex/complex.h>
#include <vcg/complex/algorithms/update/halfedge_indexed.h>
Expand Down
2 changes: 1 addition & 1 deletion include/MeshOperation.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#ifndef MESHOPERATION_INCLUDED
#define MESHOPERATION_INCLUDED

#include "Mesh.h"
#include "utils.h"

Expand Down
2 changes: 1 addition & 1 deletion include/OptimalSlice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* This is the implement slice algorithm from Rodrigo, 2017 (An Optimal Algorithm for 3D Triangle Mesh Slicing)
* which is claimed to be faster than slic3r and CGAL method.
*/
#pragma once
#ifndef OPTIMALSLICE_INCLUDED
#define OPTIMALSLICE_INCLUDED

#ifndef SLICE_PRECISION
// There's a problem of double hashing with the precision less than 1e-8 (e.g. 1e-10)
// when performed contour constructing
Expand Down
2 changes: 1 addition & 1 deletion include/QuadricSimplification.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
* for more details. *
* *
****************************************************************************/
#pragma once
#ifndef QUADSIM_INCLUDED
#define QUADSIM_INCLUDED

#include <vcg/container/simple_temporary_data.h>
#include <vcg/complex/algorithms/local_optimization.h>
#include <vcg/complex/algorithms/local_optimization/tri_edge_collapse_quadric.h>
Expand Down
Loading

0 comments on commit 91e6f66

Please sign in to comment.