MantisBT - Community
View Issue Details
0027565Community[OCCT] OCCT:Modeling Algorithmspublic2016-06-02 19:132016-12-09 16:39
BenjaminBihler 
bugmaster 
normalminor 
closedfixed 
WindowsVC++ 201564 bit
[OCCT] 7.0.0 
[OCCT] 7.1.0[OCCT] 7.1.0 
bugs moddata_3 bug27565
0027565: [Regression to OCCT 7.0.0] Number of Intersections Is Wrong
The issue was introduced in revision e64622331f0d16e29689c51f3fff6be638af2092. Up to revision 264abd72f2508894ff6d514f2d9ff5c2443656f8 two intersections (solutions) have been reported for a given wire and edge. But now only one intersection is reported, even though there are obviously two intersections.
I will upload two files: Curve.stp and Wire.stp. If you run the following code, you will see the number of solutions(it should be two):

#include <TopoDS_Wire.hxx>
#include <TopoDS_Edge.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <TopoDS.hxx>
#include <STEPControl_Reader.hxx>
#include <Precision.hxx>
#include <TopExp_Explorer.hxx>

#include <string>
#include <vector>
#include <iostream>

std::vector<TopoDS_Shape> importStep(const std::string file)
{
    std::vector<TopoDS_Shape> shapes;

    STEPControl_Reader reader;

    IFSelect_ReturnStatus status = reader.ReadFile(file.c_str());

    if (status == IFSelect_RetDone)
    {
        //Interface_TraceFile::SetDefault();
        bool failsonly = false;
        reader.PrintCheckLoad(failsonly, IFSelect_ItemsByEntity);

        int rootsNumber = reader.NbRootsForTransfer();
        reader.PrintCheckTransfer(failsonly, IFSelect_ItemsByEntity);
        for (Standard_Integer rootIndex = 1; rootIndex <= rootsNumber; rootIndex++)
        {
            //bool ok =
            reader.TransferRoot(rootIndex);
            int shapesNumber = reader.NbShapes();
            if (shapesNumber > 0)
            {
                for (int shapeIndex = 1; shapeIndex <= shapesNumber; shapeIndex++)
                {
                    TopoDS_Shape shape = reader.Shape(shapeIndex);

                    shapes.push_back(shape);
                }
            }
        }
    }
    else
    {
        throw "Could not read in file.";
    }

    return shapes;
}

int main(int, char**)
{
    std::vector<TopoDS_Shape> shapes = importStep("Curve.stp");
    TopoDS_Edge curve1;

    for (const auto& shape : shapes)
    {
        std::cout << "Searching edges." << std::endl;

        for (TopExp_Explorer edgeExplorer(shape, TopAbs_EDGE, TopAbs_WIRE);
                edgeExplorer.More(); edgeExplorer.Next())
        {
            std::cout << "Edge found." << std::endl;
            curve1 = TopoDS::Edge(edgeExplorer.Current());
        }
    }

    shapes = importStep("Wire.stp");
    TopoDS_Wire curve2;

    for (const auto& shape : shapes)
    {
        std::cout << "Searching wires." << std::endl;

        for (TopExp_Explorer wireExplorer(shape, TopAbs_WIRE); wireExplorer.More();
                wireExplorer.Next())
        {
            std::cout << "Wire found." << std::endl;

            curve2 = TopoDS::Wire(wireExplorer.Current());
        }
    }

    std::cout << "Curve 1 is null: " << curve1.IsNull() << std::endl;
    std::cout << "Curve 2 is null: " << curve2.IsNull() << std::endl;

    BRepExtrema_DistShapeShape extremaShape(curve2, curve1, 1.0,
            Extrema_ExtFlag_MIN);

    extremaShape.Perform();

    if (!extremaShape.IsDone())
    {
        std::cerr << "Computation has failed." << std::endl;
    }

    std::cout << "There are " << extremaShape.NbSolution() << " solutions."
            << std::endl;

    return 0;
}

# Test bugs moddata_3 bug27565
No tags attached.
? Curve.stp (157,370) 2016-06-02 19:13
https://tracker.dev.opencascade.org/
? Wire.stp (180,450) 2016-06-02 19:13
https://tracker.dev.opencascade.org/
? bug27565.brep (203,676) 2016-06-03 20:06
https://tracker.dev.opencascade.org/
Issue History
2016-06-02 19:13BenjaminBihlerNew Issue
2016-06-02 19:13BenjaminBihlerAssigned To => msv
2016-06-02 19:13BenjaminBihlerFile Added: Curve.stp
2016-06-02 19:13BenjaminBihlerFile Added: Wire.stp
2016-06-02 19:20abvRelationship addedchild of 0027493
2016-06-02 19:21abvAssigned Tomsv => aml
2016-06-02 19:21abvStatusnew => assigned
2016-06-02 19:25abvNote Added: 0054654
2016-06-02 19:33BenjaminBihlerNote Added: 0054655
2016-06-03 20:06amlFile Added: bug27565.brep
2016-06-03 20:29gitNote Added: 0054704
2016-06-03 20:30gitNote Added: 0054705
2016-06-03 20:37amlNote Added: 0054706
2016-06-03 20:37amlAssigned Toaml => msv
2016-06-03 20:37amlStatusassigned => resolved
2016-06-03 20:37amlSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=13839#r13839
2016-06-04 01:06msvNote Added: 0054707
2016-06-04 01:06msvAssigned Tomsv => aml
2016-06-04 01:06msvStatusresolved => assigned
2016-06-06 10:07gitNote Added: 0054710
2016-06-06 10:09amlNote Added: 0054711
2016-06-06 10:09amlAssigned Toaml => msv
2016-06-06 10:09amlStatusassigned => resolved
2016-06-06 15:59msvNote Added: 0054734
2016-06-06 15:59msvAssigned Tomsv => bugmaster
2016-06-06 15:59msvStatusresolved => reviewed
2016-06-06 16:06apvAssigned Tobugmaster => apv
2016-06-08 14:28apvTest case number => bugs moddata_3 bug27565
2016-06-08 15:10apvNote Added: 0054802
2016-06-08 15:10apvAssigned Toapv => bugmaster
2016-06-08 15:10apvStatusreviewed => tested
2016-06-08 15:10apvNote Edited: 0054802bug_revision_view_page.php?bugnote_id=54802#r13860
2016-06-10 13:12bugmasterChangeset attached => occt master f84bf635
2016-06-10 13:12bugmasterStatustested => verified
2016-06-10 13:12bugmasterResolutionopen => fixed
2016-06-17 12:14gitNote Added: 0055149
2016-12-02 09:53msvRelationship addedrelated to 0028182
2016-12-09 16:30aivStatusverified => closed
2016-12-09 16:39aivFixed in Version => 7.1.0

Notes
(0054654)
abv   
2016-06-02 19:25   
Benjamin, please note that Extrema does not seek for intersections but for extremum, actually for the point of minimal distance. It can be quite expected for it to find single point, even if two objects have several extremums.

Alexander, could you please have a look?
(0054655)
BenjaminBihler   
2016-06-02 19:33   
Andrey, thanks for your hint. But if I use a large deflection value (like 1.0 in my example), doesn't that mean that I should get all local distance minima that are within a 1.0 surrounding of the global minimum?
(0054704)
git   
2016-06-03 20:29   
Branch CR27565 has been created by aml.

SHA-1: 548aa6ceb0bd314bc0dc53a3b746fd1d44c4147f


Detailed log of new commits:

Author: aml
Date: Fri Jun 3 20:08:00 2016 +0300

    0027565: [Regression to OCCT 7.0.0] Number of Intersections Is Wrong
    
    Incorrect tolerance management is fixed.
(0054705)
git   
2016-06-03 20:30   
Branch CR27565 has been updated forcibly by aml.

SHA-1: 71223613f4e46817f33a69910d398e598407e557
(0054706)
aml   
2016-06-03 20:37   
Dear msv,
I confirm the problem. The problem was inside of duplicates handling algorithm. Method "Upper" was used instead of "Last" ("Lower" instead of "First") in computation of a scale coefficient.

Please check current state of the CR27565 branch.
(0054707)
msv   
2016-06-04 01:06   
Fix is OK. Remark is to the test. It is better to extend functionality of the command distmini instead of adding a new QA command.
(0054710)
git   
2016-06-06 10:07   
Branch CR27565 has been updated forcibly by aml.

SHA-1: 673725507c65191774b2a470c3c1b3b198220e02
(0054711)
aml   
2016-06-06 10:09   
Dear msv,
Please check current state of the CR27565 branch.
(0054734)
msv   
2016-06-06 15:59   
Reviewed.
(0054802)
apv   
2016-06-08 15:10   
Dear BugMaster,

Branch CR27565 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested.
SHA-1: 673725507c65191774b2a470c3c1b3b198220e02

Number of compiler warnings:
occt component:
   Linux: 0 (0 on master)
   Windows: 0 (0 on master)
   MacOS: 0 (0 on master)
products component:
   Linux: 72
   Windows: 4
   MacOS: 1153

Regressions/Differences:
Not detected

Testing cases:
bugs moddata_3 bug27565 - OK
http://occt-tests/CR27565-master-OCCT/Debian70-64/bugs/moddata_3/bug27565.html [^]
http://occt-tests/CR27565-master-OCCT/Windows-64-VC10/bugs/moddata_3/bug27565.html [^]

Testing on Linux:
Total MEMORY difference: 89903262 / 88754430 [+1.29%]
Total CPU difference: 19741.00000000013 / 19850.559999999932 [-0.55%]

Testing on Windows:
Total MEMORY difference: 55951520 / 55967213 [-0.03%]
Total CPU difference: 18347.776813198805 / 18470.736801398853 [-0.67%]

(0055149)
git   
2016-06-17 12:14   
Branch CR27565 has been deleted by inv.

SHA-1: 673725507c65191774b2a470c3c1b3b198220e02