View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0026378 | Community | OCCT:Foundation Classes | public | 2015-06-29 14:19 | 2016-03-28 16:16 |
| Reporter | BenjaminBihler | Assigned To | bugmaster | ||
| Priority | low | Severity | major | ||
| Status | closed | Resolution | no change required | ||
| Platform | Linux | OS | Debian 6.0 | ||
| Product Version | 6.7.1 | ||||
| Summary | 0026378: Curve tangent computed with D1 has wrong direction | ||||
| Description | When computing the tangents of curves with D1, sometimes the direction is wrong. In the example that I have attached, the direction at LastParameter() seemes flipped. | ||||
| Steps To Reproduce | Please check the attached STEP file. It contains one wire. I created tangents along this wire with the following code: ---------------------------------------------------------------------- Handle(BRepAdaptor_HCompCurve) wireAdaptor = new BRepAdaptor_HCompCurve(wire); double parameter = wireAdaptor->FirstParameter(); while( parameter <= wireAdaptor->LastParameter()) { gp_Pnt point; gp_Vec tangent; wireAdaptor->D1(parameter, point, tangent); tangent.Normalize(); Business::Visualizer::getInstance()->visualizePoint(point); Business::Visualizer::getInstance()->visualizeVector(point, tangent); parameter +=0.01; } gp_Pnt point; gp_Vec tangent; wireAdaptor->D1(wireAdaptor->LastParameter(), point, tangent); tangent.Normalize(); Business::Visualizer::getInstance()->visualizePoint(point); Business::Visualizer::getInstance()->visualizeVector(point, tangent); ---------------------------------------------------------------------- Business::Visualizer::getInstance()->visualize... creates a vertex or an edge from the given objects and adds them to ther interactive context. All tangents point into the same direction except the last one, which points towards the smaller interpolation parameters. | ||||
| Tags | No tags attached. | ||||
| Test case number | |||||
|
|
|
|
|
The issue is quite old, but the problem still exists. To ease debugging I have rewritten the test code. I hope that helps: #include <TopoDS_Wire.hxx> #include <TopoDS_Edge.hxx> #include <TopoDS.hxx> #include <STEPControl_Reader.hxx> #include <Precision.hxx> #include <TopExp_Explorer.hxx> #include <BRepAdaptor_HCompCurve.hxx> #include <BRepBuilderAPI_MakeWire.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 edge; for (const auto& shape : shapes) { std::cout << "Searching edges." << std::endl; for (TopExp_Explorer edgeExplorer(shape, TopAbs_EDGE); edgeExplorer.More(); edgeExplorer.Next()) { edge = TopoDS::Edge(edgeExplorer.Current()); std::cout << "Edge found." << std::endl; break; } } if (edge.IsNull()) { std::cout << "Edge not found." << std::endl; return 1; } BRepBuilderAPI_MakeWire wireMaker; wireMaker.Add(edge); TopoDS_Wire wire = wireMaker.Wire(); Handle(BRepAdaptor_HCompCurve) wireAdaptor = new BRepAdaptor_HCompCurve(wire); gp_Pnt dummyPoint; gp_Vec tangentAtStopPoint; gp_Vec tangentBeforeStopPoint; wireAdaptor->D1(wireAdaptor->LastParameter(), dummyPoint, tangentAtStopPoint); wireAdaptor->D1(wireAdaptor->LastParameter() - 0.01, dummyPoint, tangentBeforeStopPoint); const double angle = tangentAtStopPoint.Angle(tangentBeforeStopPoint); std::cout << "Angle: " << angle << std::endl; if (angle > M_PI / 2.0) { std::cerr << "ERROR: the tangent is flipped." << std::endl; std::cout << "Tangent at stop point: " << tangentAtStopPoint.X() << ", " << tangentAtStopPoint.Y() << ", " << tangentAtStopPoint.Z() << std::endl; std::cout << "Tangent before stop point: " << tangentBeforeStopPoint.X() << ", " << tangentBeforeStopPoint.Y() << ", " << tangentBeforeStopPoint.Z() << std::endl; } else { std::cout << "Everything is alright." << std::endl; } return 0; } |
|
|
I have realized that erroneously I have entered "[OCCT] 6.7.1" as product version. Is this the reason why this issue is not considered? May I emphasize that this is still a problem? Since computing derivatives of curves is very central, this issue seems really important to me. |
|
|
This curve has a flipping at the end. You can see it in the snapshot made in Draw. I have zoomed in the view so that to see the very end of the curve. So, D1 is calculated right in this case. |
|
2016-03-23 11:23 developer |
curve.PNG (19,277 bytes) |
|
|
Thank you very much for your answer. You are right, it seems as something went wrong during curve construction, but everything was fine with the tangent computation. I am sorry for the erroneous issue report. |
|
|
Dear bugmaster, please close this bug, no changes are required. |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2015-06-29 14:19 | BenjaminBihler | New Issue | |
| 2015-06-29 14:19 | BenjaminBihler | Assigned To | => abv |
| 2015-06-29 14:19 | BenjaminBihler | File Added: curve.stp | |
| 2016-02-03 11:45 | BenjaminBihler | Note Added: 0050376 | |
| 2016-03-22 17:25 | BenjaminBihler | Note Added: 0051857 | |
| 2016-03-23 07:11 |
|
Assigned To | abv => msv |
| 2016-03-23 11:23 |
|
Note Added: 0051868 | |
| 2016-03-23 11:23 |
|
Status | new => feedback |
| 2016-03-23 11:23 |
|
File Added: curve.PNG | |
| 2016-03-24 15:56 | BenjaminBihler | Note Added: 0051965 | |
| 2016-03-24 18:35 |
|
Note Added: 0051967 | |
| 2016-03-24 18:35 |
|
Assigned To | msv => bugmaster |
| 2016-03-24 18:35 |
|
Priority | normal => low |
| 2016-03-24 18:35 |
|
Resolution | open => no change required |
| 2016-03-28 16:16 | bugmaster | Status | feedback => closed |