Problem when creating a shape

Hi everyone, i need to create a shape that is similar to a section of a cone with parametric top and bottom radii, angles and heights. This is the code i use use to build it:

TopoDS_Face makeBaseFace(const gp_Ax2& refSys,
                        const Standard_Real bottomAngleDegrees,
                        const Standard_Real bottomRadius,
                        const Standard_Real bottomHeight,
                        const Standard_Real topAngleDegrees,
                        const Standard_Real topRadius,
                        const Standard_Real topHeight,
                        const gp_Pnt& p1,
                        const gp_Pnt& p2,
                        const gp_Pnt& p3,
                        const gp_Pnt& p4)
{
    // Compose the bottom arc
    gp_Circ bottomCirc(refSys, bottomRadius);
    GC_MakeArcOfCircle bottomArc(bottomCirc, p1, p4, true);

    // Compose the top arc
    gp_Circ topCirc(refSys, topRadius);
    auto loc = topCirc.Location();
    loc.SetZ(topHeight);
    topCirc.SetLocation(loc);
    GC_MakeArcOfCircle topArc(topCirc, p2, p3, true);

    auto& bottomCurve = bottomArc.Value();
    auto& topCurve = topArc.Value();

    // Compose the edges and the wire
    TopoDS_Edge edge1 = BRepBuilderAPI_MakeEdge(bottomCurve->StartPoint(), topCurve->StartPoint());
    TopoDS_Edge edge2 = BRepBuilderAPI_MakeEdge(topCurve);
    TopoDS_Edge edge3 = BRepBuilderAPI_MakeEdge(topCurve->EndPoint(), bottomCurve->EndPoint());
    TopoDS_Edge edge4 = BRepBuilderAPI_MakeEdge(bottomCurve);
    TopoDS_Wire wire = BRepBuilderAPI_MakeWire(edge1, edge2, edge3, edge4);

    ShapeConstruct_MakeTriangulation tri(wire, 0.0);
    auto shape = tri.Shape();

    TopoDS_Face F;
    for (TopExp_Explorer ex(shape, TopAbs_FACE); ex.More(); ex.Next())
    {
        F = TopoDS::Face(ex.Current());
    }
    return F;
}

The shape is created correctly but with some combination of the parameters that i used to build it, it shows some errors. The attached screenshots show how it behave with 90° as bottom radius and top radius:

  • 90° it's correct
  • 165° only a part of the shape is drawn
  • 180° only outer lines are displayed

Can you give me some hint of what's the problem? Thank you