MantisBT
Mantis Bug Tracker Workflow

View Revisions: Issue #27087 All Revisions ] Back to Issue ]
Summary 0027087: [Regression to OCCT 6.7.1] BRepExtrema_DistShapeShape gives wrong result
Revision 2020-03-24 15:55 by ifv
Steps To Reproduce Test case

bugs modalg_7 bug27087

Test uses input file bug27087.brep (attached)
Revision 2016-01-18 15:44 by BenjaminBihler
Steps To Reproduce Example 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;
}


Copyright © 2000 - 2020 MantisBT Team
Powered by Mantis Bugtracker