[Gmsh] Bounding Box of an imported STL Smaller than geometry?

Baltasar Rüchardt baltasar.ruechardt at ds.mpg.de
Tue Jun 23 18:41:31 CEST 2020


Dear everyone,

I hope you are dealing as good as possible with the pandemic.

I am puzzled because the bounding box that I obtain from a stl geometry
is smaller than the volume defined by the surface.

The procedure used is as follows:

1. Import stl
2. Use Bounding Box on surface
3. Create Points by coordinates obtained from Bounding Box
4. Connect points to make a volume.

This is done in create_to_small_box.geo [which should have rather be
named create_too_small_box.geo ...].

Background: The stl shows the surface of a heart obtained from a mrt
scan. I first shrink / expand it using the Plugin(Transform) and then I
want to translate it (again using the Plugin(Transform).Tz) such that
the tip of the heart is at the same height as the edge of an electrode
(small example in show_application_of_transforms.geo). My approach was
to use the bounding box zmin- value to compare the heights and then
calculate the necessary transformation by calculating tz= zmin_electrode
- zmin_heart .

Does someone have a suggestion? Or any help? The alternative would be to
move the stl with meshlab such that the heart tip is at heigh zero, then
I could apply the shrinking and transform in gmsh without problems.

Thank you very much in advance!

Best regards

Baltasar Rüchardt


Gmshinfo:

Version       : 4.6.0
License       : GNU General Public License
Build OS      : MacOSX
Build date    : 20200622
Build host    : gmsh.info
Build options : 64Bit ALGLIB Ann Bamg Blas[custom] Blossom Cgns
DIntegration Dlopen DomHex Fltk Gmm Hxt Jpeg[fltk] Kbipack
Lapack[custom] MathEx Med Mesh Metis Mmg3d Mpeg Netgen ONELAB
ONELABMetamodel OpenCASCADE OpenCASCADE-CAF OpenGL OptHom PETSc Parser
Plugins Png[fltk] Post QuadTri Solver TetGen/BR Voro++ Zlib[fltk]
FLTK version  : 1.4.0
PETSc version : 3.9.3 (real arithmtic)
OCC version   : 7.4.0
MED version   : 4.0.0
Packaged by   : geuzaine
Web site      : https://gmsh.info
Issue tracker : https://gitlab.onelab.info/gmsh/gmsh/issues
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bounding_box_smaller_than_stl.png
Type: image/png
Size: 464840 bytes
Desc: not available
URL: <http://onelab.info/pipermail/gmsh/attachments/20200623/7b95326d/attachment-0001.png>
-------------- next part --------------

Geometry.OldNewReg = 0;


Merge 'outer_boundary.stl';

// BoundingBox returns {xmin, ymin, zmin, xmax, ymax, zmax}
bb[] = BoundingBox Surface{1};

xmin = bb[0]; xmax = bb[3];
ymin = bb[1]; ymax = bb[4];
zmin = bb[2]; zmax = bb[5];

Point(newp) = {xmin, ymin, zmin};
Point(newp) = {xmin, ymax, zmin};
Point(newp) = {xmin, ymax, zmax};
Point(newp) = {xmin, ymin, zmax};

Point(newp) = {xmax, ymin, zmin};
Point(newp) = {xmax, ymax, zmin};
Point(newp) = {xmax, ymax, zmax};
Point(newp) = {xmax, ymin, zmax};

//+
Line(1) = {1, 5};
Line(2) = {5, 6};
Line(3) = {1, 2};
Line(4) = {1, 4};
Line(5) = {4, 3};
Line(6) = {3, 7};
Line(7) = {8, 4};
Line(8) = {8, 5};
Line(9) = {6, 7};
Line(10) = {8, 7};
Line(11) = {3, 2};
Line(12) = {2, 6};
Curve Loop(1) = {4, -7, 8, -1};
Plane Surface(2) = {1};
Curve Loop(2) = {2, 9, -10, 8};
Plane Surface(3) = {2};
Curve Loop(3) = {7, 5, 6, -10};
Plane Surface(4) = {3};
Curve Loop(4) = {4, 5, 11, -3};
Plane Surface(5) = {4};
Curve Loop(5) = {6, -9, -12, -11};
Plane Surface(6) = {5};
Curve Loop(6) = {3, 12, -2, -1};
Plane Surface(7) = {6};

//+
Physical Surface("box") = {4, 6, 5, 7, 2, 3};

-------------- next part --------------
A non-text attachment was scrubbed...
Name: outer_boundary.stl
Type: application/octet-stream
Size: 3837484 bytes
Desc: not available
URL: <http://onelab.info/pipermail/gmsh/attachments/20200623/7b95326d/attachment-0001.stl>
-------------- next part --------------
// 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;

////////////////// Import and transform stl ///////////////

Merge 'outer_boundary.stl';

// Heart tip should be aligned in z direction with elec_los value.
elec_low = 30; elec_high = 80;


/* Turn and shrink the meshes */
DefineConstant[ rot_angle = {90, Min 0, Max 360, Step 1,
    Name "Parameters/Rot-Angle [˚]"} ];
DefineConstant[ blow_up_factor = {0.2, Min 0.1, Max 1.6, Step 0.3,
    Name "Parameters/blow_up_factor"} ];

// Information from Christophe Geuzaine as answer to gmsh
// mailing list question, see http://onelab.info/pipermail/gmsh/2020/013626.html

Plugin(NewView).Run;
t = rot_angle * 2*Pi/360;
Plugin(Transform).A11 = Cos(t) * blow_up_factor;
Plugin(Transform).A12 = -Sin(t) * blow_up_factor;
Plugin(Transform).A21 = Sin(t) * blow_up_factor;
Plugin(Transform).A22 = Cos(t) * blow_up_factor;
Plugin(Transform).A33 = 1 * blow_up_factor;
Plugin(Transform).Run;

// BoundingBox returns {xmin, ymin, zmin, xmax, ymax, zmax}
bb_after_shrink[] = BoundingBox Surface{1};
heart_tip_z = bb_after_shrink[2];

// understand Bounding box entries:
Printf("Entries bounding box:");
For i In {0:#bb_after_shrink[]-1}
  Printf("   %g", bb_after_shrink[i]);
EndFor


Plugin(NewView).Run;
transform_z = elec_low - heart_tip_z;
Plugin(Transform).A11 = 1;
Plugin(Transform).A12 = 0;
Plugin(Transform).A21 = 0;
Plugin(Transform).A22 = 1;
Plugin(Transform).A33 = 1;
Plugin(Transform).Tz = transform_z;
Plugin(Transform).Run;

////////////////// End Import and transform stl ///////////////

/* make dummy electrode */

front_l_left = newp; Point(front_l_left)={-24,-40,elec_low};
front_l_right = newp; Point(front_l_right)={40,-40,elec_low};
front_u_left = newp; Point(front_u_left)={-24,-40,elec_high};
front_u_right = newp; Point(front_u_right)={40,-40,elec_high};

back_l_left = newp; Point(back_l_left)={-24,-45,elec_low};
back_l_right = newp; Point(back_l_right)={40,-45,elec_low};
back_u_left = newp; Point(back_u_left)={-24,-45,elec_high};
back_u_right = newp; Point(back_u_right)={40,-45,elec_high};

l1 = newl; Line(l1) = {front_l_left, front_l_right};
l2 = newl; Line(l2) = {front_l_right, front_u_right};
l3 = newl; Line(l3) = {front_u_right, front_u_left};
l4 = newl; Line(l4) = {front_u_left, front_l_left};

l5 = newl; Line(l5) = {back_l_left, back_l_right};
l6 = newl; Line(l6) = {back_l_right, back_u_right};
l7 = newl; Line(l7) = {back_u_right, back_u_left};
l8 = newl; Line(l8) = {back_u_left, back_l_left};

l9 = newl; Line(l9)   = {back_l_left, front_l_left};
l10 = newl; Line(l10) = {back_l_right, front_l_right};
l11 = newl; Line(l11) = {back_u_right, front_u_right};
l12 = newl; Line(l12) = {back_u_left, front_u_left};

cl1 = newll; Curve Loop(cl1) = {l1, l2, l3, l4};
s1 = news; Surface(s1) = cl1;
cl2 = newll; Curve Loop(cl2) = {l5, l6, l7, l8};
s2 = news; Surface(s2) = cl2;

cl3 = newll; Curve Loop(cl3) = {l9, l1, -l10, -l5};
s3 = news; Surface(s3) = cl3;
cl4 = newll; Curve Loop(cl4) = {l3, -l12, -l7, l11};
s4 = news; Surface(s4) = cl4;

cl5 = newll; Curve Loop(cl5) = {l4, -l9, -l8, l12};
s5 = news; Surface(s5) = cl5;
cl6 = newll; Curve Loop(cl6) = {-l2, -l10, l6, l11};
s6 = news; Surface(s6) = cl6;
Physical Surface("box") = {s1, s2, s3, s4, s5, s6};




More information about the gmsh mailing list