-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First example to actually use smesh (#3)
* First example to actualy use smesh * Try to build smesh in CI * Build on more platforms * Fix path * Fix another path * Fix more paths * Where is the dll? * Final try * Escape backslaches * Need. More. ESCAPE CHARACTERS. Grrrrrrr * Build docs again * Fix path * Fix coverage * Add usage information
- Loading branch information
Showing
9 changed files
with
194 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
Manifest.toml | ||
LocalPreferences.toml | ||
run/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Smesh | ||
|
||
# Create data points | ||
# Note: the transpose + collect is just such that we can write the matrix in human readable | ||
# form here | ||
data_points = collect([0.0 0.0 | ||
1.0 0.0 | ||
1.0 1.0 | ||
0.0 1.0]') | ||
|
||
# Create triangulation | ||
ve = build_delaunay_triangulation(data_points; verbose = true) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,49 @@ | ||
module Smesh | ||
|
||
""" | ||
greet() | ||
using Preferences: @load_preference, @has_preference | ||
|
||
export build_delaunay_triangulation | ||
|
||
if !@has_preference("libsmesh") | ||
error(""" | ||
Missing preference `libsmesh` for package Smesh.jl. Please add a | ||
`LocalPreferences.toml` file to your current Julia project with the following | ||
content, where `path/to/libsmesh.{ext}` is the path to your local build of | ||
libsmesh and `{ext}` is the appropriate extension for shared libraries on your | ||
system (e.g., `so` on Linux, `dylib` on macOS, `dll` on Windows). Afterwards, | ||
you need to restart Julia. | ||
Content of `LocalPreferences.toml` (between the '```' marks): | ||
``` | ||
[Smesh] | ||
libsmesh = "path/to/libsmesh.{ext}" | ||
``` | ||
""") | ||
end | ||
const libsmesh = @load_preference("libsmesh") | ||
|
||
Say hello to the world. | ||
|
||
""" | ||
""" | ||
greet() = print("Hello World!") | ||
function build_delaunay_triangulation(data_points; shuffle = false, verbose = false) | ||
# Pre-allocate output array | ||
npoints = size(data_points, 2) | ||
ve_max = @ccall libsmesh.delaunay_triangulation_temparray_size_c(npoints::Cint)::Cint | ||
ve_internal = Matrix{Cint}(undef, 3, ve_max) | ||
|
||
# Perform triangulation | ||
ntriangles = @ccall libsmesh.build_delaunay_triangulation_c(ve_internal::Ref{Cint}, | ||
data_points::Ref{Float64}, | ||
npoints::Cint, | ||
ve_max::Cint, | ||
shuffle::Cint, | ||
verbose::Cint)::Cint | ||
|
||
# Copy to array of appropriate size and convert to Julia `Int`s for convenience | ||
ve_out = convert(Matrix{Int}, ve_internal[:, 1:ntriangles]) | ||
|
||
return ve_out | ||
end | ||
|
||
end # module Smesh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters