Skip to content

Commit 3187cef

Browse files
Steffen SchulerSteffen Schuler
Steffen Schuler
authored and
Steffen Schuler
committed
Added vtkFillSurfaceHoles
based on the code by Constantine Butakoff: https://github.com/cbutakoff/tools/tree/master/FillSurfaceHoles
1 parent be5abee commit 3187cef

20 files changed

+6056
-1
lines changed

CMakeLists.txt

+11-1
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,16 @@ if(VTK_VERSION LESS 8.9)
4949
include(${VTK_USE_FILE})
5050
endif()
5151

52+
## Set up Eigen3 dependency (needed for vtkFillSurfaceHoles)
53+
find_package(Eigen3 REQUIRED)
54+
if(NOT EIGEN3_FOUND)
55+
message(FATAL_ERROR "Eigen3 could not be found. Try setting EIGEN3_INCLUDE_DIR.")
56+
else()
57+
message(STATUS "Found Eigen3: " ${EIGEN3_INCLUDE_DIR})
58+
endif()
59+
5260
## Build library "vtkMatlab", which is used by all MEX functions in this toolbox
53-
include_directories(libvtkMatlab ${Matlab_INCLUDE_DIRS})
61+
include_directories(libvtkMatlab ${Matlab_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR})
5462
add_library(vtkMatlab STATIC libvtkMatlab/common.cxx libvtkMatlab/vtkToStruct.cxx libvtkMatlab/structToVtk.cxx)
5563
target_link_libraries(vtkMatlab ${VTK_LIBRARIES})
5664

@@ -88,3 +96,5 @@ matlab_add_mex(NAME vtkThreshold SRC vtkThreshold/vtkThreshold.cxx LINK_TO vtkMa
8896
matlab_add_mex(NAME vtkTriangleFilter SRC vtkTriangleFilter/vtkTriangleFilter.cxx LINK_TO vtkMatlab ${VTK_LIBRARIES})
8997
matlab_add_mex(NAME vtkWindowedSincPolyDataFilter SRC vtkWindowedSincPolyDataFilter/vtkWindowedSincPolyDataFilter.cxx LINK_TO vtkMatlab ${VTK_LIBRARIES})
9098
#matlab_add_mex(NAME vtkMmg3d SRC vtkMmg3d/vtkMmg3d.cxx LINK_TO vtkMatlab ${VTK_LIBRARIES} mmg3d Scotch)
99+
matlab_add_mex(NAME vtkFillSurfaceHoles SRC vtkFillSurfaceHoles/vtkFillSurfaceHoles.cxx vtkFillSurfaceHoles/FillSurfaceHoles/SurfaceHoleFiller.cpp vtkFillSurfaceHoles/FillSurfaceHoles/UmbrellaWeightedOrder2Smoother.cpp vtkFillSurfaceHoles/FillSurfaceHoles/CoverRefiner.cpp LINK_TO vtkMatlab ${VTK_LIBRARIES})
100+
target_link_libraries(vtkFillSurfaceHoles Eigen3::Eigen)

MATLAB/vtkFillSurfaceHoles.m

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
% Detects and fills holes in a vtkPolyData.
2+
% You can choose, whether/how to smooth the filled-in surface.
3+
%
4+
% This function uses Constantine Butakoff's code from
5+
% https://github.com/cbutakoff/tools/tree/master/FillSurfaceHoles (commit 8c2cac1),
6+
% which implements the algorithms in
7+
% P. Liepa (2003), Filling Holes in Meshes, http://dx.doi.org/10.2312/SGP/SGP03/200-206
8+
% G. Barequet et al. (1995), Filling gaps in the boundary of a polyhedron, https://doi.org/10.1016/0167-8396(94)00011-G
9+
%
10+
% Syntax:
11+
% outStruct = vtkFillSurfaceHoles(struct inStruct, (char method), (bool verbose))
12+
%
13+
% method: smoothing method:
14+
% 'none': no smoothing
15+
% 'cot': cotangent weights (default)
16+
% 'edgelen': inverse edge length weights
17+
% verbose: whether to print status messages (default: false)
18+
%
19+
% Written in 2021 by Steffen Schuler
20+
% Institute of Biomedical Engineering, KIT
21+
% www.ibt.kit.edu
22+
23+
function outStruct = vtkFillSurfaceHoles(inStruct, method, verbose) %#ok

vtkFillSurfaceHoles/CMakeLists.txt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FIND_PACKAGE(VTK REQUIRED)
2+
INCLUDE(${VTK_USE_FILE})
3+
4+
5+
#FIND_PACKAGE(Boost COMPONENTS serialization REQUIRED)
6+
find_package(Eigen3 REQUIRED)
7+
8+
include_directories(${EIGEN3_INCLUDE_DIR})
9+
#include_directories(${Boost_INCLUDE_DIRS})
10+
11+
set(SOURCES
12+
HoleFillerDefines.h
13+
UmbrellaWeightedOrder2Smoother.h
14+
UmbrellaWeightedOrder2Smoother.cpp
15+
SurfaceHoleFiller.h
16+
SurfaceHoleFiller.cpp
17+
FillSurfaceHoles.cpp
18+
CoverRefiner.h
19+
CoverRefiner.cpp
20+
)
21+
22+
ADD_EXECUTABLE(FillSurfaceHoles ${SOURCES})
23+
TARGET_LINK_LIBRARIES(FillSurfaceHoles ${VTK_LIBRARIES})
24+
#TARGET_LINK_LIBRARIES(FillSurfaceHoles ${VTK_LIBRARIES} ${Boost_LIBRARIES})
25+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
All code in this directory is by Constantine Butakoff
2+
(https://github.com/cbutakoff/tools/tree/master/FillSurfaceHoles, commit 8c2cac1)
3+
and licensed under the Attribution-NonCommercial-ShareAlike 4.0 International license.

0 commit comments

Comments
 (0)