View Issue Details

IDProjectCategoryView StatusLast Update
0025413CommunityOCCT:Modeling Algorithmspublic2014-11-12 09:54
Reporterllbatlle Assigned Tobugmaster  
PrioritynormalSeveritymajor 
Status closedResolutionfixed 
PlatformWindowsOSVC++ 2012 
Product Version6.5.3 
Target Version6.8.0Fixed in Version6.8.0 
Summary0025413: Line-Shape intersection algorithm became 400 times slower
DescriptionThe speed of the Line-Shape intersection (IntCurvesFace_ShapeIntersector) got reduced 400 times. In an application, we are intersecting many lines (parallel to Z axis) with a shape. We could do over 70000 lines per minute with OCC until 6.5.2, and since 6.5.3 (at least until the last 6.7 we have tried) we get only around 150 lines per minute.

Is it possible to get again the speed of 6.5.2?

I have seen this downgrade in speed in Linux and Windows, 32 and 64 bit, gcc and Visual Studio.
Steps To ReproduceMeasure the speed of IntCurvesFace_ShapeIntersector::Perform in OCC 6.5.2, and any later release.

The sample code:

#include <BRepBndLib.hxx>
#include <OSD_Timer.hxx>
#include <IntCurvesFace_ShapeIntersector.hxx>

static Standard_Integer test(Draw_Interpretor& di, Standard_Integer narg , const char** a)
{
  if (narg != 2) return 1;
  TopoDS_Shape aShape = DBRep::Get(a[1]);

  IntCurvesFace_ShapeIntersector Inter;
  Inter.Load(aShape, Precision::Confusion());

  Bnd_Box aBndBox;
  BRepBndLib::Add(aShape, aBndBox);

  gp_Dir aDir(0., 1., 0.);
  const int N = 250;
  Standard_Real xMin = aBndBox.CornerMin().X();
  Standard_Real zMin = aBndBox.CornerMin().Z();
  Standard_Real xMax = aBndBox.CornerMax().X();
  Standard_Real zMax = aBndBox.CornerMax().Z();
  Standard_Real xStep = (xMax - xMin) / N;
  Standard_Real zStep = (zMax - zMin) / N;

  OSD_Timer aTimer;
  aTimer.Start();
  for (Standard_Real x = xMin; x <= xMax; x += xStep)
    for (Standard_Real z = zMin; z <= zMax; z += zStep)
    {
      gp_Pnt aPoint(x, 0.0, z);
      gp_Lin aLine(aPoint, aDir);
      Inter.PerformNearest(aLine, -100., 100.);
    }
  aTimer.Stop();
  aTimer.Show();
  return 0;
}
TagsNo tags attached.
Test case numberbugs modalg_5(010) bug25413

Attached Files

  • 0025413.brep (3,309 bytes)

Activities

llbatlle

2014-10-23 12:01

reporter   ~0033617

I reported this to OCE. There I reported how I found the culprit to be in the introduction in 6.5.3 of bFlag code:
https://github.com/tpaviot/oce/blob/master/src/IntCurvesFace/IntCurvesFace_Intersector.cxx#L116

If bFlag is set always to true, the speed of 6.5.2 is restored. Andrei Betenev suggests that this change (and huge slowdown) was introduced related to the ticket id 023089, which I don't know.

Maybe the code can be reworked so it doesn't slowdown the intersection in ANY iges, and fixes only the calculation in the specific case of 023089?

llbatlle

2014-10-23 12:02

reporter   ~0033618

The ticket in OCE is: https://github.com/tpaviot/oce/issues/527

abv

2014-10-23 12:12

manager   ~0033620

Hello, do you have some data to test that (e.g. face and set of lines or direction to be used)? The result may depend strongly on the data used (e.g. if the surface is NURBS or elementary).

llbatlle

2014-10-23 13:29

reporter   ~0033636

Here you can pick an iges object. It doesn't run 400 times slower, but slower enough to show the problem. I have other pieces that exhibit the 400 times slower problem but I cannot share them.

I'll possibly keep the URL up only the next hours, so please pick it soon if you can:
https://84.89.61.89:49257/rbmdxo/piece-slow-intersection.7z

abv

2014-10-23 13:49

manager   ~0033638

I have downloaded the archive, but it contains really big shape. What kind of projections you do on it? Can you extract or indicate one face which would exhibit the problem, so that this can be tested more easily?

llbatlle

2014-10-23 14:10

reporter   ~0033639

A projection of the front view (with a 250x250 grid, so, some thousands of lines) exhibits the time problem I think. By projection, I mean intersecting lines ortogonal to the front view with the object, and taking note of the first intersection point.

git

2014-10-28 13:57

administrator   ~0033770

Branch CR25413 has been created by azv.

SHA-1: 3eab7d847dc320a2d8887fdf3424d3d4ad1a7d3d


Detailed log of new commits:

Author: azv
Date: Tue Oct 28 13:57:07 2014 +0300

    0025413: Line-Shape intersection algorithm became 400 times slower
    
    Changed the procedure of creating initial samples

azv

2014-10-28 13:58

administrator   ~0033771

Branch CR25413 is ready for review.
The procedure of generating initial samples for IntCurvesFace_Intersector was changed

git

2014-10-28 15:58

administrator   ~0033775

Branch CR25413 has been updated forcibly by azv.

SHA-1: 340d495b12b0fa92a2f2c175ada530f77e62798d

ifv

2014-10-28 16:20

developer   ~0033776

Ok

azv

2014-10-29 16:53

administrator  

0025413.brep (3,309 bytes)

azv

2014-10-29 16:58

administrator   ~0033843

I have prepared a sample code to reproduce the problem (see "Steps To Reproduce"). The attached shape produces very bad performance (approximately 1200 times slower without the fix).

git

2014-10-31 15:12

administrator   ~0033949

Branch CR25413 has been updated by apv.

SHA-1: 058d2b9e6f611ad9bbe01e3e251d202e5558254b


Detailed log of new commits:

Author: apv
Date: Fri Oct 31 15:12:22 2014 +0300

    Test-case for issue 0025413

apv

2014-10-31 15:15

tester   ~0033950

Dear BugMaster,

Branch CR25413 (and products from GIT master) was compiled on Linux, MacOS and Windows platforms and tested.
SHA-1: 340d495b12b0fa92a2f2c175ada530f77e62798d

Number of compiler warnings:
occt component:
   Linux: 18 (18 on master)
   Windows: 0 (0 on master)
products component:
   Linux: 11 (11 on master)
   Windows: 1 (1 on master)

Regressions/Differences:
Not detected

Testing cases:
bugs modalg_5(010) bug25413 - OK
http://occt-tests/CR25413-master-occt/Debian60-64/bugs/modalg_5/bug25413.html
http://occt-tests/CR25413-master-occt/Windows-32-VC10/bugs/modalg_5/bug25413.html

Testing on Linux:
Total MEMORY difference: 372473200 / 371808660
Total CPU difference: 45760.15000000018 / 48296.64000000005

Testing on Windows:
Total MEMORY difference: 276795272 / 273087684
Total CPU difference: 44756.046875 / 37050.84375

git

2014-11-12 09:54

administrator   ~0034340

Branch CR25413 has been deleted by inv.

SHA-1: 058d2b9e6f611ad9bbe01e3e251d202e5558254b

Related Changesets

occt: master 6fb3418e

2014-11-05 14:02:23

azv


Committer: bugmaster Details Diff
0025413: Line-Shape intersection algorithm became 400 times slower

Changed the procedure of creating initial samples

Test-case for issue 0025413
Affected Issues
0025413
mod - src/IntCurvesFace/IntCurvesFace_Intersector.cxx Diff File
mod - src/QABugs/QABugs_19.cxx Diff File
add - tests/bugs/modalg_5/bug25413 Diff File

Issue History

Date Modified Username Field Change
2014-10-22 16:26 llbatlle New Issue
2014-10-22 16:26 llbatlle Assigned To => ifv
2014-10-23 12:01 llbatlle Note Added: 0033617
2014-10-23 12:02 llbatlle Note Added: 0033618
2014-10-23 12:12 abv Note Added: 0033620
2014-10-23 13:29 llbatlle Note Added: 0033636
2014-10-23 13:49 abv Note Added: 0033638
2014-10-23 14:10 llbatlle Note Added: 0033639
2014-10-27 12:16 ifv Assigned To ifv => azv
2014-10-27 12:16 ifv Status new => assigned
2014-10-28 13:57 git Note Added: 0033770
2014-10-28 13:58 azv Note Added: 0033771
2014-10-28 13:58 azv Assigned To azv => ifv
2014-10-28 13:58 azv Status assigned => resolved
2014-10-28 15:58 git Note Added: 0033775
2014-10-28 16:20 ifv Note Added: 0033776
2014-10-28 16:20 ifv Assigned To ifv => bugmaster
2014-10-28 16:20 ifv Status resolved => reviewed
2014-10-28 16:25 apv Assigned To bugmaster => apv
2014-10-29 16:43 azv Steps to Reproduce Updated
2014-10-29 16:53 azv Steps to Reproduce Updated
2014-10-29 16:53 azv File Added: 0025413.brep
2014-10-29 16:58 azv Note Added: 0033843
2014-10-31 14:18 abv Target Version => 6.8.0
2014-10-31 15:12 git Note Added: 0033949
2014-10-31 15:15 apv Note Added: 0033950
2014-10-31 15:15 apv Assigned To apv => bugmaster
2014-10-31 15:15 apv Status reviewed => tested
2014-10-31 15:16 apv Test case number => bugs modalg_5(010) bug25413
2014-11-06 15:18 bugmaster Changeset attached => occt master 6fb3418e
2014-11-06 15:18 bugmaster Status tested => verified
2014-11-06 15:18 bugmaster Resolution open => fixed
2014-11-11 12:42 aiv Fixed in Version => 6.8.0
2014-11-11 13:03 aiv Status verified => closed
2014-11-12 09:54 git Note Added: 0034340