Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
032236d
Update upstream version to v1.6.1
j-fu Sep 23, 2026
a39ecba
Add save_poly and save_nodes methods
j-fu Sep 23, 2026
729e62b
fix cutprism example
j-fu Sep 23, 2026
2753ee3
Vheck for TetGen_jll version in save_ methods.
j-fu Sep 24, 2026
7b9f633
Remove 1.6 check as we now can use the 1.5.4 jll
j-fu Sep 25, 2026
903c912
Update version to 3.0
j-fu Sep 25, 2026
290fd02
Test with both 1.5.1 and 1.6.1 tetgen versions
j-fu Sep 25, 2026
1727189
Update README, docs
j-fu Sep 25, 2026
86c4643
Update Readme + changelog
j-fu Sep 26, 2026
c262a6d
Preserve cinput during save_tetgen call
j-fu Sep 26, 2026
cfc50f7
Fix test to save tetmesh instead of mesh
j-fu Sep 26, 2026
c3ff73d
Correct typo in save_tetgen function comment
j-fu Sep 26, 2026
29147ea
Update documentation for holelist array in rawtetgenio.jl
j-fu Sep 26, 2026
ac28aa0
Refactor save_tetgen to remove unnecessary return
j-fu Sep 26, 2026
7020e31
Change tetrahedralize parameter from 'p' to 'paqAQ'
j-fu Sep 26, 2026
90ddad4
Revise CHANGELOG.md for clarity and updates
j-fu Sep 26, 2026
2d572bb
fix dos line endings in changelog introduced by copilot
j-fu Sep 26, 2026
d867344
Bump JuliaRegistries/TagBot from 1.25.11 to 1.25.13
dependabot[bot] Oct 8, 2026
f6974f5
Update upstream version to v1.6.1
j-fu Sep 23, 2026
e5cc459
Add save_poly and save_nodes methods
j-fu Sep 23, 2026
44099c8
fix cutprism example
j-fu Sep 23, 2026
8c917ce
Vheck for TetGen_jll version in save_ methods.
j-fu Sep 24, 2026
85d2184
Remove 1.6 check as we now can use the 1.5.4 jll
j-fu Sep 25, 2026
e36c1a9
Update version to 3.0
j-fu Sep 25, 2026
64f1080
Test with both 1.5.1 and 1.6.1 tetgen versions
j-fu Sep 25, 2026
0e1cd59
Update README, docs
j-fu Sep 25, 2026
47a081b
Update Readme + changelog
j-fu Sep 26, 2026
346cd14
Preserve cinput during save_tetgen call
j-fu Sep 26, 2026
afb4751
Fix test to save tetmesh instead of mesh
j-fu Sep 26, 2026
f4d22bb
Correct typo in save_tetgen function comment
j-fu Sep 26, 2026
bd14a93
Update documentation for holelist array in rawtetgenio.jl
j-fu Sep 26, 2026
b621398
Refactor save_tetgen to remove unnecessary return
j-fu Sep 26, 2026
72ab225
Change tetrahedralize parameter from 'p' to 'paqAQ'
j-fu Sep 26, 2026
1e79635
Revise CHANGELOG.md for clarity and updates
j-fu Sep 26, 2026
661c673
fix dos line endings in changelog introduced by copilot
j-fu Sep 26, 2026
fab4d49
Merge branch 'jf/upstream-161' of github.com:JuliaGeometry/TetGen.jl …
j-fu Oct 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
# ubuntu-slim doesn't support containers, and thus won't work
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@cded32665b34ca0496d3ac10a67d08ddfc726963 # v1.25.11
- uses: JuliaRegistries/TagBot@ffef3282bcacf1055e4d621a5c010959dfbe59ff # v1.25.13
with:
token: ${{ secrets.GITHUB_TOKEN }}
# For commits that modify workflow files: SSH key enables tagging, but
Expand Down
13 changes: 9 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Changelog

All notable changes to this project since V1.0 will be documented in this file.

## [3.0.0] - unreleased
- Update TetGen_jll.jl dependency to 1.6.1 (corresponding to upstream TetGen version 1.6.1). Keep supporting TetGen_jll.jl
version 1.5.4 (corresponding to upstream TetGen version 1.5.1)
- Maintain CI tests for both upstream versions
- Add `save_tetgen` method to write out tetgen input to support creation of MWE for upstream bug reports

## [2.0.2] - 2026-05-11
- Cap TetGen_jll.jl version to ~1.5.3, to avoid unexpected behavior in CI tests.
See #47 for a discussion of the background
Expand Down Expand Up @@ -60,9 +65,9 @@ All notable changes to this project since V1.0 will be documented in this file.

- Thank you travis and bye bye
- Update of upstream patch version of TetGen to "August 18, 2018".
- Formally this still appears to be 1.5.1 , and it is manifest in TetGen_jll 1.5.1+1
- Catch errors thrown by TetGen in a rc variable, throw julia error if rc!=0
- Handle unsuitable callback to allow local refinement.
- Formally this still appears to be 1.5.1 , and it is manifest in TetGen_jll 1.5.1+1
- Catch errors thrown by TetGen in a rc variable, throw julia error if rc!=0
- Handle unsuitable callback to allow local refinement.

## [1.0.0] - 2020-11-30
- Dependency on artifacts
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TetGen"
uuid = "c5d3f3f7-f850-59f6-8a2e-ffc6dc1317ea"
version = "3.0"
authors = ["SimonDanisch <sdanisch@gmail.com>", "Juergen Fuhrmann <juergen.fuhrmann@wias-berlin.de"]
version = "2.0.2"

[deps]
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Expand All @@ -17,5 +17,5 @@ GeometryBasics = "0.4, 0.5"
LinearAlgebra = "1"
Printf = "1"
StaticArrays = "1"
TetGen_jll = "~1.5.3"
TetGen_jll = "~1.5.4, 1.6.1"
julia = "1.9"
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,31 @@
[![](https://img.shields.io/badge/docs-dev-blue.svg)](https://JuliaGeometry.github.io/TetGen.jl/dev)
[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)

The `TetGen.jl` package is a Julia wrapper for the C++ project [TetGen](https://wias-berlin.de/software/index.jsp?id=TetGen&lang=1). This wrapper enables TetGen based tetrahedral meshing, and (constrained) 3D Delaunay and Voronoi tessellation.
The `TetGen.jl` package is a Julia wrapper for the C++ project [TetGen](https://codeberg.org/TetGen/TetGen). This wrapper enables TetGen based tetrahedral meshing, and (constrained) 3D Delaunay and Voronoi tessellation.

If you find TetGen useful, please consider citing
Hang Si: "TetGen, a Delaunay-Based Quality Tetrahedral Mesh Generator" ACM Trans. on Mathematical Software. 41 (2), 2015
[http://doi.acm.org/10.1145/2629697](http://doi.acm.org/10.1145/2629697).

## Supported upstream versions
By choosing corresponding versions of the [TetGen_jll.jl](https://github.com/JuliaBinaryWrappers/TetGen_jll.jl) binary package,
it is possible to choose between different TetGen upstream versions:

| TetGen version | TetGen_jll version |
|:--------------:|:------------------:|
| 1.5.1 | 1.5.4 |
| 1.6.1 | 1.6.1 |

By default, the package manager installs version 1.6.1.

## Submitting bug reports
Bug reports regarding the Julia wrapper can be submitted just by opening an issue in this repo. Please try to attach a minimal
working example (MWE) to your report.

Bug reports to upstream TetGen (v1.6.1) can be submitted to the [codeberg upstream repository](https://codeberg.org/TetGen/TetGen).
The `save_tetgen(input, fstub)` converts and writes the Julia input description to a pair of TetGen `.node` and `.poly` files which can serve
as an MWE.

## License

When installing TetGen.jl, a compiled library version of the TetGen library will be downloaded from the [TetGen_jll.jl](https://github.com/JuliaBinaryWrappers/TetGen_jll.jl) repository. This library is bound to the [Affero Gnu Public License v3 (AGPL)](https://www.gnu.org/licenses/agpl-3.0.html), but the bindings to the library in this package, TetGen.jl, are licensed under MIT. This means that code using the TetGen library via the TetGen.jl bindings is subject to TetGen's licensing terms. If you distribute covered work, i.e. a program that links to and is distributed with the TetGen library, then that distribution falls under the terms of the AGPLv3.
Expand Down
4 changes: 2 additions & 2 deletions examples/examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ function cutprism(; vol = 0.05)
-1 2 10
]'

push!(input.facetlist, RawFacet([Cint[1, 2, 3], Cint[7, 8, 9, 10]], [0.1 0.1 0.0;]))
push!(input.facetlist, RawFacet([Cint[4, 5, 6], Cint[11, 12, 13, 14]], [0.1 0.1 1.0;]))
push!(input.facetlist, RawFacet([Cint[1, 2, 3], Cint[7, 8, 9, 10]], Matrix([0.1 0.1 0.0;]')))
push!(input.facetlist, RawFacet([Cint[4, 5, 6], Cint[11, 12, 13, 14]], Matrix([0.1 0.1 1.0;]')))
push!(input.facetlist, RawFacet([Cint[1, 2, 5, 4]], Array{Cdouble, 2}(undef, 0, 0)))
push!(input.facetlist, RawFacet([Cint[2, 3, 6, 5]], Array{Cdouble, 2}(undef, 0, 0)))
push!(input.facetlist, RawFacet([Cint[3, 1, 4, 6]], Array{Cdouble, 2}(undef, 0, 0)))
Expand Down
2 changes: 2 additions & 0 deletions src/TetGen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ using Printf: Printf
using StaticArrays: StaticArrays, SVector
using TetGen_jll: TetGen_jll, libtet


include("cpptetgenio.jl")
include("jltetgenio.jl")
include("rawtetgenio.jl")
Expand All @@ -27,5 +28,6 @@ export TetGenError
export RawTetGenIO, facetlist!, RawFacet
export numberofpoints, numberoftetrahedra, numberoftrifaces, numberofedges
export volumemesh, surfacemesh
export save_tetgen

end # module
29 changes: 19 additions & 10 deletions src/api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ function voronoi(points::Vector{Point{3, T}}) where {T <: AbstractFloat}
return Mesh{Triangle}(result)
end


function JLTetGenIO(mesh; marker = :markers, holes = Point{3, Float64}[])
f = faces(mesh)
if pkgversion(GeometryBasics) < v"0.5"
kw_args = Any[:facets => GeometryBasics.metafree(f), :holes => holes]
else
kw_args = Any[:facets => f, :holes => holes]
end
if hasproperty(f, marker)
push!(kw_args, :facetmarkers => getproperty(f, marker))
end
return JLTetGenIO(coordinates(mesh); kw_args...)
end

"""
$(SIGNATURES)

Expand All @@ -27,20 +41,15 @@ function tetrahedralize(
mesh, command = "Qp";
marker = :markers, holes = Point{3, Float64}[]
)
f = faces(mesh)
if pkgversion(GeometryBasics) < v"0.5"
kw_args = Any[:facets => GeometryBasics.metafree(f), :holes => holes]
else
kw_args = Any[:facets => f, :holes => holes]
end
if hasproperty(f, marker)
push!(kw_args, :facetmarkers => getproperty(f, marker))
end
tio = JLTetGenIO(coordinates(mesh); kw_args...)
tio = JLTetGenIO(mesh; marker, holes)
result = tetrahedralize(tio, command)
return Mesh{Tetrahedron}(result)
end

function save_tetgen(mesh, fstub; marker = :markers, holes = Point{3, Float64}[])
return save_tetgen(JLTetGenIO(mesh; marker, holes), fstub)
end
Comment thread
Copilot marked this conversation as resolved.

# JF: probably this case is included in the case above
# """
# $(SIGNATURES)
Expand Down
21 changes: 21 additions & 0 deletions src/cpptetgenio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ struct CFacet{T}
numberofholes::Cint
end

"""
struct CPPTetGenIO

Julia "mirror" structure to be passed to the C wrapper code.
"""
struct CPPTetGenIO{T}
firstnumber::Cint # 0 or 1, default 0.
mesh_dim::Cint # must be 3.
Expand Down Expand Up @@ -155,3 +160,19 @@ function tetunsuitable!(unsuitable::Function; check_signature = true)
c_wrap_tetunsuitable = @cfunction(jl_wrap_tetunsuitable, Cint, (Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}))
return ccall((:tetunsuitable_callback, libtet), Cvoid, (Ptr{Cvoid},), c_wrap_tetunsuitable)
end


"""
save_tetgen(input, fstub)

Save input (mesh, [`CPPTetGenIO`](@ref), [`JLTetGenIO`](@ref) or [`RawTetGenIO`](@ref))
to the files `fstub.node` and `fstub.poly`. These can be read by the tetgen executable and are suited for submission of
bug reports to upstream tetgen.
"""
function save_tetgen end

function save_tetgen(cinput::CPPTetGenIO{Float64}, fstub::String)
ccall((:save_poly, libtet), Cvoid, (CPPTetGenIO{Float64}, Cstring), cinput, fstub)
ccall((:save_nodes, libtet), Cvoid, (CPPTetGenIO{Float64}, Cstring), cinput, fstub)
return nothing
end
11 changes: 11 additions & 0 deletions src/jltetgenio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ end
inttype(::Type{Float64}) = Int64
inttype(::Type{Float32}) = Int32

"""
struct JLTetGenIO

Intermediate structure for TetGen data for interaction with GeometryBasics.Mesh.
"""
struct JLTetGenIO{T, NSimplex, NAttributes, NMTr, IT, FT}
points::Vector{Point{3, T}}
pointattributes::Vector{SVector{NAttributes, T}}
Expand Down Expand Up @@ -339,3 +344,9 @@ function tetrahedralize(input::JLTetGenIO{Float64}, command::String)
end
return convert(JLTetGenIO, cres)
end

function save_tetgen(input::JLTetGenIO{Float64}, fstub::String)
cinput = Base.cconvert(CPPTetGenIO{Float64}, input)
GC.@preserve cinput save_tetgen(cinput[1], fstub)
return nothing
end
14 changes: 11 additions & 3 deletions src/rawtetgenio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ struct RawFacet{T}
polygonlist::Array{Array{Cint, 1}, 1}

"""
Array of points given by their coordinates
marking polygons describing holes in the facet.
`3 x nholes` array of points marking holes in the facet.
"""
holelist::Array{T, 2}
end
Expand Down Expand Up @@ -357,6 +356,9 @@ function CPPTetGenIO(tio::RawTetGenIO{T}) where {T}
for ipolygon in 1:numberofpolygons
polygonlist[ipolygon] = CPolygon(pointer(facet.polygonlist[ipolygon]), size(facet.polygonlist[ipolygon], 1))
end
if length(facet.holelist) > 0
@assert size(facet.holelist, 1) == 3
end
numberofholes = size(facet.holelist, 2)
push!(polygonlist_array, polygonlist)
push!(
Expand Down Expand Up @@ -700,8 +702,14 @@ function tetrahedralize(stlfile::String, flags::String)
return RawTetGenIO(coutput)
end

function save_tetgen(input::RawTetGenIO{Float64}, fstub::String)
cinput, flist, plist = CPPTetGenIO(input)
save_tetgen(cinput, fstub)
return nothing
end

"""
$(TYPEDSIGNATURES)
$(TYPEDSIGNATURES)

Create GeometryBasics.Mesh from the triface list
(for quick visualization purposes using Makie's wireframe).
Expand Down
10 changes: 10 additions & 0 deletions test/runtests-tetgen-1.5.1.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
push!(LOAD_PATH, "@v#.#", "@stdlib")
using Pkg
Pkg.activate(; temp = true)
Pkg.add("GeometryBasics")
Pkg.add(name = "TetGen_jll", version = "1.5.4")
Pkg.develop(path = joinpath(@__DIR__, ".."))
using Test
@testset "tetgen 1.5.1" begin
include("tetgentests.jl")
end
Loading
Loading