Skip to content

Commit e1eba4b

Browse files
authored
Update G4Vis to breaking changes in GeometryBasics@0.5 (#27)
* Update `G4Vis` to breaking changes in `GeometryBasics@0.5` * Bump compat for GeometryBasics to 0.5 * Disable drawing boolean solids
1 parent c715fa4 commit e1eba4b

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ G4Vis = ["Makie", "Colors", "StaticArrays", "Rotations", "LinearAlgebra", "IGLWr
3131
CSV = "0.10"
3232
CxxWrap = "0.16"
3333
Geant4_julia_jll = "0.2"
34-
GeometryBasics = "0.4,0.5"
34+
GeometryBasics = "0.5"
3535
IGLWrap_jll = "2.4.0"
3636
julia = "1.9"
3737
FHist = "0.11"

ext/G4Vis/Boolean.jl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function boolean(op, m1::GeometryBasics.Mesh, m2::GeometryBasics.Mesh, t::Transf
4444
if ret == 0
4545
c = unsafe_array(Point3{Float64}, cm.vertices, cm.nv)
4646
f = unsafe_array(TriangleFace{Int32}, cm.faces, cm.nf)
47-
return GeometryBasics.Mesh(c,f)
47+
return GeometryBasics.mesh(c,f)
4848
else
4949
return
5050
end
@@ -62,13 +62,15 @@ const operation = Dict("G4UnionSolid" => 0, "G4IntersectionSolid" => 1, "G4Subtr
6262

6363
function GeometryBasics.mesh(s::G4BooleanSolid)
6464
if isdefined(IGLWrap_jll, :libiglwrap)
65-
op = operation[GetEntityType(s)]
66-
left = GetConstituentSolid(s, 0)
67-
right = GetConstituentSolid(s, 1)
68-
boolean(op, GeometryBasics.mesh(left), GeometryBasics.mesh(right))
65+
println("IGLWrap_jll is available but interface needs to be fixed for drawing boolean solids (TODO)")
66+
GeometryBasics.mesh(Point3{Float64}[], QuadFace{Int32}[])
67+
# op = operation[GetEntityType(s)]
68+
# left = GetConstituentSolid(s, 0)
69+
# right = GetConstituentSolid(s, 1)
70+
# boolean(op, GeometryBasics.mesh(left), GeometryBasics.mesh(right))
6971
else
70-
println("IGLWrap_jll is not available for currrent platform $(Sys.MACHINE) and is needed for drawing boolean solids")
71-
GeometryBasics.Mesh(Point3{Float64}[], QuadFace{Int32}[])
72+
println("IGLWrap_jll is not available for current platform $(Sys.MACHINE) and is needed for drawing boolean solids")
73+
GeometryBasics.mesh(Point3{Float64}[], QuadFace{Int32}[])
7274
end
7375
end
7476

@@ -80,7 +82,7 @@ function GeometryBasics.mesh(s::G4DisplacedSolid)
8082
points = GeometryBasics.coordinates(m)
8183
faces = GeometryBasics.faces(m)
8284
map!(c -> c * t, points, points)
83-
GeometryBasics.Mesh(points, faces)
85+
GeometryBasics.mesh(points, faces)
8486
end
8587

8688
function Geant4.draw(solid::G4BooleanSolid; wireframe::Bool=false, kwargs...)

ext/G4Vis/G4Vis.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ module G4Vis
2626
return (RGB(GetRed(c),GetGreen(c), GetBlue(c)),GetAlpha(c))
2727
end
2828

29-
function GeometryBasics.Tesselation(s::G4VSolid, nvertices::NTuple{N,<:Integer}) where N
30-
return Tesselation{3,Float64,typeof(s),N}(s, Int.(nvertices))
29+
function GeometryBasics.Tessellation(s::G4VSolid, nvertices::NTuple{N,<:Integer}) where N
30+
return Tessellation{3,Float64,typeof(s),N}(s, Int.(nvertices))
3131
end
32-
GeometryBasics.mesh(s::G4VSolid) = GeometryBasics.mesh(Tesselation(s, 36), facetype=QuadFace{Int})
32+
GeometryBasics.mesh(s::G4VSolid) = GeometryBasics.mesh(Tessellation(s, 36), facetype=QuadFace{Int})
3333

3434

3535
colors = colormap("Grays", 8)
@@ -94,7 +94,7 @@ module G4Vis
9494
points = GeometryBasics.coordinates(m)
9595
faces = GeometryBasics.faces(m)
9696
map!(c -> c * t, points, points)
97-
m = GeometryBasics.Mesh(meta(points; normals=normals(points, faces)), faces)
97+
m = GeometryBasics.mesh(points, faces, normal=GeometryBasics.normals(points, faces, Vec3f))
9898
end
9999
color = g4vis != C_NULL ? convert(Tuple{RGB, Float64}, GetColour(g4vis)) : (colors[level], GetDensity(GetMaterial(lv))/(12g/cm3))
100100
visible = g4vis != C_NULL ? IsVisible(g4vis) : true

0 commit comments

Comments
 (0)