In case someone comes across this and has the same issue, this wasn't working because pcurves needed to be added for both of the new edges. It works fine for the box because the connected faces are planes, but the cylinder requires these to be fully defined. Here is the code in case anyone is interested.
try
{
Standard_Real length = 8.0;
Standard_Real radius = 2.0;
TopoDS_Solid cyl = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 0.1)), radius, length).Solid();
TopoDS_Face face = TopoDS::Face(OCCTUtils_GetFirstType(cyl, TopAbs_FACE));
TopoDS_Edge edge = TopoDS::Edge(OCCTUtils_GetFirstType(cyl, TopAbs_EDGE));
BRep_Builder builder;
Standard_Real pFirst, pLast;
Handle(Geom_Curve) curve = BRep_Tool::Curve(edge, pFirst, pLast);
gp_Pnt midPoint = curve->Value(pFirst + (pLast-pFirst)/2);
TopoDS_Vertex vStart, vEnd, vMiddle;
vStart = TopExp::FirstVertex(edge);
vEnd = TopExp::LastVertex(edge);
builder.MakeVertex(vMiddle, midPoint, Precision::Confusion());
TopoDS_Edge newEdge1 = BRepBuilderAPI_MakeEdge(curve, vStart, TopoDS::Vertex(vMiddle.Reversed()));
TopoDS_Edge newEdge2 = BRepBuilderAPI_MakeEdge(curve, vMiddle, TopoDS::Vertex(vEnd.Reversed()));
TopoDS_Wire wire;
builder.MakeWire(wire);
newEdge1.Orientation(TopAbs_REVERSED);
builder.Add(wire, newEdge1);
newEdge2.Orientation(TopAbs_REVERSED);
builder.Add(wire, newEdge2);
builder.UpdateEdge(newEdge1, new Geom2d_Line(gp_Pnt2d(0.0, length), gp_Dir2d(1,0)), face, Precision::Confusion());
builder.Range(newEdge1, face, 0, pFirst + (pLast-pFirst)/2);
builder.UpdateEdge(newEdge2, new Geom2d_Line(gp_Pnt2d(0.0, length), gp_Dir2d(1,0)), face, Precision::Confusion());
builder.Range(newEdge2, face, pFirst + (pLast-pFirst)/2, pLast);
Handle(ShapeBuild_ReShape) context = new ShapeBuild_ReShape();
context->Replace(edge, wire);
TopoDS_Shape output = context->Apply(cyl);
std::cout << std::endl << "Program finished normally" << std::endl;
}
catch (Standard_Failure)
{
Handle_Standard_Failure e = Standard_Failure::Caught();
std::cout << "OCC Error: " << e->GetMessageString() << std::endl;
}
catch (const std::exception &error)
{
std::cout << "My Error: " << error.what() << std::endl;
}