Skip to content

Commit

Permalink
Makie mesh! bug workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
plut committed Aug 3, 2023
1 parent b8249b6 commit b167a3c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
18 changes: 12 additions & 6 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# 1d paths
* Composed operators!
* use `AbstractGeometry{1}` for this!
* concrete subtypes include segments, circular arcs, splines, loop closing
* use `AbstractGeometry{1}` for this!
* allow moves to be relative as well as absolute
* allow symbolic centering of cubes etc.
* ellipsoids (`sphere(a,b,c)`)
* circular arc: defined either by angle+center+radius, sagitta+endpoints...
* meshing methods produce polylines
* concrete type for polyline
* operators 1d ↔ 2d: border, interior
* fill holes (in 2d and in 3d)
* `path_extrude(surface, profile) => path_extrude(∂surface)`
* `path(element1, element2, ...)`
# Bug fixes
Expand Down Expand Up @@ -68,8 +71,8 @@ For MeshIO: stl needs
- [ ] overload `extrude()` (for paths, angles, numbers)
- [ ] move doc examples to `WGLMakie`
- [ ] remove `ConvexHull.jl` dependency (use method from `igl` instead?)
- [ ] `linear_extrude` / `prism` ?
- [ ] `rotate_extrude` / `revolution` ?
- [x] `linear_extrude` / `prism` ?
- [x] `rotate_extrude` / `revolution` ?
- [ ] replace ad-hoc `plot` methods by correct `Makie` interface
- [x] make meshing type-stable
- [x] update `iglwrap` and use latest version
Expand All @@ -88,9 +91,12 @@ For MeshIO: stl needs
- [ ] document how to extend (e.g. new object type)
# New features
## Geometry
- [ ] `multiply`: dispose copies of a mesh (better than `union` because
- [x] `multiply`: dispose copies of a mesh (better than `union` because
we compute the child mesh only once)
- [ ] `symmetrize(m, s...) = union(s..., mirror(m, s...))`
find some easy syntax allowing also `symmetrize(m)*s`
- [ ] replace `attributes` by a pointer to the original colored object; this could allow detecting edges etc.
- [ ] and detected edges would be protected from decimation
- [x] `refine`: shorten all edges until no longer than given length
- [ ] 2d (just divide edges)
- [x] 3d (split triangles)
Expand Down Expand Up @@ -144,10 +150,10 @@ For MeshIO: stl needs
- OpenSCAD: `src/FreetypeRenderer.cc`, `::render` function
- [ ] use `Pango` for text and `FreeType` for fonts
- [x] Bézier curves (used as path for `path_extrude`, `stroke`, `polygon`)
- [ ] `symmetrize(m, s...) = union(s..., mirror(m, s...))`
find some easy syntax allowing also `symmetrize(m)*s`
- [ ] 2d Minkowski difference
## Misc.
- [ ] use snap rounding from CGAL to re-introduce our own mesh boolean
functions?
- [x] `surface(volume)` = instantiate as a mesh (avoids recomputation)
- [ ] `plot(...; zoom=...)`
## Attachments
Expand Down
13 changes: 8 additions & 5 deletions src/ConstructiveGeometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2450,6 +2450,9 @@ Base.show(io::IO, ::MIME"image/svg+xml", s::AbstractGeometry{2}) =
# TODO: figure out how to rewrite the following using native Makie recipes
@inline plot(g::AbstractGeometry; kwargs...) = plot(fullmesh(g); kwargs...)
@inline plot(g::FullMesh; kwargs...) = plot!(Makie.Scene(), g; kwargs...)
# TODO: this is a workaround for a possible Makie bug — `mesh!` plots
# nothing, while `mesh()` works correctly:
@inline Makie_mesh_bang(::SceneLike, a...; kw...) = Makie.mesh(a...; kw...)

function plot!(scene::SceneLike, m::FullMesh; kwargs...)
rawmain = raw(m.main)
Expand All @@ -2476,9 +2479,9 @@ function plot!(scene::SceneLike, m::TriangleMesh; kwargs...)
end
fmat = collect(1:size(vmat, 1))
attr = [ a[fld1(i,3)] for i in 1:size(vmat, 1)]
Makie.mesh!(scene, vmat, fmat, color=attr; # opaque!
Makie_mesh_bang(scene, vmat, fmat, color=attr; # opaque!
lightposition=Makie.Vec3f0(5e3,1e3, 10e3), kwargs... )
return scene
# return scene
end

function plot!(scene::SceneLike, m::TriangleMesh{<:Real,Nothing};
Expand All @@ -2488,7 +2491,7 @@ function plot!(scene::SceneLike, m::TriangleMesh{<:Real,Nothing};
v = TriangleMeshes.vertices(m); f = TriangleMeshes.faces(m);
vmat = [ p[j] for p in v, j in 1:3 ]
fmat = [ q[j] for q in f, j in 1:3 ]
Makie.mesh!(scene, vmat, fmat; transparency=true,
Makie_mesh_bang(scene, vmat, fmat; transparency=true,
lightposition=Makie.Vec3f0(5e3,1e3,10e3), kwargs...)
end

Expand All @@ -2509,10 +2512,10 @@ function plot!(scene::SceneLike, p::Shapes.PolygonXor;
v = Shapes.vertices(p)
tri = Shapes.triangulate(p)
m = [ t[j] for t in tri, j in 1:3 ]
Makie.mesh!(scene, v, m,
Makie_mesh_bang(scene, v, m,
specular=Makie.Vec3f0(0,0,0), diffuse=Makie.Vec3f0(0,0,0),
color=color; kwargs...)
return scene
# return scene
end

# OpenSCAD output««1
Expand Down

0 comments on commit b167a3c

Please sign in to comment.