Project a wire on a Cylinderical surface giving incorrect result. BRepOffsetAPI_NormalProjection

Hi,

I want to project a wire into a cylinderical surface. I tried 3 ways:

  1. BRepOffsetAPI_NormalProjection
  2. BRepAlgo_NormalProjection
  3. BRepProj_Projection

(1) and (2) Using BRepOffsetAPI_NormalProjection and BRepAlgo_NormalProjection the resulting wires appears to be scaled down in the width but not the height, so probably it is not able to determine the normal correctly or that it works only with planar faces, but that is not mentioned in the docs.

(3) The projection works correctly but there are 2 issues: - The wire is projected on both sides of the cylinder - The docs says it works only with conical and cylindrical faces. I have not tested this on other faces yet but wanted to check if that's true.

My code is below, it is written in Opencascade.js but it should be the same:

  private test1(targetSurface: TopoDS_Face, wires: TopoDS_Wire[]) {
    const oc = getOC();

    try {

      const resultWires: TopoDS_Wire[] = [];
      for (const wire of wires) {
        const projector = new oc.BRepAlgo_NormalProjection(targetSurface);

        projector.Add(wire)

        projector.Build()

        if (!projector.IsDone()) {
          throw new Error("Projection algorithm failed");
        }

        const list = new oc.TopTools_ListOfShape()
        projector.BuildWire(list);
        resultWires.push(...shapeListToArray(list).map(s => oc.TopoDS.Wire(s)));
      }

      return resultWires;

    } catch (error) {
      throw new Error("Projection failed: " + error);
    }
  }

  private test2(targetSurface: TopoDS_Face, wires: TopoDS_Wire[]) {
    const oc = getOC();

    try {
      const resultWires: TopoDS_Wire[] = [];
      const dir = new oc.gp_Dir(0, 1, 0);
      for (const wire of wires) {
        const projector = new oc.BRepProj_Projection(wire, targetSurface, dir);

        if (!projector.IsDone()) {
          throw new Error("Projection algorithm failed");
        }

        const comp = projector.Shape();
        const newWires = findShapes(comp, oc.TopAbs_ShapeEnum.TopAbs_WIRE);
        resultWires.push(...newWires);
      }

      return resultWires;

    } catch (error) {
      throw new Error("Projection failed: " + error);
    }
  }