
Mon, 07/24/2023 - 16:48
Hi,
I have an edge, which is basically 1/2 of a circle. It is located at the plane Z = 1.0
When using both cited methods with bounds (0 to PI) they both return the correct x ynd y coordinates.
The z coordinate, however, is translated by 1.0, at z=0.
Am I missing something here? This happens with a geometry created within the same cpp file.
If I export and read the same geometry as an IGES file the projection works.
It seems exporting corrects something in the TopoDS_Edge object, that was not done when working on the object.
The code used:
Handle(Geom_Curve) a_curve;
TopLoc_Location loc;
Standard_Real first_u = 0;
Standard_Real last_u = 0;
a_curve = BRep_Tool::Curve(TopoDS::Edge(an_edge), loc, first_u, last_u);
gp_Pnt new_pnt;
Standard_Real param = 0;
auto var = GeomAPI_ProjectPointOnCurve(a_pnt, a_curve, first_u, last_u );
auto nbpnt = var.NbPoints();
auto pnt = var.Point(1);
const Standard_Real projected = ShapeAnalysis_Curve().Project(a_curve, a_pnt, Precision:.Confusion(), new_pnt, param, first_u, last_u, false);
Tue, 07/25/2023 - 16:47
An Update: It seems the location is not passed correctly by BRep_Tool::Curve
While the edge contains the correct gp_pnt location, the location of the curve is loc = 0,0,0
The function, however, returns the correct location explicitly. So, my guess is, I should set the location of the Geom_Curve based on the returned location from the BRep_Tool::Curve.
PS.: Found this post
https://dev.opencascade.org/content/bezier-curve-loses-poles-if-created-...
It is important to work with the copy of the Geom_Curve, otherwise correcting the location and axis messes up with the TopoDS_Edge.
Wed, 07/26/2023 - 00:19
Of course, if the location object returned with the curve has a non-identity transformation you should use it to transform points got from this curve.
Wed, 07/26/2023 - 17:12
This was not clear to me, is it somewhere in the documentation?
This behaviour, however, is not always consistent.
When dealing with shapes read from IGES the Geom_Curve has both correct position and axis and the transformation of the point is not necessary.
Transforming the point will result in the wrong result.
In the end, for the algorithm to work as intended I only apply the transformation if the resulting point is outside the bounding box of the TopoDS_Shape.
Wed, 07/26/2023 - 22:01
I don't know if it is explained in documentation, but it follows from the principles of shape data structures used in OCCT. Any geometry (curve or surface) can be shared by several topology entities (edge or face), so that to be repeated with another location.
If it does not work for you, it means there is something wrong with your CAD file or with your code.