Skip to content

Commit

Permalink
Merge branch 'COMODO-research:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jbytecode authored Feb 29, 2024
2 parents e71a37f + 8d56c60 commit 31a9066
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 24 deletions.
13 changes: 12 additions & 1 deletion Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.10.1"
manifest_format = "2.0"
project_hash = "d4eb882a44fc91c1fbf111dd9aa6f52b208dd65c"
project_hash = "605ab7cd5a06e8048cf84924cbec19c5085ec0ef"

[[deps.AbstractFFTs]]
deps = ["LinearAlgebra"]
Expand Down Expand Up @@ -308,6 +308,17 @@ git-tree-sha1 = "23163d55f885173722d1e4cf0f6110cdbaf7e272"
uuid = "b552c78f-8df3-52c6-915a-8e097449b14b"
version = "1.15.1"

[[deps.Distances]]
deps = ["LinearAlgebra", "Statistics", "StatsAPI"]
git-tree-sha1 = "66c4c81f259586e8f002eacebc177e1fb06363b0"
uuid = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
version = "0.10.11"
weakdeps = ["ChainRulesCore", "SparseArrays"]

[deps.Distances.extensions]
DistancesChainRulesCoreExt = "ChainRulesCore"
DistancesSparseArraysExt = "SparseArrays"

[[deps.Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Expand Down
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ version = "0.1.0"
[deps]
BSplineKit = "093aae92-e908-43d7-9660-e50ee39d5a0a"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
FEBio = "c57eab10-e7d7-41f3-9039-a27761009b26"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache-blue.svg)](https://github.com/COMODO-research/Comodo.jl/blob/main/LICENSE)
[![example workflow](https://github.com/COMODO-research/Comodo.jl/actions/workflows/test.yml/badge.svg)](https://github.com/COMODO-research/Comodo.jl/blob/main/.github/workflows/test.yml)
[![Join the chat at https://gitter.im/Comodo.jl](https://badges.gitter.im/Comodo.jl.svg)](https://app.gitter.im/#/room/#comodo:gitter.im?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![](assets/img/COMODO.png)
[![Mastodon](https://img.shields.io/badge/-MASTODON-%232B90D9?style=for-the-badge&logo=mastodon&logoColor=white)](https://fosstodon.org/@kevinmoerman)




# About Comodo
Comodo is a [Julia](https://julialang.org/) package **computational (bio)mechanics and computational design**, and offers functionality for geometry processing, meshing, finite element analysis, automated design, topology optimisation, and image-based modelling.

Expand Down
Binary file added assets/img/COMODO_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions examples/demo_dist.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ the minimum distances are visualised on the mesh.

# Defining icosahedron
r = 1 # radius of icosahedron
n = 1 # Number of refinement steps
n = 3 # Number of refinement steps

# Define an icosahedron
M = platonicsolid(4,r) # GeometryBasics mesh description of icosahedron
Expand All @@ -20,7 +20,7 @@ F = faces(M) # Get the mesh faces

# Created refined version
Fn,Vn = subtri(F,V,n) # Subdevide/refine the mesh linearly

F,V = subtri(F,V,2)
# Use distND to compute distances from all in set 1 to all in set 2
DD = dist(Vn,V)

Expand Down
44 changes: 25 additions & 19 deletions examples/demo_mindist.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,42 @@ using GeometryBasics # For point and mesh format
using GLMakie

#=
This demo shows the use of distND to compute distances for ND points. A 3D
point set is defined on an icosahedron. Next a refined (using subtri) version is
created and the distance from the refined to the unrefined are computed. Next
the minimum distances are visualised on the mesh.
This demo shows the use of dist to compute distances for ND points. A 3D
point set is defined on an geodesic sphere. Next another, more refined version
is created, and the distance from this sphere to the coarser one is computed.
Next the minimum distances are visualised on the mesh.
=#

# Defining icosahedron
r = 1 # radius of icosahedron
n = 3 # Number of refinement steps
n = 5 # Number of refinement steps

# Define an icosahedron
M = platonicsolid(4,r) # GeometryBasics mesh description of icosahedron
V = coordinates(M) # Get the mesh coordinates
F = faces(M) # Get the mesh faces
# Define a mesh
F,V = geosphere(1,r)

# Created refined version
Fn,Vn = subtri(F,V,n) # Subdevide/refine the mesh linearly
# Define a mesh
Fn,Vn = geosphere(n,r) # Subdevide/refine the mesh linearly

# Compute nearest point distances
Dn = mindist(Vn,V; getIndex = false)
Dn,indMin = mindist(Vn,V; getIndex = true)

# Visualization
fig = Figure(size = (800,800))
fig = Figure(size = (1200,500))

ax=Axis3(fig[1, 1], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z")
ax1=Axis3(fig[1, 1], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z")

hp = poly!(ax,GeometryBasics.Mesh(Vn,Fn),strokewidth=0,color=Dn, shading=FastShading, overdraw=false)
hs1 = scatter!(ax, V,markersize=35,color=:black)
hs2 = scatter!(ax, Vn,markersize=15,color=Dn,strokewidth=1)
hp1 = poly!(ax1,GeometryBasics.Mesh(Vn,Fn),strokewidth=0,color=Dn,shading=FastShading, overdraw=false)
hs1 = scatter!(ax1, V,markersize=35,color=:black)

Colorbar(fig[1, 2], hp1,label="Distance")
Legend(fig[1, 3],[hp1,hs1],["Distances on mesh","Point set"])

ax2=Axis3(fig[1, 4], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z")

hp2 = poly!(ax2,GeometryBasics.Mesh(Vn,Fn),strokewidth=0,color=indMin,shading=FastShading, overdraw=false)
hs2 = scatter!(ax2, V,markersize=35,color=:black)

Colorbar(fig[1, 5], hp2,label="Nearest point index")
Legend(fig[1, 6],[hp2,hs2],["Point indices","Point set"])

Colorbar(fig[1, 2], hs2,label="Distance")
Legend(fig[1, 3],[hp,hs1],["Distances on mesh","Point set"])
fig
2 changes: 2 additions & 0 deletions src/Comodo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import Statistics
import SparseArrays
import GLMakie
import Rotations
import BSplineKit
import Distances

include("functions.jl")

Expand Down
6 changes: 4 additions & 2 deletions src/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ using Statistics # For: mean
using GLMakie # For slidercontrol
using SparseArrays # For meshconnectivity
using Rotations
using BSplineKit
using Distances

function comododir()
joinpath(@__DIR__, "..")
Expand Down Expand Up @@ -206,7 +208,7 @@ function dist(V1,V2)
D = Matrix{Float64}(undef,length(V1),length(V2))
for i eachindex(V1)
for j eachindex(V2)
D[i,j] = norm((V1[i].-V2[j]))
D[i,j] = euclidean(V1[i],V2[j]) # norm(V1[i]-V2[j])
end
end
return D
Expand All @@ -223,7 +225,7 @@ function mindist(V1,V2; getIndex=false, skipSelf = false )
if skipSelf && i==j
d[j] = Inf
else
d[j] = sqrt(sum((V1[i].-V2[j]).^2))
d[j] = euclidean(V1[i],V2[j]) # norm(V1[i]-V2[j])
end
end
if getIndex
Expand Down

0 comments on commit 31a9066

Please sign in to comment.