Skip to content

Commit

Permalink
Merge pull request #57 from JuliaGeometry/sjk/typestab1
Browse files Browse the repository at this point in the history
WIP: Revisit some type stability improvements
  • Loading branch information
sjkelly authored Jun 10, 2024
2 parents 283a2c4 + f3ab699 commit e25f520
Show file tree
Hide file tree
Showing 18 changed files with 259 additions and 272 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.6'
- '1.10'
#- 'nightly'
os:
- ubuntu-latest
Expand Down
14 changes: 7 additions & 7 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ StaticArrays = "1"
julia = "1.6"

[extras]
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
MeshIO = "7269a6da-0436-5bbc-96c2-40638cbb6118"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
Descartes = "ea4ead7c-22ac-5e77-afc5-cd927cdc0b20"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
HCubature = "19dc6840-f33b-545b-b366-655c7e3ffd49"
MeshIO = "7269a6da-0436-5bbc-96c2-40638cbb6118"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
WGLMakie = "276b4fcb-3e11-5398-bf8b-a0c2d153d008"


[targets]
test = ["Test", "Combinatorics", "StaticArrays", "MeshIO", "FileIO", "WGLMakie", "BenchmarkTools"]
test = ["Test", "Revise", "Combinatorics", "StaticArrays", "MeshIO", "FileIO", "WGLMakie", "BenchmarkTools"]
10 changes: 8 additions & 2 deletions examples/2d.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using Descartes: Circle, Square
using Revise
using Descartes: Circle, Square, LinearExtrude, translate
using GeometryBasics: Mesh

function beam(beam_size = [50,10,10],
function beam(;beam_size = [50,10,10],
hole_ct = 5,
hole_d = 3)

Expand All @@ -17,6 +18,11 @@ function beam(beam_size = [50,10,10],
LinearExtrude(c, beam_size[3])
end

beam(;hole_ct=3)
beam(;hole_ct=5)

@assert typeof(beam(;hole_ct=3)) == typeof(beam(;hole_ct=5))

m = Mesh(beam())

using WGLMakie
Expand Down
81 changes: 76 additions & 5 deletions examples/Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.10.3"
manifest_format = "2.0"
project_hash = "307f054144a276e094fb1ddb88ac6864dbbb8dee"

[[deps.AbstractFFTs]]
deps = ["LinearAlgebra"]
Expand Down Expand Up @@ -68,6 +70,12 @@ version = "0.4.7"
[[deps.Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[deps.BenchmarkTools]]
deps = ["JSON", "Logging", "Printf", "Profile", "Statistics", "UUIDs"]
git-tree-sha1 = "f1dff6729bc61f4d49e140da1af55dcd1ac97b2f"
uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
version = "1.5.0"

[[deps.BitFlags]]
git-tree-sha1 = "2dc09997850d68179b69dafb58ae806167a32b1b"
uuid = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35"
Expand Down Expand Up @@ -121,6 +129,12 @@ weakdeps = ["SparseArrays"]
[deps.ChainRulesCore.extensions]
ChainRulesCoreSparseArraysExt = "SparseArrays"

[[deps.CodeTracking]]
deps = ["InteractiveUtils", "UUIDs"]
git-tree-sha1 = "c0216e792f518b39b22212127d4a84dc31e4e386"
uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
version = "1.3.5"

[[deps.CodecZlib]]
deps = ["TranscodingStreams", "Zlib_jll"]
git-tree-sha1 = "59939d8a997469ee05c4b4944560a820f9ba0d73"
Expand Down Expand Up @@ -161,6 +175,17 @@ git-tree-sha1 = "362a287c3aa50601b0bc359053d5c2468f0e7ce0"
uuid = "5ae59095-9a9b-59fe-a467-6f913c188581"
version = "0.12.11"

[[deps.Combinatorics]]
git-tree-sha1 = "08c8b6831dc00bfea825826be0bc8336fc369860"
uuid = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
version = "1.0.2"

[[deps.CommonSubexpressions]]
deps = ["MacroTools", "Test"]
git-tree-sha1 = "7b8a93dba8af7e3b42fecabf646260105ac373f7"
uuid = "bbf7d656-a473-5ed7-a52c-81e309532950"
version = "0.3.0"

[[deps.Compat]]
deps = ["TOML", "UUIDs"]
git-tree-sha1 = "b1c55339b7c6c350ee89f2c1604299660525b248"
Expand Down Expand Up @@ -242,6 +267,18 @@ path = ".."
uuid = "ea4ead7c-22ac-5e77-afc5-cd927cdc0b20"
version = "0.1.0"

[[deps.DiffResults]]
deps = ["StaticArraysCore"]
git-tree-sha1 = "782dd5f4561f5d267313f23853baaaa4c52ea621"
uuid = "163ba53b-c6d8-5494-b064-1a9d43ac40c5"
version = "1.1.0"

[[deps.DiffRules]]
deps = ["IrrationalConstants", "LogExpFunctions", "NaNMath", "Random", "SpecialFunctions"]
git-tree-sha1 = "23163d55f885173722d1e4cf0f6110cdbaf7e272"
uuid = "b552c78f-8df3-52c6-915a-8e097449b14b"
version = "1.15.1"

[[deps.Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Expand Down Expand Up @@ -381,6 +418,16 @@ git-tree-sha1 = "9c68794ef81b08086aeb32eeaf33531668d5f5fc"
uuid = "1fa38f19-a742-5d3f-a2b9-30dd87b9d5f8"
version = "1.3.7"

[[deps.ForwardDiff]]
deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "LinearAlgebra", "LogExpFunctions", "NaNMath", "Preferences", "Printf", "Random", "SpecialFunctions"]
git-tree-sha1 = "cf0fe81336da9fb90944683b8c41984b08793dad"
uuid = "f6369f11-7733-5829-9624-2563aa707210"
version = "0.10.36"
weakdeps = ["StaticArrays"]

[deps.ForwardDiff.extensions]
ForwardDiffStaticArraysExt = "StaticArrays"

[[deps.FreeType]]
deps = ["CEnum", "FreeType2_jll"]
git-tree-sha1 = "907369da0f8e80728ab49c1c7e09327bf0d6d999"
Expand Down Expand Up @@ -452,6 +499,12 @@ git-tree-sha1 = "53bb909d1151e57e2484c3d1b53e19552b887fb2"
uuid = "42e2da0e-8278-4e71-bc24-59509adca0fe"
version = "1.0.2"

[[deps.HCubature]]
deps = ["Combinatorics", "DataStructures", "LinearAlgebra", "QuadGK", "StaticArrays"]
git-tree-sha1 = "10f37537bbd83e52c63abf6393f209dbd641fedc"
uuid = "19dc6840-f33b-545b-b366-655c7e3ffd49"
version = "1.6.0"

[[deps.HTTP]]
deps = ["Base64", "CodecZlib", "ConcurrentUtilities", "Dates", "ExceptionUnwrapping", "Logging", "LoggingExtras", "MbedTLS", "NetworkOptions", "OpenSSL", "Random", "SimpleBufferStream", "Sockets", "URIs", "UUIDs"]
git-tree-sha1 = "d1d712be3164d61d1fb98e7ce9bcbc6cc06b45ed"
Expand Down Expand Up @@ -547,17 +600,13 @@ deps = ["CRlibm_jll", "MacroTools", "RoundingEmulator"]
git-tree-sha1 = "23ddd329f4a2a65c7a55b91553b60849bd038575"
uuid = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
version = "0.22.11"
weakdeps = ["DiffRules", "ForwardDiff", "RecipesBase"]

[deps.IntervalArithmetic.extensions]
IntervalArithmeticDiffRulesExt = "DiffRules"
IntervalArithmeticForwardDiffExt = "ForwardDiff"
IntervalArithmeticRecipesBaseExt = "RecipesBase"

[deps.IntervalArithmetic.weakdeps]
DiffRules = "b552c78f-8df3-52c6-915a-8e097449b14b"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"

[[deps.IntervalSets]]
git-tree-sha1 = "dba9ddf07f77f60450fe5d2e2beb9854d9a49bd0"
uuid = "8197267c-284f-5f27-9208-e0e47529a953"
Expand Down Expand Up @@ -614,6 +663,12 @@ git-tree-sha1 = "c84a835e1a09b289ffcd2271bf2a337bbdda6637"
uuid = "aacddb02-875f-59d6-b918-886e6ef4fbf8"
version = "3.0.3+0"

[[deps.JuliaInterpreter]]
deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"]
git-tree-sha1 = "e9648d90370e2d0317f9518c9c6e0841db54a90b"
uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
version = "0.9.31"

[[deps.KernelDensity]]
deps = ["Distributions", "DocStringExtensions", "FFTW", "Interpolations", "StatsBase"]
git-tree-sha1 = "7d703202e65efa1369de1279c162b915e245eed1"
Expand Down Expand Up @@ -744,6 +799,12 @@ git-tree-sha1 = "c1dd6d7978c12545b4179fb6153b9250c96b0075"
uuid = "e6f89c97-d47a-5376-807f-9c37f3926c36"
version = "1.0.3"

[[deps.LoweredCodeUtils]]
deps = ["JuliaInterpreter"]
git-tree-sha1 = "c6a36b22d2cca0e1a903f00f600991f97bf5f426"
uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b"
version = "2.4.6"

[[deps.MKL_jll]]
deps = ["Artifacts", "IntelOpenMP_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "oneTBB_jll"]
git-tree-sha1 = "80b2833b56d466b3858d565adcd16a4a05f2089b"
Expand Down Expand Up @@ -991,6 +1052,10 @@ version = "1.4.3"
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[deps.Profile]]
deps = ["Printf"]
uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"

[[deps.ProgressMeter]]
deps = ["Distributed", "Printf"]
git-tree-sha1 = "763a8ceb07833dd51bb9e3bbca372de32c0605ad"
Expand Down Expand Up @@ -1072,6 +1137,12 @@ git-tree-sha1 = "838a3a4188e2ded87a4f9f184b4b0d78a1e91cb7"
uuid = "ae029012-a4dd-5104-9daa-d747884805df"
version = "1.3.0"

[[deps.Revise]]
deps = ["CodeTracking", "Distributed", "FileWatching", "JuliaInterpreter", "LibGit2", "LoweredCodeUtils", "OrderedCollections", "Pkg", "REPL", "Requires", "UUIDs", "Unicode"]
git-tree-sha1 = "12aa2d7593df490c407a3bbd8b86b8b515017f3e"
uuid = "295af30f-e4ad-537b-8983-00126c2a3abe"
version = "3.5.14"

[[deps.Rmath]]
deps = ["Random", "Rmath_jll"]
git-tree-sha1 = "f65dcb5fa46aee0cf9ed6274ccbd597adc49aa7b"
Expand Down
6 changes: 6 additions & 0 deletions examples/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Descartes = "ea4ead7c-22ac-5e77-afc5-cd927cdc0b20"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
HCubature = "19dc6840-f33b-545b-b366-655c7e3ffd49"
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
WGLMakie = "276b4fcb-3e11-5398-bf8b-a0c2d153d008"
8 changes: 4 additions & 4 deletions examples/csg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ translate([24,0,0]) {
"""


using Descartes
using Descartes: Cuboid, Sphere
using GeometryBasics

a = translate([-24,0,0])union(
Cuboid([15,15,15], center=true),
Descartes.Sphere(10))
Sphere(10))

b = intersect(
Cuboid([15,15,15], center=true),
Descartes.Sphere(10))
Sphere(10))

c = translate([24,0,0])diff(
Cuboid([15,15,15], center=true),
Descartes.Sphere(10))
Sphere(10))

m = Mesh(a,b,c)
@show typeof(m)
Expand Down
5 changes: 4 additions & 1 deletion examples/piping.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Descartes
using Descartes: Piping
using GeometryBasics: Mesh

p = Piping(1.0, [[0,0,0],
Expand All @@ -9,6 +9,9 @@ p = Piping(1.0, [[0,0,0],

m = Mesh(p)

using WGLMakie
mesh(m)

#Descartes.visualize(m)

#save("piping.ply", m)
3 changes: 3 additions & 0 deletions examples/radiused_union.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ m = Mesh(u2)
#Descartes.visualize(u2)

save("radiused_union.ply",m)

using WGLMakie
mesh(m)
19 changes: 19 additions & 0 deletions examples/triangle_wave.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Revise
using Descartes: Descartes, TriangleWave, FRep, Grid
using WGLMakie

t = TriangleWave(2.)

x = 1:0.1:10
y = [FRep(t, e) for e in x]

lines(x,y)

g = Grid(1.0)

x_vals = 1:0.1:10
y_vals = 1:0.1:10

z = [FRep(g, (x, y)) for x in x_vals, y in y_vals]
heatmap(x_vals, y_vals, z, alpha=0.6)

19 changes: 1 addition & 18 deletions src/Descartes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,11 @@ using StaticArrays,
Rotations

include("types.jl")
include("utils.jl")
include("constructors.jl")
include("operations.jl")
include("frep.jl")
include("hyperrectangles.jl")
include("meshes.jl")

# 3d primitives
export Cuboid, Cylinder, Sphere, Piping

# 2d primitives
export Square, Circle

# transforms
export translate, rotate

# operations
export Shell, LinearExtrude

# CSG
export CSGUnion, RadiusedCSGUnion, CSGDiff, CSGIntersect

# frep
export FRep

end # module
Loading

0 comments on commit e25f520

Please sign in to comment.