@@ -261,19 +261,22 @@ class LineInterfaceGeometry : public Geometry<Node>
261261 {
262262 const auto points = this ->Points ();
263263 const auto number_of_midline_nodes = std::size_t {points.size () / 2 };
264+ auto result = PointerVector<Node>{number_of_midline_nodes};
264265
265266 auto is_null = [](const auto & rNodePtr) { return rNodePtr == nullptr ; };
266267 if (std::any_of (points.ptr_begin (), points.ptr_end (), is_null)) {
267268 // At least one point is not defined, so the points of the mid-line can't be computed.
268269 // As a result, all the mid-line points will be undefined.
269- return PointerVector<Node>{number_of_midline_nodes} ;
270+ return result ;
270271 }
271272
272- auto result = PointerVector<Node>{};
273- for (std::size_t i = 0 ; i < number_of_midline_nodes; ++i) {
274- const auto mid_point = (points[i] + points[i + number_of_midline_nodes]) / 2 ;
275- result.push_back (make_intrusive<Node>(points[i].Id (), mid_point));
276- }
273+ auto begin_of_first_side = points.ptr_begin ();
274+ auto begin_of_second_side = begin_of_first_side + number_of_midline_nodes;
275+ auto make_mid_point = [](auto pPoint1, auto pPoint2) {
276+ return make_intrusive<Node>(pPoint1->Id (), Point{(*pPoint1 + *pPoint2) / 2 });
277+ };
278+ std::transform (begin_of_first_side, begin_of_second_side, begin_of_second_side,
279+ result.ptr_begin (), make_mid_point);
277280 return result;
278281 }
279282
0 commit comments