diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e29399a..f5ae947 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,8 +10,8 @@ jobs: fail-fast: false matrix: version: - - "1.3" - - "1.5" + - "1.6" + - "1.7" - "nightly" os: - ubuntu-latest diff --git a/Manifest.toml b/Manifest.toml deleted file mode 100644 index 2d0d10a..0000000 --- a/Manifest.toml +++ /dev/null @@ -1,75 +0,0 @@ -# This file is machine-generated - editing it directly is not advised - -[[Artifacts]] -deps = ["Pkg"] -git-tree-sha1 = "c30985d8821e0cd73870b17b0ed0ce6dc44cb744" -uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" -version = "1.3.0" - -[[Base64]] -uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" - -[[Dates]] -deps = ["Printf"] -uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" - -[[InteractiveUtils]] -deps = ["Markdown"] -uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" - -[[JLLWrappers]] -git-tree-sha1 = "a431f5f2ca3f4feef3bd7a5e94b8b8d4f2f647a0" -uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" -version = "1.2.0" - -[[LibGit2]] -deps = ["Printf"] -uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" - -[[Libdl]] -uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" - -[[Logging]] -uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" - -[[Markdown]] -deps = ["Base64"] -uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" - -[[Pkg]] -deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] -uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" - -[[Printf]] -deps = ["Unicode"] -uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" - -[[REPL]] -deps = ["InteractiveUtils", "Markdown", "Sockets"] -uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" - -[[Random]] -deps = ["Serialization"] -uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" - -[[SHA]] -uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" - -[[Serialization]] -uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" - -[[Sockets]] -uuid = "6462fe0b-24de-5631-8697-dd941f90decc" - -[[UUIDs]] -deps = ["Random", "SHA"] -uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" - -[[Unicode]] -uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" - -[[startin_jll]] -deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] -git-tree-sha1 = "76ff5d74b8b3e7006c8d92af60616d88488b12f6" -uuid = "c0017dae-bb0d-5ae0-bc81-a2950b9c605d" -version = "0.4.9+0" diff --git a/Project.toml b/Project.toml index cec2817..509ccf7 100644 --- a/Project.toml +++ b/Project.toml @@ -1,14 +1,15 @@ name = "StarTIN" uuid = "152385ed-0447-47b3-b417-bbbf3d580ece" authors = ["Maarten Pronk and contributors"] -version = "0.1.0" +version = "0.1.1" [deps] Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" startin_jll = "c0017dae-bb0d-5ae0-bc81-a2950b9c605d" [compat] -julia = "1.3" +julia = "1.6" +startin_jll = "0.5.3" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/src/StarTIN.jl b/src/StarTIN.jl index 18b4abc..c526836 100644 --- a/src/StarTIN.jl +++ b/src/StarTIN.jl @@ -1,6 +1,8 @@ module StarTIN using Libdl using startin_jll +# libstartin = joinpath(pwd(), "../startin/target/release/libstartin.dylib") + struct Star pt::Vector{Float64} # length 3 @@ -29,23 +31,47 @@ end function Base.insert!(t::DT, points::Matrix{Float64}) - w, h = size(points) + w, _ = size(points) w == 3 || error("Point array should be 3 dimensional, got $w dimensions.") res = ccall((:insert, libstartin), Cint, (Ptr{Triangulation}, Cint, Ref{Cdouble}), t.ptr, length(points), points) res == 0 || @warn "$res duplicate points encountered." res end +function Base.insert!(t::DT, point::Vector{Float64}) + w = length(point) + w == 3 || error("Point array should be 3 dimensional, got $w dimensions.") + res = ccall((:insert_one_pt, libstartin), Cint, (Ptr{Triangulation}, Cdouble, Cdouble, Cdouble), t.ptr, point[1], point[2], point[3]) + res == 0 || @warn "Error inserting point." + res +end + +function Base.delete!(t::DT, pointid) + res = ccall((:remove, libstartin), Cint, (Ptr{Triangulation}, Cint), t.ptr, pointid) + res == 0 || @warn "$res duplicate points encountered." + res +end + function info(t::DT) ccall((:debug, libstartin), Cint, (Ptr{Triangulation},), t.ptr) end +function get_snap_tolerance(t::DT) + ccall((:get_snap_tolerance, libstartin), Cdouble, (Ptr{Triangulation},), t.ptr) +end +function set_snap_tolerance!(t::DT, tol::Float64) + ccall((:set_snap_tolerance, libstartin), Cdouble, (Ptr{Triangulation}, Cdouble), t.ptr, tol) +end + function interpolate_nn(t::DT, x::Float64, y::Float64) ccall((:interpolate_nn, libstartin), Cdouble, (Ptr{Triangulation}, Cdouble, Cdouble), t.ptr, x, y) end function interpolate_linear(t::DT, x::Float64, y::Float64) ccall((:interpolate_linear, libstartin), Cdouble, (Ptr{Triangulation}, Cdouble, Cdouble), t.ptr, x, y) end +function interpolate_nni(t::DT, x::Float64, y::Float64) + ccall((:interpolate_nni, libstartin), Cdouble, (Ptr{Triangulation}, Cdouble, Cdouble), t.ptr, x, y) +end function interpolate_laplace(t::DT, x::Float64, y::Float64) ccall((:interpolate_laplace, libstartin), Cdouble, (Ptr{Triangulation}, Cdouble, Cdouble), t.ptr, x, y) end @@ -60,10 +86,12 @@ function destroy!(t::DT) end export DT -export insert! export interpolate_nn +export interpolate_nni export interpolate_linear export interpolate_laplace +export get_snap_tolerance +export set_snap_tolerance! export write! export destroy! export info diff --git a/test/runtests.jl b/test/runtests.jl index 380386e..6c02ebd 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,14 +5,31 @@ using Test using StarTIN t = DT() + + # Insert multiple points points = rand(0.0:0.01:100.0, 3, Int(1e5)) @test @time insert!(t, points) > 0 + # Insert single point + @test @time insert!(t, [50.0, 50.0, 50.0]) > 0 + + # Insert invalid points points = rand(4, 100) @test_throws Exception insert!(t, points) + @test_throws Exception insert!(t, [1.0, 2.0]) + + # Test removal + pid = insert!(t, [51.0, 51.0, 50.0]) + @test delete!(t, pid) == 0 + + # Test tolerance + @test get_snap_tolerance(t) == 0.001 + @test set_snap_tolerance!(t, 0.00001) == 0.00001 + # Test interpolation @test !isnan(interpolate_linear(t, 0.5, 0.5)) @test !isnan(interpolate_nn(t, 0.5, 0.5)) + @test !isnan(interpolate_nni(t, 0.5, 0.5)) @test !isnan(interpolate_laplace(t, 0.5, 0.5)) fn = "test.obj"