[Gmsh] Does BooleanUnion works on surfaces?

Christophe Geuzaine cgeuzaine at uliege.be
Mon Aug 24 09:35:26 CEST 2020



> On 23 Aug 2020, at 21:40, Marco Antolovic <marco_antolovic at yahoo.it> wrote:
> 
> Hi all,
> 
> while I was building a geometry I came across an unexpected behavior of the BooleanUnion operator.
> 
> I assumed that the operator would work on surfaces but it does not. If you try the example below, the union result is going to be two separate surfaces
> 
> SetFactory("OpenCASCADE");
> 
> recta1=newreg;
> Rectangle ( recta1 ) = { -.02, -.030, 0, .005, 0.01};
> recta2=newreg;
> Rectangle ( recta2 ) = { -.015,   -.020, 0, .005, -0.01 };
> 
> resulting_surface() = BooleanUnion{ Surface{recta1}; Delete;}{ Surface{recta2}; Delete;};
> 
> For i In {0: #resulting_surface()-1}
> Printf ("test openCASCADE surface union = %g", resulting_surface(i));
> EndFor
> 
> The example shows that resulting_surface() contains two elements instead of one.
> 
> Does BooleanUnion works on surfaces?

It does actually work as expected: the 2 surfaces are glued by the union operation (by curve 2); but indeed OpenCASCADE leaves the internal curve in the final geometry.

Recent versions of Gmsh introduced the "Geometry.OCCUnionUnify" option to try to remove internal seams when the two surfaces are on the same geometry. In your case you should define the two surfaces in the same plane (the second is reversed, i.e. you should define Rectangle ( recta2 ) = { -.015,   -.030, 0, .005, 0.01 };), and we will generate a new surface without internal curve.

Also note that you might want to se "Geometry.OCCBooleanPreserveNumbering = 0;" in this case. Because since the actual union operation keeps the two surfaces, the "Delete" operation would not be taken into account.

So, long story short:

SetFactory("OpenCASCADE");
recta1=newreg;
Rectangle ( recta1 ) = { -.02, -.030, 0, .005, 0.01};
recta2=newreg;
Rectangle ( recta2 ) = { -.015,   -.030, 0, .005, 0.01 };
Geometry.OCCUnionUnify = 1;
Geometry.OCCBooleanPreserveNumbering = 0;
resulting_surface() = BooleanUnion{ Surface{recta1}; Delete;}{ Surface{recta2}; Delete;};

Christophe



> 
> Many thanks,
> 
> Marco
> _______________________________________________
> gmsh mailing list
> gmsh at onelab.info
> http://onelab.info/mailman/listinfo/gmsh

— 
Prof. Christophe Geuzaine
University of Liege, Electrical Engineering and Computer Science 
http://www.montefiore.ulg.ac.be/~geuzaine






More information about the gmsh mailing list