HOW TO GET face of the shape?

I have a code:
BRepPrimAPI_MakeCylinder MKCyl(r, h);
TopoDS_Shape cyl = MKCyl.Shape();
...
BRepBuilderAPI_Transform aBRepTrsf(cyl, aTrsf);//some transformation
cyl = aBRepTrsf.Shape();

How can i get face of shape cyl?
I tryed to use:
TopoDS_Face face=TopoDS::Face(cyl); but it does not work,leading to a breakpoint.What can I do?

Forum supervisor's picture

Hi Giogii,
Use for this TopExp_Explorer.
Take into account that the mentioned cylinder
has 3 faces (bottom, top and lateral).
Regards

Gigoga's picture

Sorry,but i don't get how to use it,where can i find tutorial or smth.

Dennis G.'s picture

Try this:

TopoDS_Shape cyl = MKCyl.Shape();
...
TopoDS_Face cylindricalFace;

for( TopExp_Explorer ex(cyl, TopAbs_FACE); ex.More(); ex.Next() )
{
TopoDS_Face currentFace = TopoDS::Face( ex.Current() );
BRepAdaptor_Surface brepAdaptorSurface( currentFace,Standard_True );

if( brepAdaptorSurface.GetType() == GeomAbs_Cylinder )
{
// be happy
cylindricalFace = currentFace;
break;
}
}

Cheers,

Dennis

Gigoga's picture

Thank you!!