Skip to content

Commit

Permalink
Fix gridscale, labels for 3D plots
Browse files Browse the repository at this point in the history
  • Loading branch information
j-fu committed Feb 12, 2023
1 parent ba65f98 commit 13d07da
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PlutoVista"
uuid = "646e1f28-b900-46d7-9d87-d554eb38a413"
authors = ["Juergen Fuhrmann <[email protected]>"]
version = "0.8.18"
version = "0.8.19"

[deps]
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
Expand Down
26 changes: 25 additions & 1 deletion assets/plutovtkplot.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function add_cell_dataset(win,points,polys,colors,aspect)
name: 'Colors',
values: colors,
numberOfComponents: 3,
});
});s

win.cell_color_dataset.getPoints().setData(points, 3);
win.cell_color_dataset.getPolys().setData(polys,1);
Expand Down Expand Up @@ -286,6 +286,18 @@ function plutovtkplot(uuid,jsdict,invalidation)
var opolys=jsdict[cmd+"opolys"]
var ocolors=jsdict[cmd+"ocolors"]
var transparent=jsdict[cmd+"transparent"]
var gridscale=jsdict[cmd+"gridscale"]


vtk.Common.Core.vtkMatrixBuilder
.buildFromRadian()
.scale(gridscale,gridscale,gridscale)
.apply(points);

vtk.Common.Core.vtkMatrixBuilder
.buildFromRadian()
.scale(gridscale,gridscale,gridscale)
.apply(opoints);


{ // isosurfaces and plane sections
Expand Down Expand Up @@ -410,6 +422,8 @@ function plutovtkplot(uuid,jsdict,invalidation)
var points=jsdict[cmd+"points"]
var polys=jsdict[cmd+"polys"]
var colors=jsdict[cmd+"colors"]
var gridscale=jsdict[cmd+"gridscale"]


var outline=jsdict[cmd+"outline"]
var opoints=jsdict[cmd+"opoints"]
Expand All @@ -418,6 +432,16 @@ function plutovtkplot(uuid,jsdict,invalidation)

add_cell_dataset(win,points, polys, colors,1.0)

vtk.Common.Core.vtkMatrixBuilder
.buildFromRadian()
.scale(gridscale,gridscale,gridscale)
.apply(points);

vtk.Common.Core.vtkMatrixBuilder
.buildFromRadian()
.scale(gridscale,gridscale,gridscale)
.apply(opoints);


if (outline==1)
{
Expand Down
4 changes: 4 additions & 0 deletions src/plutovtkplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ function tetcontour!(p::PlutoVTKPlot, pts, tets,func; parentpts=pts, kwargs...)
yplanes=[prevfloat(Inf)],
zplanes=[prevfloat(Inf)],
levelalpha=0.25,
gridscale=1.0,
outlinealpha=0.1)
args=merge(p.args,default_args)
args=merge(args,kwargs)
Expand Down Expand Up @@ -348,6 +349,7 @@ function tetcontour!(p::PlutoVTKPlot, pts, tets,func; parentpts=pts, kwargs...)

cfaces=reshape(reinterpret(Int32,faces0),(3,length(faces0)))
cpts=copy(reinterpret(Float32,cpts0))
parameter!(p,"gridscale",args[:gridscale])
parameter!(p,"points",cpts)
parameter!(p,"polys",vtkpolys(cfaces))
nan_replacement=0.5*(crange[1]+crange[2])
Expand Down Expand Up @@ -541,6 +543,7 @@ function tetmesh!(p::PlutoVTKPlot, pts, tets;kwargs...)
colormap=nothing,
faces=nothing,
facemarkers=nothing,
gridscale=1.0,
facecolormap=nothing,
xplanes=[prevfloat(Inf)],
yplanes=[prevfloat(Inf)],
Expand All @@ -563,6 +566,7 @@ function tetmesh!(p::PlutoVTKPlot, pts, tets;kwargs...)

ntet=size(tets,2)
command!(p,"tetmesh")
parameter!(p,"gridscale",args[:gridscale])
nregions= markers==nothing ? 0 : maximum(markers)
nbregions= facemarkers==nothing ? 0 : maximum(facemarkers)

Expand Down

2 comments on commit 13d07da

@j-fu
Copy link
Owner Author

@j-fu j-fu commented on 13d07da Feb 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/77542

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.8.19 -m "<description of version>" 13d07daf36de9f7831d6d984b57bf221cd55c457
git push origin v0.8.19

Please sign in to comment.