Steps to turn Sewed Shape in to unified solid

Hi. I have a piece of code that builds a shape as follows : 

gp_Pnt p1(10,0,0);
gp_Pnt p2(10,10,0);
gp_Pnt p3(0,10,0);
gp_Pnt p4(0,0,0);
gp_Pnt p5(10,0,10);
gp_Pnt p6(10,10,10);
gp_Pnt p7(0,10,10);
gp_Pnt p8(0,0,10);

TopoDS_Edge e1 = BRepBuilderAPI_MakeEdge( p4, p1);
TopoDS_Edge e2 = BRepBuilderAPI_MakeEdge( p1, p2);
TopoDS_Edge e3 = BRepBuilderAPI_MakeEdge( p2, p3);
TopoDS_Edge e4 = BRepBuilderAPI_MakeEdge( p3, p4);
TopoDS_Edge e5 = BRepBuilderAPI_MakeEdge( p1, p5);
TopoDS_Edge e6 = BRepBuilderAPI_MakeEdge( p2, p6);
TopoDS_Edge e7 = BRepBuilderAPI_MakeEdge( p3, p7);
TopoDS_Edge e8 = BRepBuilderAPI_MakeEdge( p4, p8);
TopoDS_Edge e9 = BRepBuilderAPI_MakeEdge( p8, p5);
TopoDS_Edge e10= BRepBuilderAPI_MakeEdge( p5, p6);
TopoDS_Edge e11= BRepBuilderAPI_MakeEdge( p6, p7);
TopoDS_Edge e12= BRepBuilderAPI_MakeEdge( p7, p8);

TopoDS_Wire w1 = BRepBuilderAPI_MakeWire(e1, e2, e3, e4);
TopoDS_Wire w2 = BRepBuilderAPI_MakeWire(e5, e10,e6, e2);
TopoDS_Wire w3 = BRepBuilderAPI_MakeWire(e6, e11,e7, e3);
TopoDS_Wire w4 = BRepBuilderAPI_MakeWire(e7, e12, e8, e4);
TopoDS_Wire w5 = BRepBuilderAPI_MakeWire(e8, e9, e5, e1);
TopoDS_Wire w6 = BRepBuilderAPI_MakeWire(e12,e11,e10,e9);

TopoDS_Face f1 = BRepBuilderAPI_MakeFace(w1);
TopoDS_Face f2 = BRepBuilderAPI_MakeFace(w2);
TopoDS_Face f3 = BRepBuilderAPI_MakeFace(w3);
TopoDS_Face f4 = BRepBuilderAPI_MakeFace(w4);
TopoDS_Face f5 = BRepBuilderAPI_MakeFace(w5);
TopoDS_Face f6 = BRepBuilderAPI_MakeFace(w6);

BRepOffsetAPI_Sewing sew(0.1);

TopoDS_Shape obj = sew.SewedShape();

This code appears to produce a shape that is solid -but- when I perform a boolean operation on it against another object ( a cylinder ) I get a result where each of the faces appears to have been considered as a solid in the boolean operation rather than the object being considered as one unified solid.  
If I substitute my generated shape for a BRepPrimAPI_MakeBox instead my code works as expected and the cube is treated as a complete solid.

So I think I am missing a step. After sewing my shape up what do I need to do to ensure it is a unified solid?

 I've attached two images. One of the sewed shape in a boolean with a cylinder and the other of a BRepPrimAPI_MakeBox against the same cylinder. 


Damien Towning's picture

Updated images

Damien Towning's picture

Figured it out.
To get a solid out of this I then had to do : 

obj = sew.SewedShape();

BRepBuilderAPI_MakeSolid brep_solid(TopoDS::Shell(obj));

TopoDS_Solid top_solid = brep_solid.Solid();

Though it appears either my solid is inverted or something else is going on since in my example booleans are inverted. Union makes a hole. Difference unions the two objects together :/ 

hedzerdurksz_146270's picture

Dear Daniel,

I have the same problem as you, after making a solid from shells using the code you provided, the solid appears to be inverted.

Did you manage to solve this?