BRepBuilderAPI_MakeShell

Hello.

I am trying to make a shell from a number of faces, in order to make a solid object. But I am not able to find out how to make a shell!

Example code:

BRepOffsetAPI_Sewing sewedObj;

sewedObj.Add(face1);

sewedObj.Add(face2);

sewedObj.Add(face3);

sewedObj.Add(face4);

TopoDS_Shape newShape = sewedObj.SewedShape();

// Here I want to make a shell from newShape,

// but I do not understand how to do this!

// Maybe something like: BRepBuilderAPI_MakeShell(BRep_Tool::Surface(newShape));

// but this is not the correct format for the parameter.

BRepBuilderAPI_MakeSolid mySolid(newShell);

I hope someone can help me with this problem. Dag Magne Ulvang

Roman Lygin's picture

Hello.

Hope the following pieces of advice will help you.

> Hello.

> I am trying to make a shell from a number of
> faces, in order to make a solid object. But
> I am not able to find out how to make a
> shell!

> Example code:

> BRepOffsetAPI_Sewing sewedObj;

> sewedObj.Add(face1);

> sewedObj.Add(face2);

> sewedObj.Add(face3);

> sewedObj.Add(face4);

Here you must call Perform method to make a real sewing:

sewedObj.Perform();

> TopoDS_Shape newShape =
> sewedObj.SewedShape();

> // Here I want to make a shell from
> newShape,

> // but I do not understand how to do this!

> // Maybe something like:
> BRepBuilderAPI_MakeShell(BRep_Tool::Surface(newShape));

That's incorrect: your newShape is generally a TopoDS_Compound consisting of TopoDS_Shells, consisting in their turns, of TopoDS_Faces. And BRep_Tool::Surface is appliable for TopoDS_Face only and returns its underlying Geom_Surface.

The number of TopoDS_Shells depends on the geometry of your faces you added with sewedObj.Add and the tolerance your specified (or default one if you did not).

If you are sure that your faces should produce only one shell (i.e. they are adjacent within the tolerance), you may proceed as follows:

TopoDS_Shell newShell;

TopExp_Explorer anExp (newShape, TopAbs_SHELL);

if (anExp.More()) {

TopoDS_Shape aTmpShape = anExp.Current();

newShell = TopoDS::Shell (aTmpShape);

//here you make a solid as you did

BRepBuilderAPI_MakeSolid mySolid(newShell); }

If you expect several Shells from Sewing you may organize a loop like

for (; anExp.More(); an.Exp.Next()) { ... }

Best regards,

Roman

> // but this is not the correct format for
> the parameter.

> BRepBuilderAPI_MakeSolid mySolid(newShell);

> I hope someone can help me with this
> problem. Dag Magne Ulvang

Dag Magne Ulvang's picture

Hello Roman. This worked great and solved my problem. Thank you very much!

Best regards, Dag Magne Ulvang