View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0030367 | Community | OCCT:Modeling Algorithms | public | 2018-11-13 13:30 | 2023-08-01 15:06 |
Reporter | BenjaminBihler | Assigned To | |||
Priority | normal | Severity | minor | ||
Status | new | Resolution | open | ||
Platform | g++ | OS | Windows | ||
Product Version | 7.3.0 | ||||
Target Version | Unscheduled | ||||
Summary | 0030367: Modeling Algorithms - Distance Computation for Wire and Edge Gives Wrong Result | ||||
Description | The C++ program pasted into "Steps To Reproduce" computes the distance between an edge and a wire and compares it to the distances of the edge and wire start and stop points. The value computed by BRepExtrema_DistShapeShape is obviously too large. On my computer the output is: Computation has given a wrong result! The distance is computed as 1.06335, but it cannot be larger than 1. | ||||
Steps To Reproduce | #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 <BRepAdaptor_Curve.hxx> #include <BRepAdaptor_CompCurve.hxx> #include <BRepCheck_Analyzer.hxx> #include <iostream> int main(int, char**) { BRep_Builder builder; TopoDS_Shape shape1; BRepTools::Read(shape1, "Distance1.brep", builder); TopoDS_Shape shape2; BRepTools::Read(shape2, "Distance2.brep", builder); 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.LoadS1(wire); distanceComputer.LoadS2(edge); distanceComputer.Perform(); if (!distanceComputer.IsDone()) { std::cerr << "Calculation failed." << std::endl; exit(1); } const double distance = distanceComputer.Value(); BRepAdaptor_Curve edgeAdaptor(edge); BRepAdaptor_CompCurve wireAdaptor(wire); const double startPointDistance = edgeAdaptor.Value( edgeAdaptor.FirstParameter()).Distance( wireAdaptor.Value(wireAdaptor.FirstParameter())); const double stopPointDistance = edgeAdaptor.Value( edgeAdaptor.LastParameter()).Distance( wireAdaptor.Value(wireAdaptor.LastParameter())); const double mixedDistance1 = edgeAdaptor.Value(edgeAdaptor.LastParameter()).Distance( wireAdaptor.Value(wireAdaptor.FirstParameter())); const double mixedDistance2 = edgeAdaptor.Value(edgeAdaptor.FirstParameter()).Distance( wireAdaptor.Value(wireAdaptor.LastParameter())); const double alternativeDistanceValue = std::min( std::min(std::min(startPointDistance, stopPointDistance), mixedDistance1), mixedDistance2); if (alternativeDistanceValue < distance - Precision::Confusion()) { std::cerr << "Computation has given a wrong result!" << std::endl << "The distance is computed as " << distance << ", but it cannot be larger than " << alternativeDistanceValue << "." << std::endl; } return 0; } | ||||
Tags | No tags attached. | ||||
Test case number | |||||
Date Modified | Username | Field | Change |
---|---|---|---|
2018-11-13 13:30 | BenjaminBihler | New Issue | |
2018-11-13 13:30 | BenjaminBihler | Assigned To | => msv |
2018-11-13 13:30 | BenjaminBihler | File Added: Distance1.brep | |
2018-11-13 13:30 | BenjaminBihler | File Added: Distance2.brep | |
2019-08-12 17:45 |
|
Target Version | 7.4.0 => 7.5.0 |
2020-09-14 22:54 |
|
Target Version | 7.5.0 => 7.6.0 |
2021-08-29 18:51 |
|
Target Version | 7.6.0 => 7.7.0 |
2022-10-24 10:43 |
|
Target Version | 7.7.0 => 7.8.0 |
2023-08-01 15:06 | dpasukhi | Target Version | 7.8.0 => Unscheduled |