How to "clean" a geometry for meshing

Hi everybody,

I'm quite new with occt, i'm sorry if my question if quite obvious. I want to consolidate a list of solids (here 5 boxes) up to get a "clean" geometry to mesh.

I found an old post and i try this piece of code which work pretty fine :

TopTools_ListOfShape shapes;
shapes.Append(BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 0), gp_Pnt(1, 20, 20)));
shapes.Append(BRepPrimAPI_MakeBox(gp_Pnt(1, 0, 0), gp_Pnt(3, 20, 20)));
shapes.Append(BRepPrimAPI_MakeBox(gp_Pnt(3, 0, 0), gp_Pnt(4, 20, 20)));
shapes.Append(BRepPrimAPI_MakeBox(gp_Pnt(0, 0, -3), gp_Pnt(20, 20, 0)));
shapes.Append(BRepPrimAPI_MakeBox(gp_Pnt(0, 0, -5), gp_Pnt(20, 20, -3)));

BRepAlgoAPI_BuilderAlgo builder;
TopoDS_Compound compound = TopoDS::Compound(builder.Shape());

STEPControl_Writer writerStep2;
writerStep2.Transfer(compound, STEPControl_AsIs);

But when i open the stp file with gmsh for instance, i get a lot of duplicated vertices/edges/faces. Is there an easy way to merge shared geometric objects ?


Thank you your help.

PS : Maybe using BRepAlgoAPI_BuilderAlg is not the best way to achieve a clean geometry.

TIAN DAJIANG's picture

You can try BRepTools::Clean(TopoDS_Shape);

BADI Hamid's picture

Hi Tian,

Unfortunately BRepTools::Clean does not give the expect result...

There is a lot of algorithms in occt for sewing, glueing, fixshell, unifydomain...but i can't see which would be an effective way to "consolidate" a geometry from a given set of solids which don't share any geometrical information (in term of vertex, edge and face), the only assumption is : solids are not overlapping each other.