Don't need to specify string description of spline type in 2d geom

This commit is contained in:
Christopher Lackner 2021-01-26 11:27:46 +01:00
parent d1d3253408
commit b58c35831d

View File

@ -66,10 +66,12 @@ DLL_HEADER void ExportGeom2d(py::module &m)
.def("Append", FunctionPointer([](SplineGeometry2d &self, py::list segment, int leftdomain, int rightdomain,
optional<variant<int, string>> bc, optional<int> copy, double maxh,
double hpref, double hprefleft, double hprefright)
{
SplineSegExt * seg;
if(py::isinstance<py::str>(segment[0]))
{
auto segtype = py::cast<std::string>(segment[0]);
SplineSegExt * seg;
if (segtype == "line")
{
LineSeg<2> * l = new LineSeg<2>(self.GetPoint(py::cast<int>(segment[1])),
@ -85,6 +87,25 @@ DLL_HEADER void ExportGeom2d(py::module &m)
}
else
throw Exception("Appended segment is not a line or a spline3");
}
else
{
if(py::len(segment) == 2)
{
auto l = new LineSeg<2>(self.GetPoint(py::cast<int>(segment[0])),
self.GetPoint(py::cast<int>(segment[1])));
seg = new SplineSegExt(*l);
}
else if(py::len(segment) == 3)
{
SplineSeg3<2> * seg3 = new SplineSeg3<2>(self.GetPoint(py::cast<int>(segment[0])),
self.GetPoint(py::cast<int>(segment[1])),
self.GetPoint(py::cast<int>(segment[2])));
seg = new SplineSegExt(*seg3);
}
else
throw Exception("Appended segment must either have 2 or 3 points");
}
seg->leftdom = leftdomain;
seg->rightdom = rightdomain;
seg->hmax = maxh;