MantisBT
Mantis Bug Tracker Workflow

View Revisions: Issue #27565 All Revisions ] Back to Issue ]
Summary 0027565: [Regression to OCCT 7.0.0] Number of Intersections Is Wrong
Revision 2016-06-03 20:37 by aml
Steps To Reproduce 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
Revision 2016-06-02 19:13 by BenjaminBihler
Steps To Reproduce 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;
}


Copyright © 2000 - 2020 MantisBT Team
Powered by Mantis Bugtracker