returns mesh-data as Array (rather than std::vector)

This commit is contained in:
Joachim Schoeberl 2022-02-21 13:06:00 +01:00
parent eceb83171f
commit 1a44d665bb

View File

@ -1299,8 +1299,8 @@ project_boundaries : Optional[str] = None
.def("Mirror", &Mesh::Mirror) .def("Mirror", &Mesh::Mirror)
.def("_getVertices", [](Mesh & self) .def("_getVertices", [](Mesh & self)
{ {
std::vector<float> verts(3*self.GetNV()); // std::vector<float> verts(3*self.GetNV());
Array<float> verts(3*self.GetNV());
ParallelForRange( self.GetNV(), [&](auto myrange) { ParallelForRange( self.GetNV(), [&](auto myrange) {
const auto & points = self.Points(); const auto & points = self.Points();
for(auto i : myrange) for(auto i : myrange)
@ -1314,9 +1314,9 @@ project_boundaries : Optional[str] = None
}) })
.def("_getSegments", [](Mesh & self) .def("_getSegments", [](Mesh & self)
{ {
std::vector<int> output; // std::vector<int> output;
output.resize(2*self.GetNSeg()); // output.resize(2*self.GetNSeg());
Array<int> output(2*self.GetNSeg());
ParallelForRange( self.GetNSeg(), [&](auto myrange) { ParallelForRange( self.GetNSeg(), [&](auto myrange) {
const auto & segs = self.LineSegments(); const auto & segs = self.LineSegments();
for(auto i : myrange) for(auto i : myrange)
@ -1331,9 +1331,11 @@ project_boundaries : Optional[str] = None
{ {
const auto & topo = self.GetTopology(); const auto & topo = self.GetTopology();
size_t n = topo.GetNEdges(); size_t n = topo.GetNEdges();
/*
std::vector<int> output; std::vector<int> output;
output.resize(2*n); output.resize(2*n);
*/
Array<int> output(2*n);
ParallelForRange( n, [&](auto myrange) { ParallelForRange( n, [&](auto myrange) {
for(auto i : myrange) for(auto i : myrange)
{ {
@ -1346,9 +1348,11 @@ project_boundaries : Optional[str] = None
}) })
.def("_get2dElementsAsTriangles", [](Mesh & self) .def("_get2dElementsAsTriangles", [](Mesh & self)
{ {
/*
std::vector<int> trigs; std::vector<int> trigs;
trigs.resize(3*self.GetNSE()); trigs.resize(3*self.GetNSE());
*/
Array<int> trigs(3*self.GetNSE());
ParallelForRange( self.GetNSE(), [&](auto myrange) { ParallelForRange( self.GetNSE(), [&](auto myrange) {
const auto & surfels = self.SurfaceElements(); const auto & surfels = self.SurfaceElements();
for(auto i : myrange) for(auto i : myrange)
@ -1363,9 +1367,10 @@ project_boundaries : Optional[str] = None
}) })
.def("_get3dElementsAsTets", [](Mesh & self) .def("_get3dElementsAsTets", [](Mesh & self)
{ {
std::vector<int> tets; // std::vector<int> tets;
tets.resize(4*self.GetNE()); // tets.resize(4*self.GetNE());
Array<int> tets(4*self.GetNE());
ParallelForRange( self.GetNE(), [&](auto myrange) { ParallelForRange( self.GetNE(), [&](auto myrange) {
const auto & els = self.VolumeElements(); const auto & els = self.VolumeElements();
for(auto i : myrange) for(auto i : myrange)