diff --git a/CMakeLists.txt b/CMakeLists.txt
index 12e8d06..4c11220 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,8 +7,8 @@ cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
project(FastCAE
VERSION 2.5.0
LANGUAGES CXX
- DESCRIPTION "FastCAE,一款免费的CAE仿真软件研发支撑平台。"
- HOMEPAGE_URL "http://www.fastcae.com/"
+ DESCRIPTION "LAMPCAE,基于FastCAE的测量仿真分析软件。"
+ HOMEPAGE_URL "http://124.16.188.131:9699/web/server3/build/#/Guide/"
)
#-----------------------------------------------------------------------------
diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user
new file mode 100644
index 0000000..5de0095
--- /dev/null
+++ b/CMakeLists.txt.user
@@ -0,0 +1,419 @@
+
+
+
+
+
+ EnvironmentId
+ {d034e98c-d1df-4d65-be6b-a0d9f31abe3b}
+
+
+ ProjectExplorer.Project.ActiveTarget
+ 0
+
+
+ ProjectExplorer.Project.EditorSettings
+
+ true
+ false
+ true
+
+ Cpp
+
+ CppGlobal
+
+
+
+ QmlJS
+
+ QmlJSGlobal
+
+
+ 2
+ UTF-8
+ false
+ 4
+ false
+ 80
+ true
+ true
+ 1
+ 0
+ false
+ true
+ false
+ 0
+ true
+ true
+ 0
+ 8
+ true
+ false
+ 1
+ true
+ true
+ true
+ *.md, *.MD, Makefile
+ false
+ true
+ true
+
+
+
+ ProjectExplorer.Project.PluginSettings
+
+
+ true
+ false
+ true
+ true
+ true
+ true
+
+
+ 0
+ true
+
+ true
+ true
+ Builtin.DefaultTidyAndClazy
+ 8
+ true
+
+
+
+ true
+
+
+
+
+ ProjectExplorer.Project.Target.0
+
+ Desktop
+ Desktop Qt 5.15.2 MSVC2019 64bit
+ Desktop Qt 5.15.2 MSVC2019 64bit
+ qt.qt5.5152.win64_msvc2019_64_kit
+ 0
+ 0
+ 0
+
+ Debug
+ 2
+ false
+
+ -DCMAKE_GENERATOR:STRING=Ninja
+-DCMAKE_BUILD_TYPE:STRING=Debug
+-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
+-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
+-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
+-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
+-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
+-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
+ 0
+ D:\WBFZCPP\source\build-FastCAE-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug
+
+
+
+
+ all
+
+ false
+
+ true
+ 构建
+ CMakeProjectManager.MakeStep
+
+ 1
+ 构建
+ 构建
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+
+ clean
+
+ false
+
+ true
+ 构建
+ CMakeProjectManager.MakeStep
+
+ 1
+ 清除
+ 清除
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Debug
+ CMakeProjectManager.CMakeBuildConfiguration
+
+
+ Release
+ 2
+ false
+
+ -DCMAKE_GENERATOR:STRING=Ninja
+-DCMAKE_BUILD_TYPE:STRING=Release
+-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
+-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
+-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
+-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
+-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
+-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
+ D:\WBFZCPP\source\build-FastCAE-Desktop_Qt_5_15_2_MSVC2019_64bit-Release
+
+
+
+
+ all
+
+ false
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ 构建
+ 构建
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+
+ clean
+
+ false
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ 清除
+ 清除
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Release
+ CMakeProjectManager.CMakeBuildConfiguration
+
+
+ RelWithDebInfo
+ 2
+ false
+
+ -DCMAKE_GENERATOR:STRING=Ninja
+-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
+-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
+-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
+-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
+-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
+-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
+-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
+ D:\WBFZCPP\source\build-FastCAE-Desktop_Qt_5_15_2_MSVC2019_64bit-RelWithDebInfo
+
+
+
+
+ all
+
+ false
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ 构建
+ 构建
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+
+ clean
+
+ false
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ 清除
+ 清除
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Release with Debug Information
+ CMakeProjectManager.CMakeBuildConfiguration
+
+
+ RelWithDebInfo
+ 2
+ false
+
+ -DCMAKE_GENERATOR:STRING=Ninja
+-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
+-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
+-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
+-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
+-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
+-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
+-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
+ 0
+ D:\WBFZCPP\source\build-FastCAE-Desktop_Qt_5_15_2_MSVC2019_64bit-Profile
+
+
+
+
+ all
+
+ false
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ 构建
+ 构建
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+
+ clean
+
+ false
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ 清除
+ 清除
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Profile
+ CMakeProjectManager.CMakeBuildConfiguration
+
+
+ MinSizeRel
+ 2
+ false
+
+ -DCMAKE_GENERATOR:STRING=Ninja
+-DCMAKE_BUILD_TYPE:STRING=MinSizeRel
+-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
+-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
+-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
+-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
+-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
+-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
+ D:\WBFZCPP\source\build-FastCAE-Desktop_Qt_5_15_2_MSVC2019_64bit-MinSizeRel
+
+
+
+
+ all
+
+ false
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ 构建
+ 构建
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+
+ clean
+
+ false
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ 清除
+ 清除
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Minimum Size Release
+ CMakeProjectManager.CMakeBuildConfiguration
+
+ 5
+
+
+ 0
+ 部署
+ 部署
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+
+ false
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+ true
+ true
+ 0
+ true
+
+ 2
+
+ false
+ FastCAE
+ CMakeProjectManager.CMakeRunConfiguration.FastCAE
+ FastCAE
+ false
+ true
+ true
+ true
+ D:/WBFZCPP/source/build-FastCAE-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug/Debug
+
+ 1
+
+
+
+ ProjectExplorer.Project.TargetCount
+ 1
+
+
+ ProjectExplorer.Project.Updater.FileVersion
+ 22
+
+
+ Version
+ 22
+
+
diff --git a/cmake/FindFFTW.cmake b/cmake/FindFFTW.cmake
new file mode 100644
index 0000000..9cc94d6
--- /dev/null
+++ b/cmake/FindFFTW.cmake
@@ -0,0 +1,70 @@
+## FFTW can be compiled and subsequently linked against
+## various data types.
+## There is a single set of include files, and then muttiple libraries,
+## One for each type. I.e. libfftw.a-->double, libfftwf.a-->float
+
+## The following logic belongs in the individual package
+## mark_as_advanced(ITK_USE_FFTWD)
+## option(ITK_USE_FFTWD "Use double precision FFTW if found" ON)
+## mark_as_advanced(ITK_USE_FFTWF)
+## option(ITK_USE_FFTWF "Use single precision FFTW if found" ON)
+
+if(ITK_USE_FFTWD OR ITK_USE_FFTWF)
+
+ set(FFTW_INC_SEARCHPATH
+ /sw/include
+ /usr/include
+ /usr/local/include
+ /usr/include/fftw
+ /usr/local/include/fftw
+ )
+
+ find_path(FFTW_INCLUDE_PATH fftw3.h ${FFTW_INC_SEARCHPATH})
+
+ if(FFTW_INCLUDE_PATH)
+ file(TO_CMAKE_PATH "${FFTW_INCLUDE_PATH}" FFTW_INCLUDE_PATH)
+ set(FFTW_INCLUDE ${FFTW_INCLUDE_PATH})
+ endif()
+
+ if(FFTW_INCLUDE)
+ include_directories(${FFTW_INCLUDE})
+ endif()
+
+ get_filename_component(FFTW_INSTALL_BASE_PATH ${FFTW_INCLUDE_PATH} PATH)
+
+ set(FFTW_LIB_SEARCHPATH
+ ${FFTW_INSTALL_BASE_PATH}/lib
+ ${FFTW_INSTALL_BASE_PATH}/lib64
+ /usr/lib/fftw
+ /usr/local/lib/fftw
+ )
+
+ if(ITK_USE_FFTWD)
+ mark_as_advanced(FFTWD_LIB)
+ find_library(FFTWD_LIB fftw3 ${FFTW_LIB_SEARCHPATH}) #Double Precision Lib
+ find_library(FFTWD_THREADS_LIB fftw3_threads ${FFTW_LIB_SEARCHPATH}) #Double Precision Lib only if compiled with threads support
+
+ if(FFTWD_LIB)
+ set(FFTWD_FOUND 1)
+ get_filename_component(FFTW_LIBDIR ${FFTWD_LIB} PATH)
+ if(FFTWD_THREADS_LIB)
+ set(FFTWD_LIB ${FFTWD_LIB} ${FFTWD_THREADS_LIB} )
+ endif()
+ endif()
+ endif()
+
+ if(ITK_USE_FFTWF)
+ mark_as_advanced(FFTWF_LIB)
+ find_library(FFTWF_LIB fftw3f ${FFTW_LIB_SEARCHPATH}) #Single Precision Lib
+ find_library(FFTWF_THREADS_LIB fftw3f_threads ${FFTW_LIB_SEARCHPATH}) #Single Precision Lib only if compiled with threads support
+
+ if(FFTWF_LIB)
+ set(FFTWF_FOUND 1)
+ get_filename_component(FFTW_LIBDIR ${FFTWF_LIB} PATH)
+ if(FFTWF_THREADS_LIB)
+ set(FFTWF_LIB ${FFTWF_LIB} ${FFTWF_THREADS_LIB} )
+ endif()
+ endif()
+ endif()
+
+endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a40782d..e07abad 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -3,7 +3,7 @@
#-----------------------------------------------------------------------------
# 所有项目
#-----------------------------------------------------------------------------
-list(APPEND _libraries Common PythonModule SARibbonBar Settings DataProperty MeshData SelfDefObject Material Geometry BCBase ConfigOptions ParaClassFactory ModelData ModuleBase PostAlgorithm PostRenderData PostInterface PostCurveDataManager PostPlotWidget PostWidgets GeometryDataExchange ProjectTree ProjectTreeExtend GeometryCommand GeometryWidgets PluginManager GmshModule IO SolverControl MainWidgets UserGuidence)
+list(APPEND _libraries qcustomplot json qscintilla2 qhexedit LAMPTool WBCLFZSystemModule Common PythonModule SARibbonBar Settings DataProperty MeshData SelfDefObject Material Geometry BCBase ConfigOptions ParaClassFactory ModelData ModuleBase PostAlgorithm PostRenderData PostInterface PostCurveDataManager PostPlotWidget PostWidgets GeometryDataExchange ProjectTree ProjectTreeExtend GeometryCommand GeometryWidgets PluginManager GmshModule IO SolverControl MainWidgets UserGuidence)
#[[if(_WIN_)
list(APPEND _libraries XGenerateReport License)
diff --git a/src/FastCAE/CommandLine.cpp b/src/FastCAE/CommandLine.cpp
index 84d9903..7e6fc03 100644
--- a/src/FastCAE/CommandLine.cpp
+++ b/src/FastCAE/CommandLine.cpp
@@ -50,6 +50,8 @@
#include
#endif
+#include "Common/DebugLogger.h" // 日志文件
+
#define WELCOMETIME 1500
CommandPara::CommandPara(int argc, char *argv[])
@@ -131,7 +133,6 @@ bool CommandPara::exec(GUI::MainWindow *window)
window->show();
window->showMaximized();
}
-
if (!_projectFile.isEmpty())
{
QFile sf(_projectFile);
@@ -155,6 +156,7 @@ bool CommandPara::exec(GUI::MainWindow *window)
runSc = true;
}
}
+
if (_showGUI)
return true;
else if (runSc)
diff --git a/src/FastCAE/main.cpp b/src/FastCAE/main.cpp
index bd52c96..d784baa 100644
--- a/src/FastCAE/main.cpp
+++ b/src/FastCAE/main.cpp
@@ -31,9 +31,11 @@
#include
#include
#include
-// #include "ConfigOptions/ConfigDataReader.h"
-// #include "ConfigOptions/ConfigOptions.h"
-// #include "ConfigOptions/GlobalConfig.h"
+
+#include "ConfigOptions/ConfigDataReader.h"
+#include "ConfigOptions/ConfigOptions.h"
+#include "ConfigOptions/GlobalConfig.h"
+
#include "Common/DebugLogger.h"
#include "Settings/BusAPI.h"
@@ -44,6 +46,10 @@
#endif
#endif
+#include "Common/DebugLogger.h" // 日志文件
+
+
+
#define CHECKINGMEMORY 0
bool testOpenGL()
@@ -92,12 +98,13 @@ int main(int argc, char* argv[])
if(!testOpenGL()) {
return 1;
}
- // QString path = qApp->applicationDirPath();
- // ConfigOption::ConfigDataReader reader(path + "/../ConfigFiles/",
- // ConfigOption::ConfigOption::getInstance()); reader.read(); QString qUseRibbon =
- // ConfigOption::ConfigOption::getInstance()->getGlobalConfig()->getUseRibbon(); bool
- // bUseRibbon = qUseRibbon == "yes" ? true : false;
+ /*****************加载参数配置项 *****************************************/
+ QString path = qApp->applicationDirPath();
+ ConfigOption::ConfigDataReader reader(path + "/../ConfigFiles/", ConfigOption::ConfigOption::getInstance());
+ reader.read();
+
+ /******************************************************************************/
bool isRibbon = Setting::BusAPI::instance()->isUseRibbon();
GUI::MainWindow mainwindow(isRibbon);
@@ -128,7 +135,6 @@ int main(int argc, char* argv[])
#endif
//*****************************************
-
if(para.exec(&mainwindow))
emit mainwindow.sendInfoToStatesBar(QString("Version: %1").arg(FASTCAE_VERSION));
else
diff --git a/src/IO/CMakeLists.txt b/src/IO/CMakeLists.txt
index 3cdc1c1..33068e7 100644
--- a/src/IO/CMakeLists.txt
+++ b/src/IO/CMakeLists.txt
@@ -11,7 +11,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
#-----------------------------------------------------------------------------
# 源码扫描
#-----------------------------------------------------------------------------
-file(GLOB _header "*.h")
+file(GLOB _header "*.h*")
file(GLOB _source "*.cpp")
#-----------------------------------------------------------------------------
diff --git a/src/LAMPTool/BaseToollib/BaseConstVariable.h b/src/LAMPTool/BaseToollib/BaseConstVariable.h
new file mode 100644
index 0000000..c38899b
--- /dev/null
+++ b/src/LAMPTool/BaseToollib/BaseConstVariable.h
@@ -0,0 +1,38 @@
+#pragma once
+
+#ifndef BASECONSTVARIABLE_H
+#define BASECONSTVARIABLE_H
+
+
+#include
+#include
+
+
+#define PI_180 180/3.141592653589793238462643383279
+#define T180_PI 3.141592653589793238462643383279/180
+#define LIGHTSPEED 299792458
+
+#define Radians2Degrees(Radians) Radians*PI_180
+#define Degrees2Radians(Degrees) Degrees*T180_PI
+
+
+
+const double PI = 3.141592653589793238462643383279;
+const double epsilon = 0.000000000000001;
+const double pi = 3.14159265358979323846;
+const double d2r = pi / 180;
+const double r2d = 180 / pi;
+
+const double a = 6378137.0; //
+const double ae = 6378137.0; //
+const double ee = 0.0818191910428;// һƫ
+const double f_inverse = 298.257223563; //ʵ
+const double b = a - a / f_inverse;
+const double eSquare = (a * a - b * b) / (a * a);
+const double e = sqrt(eSquare);
+const double earth_Re = 6378136.49;
+const double earth_Rp = (1 - 1 / f_inverse) * earth_Re;
+const double earth_We = 0.000072292115;
+
+
+#endif
\ No newline at end of file
diff --git a/src/LAMPTool/BaseToollib/BaseTool.cpp b/src/LAMPTool/BaseToollib/BaseTool.cpp
new file mode 100644
index 0000000..81da26c
--- /dev/null
+++ b/src/LAMPTool/BaseToollib/BaseTool.cpp
@@ -0,0 +1,256 @@
+#pragma once
+#include "BaseTool.h"
+///
+///
+//#define EIGEN_USE_MKL_ALL
+//#define EIGEN_VECTORIZE_SSE4_2
+//#include
+
+#include "referenceHeader.h"
+#include
+#include
+#include
+#include
+//#include
+#include
+#include
+
+#include < io.h >
+#include < stdio.h >
+#include < stdlib.h >
+#include
+#include
+#include
+//#include
+#include //#include "ogrsf_frmts.h"
+
+#include
+#include
+#include "GeoOperator.h"
+
+
+#include "baseTool.h"
+using namespace std;
+using namespace Eigen;
+
+
+
+
+QString getCurrentTimeString() {
+ struct tm ConversionTime;
+ std::time_t t = std::time(NULL);
+ char mbstr[100];
+ _localtime64_s(&ConversionTime, &t);
+ std::strftime(mbstr, sizeof(mbstr), "%Y-%m-%d %H:%M:%S", &ConversionTime);
+ QString strTime = mbstr;
+ return strTime;
+}
+
+QString getCurrentShortTimeString() {
+ struct tm ConversionTime;
+ std::time_t t = std::time(NULL);
+ char mbstr[100];
+ _localtime64_s(&ConversionTime, &t);
+ std::strftime(mbstr, sizeof(mbstr), "%Y-%m-%d %H:%M:%S", &ConversionTime);
+ QString strTime = mbstr;
+ return strTime;
+}
+
+std::vector splitString(const QString& str, char delimiter)
+{
+ QStringList tokens = str.split(delimiter);
+ return convertQStringListToStdVector(tokens);
+}
+
+
+complex Cubic_Convolution_interpolation(double u, double v, Eigen::MatrixX> img)
+{
+ if (img.rows() != 4 || img.cols() != 4) {
+ throw exception("the size of img's block is not right");
+ }
+ // ����
+ Eigen::MatrixX> wrc(1, 4);// ʹ�� complex ���Ҫԭ�Ϊ�˻�ȡֵ
+ Eigen::MatrixX> wcr(4, 1);//
+ for (int i = 0; i < 4; i++) {
+ wrc(0, i) = Cubic_kernel_weight(u + 1 - i); // u+1,u,u-1,u-2
+ wcr(i, 0) = Cubic_kernel_weight(v + 1 - i);
+ }
+
+ Eigen::MatrixX> interValue = wrc * img * wcr;
+ return interValue(0, 0);
+}
+
+complex Cubic_kernel_weight(double s)
+{
+ s = abs(s);
+ if (s <= 1) {
+ return complex(1.5 * s * s * s - 2.5 * s * s + 1, 0);
+ }
+ else if (s <= 2) {
+ return complex(-0.5 * s * s * s + 2.5 * s * s - 4 * s + 2, 0);
+ }
+ else {
+ return complex(0, 0);
+ }
+}
+
+///
+/// p11 p12 -- x
+/// p0(u,v)
+/// p21 p22
+/// |
+/// y
+/// p11(0,0)
+/// p21(0,1)
+/// P12(1,0)
+/// p22(1,1)
+///
+/// x,y,z
+/// x,y,z
+/// x,y,z
+/// x,y,z
+/// x,y,z
+///
+double Bilinear_interpolation(Landpoint p0, Landpoint p11, Landpoint p21, Landpoint p12, Landpoint p22)
+{
+
+ return p11.ati * (1 - p0.lon) * (1 - p0.lat) +
+ p12.ati * p0.lon * (1 - p0.lat) +
+ p21.ati * (1 - p0.lon) * p0.lat +
+ p22.ati * p0.lon * p0.lat;
+}
+
+
+
+bool onSegment(Point_3d Pi, Point_3d Pj, Point_3d Q)
+{
+ if ((Q.x - Pi.x) * (Pj.y - Pi.y) == (Pj.x - Pi.x) * (Q.y - Pi.y) //
+ //֤Qpi,pj֮
+ && min(Pi.x, Pj.x) <= Q.x && Q.x <= max(Pi.x, Pj.x)
+ && min(Pi.y, Pj.y) <= Q.y && Q.y <= max(Pi.y, Pj.y))
+ return true;
+ else
+ return false;
+}
+
+Point_3d invBilinear(Point_3d p, Point_3d a, Point_3d b, Point_3d c, Point_3d d)
+{
+ Point_3d res;
+
+ Point_3d e = b - a;
+ Point_3d f = d - a;
+ Point_3d g = a - b + c - d;
+ Point_3d h = p - a;
+
+ double k2 = cross2d(g, f);
+ double k1 = cross2d(e, f) + cross2d(h, g);
+ double k0 = cross2d(h, e);
+ double u, v;
+ // if edges are parallel, this is a linear equation
+ if (abs(k2) < 0.001)
+ {
+ v = -k0 / k1;
+ u = (h.x - f.x * v) / (e.x + g.x * v);
+ p.z = a.z + (b.z - a.z) * u + (d.z - a.z) * v + (a.z - b.z + c.z - d.z) * u * v;
+ return p;
+ }
+ // otherwise, it's a quadratic
+ else
+ {
+ float w = k1 * k1 - 4.0 * k0 * k2;
+ if (w < 0.0) {
+ // ڱ߽
+ if (onSegment(a, b, p)) {
+ Point_3d tt = b - a;
+ Point_3d ttpa = p - a;
+ double scater = ttpa / tt;
+ if (scater < 0 || scater>1) { return { -9999,-9999,-9999 }; }
+ p.z = a.z + scater * tt.z;
+ return p;
+ }
+ else if (onSegment(b, c, p)) {
+ Point_3d tt = c - b;
+ Point_3d ttpa = p - b;
+ double scater = ttpa / tt;
+ if (scater < 0 || scater>1) { return { -9999,-9999,-9999 }; }
+ p.z = b.z + scater * tt.z;
+ return p;
+ }
+ else if (onSegment(c, d, p)) {
+ Point_3d tt = d - c;
+ Point_3d ttpa = p - c;
+ double scater = ttpa / tt;
+ if (scater < 0 || scater>1) { return { -9999,-9999,-9999 }; }
+ p.z = c.z + scater * tt.z;
+ return p;
+ }
+ else if (onSegment(d, a, p)) {
+ Point_3d tt = a - d;
+ Point_3d ttpa = p - d;
+ double scater = ttpa / tt;
+ if (scater < 0 || scater>1) { return { -9999,-9999,-9999 }; }
+ p.z = d.z + scater * tt.z;
+ return p;
+ }
+
+ return { -9999,-9999,-9999 };
+ }
+ else {
+ w = sqrt(w);
+
+ float ik2 = 0.5 / k2;
+ float v = (-k1 - w) * ik2;
+ float u = (h.x - f.x * v) / (e.x + g.x * v);
+
+ if (u < 0.0 || u>1.0 || v < 0.0 || v>1.0)
+ {
+ v = (-k1 + w) * ik2;
+ u = (h.x - f.x * v) / (e.x + g.x * v);
+ }
+ p.z = a.z + (b.z - a.z) * u + (d.z - a.z) * v + (a.z - b.z + c.z - d.z) * u * v;
+ return p;
+ }
+ }
+ p.z = a.z + (b.z - a.z) * u + (d.z - a.z) * v + (a.z - b.z + c.z - d.z) * u * v;
+ return p;
+}
+
+double sind(double degree)
+{
+ return sin(degree * d2r);
+}
+
+double cosd(double d)
+{
+ return cos(d * d2r);
+}
+
+
+string Convert(float Num)
+{
+ ostringstream oss;
+ oss << Num;
+ string str(oss.str());
+ return str;
+}
+
+QString JoinPath(const QString& path, const QString& filename)
+{
+ QDir dir(path);
+
+ // Ensure the path ends with the appropriate separator
+ if (!QDir::isAbsolutePath(path))
+ dir.makeAbsolute();
+
+ return dir.filePath(filename);
+}
+std::vector convertQStringListToStdVector(const QStringList& qStringList)
+{
+ std::vector stdVector;
+
+ for (const QString& str : qStringList) {
+ stdVector.push_back(str);
+ }
+
+ return stdVector;
+};
\ No newline at end of file
diff --git a/src/LAMPTool/BaseToollib/BaseTool.h b/src/LAMPTool/BaseToollib/BaseTool.h
new file mode 100644
index 0000000..4743173
--- /dev/null
+++ b/src/LAMPTool/BaseToollib/BaseTool.h
@@ -0,0 +1,93 @@
+#pragma once
+#pragma once
+#ifndef BASETOOL_H
+#define BASETOOL_H
+
+///
+/// ࡢ
+///
+//#define EIGEN_USE_MKL_ALL
+//#define EIGEN_VECTORIZE_SSE4_2
+//#include
+
+//#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "referenceHeader.h"
+#include
+#include
+#include
+#include
+#include
+#include "GeoOperator.h"
+#include
+#include
+
+using namespace std;
+using namespace Eigen;
+
+
+///////////////////////////////////// ʱӡ //////////////////////////////////////////////////////////
+
+
+QString getCurrentTimeString();
+QString getCurrentShortTimeString();
+
+std::vector splitString(const QString& str, char delimiter);
+
+
+
+/////////////////////////////// ͼ //////////////////////////////////////////////////////////
+
+string Convert(float Num);
+QString JoinPath(const QString& path, const QString& filename);
+
+////////////////////////////// 겿ֻ //////////////////////////////////////////
+
+
+////////////////////////////// 겿ֻ //////////////////////////////////////////
+
+
+////////////////////////////// ֵ ////////////////////////////////////////////
+
+complex Cubic_Convolution_interpolation(double u, double v, Eigen::MatrixX> img);
+
+complex Cubic_kernel_weight(double s);
+
+double Bilinear_interpolation(Landpoint p0, Landpoint p11, Landpoint p21, Landpoint p12, Landpoint p22);
+
+bool onSegment(Point_3d Pi, Point_3d Pj, Point_3d Q);
+
+Point_3d invBilinear(Point_3d p, Point_3d a, Point_3d b, Point_3d c, Point_3d d);
+
+
+
+//
+// WGS84 J2000 ϵı任
+// οַhttps://blog.csdn.net/hit5067/article/details/116894616
+// ַhttp://celestrak.org/spacedata/
+// ļ
+// a. Earth Orientation Parameter ļ http://celestrak.org/spacedata/EOP-Last5Years.csv
+// b. Space Weather Data ļ http://celestrak.org/spacedata/SW-Last5Years.csv
+// עļ2017-
+/**
+wgs84 ϵתJ2000 ϵ Ҫ 漰תһWGSΪ ʱ̵ t ,BLH
+ת裺
+step 1: WGS 84 תЭϵ
+step 2: Эϵ תΪ˲ʱϵ
+step 3: ˲ʱϵ תΪ ˲ʱϵ
+step 4: ˲ʱϵ ת˲ʱƽ ϵ
+step 5: ˲ʱƽϵתΪЭϵJ2000
+**/
+
+
+double sind(double degree);
+
+double cosd(double d);
+
+#endif
\ No newline at end of file
diff --git a/src/LAMPTool/BaseToollib/FileOperator.cpp b/src/LAMPTool/BaseToollib/FileOperator.cpp
new file mode 100644
index 0000000..7ce44bb
--- /dev/null
+++ b/src/LAMPTool/BaseToollib/FileOperator.cpp
@@ -0,0 +1,188 @@
+#include "FileOperator.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+std::vector getFilelist(const QString& folderpath, const QString& filenameExtension, int (*logfun)(QString logtext, int value))
+{
+ QString filenameExtensionStr = filenameExtension;
+ filenameExtensionStr = filenameExtensionStr.remove(0, 1);
+ std::vector filenames(0);
+ if (isExists(folderpath) && isDirectory(folderpath)) {
+ QDir directory(folderpath);
+ if (directory.exists() && directory.isReadable()) {
+ QFileInfoList fileList = directory.entryInfoList(QDir::Files | QDir::NoDotAndDotDot);
+ for (const QFileInfo& fileInfo : fileList) {
+ qDebug() << fileInfo.filePath() + "\nExtension: (" + filenameExtensionStr + ", " + fileInfo.suffix() + ")";
+ if (filenameExtensionStr == u8"*" || filenameExtensionStr == fileInfo.suffix()) {
+ filenames.push_back(fileInfo.filePath());
+ }
+ if (logfun) {
+ logfun(fileInfo.filePath() + "\nExtension: (" + filenameExtensionStr + ", " + fileInfo.suffix() + ")", 4);
+ }
+ }
+ }
+ else {
+ qWarning() << "Folder does not exist or is not readable: " << folderpath;
+ }
+ return filenames;
+ }
+ else {
+ return std::vector(0);
+ }
+
+}
+
+QString getParantFolderNameFromPath(const QString& path)
+{
+ QDir directory(path);
+ directory.cdUp();
+ QString parentPath = directory.absolutePath();
+ return directory.dirName();
+}
+
+QString getParantFromPath(const QString& path)
+{
+ //qDebug() << path;
+ QDir directory(path);
+ directory.cdUp();
+ QString parentPath = directory.absolutePath();
+ //qDebug() << parentPath;
+ return parentPath;
+}
+
+QString getFileNameFromPath(const QString& path)
+{
+ QFileInfo fileInfo(path);
+ return fileInfo.fileName();
+}
+
+bool isDirectory(const QString& path)
+{
+ QFileInfo fileinfo(path);
+ return fileinfo.isDir();
+}
+
+bool isExists(const QString& path)
+{
+ QFileInfo fileinfo(path);
+ return fileinfo.exists();
+}
+
+bool isFile(const QString& path)
+{
+ QFileInfo fileinfo(path);
+ return fileinfo.isFile();
+}
+
+int write_binfile(char* filepath, char* data, size_t data_len)
+{
+ FILE* pd = fopen(filepath, "w");
+ if (NULL == pd) {
+ return 2;
+ }
+ //ݿַ: "&a"ԪشС: "sizeof(unsigned __int8)" Ԫظ: "10" ļָ룺"pd"
+ fwrite(data, sizeof(char), data_len, pd);
+ fclose(pd);
+ return -1;
+}
+
+char* read_textfile(char* text_path, int* length)
+{
+ char* data = NULL;
+ FILE* fp1 = fopen(text_path, "r");
+ if (fp1 == NULL) {
+ return NULL;
+ }
+ else {}
+ // ȡļ
+ fseek(fp1, 0, SEEK_END);
+ int data_length = ftell(fp1);
+ data = (char*)malloc((data_length + 1) * sizeof(char));
+ rewind(fp1);
+ if (data_length == fread(data, sizeof(char), data_length, fp1)) {
+ data[data_length] = '\0'; // ļβ
+ }
+ else {
+ free(data);
+ fclose(fp1);
+ return NULL;
+ }
+ fclose(fp1);
+ *length = data_length + 1;
+ return data;
+}
+
+bool exists_test(const QString& name)
+{
+ return isExists(name);
+}
+
+size_t fsize(FILE* fp)
+{
+ size_t n;
+ fpos_t fpos; // ǰλ
+ fgetpos(fp, &fpos); // ȡǰλ
+ fseek(fp, 0, SEEK_END);
+ n = ftell(fp);
+ fsetpos(fp, &fpos); // ָ֮ǰλ
+ return n;
+}
+
+
+void removeFile(const QString& filePath)
+{
+ QFile file(filePath);
+
+ if (file.exists()) {
+ if (file.remove()) {
+ qDebug() << "File removed successfully: " << filePath;
+ }
+ else {
+ qWarning() << "Failed to remove file: " << filePath;
+ }
+ }
+ else {
+ qDebug() << "File does not exist: " << filePath;
+ }
+}
+
+unsigned long convertToULong(const QString& input) {
+ bool ok; // Used to check if the conversion was successful
+ unsigned long result = input.toULong(&ok);
+
+ if (!ok) {
+ qWarning() << "Conversion to unsigned long failed for input: " << input;
+ }
+
+ return result;
+}
+
+
+
+void copyFile(const QString& sourcePath, const QString& destinationPath) {
+ QFile sourceFile(sourcePath);
+ QFile destinationFile(destinationPath);
+
+ if (sourceFile.exists()) {
+ if (sourceFile.copy(destinationPath)) {
+ // Ƴɹ
+ //QMessageBox::information(nullptr, u8"ɹ", u8"ļƳɹ");
+ }
+ else {
+ // ʧ
+ QMessageBox::critical(nullptr, u8"", u8"ļʧ");
+ }
+ }
+ else {
+ // Դļ
+ QMessageBox::warning(nullptr, u8"", u8"Դļ");
+ }
+}
\ No newline at end of file
diff --git a/src/LAMPTool/BaseToollib/FileOperator.h b/src/LAMPTool/BaseToollib/FileOperator.h
new file mode 100644
index 0000000..a823f0f
--- /dev/null
+++ b/src/LAMPTool/BaseToollib/FileOperator.h
@@ -0,0 +1,50 @@
+#pragma once
+
+#ifndef FILEOPERATOR_H
+#define FILEOPERATOR_H
+
+#include "referenceHeader.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+bool isDirectory(const QString& path);
+bool isExists(const QString& path);
+bool isFile(const QString& path);
+void removeFile(const QString& filePath);
+unsigned long convertToULong(const QString& input);
+///
+/// ȡļ(·
+///
+///
+///
+///
+std::vector getFilelist(const QString& folderpath, const QString& FilenameExtension = ".*",int (*logfun)(QString logtext,int value)=nullptr);
+
+QString getParantFolderNameFromPath(const QString& path);
+
+QString getFileNameFromPath(const QString& path);
+
+int write_binfile(char* filepath, char* data, size_t data_len);
+
+char* read_textfile(char* text_path, int* length);
+
+bool exists_test(const QString& name);
+
+size_t fsize(FILE* fp);
+
+QString getParantFromPath(const QString& path);
+void copyFile(const QString& sourcePath, const QString& destinationPath);
+// QT FileOperator
+#endif
\ No newline at end of file
diff --git a/src/LAMPTool/BaseToollib/GeoOperator.cpp b/src/LAMPTool/BaseToollib/GeoOperator.cpp
new file mode 100644
index 0000000..d515e3a
--- /dev/null
+++ b/src/LAMPTool/BaseToollib/GeoOperator.cpp
@@ -0,0 +1,271 @@
+#include "GeoOperator.h"
+#include
+#include
+#include
+#include
+//#include
+#include
+#include
+#include < io.h >
+#include < stdio.h >
+#include < stdlib.h >
+#include
+#include
+#include
+//#include
+#include //#include "ogrsf_frmts.h"
+#include
+#include
+
+using namespace std;
+using namespace Eigen;
+
+
+Landpoint operator +(const Landpoint& p1, const Landpoint& p2)
+{
+ return Landpoint{ p1.lon + p2.lon,p1.lat + p2.lat,p1.ati + p2.ati };
+}
+
+Landpoint operator -(const Landpoint& p1, const Landpoint& p2)
+{
+ return Landpoint{ p1.lon - p2.lon,p1.lat - p2.lat,p1.ati - p2.ati };
+}
+
+bool operator ==(const Landpoint& p1, const Landpoint& p2)
+{
+ return p1.lat == p2.lat && p1.lon == p2.lon && p1.ati == p2.ati;
+}
+
+
+
+Landpoint operator *(const Landpoint& p, double scale)
+{
+ return Landpoint{
+ p.lon * scale,
+ p.lat * scale,
+ p.ati * scale
+ };
+}
+
+
+Landpoint LLA2XYZ(const Landpoint& LLA) {
+ double L = LLA.lon * d2r;
+ double B = LLA.lat * d2r;
+ double H = LLA.ati;
+
+ double sinB = sin(B);
+ double cosB = cos(B);
+
+ //double N = a / sqrt(1 - e * e * sin(B) * sin(B));
+ double N = a / sqrt(1 - eSquare * sinB * sinB);
+ Landpoint result = { 0,0,0 };
+ result.lon = (N + H) * cosB * cos(L);
+ result.lat = (N + H) * cosB * sin(L);
+ //result.z = (N * (1 - e * e) + H) * sin(B);
+ result.ati = (N * (1 - 1 / f_inverse) * (1 - 1 / f_inverse) + H) * sinB;
+ return result;
+}
+
+
+Eigen::MatrixXd LLA2XYZ(Eigen::MatrixXd landpoint)
+{
+ landpoint.col(0) = landpoint.col(0).array() * d2r; // lon
+ landpoint.col(1) = landpoint.col(1).array() * d2r; // lat
+
+ Eigen::MatrixXd sinB = (landpoint.col(1).array().sin());//lat
+ Eigen::MatrixXd cosB = (landpoint.col(1).array().cos());//lat
+
+ Eigen::MatrixXd N = a / ((1 - sinB.array().pow(2) * eSquare).array().sqrt());
+ Eigen::MatrixXd result(landpoint.rows(), 3);
+
+ result.col(0) = (N.array() + landpoint.col(2).array()) * cosB.array() * Eigen::cos(landpoint.col(0).array()).array(); //x
+ result.col(1) = (N.array() + landpoint.col(2).array()) * cosB.array() * Eigen::sin(landpoint.col(0).array()).array(); //y
+
+ result.col(2) = (N.array() * (1 - 1 / f_inverse) * (1 - 1 / f_inverse) + landpoint.col(2).array()) * sinB.array(); //z
+
+ return result;
+}
+
+
+Landpoint XYZ2LLA(const Landpoint& XYZ) {
+ double tmpX = XYZ.lon;//
+ double temY = XYZ.lat;//
+ double temZ = XYZ.ati;
+
+ double curB = 0;
+ double N = 0;
+ double sqrtTempXY = sqrt(tmpX * tmpX + temY * temY);
+ double calB = atan2(temZ, sqrtTempXY);
+ int counter = 0;
+ double sinCurB = 0;
+ while (abs(curB - calB) * r2d > epsilon && counter < 25)
+ {
+ curB = calB;
+ sinCurB = sin(curB);
+ N = a / sqrt(1 - eSquare * sinCurB * sinCurB);
+ calB = atan2(temZ + N * eSquare * sinCurB, sqrtTempXY);
+ counter++;
+ }
+
+ Landpoint result = { 0,0,0 };
+ result.lon = atan2(temY, tmpX) * r2d;
+ result.lat = curB * r2d;
+ result.ati = temZ / sinCurB - N * (1 - eSquare);
+ return result;
+}
+
+
+
+
+double getAngle(const Landpoint& a, const Landpoint& b)
+{
+ double c = dot(a, b) / (getlength(a) * getlength(b));
+ if (a.lon * b.lat - a.lat * b.lon >= 0) {
+ return acos(c > 1 ? 1 : c < -1 ? -1 : c) * r2d;
+ }
+ else {
+ return 360 - acos(c > 1 ? 1 : c < -1 ? -1 : c) * r2d;
+ }
+}
+
+double dot(const Landpoint& p1, const Landpoint& p2)
+{
+ return p1.lat * p2.lat + p1.lon * p2.lon + p1.ati * p2.ati;
+}
+
+double getlength(const Landpoint& p1) {
+
+ return sqrt(dot(p1, p1));
+}
+
+Landpoint crossProduct(const Landpoint& a, const Landpoint& b) {
+ return Landpoint{
+ a.lat * b.ati - a.ati * b.lat,//x
+ a.ati * b.lon - a.lon * b.ati,//y
+ a.lon * b.lat - a.lat * b.lon//z
+ };
+}
+
+float cross2d(Point_3d a, Point_3d b)
+{
+ return a.x * b.y - a.y * b.x;
+}
+
+Point_3d operator -(Point_3d a, Point_3d b)
+{
+ return Point_3d{ a.x - b.x, a.y - b.y, a.z - b.z };
+}
+
+Point_3d operator +(Point_3d a, Point_3d b)
+{
+ return Point_3d{ a.x + b.x, a.y + b.y, a.z + b.z };
+}
+
+double operator /(Point_3d a, Point_3d b)
+{
+ return sqrt(pow(a.x, 2) + pow(a.y, 2)) / sqrt(pow(b.x, 2) + pow(b.y, 2));
+}
+
+
+Landpoint getSlopeVector(const Landpoint& p0, const Landpoint& p1, const Landpoint& p2, const Landpoint& p3, const Landpoint& p4) {
+
+ Landpoint n0 = LLA2XYZ(p0),
+ n1 = LLA2XYZ(p1),
+ n2 = LLA2XYZ(p2),
+ n3 = LLA2XYZ(p3),
+ n4 = LLA2XYZ(p4);
+ Landpoint n01 = n1 - n0, n02 = n2 - n0, n03 = n3 - n0, n04 = n4 - n0;
+ // ��n01��������
+ Landpoint np01 = p1 - p0, np02 = p2 - p0, np03 = p3 - p0, np04 = p4 - p0;
+ double a2 = getAngle(Landpoint{ np01.lon,np01.lat,0 }, Landpoint{ np02.lon,np02.lat,0 });// 01->02 ��ʱ��
+ double a3 = getAngle(Landpoint{ np01.lon,np01.lat,0 }, Landpoint{ np03.lon,np03.lat,0 });// 01->03 ��ʱ��
+ double a4 = getAngle(Landpoint{ np01.lon,np01.lat,0 }, Landpoint{ np04.lon,np04.lat,0 });// 01->04 ��ʱ��
+ //qDebug() << a2 << "\t" << a3 << "\t" << a4 << endl;
+ a2 = 360 - a2;
+ a3 = 360 - a3;
+ a4 = 360 - a4;
+ Landpoint N, W, S, E;
+ N = n01;
+ if (a2 >= a3 && a2 >= a4) {
+ W = n02;
+ if (a3 >= a4) {
+ S = n03;
+ E = n04;
+ }
+ else {
+ S = n04;
+ E = n03;
+ }
+ }
+ else if (a3 >= a2 && a3 >= a4) {
+ W = n03;
+ if (a2 >= a4) {
+ S = n02;
+ E = n04;
+ }
+ else {
+ S = n04;
+ E = n02;
+ }
+ }
+ else if (a4 >= a2 && a4 >= a3)
+ {
+ W = n04;
+ if (a2 >= a3) {
+ S = n02;
+ E = n03;
+ }
+ else {
+ S = n03;
+ E = n02;
+ }
+ }
+ return (crossProduct(N, W) + crossProduct(W, S) + crossProduct(S, E) + crossProduct(E, N)) * 0.25;
+}
+
+
+
+double distance(const Vector3D& p1, const Vector3D& p2)
+{
+ double dx = p1.x - p2.x;
+ double dy = p1.y - p2.y;
+ double dz = p1.z - p2.z;
+ return std::sqrt(dx * dx + dy * dy + dz * dz);
+}
+
+double pointToLineDistance(const Vector3D& point, const Vector3D& linePoint, const Vector3D& lineDirection)
+{
+ Vector3D pointToLine = { point.x - linePoint.x, point.y - linePoint.y, point.z - linePoint.z };
+
+ // 计算点到直线的投影点的位置
+ double t = (pointToLine.x * lineDirection.x + pointToLine.y * lineDirection.y + pointToLine.z * lineDirection.z) /
+ (lineDirection.x * lineDirection.x + lineDirection.y * lineDirection.y + lineDirection.z * lineDirection.z);
+
+ // 计算投影点
+ Vector3D projection = { linePoint.x + t * lineDirection.x, linePoint.y + t * lineDirection.y, linePoint.z + t * lineDirection.z };
+
+ // 计算点到直线的距离
+ return distance(point, projection);
+}
+
+SphericalCoordinates cartesianToSpherical(const CartesianCoordinates& cartesian)
+{
+ SphericalCoordinates spherical;
+
+ spherical.r = std::sqrt(cartesian.x * cartesian.x + cartesian.y * cartesian.y + cartesian.z * cartesian.z);
+ spherical.theta = std::acos(cartesian.z / spherical.r);
+ spherical.phi = std::atan2(cartesian.y, cartesian.x);
+
+ return spherical;
+}
+
+CartesianCoordinates sphericalToCartesian(const SphericalCoordinates& spherical)
+{
+ CartesianCoordinates cartesian;
+
+ cartesian.x = spherical.r * std::sin(spherical.theta) * std::cos(spherical.phi);
+ cartesian.y = spherical.r * std::sin(spherical.theta) * std::sin(spherical.phi);
+ cartesian.z = spherical.r * std::cos(spherical.theta);
+
+ return cartesian;
+}
\ No newline at end of file
diff --git a/src/LAMPTool/BaseToollib/GeoOperator.h b/src/LAMPTool/BaseToollib/GeoOperator.h
new file mode 100644
index 0000000..51dd1dd
--- /dev/null
+++ b/src/LAMPTool/BaseToollib/GeoOperator.h
@@ -0,0 +1,111 @@
+#pragma once
+
+
+#ifndef GEOOPERATOR_H
+#define GEOOPERATOR_H
+
+#include "BaseConstVariable.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+///
+/// ά
+///
+struct Landpoint // SARӰꣻ
+{
+ ///
+ /// x
+ ///
+ double lon; // x lon pixel_col
+ ///
+ /// γy
+ ///
+ double lat; // γy lat pixel_row
+ ///
+ /// ߶z
+ ///
+ double ati; // ߳z ati pixel_time
+};
+struct Point_3d {
+ double x;
+ double y;
+ double z;
+};
+
+///
+/// γתΪع̲ϵ
+///
+/// γȵ--degree
+/// ͶӰϵ
+Landpoint LLA2XYZ(const Landpoint& LLA);
+Eigen::MatrixXd LLA2XYZ(Eigen::MatrixXd landpoint);
+
+///
+/// ع̲ϵתΪγ
+///
+/// ̲ϵ
+/// γ--degree
+Landpoint XYZ2LLA(const Landpoint& XYZ);
+
+
+Landpoint operator +(const Landpoint& p1, const Landpoint& p2);
+
+Landpoint operator -(const Landpoint& p1, const Landpoint& p2);
+
+bool operator ==(const Landpoint& p1, const Landpoint& p2);
+
+Landpoint operator *(const Landpoint& p, double scale);
+
+double getAngle(const Landpoint& a, const Landpoint& b);
+
+double dot(const Landpoint& p1, const Landpoint& p2);
+
+double getlength(const Landpoint& p1);
+
+Landpoint crossProduct(const Landpoint& a, const Landpoint& b);
+
+
+Landpoint getSlopeVector(const Landpoint& p0, const Landpoint& p1, const Landpoint& p2, const Landpoint& p3, const Landpoint& p4);
+
+
+
+float cross2d(Point_3d a, Point_3d b);
+
+Point_3d operator -(Point_3d a, Point_3d b);
+
+Point_3d operator +(Point_3d a, Point_3d b);
+
+double operator /(Point_3d a, Point_3d b);
+
+
+
+// ʸ
+struct Vector3D {
+ double x, y, z;
+};
+
+// ֮ľ
+double distance(const Vector3D& p1, const Vector3D& p2);
+// 㵽ֱߵ̾
+double pointToLineDistance(const Vector3D& point, const Vector3D& linePoint, const Vector3D& lineDirection);
+
+
+struct CartesianCoordinates {
+ double x, y, z;
+};
+
+struct SphericalCoordinates {
+ double r, theta, phi;
+};
+
+SphericalCoordinates cartesianToSpherical(const CartesianCoordinates& cartesian);
+
+CartesianCoordinates sphericalToCartesian(const SphericalCoordinates& spherical);
+
+
+#endif
\ No newline at end of file
diff --git a/src/LAMPTool/BaseToollib/ImageOperatorBase.cpp b/src/LAMPTool/BaseToollib/ImageOperatorBase.cpp
new file mode 100644
index 0000000..6ea06d2
--- /dev/null
+++ b/src/LAMPTool/BaseToollib/ImageOperatorBase.cpp
@@ -0,0 +1,1239 @@
+#include "ImageOperatorBase.h"
+#include "GeoOperator.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "FileOperator.h"
+
+using namespace std;
+using namespace Eigen;
+
+/**
+* ENVIʽ
+*/
+
+
+
+
+
+
+std::shared_ptr OpenDataset(const QString& in_path,GDALAccess rwmode)
+{
+ GDALAllRegister();
+ GDALDataset* dataset_ptr = (GDALDataset*)(GDALOpen(in_path.toUtf8().constData(), rwmode));
+ std::shared_ptr rasterDataset(dataset_ptr, CloseDataset);
+ return rasterDataset;
+}
+
+void CloseDataset(GDALDataset* ptr)
+{
+ GDALClose(ptr);
+ ptr = NULL;
+}
+
+int TIFF2ENVI(QString in_tiff_path, QString out_envi_path)
+{
+ std::shared_ptr ds = OpenDataset(in_tiff_path);
+ const char* args[] = { "-of", "ENVI", NULL };
+ GDALTranslateOptions* psOptions = GDALTranslateOptionsNew((char**)args, NULL);
+ GDALClose(GDALTranslate(out_envi_path.toUtf8().constData(),ds.get(), psOptions,NULL));
+ GDALTranslateOptionsFree(psOptions);
+ return 0;
+}
+
+int ENVI2TIFF(QString in_envi_path, QString out_tiff_path)
+{
+ std::shared_ptr ds = OpenDataset(in_envi_path);
+ const char* args[] = { "-of", "Gtiff", NULL };
+ GDALTranslateOptions* psOptions = GDALTranslateOptionsNew((char**)args, NULL);
+ GDALClose(GDALTranslate(out_tiff_path.toUtf8().constData(), ds.get(), psOptions, NULL));
+ GDALTranslateOptionsFree(psOptions);
+ return 0;
+}
+
+int CreateDataset(QString new_file_path,int height, int width, int band_num,double* gt, QString projection, GDALDataType gdal_dtype ,bool need_gt)
+{
+ GDALAllRegister();
+ GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName("ENVI");
+ std::shared_ptr< GDALDataset> poDstDS(poDriver->Create(new_file_path.toUtf8().constData(), width, height, band_num, gdal_dtype, NULL));
+ if (need_gt)
+ {
+ poDstDS->SetProjection(projection.toUtf8().constData());
+ poDstDS->SetGeoTransform(gt);
+ }
+ else {}
+ GDALFlushCache((GDALDatasetH)poDstDS.get());
+ return 0;
+}
+
+int saveDataset(QString new_file_path, int start_line,int start_cols ,int band_ids, int datacols,int datarows,void* databuffer)
+{
+ GDALAllRegister();
+ std::shared_ptr poDstDS = OpenDataset(new_file_path,GA_Update);
+ GDALDataType gdal_datatype = poDstDS->GetRasterBand(1)->GetRasterDataType();
+ poDstDS->GetRasterBand(band_ids)->RasterIO(GF_Write, start_cols, start_line, datacols, datarows, databuffer, datacols, datarows, gdal_datatype, 0, 0);
+ GDALFlushCache(poDstDS.get());
+ return 0;
+}
+
+int block_num_pre_memory(int block_width, int height, GDALDataType gdal_datatype,double memey_size)
+{
+ // С
+ int size_meta = 0;
+
+ if (gdal_datatype == GDT_Byte) {
+ size_meta = 1;
+ }
+ else if (gdal_datatype == GDT_UInt16) {
+ size_meta = 2; // ֻ˫ܹͨ
+ }
+ else if (gdal_datatype == GDT_UInt16) {
+ size_meta = 2;
+ }
+ else if (gdal_datatype == GDT_Int16) {
+ size_meta = 2;
+ }
+ else if (gdal_datatype == GDT_UInt32) {
+ size_meta = 4;
+ }
+ else if (gdal_datatype == GDT_Int32) {
+ size_meta = 4;
+ }
+ //else if (gdal_datatype == GDT_UInt64) {
+ // size_meta = 8;
+ //}
+ //else if (gdal_datatype == GDT_Int64) {
+ // size_meta = 8;
+ //}
+ else if (gdal_datatype == GDT_Float32) {
+ size_meta = 4;
+ }
+ else if (gdal_datatype == GDT_Float64) {
+ size_meta = 4;
+ }
+ else if (gdal_datatype == GDT_CInt16) { size_meta = 2; }
+ else if (gdal_datatype == GDT_CInt32) { size_meta = 2; }
+ else if (gdal_datatype == GDT_CFloat32) { size_meta = 4; }
+ else if (gdal_datatype == GDT_CFloat64) { size_meta = 8; }
+ else {}
+ int block_num = int(memey_size / (size_meta * block_width));
+ block_num = block_num > height ? height : block_num; //
+ block_num = block_num < 1 ? 1 : block_num;
+ return block_num;
+}
+
+Eigen::Matrix ReadComplexMatrixData(int start_line, int width, int line_num, std::shared_ptr rasterDataset, GDALDataType gdal_datatype)
+{
+
+ int band_num = rasterDataset->GetRasterCount();
+ if (gdal_datatype == 0) {
+ return Eigen::Matrix (0, 0);
+ }
+ else if (gdal_datatype < 8) {
+ if (band_num != 2) {
+ return Eigen::Matrix(0, 0);
+ }
+ }
+ else if (gdal_datatype < 12) {
+ if (band_num != 1) {
+ return Eigen::Matrix(0, 0);
+ }
+
+ }
+ else {}
+ bool _flag = false;
+ Eigen::Matrix data_mat(line_num * width, 2);// ǿ
+ if (gdal_datatype == GDT_Byte) {
+ Eigen::MatrixX real_mat(line_num * width, 1);
+ Eigen::MatrixX imag_mat(line_num * width, 1);
+ rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, start_line, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, start_line, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
+ data_mat.col(0) = (real_mat.array().cast()).array();
+ data_mat.col(1) = (imag_mat.array().cast()).array();
+ _flag = true;
+ }
+ else if (gdal_datatype == GDT_UInt16) {
+ Eigen::MatrixX real_mat(line_num * width, 1);
+ Eigen::MatrixX imag_mat(line_num * width, 1);
+ rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, start_line, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, start_line, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
+ data_mat.col(0) = (real_mat.array().cast()).array();
+ data_mat.col(1) = (imag_mat.array().cast()).array();
+ _flag = true;
+ }
+ else if (gdal_datatype == GDT_Int16) {
+ Eigen::MatrixX real_mat(line_num * width, 1);
+ Eigen::MatrixX imag_mat(line_num * width, 1);
+ rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, start_line, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, start_line, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
+ data_mat.col(0) = (real_mat.array().cast()).array();
+ data_mat.col(1) = (imag_mat.array().cast()).array();
+ _flag = true;
+ }
+ else if (gdal_datatype == GDT_UInt32) {
+ Eigen::MatrixX real_mat(line_num * width, 1);
+ Eigen::MatrixX imag_mat(line_num * width, 1);
+ rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, start_line, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, start_line, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
+ data_mat.col(0) = (real_mat.array().cast()).array();
+ data_mat.col(1) = (imag_mat.array().cast()).array();
+ _flag = true;
+ }
+ else if (gdal_datatype == GDT_Int32) {
+ Eigen::MatrixX real_mat(line_num * width, 1);
+ Eigen::MatrixX imag_mat(line_num * width, 1);
+ rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, start_line, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, start_line, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
+ data_mat.col(0) = (real_mat.array().cast()).array();
+ data_mat.col(1) = (imag_mat.array().cast()).array();
+ _flag = true;
+ }
+ //else if (gdal_datatype == GDT_UInt64) {
+ // Eigen::MatrixX real_mat(line_num * width, 1);
+ // Eigen::MatrixX imag_mat(line_num * width, 1);
+ // rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, start_line, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ // rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, start_line, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
+ // data_mat.col(0) = (real_mat.array().cast()).array();
+ // data_mat.col(1) = (imag_mat.array().cast()).array();
+ // _flag = true;
+ //}
+ //else if (gdal_datatype == GDT_Int64) {
+ // Eigen::MatrixX real_mat(line_num * width, 1);
+ // Eigen::MatrixX imag_mat(line_num * width, 1);
+ // rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, start_line, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ // rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, start_line, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
+ // data_mat.col(0) = (real_mat.array().cast()).array();
+ // data_mat.col(1) = (imag_mat.array().cast()).array();
+ // _flag = true;
+ //}
+ else if (gdal_datatype == GDT_Float32) {
+ Eigen::MatrixX real_mat(line_num * width, 1);
+ Eigen::MatrixX imag_mat(line_num * width, 1);
+ rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, start_line, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, start_line, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
+ data_mat.col(0) = (real_mat.array().cast()).array();
+ data_mat.col(1) = (imag_mat.array().cast()).array();
+ _flag = true;
+ }
+ else if (gdal_datatype == GDT_Float64) {
+ Eigen::MatrixX real_mat(line_num * width, 1);
+ Eigen::MatrixX imag_mat(line_num * width, 1);
+ rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, start_line, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, start_line, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
+ data_mat.col(0) = (real_mat.array().cast()).array();
+ data_mat.col(1) = (imag_mat.array().cast()).array();
+ _flag = true;
+ }
+ else if (gdal_datatype == GDT_CInt16) {
+ Eigen::MatrixX> complex_short_mat(line_num * width, 1);
+ rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, start_line, width, line_num, complex_short_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ data_mat.col(0) = (complex_short_mat.real().array().cast()).array();
+ data_mat.col(1) = (complex_short_mat.imag().array().cast()).array();
+ _flag = true;
+ }
+ else if (gdal_datatype == GDT_CInt32) {
+ Eigen::MatrixX> complex_short_mat(line_num * width, 1);
+ rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, start_line, width, line_num, complex_short_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ data_mat.col(0) = (complex_short_mat.real().array().cast()).array();
+ data_mat.col(1) = (complex_short_mat.imag().array().cast()).array();
+ _flag = true;
+ }
+ else if (gdal_datatype == GDT_CFloat32) {
+ Eigen::MatrixX> complex_short_mat(line_num * width, 1);
+ rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, start_line, width, line_num, complex_short_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ data_mat.col(0) = (complex_short_mat.real().array().cast()).array();
+ data_mat.col(1) = (complex_short_mat.imag().array().cast()).array();
+ _flag = true;
+ }
+ else if (gdal_datatype == GDT_CFloat64) {
+ Eigen::MatrixX> complex_short_mat(line_num * width, 1);
+ rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, start_line, width, line_num, complex_short_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ data_mat.col(0) = (complex_short_mat.real().array().cast()).array();
+ data_mat.col(1) = (complex_short_mat.imag().array().cast()).array();
+ _flag = true;
+ }
+ else {}
+ //
+
+
+ if (_flag) {
+ return data_mat;
+ }
+ else {
+ return Eigen::Matrix(0, 0);// ǿ;
+ }
+}
+
+Eigen::Matrix ReadMatrixDoubleData(int start_line, int width, int line_num, std::shared_ptr rasterDataset, GDALDataType gdal_datatype, int band_idx)
+{
+ // 飬ʹeigen о㣬ټ
+ bool _flag = false;
+ Eigen::Matrix data_mat(line_num * width, 1);// ǿ
+ if (gdal_datatype == GDT_Byte) {
+ Eigen::MatrixX real_mat(line_num * width, 1);
+ rasterDataset->GetRasterBand(band_idx)->RasterIO(GF_Read, 0, start_line, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ data_mat.col(0) = ((real_mat.array().cast()).array().pow(2)).log10() * 10.0;
+ _flag = true;
+ }
+ else if (gdal_datatype == GDT_UInt16) {
+ Eigen::MatrixX real_mat(line_num * width, 1);
+ rasterDataset->GetRasterBand(band_idx)->RasterIO(GF_Read, 0, start_line, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ data_mat.col(0) = ((real_mat.array().cast()).array().pow(2)).log10() * 10.0;
+ _flag = true;
+ }
+ else if (gdal_datatype == GDT_Int16) {
+ Eigen::MatrixX real_mat(line_num * width, 1);
+ rasterDataset->GetRasterBand(band_idx)->RasterIO(GF_Read, 0, start_line, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ data_mat.col(0) = ((real_mat.array().cast()).array().pow(2)).log10() * 10.0;
+ _flag = true;
+ }
+ else if (gdal_datatype == GDT_UInt32) {
+ Eigen::MatrixX real_mat(line_num * width, 1);
+ rasterDataset->GetRasterBand(band_idx)->RasterIO(GF_Read, 0, start_line, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ data_mat.col(0) = ((real_mat.array().cast()).array().pow(2)).log10() * 10.0;
+ _flag = true;
+ }
+ else if (gdal_datatype == GDT_Int32) {
+ Eigen::MatrixX real_mat(line_num * width, 1);
+ rasterDataset->GetRasterBand(band_idx)->RasterIO(GF_Read, 0, start_line, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ data_mat.col(0) = ((real_mat.array().cast()).array().pow(2)).log10() * 10.0;
+ _flag = true;
+ }
+ //else if (gdal_datatype == GDT_UInt64) {
+ // Eigen::MatrixX real_mat(line_num * width, 1);
+ // rasterDataset->GetRasterBand(band_idx)->RasterIO(GF_Read, 0, start_line, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ // data_mat.col(0) = ((real_mat.array().cast()).array().pow(2)).log10() * 10.0;
+ // _flag = true;
+ //}
+ //else if (gdal_datatype == GDT_Int64) {
+ // Eigen::MatrixX real_mat(line_num * width, 1);
+ // rasterDataset->GetRasterBand(band_idx)->RasterIO(GF_Read, 0, start_line, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ // data_mat.col(0) = ((real_mat.array().cast()).array().pow(2)).log10() * 10.0;
+ // _flag = true;
+ //}
+ else if (gdal_datatype == GDT_Float32) {
+ Eigen::MatrixX real_mat(line_num * width, 1);
+ rasterDataset->GetRasterBand(band_idx)->RasterIO(GF_Read, 0, start_line, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ data_mat.col(0) = ((real_mat.array().cast()).array().pow(2)).log10() * 10.0;
+ _flag = true;
+ }
+ else if (gdal_datatype == GDT_Float64) {
+ Eigen::MatrixX real_mat(line_num * width, 1);
+ rasterDataset->GetRasterBand(band_idx)->RasterIO(GF_Read, 0, start_line, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
+ data_mat.col(0) = ((real_mat.array().cast()).array().pow(2)).log10() * 10.0;
+ _flag = true;
+ }
+ else {}
+
+
+ return data_mat;
+}
+
+Eigen::MatrixXd getGeoTranslationArray(QString in_path)
+{
+
+
+
+ return Eigen::MatrixXd();
+}
+
+ImageGEOINFO getImageINFO(QString in_path)
+{
+ std::shared_ptr df = OpenDataset(in_path);
+ int width = df->GetRasterXSize();
+ int heigh = df->GetRasterYSize();
+ int band_num = df->GetRasterCount();
+ ImageGEOINFO result;
+ result.width = width;
+ result.height = heigh;
+ result.bandnum = band_num;
+
+ return result;
+}
+
+GDALDataType getGDALDataType(QString fileptah)
+{
+ omp_lock_t lock;
+ omp_init_lock(&lock);
+ omp_set_lock(&lock);
+ GDALAllRegister();
+
+ GDALDataset* rasterDataset = (GDALDataset*)(GDALOpen(fileptah.toUtf8().constData(), GA_ReadOnly));//��ֻ�ʽ��ȡ�Ӱ��
+
+ GDALDataType gdal_datatype = rasterDataset->GetRasterBand(1)->GetRasterDataType();
+
+ GDALClose((GDALDatasetH)rasterDataset);
+ omp_unset_lock(&lock); //�ͷŻ��
+ omp_destroy_lock(&lock); //ٻ��
+
+ return gdal_datatype;
+}
+
+
+gdalImage::gdalImage()
+{
+ this->height = 0;
+ this->width = 0;
+ this->data_band_ids = 1;
+ this->start_row = 0;
+ this->start_col = 0;
+}
+
+///
+/// �ͼȡӰ�?1?7
+///
+///
+gdalImage::gdalImage(const QString& raster_path)
+{
+ omp_lock_t lock;
+ omp_init_lock(&lock); // ��ʼ��
+ omp_set_lock(&lock); //��û�?1?7
+ this->img_path = raster_path;
+
+ GDALAllRegister();// עʽ��?1?7
+ // ��DEMӰ��
+ GDALDataset* rasterDataset = (GDALDataset*)(GDALOpen(raster_path.toUtf8().constData(), GA_ReadOnly));//��ֻ�ʽ��ȡ�Ӱ��
+ this->width = rasterDataset->GetRasterXSize();
+ this->height = rasterDataset->GetRasterYSize();
+ this->band_num = rasterDataset->GetRasterCount();
+
+ double* gt = new double[6];
+ // ��÷���
+ rasterDataset->GetGeoTransform(gt);
+ this->gt = Eigen::MatrixXd(2, 3);
+ this->gt << gt[0], gt[1], gt[2], gt[3], gt[4], gt[5];
+
+ this->projection = rasterDataset->GetProjectionRef();
+ // ��
+ //double* inv_gt = new double[6];;
+ //GDALInvGeoTransform(gt, inv_gt); // ��
+ // �ͶӰ
+ GDALFlushCache((GDALDatasetH)rasterDataset);
+ GDALClose((GDALDatasetH)rasterDataset);
+ rasterDataset = NULL;// ָÿ�
+ this->InitInv_gt();
+ delete[] gt;
+ ////GDALDestroy(); // or, DllMain at DLL_PROCESS_DETACH
+ omp_unset_lock(&lock); //�ͷŻ��
+ omp_destroy_lock(&lock); //ٻ��
+}
+
+gdalImage::~gdalImage()
+{
+}
+
+void gdalImage::setHeight(int height)
+{
+ this->height = height;
+}
+
+void gdalImage::setWidth(int width)
+{
+ this->width = width;
+}
+
+void gdalImage::setTranslationMatrix(Eigen::MatrixXd gt)
+{
+ this->gt = gt;
+}
+
+void gdalImage::setData(Eigen::MatrixXd, int data_band_ids)
+{
+ this->data = data;
+ this->data_band_ids = data_band_ids;
+}
+
+
+
+Eigen::MatrixXd gdalImage::getData(int start_row, int start_col, int rows_count, int cols_count, int band_ids = 1)
+{
+ omp_lock_t lock;
+ omp_init_lock(&lock);
+ omp_set_lock(&lock);
+ GDALAllRegister();
+
+ GDALDataset* rasterDataset = (GDALDataset*)(GDALOpen(this->img_path.toUtf8().constData(), GA_ReadOnly));//��ֻ�ʽ��ȡ�Ӱ��
+
+ GDALDataType gdal_datatype = rasterDataset->GetRasterBand(1)->GetRasterDataType();
+ GDALRasterBand* demBand = rasterDataset->GetRasterBand(band_ids);
+
+ rows_count = start_row + rows_count <= this->height ? rows_count : this->height - start_row;
+ cols_count = start_col + cols_count <= this->width ? cols_count : this->width - start_col;
+
+ MatrixXd datamatrix(rows_count, cols_count);
+
+
+ if (gdal_datatype == GDT_Byte) {
+ char* temp = new char[rows_count * cols_count];
+ demBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, temp, cols_count, rows_count, gdal_datatype, 0, 0);
+ for (int i = 0; i < rows_count; i++) {
+ for (int j = 0; j < cols_count; j++) {
+ datamatrix(i, j) = temp[i * cols_count + j];
+ }
+ }
+ delete[] temp;
+ }
+ else if (gdal_datatype == GDT_UInt16) {
+ unsigned short* temp = new unsigned short[rows_count * cols_count];
+ demBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, temp, cols_count, rows_count, gdal_datatype, 0, 0);
+ for (int i = 0; i < rows_count; i++) {
+ for (int j = 0; j < cols_count; j++) {
+ datamatrix(i, j) = temp[i * cols_count + j];
+ }
+ }
+ delete[] temp;
+ }
+ else if (gdal_datatype == GDT_Int16) {
+ short* temp = new short[rows_count * cols_count];
+ demBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, temp, cols_count, rows_count, gdal_datatype, 0, 0);
+ for (int i = 0; i < rows_count; i++) {
+ for (int j = 0; j < cols_count; j++) {
+ datamatrix(i, j) = temp[i * cols_count + j];
+ }
+ }
+ delete[] temp;
+ }
+ else if (gdal_datatype == GDT_UInt32) {
+ unsigned int* temp = new unsigned int[rows_count * cols_count];
+ demBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, temp, cols_count, rows_count, gdal_datatype, 0, 0);
+ for (int i = 0; i < rows_count; i++) {
+ for (int j = 0; j < cols_count; j++) {
+ datamatrix(i, j) = temp[i * cols_count + j];
+ }
+ }
+ delete[] temp;
+ }
+ else if (gdal_datatype == GDT_Int32) {
+ int* temp = new int[rows_count * cols_count];
+ demBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, temp, cols_count, rows_count, gdal_datatype, 0, 0);
+ for (int i = 0; i < rows_count; i++) {
+ for (int j = 0; j < cols_count; j++) {
+ datamatrix(i, j) = temp[i * cols_count + j];
+ }
+ }
+ delete[] temp;
+ }
+ //else if (gdal_datatype == GDT_UInt64) {
+ // unsigned long* temp = new unsigned long[rows_count * cols_count];
+ // demBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, temp, cols_count, rows_count, gdal_datatype, 0, 0);
+ // for (int i = 0; i < rows_count; i++) {
+ // for (int j = 0; j < cols_count; j++) {
+ // datamatrix(i, j) = temp[i * cols_count + j];
+ // }
+ // }
+ // delete[] temp;
+ //}
+ //else if (gdal_datatype == GDT_Int64) {
+ // long* temp = new long[rows_count * cols_count];
+ // demBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, temp, cols_count, rows_count, gdal_datatype, 0, 0);
+ // for (int i = 0; i < rows_count; i++) {
+ // for (int j = 0; j < cols_count; j++) {
+ // datamatrix(i, j) = temp[i * cols_count + j];
+ // }
+ // }
+ // delete[] temp;
+ //}
+ else if (gdal_datatype == GDT_Float32) {
+ float* temp = new float[rows_count * cols_count];
+ demBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, temp, cols_count, rows_count, gdal_datatype, 0, 0);
+
+ for (int i = 0; i < rows_count; i++) {
+ for (int j = 0; j < cols_count; j++) {
+ datamatrix(i, j) = temp[i * cols_count + j];
+ }
+ }
+ delete[] temp;
+ }
+ else if (gdal_datatype == GDT_Float64) {
+ double* temp = new double[rows_count * cols_count];
+ demBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, temp, cols_count, rows_count, gdal_datatype, 0, 0);
+
+ for (int i = 0; i < rows_count; i++) {
+ for (int j = 0; j < cols_count; j++) {
+ datamatrix(i, j) = temp[i * cols_count + j];
+ }
+ }
+ delete[] temp;
+ }
+ else {}
+ GDALClose((GDALDatasetH)rasterDataset);
+ omp_unset_lock(&lock); //�ͷŻ��
+ omp_destroy_lock(&lock); //ٻ��
+ //GDALDestroy(); // or, DllMain at DLL_PROCESS_DETACH
+ return datamatrix;
+
+}
+
+Eigen::MatrixXd gdalImage::getGeoTranslation()
+{
+ return this->gt;
+}
+
+GDALDataType gdalImage::getDataType()
+{
+ GDALDataset* rasterDataset = (GDALDataset*)(GDALOpen(this->img_path.toUtf8().constData(), GA_ReadOnly));
+ GDALDataType gdal_datatype = rasterDataset->GetRasterBand(1)->GetRasterDataType();
+ return gdal_datatype;
+}
+
+///
+/// д��ң��Ӱ��
+///
+///
+///
+///
+///
+void gdalImage::saveImage(Eigen::MatrixXd data, int start_row = 0, int start_col = 0, int band_ids = 1)
+{
+ omp_lock_t lock;
+ omp_init_lock(&lock);
+ omp_set_lock(&lock);
+ if (start_row + data.rows() > this->height || start_col + data.cols() > this->width) {
+ QString tip = u8"file path: " + this->img_path;
+ qDebug() << tip;
+ throw exception(tip.toUtf8().constData());
+ }
+ GDALAllRegister();
+ GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName("GTiff");
+ GDALDataset* poDstDS = nullptr;
+ if (exists_test(this->img_path)) {
+ poDstDS = (GDALDataset*)(GDALOpen(this->img_path.toUtf8().constData(), GA_Update));
+ }
+ else {
+ poDstDS = poDriver->Create(this->img_path.toUtf8().constData(), this->width, this->height, this->band_num, GDT_Float32, NULL); // ���
+ poDstDS->SetProjection(this->projection.toUtf8().constData());
+
+
+ double gt_ptr[6];
+ for (int i = 0; i < this->gt.rows(); i++) {
+ for (int j = 0; j < this->gt.cols(); j++) {
+ gt_ptr[i * 3 + j] = this->gt(i, j);
+ }
+ }
+ poDstDS->SetGeoTransform(gt_ptr);
+ delete[] gt_ptr;
+ }
+
+ int datarows = data.rows();
+ int datacols = data.cols();
+
+ float* databuffer = new float[datarows * datacols];// (float*)malloc(datarows * datacols * sizeof(float));
+
+ for (int i = 0; i < datarows; i++) {
+ for (int j = 0; j < datacols; j++) {
+ float temp = float(data(i, j));
+ databuffer[i * datacols + j] = temp;
+ }
+ }
+ //poDstDS->RasterIO(GF_Write,start_col, start_row, datacols, datarows, databuffer, datacols, datarows, GDT_Float32,band_ids, num,0,0,0);
+ poDstDS->GetRasterBand(band_ids)->RasterIO(GF_Write, start_col, start_row, datacols, datarows, databuffer, datacols, datarows, GDT_Float32, 0, 0);
+
+ GDALFlushCache(poDstDS);
+ GDALClose((GDALDatasetH)poDstDS);
+ //GDALDestroy(); // or, DllMain at DLL_PROCESS_DETACH
+ delete[] databuffer;
+ omp_unset_lock(&lock); //�ͷŻ��
+ omp_destroy_lock(&lock); //ٻ��
+}
+
+void gdalImage::saveImage()
+{
+ this->saveImage(this->data, this->start_row, this->start_col, this->data_band_ids);
+}
+
+void gdalImage::setNoDataValue(double nodatavalue = -9999, int band_ids = 1)
+{
+ GDALAllRegister();// עʽ��?1?7
+ //GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName("GTiff");
+ GDALDataset* poDstDS = (GDALDataset*)(GDALOpen(img_path.toUtf8().constData(), GA_Update));
+ poDstDS->GetRasterBand(band_ids)->SetNoDataValue(nodatavalue);
+ GDALFlushCache((GDALDatasetH)poDstDS);
+ GDALClose((GDALDatasetH)poDstDS);
+}
+
+int gdalImage::InitInv_gt()
+{
+ //1 lon lat = x
+ //1 lon lat = y
+ Eigen::MatrixXd temp=Eigen::MatrixXd::Zero(2, 3);
+ this->inv_gt = temp;
+ double a = this->gt(0, 0);
+ double b = this->gt(0, 1);
+ double c = this->gt(0, 2);
+ double d = this->gt(1, 0);
+ double e = this->gt(1, 1);
+ double f = this->gt(1, 2);
+ double g = 1;
+ double det_gt = b * f - c * e;
+ if (det_gt == 0) {
+ return 0;
+ }
+ this->inv_gt(0, 0) = (c * d - a * f) / det_gt; //2
+ this->inv_gt(0, 1) = f / det_gt; // lon
+ this->inv_gt(0, 2) = -c / det_gt; // lat
+ this->inv_gt(1, 0) = (a * e - b * d) / det_gt; //1
+ this->inv_gt(1, 1) = -e / det_gt; // lon
+ this->inv_gt(1, 2) = b / det_gt; // lat
+ return 1;
+}
+
+Landpoint gdalImage::getRow_Col(double lon, double lat)
+{
+ Landpoint p{ 0,0,0 };
+ p.lon = this->inv_gt(0, 0) + lon * this->inv_gt(0, 1) + lat * this->inv_gt(0, 2); //x
+ p.lat = this->inv_gt(1, 0) + lon * this->inv_gt(1, 1) + lat * this->inv_gt(1, 2); //y
+ return p;
+}
+
+Landpoint gdalImage::getLandPoint(double row, double col, double ati = 0)
+{
+ Landpoint p{ 0,0,0 };
+ p.lon = this->gt(0, 0) + col * this->gt(0, 1) + row * this->gt(0, 2); //x
+ p.lat = this->gt(1, 0) + col * this->gt(1, 1) + row * this->gt(1, 2); //y
+ p.ati = ati;
+ return p;
+}
+
+double gdalImage::mean(int bandids)
+{
+ double mean_value = 0;
+ double count = this->height * this->width;
+ int line_invert = 100;
+ int start_ids = 0;
+ do {
+ Eigen::MatrixXd sar_a = this->getData(start_ids, 0, line_invert, this->width, bandids);
+ mean_value = mean_value + sar_a.sum() / count;
+ start_ids = start_ids + line_invert;
+ } while (start_ids < this->height);
+ return mean_value;
+}
+
+double gdalImage::max(int bandids)
+{
+ double max_value = 0;
+ bool state_max = true;
+ int line_invert = 100;
+ int start_ids = 0;
+ double temp_max = 0;
+ do {
+ Eigen::MatrixXd sar_a = this->getData(start_ids, 0, line_invert, this->width, bandids);
+ if (state_max) {
+ state_max = false;
+ max_value = sar_a.maxCoeff();
+ }
+ else {
+ temp_max = sar_a.maxCoeff();
+ if (max_value < temp_max) {
+ max_value = temp_max;
+ }
+ }
+ start_ids = start_ids + line_invert;
+ } while (start_ids < this->height);
+ return max_value;
+}
+
+double gdalImage::min(int bandids)
+{
+ double min_value = 0;
+ bool state_min = true;
+ int line_invert = 100;
+ int start_ids = 0;
+ double temp_min = 0;
+ do {
+ Eigen::MatrixXd sar_a = this->getData(start_ids, 0, line_invert, this->width, bandids);
+ if (state_min) {
+ state_min = false;
+ min_value = sar_a.minCoeff();
+ }
+ else {
+ temp_min = sar_a.minCoeff();
+ if (min_value < temp_min) {
+ min_value = temp_min;
+ }
+ }
+ start_ids = start_ids + line_invert;
+ } while (start_ids < this->height);
+ return min_value;
+}
+
+GDALRPCInfo gdalImage::getRPC()
+{
+ CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");
+ CPLSetConfigOption("GDAL_DATA", "./data");
+ GDALAllRegister();//ע���
+ //���
+ GDALDataset* pDS = (GDALDataset*)GDALOpen(this->img_path.toUtf8().constData(), GA_ReadOnly);
+ //��Ԫ��л�ȡRPC��Ϣ
+ char** papszRPC = pDS->GetMetadata("RPC");
+
+ //�ȡ��RPC��Ϣ�ɽṹ�?1?7
+ GDALRPCInfo oInfo;
+ GDALExtractRPCInfo(papszRPC, &oInfo);
+
+ GDALClose((GDALDatasetH)pDS);
+
+ return oInfo;
+}
+
+Eigen::MatrixXd gdalImage::getLandPoint(Eigen::MatrixXd points)
+{
+ if (points.cols() != 3) {
+ throw new exception("the size of points is equit 3!!!");
+ }
+
+ Eigen::MatrixXd result(points.rows(), 3);
+ result.col(2) = points.col(2);// �߳�
+ points.col(2) = points.col(2).array() * 0 + 1;
+ points.col(0).swap(points.col(2));// �
+ Eigen::MatrixXd gts(3, 2);
+ gts.col(0) = this->gt.row(0);
+ gts.col(1) = this->gt.row(1);
+
+ result.block(0, 0, points.rows(), 2) = points * gts;
+ return result;
+}
+
+Eigen::MatrixXd gdalImage::getHist(int bandids)
+{
+ GDALAllRegister();// עʽ��?1?7
+ // ��DEMӰ��
+ GDALDataset* rasterDataset = (GDALDataset*)(GDALOpen(this->img_path.toUtf8().constData(), GA_ReadOnly));//��ֻ�ʽ��ȡ�Ӱ��
+
+ GDALDataType gdal_datatype = rasterDataset->GetRasterBand(1)->GetRasterDataType();
+ GDALRasterBand* xBand = rasterDataset->GetRasterBand(bandids);
+
+
+ double dfMin = this->min(bandids);
+ double dfMax = this->max(bandids);
+ int count = int((dfMax - dfMin) / 0.01);
+ count = count > 255 ? count : 255;
+ GUIntBig* panHistogram = new GUIntBig[count];
+ xBand->GetHistogram(dfMin, dfMax, count, panHistogram, TRUE, FALSE, NULL, NULL);
+ Eigen::MatrixXd result(count, 2);
+ double delta = (dfMax - dfMin) / count;
+ for (int i = 0; i < count; i++) {
+ result(i, 0) = dfMin + i * delta;
+ result(i, 1) = double(panHistogram[i]);
+ }
+ delete[] panHistogram;
+ GDALClose((GDALDatasetH)rasterDataset);
+ return result;
+}
+
+
+gdalImage CreategdalImage(const QString& img_path, int height, int width, int band_num, Eigen::MatrixXd gt, QString projection, bool need_gt,bool overwrite) {
+
+ if (exists_test(img_path.toUtf8().constData())) {
+ if (overwrite) {
+ gdalImage result_img(img_path);
+ return result_img;
+ }
+ else {
+ throw "file has exist!!!";
+ exit(1);
+ }
+ }
+ GDALAllRegister();// ע���ʽ�����?1?7
+ GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName("GTiff");
+ GDALDataset* poDstDS = poDriver->Create(img_path.toUtf8().constData(), width, height, band_num, GDT_Float32, NULL); // ������
+ if (need_gt) {
+ poDstDS->SetProjection(projection.toUtf8().constData());
+
+ // ����ת������
+ double gt_ptr[6] = { 0 };
+ for (int i = 0; i < gt.rows(); i++) {
+ for (int j = 0; j < gt.cols(); j++) {
+ gt_ptr[i * 3 + j] = gt(i, j);
+ }
+ }
+ poDstDS->SetGeoTransform(gt_ptr);
+ }
+ for (int i = 1; i <= band_num; i++) {
+ poDstDS->GetRasterBand(i)->SetNoDataValue(-9999);
+ }
+ GDALFlushCache((GDALDatasetH)poDstDS);
+ GDALClose((GDALDatasetH)poDstDS);
+ ////GDALDestroy(); // or, DllMain at DLL_PROCESS_DETACH
+ gdalImage result_img(img_path);
+ return result_img;
+}
+
+gdalImageComplex CreategdalImageComplex(const QString& img_path, int height, int width, int band_num, Eigen::MatrixXd gt, QString projection, bool need_gt, bool overwrite)
+{
+ if (exists_test(img_path.toUtf8().constData())) {
+ if (overwrite) {
+ gdalImageComplex result_img(img_path);
+ return result_img;
+ }
+ else {
+ throw "file has exist!!!";
+ exit(1);
+ }
+ }
+ GDALAllRegister();
+ GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName("ENVI");
+ GDALDataset* poDstDS = poDriver->Create(img_path.toUtf8().constData(), width, height, band_num, GDT_CFloat64, NULL);
+ if (need_gt) {
+ poDstDS->SetProjection(projection.toUtf8().constData());
+
+ // ����ת������
+ double gt_ptr[6] = { 0 };
+ for (int i = 0; i < gt.rows(); i++) {
+ for (int j = 0; j < gt.cols(); j++) {
+ gt_ptr[i * 3 + j] = gt(i, j);
+ }
+ }
+ poDstDS->SetGeoTransform(gt_ptr);
+ }
+ for (int i = 1; i <= band_num; i++) {
+ poDstDS->GetRasterBand(i)->SetNoDataValue(-9999);
+ }
+ GDALFlushCache((GDALDatasetH)poDstDS);
+ GDALClose((GDALDatasetH)poDstDS);
+ ////GDALDestroy(); // or, DllMain at DLL_PROCESS_DETACH
+ gdalImageComplex result_img(img_path);
+ return result_img;
+}
+
+
+int ResampleGDAL(const char* pszSrcFile, const char* pszOutFile, double* gt, int new_width, int new_height, GDALResampleAlg eResample)
+{
+ GDALAllRegister();
+ CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");
+ GDALDataset* pDSrc = (GDALDataset*)GDALOpen(pszSrcFile, GA_ReadOnly);
+ if (pDSrc == NULL)
+ {
+ return -1;
+ }
+
+ GDALDriver* pDriver = GetGDALDriverManager()->GetDriverByName("GTiff");
+ if (pDriver == NULL)
+ {
+ GDALClose((GDALDatasetH)(GDALDatasetH)pDSrc);
+ return -2;
+ }
+ int width = pDSrc->GetRasterXSize();
+ int height = pDSrc->GetRasterYSize();
+ int nBandCount = pDSrc->GetRasterCount();
+ GDALDataType dataType = pDSrc->GetRasterBand(1)->GetRasterDataType();
+
+ char* pszSrcWKT = NULL;
+ pszSrcWKT = const_cast(pDSrc->GetProjectionRef());
+
+ //���û��ͶӰ����?���һ�?1?7
+ if (strlen(pszSrcWKT) <= 0)
+ {
+ OGRSpatialReference oSRS;
+ oSRS.importFromEPSG(4326);
+ //oSRS.SetUTM(50, true); //������ ����120��
+ //oSRS.SetWellKnownGeogCS("WGS84");
+ oSRS.exportToWkt(&pszSrcWKT);
+ }
+ qDebug() << "GDALCreateGenImgProjTransformer " << endl;
+ void* hTransformArg;
+ hTransformArg = GDALCreateGenImgProjTransformer((GDALDatasetH)pDSrc, pszSrcWKT, NULL, pszSrcWKT, FALSE, 0.0, 1);
+ qDebug() << "no proj " << endl;
+ //(û��ͶӰ��Ӱ��������߲�??1?7)
+ if (hTransformArg == NULL)
+ {
+ GDALClose((GDALDatasetH)(GDALDatasetH)pDSrc);
+ return -3;
+ }
+ qDebug() << "has proj " << endl;
+ double dGeoTrans[6] = { 0 };
+ int nNewWidth = 0, nNewHeight = 0;
+ if (GDALSuggestedWarpOutput((GDALDatasetH)pDSrc, GDALGenImgProjTransform, hTransformArg, dGeoTrans, &nNewWidth, &nNewHeight) != CE_None)
+ {
+ GDALClose((GDALDatasetH)(GDALDatasetH)pDSrc);
+ return -3;
+ }
+
+ //GDALDestroyGenImgProjTransformer(hTransformArg);
+
+
+ GDALDataset* pDDst = pDriver->Create(pszOutFile, new_width, new_height, nBandCount, dataType, NULL);
+ if (pDDst == NULL)
+ {
+ GDALClose((GDALDatasetH)(GDALDatasetH)pDSrc);
+ return -2;
+ }
+
+ pDDst->SetProjection(pszSrcWKT);
+ pDDst->SetGeoTransform(gt);
+
+ GDALWarpOptions* psWo = GDALCreateWarpOptions();
+
+ //psWo->papszWarpOptions = CSLDuplicate(NULL);
+ psWo->eWorkingDataType = dataType;
+ psWo->eResampleAlg = eResample;
+
+ psWo->hSrcDS = (GDALDatasetH)pDSrc;
+ psWo->hDstDS = (GDALDatasetH)pDDst;
+ qDebug() << "GDALCreateGenImgProjTransformer" << endl;
+ psWo->pfnTransformer = GDALGenImgProjTransform;
+ psWo->pTransformerArg = GDALCreateGenImgProjTransformer((GDALDatasetH)pDSrc, pszSrcWKT, (GDALDatasetH)pDDst, pszSrcWKT, FALSE, 0.0, 1);;
+
+ qDebug() << "GDALCreateGenImgProjTransformer has created" << endl;
+ psWo->nBandCount = nBandCount;
+ psWo->panSrcBands = (int*)CPLMalloc(nBandCount * sizeof(int));
+ psWo->panDstBands = (int*)CPLMalloc(nBandCount * sizeof(int));
+ for (int i = 0; i < nBandCount; i++)
+ {
+ psWo->panSrcBands[i] = i + 1;
+ psWo->panDstBands[i] = i + 1;
+ }
+
+ GDALWarpOperation oWo;
+ if (oWo.Initialize(psWo) != CE_None)
+ {
+ GDALClose((GDALDatasetH)(GDALDatasetH)pDSrc);
+ GDALClose((GDALDatasetH)(GDALDatasetH)pDDst);
+ return -3;
+ }
+ qDebug() << "ChunkAndWarpImage:" << new_width << "," << new_height << endl;
+ oWo.ChunkAndWarpMulti(0, 0, new_width, new_height);
+ GDALFlushCache(pDDst);
+ qDebug() << "ChunkAndWarpImage over" << endl;
+ //GDALDestroyGenImgProjTransformer(psWo->pTransformerArg);
+ //GDALDestroyWarpOptions(psWo);
+ GDALClose((GDALDatasetH)(GDALDatasetH)pDSrc);
+ GDALClose((GDALDatasetH)(GDALDatasetH)pDDst);
+ ////GDALDestroy(); // or, DllMain at DLL_PROCESS_DETACH
+ return 0;
+}
+
+int ResampleGDALs(const char* pszSrcFile, int band_ids, GDALRIOResampleAlg eResample)
+{
+ GDALAllRegister();
+ CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");
+ GDALDataset* pDSrc = (GDALDataset*)GDALOpen(pszSrcFile, GA_Update);
+ if (pDSrc == NULL)
+ {
+ return -1;
+ }
+
+ GDALDataType gdal_datatype = pDSrc->GetRasterBand(1)->GetRasterDataType();
+
+ GDALRasterBand* demBand = pDSrc->GetRasterBand(band_ids);
+
+ int width = pDSrc->GetRasterXSize();
+ int height = pDSrc->GetRasterYSize();
+ int start_col = 0, start_row = 0, rows_count = 0, cols_count;
+
+ int row_delta = int(120000000 / width);
+
+ GDALRasterIOExtraArg psExtraArg;
+ INIT_RASTERIO_EXTRA_ARG(psExtraArg);
+ psExtraArg.eResampleAlg = eResample;
+
+ do {
+
+ rows_count = start_row + row_delta < height ? row_delta : height - start_row;
+ cols_count = width;
+
+ if (gdal_datatype == GDALDataType::GDT_UInt16) {
+
+ unsigned short* temp = new unsigned short[rows_count * cols_count];
+ demBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, temp, cols_count, rows_count, gdal_datatype, 0, 0);
+ demBand->RasterIO(GF_Write, start_col, start_row, cols_count, rows_count, temp, cols_count, rows_count, gdal_datatype, 0, 0, &psExtraArg);
+ delete[] temp;
+
+ }
+ else if (gdal_datatype == GDALDataType::GDT_Int16) {
+
+ short* temp = new short[rows_count * cols_count];
+ demBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, temp, cols_count, rows_count, gdal_datatype, 0, 0);
+ demBand->RasterIO(GF_Write, start_col, start_row, cols_count, rows_count, temp, cols_count, rows_count, gdal_datatype, 0, 0, &psExtraArg);
+ delete[] temp;
+ }
+ else if (gdal_datatype == GDALDataType::GDT_Float32) {
+ float* temp = new float[rows_count * cols_count];
+ demBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, temp, cols_count, rows_count, gdal_datatype, 0, 0);
+ demBand->RasterIO(GF_Write, start_col, start_row, cols_count, rows_count, temp, cols_count, rows_count, gdal_datatype, 0, 0, &psExtraArg);
+ delete[] temp;
+ }
+ start_row = start_row + rows_count;
+ } while (start_row < height);
+ GDALClose((GDALDatasetH)pDSrc);
+
+
+ return 0;
+}
+
+int saveMatrixXcd2TiFF(Eigen::MatrixXcd data, QString out_tiff_path)
+{
+ int rows = data.rows();
+ int cols = data.cols();
+
+ Eigen::MatrixXd gt = Eigen::MatrixXd::Zero(2, 3);
+
+ gdalImage image_tiff = CreategdalImage(out_tiff_path, rows, cols, 2, gt, "", false, true);// עﱣ
+ // ļ
+ Eigen::MatrixXd real_img = data.array().real();
+ Eigen::MatrixXd imag_img = data.array().imag();
+ image_tiff.saveImage(real_img, 0, 0, 1);
+ image_tiff.saveImage(imag_img, 0, 0, 2);
+ return -1;
+}
+
+
+gdalImageComplex::gdalImageComplex(const QString& raster_path)
+{
+ omp_lock_t lock;
+ omp_init_lock(&lock);
+ omp_set_lock(&lock);
+ this->img_path = raster_path;
+
+ GDALAllRegister();
+ GDALDataset* rasterDataset = (GDALDataset*)(GDALOpen(raster_path.toUtf8().constData(), GA_ReadOnly));//��ֻ�ʽ��ȡ�Ӱ��
+ this->width = rasterDataset->GetRasterXSize();
+ this->height = rasterDataset->GetRasterYSize();
+ this->band_num = rasterDataset->GetRasterCount();
+
+ double* gt = new double[6];
+ rasterDataset->GetGeoTransform(gt);
+ this->gt = Eigen::MatrixXd(2, 3);
+ this->gt << gt[0], gt[1], gt[2], gt[3], gt[4], gt[5];
+
+
+ double a = this->gt(0, 0);
+ double b = this->gt(0, 1);
+ double c = this->gt(0, 2);
+ double d = this->gt(1, 0);
+ double e = this->gt(1, 1);
+ double f = this->gt(1, 2);
+
+ this->projection = rasterDataset->GetProjectionRef();
+
+ // �ͶӰ
+ GDALFlushCache((GDALDatasetH)rasterDataset);
+ GDALClose((GDALDatasetH)rasterDataset);
+ rasterDataset = NULL;// ָÿ�
+ this->InitInv_gt();
+ delete[] gt;
+ ////GDALDestroy(); // or, DllMain at DLL_PROCESS_DETACH
+ omp_unset_lock(&lock); //�ͷŻ��
+ omp_destroy_lock(&lock); //ٻ��
+
+
+}
+
+gdalImageComplex::~gdalImageComplex()
+{
+}
+
+void gdalImageComplex::setData(Eigen::MatrixXcd data)
+{
+ this->data = data;
+}
+
+void gdalImageComplex::saveImage(Eigen::MatrixXcd data, int start_row, int start_col, int band_ids)
+{
+ omp_lock_t lock;
+ omp_init_lock(&lock);
+ omp_set_lock(&lock);
+ if (start_row + data.rows() > this->height || start_col + data.cols() > this->width) {
+ QString tip = u8"file path: " + this->img_path;
+ qDebug() << tip;
+ throw exception(tip.toUtf8().constData());
+ }
+ GDALAllRegister();
+ GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName("ENVI");
+ GDALDataset* poDstDS = nullptr;
+ if (exists_test(this->img_path)) {
+ poDstDS = (GDALDataset*)(GDALOpen(this->img_path.toUtf8().constData(), GA_Update));
+ }
+ else {
+ poDstDS = poDriver->Create(this->img_path.toUtf8().constData(), this->width, this->height, this->band_num, GDT_CFloat64, NULL); // ���
+ poDstDS->SetProjection(this->projection.toUtf8().constData());
+
+
+ double gt_ptr[6];
+ for (int i = 0; i < this->gt.rows(); i++) {
+ for (int j = 0; j < this->gt.cols(); j++) {
+ gt_ptr[i * 3 + j] = this->gt(i, j);
+ }
+ }
+ poDstDS->SetGeoTransform(gt_ptr);
+ delete[] gt_ptr;
+ }
+
+ int datarows = data.rows();
+ int datacols = data.cols();
+
+ double* databuffer = new double[data.size() * 2];
+ for (int i = 0; i < data.rows(); i++) {
+ for (int j = 0; j < data.cols(); j++) {
+ databuffer[i * data.cols() * 2 + j * 2] = data(i, j).real();
+ databuffer[i * data.cols() * 2 + j * 2 + 1] = data(i, j).imag();
+ }
+ }
+
+ //poDstDS->RasterIO(GF_Write,start_col, start_row, datacols, datarows, databuffer, datacols, datarows, GDT_Float32,band_ids, num,0,0,0);
+ poDstDS->GetRasterBand(band_ids)->RasterIO(GF_Write, start_col, start_row, datacols, datarows, databuffer, datacols, datarows, GDT_CFloat64, 0, 0);
+ GDALFlushCache(poDstDS);
+ delete databuffer;
+ GDALClose((GDALDatasetH)poDstDS);
+ //GDALDestroy(); // or, DllMain at DLL_PROCESS_DETACH
+ omp_unset_lock(&lock); //�ͷŻ��
+ omp_destroy_lock(&lock); //ٻ��
+
+}
+
+Eigen::MatrixXcd gdalImageComplex::getDataComplex(int start_row, int start_col, int rows_count, int cols_count, int band_ids)
+{
+
+
+ GDALDataset* poDataset;
+ GDALAllRegister();
+
+ // TIFFļ
+ poDataset = (GDALDataset*)GDALOpen(this->img_path.toUtf8().constData(), GA_ReadOnly);
+ if (poDataset == nullptr) {
+ QMessageBox::warning(nullptr, u8"", u8"ļ" + this->img_path);
+ qDebug() << u8"ļ" + this->img_path;
+ }
+
+ // ȡݼĵһ
+ GDALRasterBand* poBand;
+ poBand = poDataset->GetRasterBand(1);
+
+ // ȡϢǸ
+ int nXSize = poBand->GetXSize();
+ int nYSize = poBand->GetYSize();
+
+
+ double* databuffer = new double[nXSize * nYSize * 2];
+ poBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, databuffer, cols_count, rows_count, GDT_CFloat64, 0, 0);
+ GDALClose((GDALDatasetH)poDataset);
+ Eigen::MatrixXcd rasterData(nYSize, nXSize); // ʹEigenMatrixXcd
+ for (size_t i = 0; i < nYSize; i++)
+ {
+ for (size_t j = 0; j < nXSize; j++) {
+ rasterData(i, j) = std::complex(databuffer[i * nXSize * 2 + j * 2], databuffer[i * nXSize * 2 + j * 2 + 1]);
+ }
+ }
+
+ delete databuffer;
+ return rasterData;
+
+}
+
+void gdalImageComplex::saveImage()
+{
+ this->saveImage(this->data, this->start_row, this->start_col, this->data_band_ids);
+}
+
+
\ No newline at end of file
diff --git a/src/LAMPTool/BaseToollib/ImageOperatorBase.h b/src/LAMPTool/BaseToollib/ImageOperatorBase.h
new file mode 100644
index 0000000..eccede4
--- /dev/null
+++ b/src/LAMPTool/BaseToollib/ImageOperatorBase.h
@@ -0,0 +1,190 @@
+#pragma once
+/**
+ * Ӱݲ
+ * صIJǻENVIݸʽ
+ * Ӱдʱ GDAL
+ * **/
+
+
+
+#ifndef IMAGEOPERATORBASE_H
+#define IMAGEOPERATORBASE_H
+
+#include "BaseToollib/BaseConstVariable.h"
+#include "BaseToollib/GeoOperator.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include // for CPLMalloc()
+#include "referenceHeader.h"
+using namespace std;
+using namespace Eigen;
+
+struct ImageGEOINFO {
+ int width;
+ int height;
+ int bandnum;
+};
+
+
+// жǷҪΪDLL
+#define DLLOUT
+// ļ
+std::shared_ptr OpenDataset(const QString& in_path, GDALAccess rwmode= GA_ReadOnly); // ָʱGDALClose
+void CloseDataset(GDALDataset* ptr);
+
+// ݸʽת
+int TIFF2ENVI(QString in_tiff_path,QString out_envi_path);
+int ENVI2TIFF(QString in_envi_path,QString out_tiff_path);
+
+// Ӱ --ֱӱ ENVI ļ
+
+int CreateDataset(QString new_file_path, int height, int width, int band_num, double* gt, QString projection, GDALDataType gdal_dtype, bool need_gt); // ļ
+
+int saveDataset(QString new_file_path, int start_line, int start_cols, int band_ids, int datacols, int datarows, void* databuffer);
+
+// ֿС
+int block_num_pre_memory(int width, int height, GDALDataType gdal_dtype,double memey_size);
+
+// תΪ ʵ
+Eigen::Matrix ReadComplexMatrixData(int start_line,int width, int line_num, std::shared_ptr rasterDataset, GDALDataType gdal_datatype);
+
+Eigen::Matrix ReadMatrixDoubleData(int start_line, int width, int line_num, std::shared_ptr rasterDataset, GDALDataType gdal_datatype,int band_idx);
+
+Eigen::MatrixXd getGeoTranslationArray(QString in_path);
+ImageGEOINFO getImageINFO(QString in_path);
+
+GDALDataType getGDALDataType(QString fileptah);
+
+
+struct DemBox {
+ double min_lat; //γ
+ double min_lon;//
+ double max_lat;//γ
+ double max_lon;//
+};
+
+
+///
+/// gdalImageͼ
+///
+class gdalImage
+{
+
+public: //
+ gdalImage();
+ gdalImage(const QString& raster_path);
+ ~gdalImage();
+ virtual void setHeight(int);
+ virtual void setWidth(int);
+ virtual void setTranslationMatrix(Eigen::MatrixXd gt);
+ virtual void setData(Eigen::MatrixXd,int data_band_ids=1);
+ virtual Eigen::MatrixXd getData(int start_row, int start_col, int rows_count, int cols_count, int band_ids);
+ virtual Eigen::MatrixXd getGeoTranslation();
+ virtual GDALDataType getDataType();
+ virtual void saveImage(Eigen::MatrixXd, int start_row, int start_col, int band_ids);
+ virtual void saveImage();
+ virtual void setNoDataValue(double nodatavalue, int band_ids);
+ virtual int InitInv_gt();
+ virtual Landpoint getRow_Col(double lon, double lat);
+ virtual Landpoint getLandPoint(double i, double j, double ati);
+ virtual double mean(int bandids = 1);
+ virtual double max(int bandids = 1);
+ virtual double min(int bandids = 1);
+ virtual GDALRPCInfo getRPC();
+ virtual Eigen::MatrixXd getLandPoint(Eigen::MatrixXd points);
+
+ virtual Eigen::MatrixXd getHist(int bandids);
+public:
+ QString img_path; // ͼļ
+ int height; //
+ int width; //
+ int band_num;//
+ int start_row;//
+ int start_col;//
+ int data_band_ids;
+ Eigen::MatrixXd gt; // 任
+ Eigen::MatrixXd inv_gt; // 任
+ Eigen::MatrixXd data;
+ QString projection;
+};
+
+
+
+
+
+
+
+///
+/// gdalImageͼ
+///
+class gdalImageComplex:public gdalImage
+{
+
+public: //
+ gdalImageComplex(const QString& raster_path);
+ ~gdalImageComplex();
+ void setData(Eigen::MatrixXcd);
+ void saveImage(Eigen::MatrixXcd data, int start_row, int start_col, int band_ids);
+ Eigen::MatrixXcd getDataComplex(int start_row, int start_col, int rows_count, int cols_count, int band_ids);
+ void saveImage() override;
+
+public:
+ Eigen::MatrixXcd data;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+gdalImage CreategdalImage(const QString& img_path, int height, int width, int band_num, Eigen::MatrixXd gt, QString projection, bool need_gt = true, bool overwrite = false);
+gdalImageComplex CreategdalImageComplex(const QString& img_path, int height, int width, int band_num, Eigen::MatrixXd gt, QString projection, bool need_gt = true, bool overwrite = false);
+
+
+
+
+int ResampleGDAL(const char* pszSrcFile, const char* pszOutFile, double* gt, int new_width, int new_height, GDALResampleAlg eResample);
+
+int ResampleGDALs(const char* pszSrcFile, int band_ids, GDALRIOResampleAlg eResample = GRIORA_Bilinear);
+
+
+//--------------------- IJ -------------------------------
+
+int saveMatrixXcd2TiFF(Eigen::MatrixXcd data, QString out_tiff_path);
+
+//----------------------------------------------------
+
+
+
+#ifndef DLLOUT
+
+
+
+
+
+#else
+//#define DllExport __declspec( dllexport )
+//double __declspec(dllexport) ProcessMGCMathX_MGC(int Xbetaidx, int Xbwidx, double XTao, double satH, char* sigma_path, char* output_path,
+// double p1_x, double p1_y, double p2_x, double p2_y, double p3_x, double p3_y, double p4_x, double p4_y)
+
+#endif
+
+#endif
\ No newline at end of file
diff --git a/src/LAMPTool/BaseToollib/interpolation.cpp b/src/LAMPTool/BaseToollib/interpolation.cpp
new file mode 100644
index 0000000..0203513
--- /dev/null
+++ b/src/LAMPTool/BaseToollib/interpolation.cpp
@@ -0,0 +1,13 @@
+#include "BaseToolLib/interpolation.h"
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+
+namespace LampInterpolation {
+
+}
\ No newline at end of file
diff --git a/src/LAMPTool/BaseToollib/interpolation.h b/src/LAMPTool/BaseToollib/interpolation.h
new file mode 100644
index 0000000..e3e087e
--- /dev/null
+++ b/src/LAMPTool/BaseToollib/interpolation.h
@@ -0,0 +1,69 @@
+#pragma once
+
+#ifndef INTERPOLATION_H
+#define INTERPOLATION_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+namespace LampInterpolation {
+ enum interpolationtype {
+ nearest,
+ linear,
+ cubic,
+ };
+
+
+ ///
+ /// Ϊ 1xn
+ ///
+ template
+ std::complex interpolation(Eigen::MatrixX>& echo, double& index, interpolationtype methodtype)
+ {
+ assert(echo.rows() != 1 || echo.cols() >= index || index < 0); //
+ if (methodtype == interpolationtype::linear) {
+ return interpolationLinear(echo, index);
+ }
+ else if (methodtype == interpolationtype::cubic) {
+
+ }
+ else if (methodtype == interpolationtype::nearest) {
+ return interpolationNearest(echo, index);
+ }
+ else {}
+ return std::complex(0, 0);
+ };
+
+ template
+ std::complex interpolationLinear(Eigen::MatrixX>& echo, double& index)
+ {
+ size_t last_ids = size_t(std::floor(index));
+ size_t next_ids = size_t(std::ceil(index));
+
+ std::complex last_value = echo(1, last_ids);
+ std::complex next_value = echo(1, next_ids);
+
+ // ʵ鲿ͬʱֵ
+ double real = last_value.real() + ((next_value.real() - last_value.real()) / (next_ids - last_ids)) * (index - last_ids);
+ double imag = last_value.imag() + ((next_value.imag() - last_value.imag()) / (next_ids - last_ids)) * (index - last_ids);
+
+ return std::complex(T(real), T(imag));
+ };
+
+ template
+ std::complex interpolationNearest(Eigen::MatrixX>& echo, double& index)
+ {
+ size_t nearest_ids = size_t(std::round(index));
+ return echo(1, nearest_ids);
+ };
+
+}
+
+
+#endif
\ No newline at end of file
diff --git a/src/LAMPTool/BaseToollib/readme.md b/src/LAMPTool/BaseToollib/readme.md
new file mode 100644
index 0000000..671e01a
--- /dev/null
+++ b/src/LAMPTool/BaseToollib/readme.md
@@ -0,0 +1,2 @@
+# 说明
+此模块主要是通用基础模块
\ No newline at end of file
diff --git a/src/LAMPTool/CMakeLists.txt b/src/LAMPTool/CMakeLists.txt
new file mode 100644
index 0000000..823dd5f
--- /dev/null
+++ b/src/LAMPTool/CMakeLists.txt
@@ -0,0 +1,68 @@
+#-----------------------------------------------------------------------------
+# 头文件搜索路径
+#-----------------------------------------------------------------------------
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
+
+#-----------------------------------------------------------------------------
+# 自动添加include目录
+#-----------------------------------------------------------------------------
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+#-----------------------------------------------------------------------------
+# 添加资源文件
+#-----------------------------------------------------------------------------
+set(_qrc "${CMAKE_CURRENT_SOURCE_DIR}/../qrc/WBCLFZSystemModule.qrc")
+
+qt5_add_resources(_resource ${_qrc} ${_lang})
+
+#-----------------------------------------------------------------------------
+# 源码扫描
+#-----------------------------------------------------------------------------
+file(GLOB _ui "*.ui")
+file(GLOB _header "*.h*")
+file(GLOB _source "*.cpp")
+qt5_wrap_ui(_interface ${_ui})
+
+#-----------------------------------------------------------------------------
+# 添加动态库目标
+#-----------------------------------------------------------------------------
+add_library(LAMPTool
+ ${_resource}
+ ${_interface}
+ ${_header}
+ ${_source}
+)
+
+#-----------------------------------------------------------------------------
+# 添加接口声明宏
+#-----------------------------------------------------------------------------
+target_compile_definitions(LAMPTool PRIVATE "LAMPTool_API")
+
+
+
+
+list(APPEND _depend_library qcustomplot)
+
+list(APPEND _runtimes_libraries
+ Qt5::Core Qt5::Gui Qt5::Widgets
+)
+
+target_include_directories(LAMPTool PRIVATE ${Qwt_INCLUDE_DIRS})
+
+#-----------------------------------------------------------------------------
+# 链接依赖库
+#-----------------------------------------------------------------------------
+target_link_libraries(LAMPTool PRIVATE
+ ${_runtimes_libraries}
+ ${_depend_library}
+)
+
+#-----------------------------------------------------------------------------
+# 添加依赖关系
+#-----------------------------------------------------------------------------
+add_dependencies(LAMPTool ${_depend_library})
+
+#-----------------------------------------------------------------------------
+# 添加运行时依赖关系
+#-----------------------------------------------------------------------------
+set(FastCAE_LAMPTool_Runtimes_Libraries ${_runtimes_libraries} PARENT_SCOPE)
\ No newline at end of file
diff --git a/src/LAMPTool/FEKOFarFieldFileClass.cpp b/src/LAMPTool/FEKOFarFieldFileClass.cpp
new file mode 100644
index 0000000..0f24aa4
--- /dev/null
+++ b/src/LAMPTool/FEKOFarFieldFileClass.cpp
@@ -0,0 +1,446 @@
+#include "FEKOFarFieldFileClass.h"
+
+FEKOBase::FEKOFarFieldFileClass::FEKOFarFieldFileClass()
+{
+
+}
+
+FEKOBase::FEKOFarFieldFileClass::~FEKOFarFieldFileClass()
+{
+
+}
+
+void FEKOBase::FEKOFarFieldFileClass::parseFarFieldFile(const QString& fileName)
+{
+ QFile file(fileName);
+ // ıļеݵһ QString
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
+ {
+ qDebug() << "Failed to open file for reading";
+ return;
+ }
+ QTextStream in(&file);
+ QString line;
+ bool dataSectionStarted = false;
+
+
+ QList dataBlockStrList;
+ dataBlockStrList.clear();
+ while (!in.atEnd()) {
+ line = in.readLine().trimmed();
+ if (line.startsWith(u8"##")) {
+ if (line.indexOf(u8"File Type:") != -1) {
+ this->FileType = line.split(":")[1].trimmed();
+ }
+ else if (line.indexOf(u8"File Format:") != -1) {
+ this->FileFormat = line.split(":")[1].trimmed();
+ }
+ else if (line.indexOf(u8"Source:") != -1) {
+ this->Sourcestr = line.split(":")[1].trimmed();
+ }
+ else if (line.indexOf(u8"Date:") != -1) {
+ this->Datestr = line.split(":")[1].trimmed();
+ }
+ else {
+ continue;
+ }
+ }
+ else if (line.startsWith("**")) {
+ dataBlockStrList.clear();
+ continue;
+ }
+ else {
+ if (line.length() < 5) {
+ if (dataBlockStrList.length() > 0) {
+ FEKOFARFIELDFEKODATABLOCK temp_dataBlock;
+ temp_dataBlock.paraseFEKOFarFieldDataBlockFromList(dataBlockStrList);
+ this->dataBlockList.push_back(temp_dataBlock);
+ }
+ else {
+
+ }
+ dataBlockStrList.clear();
+ }
+ else {
+ dataBlockStrList.append(line);
+ }
+ }
+ }
+
+ if (dataBlockStrList.length() > 0) {
+ FEKOFARFIELDFEKODATABLOCK temp_dataBlock;
+ temp_dataBlock.paraseFEKOFarFieldDataBlockFromList(dataBlockStrList);
+ this->dataBlockList.push_back(temp_dataBlock);
+ }
+
+ file.close();
+}
+
+void FEKOBase::FEKOFarFieldFileClass::outputToFile(const QString& fileName)
+{
+ QFile file(fileName);
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
+ {
+ qDebug() << "Failed to open file for writing";
+ return;
+ }
+
+ QTextStream out(&file);
+
+ file.close();
+
+}
+
+FEKOBase::FEKOFARFIELDRESULTTYPE FEKOBase::FEKOFARFIELDRESULTTYPEString2Enum(QString str)
+{
+ if (str.toUpper() == "GAIN") { return FEKOBase::GAIN; }
+ else if (str.toUpper() == "DIRECTIVITY") { return FEKOBase::DIRECTIVITY; }
+ else if (str.toUpper() == "RCS") { return FEKOBase::RCS; }
+ else if (str.toUpper() == "FARFIELDVALUES") { return FEKOBase::FARFIELDVALUES; }
+ else {
+ return FEKOBase::FEKOFARFIELDRESULTTYPEUNKOWN;
+ }
+ return FEKOBase::FEKOFARFIELDRESULTTYPE();
+}
+
+QString FEKOBase::QString2FEKOFARFIELDRESULTTYPE(FEKOBase::FEKOFARFIELDRESULTTYPE mode)
+{
+ switch (mode) {
+ case FEKOBase::GAIN:
+ return "GAIN";
+ case FEKOBase::DIRECTIVITY:
+ return "DIRECTIVITY";
+ case FEKOBase::RCS:
+ return "RCS";
+ case FEKOBase::FARFIELDVALUES:
+ return "FARFIELDVALUES";
+ default:
+ return "FEKOFARFIELDRESULTTYPEUNKOWN";
+
+ }
+}
+
+FEKOBase::FEKOFARFIELDFEKODATABLOCK::FEKOFARFIELDFEKODATABLOCK()
+{
+ this->dataList.clear();
+ this->thetaSamples = 0;
+ this->phiSamples = 0;
+ this->USamples = 0;
+ this->VSamples = 0;
+ this->configurationName.clear();
+ this->requestName.clear();
+ this->frequency = 0;
+ this->Origin = { 0,0,0 };
+ this->headerLines = 0;
+ this->coordinateSystem = FEKOBase::UNKONWFEKOCOORDINATESYSTEM;
+ this->resultType = FEKOBase::FEKOFARFIELDRESULTTYPEUNKOWN;
+}
+
+FEKOBase::FEKOFARFIELDFEKODATABLOCK::~FEKOFARFIELDFEKODATABLOCK()
+{
+
+}
+
+int FEKOBase::FEKOFARFIELDFEKODATABLOCK::paraseFEKOFarFieldDataBlock(const QString& blockstr)
+{
+ // нн
+ QList lines= blockstr.split("\n");
+ return this->paraseFEKOFarFieldDataBlockFromList(lines);
+ return 1;
+
+}
+
+int FEKOBase::FEKOFARFIELDFEKODATABLOCK::paraseFEKOFarFieldDataBlockFromList(QList& lines)
+{
+ bool in_readHeaderState = false;
+ size_t headerlineCount = 0;
+ std::vector headerLines;// ʱ֤
+
+
+ for (size_t i = 0; i < lines.size(); i++) {
+ if (lines[i].startsWith("#")) { // # ͷΪ
+ // Բͬȡ
+ QString configName = normalizationHeaderString(lines[i]); // ȡĹһ
+ if (configName == u8"") { // δ֪
+ // ֶν״̬
+ if (in_readHeaderState) { // ֶ
+ QList temp_headerLines=lines[i].split(FEKOFARFIELDSPLITCHAT);
+ for (size_t ii = 0; ii < temp_headerLines.size();ii++) {
+ if (temp_headerLines[ii].length() > 2) {
+ QString temp_header_str= this->normalizationHeaderString(temp_headerLines[ii]);
+ headerLines.push_back(temp_header_str);
+ }
+ else {
+ continue;
+ }
+ }
+ headerlineCount++;
+ if (headerlineCount >= this->headerLines) {
+ in_readHeaderState = false;
+ }
+ }
+ else {
+ continue;
+ }
+ }
+ else if (configName == u8"ConfigurationName") {
+ this->configurationName = lines[i].split(":")[1].trimmed();
+ }
+ else if (configName == u8"RequestName") {
+ this->requestName = lines[i].split(":")[1].trimmed();
+ }
+ else if (configName == u8"Frequency") {
+ this->frequency = lines[i].split(":")[1].trimmed().toDouble();
+ }
+ else if (configName == u8"CoordinateSystem") {
+ this->coordinateSystem = FEKOBase::FEKOCoordinateSystemString2Enum(lines[i].split(":")[1].trimmed());
+ }
+ else if (configName == u8"ThetaSamplePointsNumber") {
+ this->thetaSamples = lines[i].split(":")[1].trimmed().toInt();
+ }
+ else if (configName == u8"PhiSamplePointsNumber") {
+ this->phiSamples = lines[i].split(":")[1].trimmed().toInt();
+ }
+ else if (configName == u8"USamplePointNumber") {
+ this->USamples = lines[i].split(":")[1].trimmed().toInt();
+ }
+ else if (configName == u8"VSamplePointNumber") {
+ this->VSamples = lines[i].split(":")[1].trimmed().toInt();
+ }
+ else if (configName == u8"ORIGIN") {
+ QStringList originstrlist = lines[i].replace("(", "").replace(")", "").split(":")[1].trimmed().split(",");
+ this->Origin = { originstrlist[0].trimmed().toDouble(),originstrlist[1].trimmed().toDouble(),originstrlist[2].trimmed().toDouble() };
+ }
+ else if (configName == u8"ResultType") {
+ this->resultType = FEKOBase::FEKOFARFIELDRESULTTYPEString2Enum(lines[i].split(":")[1].trimmed());
+ }
+ else if (configName == u8"HeaderLines") {
+ this->headerLines = lines[i].split(":")[1].trimmed().toInt();
+ in_readHeaderState = true;
+
+ }
+ else {
+ continue;
+ }
+ }
+ else if (lines[i].size() > 10) { // ݿ
+ QList dataline = lines[i].split(FEKOFARFIELDSPLITCHAT);
+ FEKOBase::FEKOFarFieldFEKOFarFieldData temp_data;
+ long field_idx =-1;
+ for (size_t ii = 0; ii < dataline.count(); ii++) {
+ if (dataline[ii] == u8"") { continue; }
+ else { field_idx = field_idx + 1; }
+ if (headerLines[field_idx] == "theta") { temp_data.theta = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "phi") { temp_data.phi = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "re(etheta)") { temp_data.re_Etheta = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "im(etheta)") { temp_data.im_Etheta = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "re(ephi)") { temp_data.re_Ephi = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "im(ephi)") { temp_data.im_Ephi = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "gain(theta)") { temp_data.gain_Theta = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "gain(phi)") { temp_data.gain_Phi = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "gain(total)") { temp_data.gain_Total = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "radius") { temp_data.radius = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "x") { temp_data.X = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "y") { temp_data.Y = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "z") { temp_data.Z = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "re(ex)") { temp_data.re_Ex = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "re(ey)") { temp_data.re_Ey = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "re(ez)") { temp_data.re_Ez = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "im(ex)") { temp_data.im_Ex = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "im(ey)") { temp_data.im_Ey = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "im(ez)") { temp_data.im_Ez = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "re(er)") { temp_data.re_Er = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "im(er)") { temp_data.im_Er = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "u") { temp_data.U = dataline[ii].toDouble(); }
+ else if (headerLines[field_idx] == "v") { temp_data.V = dataline[ii].toDouble(); }
+ else {
+ continue;
+ }
+ }
+ this->dataList.push_back(temp_data);
+ }
+ else {
+ continue;
+ }
+
+ }
+ return 0;
+}
+
+QString FEKOBase::FEKOFARFIELDFEKODATABLOCK::normalizationHeaderString(QString headerstr)
+{
+ headerstr = headerstr.replace("'", "").replace(u8"\"",u8"");
+ if(headerstr.indexOf("#Configuration Name") != -1)
+ {
+ return u8"ConfigurationName";
+ }
+ else if (headerstr.indexOf("#Request Name") != -1)
+ {
+ return u8"RequestName";
+ }
+ else if (headerstr.indexOf("#Frequency") != -1)
+ {
+ return u8"Frequency";
+ }
+ else if (headerstr.indexOf("#Coordinate System:") != -1)
+ {
+ return u8"CoordinateSystem";
+ }
+ else if (headerstr.indexOf("#No. of Theta Samples:") != -1)
+ {
+ return u8"ThetaSamplePointsNumber";
+ }
+ else if (headerstr.indexOf("#No. of Phi Samples:") != -1)
+ {
+ return u8"PhiSamplePointsNumber";
+ }
+ else if (headerstr.indexOf("#No. of U Samples:") != -1)
+ {
+ return u8"USamplePointNumber";
+ }
+ else if (headerstr.indexOf("#No. of V Samples:") != -1)
+ {
+ return u8"VSamplePointNumber";
+ }
+ else if (headerstr.indexOf("#No. of X Samples:") != -1)
+ {
+ return u8"XSamplePointNumber";
+ }
+ else if (headerstr.indexOf("#No. of Y Samples:") != -1)
+ {
+ return u8"YSamplePointNumber";
+ }
+ else if (headerstr.indexOf("#No. of Z Samples:") != -1)
+ {
+ return u8"ZSamplePointNumber";
+ }
+ else if (headerstr.indexOf("#Origin:") != -1)
+ {
+ return u8"ORIGIN";
+ }
+ else if (headerstr.indexOf("#Result Type:") != -1)
+ {
+ return u8"ResultType";
+ }
+ else if (headerstr.indexOf("#No. of Header Lines:") != -1)
+ {
+ return u8"HeaderLines";
+ }
+ else if (headerstr.toLower().trimmed()==u8"theta"|| headerstr.toLower().trimmed() == u8"theta'") {
+ return u8"theta";
+ }
+ else if (headerstr.toLower().trimmed() == u8"phi"|| headerstr.toLower().trimmed() == u8"phi'") {
+ return u8"phi";
+ }
+ else if (headerstr.toLower().trimmed() == u8"re(etheta)"|| headerstr.toLower().trimmed() == u8"re(etheta')") {
+ return u8"re(etheta)";
+ }
+ else if (headerstr.toLower().trimmed() == u8"im(etheta)"|| headerstr.toLower().trimmed() == u8"im(etheta')") {
+ return u8"im(etheta)";
+ }
+ else if (headerstr.toLower().trimmed() == u8"re(ephi)"|| headerstr.toLower().trimmed() == u8"re(ephi')") {
+ return u8"re(ephi)";
+ }
+ else if (headerstr.toLower().trimmed() == u8"im(ephi)"|| headerstr.toLower().trimmed() == u8"im(ephi')") {
+ return u8"im(ephi)";
+ }
+ else if (headerstr.toLower().trimmed() == u8"re(er)"|| headerstr.toLower().trimmed() == u8"re(er')") {
+ return u8"re(ephi)";
+ }
+ else if (headerstr.toLower().trimmed() == u8"im(er)"|| headerstr.toLower().trimmed() == u8"im(er')") {
+ return u8"im(ephi)";
+ }
+ else if (headerstr.toLower().trimmed() == u8"gain(theta)"|| headerstr.toLower().trimmed() == u8"gain(theta')") {
+ return u8"gain(theta)";
+ }
+ else if (headerstr.toLower().trimmed() == u8"gain(phi)"|| headerstr.toLower().trimmed() == u8"gain(phi')") {
+ return u8"gain(phi)";
+ }
+ else if (headerstr.toLower().trimmed() == u8"gain(total)"|| headerstr.toLower().trimmed() == u8"gain(total')") {
+ return u8"gain(total)";
+ }
+ else if (headerstr.toLower().trimmed() == u8"radius"|| headerstr.toLower().trimmed() == u8"radius'") {
+ return u8"radius";
+ }
+ else if (headerstr.toLower().trimmed() == u8"x" || headerstr.toLower().trimmed() == "x'") {
+ return u8"x";
+ }
+ else if (headerstr.toLower().trimmed() == u8"y" || headerstr.toLower().trimmed() == "y'") {
+ return u8"y";
+ }
+ else if (headerstr.toLower().trimmed() == u8"z" || headerstr.toLower().trimmed() == "z'") {
+ return u8"z";
+ }
+ else if (headerstr.toLower().trimmed() == "re(ex)" || headerstr.toLower().trimmed() == "re(ex')") {
+ return u8"re(ex)";
+ }
+ else if (headerstr.toLower().trimmed() == "re(ey)" || headerstr.toLower().trimmed() == "re(ey')") {
+ return u8"re(ey)";
+ }
+ else if (headerstr.toLower().trimmed() == "re(ez)" || headerstr.toLower().trimmed() == "re(ez')") {
+ return u8"re(ez)";
+ }
+ else if (headerstr.toLower().trimmed() == "im(ex)" || headerstr.toLower().trimmed() == "im(ex')") {
+ return u8"im(ex)";
+ }
+ else if (headerstr.toLower().trimmed() == "im(ey)" || headerstr.toLower().trimmed() == "im(ey')") {
+ return u8"im(ey)";
+ }
+ else if (headerstr.toLower().trimmed() == "im(ez)" || headerstr.toLower().trimmed() == "im(ez')") {
+ return u8"im(ez)";
+ }
+ else if (headerstr.toLower().trimmed() == "re(er)" || headerstr.toLower().trimmed() == "re(er')") {
+ return u8"re(er)";
+ }
+ else if (headerstr.toLower().trimmed() == "im(er)" || headerstr.toLower().trimmed() == "im(er')") {
+ return u8"im(er)";
+ }
+ else if (headerstr.toLower().trimmed() == "u" || headerstr.toLower().trimmed() == "u'") {
+ return u8"u";
+ }
+ else if (headerstr.toLower().trimmed() == "v" || headerstr.toLower().trimmed() == "v'") {
+ return u8"v";
+ }
+ else {
+ return u8"";
+ }
+
+;
+}
+
+QString FEKOBase::FEKOFARFIELDFEKODATABLOCK::saveFEKOFarFieldDataBlock()
+{
+
+ switch (this->resultType) {
+ case FEKOBase::GAIN:
+ return this->saveFEKOFarFieldDataBlock_Gain();
+ case FEKOBase::DIRECTIVITY:
+ return this->saveFEKOFarFieldDataBlock_Directivity();
+ case FEKOBase::RCS:
+ return this->saveFEKOFarFieldDataBlock_RCS();
+ case FEKOBase::FARFIELDVALUES:
+ return this->saveFEKOFarFieldDataBlock_FarFieldValues();
+ default:
+ return QString();
+ }
+}
+
+QString FEKOBase::FEKOFARFIELDFEKODATABLOCK::saveFEKOFarFieldDataBlock_Gain()
+{
+ return QString();
+}
+
+QString FEKOBase::FEKOFARFIELDFEKODATABLOCK::saveFEKOFarFieldDataBlock_Directivity()
+{
+ return QString();
+}
+
+QString FEKOBase::FEKOFARFIELDFEKODATABLOCK::saveFEKOFarFieldDataBlock_RCS()
+{
+ return QString();
+}
+
+QString FEKOBase::FEKOFARFIELDFEKODATABLOCK::saveFEKOFarFieldDataBlock_FarFieldValues()
+{
+ return QString();
+}
diff --git a/src/LAMPTool/FEKOFarFieldFileClass.h b/src/LAMPTool/FEKOFarFieldFileClass.h
new file mode 100644
index 0000000..e778bb4
--- /dev/null
+++ b/src/LAMPTool/FEKOFarFieldFileClass.h
@@ -0,0 +1,138 @@
+#pragma once
+
+#ifndef FARFIELDFILECLASS_H
+#define FARFIELDFILECLASS_H
+#include "referenceHeader.h"
+#include "SARImage/FEKOBaseToolClass.h"
+
+
+namespace FEKOBase {
+ //
+ // altair feko user guide 2018.1
+ // ½ A-10 summary of feko file formats
+ //
+
+ const QString FEKOFARFIELDSPLITCHAT = u8" ";
+
+ enum FEKOFARFIELDRESULTTYPE {
+ GAIN, //
+ DIRECTIVITY,// 糡
+ RCS,// ɢϵ
+ FARFIELDVALUES,// Զֵ
+ FEKOFARFIELDRESULTTYPEUNKOWN
+ };
+ FEKOBase::FEKOFARFIELDRESULTTYPE FEKOFARFIELDRESULTTYPEString2Enum(QString str);
+ QString QString2FEKOFARFIELDRESULTTYPE(FEKOBase::FEKOFARFIELDRESULTTYPE mode);
+
+
+
+//==========================================================
+// FEKO ļ farfield ļ ffe
+// ffe ļ
+//==========================================================
+ struct FEKOFarFieldFEKOFarFieldData //
+ {
+ double X=0;// cartesian coordinate system
+ double Y=0;
+ double Z=0;
+ double U=0; // cartesian coordinate system
+ double V=0;
+ double radius=0; // nearfield
+ double theta=0; // spherical coordinate system
+ double phi=0;
+ double re_Er=0;
+ double im_Er=0;
+ double re_Etheta=0; // theta
+ double im_Etheta=0;
+ double re_Ephi=0; // phi
+ double im_Ephi=0;
+ double re_Ex=0;// X
+ double im_Ex=0;
+ double re_Ey=0; //y
+ double im_Ey=0;
+ double re_Ez=0; //z
+ double im_Ez=0;
+ double gain_Theta=0; // gain in spherical coordinate system
+ double gain_Phi=0;
+ double gain_Total=0;
+ double directivity_Theta=0; // directivity in spherical coordinate system
+ double directivity_Phi = 0;
+ double directivity_total = 0;
+ double RCS_theta = 0;// RCS in spherical coordinate system
+ double RCS_phi = 0;
+ double RCS_total = 0;
+ };
+
+ class FEKOFARFIELDFEKODATABLOCK { // ݿ
+ public:
+ FEKOFARFIELDFEKODATABLOCK();
+ ~FEKOFARFIELDFEKODATABLOCK();
+ public: //
+ QString configurationName;
+ QString requestName;
+ double frequency;
+ FEKOBase::FEKOCoordinateSystem coordinateSystem; //
+ FEKOBase::FEKOFARFIELDRESULTTYPE resultType;
+ long thetaSamples;
+ long phiSamples;
+ long USamples;
+ long VSamples;
+ CartesianCoordinates Origin; // ϵԭ
+ long headerLines;
+ QList dataList;
+ public: // غ
+ // ļ
+ int paraseFEKOFarFieldDataBlock(const QString& blockstr); // ݿ
+ int paraseFEKOFarFieldDataBlockFromList(QList& blockstr); // ݿ
+ QString normalizationHeaderString(QString headerstr);// ݿͷƽб
+
+ // ļ
+ QString saveFEKOFarFieldDataBlock(); // ݿַ
+ QString saveFEKOFarFieldDataBlock_Gain(); // ݿַ
+ QString saveFEKOFarFieldDataBlock_Directivity();
+ QString saveFEKOFarFieldDataBlock_RCS();
+ QString saveFEKOFarFieldDataBlock_FarFieldValues();
+ };
+
+
+
+
+
+
+
+class FEKOFarFieldFileClass: public QObject
+{
+ Q_OBJECT
+public:
+ FEKOFarFieldFileClass();
+ ~FEKOFarFieldFileClass();
+
+public:
+ QString FileType;
+ QString FileFormat;
+ QString Sourcestr;
+ QString Datestr;
+ QList dataBlockList;
+
+
+public:
+ void parseFarFieldFile(const QString& fileName);
+ void outputToFile(const QString& fileName);
+
+};
+
+
+
+//==========================================================
+// FEKO ļ nearfield ļ efe
+// efe ļ
+//==========================================================
+
+
+
+
+
+
+}
+#endif // ! FARFIELDFILECLASS_H
+
diff --git a/src/LAMPTool/FEKOSimulationSARClass.cpp b/src/LAMPTool/FEKOSimulationSARClass.cpp
new file mode 100644
index 0000000..177fcfc
--- /dev/null
+++ b/src/LAMPTool/FEKOSimulationSARClass.cpp
@@ -0,0 +1,1125 @@
+// ĴԵȡ벹
+#include "FEKOSimulationSARClass.h"
+#include "BaseToolLib/BaseConstVariable.h"
+#include