|
@@ -0,0 +1,53 @@
|
|
|
+/*********************************************************************/
|
|
|
+/* */
|
|
|
+/* Copyright 2022-2023 Rémi Synave - remi.synave@univ-littoral.fr */
|
|
|
+/* */
|
|
|
+/* This file is part of DSL. */
|
|
|
+/* This software uses Qt to build the Graphical User Interface */
|
|
|
+/* https://www.qt.io/ */
|
|
|
+/* */
|
|
|
+/* DSL is free software: you can redistribute it and/or modify */
|
|
|
+/* it under the terms of the GNU General Public License as published */
|
|
|
+/* by the Free Software Foundation, either version 3 of the License, */
|
|
|
+/* or (at your option) any later version. */
|
|
|
+/* */
|
|
|
+/* DSL is distributed in the hope that it will be useful, */
|
|
|
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
|
|
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
|
|
+/* GNU General Public License for more details. */
|
|
|
+/* */
|
|
|
+/* You should have received a copy of the GNU General Public License */
|
|
|
+/* along with DSL. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
+/* */
|
|
|
+/*********************************************************************/
|
|
|
+
|
|
|
+#include <QDebug>
|
|
|
+#include <QFile>
|
|
|
+#include <QJsonObject>
|
|
|
+#include <QJsonArray>
|
|
|
+#include <QJsonDocument>
|
|
|
+
|
|
|
+#include "SLList.hpp"
|
|
|
+
|
|
|
+SLList::SLList (const char* file)
|
|
|
+{
|
|
|
+ list.clear();
|
|
|
+
|
|
|
+ QFile fin(QString::fromStdString (file));
|
|
|
+ fin.open(QIODevice::ReadOnly);
|
|
|
+ QByteArray ba = fin.readAll();
|
|
|
+ QJsonParseError parseError;
|
|
|
+ QJsonDocument doc = QJsonDocument::fromJson(ba, &parseError);
|
|
|
+ QJsonArray lines = doc["lines"].toArray();
|
|
|
+ for(int i=0; i<lines.size(); i++){
|
|
|
+ QJsonArray line = lines[i].toArray();
|
|
|
+ QJsonArray point1 = line[0].toArray();
|
|
|
+ QJsonArray point2 = line[1].toArray();
|
|
|
+ list << StrengthLine(point1[0].toDouble(), point1[1].toDouble(), point2[0].toDouble(), point2[1].toDouble());
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+std::pair<double, int> SLList::distance(SLList*, QImage*) const
|
|
|
+{
|
|
|
+ return std::make_pair(1, -1);
|
|
|
+}
|