Partition operation done programatically

Hello

I'm trying to do a partition operation programatically i C++. Like in the link below I've got two boxes I'd like to partition into 3 boxes so i
can create the volume groups and subsequently mesh them and then create the mesh groups.

So basically i'd like to do the steps in the link from code

http://www.elmerfem.org/elmerwiki/index.php?title=Multiple_bodies_from_S...

TopoDS_Shape s1;
TopoDS_Shape s2;
s1 = MakeBox(0, 0, 0, 40, 40, 10);
s2 = MakeBox(10, 10, 5, 20, 20, 10);

....

What do i do from here ?

Any help much appreciated

jelle's picture

PythonOCC wraps the Partition module that comes with Salome:
Mark Blome wrote an interesting blog article here:
http://www.pythonocc.org/resources/meshing/pythonocc-and-smesh/

-jelle

Eugeny's picture

Hello Henrik Rune Jakobsen,

To make a partition use class BOPAlgo_Builder.

TopoDS_Shape s1;
TopoDS_Shape s2;
s1 = MakeBox(0, 0, 0, 40, 40, 10);
s2 = MakeBox(10, 10, 5, 20, 20, 10);
//
BOPAlgo_Builder aBuilder;
//
aBuilder.AddArgument(s1);
aBuilder.AddArgument(s2);
//
aBuilder.Perform();
Standard_Integer iErr = aBuilder.ErrorStatus();
if (iErr) {
return iErr;
}
//
const TopoDS_Shape& aRes = aBuilder.Shape();
//.....

The result aRes is a compound containing all splits of the arguments.

Best regards,
Eugeny.

Henrik Rune Jakobsen's picture

Thank you very much for the help :)