MantisBT - Community
View Issue Details
0029775Community[OCCT] OCCT:Modeling Datapublic2018-05-15 17:422018-06-29 21:18
BenjaminBihler 
abv 
normalminor 
closedfixed 
mingw-w64Windows7
[OCCT] 7.2.0 
[OCCT] 7.3.0[OCCT] 7.3.0 
Not needed
0029775: Modeling Data - BRepAdaptor_CompCurve Parameterization Is Incorrect
When I create a BRepAdaptor_CompCurve for a wire, the evaluations at the first and the last parameter do not return the first and the last position of the wire.

It could be that this issue has already been described here: https://www.opencascade.com/content/wrong-first-and-lastparameter-using-brepadaptorcompcurve [^] and it could be that issue "0005698: Inaccurate result of D0 method in BRepAdaptor_CompCurve" describes the same problem.

Please see the pasted code. It is especially surprising for me, that the start and stop point coordinates change, if I run the snippet several times.
// Define points
const gp_Pnt corner1(0.0, 100.0, 0.0);
const gp_Pnt point2(10.0, 100.0, 0.0);
const gp_Pnt point3(90.0, 100.0, 0.0);
const gp_Pnt corner4(100.0, 100.0, 0.0);
const gp_Pnt corner5(100.0, 0.0, 0.0);
const gp_Pnt corner6(0.0, 0.0, 0.0);
const gp_Pnt point7(0.0, 10.0, 0.0);
const gp_Pnt point8(0.0, 90.0, 0.0);

// Create wire
TopoDS_Wire wire;
BRep_Builder wireBuilder;
wireBuilder.MakeWire(wire);

wireBuilder.Add(wire, BRepBuilderAPI_MakeEdge(corner1, point2));
wireBuilder.Add(wire, BRepBuilderAPI_MakeEdge(point2, point3));
wireBuilder.Add(wire, BRepBuilderAPI_MakeEdge(point3, corner4));
wireBuilder.Add(wire, BRepBuilderAPI_MakeEdge(corner4, corner5));
wireBuilder.Add(wire, BRepBuilderAPI_MakeEdge(corner5, corner6));
wireBuilder.Add(wire, BRepBuilderAPI_MakeEdge(corner6, point7));
wireBuilder.Add(wire, BRepBuilderAPI_MakeEdge(point7, point8));

// Create an adaptor
const BRepAdaptor_CompCurve curve(wire);

// Get the first and the last point of the wire
const gp_Pnt startPoint = curve.Value(curve.FirstParameter());
const gp_Pnt stopPoint = curve.Value(curve.LastParameter());

// Check the points
if (startPoint.Distance(corner1) > Precision::Approximation())
{
  std::cout << "Error! Start point: " << startPoint.X() << ", "
    << startPoint.Y() << ", " << startPoint.Z() << std::endl;
}

if (stopPoint.Distance(point8) > Precision::Approximation())
{
  std::cout << "Error! Stop point: " << stopPoint.X() << ", "
    << stopPoint.Y() << ", " << stopPoint.Z() << std::endl;
}
No tags attached.
Issue History
2018-05-15 17:42BenjaminBihlerNew Issue
2018-05-15 17:42BenjaminBihlerAssigned To => msv
2018-05-15 18:16msvNote Added: 0075984
2018-05-15 18:16msvAssigned Tomsv => BenjaminBihler
2018-05-15 18:16msvStatusnew => feedback
2018-05-16 13:09gitNote Added: 0075990
2018-05-16 13:13BenjaminBihlerNote Added: 0075991
2018-05-16 13:13BenjaminBihlerAssigned ToBenjaminBihler => msv
2018-05-16 13:13BenjaminBihlerStatusfeedback => resolved
2018-05-16 15:13msvNote Added: 0075996
2018-05-16 15:15gitNote Added: 0075997
2018-05-16 15:16msvNote Added: 0075998
2018-05-16 15:16msvAssigned Tomsv => bugmaster
2018-05-16 15:16msvStatusresolved => reviewed
2018-05-23 12:05bugmasterNote Added: 0076151
2018-05-23 12:05bugmasterStatusreviewed => tested
2018-05-23 12:32bugmasterTest case number => Not needed
2018-05-24 06:48abvTarget Version7.4.0 => 7.3.0
2018-05-24 16:02abvChangeset attached => occt master 340549b0
2018-05-24 16:02abvAssigned Tobugmaster => abv
2018-05-24 16:02abvStatustested => verified
2018-05-24 16:02abvResolutionopen => fixed
2018-06-23 13:56gitNote Added: 0076949
2018-06-29 21:13aivFixed in Version => 7.3.0
2018-06-29 21:18aivStatusverified => closed

Notes
(0075984)
msv   
2018-05-15 18:16   
You create invalid wire. All edges in it are not connected to each other. CompCurve must work only on valid wires where all edges are connected to each other to make a chain.
(0075990)
git   
2018-05-16 13:09   
Branch CR29775 has been created by BenjaminBihler.

SHA-1: aa011b8906d55d6fe9dae730aefbb1a4ea731ff6


Detailed log of new commits:

Author: Benjamin Bihler
Date: Wed May 16 12:07:24 2018 +0200

    0029775: Modeling Data - BRepAdaptor_CompCurve Parameterization Is Incorrect
    
    Added vertex orientation requirement to class documentation of
    BRepAdaptor_CompCurve.

Author: Benjamin Bihler
Date: Wed May 16 11:59:15 2018 +0200

    0029775: Modeling Data - BRepAdaptor_CompCurve Parameterization Is Incorrect
    
    Added wire connectivity requirement to class documentation of
    BRepAdaptor_CompCurve.
(0075991)
BenjaminBihler   
2018-05-16 13:13   
Thank you very much, Mikhail. This was one of my problems. I haven't been aware of that requirement. In my real-life code I had also done the vertex orientation mistake which you have pointed to in issue 0029765.

In my humble opinition at least the first requirement should definitely be mentioned in the documentation of BRepAdaptor_CompCurve. Mentioning the other requirement might also not be wrong. I have made two commits with a documentation proposal.
(0075996)
msv   
2018-05-16 15:13   
Usually all modeling algorithms expect the shapes to be valid, at least in terms of the BRepCheck_Analyzer class. So, in general it is useless to put in documentation the statement that the input shape must be correct.

Nevertheless, I have no objection against the first commit. It sounds clear, though excess.
But the second one has ambiguous sense. It would be more right to say that the edges in the wire must also be correct. We can go much further with such explanations of requirements. But they will be so obvious that can make the reader puzzled "why is it written here?".
(0075997)
git   
2018-05-16 15:15   
Branch CR29775 has been updated forcibly by msv.

SHA-1: ccdf6a11937a57044bcf9a201d76bf6825719cd6
(0075998)
msv   
2018-05-16 15:16   
Reviewed.
No need to test, as only comments have been updated.
(0076151)
bugmaster   
2018-05-23 12:05   
Comments have been updated only
(0076949)
git   
2018-06-23 13:56   
Branch CR29775 has been deleted by kgv.

SHA-1: ccdf6a11937a57044bcf9a201d76bf6825719cd6