Skip to content

Commit

Permalink
fixup CSG rework
Browse files Browse the repository at this point in the history
  • Loading branch information
sjkelly committed Jun 10, 2024
1 parent 2ef43fe commit f3ab699
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
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
12 changes: 10 additions & 2 deletions src/hyperrectangles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,23 @@ function HyperRectangle(m::MapContainer)
end

function HyperRectangle(csg::CSGUnion)
union(HyperRectangle(csg.left), HyperRectangle(csg.right))
h = HyperRectangle(csg.left)
for r in csg.right
union(h, HyperRectangle(r))
end
h
end

function HyperRectangle(csg::RadiusedCSGUnion)
union(HyperRectangle(csg.left), HyperRectangle(csg.right))
end

function HyperRectangle(csg::CSGIntersect)
intersect(HyperRectangle(csg.left), HyperRectangle(csg.right))
h = HyperRectangle(csg.left)
for r in csg.right
intersect(h, HyperRectangle(r))
end
h
end

function HyperRectangle(csg::CSGDiff)
Expand Down
4 changes: 4 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

function dim(::AbstractPrimitive{N,T}) where {N,T}
return N
end
2 changes: 1 addition & 1 deletion test/examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"2d.jl"]
for file in files
@testset "$file" begin
include("$dir/$file")
include("$dir/$file")
end
end
end

0 comments on commit f3ab699

Please sign in to comment.