Detecting unusable results of BRepOffsetAPI_MakeFilling

Unfortunately, BRepOffsetAPI_MakeFilling often creates strange surfaces in more complex cases. The surfaces have strong undulations. I would like to be able to detect such cases in order to try the surface generation with different parameters or boundaries.
Does somebody have an idea how to detect it?

When I used BRepOffsetAPI_MakeFilling::G0Error(), I think it sometimes returns incorrect values.

In order to reproduce the problem you can use the following Draw script:
restore Basis-wire.brep b
explode b
restore Basis-plane.brep p
filling r 4 0 0 p b_1 0 b_2 0 b_3 0 b_4 0

In Debug mode Draw returns:
dist. max = 0.01596344026784044 ; angle max = 0 ; diffcurv max = 0
Temps de calcul : 0.17160110000000017

dist. max is the result of BRepOffsetAPI_MakeFilling::G0Error(), but I think it is much too low. When I measure the maximum distance with FreeCAD I get 0.337 (a screen shot is appended).

Is this a bug?

Generally, I would be glad if BRepOffsetAPI_MakeFilling would be more stable, but probably this is a difficulat task.
If somebody has ideas or experiences how to get better results, e.g. by tuning parameters or adhering to some requirements regarding the definition of constraints, it is also welcome.


Timo Roth's picture

Dear Forum supervisor,

can the result of G0Error() here considered to be a bug?
Should I report it on the bugtracker?


Forum supervisor's picture

Dear Timo,

It seems that the method BRepOffsetAPI_MakeFilling::G0Error() really returns rather rough estimation of the error. The value of the error that seems to be true is returned by methods
that get tolerance of a shape: in DRAW it is the command "tolerance":
filling r 4 0 0 p b_1 0 b_2 0 b_3 0 b_4 0
tolerance r

## -maximum tolerance on edges of "r" is about 0.45.

Indeed the algorithm BRepOffsetAPI_MakeFilling obtains bad results on contours that assume "swept" surface. Possible way out is to find a good initial surface:
pload ALL
restore Basis-wire.brep b
reducepcurves b
tclean b
settolerance b 1e-7
explode b

wire w1 b_1
wire w2 b_2
wire w3 b_3
wire w4 b_4

mksweep w2
setsweep -G w4 1 0
addsweep w3
addsweep w1
buildsweep q
explode q

filling r 4 0 0 q_1 b_1 0 b_2 0 b_3 0 b_4 0

With the swept surface "q_1" as initial surface, BRepOffsetAPI_MakeFilling
really obtains good result.


Timo Roth's picture

Thanks for the reply.

Your solution really obtains a good result. Until now, I thought the initial surface has to be a plane because once I experimented with bspline surfaces as initial surface and it did'nt work. Are there any restrictions regarding the type of the initial surface?

Regarding the tolerance-command:
On my system, I get a different result, which is much lower:
Draw[8]> tolerance r
Tolerance MAX=0.017559784294777007 AVG=0.010809105719812247 MIN=9.9999999999999995e-008
FACE : MAX=9.9999999999999995e-008 AVG=9.9999999999999995e-008 MIN=9.9999999999999995e-008
EDGE : MAX=1.0000000000000001e-005 AVG=1.0000000000000001e-005 MIN=1.0000000000000001e-005
VERTEX : MAX=0.017559784294777007 AVG=0.017559784294694902 MIN=0.017559784294624486
I'm using the official OCC 6.5.2 release on Win7 64 bit. Did you set special parameters for the filling command?
I'm appending the result of the original filling-operation (r.brep).

By the way, the command "reducepcurves", which you used in your solution, doesn't exist in OCC 6.5.2.