Преглед на файлове

Ajout du programme pour comparer des ensembles de lignes de force

Rémi Synave преди 8 месеца
родител
ревизия
768734ad97
променени са 4 файла, в които са добавени 163 реда и са изтрити 0 реда
  1. 26 0
      SLList/Main.cpp
  2. 53 0
      SLList/SLList.cpp
  3. 47 0
      SLList/SLList.hpp
  4. 37 0
      SLList/sllist.pro

+ 26 - 0
SLList/Main.cpp

@@ -0,0 +1,26 @@
+#include <iostream>
+#include <QImage>
+#include "SLList.hpp"
+
+void usage(char** argv)
+{
+  std::cout << "usage : " << argv[0] << " json1 json2 image" << std::endl;
+}
+
+int main(int argc, char** argv)
+{
+  if(argc!=4)
+    {
+      usage(argv);
+      return EXIT_FAILURE;
+    }
+
+  std::string fichier1 = argv[1];
+  std::string fichier2 = argv[2];
+  
+  SLList sll1(fichier1);
+  SLList sll2(fichier2);
+  QImage img(argv[3]);
+  std::pair<double, int> resultat = sll1.distance(&sll2, &img);
+  std::cout << resultat.first << " , " << resultat.second << std::endl;
+}

+ 53 - 0
SLList/SLList.cpp

@@ -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);
+}

+ 47 - 0
SLList/SLList.hpp

@@ -0,0 +1,47 @@
+/*********************************************************************/
+/*                                                                   */
+/* 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/>.       */
+/*                                                                   */
+/*********************************************************************/
+
+#ifndef SLLIST_HPP
+#define SLLIST_HPP
+
+#include <QPoint>
+#include <QImage>
+#include <QList>
+
+#include "StrengthLine.hpp"
+
+
+class SLList
+{
+private:
+  QList < StrengthLine > list;
+
+public:
+  SLList (const char* file);
+  SLList (std::string file) : SLList(file.c_str()){}
+  SLList (QString file) : SLList(file.toStdString()){}
+
+  std::pair<double, int> distance(SLList*, QImage*) const;
+};
+
+#endif

+ 37 - 0
SLList/sllist.pro

@@ -0,0 +1,37 @@
+#/*********************************************************************/
+#/*                                                                   */
+#/* 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/>.       */
+#/*                                                                   */
+#/*********************************************************************/
+
+QT += core
+
+INCLUDEPATH = ../StrengthLine/
+
+HEADERS = ../StrengthLine/StrengthLine.hpp \
+          SLList.hpp
+                
+SOURCES = ../StrengthLine/StrengthLine.cpp \
+          SLList.cpp \
+          Main.cpp
+                    
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/sllist
+INSTALLS += target