Endless loop in method BRepClass3d_Solidexplorer::OtherSegment

Our application faces a great lot of data imported from IFC file which are produced from various CAD systems.
And few days ago, we got an IFC file. When we handle that IFC file by calling BRepAlgoAPI_Common and BRepAlgoAPI_Cut, we met an endless loop.

After debug, we found it is in method BRepClass3d_Solidexplorer::OtherSegment, line 554, myParamOnEdge*=0.5.
myParamOnEdge is decreased a half evey time. If the "return" sectence never meet before it, this value will be decreased to 0.000000000000. And then it will never change. So endless loop produced.

My modification:
line 554: else if(myParamOnEdge > Precision::Confusion()) myParamOnEdge*=0.5;
line 555: else{break;}

The endless loop can be fixed by the above modification.
But Precision::Confusion() = 1e-7, it is too small, start from 0.9 decrease to this value need 24 times. It will costs a lot of time to run the "while" loop 24 times.
Is there a better reasonalbe value to replace Precision::Confusion()? Actually, I don't know the source codes
very well.

Please suggest me a better value, thanks!

Forum supervisor's picture

Dear xumingstar,
We would be pleased to get from you a short description (and data...)
which would allowed us to reproduce the mentioned case.

xumingstar's picture

Thanks for your reply.

Actually, I want to post some data too. But my situation is I cannot copy anything to internet. When I have a way to post the data, I will.

What we want to do is:
1. Construct the shape using the data from IFC file.
2. Do "Cut" operation: using the openings to cut it parent.
For instance, I have a wall, there is an opening/hole on it which is usually use to place a window or door. But in an IFC file, the wall actually has no hole, it holds the shape before placing a window. It only holds the relationship with its opening which will be used to "Cut" this wall. If no cut, the window cannot be seen when display them, it is hidded by its parent wall.

In a great lot of "Cut", for that IFC file, it meet the endless loop.

And may be not the source code causes the dead loop, it is possible to come out from our wrong previous logic. So I don't know whether it can reproduce only by the data.

Currently, I only want some suggention from logic only. To get a reasonable comparsion value to come out the endless "while" loop when that variable is not helpful to keep/try some values very close to 0.0000000000000. And avoid to do the "while" loop so much times with no any good but waste time. I have thought maybe 0.01 is enough.

For the logic, when that variable comes to 0.00000000000, it must be into an endless loop situation, in my opinion.

Thanks in advance!

xumingstar's picture

Or a simple test, what will happen if we init that variable to 0.00000000000, endless loop?

xumingstar's picture

Cauchy Ding met this endless loop too, then his data may be helpful.


xumingstar's picture

Test data added.
- MS Windows 7 Win32 & VC9, OpenCASCADE 6.5.1, precision is by default.
Test method: TestOCCAPI method.txt
Test data: "Void.brep" cut "Positive.brep" cause endless loop.
Test data: "Void1.brep" cut "Positive.brep" can not get good result.

I don't know whether it is still exists using OpenCASCADE's newest source codes.

Please help me to check, thanks!

Forum supervisor's picture

Dear xumingstar,
I would like to inform you that the posted problem is checked and reproduced as for
endless loop case as for incorrect (& not valid shape) result.
The corresponding issues with ID = 22793 (endless loop case) and ID = 22794 (not valid case) have been registered.
Later you can know if the issues are resolved by checking references to the specified IDs in OCCT Release Notes. The analysis of the issues will take some time depending on our technical capability and availability of resources.
If you can't wait and the problem is urgent for you, you may contact us via Contact Form http://www.opencascade.org/about/contacts/.
We will try to find a solution/workaround acceptable for you.