MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0031319Community[OCCT] OCCT:Modeling Algorithmspublic2020-01-24 12:342020-09-15 12:36
ReporterBenjaminBihler 
Assigned Tomsv 
PrioritynormalSeverityminor 
StatusnewResolutionopen 
PlatformAOSLOS VersionL
Product Version[OCCT] 7.4.0 
Target Version[OCCT] 7.6.0*Fixed in Version 
Summary0031319: Modeling Algorithms - BRepExtrema_DistShapeShape won't find all intersections
DescriptionI have an example of a wire and an edge that intersect two times (with their intersection positions being far away from each other), but BRepExtrema_DistShapeShape finds only one of the intersections.

Please see the code in "Steps To Reproduce".
Steps To Reproduce#include <BRepAdaptor_CompCurve.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepCheck_Analyzer.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <BRepTools.hxx>
#include <BRep_Builder.hxx>
#include <Precision.hxx>
#include <ShapeFix_Edge.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx>

#include <iostream>

int main(int, char**)
{
    BRep_Builder builder;

    TopoDS_Wire wire;

    {
        TopoDS_Shape shape;
        BRepTools::Read(shape, "Wire.brep", builder);

        for (TopExp_Explorer wireExplorer(shape, TopAbs_WIRE); wireExplorer.More();
                 wireExplorer.Next())
        {
            wire = TopoDS::Wire(wireExplorer.Current());
            break;
        }

        if (wire.IsNull())
        {
            std::cerr << "Wire is null." << std::endl;
            exit(1);
        }

        BRepCheck_Analyzer wireAnalyzer(wire);

        if (!wireAnalyzer.IsValid())
        {
            std::cerr << "Wire is invalid." << std::endl;
            exit(1);
        }
    }

    TopoDS_Edge edge;

    {
        TopoDS_Shape shape;
        BRepTools::Read(shape, "Edge.brep", builder);

        for (TopExp_Explorer edgeExplorer(shape, TopAbs_EDGE); edgeExplorer.More();
                 edgeExplorer.Next())
        {
            edge = TopoDS::Edge(edgeExplorer.Current());
            break;
        }

        if (edge.IsNull())
        {
            std::cerr << "Edge is null." << std::endl;
            exit(1);
        }

        BRepCheck_Analyzer edgeAnalyzer(edge);

        if (!edgeAnalyzer.IsValid())
        {
            std::cerr << "Edge is invalid." << std::endl;
            exit(1);
        }
    }

    BRepExtrema_DistShapeShape distanceComputer;
    distanceComputer.SetFlag(Extrema_ExtFlag_MIN);
    distanceComputer.LoadS1(wire);
    distanceComputer.LoadS2(edge);
    distanceComputer.Perform();

    if (!distanceComputer.IsDone())
    {
        std::cerr << "Calculation failed." << std::endl;
        exit(1);
    }

    std::cout << "There are " << distanceComputer.NbSolution()
                        << " solutions, two solutions are expected!" << std::endl;

    return 0;
}
TagsNo tags attached.
Test case number
Attached Files? file icon Edge.brep (470 bytes) 2020-01-24 12:34
? file icon Wire.brep (23,454 bytes) 2020-01-24 12:34

- Relationships

-  Notes
(0090074)
BenjaminBihler (developer)
2020-01-27 14:13

The described problem appears quite often with the given wire. If necessary I can show more edges whose intersections are partially missed.
(0090077)
msv (developer)
2020-01-27 17:18

If we make the edge shorter (in bounds of the wire) then both solutions are found.
If we change the order of arguments then also both solutions are found.
It is obviously the bug in extrema algo.

- Issue History
Date Modified Username Field Change
2020-01-24 12:34 BenjaminBihler New Issue
2020-01-24 12:34 BenjaminBihler Assigned To => msv
2020-01-24 12:34 BenjaminBihler File Added: Edge.brep
2020-01-24 12:34 BenjaminBihler File Added: Wire.brep
2020-01-27 14:13 BenjaminBihler Note Added: 0090074
2020-01-27 17:18 msv Note Added: 0090077
2020-09-15 12:36 msv Target Version 7.5.0 => 7.6.0*


Copyright © 2000 - 2020 MantisBT Team
Powered by Mantis Bugtracker