Skip to content

Commit b7505cf

Browse files
authored
Merge pull request #31 from j-fu/stl
Stl
2 parents 7f7d243 + e1f1d74 commit b7505cf

File tree

7 files changed

+369
-241
lines changed

7 files changed

+369
-241
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
version:
18-
- '1.3' # Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'.
18+
- '1.6' # Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'.
1919
- '1' # Leave this line unchanged. '1' will automatically expand to the latest stable 1.x release of Julia.
20-
- '1.6' # usually nigthly, but error-catching fails on windows
20+
- 'nightly'
2121
os:
2222
- ubuntu-latest
2323
- macos-latest

Project.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "TetGen"
22
uuid = "c5d3f3f7-f850-59f6-8a2e-ffc6dc1317ea"
33
authors = ["SimonDanisch <[email protected]>", "Juergen Fuhrmann <[email protected]"]
4-
version = "1.3"
4+
version = "1.4.0"
55

66
[deps]
77
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
@@ -12,11 +12,11 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1212
TetGen_jll = "b47fdcd6-d2c1-58e9-bbba-c1cee8d8c179"
1313

1414
[compat]
15-
DocStringExtensions = "^0.8"
15+
DocStringExtensions = "0.8,0.9"
1616
GeometryBasics = "0.2, 0.3, 0.4"
1717
StaticArrays = "1"
18-
TetGen_jll = "1.5.1"
19-
julia = "1.3"
18+
julia = "1.6"
19+
TetGen_jll = "1.5.3"
2020

2121
[extras]
2222
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

examples/examples.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ end
8080
8181
Tetrahedralization of cube with local refinement callback
8282
"""
83-
8483
function cube_localref()
8584

8685
tetunsuitable() do pa,pb,pc,pd
@@ -109,8 +108,16 @@ function cube_localref()
109108
end
110109

111110

111+
"""
112+
cube_stl()
112113
113-
114+
Tetrahedralization of cube from an stl file
115+
"""
116+
function cube_stl()
117+
modeldir=joinpath(dirname(pathof(TetGen)),"..","test","surfaceModels")
118+
modelfile=joinpath(modeldir,"cube.stl")
119+
tetrahedralize(modelfile, "pQa1.0")
120+
end
114121
"""
115122
prism(;vol=1)
116123

src/cpptetgenio.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ function Base.show(io::IO, e::TetGenError)
8181
println(io,"TetGen error $(e.rc): two very close input facets were detected. Hint: use -Y option to avoid adding Steiner points in boundary.\n");
8282
elseif e.rc==10
8383
println(io,"TetGen error $(e.rc): an input error was detected.\n");
84+
elseif e.rc==101
85+
println(io,"TetGen error: unable to load stl file\n");
8486
else
8587
println(io,"TetGen error $(e.rc): unknown error.\n");
8688
end
@@ -102,6 +104,7 @@ function tetrahedralize(input::CPPTetGenIO{Float64}, command::String)
102104
end
103105

104106

107+
105108
"""
106109
Trivial Julia tetunsuitable function
107110
"""

src/rawtetgenio.jl

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,21 @@ function tetrahedralize(input::RawTetGenIO{Float64}, flags::String)
634634
RawTetGenIO(coutput)
635635
end
636636

637+
"""
638+
$(SIGNATURES)
639+
640+
Tetrahedralize stl file.
641+
"""
642+
function tetrahedralize(stlfile::String, flags::String)
643+
base=rsplit(stlfile,".",limit=2)[1]
644+
rc=Cint[0]
645+
coutput = ccall((:tetrahedralize2_stl_f64, libtet), CPPTetGenIO{Float64}, (Cstring, Cstring, Ptr{Cint}), base, flags, rc)
646+
if rc[1]!=0
647+
throw(TetGenError(rc[1]))
648+
end
649+
RawTetGenIO(coutput)
650+
end
651+
637652

638653
"""
639654
$(TYPEDSIGNATURES)
@@ -642,7 +657,7 @@ Create GeometryBasics.Mesh from the triface list
642657
(for quick visualization purposes using Makie's wireframe).
643658
"""
644659
function surfacemesh(tgio::RawTetGenIO)
645-
points=[ Point3f0(tgio.pointlist[:,i]...) for i=1:size(tgio.pointlist,2)]
660+
points=[ Point3f(tgio.pointlist[:,i]...) for i=1:size(tgio.pointlist,2)]
646661
faces= [TriangleFace(tgio.trifacelist[:,i]...) for i=1:size(tgio.trifacelist,2)]
647662
mesh=GeometryBasics.Mesh(points,faces)
648663
end
@@ -654,7 +669,7 @@ Create GeometryBasics.Mesh of all tetrahedron faces
654669
(for quick visualization purposes using Makie's wireframe).
655670
"""
656671
function volumemesh(tgio::RawTetGenIO)
657-
points=[ Point3f0(tgio.pointlist[:,i]...) for i=1:size(tgio.pointlist,2)]
672+
points=[ Point3f(tgio.pointlist[:,i]...) for i=1:size(tgio.pointlist,2)]
658673
faces=Array{NgonFace{3,Int32},1}(undef,0)
659674
tetlist=tgio.tetrahedronlist
660675
for itet=1:size(tetlist,2)

0 commit comments

Comments
 (0)