Is This a Bug in GeomAPI_ProjectPointOnCurve ?

Here's the test code.

int main()
auto edge = BRepBuilderAPI_MakeEdge(gp_Lin(gp::Origin(), gp::DX())).Edge();
gp_Trsf tfs;
tfs.SetTranslation(gp::Origin(), gp_Pnt(0,1000,0));
BRepAdaptor_Curve bc(edge);
GeomAPI_ProjectPointOnCurve ppc(gp::Origin(), bc.Curve().Curve());
auto resultPnt = ppc.NearestPoint();


The problem is resultPnt.Y() is 0, not 1000, which means the transformation of tfs doesn't influence GeomAPI_ProjectPointOnCurve's calculation. Is it a bug?

Forum supervisor's picture

Dear Tom,

Nearest point gives correct result:
## NearestPoint: X = 0 Y = 1000 Z = 0

So, it is not a bug. I suggest you to check it using Draw command

See for details file GeometryTest_APICommands.cxx which contains source code of the command.
Best regards

Thomas Rabenbauer's picture

My OCCT version is 6.7.1, I check over and over and still got the wrong result. I build the code with Visual Studio 2012, not using draw comand

Timo Roth's picture

I think your usage of BRepAdaptor_Curve is wrong. By accessing bc.Curve() the information about the translation is lost. The result is only a geometric object which does not know about the translation.
According to my understanding BRepAdaptor_Curve should only be used in methods where an Adaptor3D_Curve is expected.

Probably, your problem can be solved by not using an adaptor but accessing your geometrical curve and transforming it if needed. I found the following code for it in LocOpe_Spliter.Select:

GeomAPI_ProjectPointOnCurve proj;
C = BRep_Tool::Curve(edg,Loc,f,l);
if (!Loc.IsIdentity()) {
Handle(Geom_Geometry) GG = C->Transformed(Loc.Transformation());
C = *((Handle(Geom_Curve)*)&GG);


Thomas Rabenbauer's picture

Thx Timo, It helps me a lot!