MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0027087Community[OCCT] OCCT:Modeling Algorithmspublic2016-01-18 15:442017-12-05 17:08
ReporterBenjaminBihler 
Assigned Toaml 
PriorityhighSeverityminor 
StatusassignedResolutionopen 
PlatformWindowsOSVC++ 2012OS Version32bit
Product Version[OCCT] 7.0.0 
Target Version[OCCT] 7.4.0*Fixed in Version 
Summary0027087: [Regression to OCCT 6.7.1] BRepExtrema_DistShapeShape gives wrong result
DescriptionI have an example where an edge pierces through a shell, but BRepExtrema_DistShapeShape states the distance was 0.00760306. This is definitely wrong, the distance is zero.

It seems as if such errors happened especially, if an edge pierces through another edge with is the boundary of a face of the shell.
Steps To ReproduceExample program for the uploaded file:

#include <TopoDS_Shell.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 argc, char* argv[])
{
    std::vector<TopoDS_Shape> shapes = importStep("Distance.stp");

    TopoDS_Shell shellSurface;
    TopoDS_Edge connectingEdge;

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

        for (TopExp_Explorer shellExplorer(shape, TopAbs_SHELL);
                shellExplorer.More(); shellExplorer.Next())
        {
            shellSurface = TopoDS::Shell(shellExplorer.Current());
            std::cout << "Shell found." << std::endl;
            break;
        }

        std::cout << "Searching edges." << std::endl;

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

    BRepExtrema_DistShapeShape distanceComputer(shellSurface, connectingEdge,
            Precision::Intersection(), Extrema_ExtFlag_MIN);
    if (distanceComputer.IsDone())
    {
        std::cout << "Calculated Distance = " << distanceComputer.Value()
                << std::endl;
    }
    else
    {
        std::cout << "Calculation failed." << std::endl;
    }

    return 0;
}
TagsNo tags attached.
Test case number
Attached Files? file icon Distance.stp (229,973 bytes) 2016-01-18 15:44
? file icon bug27087.brep (9,221,501 bytes) 2016-05-09 11:44

- Relationships

-  Notes
(0053915)
BenjaminBihler (developer)
2016-05-09 10:08

I have tried the following to spot the error:
- played with BRepExtrema_DistShapeShape deflection values -> nothing changes
- changed the BRepExtrema_DistShapeShape algorithm -> nothing changes
- computed the distance of connectingEdge in my example code to every face and every edge of shellSurface -> I get no smaller value than 0.00760306

Therefore it seems to me, that BRepExtrema_DistShapeShape really computes the point pair with minimum distance, but somehow they are not computed precise enough. It misses the real minimum a little bit.

Is there anything more I can do to support your search for this error?
(0053916)
abv (manager)
2016-05-09 11:49
edited on: 2016-05-09 11:50

I confirm the problem (also tested in OCCT 6.8, 6.9.1). Here are steps to reproduce in DRAW (use file bug27087 attached):

pload MODELING
restore [locate_data_file bug27087.brep] a
explode a
distmini r a_1 a_2
if { [dval r_val] > 0.0001 } { puts "Error: too big deviation, should be 0!" }

The reported distance 0.0076 is actually the value computed between a_1 and boundary edge of a_2.
To see that curve (a_1, geometrically a line) actually does intersect a face (a_2, 20-th face from original model), show it in viewer and zoom:

pload VISUALIZATION
incmesh a 0.001
vdisplay a

(0053951)
aml (developer)
2016-05-10 15:02

The problem is inside of extrema Curve / Surface algorithm which does not take into account surface / curve complexity.
Number of samples is always 10 or 13 (for line curve too - 10 samples, instead of 3).

The proposed solution is to make number of samples adaptive according to the objects complexity.

This case is regression to 6.7.1.
(0055625)
David Austin (reporter)
2016-07-01 06:14

I have this issue too. Sphere to shape distances that should be reported as
zero are reported as a (random) small positive number.

- Issue History
Date Modified Username Field Change
2016-01-18 15:44 BenjaminBihler New Issue
2016-01-18 15:44 BenjaminBihler Assigned To => abv
2016-01-18 15:44 BenjaminBihler File Added: Distance.stp
2016-01-18 15:56 abv Assigned To abv => msv
2016-01-18 15:56 abv Category OCCT:Foundation Classes => OCCT:Modeling Algorithms
2016-05-09 10:08 BenjaminBihler Note Added: 0053915
2016-05-09 11:44 abv File Added: bug27087.brep
2016-05-09 11:49 abv Note Added: 0053916
2016-05-09 11:50 abv Note Edited: 0053916 View Revisions
2016-05-10 09:41 msv Assigned To msv => aml
2016-05-10 09:41 msv Status new => assigned
2016-05-10 14:54 msv Summary BRepExtrema_DistShapeShape gives wrong result => [Regression to OCCT 6.7.1] BRepExtrema_DistShapeShape gives wrong result
2016-05-10 15:02 aml Note Added: 0053951
2016-07-01 06:14 David Austin Note Added: 0055625
2016-10-28 16:32 msv Target Version 7.1.0 => 7.2.0
2017-07-21 11:34 msv Target Version 7.2.0 => 7.3.0
2017-10-09 11:39 abv Priority normal => high
2017-12-05 17:08 msv Target Version 7.3.0 => 7.4.0*


Copyright © 2000 - 2018 MantisBT Team
Powered by Mantis Bugtracker