mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-26 13:50:33 +05:00
SplineInterpolation now works; refined some docstrings
This commit is contained in:
parent
f2c6a0f8c0
commit
a5aed39f9d
@ -2069,60 +2069,49 @@ tol : float
|
|||||||
|
|
||||||
)delimiter");
|
)delimiter");
|
||||||
|
|
||||||
// CRASHES BADLY during call of Curve()!
|
m.def("SplineInterpolation", [](py::object pnts, bool periodic, double tol) {
|
||||||
// m.def("SplineInterpolation", [](py::object pnts, bool periodic, double tol) {
|
Handle(TColgp_HArray1OfPnt) points = new TColgp_HArray1OfPnt(1, 1);
|
||||||
// cout << "enter" << endl;
|
if (py::extract<std::vector<gp_Pnt>>(pnts).check()) {
|
||||||
// TColgp_Array1OfPnt points(0, 0);
|
std::vector<gp_Pnt> pnt_list{py::extract<std::vector<gp_Pnt>>(pnts)()};
|
||||||
// cout << "points array exists" << endl;
|
points->Resize(1, pnt_list.size(), true);
|
||||||
// if (py::extract<std::vector<gp_Pnt>>(pnts).check()) {
|
for (int i = 0; i < pnt_list.size(); i++)
|
||||||
// std::vector<gp_Pnt> pnt_list{py::extract<std::vector<gp_Pnt>>(pnts)()};
|
points->SetValue(i+1, pnt_list[i]);
|
||||||
// points.Resize(1, pnt_list.size(), true);
|
} else if (py::extract<py::array_t<double>>(pnts).check()) {
|
||||||
// for (int i = 0; i < pnt_list.size(); i++)
|
py::array_t<double> pnt_array{py::extract<py::array_t<double>>(pnts)()};
|
||||||
// points.SetValue(i+1, pnt_list[i]);
|
if (pnt_array.ndim() != 2)
|
||||||
// } else if (py::extract<py::array_t<double>>(pnts).check()) {
|
throw Exception("`points` array must have dimension 2.");
|
||||||
// py::array_t<double> pnt_array{py::extract<py::array_t<double>>(pnts)()};
|
if (pnt_array.shape(1) != 3)
|
||||||
// if (pnt_array.ndim() != 2)
|
throw Exception("The second dimension must have size 3.");
|
||||||
// throw Exception("`points` array must have dimension 2.");
|
points->Resize(1, pnt_array.shape(0), false);
|
||||||
// if (pnt_array.shape(1) != 3)
|
auto pnts_unchecked = pnt_array.unchecked<2>();
|
||||||
// throw Exception("The second dimension must have size 3.");
|
for (int i = 0; i < pnt_array.shape(0); ++i)
|
||||||
// cout << "resize" << endl;
|
points->SetValue(i+1, gp_Pnt(pnts_unchecked(i, 0), pnts_unchecked(i, 1), pnts_unchecked(i, 2)));
|
||||||
// points.Resize(1, pnt_array.shape(0), true);
|
} else
|
||||||
// auto pnts_unchecked = pnt_array.unchecked<2>();
|
throw Exception("Not able to process the data type of points");
|
||||||
// for (int i = 0; i < pnt_array.shape(0); ++i)
|
|
||||||
// points.SetValue(i+1, gp_Pnt(pnts_unchecked(i, 0), pnts_unchecked(i, 1), pnts_unchecked(i, 2)));
|
GeomAPI_Interpolate builder(points, periodic, tol);
|
||||||
// cout << "values set" << endl;
|
builder.Perform();
|
||||||
// } else
|
return BRepBuilderAPI_MakeEdge(builder.Curve()).Edge();
|
||||||
// throw Exception("Not able to process the data type of points");
|
},
|
||||||
//
|
py::arg("points"),
|
||||||
// TColgp_HArray1OfPnt hpoints{points};
|
py::arg("periodic")=false,
|
||||||
// const auto _handle = opencascade::handle<TColgp_HArray1OfPnt>{&hpoints};
|
py::arg("tol")=1e-8,
|
||||||
// cout << "build" << endl;
|
R"delimiter(
|
||||||
// GeomAPI_Interpolate builder(_handle, periodic, tol);
|
Generate a piecewise continuous spline-curve interpolating a list of points.
|
||||||
// cout << "done" << endl;
|
|
||||||
// auto curve = builder.Curve();
|
Parameters
|
||||||
// cout << "curve done" << endl;
|
----------
|
||||||
// return BRepBuilderAPI_MakeEdge(curve);
|
|
||||||
//// return BRepBuilderAPI_MakeEdge(builder.Curve()).Edge();
|
points : List[gp_Pnt] or Tuple[gp_Pnt] or np.ndarray[double]
|
||||||
// },
|
List (or tuple) of gp_Pnt. If a numpy array is provided instead, the data must contain the coordinates
|
||||||
// py::arg("points"),
|
|
||||||
// py::arg("periodic")=false,
|
periodic : bool
|
||||||
// py::arg("tol")=1e-8,
|
Whether the result should be periodic
|
||||||
// R"delimiter(
|
|
||||||
//Generate a piecewise continuous spline-curve interpolating a list of points.
|
tol : float
|
||||||
//
|
Tolerance for the distance between points.
|
||||||
//Parameters
|
|
||||||
//----------
|
)delimiter");
|
||||||
//
|
|
||||||
//points : List[gp_Pnt] or Tuple[gp_Pnt] or np.ndarray[double]
|
|
||||||
// List (or tuple) of gp_Pnt. If a numpy array is provided instead, the data must contain the coordinates
|
|
||||||
//
|
|
||||||
//periodic : bool
|
|
||||||
// Whether the result should be periodic
|
|
||||||
//
|
|
||||||
//tol : float
|
|
||||||
// Tolerance for the distance between points.
|
|
||||||
//
|
|
||||||
//)delimiter");
|
|
||||||
|
|
||||||
|
|
||||||
m.def("SplineSurfaceApproximation", [](py::array_t<double> pnt_array,
|
m.def("SplineSurfaceApproximation", [](py::array_t<double> pnt_array,
|
||||||
@ -2182,7 +2171,7 @@ tol : float
|
|||||||
Tolerance for the distance from individual points to the approximating surface.
|
Tolerance for the distance from individual points to the approximating surface.
|
||||||
|
|
||||||
periodic : bool
|
periodic : bool
|
||||||
Whether the result should be periodic
|
Whether the result should be periodic in the first surface parameter
|
||||||
|
|
||||||
degen_tol : double
|
degen_tol : double
|
||||||
Tolerance for resolution of degenerate edges
|
Tolerance for resolution of degenerate edges
|
||||||
@ -2230,7 +2219,7 @@ approx_type : ApproxParamType
|
|||||||
Assumption on location of parameters wrt points.
|
Assumption on location of parameters wrt points.
|
||||||
|
|
||||||
periodic : bool
|
periodic : bool
|
||||||
Whether the result should be periodic
|
Whether the result should be periodic in the first surface parameter
|
||||||
|
|
||||||
degen_tol : double
|
degen_tol : double
|
||||||
Tolerance for resolution of degenerate edges
|
Tolerance for resolution of degenerate edges
|
||||||
|
Loading…
Reference in New Issue
Block a user