diff --git a/Project.toml b/Project.toml index 3efc26d..82d328c 100644 --- a/Project.toml +++ b/Project.toml @@ -14,14 +14,14 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" [compat] Aqua = "0.8" -CoordinateTransformations = "0.6" Combinatorics = "1" +CoordinateTransformations = "0.6" FileIO = "1" ForwardDiff = "0.10" GeometryBasics = "0.4" LinearAlgebra = "1" -Meshing = "0.5" MeshIO = "0.4" +Meshing = "0.7" Revise = "3" Rotations = "1" StaticArrays = "1" diff --git a/docs/make.jl b/docs/make.jl index 0dc9767..2d379e5 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -4,7 +4,7 @@ using Descartes makedocs( sitename = "Descartes", format = Documenter.HTML(), - modules = [Descartes], + #modules = [Descartes], authors = "Steve Kelly", pages = ["Primitives" => "primitives.md", "Design" => "design.md"] diff --git a/docs/src/design.md b/docs/src/design.md index b940f1d..637f83d 100644 --- a/docs/src/design.md +++ b/docs/src/design.md @@ -2,18 +2,17 @@ Descartes current uses implicit modeling to create solid models. This is a brief overview of the system internals. - ## Implicit Geometry Pipeline +## API -## UX - -The UX (API) is designed to be familiar to those who use OpenSCAD. Let's start with a simple example to show the similarities. +The API is designed to be familiar to those who use OpenSCAD. Let's start with a simple example to show the similarities. This can all be executed in the Julia REPL, so follow along: ```julia using Descartes +using GeometryBasics c = Cuboid([5,5,5]) @@ -21,7 +20,7 @@ h = translate([2.5,2.5,0])Cylinder(1,5) obj = diff(c,h) -m = HomogenousMesh(obj) +m = GeometryBasics.Mesh(obj) save("cube_with_hole.stl", m) ``` @@ -53,7 +52,7 @@ obj = diff(c,h) Here we difference the cylinder from the cube. The corresponding set operations are `union` and `intersect`. ```julia -m = HomogenousMesh(obj) +m = GeometryBasics.Mesh(obj) ``` At this point we convert our object to a mesh. Prior to this point the model is simply a data structure. In the next section we will discuss the process of meshign more in-depth. @@ -64,42 +63,10 @@ save("cube_with_hole.stl", m) Finally we save the mesh as an STL. Other formats such as OBJ, PLY, and OFF are also supported. - ## Meshing In the prior section we mentioned that the "model" we create is just a data structure until we mesh it. So let's explore what happens in the meshing process. -The code to convert our data structure to a mesh is actually fairly short: - -[Current version](https://github.com/sjkelly/Descartes.jl/blob/master/src/meshes.jl) - - -```julia -function (::Type{MT})(primitives::AbstractPrimitive{3, T}...; - samples=(128,128,128), - algorithm=MarchingCubes() - ) where {T, MT <: AbstractMesh} - - f(x) = FRep(primitives[1], x) - mesh = MT(f, HyperRectangle(primitives[1]), samples, algorithm) - - for i = 2:length(primitives) - b = HyperRectangle(primitives[i]) - lm = MT(x -> FRep(primitives[i], x), b, samples, algorithm) - mesh = merge(mesh, lm) - end - - return mesh -end -``` - -The first two lines here are where the meshing happens: - -```julia - f(x) = FRep(primitives[1], x) - mesh = MT(f, HyperRectangle(primitives[1]), samples, algorithm) -``` - Any primitve or operation must implement two core operations; `FRep` and `HyperRectangle`. `FRep` is the functional representation (implicit representation) of the model. The first argument to `FRep` is always the primitive. The second is a generic `AbstractVector`. In julia we have type inference, so we do not need to annotate, so this will always be fast. FRep by convention must use 0 as the surface of the model, positive outside the model, and negative inside. @@ -107,5 +74,3 @@ Any primitve or operation must implement two core operations; `FRep` and `HyperR `HyperRectangle` should return the extents of the primitive. The underlying API will handle transformations and basic set operations for us. In the next line we actually perform the meshing operation. We call the meshtype with the implicit function we created, `f`, in the bounds generated by `HyperRectangle`, uniformly sample the space by `samples`, and actually generate the triangular meshing using `algorithm`. In this case, the defaults are `samples=(128,128,128)` and `algorithm=MarchingCubes()`. - -In the loop `for i = 2:length(primitives) ... end` we handle additional primitives passed to our meshing function so you can create a single mesh output from several different objects. In order to maintain performance and resolution these are not `union`ed. diff --git a/examples/Manifest.toml b/examples/Manifest.toml index d8cb611..549298c 100644 --- a/examples/Manifest.toml +++ b/examples/Manifest.toml @@ -2,12 +2,12 @@ julia_version = "1.10.4" manifest_format = "2.0" -project_hash = "45f0ef80ca12ef806f32247cd0d5651dd69dc4de" +project_hash = "5711fc8d77eed703586d928736ce229a69d0c5a2" [[deps.ADTypes]] -git-tree-sha1 = "fa0822e5baee6e23081c2685ae27265dabee23d8" +git-tree-sha1 = "ae44a0c3d68a420d4ac0fa1f7e0c034ccecb6dc5" uuid = "47edcb42-4c32-4615-8424-f2b9edc5f35b" -version = "1.4.0" +version = "1.5.2" [deps.ADTypes.extensions] ADTypesChainRulesCoreExt = "ChainRulesCore" @@ -139,14 +139,14 @@ uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" version = "1.5.0" [[deps.Bijections]] -git-tree-sha1 = "c9b163bd832e023571e86d0b90d9de92a9879088" +git-tree-sha1 = "95f5c7e2d177b7ba1a240b0518038b975d72a8c0" uuid = "e2ed5e7c-b2de-5872-ae92-c73ca462fb04" -version = "0.1.6" +version = "0.1.7" [[deps.BitFlags]] -git-tree-sha1 = "2dc09997850d68179b69dafb58ae806167a32b1b" +git-tree-sha1 = "0691e34b3bb8be9307330f88d1a3c3f25466c24d" uuid = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35" -version = "0.1.8" +version = "0.1.9" [[deps.Bonito]] deps = ["Base64", "CodecZlib", "Colors", "Dates", "Deno_jll", "HTTP", "Hyperscript", "LinearAlgebra", "Markdown", "MsgPack", "Observables", "RelocatableFolders", "SHA", "Sockets", "Tables", "ThreadPools", "URIs", "UUIDs", "WidgetsBase"] @@ -258,6 +258,11 @@ git-tree-sha1 = "7b8a93dba8af7e3b42fecabf646260105ac373f7" uuid = "bbf7d656-a473-5ed7-a52c-81e309532950" version = "0.3.0" +[[deps.CommonWorldInvalidations]] +git-tree-sha1 = "ae52d1c52048455e85a387fbee9be553ec2b68d0" +uuid = "f70d9fcc-98c5-4d4a-abd7-e4cdeebd8ca8" +version = "1.0.0" + [[deps.Compat]] deps = ["TOML", "UUIDs"] git-tree-sha1 = "b1c55339b7c6c350ee89f2c1604299660525b248" @@ -582,9 +587,9 @@ version = "0.1.6" [[deps.GeoInterface]] deps = ["Extents"] -git-tree-sha1 = "801aef8228f7f04972e596b09d4dba481807c913" +git-tree-sha1 = "9fff8990361d5127b770e3454488360443019bb3" uuid = "cf35fbd7-0cd7-5166-be24-54bfbe79505f" -version = "1.3.4" +version = "1.3.5" [[deps.GeometryBasics]] deps = ["EarCut_jll", "Extents", "GeoInterface", "IterTools", "LinearAlgebra", "StaticArrays", "StructArrays", "Tables"] @@ -592,12 +597,6 @@ git-tree-sha1 = "b62f2b2d76cee0d61a2ef2b3118cd2a3215d3134" uuid = "5c1252a2-5f33-56bf-86c9-59e7332b4326" version = "0.4.11" -[[deps.GeometryTypes]] -deps = ["ColorTypes", "FixedPointNumbers", "LinearAlgebra", "StaticArrays"] -git-tree-sha1 = "d796f7be0383b5416cd403420ce0af083b0f9b28" -uuid = "4d00f742-c7ba-57c2-abde-4428a4b178cb" -version = "0.8.5" - [[deps.Gettext_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Libiconv_jll", "Pkg", "XML2_jll"] git-tree-sha1 = "9b02998aba7bf074d14de89f9d37ca24a1a0b046" @@ -1024,10 +1023,9 @@ uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" version = "2.28.2+1" [[deps.Meshing]] -deps = ["GeometryBasics", "GeometryTypes", "StaticArrays"] -git-tree-sha1 = "b32d34f3e3ca44391ca7261ca4eb96af71e022b9" +path = "/Users/sjkelly/.julia/dev/Meshing" uuid = "e6723b4c-ebff-59f1-b4b7-d97aa5274f73" -version = "0.5.7" +version = "0.7.0" [[deps.Missings]] deps = ["DataAPI"] @@ -1435,9 +1433,9 @@ version = "0.3.8" [[deps.SciMLStructures]] deps = ["ArrayInterface"] -git-tree-sha1 = "6ab4beaf88dcdd2639bead916f2347f81dcacd0e" +git-tree-sha1 = "cfdd1200d150df1d3c055cc72ee6850742e982d7" uuid = "53ae85a6-f571-4167-b2af-e1d143709226" -version = "1.3.0" +version = "1.4.1" [[deps.Scratch]] deps = ["Dates"] @@ -1525,9 +1523,9 @@ version = "0.1.1" [[deps.StaticArrays]] deps = ["LinearAlgebra", "PrecompileTools", "Random", "StaticArraysCore"] -git-tree-sha1 = "6e00379a24597be4ae1ee6b2d882e15392040132" +git-tree-sha1 = "20833c5b7f7edf0e5026f23db7f268e4f23ec577" uuid = "90137ffa-7385-5640-81b9-e52037218182" -version = "1.9.5" +version = "1.9.6" weakdeps = ["ChainRulesCore", "Statistics"] [deps.StaticArrays.extensions] @@ -1603,15 +1601,15 @@ version = "0.2.1" [[deps.SymbolicUtils]] deps = ["AbstractTrees", "Bijections", "ChainRulesCore", "Combinatorics", "ConstructionBase", "DataStructures", "DocStringExtensions", "DynamicPolynomials", "IfElse", "LabelledArrays", "LinearAlgebra", "MultivariatePolynomials", "NaNMath", "Setfield", "SparseArrays", "SpecialFunctions", "StaticArrays", "SymbolicIndexingInterface", "TermInterface", "TimerOutputs", "Unityper"] -git-tree-sha1 = "79813de27af70906d223fbd89ad90dba3d88a2b0" +git-tree-sha1 = "cc049913a449be8c7ac00979831f26891e01add2" uuid = "d1185830-fcd6-423d-90d6-eec64667417b" -version = "2.0.2" +version = "2.1.0" [[deps.Symbolics]] -deps = ["ADTypes", "ArrayInterface", "Bijections", "ConstructionBase", "DataStructures", "DiffRules", "Distributions", "DocStringExtensions", "DomainSets", "DynamicPolynomials", "ForwardDiff", "IfElse", "LaTeXStrings", "LambertW", "Latexify", "Libdl", "LinearAlgebra", "LogExpFunctions", "MacroTools", "Markdown", "NaNMath", "PrecompileTools", "RecipesBase", "Reexport", "Requires", "RuntimeGeneratedFunctions", "SciMLBase", "Setfield", "SparseArrays", "SpecialFunctions", "StaticArrays", "SymbolicIndexingInterface", "SymbolicLimits", "SymbolicUtils", "TermInterface"] -git-tree-sha1 = "3669f8eba2720c595e16b038f33cb880c12ef7f7" +deps = ["ADTypes", "ArrayInterface", "Bijections", "CommonWorldInvalidations", "ConstructionBase", "DataStructures", "DiffRules", "Distributions", "DocStringExtensions", "DomainSets", "DynamicPolynomials", "ForwardDiff", "IfElse", "LaTeXStrings", "LambertW", "Latexify", "Libdl", "LinearAlgebra", "LogExpFunctions", "MacroTools", "Markdown", "NaNMath", "PrecompileTools", "RecipesBase", "Reexport", "Requires", "RuntimeGeneratedFunctions", "SciMLBase", "Setfield", "SparseArrays", "SpecialFunctions", "StaticArraysCore", "SymbolicIndexingInterface", "SymbolicLimits", "SymbolicUtils", "TermInterface"] +git-tree-sha1 = "8539a734b448ca27707709c62420b1bf115ed7d9" uuid = "0c5d862f-8b57-4792-8d23-62f2024744c7" -version = "5.30.3" +version = "5.33.0" [deps.Symbolics.extensions] SymbolicsGroebnerExt = "Groebner" @@ -1681,9 +1679,9 @@ uuid = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f" version = "0.5.24" [[deps.TranscodingStreams]] -git-tree-sha1 = "a947ea21087caba0a798c5e494d0bb78e3a1a3a0" +git-tree-sha1 = "d73336d81cafdc277ff45558bb7eaa2b04a8e472" uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" -version = "0.10.9" +version = "0.10.10" weakdeps = ["Random", "Test"] [deps.TranscodingStreams.extensions] @@ -1749,15 +1747,15 @@ version = "1.0.0" [[deps.XML2_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Libiconv_jll", "Zlib_jll"] -git-tree-sha1 = "52ff2af32e591541550bd753c0da8b9bc92bb9d9" +git-tree-sha1 = "d9717ce3518dc68a99e6b96300813760d887a01d" uuid = "02c8fc9c-b97f-50b9-bbe4-9be30ff0a78a" -version = "2.12.7+0" +version = "2.13.1+0" [[deps.XSLT_jll]] -deps = ["Artifacts", "JLLWrappers", "Libdl", "Libgcrypt_jll", "Libgpg_error_jll", "Libiconv_jll", "Pkg", "XML2_jll", "Zlib_jll"] -git-tree-sha1 = "91844873c4085240b95e795f692c4cec4d805f8a" +deps = ["Artifacts", "JLLWrappers", "Libdl", "Libgcrypt_jll", "Libgpg_error_jll", "Libiconv_jll", "XML2_jll", "Zlib_jll"] +git-tree-sha1 = "a54ee957f4c86b526460a720dbc882fa5edcbefc" uuid = "aed1982a-8fda-507f-9586-7b0439959a61" -version = "1.1.34+0" +version = "1.1.41+0" [[deps.Xorg_libX11_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Xorg_libxcb_jll", "Xorg_xtrans_jll"] @@ -1797,9 +1795,9 @@ version = "0.1.1+0" [[deps.Xorg_libxcb_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "XSLT_jll", "Xorg_libXau_jll", "Xorg_libXdmcp_jll", "Xorg_libpthread_stubs_jll"] -git-tree-sha1 = "b4bfde5d5b652e22b9c790ad00af08b6d042b97d" +git-tree-sha1 = "bcd466676fef0878338c61e655629fa7bbc69d8e" uuid = "c7cfdc94-dc32-55de-ac96-5a1b8d977c5b" -version = "1.15.0+0" +version = "1.17.0+0" [[deps.Xorg_xtrans_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] diff --git a/examples/Project.toml b/examples/Project.toml index f90ca43..19947fa 100644 --- a/examples/Project.toml +++ b/examples/Project.toml @@ -6,6 +6,7 @@ ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326" HCubature = "19dc6840-f33b-545b-b366-655c7e3ffd49" Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" +Meshing = "e6723b4c-ebff-59f1-b4b7-d97aa5274f73" QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" diff --git a/examples/gyroid.jl b/examples/gyroid.jl new file mode 100644 index 0000000..68a1084 --- /dev/null +++ b/examples/gyroid.jl @@ -0,0 +1,12 @@ +using Revise +using Descartes: Gyroid, Cuboid, PolarWarp, Cylinder, FRep +using GeometryBasics: GeometryBasics, mesh +using Meshing: MarchingTetrahedra + +p = intersect(PolarWarp(Gyroid(0.5), 200), Cuboid([50,50,50])) + +@time m = mesh(p; samples=(100,100,100), algorithm=MarchingTetrahedra()); + +using WGLMakie +WGLMakie.activate!(resize_to=:body) +WGLMakie.mesh(m) diff --git a/examples/piping.jl b/examples/piping.jl index 45d7a09..704261c 100644 --- a/examples/piping.jl +++ b/examples/piping.jl @@ -1,5 +1,5 @@ using Descartes: Piping -using GeometryBasics: Mesh +using GeometryBasics: mesh p = Piping(1.0, [[0,0,0], [10,0,0], @@ -7,7 +7,7 @@ p = Piping(1.0, [[0,0,0], [10,10,10], [5,5,5]]) -m = Mesh(p) +m = mesh(p) using WGLMakie mesh(m) diff --git a/examples/triangle_wave.jl b/examples/triangle_wave.jl index 87023fd..b802ac7 100644 --- a/examples/triangle_wave.jl +++ b/examples/triangle_wave.jl @@ -1,5 +1,5 @@ using Revise -using Descartes: Descartes, TriangleWave, FRep, Grid, PolarWarp, Cuboid, union +using Descartes: Descartes, TriangleWave, FRep, PolarWarp, Cuboid, union using WGLMakie using CoordinateTransformations using StaticArrays @@ -19,7 +19,7 @@ y2 = [FRep(t2, e) for e in x] lines(x,y2) -g = union(TriangleWave(1., 1), TriangleWave(2., 2)) +g = union(TriangleWave(5., 1), TriangleWave(1., 2)) x_vals = -10:0.1:10 y_vals = -10:0.1:10 @@ -33,7 +33,7 @@ heatmap(x_vals, y_vals, z, alpha=0.6) FRep(g, (x, y)) # Apply warp -g_polar = PolarWarp(g, 8) +g_polar = PolarWarp(g, 2) #FRep(g_polar, (x, y)) diff --git a/src/Descartes.jl b/src/Descartes.jl index dd1458e..aebc9e2 100644 --- a/src/Descartes.jl +++ b/src/Descartes.jl @@ -1,10 +1,12 @@ module Descartes import Base: *, union, diff, intersect +using GeometryBasics: GeometryBasics import GeometryBasics: AbstractMesh, HyperRectangle, Vec, - Mesh + mesh + using StaticArrays, Meshing, diff --git a/src/frep.jl b/src/frep.jl index 844c9a3..2af1d70 100644 --- a/src/frep.jl +++ b/src/frep.jl @@ -29,6 +29,12 @@ function FRep(u::CSGIntersect, v) f end +_gyroid(v) = cos(v[1])*sin(v[2])+cos(v[2])*sin(v[3])+cos(v[3])*sin(v[1]) + +function FRep(p::Gyroid, v) + max(_gyroid(v)-p.width,-_gyroid(v)-p.width) +end + function FRep(p::Sphere,v) norm(v) - p.radius end @@ -124,10 +130,10 @@ function FRep(p::PolarWarp, v) end function inner_warp(p::AbstractPrimitive, w, v) - T(a) = SVector(hypot(a...), atan(a[2], a[1])*w/2π) #cartesian to polar + T(a) = SVector(hypot(a[1], a[2]), atan(a[2], a[1])*w/2π, a[3]) #cartesian to polar hr = gradient(a -> FRep(p, T(a)), SVector(v...)) mr, mt = T(v) - FRep(p, SVector(mr, mt))/norm(hr) + FRep(p, SVector(mr, mt, v[3]))/norm(hr) end function inner_warp(p::CSGUnion, w, v) diff --git a/src/hyperrectangles.jl b/src/hyperrectangles.jl index f31c504..b192053 100644 --- a/src/hyperrectangles.jl +++ b/src/hyperrectangles.jl @@ -18,6 +18,10 @@ function HyperRectangle(p::Circle{T}) where {T} HyperRectangle{2,T}(Vec(-p.radius,-p.radius), Vec(p.radius*2,p.radius*2)) end +function HyperRectangle(p::PolarWarp) + nothing +end + function HyperRectangle(p::Piping{T}) where {T} maxx, maxy, maxz = typemin(Float64), typemin(Float64), typemin(Float64) minx, miny, minz = typemax(Float64), typemax(Float64), typemax(Float64) @@ -42,7 +46,7 @@ end function HyperRectangle(csg::CSGUnion) h = HyperRectangle(csg.left) for r in csg.right - union(h, HyperRectangle(r)) + h = union(h, HyperRectangle(r)) end h end @@ -54,7 +58,7 @@ end function HyperRectangle(csg::CSGIntersect) h = HyperRectangle(csg.left) for r in csg.right - intersect(h, HyperRectangle(r)) + h = intersect(h, HyperRectangle(r)) end h end @@ -91,16 +95,20 @@ diff(h1::HyperRectangle, h2::HyperRectangle) = h1 """ Perform a intersection between two HyperRectangles. """ -function intersect(h1::HyperRectangle, h2::HyperRectangle) +function Base.intersect(h1::HyperRectangle, h2::HyperRectangle) m = max.(minimum(h1), minimum(h2)) mm = min.(maximum(h1), maximum(h2)) HyperRectangle(m, mm - m) end -function intersect(::Nothing, h1::HyperRectangle) +function Base.intersect(::Nothing, h1::HyperRectangle) h1 end function Base.intersect(h1::HyperRectangle, ::Nothing) h1 +end + +function HyperRectangle(g::Gyroid) + nothing end \ No newline at end of file diff --git a/src/meshes.jl b/src/meshes.jl index 258cc37..cb525b7 100644 --- a/src/meshes.jl +++ b/src/meshes.jl @@ -1,13 +1,37 @@ -function (::Type{MT})(primitives::AbstractPrimitive...; +function GeometryBasics.mesh(primitives::AbstractPrimitive...; samples=(128,128,128), - algorithm=MarchingCubes(), - adf=false) where {MT <: AbstractMesh} + algorithm=MarchingCubes()) f(x) = FRep(primitives[1], x) - meshes = Vector{MT}(undef, length(primitives)) + meshes = Vector{GeometryBasics.Mesh}(undef, length(primitives)) + sdf_arr = Array{Float64}(undef, samples) + for i = 1:length(primitives) b = HyperRectangle(primitives[i]) - meshes[i] = MT(x -> FRep(primitives[i], x), b, samples, algorithm) + rng = range.(b.origin, b.origin.+ b.widths) + + @info "Sampling SDF" + xp = LinRange(first(rng[1]), last(rng[1]), samples[1]) + yp = LinRange(first(rng[2]), last(rng[2]), samples[2]) + zp = LinRange(first(rng[3]), last(rng[3]), samples[3]) + sdf(v) = FRep(primitives[i], SVector(v...)) + sdf_normal(v) = gradient(sdf, SVector(v...)) + + @time Threads.@threads for x in eachindex(xp) + for y in eachindex(yp), z in eachindex(zp) + sdf_arr[x,y,z] = sdf((xp[x],yp[y],zp[z])) + end + end + + @info "generating mesh" + @time vts, fcs = isosurface(sdf_arr, algorithm, rng[1], rng[2], rng[3]) + @info "remapping data types" + @time _points = map(GeometryBasics.Point, vts) + @time _faces = map(v -> GeometryBasics.TriangleFace{GeometryBasics.OneIndex}(v), fcs) + @info "evaluating normals" + @time normals = map(v -> GeometryBasics.Vec3f(sdf_normal(v)), vts) + @info "remapping mesh" + @time meshes[i] = GeometryBasics.Mesh(GeometryBasics.meta(_points; normals=normals), _faces) end return merge(meshes) end diff --git a/src/types.jl b/src/types.jl index d3f810e..019de36 100644 --- a/src/types.jl +++ b/src/types.jl @@ -91,7 +91,12 @@ struct TriangleWave{T} <: AbstractPrimitive{2, T} direction::Int end -struct PolarWarp{T} <: AbstractPrimitive{2, T} - primitive +struct PolarWarp{T, P} <: AbstractPrimitive{3, T} + primitive::P w::T +end + +struct Gyroid{T} <: AbstractPrimitive{3,T} + #TODO period, etc. + width::T end \ No newline at end of file diff --git a/test/meshes.jl b/test/meshes.jl index a3efe37..71051b6 100644 --- a/test/meshes.jl +++ b/test/meshes.jl @@ -1,8 +1,8 @@ @testset "Meshing" begin - c = Mesh(translate([4,5,6])Cuboid([1,2,3])) - @test_broken length(c.vertices) == 7638 - @test_broken length(c.faces) == 15272 + c = mesh(translate([4,5,6])Cuboid([1,2,3])) + #@test_broken length(c.vertices) == 7638 + #@test_broken length(c.faces) == 15272 @testset "Radiused Shelled Box" begin @@ -12,8 +12,8 @@ u = Shell(0.5)RadiusedCSGUnion(1,c2, cyl1) u2 = CSGDiff(u, Cuboid([2,2,2])) - m = Mesh(u2) - @test_broken length(m.vertices) == 86406 - @test_broken length(m.faces) == 172678 + m = mesh(u2) + #@test_broken length(m.vertices) == 86406 + #@test_broken length(m.faces) == 172678 end end diff --git a/test/runtests.jl b/test/runtests.jl index b30ccb1..e042680 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,7 +5,7 @@ using Combinatorics using FileIO using MeshIO -using GeometryBasics: Mesh, HyperRectangle +using GeometryBasics: mesh, HyperRectangle primitives_array = [Sphere(1), Cuboid([1,2,3]), Cylinder(3,4)] operations_array = [CSGUnion, CSGIntersect, CSGDiff]