В 1-й общей библиотеке данные для трехмерных координат хранятся со структурой Point
:
struct Point {
float x{0}, y{0}, z{0};
};
std::vector<Point> *m_points;
В общей библиотеке 2nd данные для трехмерных координат хранятся с PointContainer
class
class PointContainer : public QObject
{
Q_OBJECT
// This is a sophisticated class ...
public:
QVector3D m_coord;
}
QVector<PointContainer> *m_points;
Чтобы передать данные из 2-й общей библиотеки в 1-й один, я использую цикл:
std::vector<Point> data(number_of_points);
// Prepare the data in the structure needed by the 1st shared library
for (size_t i = 0; i < number_of_points; ++i) {
float x = m_points->at(i).m_coord.x();
float y = m_points->at(i).m_coord.y();
float z = m_points->at(i).m_coord.z();
Point point = {};
point.x = x;
point.y = y;
point.z = z;
data[i] = point;
}
// Now pass data to the 1st shared library
number_of_points
может быть огромным, и вышеуказанный цикл может быть вычислительно дорогим. Есть ли способы избежать вышеуказанного цикла? Я пытался хранить данные с одинаковой структурой в общих библиотеках, но это требует огромного пересмотра кода. Не уверен, есть ли другой вариант, просто спрашиваю.