DiscussionsIssue archiveOCCT:Modeling Algorithms

Archived issue #0032949

Modeling Algorithms - Infinite loop in ShapeUpgrade_UnifySameDomain

CommunityOCCT:Modeling Algorithmsassigned12 public notes

Search issues

Description

Hi

ShapeUpgrade_UnifySameDomain tool sometimes goes into infinite loop. Upon further investigation, it turns out that in function
RelocatePCurvesToNewUorigin(), there are 3 nested for loops and CurEdge is not updated in following loop
for (;;) //collect pcurves of a contour
{
//HERE, edge is not found in theVEmap, but the same map contains CurEdge's vertices with some other edges in their list
RemoveEdgeFromMap(CurEdge, theVEmap);

...

//Following returns non-zero entries
const TopTools_ListOfShape& Elist = theVEmap.FindFromKey(CurVertex);
if (Elist.IsEmpty()) {
break; //end of contour in 3d
}

...

for (; itl.More(); itl.Next())
{
//in this, CurEdge is never updated, i.e. next edge is not found
}

//Loop continues. If we detect this condition and exit from this loop, things work
}

Boolean operation I was trying contained pipe like structure with another cylinder cut (with exactly same radius as inner radius of pipe). After the operation, tried to simplify the shape which caused this infinite loop.

Will appreciate if someone can take look and put an exit condition in these loops.

OCCT version 7.6, platform Ubuntu.

Thx

Steps to reproduce

Approximate steps to reproduce this.

1. Create a cylinder of radius say 15 and cut another cylinder of smaller radius say 10 to create a pipe like shape. Can also create a pipe directly
3. Cut another cylinder of radius 10 (this results in touching surfaces for boolean operations)
4. Call ShapeUpgrade_UnifySameDomain
5. Simplify goes into infinite loop - potentially due to some inaccuracies after boolean operation.

Will try to provide BREP's for testing - once I get time. Busy ATM

Public activity

12 archived notes

Participants are labeled by their role within this record.

01Commenter 1
I tried to reproduce it in draw using the following script:
pcylinder c1 15 20
pcylinder c2 10 20
bcut r1 c1 c2
pcylinder c3 10 20
bcut r2 r1 c3
unifysamedom r3 r2

But it works without any hanging.
So, the input shape is highly needed to reproduce the bug.
02Author
I will attach input shape. Pls examine all the exit criteria for the the loops mentioned above in the meanwhile.

Thx
03Commenter 1
Dear Commenter 1,

Do you have any updates concerning this issue?
It is impossible to find the root cause of the hang without the shape.
04Author
I have fixed it locally. I understand you need sample data to reproduce this. It is little challenging in my current environment setup. Will sure try.

Thx
05Commenter 5
To make a snapshot of the shape before unify same domain algorithm, just insert in your program the following code:
  BinTools::Write (aShape, "file.bbrep");

Then attach the produced shape file here. Thanks.
06Commenter 2
Hello Commenter 3, I can reproduce this issue with the attached shape file.
Attachment 2 (BBREP) (6,433 bytes)
07Commenter 4
08Commenter 4
Dear Commenter 5
Please review
Need to review and adapt this commit:
Attachment 1 (PATCH) (3,119 bytes)   
09Commenter 6
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: Commenter 7
Date: Mon Sep 18 16:49:06 2023 +0100

    0032949: Modeling Algorithms - Infinite loop in ShapeUpgrade_UnifySameDomain
    
    Problem occurs when InternalEdges is empty but the vertices from VV is not same.
    Added condition to stop the loop when InternalEdges is empty.
10Commenter 6
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
11Commenter 7
12Commenter 7
Represented earlier patch from user does not fix current problem.