View Issue Details

IDProjectCategoryView StatusLast Update
0031319CommunityOCCT:Modeling Algorithmspublic2021-08-29 18:53
ReporterBenjaminBihler Assigned Tomsv  
PrioritynormalSeverityminor 
Status newResolutionopen 
PlatformAOSL 
Product Version7.4.0 
Target Version7.7.0 
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

  • Edge.brep (470 bytes)
  • Wire.brep (23,454 bytes)

Activities

BenjaminBihler

2020-01-24 12:34

developer  

Edge.brep (470 bytes)

BenjaminBihler

2020-01-24 12:34

developer  

Wire.brep (23,454 bytes)

BenjaminBihler

2020-01-27 14:13

developer   ~0090074

The described problem appears quite often with the given wire. If necessary I can show more edges whose intersections are partially missed.

msv

2020-01-27 17:18

developer   ~0090077

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
2021-08-29 18:53 msv Target Version 7.6.0 => 7.7.0