Skip to content

Commit

Permalink
PR for unreleased version. (#2)
Browse files Browse the repository at this point in the history
* PR for unreleased version.
* Update versions.
  • Loading branch information
evetion authored Dec 24, 2021
1 parent 3cdffe8 commit c641c59
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 81 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
fail-fast: false
matrix:
version:
- "1.3"
- "1.5"
- "1.6"
- "1.7"
- "nightly"
os:
- ubuntu-latest
Expand Down
75 changes: 0 additions & 75 deletions Manifest.toml

This file was deleted.

5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
name = "StarTIN"
uuid = "152385ed-0447-47b3-b417-bbbf3d580ece"
authors = ["Maarten Pronk <[email protected]> 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"
Expand Down
32 changes: 30 additions & 2 deletions src/StarTIN.jl
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
17 changes: 17 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

2 comments on commit c641c59

@evetion
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/51188

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.1 -m "<description of version>" c641c596311a5c38ebefc81c2271c2181b82a421
git push origin v0.1.1

Please sign in to comment.