fail to use BRepOffsetAPI_ThruSections to build a loft

When I use this function to generate a loft, if the constructed polygon is a concave polygon with a large concave angle, the loft will fail to be constructed. When I debug it, the program throws exception: Unhandled exception at 0x00007FFD7FB8CD29 (in MyOCCT.exe): Microsoft C++ exception: Standard_ConstructionError at memory location 0x000000DD480FDB70. Appeared. Who can help me. Thanks a lot. Below is my code:

vector<vector<float>> bottom={
    {0,0},
    {1,0},
    {0.5,2}};
vector<vector<float>> top = {
    {0,0},
    {0.5,1.0},
    {1,0},
    {0.5,2} };

int main()
{
    int bottom_z = 27, top_z = 28;
    BRepBuilderAPI_MakePolygon polygon;
    for (auto& p : top)
    {
        polygon.Add(gp_Pnt(p[0], p[1], bottom_z));
    }
    polygon.Close();
    cout << 1.0e-03 << endl;
    BRepOffsetAPI_ThruSections solid_generators(Standard_True);
    solid_generators.AddWire(polygon.Wire());
    BRepBuilderAPI_MakePolygon polygon_2;
    for (auto& p : bottom)
    {
        polygon_2.Add(gp_Pnt(p[0], p[1], top_z));
    }
    polygon_2.Close();
    solid_generators.AddWire(polygon_2.Wire());
    solid_generators.Build();
    TopoDS_Shape shape_1 = solid_generators.Shape();
    return 0;
}