Problem with OCBRepFilletAPI_MakeFillet

Hi
I'm trying to make fillet between 2 linear edges. My code is below. After I call OCTopoDS_Shape connectedEdges = filleter.Shape() my program crashes. Could anybody tell me what might be the cause?

BRepBuilderAPI_MakeEdge edgeMaker1 = new BRepBuilderAPI_MakeEdge(new gp_Pnt(0, 0, 10), new gp_Pnt(0, 0, 50));

BRepBuilderAPI_MakeEdge edgeMaker2 = new BRepBuilderAPI_MakeEdge(new gp_Pnt(0, 10, 0), new gp_Pnt(0, 50, 0));

BRepFilletAPI_MakeFillet filleter = new BRepFilletAPI_MakeFillet(edgeMaker1.Shape(), ChFi3d_FilletShape.ChFi3d_Rational);

filleter.Add(30, edgeMaker1.Edge());
filleter.Add(30, edgeMaker2.Edge());

TopoDS_Shape connectedEdges = filleter.Shape(); // Program Crashes here

jelle's picture

Your 2 edges have no correlation topologically. Make a wire from you 2 edges and try again.

marek99's picture

Thank you for your reply. I made a wire from those 2 edges but it still dosen't work. HasResult and IsDone functions always return false. It looks like problem with add function of BRepFilletAPI_MakeFillet or maybe I'm doing something incorrect way? My code is below.

BRepBuilderAPI_MakeEdge edgeMaker1 = new BRepBuilderAPI_MakeEdge(new gp_Pnt(0, 0, 0), new gp_Pnt(10, 0, 0)); //
BRepBuilderAPI_MakeEdge edgeMaker2 = new BRepBuilderAPI_MakeEdge(new gp_Pnt(10, 0, 0), new gp_Pnt(10, 10, 0)); //
BRepBuilderAPI_MakeWire wireMaker = new BRepBuilderAPI_MakeWire();

wireMaker.Add(edgeMaker1.Edge());
wireMaker.Add(edgeMaker2.Edge());

BRepFilletAPI_MakeFillet filleter = new BRepFilletAPI_MakeFillet(wireMaker.Shape(), OCChFi3d_FilletShape.ChFi3d_Polynomial);

if (wireMaker.IsDone()) {

TopExp_Explorer explorer = new TopExp_Explorer(wireMaker.Shape(), TopAbs_ShapeEnum.TopAbs_EDGE, TopAbs_ShapeEnum.TopAbs_SHAPE);
for (; explorer.More(); explorer.Next()) {

TopoDS_Shape shape = explorer.Current();
if (shape.ShapeType() == TopAbs_ShapeEnum.TopAbs_EDGE) {
TopoDS_Edge edge = TopoDS.Edge(shape);
filleter.Add(3, edge);

}

}

}
int c = filleter.NbFaultyVertices(); // = 0

TopTools_ListOfShape lOS = filleter.Generated(wireMaker.Shape());
if (lOS.IsEmpty()) {
// list of generated shapes is empty
}

if (filleter.HasResult()/* Allwys returns false */) {
int b = 0;
}

if (filleter.IsDone()/* always returns false*/) {

userControl11.Display(new AIS_Shape(filleter.BadShape()));

userControl11.Display(new AIS_Shape(filleter.Shape())); //if outside this block makes program crashes
}

jelle's picture

If you look at BRepFilletAPI_LocalOperation from which Fillet inherits, you'll see that the operation is implemented for a shell, not mere edges:

BRepFilletAPI_LocalOperation Class Reference

Construction of fillets on the edges of a Shell.
.
#include

MakeFillet2d is even more clear:

Describes functions to build fillets and chamfers on the
vertices of a planar face.
Fillets and Chamfers on the Vertices of a Planar Face
A MakeFillet2d object provides a framework for:
- initializing the construction algorithm with a given face,
- acquiring the data characterizing the fillets and chamfers,
- building the fillets and chamfers, and constructing the
resulting shape, and
- consulting the result.
Warning
Only segments of straight lines and arcs of circles are
treated. BSplines are not processed.

-jelle

Inheritance diagram for BRepFilletAPI_LocalOperation: