Skip to content

Commit c641c59

Browse files
authored
PR for unreleased version. (#2)
* PR for unreleased version. * Update versions.
1 parent 3cdffe8 commit c641c59

File tree

5 files changed

+52
-81
lines changed

5 files changed

+52
-81
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
version:
13-
- "1.3"
14-
- "1.5"
13+
- "1.6"
14+
- "1.7"
1515
- "nightly"
1616
os:
1717
- ubuntu-latest

Manifest.toml

Lines changed: 0 additions & 75 deletions
This file was deleted.

Project.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
name = "StarTIN"
22
uuid = "152385ed-0447-47b3-b417-bbbf3d580ece"
33
authors = ["Maarten Pronk <git@evetion.nl> and contributors"]
4-
version = "0.1.0"
4+
version = "0.1.1"
55

66
[deps]
77
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
88
startin_jll = "c0017dae-bb0d-5ae0-bc81-a2950b9c605d"
99

1010
[compat]
11-
julia = "1.3"
11+
julia = "1.6"
12+
startin_jll = "0.5.3"
1213

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

src/StarTIN.jl

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module StarTIN
22
using Libdl
33
using startin_jll
4+
# libstartin = joinpath(pwd(), "../startin/target/release/libstartin.dylib")
5+
46

57
struct Star
68
pt::Vector{Float64} # length 3
@@ -29,23 +31,47 @@ end
2931

3032

3133
function Base.insert!(t::DT, points::Matrix{Float64})
32-
w, h = size(points)
34+
w, _ = size(points)
3335
w == 3 || error("Point array should be 3 dimensional, got $w dimensions.")
3436
res = ccall((:insert, libstartin), Cint, (Ptr{Triangulation}, Cint, Ref{Cdouble}), t.ptr, length(points), points)
3537
res == 0 || @warn "$res duplicate points encountered."
3638
res
3739
end
3840

41+
function Base.insert!(t::DT, point::Vector{Float64})
42+
w = length(point)
43+
w == 3 || error("Point array should be 3 dimensional, got $w dimensions.")
44+
res = ccall((:insert_one_pt, libstartin), Cint, (Ptr{Triangulation}, Cdouble, Cdouble, Cdouble), t.ptr, point[1], point[2], point[3])
45+
res == 0 || @warn "Error inserting point."
46+
res
47+
end
48+
49+
function Base.delete!(t::DT, pointid)
50+
res = ccall((:remove, libstartin), Cint, (Ptr{Triangulation}, Cint), t.ptr, pointid)
51+
res == 0 || @warn "$res duplicate points encountered."
52+
res
53+
end
54+
3955
function info(t::DT)
4056
ccall((:debug, libstartin), Cint, (Ptr{Triangulation},), t.ptr)
4157
end
4258

59+
function get_snap_tolerance(t::DT)
60+
ccall((:get_snap_tolerance, libstartin), Cdouble, (Ptr{Triangulation},), t.ptr)
61+
end
62+
function set_snap_tolerance!(t::DT, tol::Float64)
63+
ccall((:set_snap_tolerance, libstartin), Cdouble, (Ptr{Triangulation}, Cdouble), t.ptr, tol)
64+
end
65+
4366
function interpolate_nn(t::DT, x::Float64, y::Float64)
4467
ccall((:interpolate_nn, libstartin), Cdouble, (Ptr{Triangulation}, Cdouble, Cdouble), t.ptr, x, y)
4568
end
4669
function interpolate_linear(t::DT, x::Float64, y::Float64)
4770
ccall((:interpolate_linear, libstartin), Cdouble, (Ptr{Triangulation}, Cdouble, Cdouble), t.ptr, x, y)
4871
end
72+
function interpolate_nni(t::DT, x::Float64, y::Float64)
73+
ccall((:interpolate_nni, libstartin), Cdouble, (Ptr{Triangulation}, Cdouble, Cdouble), t.ptr, x, y)
74+
end
4975
function interpolate_laplace(t::DT, x::Float64, y::Float64)
5076
ccall((:interpolate_laplace, libstartin), Cdouble, (Ptr{Triangulation}, Cdouble, Cdouble), t.ptr, x, y)
5177
end
@@ -60,10 +86,12 @@ function destroy!(t::DT)
6086
end
6187

6288
export DT
63-
export insert!
6489
export interpolate_nn
90+
export interpolate_nni
6591
export interpolate_linear
6692
export interpolate_laplace
93+
export get_snap_tolerance
94+
export set_snap_tolerance!
6795
export write!
6896
export destroy!
6997
export info

test/runtests.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,31 @@ using Test
55
using StarTIN
66

77
t = DT()
8+
9+
# Insert multiple points
810
points = rand(0.0:0.01:100.0, 3, Int(1e5))
911
@test @time insert!(t, points) > 0
1012

13+
# Insert single point
14+
@test @time insert!(t, [50.0, 50.0, 50.0]) > 0
15+
16+
# Insert invalid points
1117
points = rand(4, 100)
1218
@test_throws Exception insert!(t, points)
19+
@test_throws Exception insert!(t, [1.0, 2.0])
20+
21+
# Test removal
22+
pid = insert!(t, [51.0, 51.0, 50.0])
23+
@test delete!(t, pid) == 0
24+
25+
# Test tolerance
26+
@test get_snap_tolerance(t) == 0.001
27+
@test set_snap_tolerance!(t, 0.00001) == 0.00001
1328

29+
# Test interpolation
1430
@test !isnan(interpolate_linear(t, 0.5, 0.5))
1531
@test !isnan(interpolate_nn(t, 0.5, 0.5))
32+
@test !isnan(interpolate_nni(t, 0.5, 0.5))
1633
@test !isnan(interpolate_laplace(t, 0.5, 0.5))
1734

1835
fn = "test.obj"

0 commit comments

Comments
 (0)