Anonymous | Login 2020-08-15 08:33 MSK Project: All Projects Community Open CASCADE
 My View | View Issues | Change Log | Roadmap

View Issue Details  Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0030722Community[OCCT] OCCT:Modeling Algorithmspublic2019-05-21 15:372019-08-12 18:01
ReporterBenjaminBihler
Assigned Toifv
PrioritynormalSeverityminor
StatusassignedResolutionopen
PlatformAOSLOS VersionL
Product Version[OCCT] 7.3.0
Target Version[OCCT] 7.5.0*Fixed in Version
Summary0030722: Modeling Algorithms - BRepExtrema_DistShapeShape computes wrong distances
DescriptionWhen computing the intersections of a wire and an edge, the result is wrong. Checking the wire's edges against the given edge shows that there is a major computation error.
Steps To ReproduceDraw script:

restore Wire.brep w
restore Edge.brep e
explode w
mkcurve c1 w_1
mkcurve c2 e
extrema c1 c2

Original steps:

#include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <TopoDS.hxx>
#include <Precision.hxx>
#include <TopExp_Explorer.hxx>
#include <BRepTools.hxx>
#include <BRep_Builder.hxx>
#include <BRepCheck_Analyzer.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>

#include <iostream>

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

TopoDS_Shape shape1;

TopoDS_Shape shape2;

TopoDS_Edge edge;
TopoDS_Wire wire;

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

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

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

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

BRepCheck_Analyzer edgeAnalyzer(edge);

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

BRepCheck_Analyzer wireAnalyzer(wire);

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

BRepExtrema_DistShapeShape distanceComputer;
distanceComputer.SetFlag(Extrema_ExtFlag_MIN);
distanceComputer.Perform();

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

if (2 != distanceComputer.NbSolution())
{
std::cout << "Two solutions are expected, but there are "
<< distanceComputer.NbSolution() << " solutions." << std::endl;
}

for (TopExp_Explorer edgeExplorer(wire, TopAbs_EDGE); edgeExplorer.More();
edgeExplorer.Next())
{
TopoDS_Edge wireEdge = TopoDS::Edge(edgeExplorer.Current());

BRepExtrema_DistShapeShape wireEdgeDistanceComputer;
wireEdgeDistanceComputer.SetFlag(Extrema_ExtFlag_MIN);
wireEdgeDistanceComputer.Perform();

double smallestDistance = std::numeric_limits<double>::max();

parameter <= adaptor.LastParameter(); parameter += 0.01)
{
BRepExtrema_DistShapeShape edgePointDistanceComputer;
edgePointDistanceComputer.SetFlag(Extrema_ExtFlag_MIN);

TopoDS_Vertex vertex = BRepBuilderAPI_MakeVertex(

edgePointDistanceComputer.Perform();

const double pointDistance = edgePointDistanceComputer.Value();

if (pointDistance < smallestDistance)
{
smallestDistance = pointDistance;
}
}

if (smallestDistance
< wireEdgeDistanceComputer.Value() - Precision::Confusion())
{
std::cout << "Error in distance computation: "
<< wireEdgeDistanceComputer.Value()
<< " has been computed but the distance is " << smallestDistance
<< " at most!" << std::endl;
}
}

return 0;
}
TagsNo tags attached.
Test case number
Attached Files Edge.brep (471 bytes) 2019-05-21 15:37
Wire.brep (7,620 bytes) 2019-05-21 15:37

 Relationships

 Notes BenjaminBihler (developer) 2019-05-21 15:41 There are quite a lot of similar issues like 0030164, 0030367, 0027087. After having been using Open CASCADE for several years, I would claim that BRepExtrema_DistShapeShape errors are a major quality issue of Open CASCADE. msv (developer) 2019-05-21 16:33 There is a real issue in extrema computation between the trimmed ellipse (first edge of the wire) and the trimmed line. It finds no solution, but must find the single solution. I have provided the Draw script in steps to reproduce.

 Issue History Date Modified Username Field Change 2019-05-21 15:37 BenjaminBihler New Issue 2019-05-21 15:37 BenjaminBihler Assigned To => msv 2019-05-21 15:37 BenjaminBihler File Added: Edge.brep 2019-05-21 15:37 BenjaminBihler File Added: Wire.brep 2019-05-21 15:41 BenjaminBihler Note Added: 0084508 2019-05-21 16:33 msv Note Added: 0084515 2019-05-21 16:34 msv Steps to Reproduce Updated View Revisions 2019-05-21 16:37 msv Assigned To msv => ifv 2019-05-21 16:37 msv Status new => assigned 2019-08-12 18:01 msv Target Version 7.4.0 => 7.5.0*