I am trying to chamfer using BRepFilletAPI_MakeChamfer and by selecting the edges to chamfer with the mouse. My code is given below:

BRepFilletAPI_MakeChamfer MakeChamfer(Shape);
for(pContext->InitSelected(); pContext->MoreSelected(); pContext->NextSelected())
Edge = TopoDS::Edge(pContext->SelectedShape());

TopoDS_Shape NewShape;
NewShape = MakeChamfer.Shape();

My problem is that the Add() function needs the face on which the edge lies. I cannot seem to find a way to get the face containing the edge that I have selected. Since my chamfer distances are equal it does not matter which of the two faces I get. Any one will do.

Any suggestions?

Rob Bachrach's picture

Try calling:

TopExp::MapShapesAndAncestors(Shape, TopAbs_EDGE, TopAbs_FACE, mapEdgeFace);

This will fill mapEdgeFace with a map of edges to lists of shapes (faces) connected to them. Then, you can just pick the first face attached to the edge.

Ivy Monteiro's picture


I am new to this forum. I am trying to use the BRepFilletAPI_MakeChamfer API to create a Top bevel on a flat plate. I have attached image for better explanation.

If the plate thickness = 10 and Bevel angle = 45 then using the AddDA API to get a top bevel I input an edge, give the swarf face as input and Distance = 10 and Angle =45.

But for some reason the BRepFilletAPI_MakeChamfer.Shape API throws exception and fails to create chamfer.

Observation : In case I imput Distance = 9.9999 then the API seems to work. But this would leave a small area face somewhere in the body which I do not want.

Can I get some help on this please?