I got a rough gui version working with scaling and translation.
It takes a copy of the input "Mesh file", transforms it and saves it as
"transformed.msh".
It works nicely if you merge the "base" mesh file first and then start
playing around with the transformed version.
Here is a copy if anyone would like to try it:
[image: image.png]
On Tue, Jan 14, 2020 at 1:53 AM Christophe Geuzaine <[email protected]>
wrote:
>
>
> > On 13 Jan 2020, at 23:23, Max Orok <[email protected]> wrote:
> >
> > Thank you Christophe, I was scared off a bit from setNodes by the doc
> >
> > <image.png>
> >
> > and went looking for some sort of "block assign" for large meshes and
> skipped the step where I tried using setNodes directly.
> >
>
> Indeed I was maybe a bit extreme in the warning :-) I'll change this.
>
> > Thanks guys,
> > Max
> >
> > On Mon, Jan 13, 2020 at 1:44 PM Christophe Geuzaine <[email protected]>
> wrote:
> >
> >
> > > On 13 Jan 2020, at 19:15, Max Orok <[email protected]> wrote:
> > >
> > > Hi Jeremy, thanks for your response.
> > > This is kind of what I've got going right now with the attached
> scripts:
> > >
> > > I'd like to be able to do this in the GUI, just because the adjustment
> is a little touchy.
> > > Maybe an extension could be to combine these into a ONELAB client and
> try it that way.
> > > I also considered adding a plugin but perhaps the ONELAB route is
> fastest.
> > >
> >
> > You can directly change the mesh and run the GUI in the script:
> >
> >
> >
> > Christophe
> >
> > > Max
> > > <scale.py><shift.py>_______________________________________________
> > > gmsh mailing list
> > > [email protected]
> > > http://onelab.info/mailman/listinfo/gmsh
> >
> > —
> > Prof. Christophe Geuzaine
> > University of Liege, Electrical Engineering and Computer Science
> > http://www.montefiore.ulg.ac.be/~geuzaine
> >
> >
> >
> >
> >
> > --
> > Max Orok
> > Contractor
> > www.mevex.com
> >
> >
>
> —
> Prof. Christophe Geuzaine
> University of Liege, Electrical Engineering and Computer Science
> http://www.montefiore.ulg.ac.be/~geuzaine
>
>
>
>
--
Max Orok
Contractor
www.mevex.com
# transform a mesh interactively
# -- requires Gmsh 4.5 for setNode function
# -- Max Orok, January 2020
import onelab
import gmsh
c = onelab.client(__file__)
x_shift = c.defineNumber('Shift/x', value=0.0)
y_shift = c.defineNumber('Shift/y', value=0.0)
z_shift = c.defineNumber('Shift/z', value=0.0)
x_scale = c.defineNumber('Scale/x', value=1.0)
y_scale = c.defineNumber('Scale/y', value=1.0)
z_scale = c.defineNumber('Scale/z', value=1.0)
fname = c.defineString('Mesh file', kind='file')
gmsh.initialize()
gmsh.open(fname)
# # find bounding box of whole model
# (xmin, ymin, zmin, xmax, ymax, zmax) = gmsh.model.getBoundingBox(-1, -1)
#
# xc = (xmax + xmin) / 2
# yc = (ymax + ymin) / 2
# zc = (zmax + zmin) / 2
(nodes, coords, _) = gmsh.model.mesh.getNodes()
# scale doesn't really work nicely unless the model's centered
for i, tag in enumerate(nodes):
gmsh.model.mesh.setNode(tag, [x_scale * coords[3*i] + x_shift, y_scale
* coords[3*i+1] + y_shift, z_scale * coords[3*i+2] + z_shift], [])
gmsh.write("transformed.msh")
gmsh.finalize()
c.mergeFile(c.checkPath("transformed.msh"))
_______________________________________________
gmsh mailing list
[email protected]
http://onelab.info/mailman/listinfo/gmsh