Project an edge over a curved surface

My goal seems to be easy to develop, but I cannot get it. Also, my doubts do not help me.

Ok, I have got two planar faces (wall and roof, again). User can pick point over the faces defining a wire and maybe there are transitions along the faces. To calculate the point on the edge that join the wall and the roof is easy when the wire goes from one to another plane. But sometimes that join is not an edge but a circular plane (fillet).
This is when I have to project an edge (one point from one face and the other point from the other face) to that plane, and this is what I want to achieve.

For doing so, I am trying with this code, unsuccesfully.

BRepBuilderAPI_MakeWire mkWire;
Standard_Real first_p, last_p;
first_p = last_p = 0;
Handle(Geom_Curve) aCurve = GC_MakeSegment(prevVertex->GetPoint(), vertex->GetPoint());
Handle(Geom_Surface) aSurface = BRep_Tool::Surface(profile->GetFace(plane));
Handle(Geom_Curve) projection = GeomProjLib::Project(aCurve, aSurface);
mkWire.Add(BRepBuilderAPI_MakeEdge(projection, projection->FirstParameter(), projection->LastParameter()));
result = (mkWire.IsDone() == Standard_True);
if (result) joinWired = mkWire.Wire();

My doubts:
-How can I select projection direction? That data is not provided and I think a gp_Dir is neccesary. My results are too strange.
-How can I restrict the result to the original face? I think the key are the first and last parameters, but my results are going over my face limits (over the whole surface)

if doubt is not very clear, please tell me and I will provide some screenshots.

Kind regards

Kazumasa Uno's picture


The direction of projection is normal of the surface.
So you do not have to specify the gp_Dir.
You can see the picture below.

The closed curve(green) is projected on sphere (red curve).
The markers on the curve are also projected on shpere (red line).
The red lines pass the origin of sphere and these are the shortest path between the marker and the sphere.

arkoala's picture

Ok, you have given me some very good clues to know how the function is working and why I am not getting good results. But, even with that, I don't know how to manage it, because I am using a very special case of projection.

Rule 1: All the points are projected into the surface according with the normal in the surface.
Problem 1: My surface is a cylinder but normal vector to be used is not center-surface direction but surface-center direction. I want to project the line indoors. Is it that I have to change face orientation? I tried with Reverse but I get the same result.

Rule 2: Intermediate points will be calculated with the same rule previous defined. Your sample image show it very well thanks to point discretized.
Problem 2: But, what if I go accross the surface?

Then, I will have to manage result points over my original face, and not over my surface, but this will be another issue.

I give you an image that summarizes my environment, my aims and my projection case.

The solid is easy to see, a "L" extruded, with corner rounded. There are two lines projected drawn in blue (painted by hand)
Red lines are the result of the projection (what you see is what I get. I mean, the nearest projection result don't go more than you see).
Green lines are the union between initial and final line to the axis of the cylinder.

Free Image Hosting at www.ImageShack.usQuickPost

User can pick points over the vertical plane, and over the horizontal plane. And I have to calculate the polyline over the surface of the object.

Thank you