Hello everyone,
While working with gmsh and importing stls in order to create FEM-meshes I was confronted with a question I wasn't able to solve on my own so far: Can I merge a stl file in gmsh and rotate the stl data afterwards? Alternatively, can I rotate the geometry that was created by CreateGeometry; such that the fem mesh will be rotated as well? I attached an example script (dev_test_rotation.geo) where I try the second approach: Create the volume from the stl and then I try to rotate the geometrical entities. See the part "Try rotate volume" in the script. I also attached a simple stl geometry to test it. Do you have any ideas? The alternative that came to my mind is to rotate with e.g. meshlab before merging to gmsh. Is this the best / only solution? I am looking forward to your answers! Thank you and stay well Baltasar Rüchardt
example.stl
Description: Binary data
// Gmsh project created on Wed Feb 26 23:17:35 2020 // Use seperate counting for lines, surfaces, volumes (see http://gmsh.info/doc/texinfo/gmsh.html#index-Geometry_002eOldNewReg) Geometry.OldNewReg = 0; // Mesh.SaveAll = 1; // macros ////////////////// begin creation of volume from stl /////////////// // In the following I import the surface mesh. // Because in the stl there are very close vertices // the stl will be reclassify such that the nodes // of the fem mesh created do not necessarily // overlap with the nodes of the stl, which I think // was the case before. // To do so, I use the ClassifySurfaces function which // (this is handwaving) reads the stl surface and finds // a way to describe these surfaces with gmsh. // In the next step, the CreateGeometry function creates // the gmsh representation based on the classified // surfaces. // The parameters of ClassifySurfaces are: // angle: angle which is used to create sharp edges. // If angle = 180 degree: never create sharp edges // [see gmsh mailing list answer to my question] // forceParametrizablePatches: Create surfaces guaranteed // to be parametrizable // includeBoundary: todo // splitangle: forces splitting if two generated curves // have an angle larger than this one. Merge 'example.stl'; DefineConstant[ angle = {20, Min 0, Max 360, Step 1, Name "ClassifySurfaceArgs/angle"} ]; DefineConstant[ splitangle = {45, Min 0, Max 360, Step 1, Name "ClassifySurfaceArgs/splitangle"} ]; forceParametrizablePatches = 1; includeBoundary = 1; surface_tag_before_classification = news; ClassifySurfaces{angle * Pi/180, includeBoundary, forceParametrizablePatches, splitangle * Pi/180}; CreateGeometry; surface_tag_after_classification = news; /// make volume surfaces_stl[] = {}; For i In {surface_tag_before_classification:surface_tag_after_classification-1} surfaces_stl[]+=i; EndFor boundary_stl = newsl; Surface Loop(boundary_stl) = {surfaces_stl[]}; volume_stl = newv; Volume(volume_stl) = {boundary_stl}; /// Try rotate volume DefineConstant[ rot_angle = {0, Min 0, Max 360, Step 1, Name "Parameters/Rot-Angle [˚]"} ]; Rotate {{1, 0, 0}, {0, 0, 0}, rot_angle * Pi/180} { Volume{:}; } Rotate {{1, 0, 0}, {0, 0, 0}, rot_angle * Pi/180} { Point{:}; } Rotate {{1, 0, 0}, {0, 0, 0}, rot_angle * Pi/180} { Surface{:}; } ////////////////// end creation volume from stl ///////////////
_______________________________________________ gmsh mailing list gmsh@onelab.info http://onelab.info/mailman/listinfo/gmsh