diff --git a/CMakeLists.txt b/CMakeLists.txt index 78bbac2..4be9833 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,6 +139,7 @@ list(APPEND QtNeededModules PrintSupport # QwtPolar DBus Qml DataVisualization Charts + ) if(LAMPCAE_LINUX) list(APPEND QtNeededModules XcbQpa) @@ -211,6 +212,21 @@ find_package(Gmsh REQUIRED) # Python find_package(Python REQUIRED) +# OpenMesh +find_package(OpenMesh CONFIG REQUIRED) + +# VCGLIB +find_path(VCGLIB_INCLUDE_DIRS "img/img.h") +# FFTW3 +find_package(FFTW3 CONFIG REQUIRED) +# gsl +find_package(GSL REQUIRED) +#GDAL +find_package(GDAL CONFIG REQUIRED) + + + + message("CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR}") @@ -226,9 +242,10 @@ include_directories(SYSTEM C:/PCL/3rdParty/VTK/include/vtk-9.3) include_directories(SYSTEM C:/PCL/include/pcl-1.14) set(CMAKE_INCLUDE_CURRENT_DIR ON) -find_package(Qt5 REQUIRED COMPONENTS Core Quick Sql Core Xml Opengl Gui Svg Xmlpatterns Uitools Widgets Qml Printsupport Sensors Quickwidgets Quick Concurrent Openglextensions Charts Datavisualization) +find_package(Qt5 REQUIRED COMPONENTS Test Core Quick Sql Core Xml Opengl Gui Svg Xmlpatterns Uitools Widgets Qml Printsupport Sensors Quickwidgets Quick Concurrent Openglextensions Charts Datavisualization) find_package(PCL) include_directories(${PCL_INCLUDE_DIRS}) +include_directories(${VCGLIB_INCLUDE_DIRS}) link_directories(${PCL_LIBRARY_DIRS}) add_definitions(${PCL_DEFINITIONS}) @@ -251,7 +268,7 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) # 定义GNU标准的安装目录(GNUInstallDirs.cmake) #----------------------------------------------------------------------------- include(GNUInstallDirs) -set(CMAKE_INSTALL_LIBDIR "lib") +set(CMAKE_INSTALL_LIBDIR "lib" ) #----------------------------------------------------------------------------- # 定义项目构建中间文件的生成目录 diff --git a/devopler.md b/devopler.md index 343e45d..5214735 100644 --- a/devopler.md +++ b/devopler.md @@ -2,8 +2,14 @@ LAMPCAE软件是基于FastCAE 软件上开发得到,增加了点云、feko仿真、成像三个部分功能。注意FastCAE 遵循 BSD-3-Clause 协议。为了避免被其他的依赖库协议污染,这里将程序库进行了拆分。 ## 点云功能部分依赖库 -点云部分依赖pcl,其中模型渲染部分重新用fastCAE软件的渲染重新适配。 -其中点云属性与点云实体分开存储,后期在考虑完全统一 +注意因为窗口界面部分是后续实现的,因此需要依赖python 作为中间件,链接 +点云格式:pclpointcloud2 + +1. 点云数据管理与mesh管理合并 +2. 点云滤波 +3. 点云重新构面 + + ## mesh网格处理 依赖meshlab中库代码处理 @@ -24,6 +30,7 @@ LAMPCAE软件是基于FastCAE 软件上开发得到,增加了点云、feko仿 ## 影像处理部分依赖库 -# V1.0 -1. 原来点云处理模块全部内置到FastCAE中 - +# V2.5.0 +1. 点云加载与保存 +2. 增加mesh的点删除功能 +3. 增加mesh的面片删除功能 \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ecce144..e4f8a9d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,8 +5,9 @@ set(SOVERSION ${PROJECT_VERSION} ${PROJECT_VERSION_MAJOR} ${PROJECT_VERSION_MINO # 所有项目 #----------------------------------------------------------------------------- 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 PointCloudOperator ) list(APPEND _libraries json qcustomplot qhexedit qscintilla2 LAMPTool WBCLFZSystemModule ) -list(APPEND _libraries PluginMotorBike) +list(APPEND _libraries PluginMotorBike ) #[[if(_WIN_) list(APPEND _libraries XGenerateReport License) endif()]] @@ -28,7 +29,7 @@ file(TO_NATIVE_PATH "${_rpath}/${INSTALL_LIBDIR}" _lib_rpath) # 遗漏两个,临时解决方案 list(APPEND LAMPCAE_Runtimes_Libraries VTK::loguru VTK::gl2ps Qt5::DBus VTK::IOChemistry ) -list(APPEND LAMPCAE_Runtimes_Libraries Qt5::Qml ) +list(APPEND LAMPCAE_Runtimes_Libraries Qt5::Qml ) @@ -65,7 +66,7 @@ install( LIBRARY DESTINATION ${INSTALL_LIBDIR} COMPONENT lib ) -list(APPEND _plugins PluginCustomizer PluginMeshDataExchange) +list(APPEND _plugins PluginCustomizer PluginMeshDataExchange PluginWBFZExchangePlugin) foreach(_plugin ${_plugins}) list(APPEND LAMPCAE_Runtimes_Libraries ${LAMPCAE_${_plugin}_Runtimes_Libraries}) diff --git a/src/Common/DebugLogger.h b/src/Common/DebugLogger.h index 1b79a82..9064f2a 100644 --- a/src/Common/DebugLogger.h +++ b/src/Common/DebugLogger.h @@ -7,10 +7,10 @@ * @copyright Copyright (c) Since 2020 青岛数智船海科技有限公司 All rights reserved. * * ============================================================================ - * Program: LAMPCAE + * Program: FASTCAE * * Copyright (c) Since 2020 青岛数智船海科技有限公司 All rights reserved. - * See License or http://www.LAMPCAE.com/ for details. + * See License or http://www.FASTCAE.com/ for details. * * BSD 3-Clause License * diff --git a/src/IO/IOConfig.h b/src/IO/IOConfig.h index 8dde777..c8b46f3 100644 --- a/src/IO/IOConfig.h +++ b/src/IO/IOConfig.h @@ -85,8 +85,6 @@ namespace IO //获取点云导出的方法 static EXPORTMESHFUN getPclExporter(QString suffix); - - //注册替换方法 static void RegisterKeyWordReplacer(QString kw, REPLACEKEYWORDFUN fun); //获取替换方法 diff --git a/src/LAMPTool/BaseToollib/BaseConstVariable.h b/src/LAMPTool/BaseToollib/BaseConstVariable.h deleted file mode 100644 index 81529e3..0000000 --- a/src/LAMPTool/BaseToollib/BaseConstVariable.h +++ /dev/null @@ -1,38 +0,0 @@ -#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 deleted file mode 100644 index 1c24103..0000000 --- a/src/LAMPTool/BaseToollib/BaseTool.cpp +++ /dev/null @@ -1,256 +0,0 @@ -#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) //叉乘 - //保证Q点坐标在pi,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 deleted file mode 100644 index 7e9fc55..0000000 --- a/src/LAMPTool/BaseToollib/BaseTool.h +++ /dev/null @@ -1,93 +0,0 @@ -#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 "../LAMPTool/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 deleted file mode 100644 index 9f61e18..0000000 --- a/src/LAMPTool/BaseToollib/FileOperator.cpp +++ /dev/null @@ -1,188 +0,0 @@ -#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, QObject::tr("error"), QObject::tr("file copy error")); - } - } - else { - // 源文件不存在 - QMessageBox::warning(nullptr, QObject::tr("warning"), QObject::tr("Source file not found")); - } -} \ No newline at end of file diff --git a/src/LAMPTool/BaseToollib/FileOperator.h b/src/LAMPTool/BaseToollib/FileOperator.h deleted file mode 100644 index fd95a59..0000000 --- a/src/LAMPTool/BaseToollib/FileOperator.h +++ /dev/null @@ -1,50 +0,0 @@ -#pragma once - -#ifndef FILEOPERATOR_H -#define FILEOPERATOR_H - -#include "../LAMPTool/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 deleted file mode 100644 index 581298c..0000000 --- a/src/LAMPTool/BaseToollib/GeoOperator.cpp +++ /dev/null @@ -1,271 +0,0 @@ -#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 deleted file mode 100644 index 4673476..0000000 --- a/src/LAMPTool/BaseToollib/GeoOperator.h +++ /dev/null @@ -1,111 +0,0 @@ -#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 deleted file mode 100644 index 36b20a1..0000000 --- a/src/LAMPTool/BaseToollib/ImageOperatorBase.cpp +++ /dev/null @@ -1,1237 +0,0 @@ -#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); // 使用Eigen的MatrixXcd - 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 deleted file mode 100644 index e673681..0000000 --- a/src/LAMPTool/BaseToollib/ImageOperatorBase.h +++ /dev/null @@ -1,190 +0,0 @@ -#pragma once -/** - * 影像数据操作项 - * 所有数据相关的操作,都是基于ENVI的数据格式 - * 影像读写操作时基于 GDAL 库 - * **/ - - - -#ifndef IMAGEOPERATORBASE_H -#define IMAGEOPERATORBASE_H - -#include "../LAMPTool/BaseToollib/BaseConstVariable.h" -#include "../LAMPTool/BaseToollib/GeoOperator.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include // for CPLMalloc() -#include "../LAMPTool/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); - - -//--------------------- 保存文博 ------------------------------- - -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 deleted file mode 100644 index f02df98..0000000 --- a/src/LAMPTool/BaseToollib/interpolation.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#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 deleted file mode 100644 index a93a8ab..0000000 --- a/src/LAMPTool/BaseToollib/interpolation.h +++ /dev/null @@ -1,69 +0,0 @@ -#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 deleted file mode 100644 index 671e01a..0000000 --- a/src/LAMPTool/BaseToollib/readme.md +++ /dev/null @@ -1,2 +0,0 @@ -# 说明 -此模块主要是通用基础模块 \ No newline at end of file diff --git a/src/LAMPTool/CMakeLists.txt b/src/LAMPTool/CMakeLists.txt index 5a86f6a..63de74e 100644 --- a/src/LAMPTool/CMakeLists.txt +++ b/src/LAMPTool/CMakeLists.txt @@ -3,24 +3,91 @@ #----------------------------------------------------------------------------- include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) +# boost +include_directories(D:/vcpkg/installed/x64-windows/include) + +# pcl +include_directories(C:/PCL/3rdParty/FLANN/include) +include_directories(C:/PCL/3rdParty/VTK/include/vtk-9.3) +include_directories(C:/PCL/include/pcl-1.14) + +# FindOpenCASCADE +include_directories(${OpenCASCADE_INCLUDE_DIRS}) + +# qt5 +include_directories(C:/Qt/5.15.2/msvc2019_64/include/QtQml) + +# json +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../json) + +# qscintilla2 +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qscintilla2) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qscintilla2/lexers) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qscintilla2/include) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qscintilla2/lexlib) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qscintilla2/Qt4Qt5) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qscintilla2/src) + +# lamptool +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../LAMPTool) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../LAMPTool/include) + +# qcustomplot +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qcustomplot) + +# qhexedit +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qhexedit) + + +# 内部结构 +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/SqliteDBProcess/src) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/modelProcess) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/EchoShowProcess) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/OCCViewer) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/PointCloudProcess) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/SharedModuleLib) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/TableProcess) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/TaskXml) + + +#----------------------------------------------------------------------------- +# 链接库 +#----------------------------------------------------------------------------- + +# pcl +link_directories("C:/PCL/3rdParty/FLANN/lib") +link_directories("C:/VTK/lib") +link_directories("C:/PCL/lib") + +# + + #----------------------------------------------------------------------------- # 自动添加include目录 #----------------------------------------------------------------------------- set(CMAKE_INCLUDE_CURRENT_DIR ON) +find_package(Qt5 REQUIRED COMPONENTS Core Quick Sql Core Xml Opengl Gui Svg Xmlpatterns Uitools Widgets Qml Printsupport Sensors Quickwidgets Quick Concurrent Openglextensions Charts Datavisualization) +find_package(PCL) +include_directories(${PCL_INCLUDE_DIRS}) +link_directories(${PCL_LIBRARY_DIRS}) +add_definitions(${PCL_DEFINITIONS}) + + #----------------------------------------------------------------------------- # 添加资源文件 #----------------------------------------------------------------------------- set(_qrc "${CMAKE_CURRENT_SOURCE_DIR}/../qrc/WBCLFZSystemModule.qrc") - +set(_qrc "${CMAKE_CURRENT_SOURCE_DIR}/../qrc/qianfan.qrc") +set(_lang "${CMAKE_CURRENT_SOURCE_DIR}/../qrc/translations.qrc") qt5_add_resources(_resource ${_qrc} ${_lang}) #----------------------------------------------------------------------------- # 源码扫描 #----------------------------------------------------------------------------- -file(GLOB_RECURSE _ui "*.ui") -file(GLOB_RECURSE _header "*.h*") -file(GLOB_RECURSE _source "*.cpp") +file(GLOB_RECURSE _ui "*.ui" ) +file(GLOB_RECURSE _header "*.h" ) +file(GLOB_RECURSE _source "*.cpp" ) qt5_wrap_ui(_interface ${_ui}) #----------------------------------------------------------------------------- @@ -36,15 +103,24 @@ add_library(LAMPTool STATIC #----------------------------------------------------------------------------- # 添加接口声明宏 #----------------------------------------------------------------------------- -target_compile_definitions(LAMPTool PUBLIC "LAMPTool_API") +target_compile_definitions(LAMPTool PUBLIC LAMPTOOL_API) +#----------------------------------------------------------------------------- +# 安装Qt的依赖文件 +#----------------------------------------------------------------------------- +get_target_property(_qmake_executable Qt5::qmake IMPORTED_LOCATION) +get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY) list(APPEND _depend_library qcustomplot) list(APPEND _runtimes_libraries - Qt5::Core Qt5::Gui Qt5::Widgets + Qt5::Core Qt5::Gui Qt5::Widgets Qt5::DBus Qt5::Core Qt5::Xml Qt5::OpenGL Qt5::Gui Qt5::Svg Qt5::Widgets Qt5::Qml Qt5::DataVisualization Qt5::Charts Qt5::PrintSupport +) + +list(APPEND _runtimes_libraries + OpenCASCADE::TKOpenGl OpenCASCADE::Freetype OpenCASCADE::TKBO OpenCASCADE::TKBRep OpenCASCADE::TKBool OpenCASCADE::TKCAF OpenCASCADE::TKCDF OpenCASCADE::TKG2d OpenCASCADE::TKG3d OpenCASCADE::TKGeomAlgo OpenCASCADE::TKGeomBase OpenCASCADE::TKHLR OpenCASCADE::TKIGES OpenCASCADE::TKLCAF OpenCASCADE::TKMath OpenCASCADE::TKMesh OpenCASCADE::TKPrim OpenCASCADE::TKSTEP OpenCASCADE::TKSTEP209 OpenCASCADE::TKSTEPAttr OpenCASCADE::TKSTEPBase OpenCASCADE::TKService OpenCASCADE::TKShHealing OpenCASCADE::TKTopAlgo OpenCASCADE::TKV3d OpenCASCADE::TKVCAF OpenCASCADE::TKXCAF OpenCASCADE::TKXDEIGES OpenCASCADE::TKXSBase OpenCASCADE::TKernel Qt5::Widgets Qt5::Xml VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersSources VTK::FiltersStatistics VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingMath VTK::InteractionStyle VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2 VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::lz4 VTK::lzma VTK::sys VTK::zlib VTK::IOGeometry ) target_include_directories(LAMPTool PRIVATE ${Qwt_INCLUDE_DIRS}) @@ -55,6 +131,9 @@ target_include_directories(LAMPTool PRIVATE ${Qwt_INCLUDE_DIRS}) target_link_libraries(LAMPTool PRIVATE ${_runtimes_libraries} ${_depend_library} + ${PCL_LIBRARIES} + FFTW3::fftw3 + GSL::gsl GSL::gslcblas ) #----------------------------------------------------------------------------- diff --git a/src/LAMPTool/FEKOFarFieldFileClass.cpp b/src/LAMPTool/FEKOFarFieldFileClass.cpp index 7980a82..445cad9 100644 --- a/src/LAMPTool/FEKOFarFieldFileClass.cpp +++ b/src/LAMPTool/FEKOFarFieldFileClass.cpp @@ -1,16 +1,16 @@ #include "FEKOFarFieldFileClass.h" -FEKOBase::FEKOFarFieldFileClass::FEKOFarFieldFileClass() +LAMPTOOLAPI FEKOBase::FEKOFarFieldFileClass::FEKOFarFieldFileClass() { } -FEKOBase::FEKOFarFieldFileClass::~FEKOFarFieldFileClass() +LAMPTOOLAPI FEKOBase::FEKOFarFieldFileClass::~FEKOFarFieldFileClass() { } -void FEKOBase::FEKOFarFieldFileClass::parseFarFieldFile(const QString& fileName) +void LAMPTOOLAPI FEKOBase::FEKOFarFieldFileClass::parseFarFieldFile(const QString& fileName) { QFile file(fileName); // 加载文本文件中的所有数据到一个 QString 中 @@ -76,7 +76,7 @@ void FEKOBase::FEKOFarFieldFileClass::parseFarFieldFile(const QString& fileName) file.close(); } -void FEKOBase::FEKOFarFieldFileClass::outputToFile(const QString& fileName) +void LAMPTOOLAPI FEKOBase::FEKOFarFieldFileClass::outputToFile(const QString& fileName) { QFile file(fileName); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) @@ -91,7 +91,7 @@ void FEKOBase::FEKOFarFieldFileClass::outputToFile(const QString& fileName) } -FEKOBase::FEKOFARFIELDRESULTTYPE FEKOBase::FEKOFARFIELDRESULTTYPEString2Enum(QString str) + FEKOBase::FEKOFARFIELDRESULTTYPE LAMPTOOLAPI FEKOBase::FEKOFARFIELDRESULTTYPEString2Enum(QString str) { if (str.toUpper() == "GAIN") { return FEKOBase::GAIN; } else if (str.toUpper() == "DIRECTIVITY") { return FEKOBase::DIRECTIVITY; } @@ -103,7 +103,7 @@ FEKOBase::FEKOFARFIELDRESULTTYPE FEKOBase::FEKOFARFIELDRESULTTYPEString2Enum(QSt return FEKOBase::FEKOFARFIELDRESULTTYPE(); } -QString FEKOBase::QString2FEKOFARFIELDRESULTTYPE(FEKOBase::FEKOFARFIELDRESULTTYPE mode) +QString LAMPTOOLAPI FEKOBase::QString2FEKOFARFIELDRESULTTYPE(FEKOBase::FEKOFARFIELDRESULTTYPE mode) { switch (mode) { case FEKOBase::GAIN: @@ -120,7 +120,7 @@ QString FEKOBase::QString2FEKOFARFIELDRESULTTYPE(FEKOBase::FEKOFARFIELDRESULTTYP } } -FEKOBase::FEKOFARFIELDFEKODATABLOCK::FEKOFARFIELDFEKODATABLOCK() +LAMPTOOLAPI FEKOBase::FEKOFARFIELDFEKODATABLOCK::FEKOFARFIELDFEKODATABLOCK() { this->dataList.clear(); this->thetaSamples = 0; @@ -136,12 +136,12 @@ FEKOBase::FEKOFARFIELDFEKODATABLOCK::FEKOFARFIELDFEKODATABLOCK() this->resultType = FEKOBase::FEKOFARFIELDRESULTTYPEUNKOWN; } -FEKOBase::FEKOFARFIELDFEKODATABLOCK::~FEKOFARFIELDFEKODATABLOCK() +LAMPTOOLAPI FEKOBase::FEKOFARFIELDFEKODATABLOCK::~FEKOFARFIELDFEKODATABLOCK() { } -int FEKOBase::FEKOFARFIELDFEKODATABLOCK::paraseFEKOFarFieldDataBlock(const QString& blockstr) +int LAMPTOOLAPI FEKOBase::FEKOFARFIELDFEKODATABLOCK::paraseFEKOFarFieldDataBlock(const QString& blockstr) { // 按行进行解析 QList lines= blockstr.split("\n"); @@ -150,7 +150,7 @@ int FEKOBase::FEKOFARFIELDFEKODATABLOCK::paraseFEKOFarFieldDataBlock(const QStri } -int FEKOBase::FEKOFARFIELDFEKODATABLOCK::paraseFEKOFarFieldDataBlockFromList(QList& lines) +int LAMPTOOLAPI FEKOBase::FEKOFARFIELDFEKODATABLOCK::paraseFEKOFarFieldDataBlockFromList(QList& lines) { bool in_readHeaderState = false; size_t headerlineCount = 0; @@ -267,7 +267,7 @@ int FEKOBase::FEKOFARFIELDFEKODATABLOCK::paraseFEKOFarFieldDataBlockFromList(QLi return 0; } -QString FEKOBase::FEKOFARFIELDFEKODATABLOCK::normalizationHeaderString(QString headerstr) +QString LAMPTOOLAPI FEKOBase::FEKOFARFIELDFEKODATABLOCK::normalizationHeaderString(QString headerstr) { headerstr = headerstr.replace("'", "").replace(u8"\"",u8""); if(headerstr.indexOf("#Configuration Name") != -1) @@ -408,7 +408,7 @@ QString FEKOBase::FEKOFARFIELDFEKODATABLOCK::normalizationHeaderString(QString h ; } -QString FEKOBase::FEKOFARFIELDFEKODATABLOCK::saveFEKOFarFieldDataBlock() +QString LAMPTOOLAPI FEKOBase::FEKOFARFIELDFEKODATABLOCK::saveFEKOFarFieldDataBlock() { switch (this->resultType) { @@ -425,22 +425,22 @@ QString FEKOBase::FEKOFARFIELDFEKODATABLOCK::saveFEKOFarFieldDataBlock() } } -QString FEKOBase::FEKOFARFIELDFEKODATABLOCK::saveFEKOFarFieldDataBlock_Gain() +QString LAMPTOOLAPI FEKOBase::FEKOFARFIELDFEKODATABLOCK::saveFEKOFarFieldDataBlock_Gain() { return QString(); } -QString FEKOBase::FEKOFARFIELDFEKODATABLOCK::saveFEKOFarFieldDataBlock_Directivity() +QString LAMPTOOLAPI FEKOBase::FEKOFARFIELDFEKODATABLOCK::saveFEKOFarFieldDataBlock_Directivity() { return QString(); } -QString FEKOBase::FEKOFARFIELDFEKODATABLOCK::saveFEKOFarFieldDataBlock_RCS() +QString LAMPTOOLAPI FEKOBase::FEKOFARFIELDFEKODATABLOCK::saveFEKOFarFieldDataBlock_RCS() { return QString(); } -QString FEKOBase::FEKOFARFIELDFEKODATABLOCK::saveFEKOFarFieldDataBlock_FarFieldValues() +QString LAMPTOOLAPI FEKOBase::FEKOFARFIELDFEKODATABLOCK::saveFEKOFarFieldDataBlock_FarFieldValues() { return QString(); } diff --git a/src/LAMPTool/FEKOFarFieldFileClass.h b/src/LAMPTool/FEKOFarFieldFileClass.h index a615a16..7188352 100644 --- a/src/LAMPTool/FEKOFarFieldFileClass.h +++ b/src/LAMPTool/FEKOFarFieldFileClass.h @@ -3,7 +3,7 @@ #ifndef FARFIELDFILECLASS_H #define FARFIELDFILECLASS_H #include "referenceHeader.h" -#include "SARImage/FEKOBaseToolClass.h" +#include "FEKOBaseToolClass.h" namespace FEKOBase { @@ -21,8 +21,8 @@ namespace FEKOBase { FARFIELDVALUES,// 远场值 FEKOFARFIELDRESULTTYPEUNKOWN }; - FEKOBase::FEKOFARFIELDRESULTTYPE FEKOFARFIELDRESULTTYPEString2Enum(QString str); - QString QString2FEKOFARFIELDRESULTTYPE(FEKOBase::FEKOFARFIELDRESULTTYPE mode); + FEKOBase::FEKOFARFIELDRESULTTYPE LAMPTOOLAPI FEKOFARFIELDRESULTTYPEString2Enum(QString str); + QString LAMPTOOLAPI QString2FEKOFARFIELDRESULTTYPE(FEKOBase::FEKOFARFIELDRESULTTYPE mode); @@ -63,7 +63,7 @@ namespace FEKOBase { double RCS_total = 0; }; - class FEKOFARFIELDFEKODATABLOCK { // 数据块 + class LAMPTOOLAPI FEKOFARFIELDFEKODATABLOCK { // 数据块 public: FEKOFARFIELDFEKODATABLOCK(); ~FEKOFARFIELDFEKODATABLOCK(); @@ -100,7 +100,7 @@ namespace FEKOBase { -class FEKOFarFieldFileClass: public QObject +class LAMPTOOLAPI FEKOFarFieldFileClass: public QObject { Q_OBJECT public: diff --git a/src/LAMPTool/FEKOSimulationSARClass.cpp b/src/LAMPTool/FEKOSimulationSARClass.cpp index 472983d..cca7185 100644 --- a/src/LAMPTool/FEKOSimulationSARClass.cpp +++ b/src/LAMPTool/FEKOSimulationSARClass.cpp @@ -1,14 +1,14 @@ // 下面的代码是属性的设置与获取,请补充完整 #include "FEKOSimulationSARClass.h" -#include "BaseToolLib/BaseConstVariable.h" +#include "BaseConstVariable.h" #include #include #include -#include "BaseToollib/ImageOperatorBase.h" -#include -#include "BaseToollib/FileOperator.h" +#include "ImageOperatorBase.h" +#include "SARImageBase.h" +#include "FileOperator.h" #include -#include "BaseToollib/GeoOperator.h" +#include "GeoOperator.h" @@ -434,7 +434,7 @@ QString FEKOBase::FEKOSimulationSARClass::createLuaSciptString(size_t startprfid -bool FEKOBase::FEKOImageProcess(EchoDataClass& echodata, FEKOImageSettingParams& imageSettingParams, QString& outPath, FEKOImageAlgorithm algmethod, ImageAlgWindowFun winfun) +bool LAMPTOOLAPI FEKOBase::FEKOImageProcess(EchoDataClass& echodata, FEKOImageSettingParams& imageSettingParams, QString& outPath, FEKOImageAlgorithm algmethod, ImageAlgWindowFun winfun) { Eigen::MatrixXcd echoData = echodata.getEchoData(); Eigen::MatrixXd antpos = echodata.getAntPos(); diff --git a/src/LAMPTool/FEKOSimulationSARClass.h b/src/LAMPTool/FEKOSimulationSARClass.h index b103f2d..ffe856a 100644 --- a/src/LAMPTool/FEKOSimulationSARClass.h +++ b/src/LAMPTool/FEKOSimulationSARClass.h @@ -1,188 +1,183 @@ #pragma once /* -* FEKO_SIMULAION_SAR_CLASS 是适配FEKO成像算法 -* FEKOSimulationSARClass -* -*/ -#ifndef FEKO_SIMULATION_SAR_CLASS_H -#define FEKO_SIMULATION_SAR_CLASS_H + * FEKO_SIMULAION_SAR_CLASS 是适配FEKO成像算法 + * FEKOSimulationSARClass + * + */ +#ifndef _FEKO_SIMULATION_SAR_CLASS_H +#define _FEKO_SIMULATION_SAR_CLASS_H #include "referenceHeader.h" #include "OCCTBase.h" -#include "BaseToollib/GeoOperator.h" -#include "SARImage/FEKOBaseToolClass.h" -#include "SARBaseToolLib/SARImageBase.h" - +#include "GeoOperator.h" +#include "FEKOBaseToolClass.h" +#include "SARImageBase.h" + #include namespace FEKOBase { //========================================================== - // FEKO成像仿真参数类 + // FEKO成像仿真参数类 //========================================================== - class FEKOSimulationDataparams:public QObject - { // 仿真参数类 + class LAMPTOOLAPI FEKOSimulationDataparams : public QObject { // 仿真参数类 Q_OBJECT public: - FEKOSimulationDataparams(QObject* parent=nullptr); + FEKOSimulationDataparams(QObject* parent = nullptr); ~FEKOSimulationDataparams(); - + signals: void FEKOSimulationDataparamsChanged(); // 响应时间,作为一个参数分发 - - public: // 频率更新 - void CalFEKOSimulationFreqParams(double centerFreq, double resolution, double bandWidth, double scenceRange, bool isResolution = false); - void updateFEKOSimulationFreqParams(double startfreq, double endfreq, size_t freqpoints); + public: // 频率更新 + void CalFEKOSimulationFreqParams(double centerFreq, double resolution, double bandWidth, + double scenceRange, bool isResolution = false); + void updateFEKOSimulationFreqParams(double startfreq, double endfreq, size_t freqpoints); public: - void loadXml(const QString& fileName); - void saveXml(const QString& fileName); - + void loadXml(const QString& fileName); + void saveXml(const QString& fileName); - public: // 属性字段 - QString taskName; // 任务名称 - FEKOImageMode imagemode; // 成像时间 - QString AntennaRadiationFileName; // 远程天线等效辐射方向图文件地址 - long farsource_thetaPoints; - long farsource_phiPoints; + public: // 属性字段 + QString taskName; // 任务名称 + FEKOImageMode imagemode; // 成像时间 + QString AntennaRadiationFileName; // 远程天线等效辐射方向图文件地址 + long farsource_thetaPoints; + long farsource_phiPoints; + bool isRight = false; // 是否为右视 + double refRange; // 参考距离 m + double incangle; // 入射角 ° - bool isRight = false; // 是否为右视 - double refRange;// 参考距离 m - double incangle; // 入射角 ° + double centerFreq; // 中心频率 + double rangeResolution; // 分辨率 + double bandwidth; // 带宽 - double centerFreq; // 中心频率 - double rangeResolution;//分辨率 - double bandwidth;// 带宽 + double startfreq; // 频率参数 + double endfreq; + double freqpoints; - double startfreq; // 频率参数 - double endfreq; - double freqpoints; + // 成像场景设置 + double x_min; + double x_max; + double y_min; + double y_max; + double z_plane; - - //成像场景设置 - double x_min; - double x_max; - double y_min; - double y_max; - double z_plane; - - size_t imageheight; // 图像高度 - size_t imagewidth; // 图像宽度 + size_t imageheight; // 图像高度 + size_t imagewidth; // 图像宽度 // 条带模式参数 - size_t prfcount; // 脉冲数量 - double start_x; - double end_x; - double start_y; - double end_y; - double start_z; - double end_z; + size_t prfcount; // 脉冲数量 + double start_x; + double end_x; + double start_y; + double end_y; + double start_z; + double end_z; // 扫描模式参数 - double start_az_angle; // 扫描起始角 - double end_az_angle; // 扫描终止角 - + double start_az_angle; // 扫描起始角 + double end_az_angle; // 扫描终止角 // ISAR模式参数 , 圆迹模式参数 - double start_circle_angle; // 起始扫描角 - double end_circle_angle; // 终止扫描角 - double delta_angle;// 扫描角间隔 + double start_circle_angle; // 起始扫描角 + double end_circle_angle; // 终止扫描角 + double delta_angle; // 扫描角间隔 - public: - void setTaskName(QString taskName); - QString getTaskName(); + public: + void setTaskName(QString taskName); + QString getTaskName(); // 成像模式 - void setImagemode(FEKOImageMode imagemode); + void setImagemode(FEKOImageMode imagemode); FEKOImageMode getImagemode(); // 是否为右视 - void setIsRight(bool isRight); - bool getIsRight(); + void setIsRight(bool isRight); + bool getIsRight(); // 参考距离 - void setRefRange(double refRange); - double getRefRange(); + void setRefRange(double refRange); + double getRefRange(); // 入射角 - void setIncangle(double incangle); - double getIncangle(); + void setIncangle(double incangle); + double getIncangle(); // 中心频率 - void setCenterFreq(double centerFreq); - double getCenterFreq(); + void setCenterFreq(double centerFreq); + double getCenterFreq(); // 分辨率 - void setRangeResolution(double rangeResolution); - double getRangeResolution(); + void setRangeResolution(double rangeResolution); + double getRangeResolution(); // 带宽 - void setBandwidth(double bandwidth); - double getBandwidth(); + void setBandwidth(double bandwidth); + double getBandwidth(); // 频率参数 - void setStartfreq(double startfreq); - double getStartfreq(); - void setEndfreq(double endfreq); - double getEndfreq(); - void setFreqpoints(double freqpoints); - double getFreqpoints(); + void setStartfreq(double startfreq); + double getStartfreq(); + void setEndfreq(double endfreq); + double getEndfreq(); + void setFreqpoints(double freqpoints); + double getFreqpoints(); // 成像范围 - void setX_min(double x_min); - double getX_min(); - void setX_max(double x_max); - double getX_max(); - void setY_min(double y_min); - double getY_min(); - void setY_max(double y_max); - double getY_max(); - void setZ_plane(double z_plane); - double getZ_plane(); + void setX_min(double x_min); + double getX_min(); + void setX_max(double x_max); + double getX_max(); + void setY_min(double y_min); + double getY_min(); + void setY_max(double y_max); + double getY_max(); + void setZ_plane(double z_plane); + double getZ_plane(); // 图像高度 - void setImageheight(size_t imageheight); - size_t getImageheight(); + void setImageheight(size_t imageheight); + size_t getImageheight(); // 图像宽度 - void setImagewidth(size_t imagewidth); - size_t getImagewidth(); + void setImagewidth(size_t imagewidth); + size_t getImagewidth(); // 条带模式参数 - void setPRFCount(size_t prfcount); - size_t getPRFCount(); - void setStart_x(double start_x); - double getStart_x(); - void setEnd_x(double end_x); - double getEnd_x(); - void setStart_y(double start_y); - double getStart_y(); - void setEnd_y(double end_y); - double getEnd_y(); - void setStart_z(double start_z); - double getStart_z(); - void setEnd_z(double end_z); - double getEnd_z(); - double getStart_az_angle(); // 扫描起始角 - double getEnd_az_angle(); // 扫描终止角 - double getStart_circle_angle(); // 起始扫描角 - double getEnd_circle_angle(); // 终止扫描角 - double getDelta_angle();// 扫描角间隔 + void setPRFCount(size_t prfcount); + size_t getPRFCount(); + void setStart_x(double start_x); + double getStart_x(); + void setEnd_x(double end_x); + double getEnd_x(); + void setStart_y(double start_y); + double getStart_y(); + void setEnd_y(double end_y); + double getEnd_y(); + void setStart_z(double start_z); + double getStart_z(); + void setEnd_z(double end_z); + double getEnd_z(); + double getStart_az_angle(); // 扫描起始角 + double getEnd_az_angle(); // 扫描终止角 + double getStart_circle_angle(); // 起始扫描角 + double getEnd_circle_angle(); // 终止扫描角 + double getDelta_angle(); // 扫描角间隔 - void setStart_az_angle(double Start_az_angle); // 扫描起始角 - void setEnd_az_angle(double End_az_angle); // 扫描终止角 - void setStart_circle_angle(double Start_circle_angle); // 起始扫描角 - void setEnd_circle_angle(double End_circle_angle); // 终止扫描角 - void setDelta_angle(double Delta_angle);// 扫描角间隔 - - QString getAntennaRadiationFileName(); - void setAntennaRadiationFileName( QString path); - long getFarsourceThetaPoints(); - void setFarsourceThetaPoints(long thetaPoints); - long getFarsourcePhiPoints(); - void setFarsourcePhiPoints(long phiPoints); + void setStart_az_angle(double Start_az_angle); // 扫描起始角 + void setEnd_az_angle(double End_az_angle); // 扫描终止角 + void setStart_circle_angle(double Start_circle_angle); // 起始扫描角 + void setEnd_circle_angle(double End_circle_angle); // 终止扫描角 + void setDelta_angle(double Delta_angle); // 扫描角间隔 + QString getAntennaRadiationFileName(); + void setAntennaRadiationFileName(QString path); + long getFarsourceThetaPoints(); + void setFarsourceThetaPoints(long thetaPoints); + long getFarsourcePhiPoints(); + void setFarsourcePhiPoints(long phiPoints); }; - class FEKOSimulationDataparamsHandler { - + class LAMPTOOLAPI FEKOSimulationDataparamsHandler { public: FEKOSimulationDataparamsHandler(); ~FEKOSimulationDataparamsHandler(); + public: std::shared_ptr simulationparams; - void setFEKOSimulationDataparams(std::shared_ptr simulationparams); + void setFEKOSimulationDataparams( + std::shared_ptr simulationparams); std::shared_ptr getFEKOSimulationDataparams(); public: @@ -190,70 +185,75 @@ namespace FEKOBase { }; //========================================================== - // FEKO仿真成像参数类 + // FEKO仿真成像参数类 // 解析成像参数xml //========================================================== - class FEKOSimulationSARClass : public FEKOSimulationDataparamsHandler - { + class LAMPTOOLAPI FEKOSimulationSARClass : public FEKOSimulationDataparamsHandler { public: - FEKOSimulationSARClass(); + FEKOSimulationSARClass(); ~FEKOSimulationSARClass(); - public: - std::vector FEKOAntPoselist;// FEKO的天线参数设置 - void setFEKOAntPoselist(std::vector FEKOAntPoselist); // FEKO的天线参数设置 + public: + std::vector FEKOAntPoselist; // FEKO的天线参数设置 + void setFEKOAntPoselist( + std::vector FEKOAntPoselist); // FEKO的天线参数设置 std::vector getFEKOAntPoselist(); public: - void generator_STRIP_FEKOSatelliteParams(); - void generator_SCAN_FEKOSatelliteParams(); - void generator_ISAR_FEKOSatelliteParams(); - void generator_CircleSAR_FEKOSatelliteParams(); - void generator_FEKOSatelliteParams(); - + void generator_STRIP_FEKOSatelliteParams(); + void generator_SCAN_FEKOSatelliteParams(); + void generator_ISAR_FEKOSatelliteParams(); + void generator_CircleSAR_FEKOSatelliteParams(); + void generator_FEKOSatelliteParams(); + virtual void refreshFEKOSimulationParams(); public: - QString workSpace; // 工作空间 + QString workSpace; // 工作空间 QString AntennaRadiationPath; // 远程天线等效辐射方向图文件地址 QString xmlpath; - public : // 初始化模型 - void loadFEKOImageSettingXML(QString xmlpath); - void saveFEKOImageSettingXML(); + + public: // 初始化模型 + void loadFEKOImageSettingXML(QString xmlpath); + void saveFEKOImageSettingXML(); QString createLuaSciptString(size_t startprfidx, size_t endprfidx); }; //========================================================== - // FEKO成像 + // FEKO成像 //========================================================== - bool FEKOImageProcess(EchoDataClass& echodata, FEKOImageSettingParams& imageSettingParams, QString& outPath, FEKOImageAlgorithm algmethod = FEKOImageAlgorithm::TBP_FREQ, ImageAlgWindowFun winfun = ImageAlgWindowFun::HANMMING); - - class FEKOImageProcessAbstractClass { + bool LAMPTOOLAPI FEKOImageProcess(EchoDataClass& echodata, + FEKOImageSettingParams& imageSettingParams, QString& outPath, + FEKOImageAlgorithm algmethod = FEKOImageAlgorithm::TBP_FREQ, + ImageAlgWindowFun winfun = ImageAlgWindowFun::HANMMING); + class LAMPTOOLAPI FEKOImageProcessAbstractClass { public: FEKOImageProcessAbstractClass(); ~FEKOImageProcessAbstractClass(); + private: - EchoDataClass echodata; // 原始回波数据 - + EchoDataClass echodata; // 原始回波数据 - FEKOImageSettingParams imageSettingParams; // 成像参数 - FEKOImageAlgorithm algmethod; // 成像算法 - QString tiffPath; + FEKOImageAlgorithm algmethod; // 成像算法 + QString tiffPath; + public: // 构建与成员变量有关的属性函数 - void setEchoData(EchoDataClass echodata); - EchoDataClass getEchoData() const; - void setImageSettingParams(FEKOImageSettingParams imageSettingParams); + void setEchoData(EchoDataClass echodata); + EchoDataClass getEchoData() const; + void setImageSettingParams(FEKOImageSettingParams imageSettingParams); FEKOImageSettingParams getImageSettingParams(); - void setAlgmethod(FEKOImageAlgorithm algmethod); - FEKOImageAlgorithm getAlgmethod(); - void settiffPath(QString outtiffPath); - QString gettiffPath(); - void LoadEchoDataPath(QString echoPath); + void setAlgmethod(FEKOImageAlgorithm algmethod); + FEKOImageAlgorithm getAlgmethod(); + void settiffPath(QString outtiffPath); + QString gettiffPath(); + void LoadEchoDataPath(QString echoPath); + public: // 成像参数 bool Imageprocess(); }; -}; - +}; // namespace FEKOBase #endif \ No newline at end of file diff --git a/src/LAMPTool/LAMPTool.h b/src/LAMPTool/LAMPTool.h index 9e57256..d0cb7cc 100644 --- a/src/LAMPTool/LAMPTool.h +++ b/src/LAMPTool/LAMPTool.h @@ -6,8 +6,8 @@ #include #include "ui_LAMPTool.h" - -class LAMPTool : public QMainWindow +#include "LAMPToolAPI.h" +class LAMPTOOLAPI LAMPTool : public QMainWindow { Q_OBJECT diff --git a/src/LAMPTool/OCCTBase.cpp b/src/LAMPTool/OCCTBase.cpp index e43c020..0cf1ccc 100644 --- a/src/LAMPTool/OCCTBase.cpp +++ b/src/LAMPTool/OCCTBase.cpp @@ -1,6 +1,6 @@ #include "OCCTBase.h" #include "referenceHeader.h" -#include +#include // =================================================================== @@ -8,7 +8,7 @@ // =================================================================== -OCCTShapeType str2OCCTShapeType(QString str) +OCCTShapeType LAMPTOOLAPI str2OCCTShapeType(QString str) { if (str.isEmpty()) { return OCCTShapeType::NoneType; @@ -28,7 +28,7 @@ OCCTShapeType str2OCCTShapeType(QString str) return OCCTShapeType(); } -QStringList getOCCTShapeTypeEmnu() +QStringList LAMPTOOLAPI getOCCTShapeTypeEmnu() { QStringList list; list.push_back(QString(u8"STL")); @@ -38,27 +38,27 @@ QStringList getOCCTShapeTypeEmnu() return list; } -QString getOCCTShapeTypeFilterString() +QString LAMPTOOLAPI getOCCTShapeTypeFilterString() { return QString(u8"STL Files (*.stl);;STL Files (*.stla);;step Files (*.stp);;step Files (*.step);;IGES Files (*.iges);;IGES Files (*.igs)"); } -QString get_STL_FilterString() +QString LAMPTOOLAPI get_STL_FilterString() { return QString(u8"STL Files (*.stl);;STL Files (*.stla)"); } -QString get_STEP_FilterString() +QString LAMPTOOLAPI get_STEP_FilterString() { return QString(u8"step Files (*.stp);;step Files (*.step)"); } -QString get_IGES_FilterString() +QString LAMPTOOLAPI get_IGES_FilterString() { return QString(u8"IGES Files (*.iges);;IGES Files (*.igs)"); } -QString getOCCTShapeTypeFilterString(OCCTShapeType switch_on) +QString LAMPTOOLAPI getOCCTShapeTypeFilterString(OCCTShapeType switch_on) { switch (switch_on) { @@ -71,26 +71,26 @@ QString getOCCTShapeTypeFilterString(OCCTShapeType switch_on) } } -QString getOCCTShapeTypeFilterString(QString str) +QString LAMPTOOLAPI getOCCTShapeTypeFilterString(QString str) { return getOCCTShapeTypeFilterString(str2OCCTShapeType(str)); } -bool SaveTopoDs_Stl(QString FilePath, const TopoDS_Shape& shape) { +bool LAMPTOOLAPI SaveTopoDs_Stl(QString FilePath, const TopoDS_Shape& shape) { // 将形状保存为 STL 文件 qDebug() << u8"SaveTopoDs_Stl " << FilePath; StlAPI_Writer writer; writer.Write(shape, FilePath.toStdString().c_str()); // 保存为stl模型 return true; } -bool SaveTopoDs_Step(QString FilePath, const TopoDS_Shape& shape) { +bool LAMPTOOLAPI SaveTopoDs_Step(QString FilePath, const TopoDS_Shape& shape) { qDebug() << u8"SaveTopoDs_Step " << FilePath; STEPControl_Writer writer; writer.Transfer(shape, STEPControl_AsIs); writer.Write(FilePath.toStdString().c_str()); return true; } -bool SaveTopoDs_IGES(QString FilePath,const TopoDS_Shape& shape) { +bool LAMPTOOLAPI SaveTopoDs_IGES(QString FilePath,const TopoDS_Shape& shape) { qDebug() << u8"SaveTopoDs_IGES " << FilePath; IGESControl_Writer writer; writer.AddShape(shape); @@ -98,7 +98,7 @@ bool SaveTopoDs_IGES(QString FilePath,const TopoDS_Shape& shape) { return true; } -bool SaveTopoDs(QString FilePath,const TopoDS_Shape& DataShape, OCCTShapeType shapetype) +bool LAMPTOOLAPI SaveTopoDs(QString FilePath,const TopoDS_Shape& DataShape, OCCTShapeType shapetype) { switch (shapetype) { @@ -125,20 +125,20 @@ bool SaveTopoDs(QString FilePath,const TopoDS_Shape& DataShape, OCCTShapeType s return true; } -TopoDS_Shape ReadTopoDs_IGES(QString Filepath) { +TopoDS_Shape LAMPTOOLAPI ReadTopoDs_IGES(QString Filepath) { IGESControl_Reader reader; reader.ReadFile(Filepath.toStdString().c_str()); reader.TransferRoots(); TopoDS_Shape shape = reader.OneShape(); return shape; } -TopoDS_Shape ReadTopoDs_Stl(QString Filepath) { +TopoDS_Shape LAMPTOOLAPI ReadTopoDs_Stl(QString Filepath) { TopoDS_Shape shape_TopoDs; StlAPI_Reader aReader_Stl; aReader_Stl.Read(shape_TopoDs, Filepath.toStdString().c_str()); return shape_TopoDs; } -TopoDS_Shape ReadTopoDs_Step(QString Filepath) { +TopoDS_Shape LAMPTOOLAPI ReadTopoDs_Step(QString Filepath) { TopoDS_Shape shape; STEPControl_Reader reader; IFSelect_ReturnStatus status = reader.ReadFile(Filepath.toStdString().c_str()); @@ -152,7 +152,7 @@ TopoDS_Shape ReadTopoDs_Step(QString Filepath) { } } -OCCTShapeType ReadTopoDs_Shape(QString filepath, TopoDS_Shape& shape_TopoDs) +OCCTShapeType LAMPTOOLAPI ReadTopoDs_Shape(QString filepath, TopoDS_Shape& shape_TopoDs) { QFileInfo fileinfo(filepath); QString filename = fileinfo.fileName(); @@ -182,7 +182,7 @@ OCCTShapeType ReadTopoDs_Shape(QString filepath, TopoDS_Shape& shape_TopoDs) } } -TopoDS_Shape MergedTopoShape(std::vector TopoDS_Shapelist) +TopoDS_Shape LAMPTOOLAPI MergedTopoShape(std::vector TopoDS_Shapelist) { // 创建一个复合体 TopoDS_Compound compound; @@ -199,7 +199,7 @@ TopoDS_Shape MergedTopoShape(std::vector TopoDS_Shapelist) } -void ChangeModelColor(Handle(AIS_Shape)& aisShape, Quantity_Color& redColor) +void LAMPTOOLAPI ChangeModelColor(Handle(AIS_Shape)& aisShape, Quantity_Color& redColor) { // 将颜色应用到模型 @@ -208,7 +208,7 @@ void ChangeModelColor(Handle(AIS_Shape)& aisShape, Quantity_Color& redColor) -TopoDS_Shape CreateArrow(const gp_Dir& direction, Standard_Real length, Standard_Real radius) { +TopoDS_Shape LAMPTOOLAPI CreateArrow(const gp_Dir& direction, Standard_Real length, Standard_Real radius) { // 创建一个圆柱作为箭头的主体 gp_Pnt origin(0, 0, 0); gp_Ax2 axis(origin, direction); @@ -230,7 +230,7 @@ TopoDS_Shape CreateArrow(const gp_Dir& direction, Standard_Real length, Standard } -gp_Trsf GetTransFormFromVector(const gp_Vec& vectorA, const gp_Vec& vectorB) +gp_Trsf LAMPTOOLAPI GetTransFormFromVector(const gp_Vec& vectorA, const gp_Vec& vectorB) { // 计算旋转轴和旋转角度 gp_Vec rotationAxis = vectorA.Crossed(vectorB); @@ -250,7 +250,7 @@ gp_Trsf GetTransFormFromVector(const gp_Vec& vectorA, const gp_Vec& vectorB) } -TopoDS_Shape Process_RotationThetaPhi_MoveXYZ(TopoDS_Shape shape, double theta, double phi, double X, double Y, double Z) +TopoDS_Shape LAMPTOOLAPI Process_RotationThetaPhi_MoveXYZ(TopoDS_Shape shape, double theta, double phi, double X, double Y, double Z) { gp_Vec Position(gp_Pnt(0, 0, 0), gp_Pnt(X, Y, Z)); gp_Trsf rotationTransform_theta; @@ -270,7 +270,7 @@ TopoDS_Shape Process_RotationThetaPhi_MoveXYZ(TopoDS_Shape shape, double theta, return result; } -TopoDS_Shape CreateCartesianCoordinatesAxis(double xlength, double ylength, double zlength) +TopoDS_Shape LAMPTOOLAPI CreateCartesianCoordinatesAxis(double xlength, double ylength, double zlength) { // 创建三个方向的箭头 @@ -296,21 +296,21 @@ TopoDS_Shape CreateCartesianCoordinatesAxis(double xlength, double ylength, doub return compound; } -TopoDS_Shape CreateBox(double x, double y, double z) +TopoDS_Shape LAMPTOOLAPI CreateBox(double x, double y, double z) { // 创建一个长方体 BRepPrimAPI_MakeBox box(gp_Pnt(-x / 2, -y / 2, -z / 2), gp_Pnt(x / 2, y / 2, z / 2)); return box.Shape(); } -TopoDS_Shape CreateCylinder(double radius, double height) +TopoDS_Shape LAMPTOOLAPI CreateCylinder(double radius, double height) { BRepPrimAPI_MakeCylinder makeCylinder(radius, height); TopoDS_Shape cylinderShape = makeCylinder.Shape(); return cylinderShape; } -TopoDS_Shape CreateCone(double radius1, double radius2, double height) +TopoDS_Shape LAMPTOOLAPI CreateCone(double radius1, double radius2, double height) { BRepPrimAPI_MakeCone mkCone = BRepPrimAPI_MakeCone::BRepPrimAPI_MakeCone(radius1, radius2, height); TopoDS_Shape coneShape = mkCone.Shape(); @@ -318,29 +318,29 @@ TopoDS_Shape CreateCone(double radius1, double radius2, double height) return coneShape; } -TopoDS_Shape CreateSphere(double radius) +TopoDS_Shape LAMPTOOLAPI CreateSphere(double radius) { return TopoDS_Shape(); } -TopoDS_Shape CreateTorus(double majorRadius, double minorRadius) +TopoDS_Shape LAMPTOOLAPI CreateTorus(double majorRadius, double minorRadius) { return TopoDS_Shape(); } -TopoDS_Shape Cut(TopoDS_Shape& shape1, TopoDS_Shape& shape2) +TopoDS_Shape LAMPTOOLAPI Cut(TopoDS_Shape& shape1, TopoDS_Shape& shape2) { return TopoDS_Shape(); } -TopoDS_Shape Fuse(TopoDS_Shape& shape1, TopoDS_Shape& shape2) +TopoDS_Shape LAMPTOOLAPI Fuse(TopoDS_Shape& shape1, TopoDS_Shape& shape2) { return TopoDS_Shape(); } -TopoDS_Shape Rotate(TopoDS_Shape& shape, gp_Ax1 axis, double angle) +TopoDS_Shape LAMPTOOLAPI Rotate(TopoDS_Shape& shape, gp_Ax1 axis, double angle) { // 进行旋转 angle= angle * M_PI / 180; @@ -350,7 +350,7 @@ TopoDS_Shape Rotate(TopoDS_Shape& shape, gp_Ax1 axis, double angle) return rotateTransform_X.Shape(); } -TopoDS_Shape Translate(TopoDS_Shape& shape, gp_Vec move_vec) +TopoDS_Shape LAMPTOOLAPI Translate(TopoDS_Shape& shape, gp_Vec move_vec) { gp_Trsf translation; translation.SetTranslation(move_vec); @@ -358,7 +358,7 @@ TopoDS_Shape Translate(TopoDS_Shape& shape, gp_Vec move_vec) return translateTransform.Shape(); } -TopoDS_Shape Scale(TopoDS_Shape& shape, gp_Pnt refrenceCenter, double scale) +TopoDS_Shape LAMPTOOLAPI Scale(TopoDS_Shape& shape, gp_Pnt refrenceCenter, double scale) { gp_Trsf scaleTransform; scaleTransform.SetScale(refrenceCenter, scale); @@ -366,7 +366,7 @@ TopoDS_Shape Scale(TopoDS_Shape& shape, gp_Pnt refrenceCenter, double scale) return scaleTransformBuilder.Shape(); } -TopoDS_Shape createConicalHorn(double bottomRadius, double bottomHeight, double topRadius, double topHeight) +TopoDS_Shape LAMPTOOLAPI createConicalHorn(double bottomRadius, double bottomHeight, double topRadius, double topHeight) { BRepPrimAPI_MakeCone mkCone = BRepPrimAPI_MakeCone::BRepPrimAPI_MakeCone(bottomRadius,topRadius,topHeight); @@ -394,7 +394,7 @@ TopoDS_Shape createConicalHorn(double bottomRadius, double bottomHeight, double return compound; } -TopoDS_Shape createPyramidalHorn(double bottomWidth, double bottomHeight, double bottomAtl, double topWidth, double topHeight, double topAtl) +TopoDS_Shape LAMPTOOLAPI createPyramidalHorn(double bottomWidth, double bottomHeight, double bottomAtl, double topWidth, double topHeight, double topAtl) { @@ -402,7 +402,7 @@ TopoDS_Shape createPyramidalHorn(double bottomWidth, double bottomHeight, double return TopoDS_Shape(); } - TopoDS_Shape CreateWedge(double x, double y, double z) + TopoDS_Shape LAMPTOOLAPI CreateWedge(double x, double y, double z) { diff --git a/src/LAMPTool/OCCTBase.h b/src/LAMPTool/OCCTBase.h index 99f11eb..77bf026 100644 --- a/src/LAMPTool/OCCTBase.h +++ b/src/LAMPTool/OCCTBase.h @@ -2,6 +2,7 @@ #ifndef OCCTBASELAMP_H #define OCCTBASELAMP_H +#include "LAMPToolAPI.h" #include "referenceHeader.h" @@ -17,45 +18,45 @@ enum OCCTShapeType NoneType, }; -OCCTShapeType str2OCCTShapeType(QString str); -QStringList getOCCTShapeTypeEmnu(); -QString getOCCTShapeTypeFilterString(); -QString get_STL_FilterString(); -QString get_STEP_FilterString(); -QString get_IGES_FilterString(); -QString getOCCTShapeTypeFilterString(OCCTShapeType t); -QString getOCCTShapeTypeFilterString(QString str); +OCCTShapeType LAMPTOOLAPI str2OCCTShapeType(QString str); +QStringList LAMPTOOLAPI getOCCTShapeTypeEmnu(); +QString LAMPTOOLAPI getOCCTShapeTypeFilterString(); +QString LAMPTOOLAPI get_STL_FilterString(); +QString LAMPTOOLAPI get_STEP_FilterString(); +QString LAMPTOOLAPI get_IGES_FilterString(); +QString LAMPTOOLAPI getOCCTShapeTypeFilterString(OCCTShapeType t); +QString LAMPTOOLAPI getOCCTShapeTypeFilterString(QString str); // 常用静态函数 -bool SaveTopoDs_Stl(QString FilePath, const TopoDS_Shape& shape); -bool SaveTopoDs_Step(QString FilePath, const TopoDS_Shape& shape); -bool SaveTopoDs_IGES(QString FilePath,const TopoDS_Shape& shape); -bool SaveTopoDs(QString FilePath,const TopoDS_Shape& shape, OCCTShapeType type); +bool LAMPTOOLAPI SaveTopoDs_Stl(QString FilePath, const TopoDS_Shape& shape); +bool LAMPTOOLAPI SaveTopoDs_Step(QString FilePath, const TopoDS_Shape& shape); +bool LAMPTOOLAPI SaveTopoDs_IGES(QString FilePath,const TopoDS_Shape& shape); +bool LAMPTOOLAPI SaveTopoDs(QString FilePath,const TopoDS_Shape& shape, OCCTShapeType type); -TopoDS_Shape ReadTopoDs_IGES(QString Filepath); -TopoDS_Shape ReadTopoDs_Stl(QString Filepath); -TopoDS_Shape ReadTopoDs_Step(QString Filepath); +TopoDS_Shape LAMPTOOLAPI ReadTopoDs_IGES(QString Filepath); +TopoDS_Shape LAMPTOOLAPI ReadTopoDs_Stl(QString Filepath); +TopoDS_Shape LAMPTOOLAPI ReadTopoDs_Step(QString Filepath); -OCCTShapeType ReadTopoDs_Shape(QString FilePath, TopoDS_Shape& shape_TopoDs); +OCCTShapeType LAMPTOOLAPI ReadTopoDs_Shape(QString FilePath, TopoDS_Shape& shape_TopoDs); // 模型合并 -TopoDS_Shape MergedTopoShape(std::vector TopoDS_Shapelist); +TopoDS_Shape LAMPTOOLAPI MergedTopoShape(std::vector TopoDS_Shapelist); // 修改模型显示 -void ChangeModelColor(Handle(AIS_Shape)& aisShape, Quantity_Color& redColor); +void LAMPTOOLAPI ChangeModelColor(Handle(AIS_Shape)& aisShape, Quantity_Color& redColor); //// 创建箭头 -TopoDS_Shape CreateArrow(const gp_Dir& direction, Standard_Real length, Standard_Real radius); +TopoDS_Shape LAMPTOOLAPI CreateArrow(const gp_Dir& direction, Standard_Real length, Standard_Real radius); // // OCCT 根据向量A和B,计算变换矩阵 -gp_Trsf GetTransFormFromVector(const gp_Vec& A, const gp_Vec& B); +gp_Trsf LAMPTOOLAPI GetTransFormFromVector(const gp_Vec& A, const gp_Vec& B); -TopoDS_Shape Process_RotationThetaPhi_MoveXYZ(TopoDS_Shape shape, double theta, double phi,double X,double Y,double Z); +TopoDS_Shape LAMPTOOLAPI Process_RotationThetaPhi_MoveXYZ(TopoDS_Shape shape, double theta, double phi,double X,double Y,double Z); //TopoDS_Shape Createpyramid(double width=10.0,double depth=5.0, double mouthWidth=1.0, double mouthHeight=0.5, double height = 15.0); @@ -63,27 +64,27 @@ TopoDS_Shape Process_RotationThetaPhi_MoveXYZ(TopoDS_Shape shape, double theta, // 创建一个笛卡尔坐标系 -TopoDS_Shape CreateCartesianCoordinatesAxis(double xlength,double ylength,double zlength); +TopoDS_Shape LAMPTOOLAPI CreateCartesianCoordinatesAxis(double xlength,double ylength,double zlength); // 常见模型创建 -TopoDS_Shape CreateBox(double x, double y, double z); -TopoDS_Shape CreateCylinder(double radius, double height); -TopoDS_Shape CreateCone(double radius_bottom, double radius_top, double height); -TopoDS_Shape CreateSphere(double radius); -TopoDS_Shape CreateTorus(double majorRadius, double minorRadius); +TopoDS_Shape LAMPTOOLAPI CreateBox(double x, double y, double z); +TopoDS_Shape LAMPTOOLAPI CreateCylinder(double radius, double height); +TopoDS_Shape LAMPTOOLAPI CreateCone(double radius_bottom, double radius_top, double height); +TopoDS_Shape LAMPTOOLAPI CreateSphere(double radius); +TopoDS_Shape LAMPTOOLAPI CreateTorus(double majorRadius, double minorRadius); // 常见模型操作 -TopoDS_Shape Cut(TopoDS_Shape& shape1, TopoDS_Shape& shape2); -TopoDS_Shape Fuse(TopoDS_Shape& shape1, TopoDS_Shape& shape2); +TopoDS_Shape LAMPTOOLAPI Cut(TopoDS_Shape& shape1, TopoDS_Shape& shape2); +TopoDS_Shape LAMPTOOLAPI Fuse(TopoDS_Shape& shape1, TopoDS_Shape& shape2); // 常见操作 -- 模型旋转、平移、缩放 -TopoDS_Shape Rotate(TopoDS_Shape& shape, gp_Ax1 axis, double angle); -TopoDS_Shape Translate(TopoDS_Shape& shape, gp_Vec move_vec); -TopoDS_Shape Scale(TopoDS_Shape& shape, gp_Pnt refrenceCenter, double scale); +TopoDS_Shape LAMPTOOLAPI Rotate(TopoDS_Shape& shape, gp_Ax1 axis, double angle); +TopoDS_Shape LAMPTOOLAPI Translate(TopoDS_Shape& shape, gp_Vec move_vec); +TopoDS_Shape LAMPTOOLAPI Scale(TopoDS_Shape& shape, gp_Pnt refrenceCenter, double scale); // 创建散射体雷达 // 创建一个坐标原点为圆心的 -TopoDS_Shape createConicalHorn(double bottomRadius,double bottomHeight,double topRadius,double topHeight); -TopoDS_Shape createPyramidalHorn(double bottomWidth, double bottomHeight, double bottomAtl, double topWidth, double topHeight, double topAtl); +TopoDS_Shape LAMPTOOLAPI createConicalHorn(double bottomRadius,double bottomHeight,double topRadius,double topHeight); +TopoDS_Shape LAMPTOOLAPI createPyramidalHorn(double bottomWidth, double bottomHeight, double bottomAtl, double topWidth, double topHeight, double topAtl); diff --git a/src/LAMPTool/SARBaseToolLib/BackScatterModel.cpp b/src/LAMPTool/SARBaseToolLib/BackScatterModel.cpp deleted file mode 100644 index fc43fa2..0000000 --- a/src/LAMPTool/SARBaseToolLib/BackScatterModel.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "BackScatterModel.h" -#include -#include - - -double MuhlemanSimulationBackScatter(double incidentAngle) -{ - return 0.0133*cos(incidentAngle)/pow(sin(incidentAngle)+0.1*cos(incidentAngle), 3); -} - -Eigen::MatrixXd MuhlemanSimulationBackScatter(Eigen::MatrixXd incidentAngle) -{ - return 0.0133 * (incidentAngle.array().cos()) / ((incidentAngle.array().sin()) + cos(incidentAngle.array().cos()*0.1).pow(3)); -} diff --git a/src/LAMPTool/SARBaseToolLib/BackScatterModel.h b/src/LAMPTool/SARBaseToolLib/BackScatterModel.h deleted file mode 100644 index 3544153..0000000 --- a/src/LAMPTool/SARBaseToolLib/BackScatterModel.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include -#include - -double MuhlemanSimulationBackScatter(double incidentAngle); -Eigen::MatrixXd MuhlemanSimulationBackScatter(Eigen::MatrixXd incidentAngle); - - - - - - diff --git a/src/LAMPTool/SARBaseToolLib/SARBaseTool.cpp b/src/LAMPTool/SARBaseToolLib/SARBaseTool.cpp deleted file mode 100644 index 320f543..0000000 --- a/src/LAMPTool/SARBaseToolLib/SARBaseTool.cpp +++ /dev/null @@ -1,283 +0,0 @@ -// SARBaseTool.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 -// - -#include "BaseToollib/ImageOperatorBase.h" -#include "SARBaseTool.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - -int Complex2dB(QString in_tiff, QString out_dB_path) -{ - GDALAllRegister(); - std::shared_ptr rasterDataset = OpenDataset(in_tiff); - int width = rasterDataset->GetRasterXSize(); - int height = rasterDataset->GetRasterYSize(); - int band_num = rasterDataset->GetRasterCount(); - double* gt = new double[6]; - std::shared_ptr gt_ptr(gt); - QString projectDef = rasterDataset->GetProjectionRef(); - GDALDataType gdal_datatype = rasterDataset->GetRasterBand(1)->GetRasterDataType(); - bool _nGt_flag = false; - if (projectDef == "") { - _nGt_flag = true; - } - else { - _nGt_flag = false; - } - CreateDataset(out_dB_path, height, width, 1, gt_ptr.get(), projectDef, GDT_Float64, _nGt_flag); - // 计算大小 - if (gdal_datatype == 0) { - return 1; - } - else if (gdal_datatype < 8) { - if (band_num != 2) { return 1; } - } - else if (gdal_datatype < 12) { - if (band_num != 1) { return 1; } - } - - int block_num = block_num_pre_memory(width, height, gdal_datatype, 1e9);// - block_num = block_num > height ? height : block_num; // 行数 - int line_num = block_num; - for (int i = 0; i < height; i = block_num + i) { - if (height - i < block_num) { - line_num = height - i; - } - else {} - // 构建矩阵块,使用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); - Eigen::MatrixX imag_mat(line_num * width, 1); - rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - data_mat.col(0) = ((real_mat.array().cast()).array().pow(2) + (imag_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); - Eigen::MatrixX imag_mat(line_num * width, 1); - rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - data_mat.col(0) = ((real_mat.array().cast()).array().pow(2) + (imag_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); - Eigen::MatrixX imag_mat(line_num * width, 1); - rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - data_mat.col(0) = ((real_mat.array().cast()).array().pow(2) + (imag_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); - Eigen::MatrixX imag_mat(line_num * width, 1); - rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - data_mat.col(0) = ((real_mat.array().cast()).array().pow(2) + (imag_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); - Eigen::MatrixX imag_mat(line_num * width, 1); - rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - data_mat.col(0) = ((real_mat.array().cast()).array().pow(2) + (imag_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); - // Eigen::MatrixX imag_mat(line_num * width, 1); - // rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - // rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - // data_mat.col(0) = ((real_mat.array().cast()).array().pow(2) + (imag_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); - // Eigen::MatrixX imag_mat(line_num * width, 1); - // rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - // rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - // data_mat.col(0) = ((real_mat.array().cast()).array().pow(2) + (imag_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); - Eigen::MatrixX imag_mat(line_num * width, 1); - rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - data_mat.col(0) = ((real_mat.array().cast()).array().pow(2) + (imag_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); - Eigen::MatrixX imag_mat(line_num * width, 1); - rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - data_mat.col(0) = ((real_mat.array().cast()).array().pow(2) + (imag_mat.array().cast()).array().pow(2)).log10() * 10.0; - _flag = true; - } - else if (gdal_datatype == GDT_CInt16) { - Eigen::MatrixX> complex_short_mat(line_num * width, 1); - rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, 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().pow(2) + complex_short_mat.imag().array().cast().pow(2)).log10() * 10.0; - _flag = true; - } - else if (gdal_datatype == GDT_CInt32) { - Eigen::MatrixX> complex_short_mat(line_num * width, 1); - rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, 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().pow(2) + complex_short_mat.imag().array().cast().pow(2)).log10() * 10.0; - _flag = true; - } - else if (gdal_datatype == GDT_CFloat32) { - Eigen::MatrixX> complex_short_mat(line_num * width, 1); - rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, 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().pow(2) + complex_short_mat.imag().array().cast().pow(2)).log10() * 10.0; - _flag = true; - } - else if (gdal_datatype == GDT_CFloat64) { - Eigen::MatrixX> complex_short_mat(line_num * width, 1); - rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, 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().pow(2) + complex_short_mat.imag().array().cast().pow(2)).log10() * 10.0; - _flag = true; - } - else {} - // 保存数据 - if (_flag) { - // 定义赋值矩阵 - saveDataset(out_dB_path, i, 0, 1, width, line_num, data_mat.data()); - } - else { - } - } - return 0; -} - -int Amplitude2dB(QString in_tiff, QString out_dB_path) -{ - - GDALAllRegister(); - std::shared_ptr rasterDataset = OpenDataset(in_tiff); - int width = rasterDataset->GetRasterXSize(); - int height = rasterDataset->GetRasterYSize(); - int band_num = rasterDataset->GetRasterCount(); - double* gt = new double[6]; - std::shared_ptr gt_ptr(gt); - QString projectDef = rasterDataset->GetProjectionRef(); - GDALDataType gdal_datatype = rasterDataset->GetRasterBand(1)->GetRasterDataType(); - bool _nGt_flag = false; - if (projectDef == "") { - _nGt_flag = true; - } - else { - _nGt_flag = false; - } - CreateDataset(out_dB_path, height, width, 1, gt_ptr.get(), projectDef, GDT_Float64, _nGt_flag); - // 计算大小 - if (gdal_datatype == 0) { - return 1; - } - else if (gdal_datatype < 8) { - if (band_num != 1) { return 1; } - } - else { return 1; } - - - int block_num = block_num_pre_memory(width, height, gdal_datatype, 2e9);// - block_num = block_num > height ? height : block_num; // 行数 - int line_num = block_num; - for (int i = 0; i < height; i = block_num + i) { - if (height - i < block_num) { - line_num = height - i; - } - else {} - // 构建矩阵块,使用eigen 进行矩阵计算,加速计算 - bool _flag = false; - Eigen::Matrix data_mat = ReadMatrixDoubleData(i, width, line_num, rasterDataset, gdal_datatype, 1); - _flag = (data_mat.rows() > 0) && (data_mat.cols() > 0); - // 保存数据 - if (_flag) { - // 定义赋值矩阵 - saveDataset(out_dB_path, i, 0, 1, width, line_num, data_mat.data()); - } - else { - } - } - return 0; -} - -Eigen::MatrixXd Complex2dB(Eigen::MatrixXcd in_matrix) -{ - return Complex2dB(in_matrix.real().array(), in_matrix.imag().array()); -} - -Eigen::MatrixXd Complex2dB(Eigen::MatrixXd in_matrix_real, Eigen::MatrixXd in_matrix_imag) -{ - return (in_matrix_real.array().pow(2) + in_matrix_imag.array().pow(2)).log10() * 10; -} - -double Complex2Amplitude(std::complex sign) -{ - return sqrt(pow(sign.real(),2)+pow(sign.imag(),2)); -} - -double Complex2phase(std::complex sign) -{ - //return (sign.real() == 0)*((sign.imag() < 0) * PI / 2)+ (sign.real() != 0)*(atan(sign.imag() / sign.real()) + (sign.real() < 0) * ((sign.imag() <= 0) * PI)); - if (sign.real() != 0) { - return atan(sign.imag() / sign.real()) + (sign.real() < 0) * ((sign.imag() <= 0) * PI); - } - else { - return (sign.imag() < 0) * PI / 2; - } -} - -Eigen::MatrixXd Complex2Amplitude(Eigen::MatrixXcd in_matrix) -{ - return in_matrix.array().abs().cast().array(); -} - -Eigen::MatrixXd Complex2phase(Eigen::MatrixXcd in_matrix) -{ - // 复数转相位 - Eigen::MatrixXd result = in_matrix.real().array(); - int rows = in_matrix.rows(); - int cols = in_matrix.cols(); - for (int i = 0; i < rows; i++) { // 可能是性能瓶颈 - for (int j = 0; j < cols; j++) { - result(i, j) = Complex2phase(in_matrix(i, j)); - } - } - - - return result; -} - -int Complex2dB_DLL(QString out_path, QString in_sar_path) -{ - return Complex2dB(in_sar_path, out_path); -} - -int Amplitude2dB_DLL(QString in_tiff, QString out_dB_path) -{ - return Amplitude2dB(in_tiff, out_dB_path); -} - - diff --git a/src/LAMPTool/SARBaseToolLib/SARBaseTool.h b/src/LAMPTool/SARBaseToolLib/SARBaseTool.h deleted file mode 100644 index b5d175d..0000000 --- a/src/LAMPTool/SARBaseToolLib/SARBaseTool.h +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once -/** -* 基础SARBaseTool 操作 -* -*/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#define PI 3.141592653589793238462643383279 -#define PI_180 180/3.141592653589793238462643383279 -#define T180_PI 3.141592653589793238462643383279/180 -#define LIGHTSPEED 299792458 -#define LIGHESPEEDGHZ 0.299792458 - -#define Radians2Degrees(Radians) Radians*PI_180 -#define Degrees2Radians(Degrees) Degrees*T180_PI - - -// 判断是否需要输出为DLL -#define DLLOUT -int Complex2dB(QString in_tiff, QString out_dB_path); -int Amplitude2dB(QString in_tiff, QString out_dB_path); -Eigen::MatrixXd Complex2dB(Eigen::MatrixXcd in_matrix); -Eigen::MatrixXd Complex2dB(Eigen::MatrixXd in_matrix_real, Eigen::MatrixXd in_matrix_imag ); - -double Complex2Amplitude(std::complex sign); -double Complex2phase(std::complex sign);// 返回弧度制相位 - - - -Eigen::MatrixXd Complex2Amplitude(Eigen::MatrixXcd in_matrix); -Eigen::MatrixXd Complex2phase(Eigen::MatrixXcd in_matrix); -// ---------------------------------------------------------------------------------------------------------- -// 后向散射系数系统仿真模型 - -#ifndef DLLOUT - -#else - -#ifdef __cplusplus -extern "C" { -#endif -#define DllExport __declspec( dllexport ) - int __declspec(dllexport) Complex2dB_DLL(QString out_path, QString in_sar_path); - int __declspec(dllexport) Amplitude2dB_DLL(QString in_tiff, QString out_dB_path); -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/src/LAMPTool/SARBaseToolLib/SARCalibration.cpp b/src/LAMPTool/SARBaseToolLib/SARCalibration.cpp deleted file mode 100644 index ccd3fbf..0000000 --- a/src/LAMPTool/SARBaseToolLib/SARCalibration.cpp +++ /dev/null @@ -1,384 +0,0 @@ -#include "SARCalibration.h" -#include "BaseToollib/ImageOperatorBase.h" -#include "SARBaseTool.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -using namespace std; -using namespace Eigen; - -/** -* 输入数据是ENVI格式数据 -*/ - - - - - - -Eigen::Matrix2cd CalibrationMatrix(Eigen::MatrixXcd in_matrix, double calibrationValue) -{ - return in_matrix.array() * calibrationValue; -} - -int CalibrationSiglePolarSAR(QString out_path, QString in_sar_path, double calibrationValue) -{ - return CalibrationComplex(out_path, in_sar_path, calibrationValue); -} - -int CalibrationComplex(const QString& out_path, const QString& in_sar_path, double calibrationValue) -{ - GDALAllRegister(); - std::shared_ptr rasterDataset = OpenDataset(in_sar_path); - int width = rasterDataset->GetRasterXSize(); - int height = rasterDataset->GetRasterYSize(); - int band_num = rasterDataset->GetRasterCount(); - double* gt = new double[6]; - std::shared_ptr gt_ptr(gt); - QString projectDef = rasterDataset->GetProjectionRef(); - GDALDataType gdal_datatype = rasterDataset->GetRasterBand(1)->GetRasterDataType(); - bool _nGt_flag = false; - if (projectDef == "") { - _nGt_flag = true; - } - else { - _nGt_flag = false; - } - CreateDataset(out_path, height, width, 1, gt_ptr.get(), projectDef, GDT_CFloat64, _nGt_flag); - // 计算大小 - if (gdal_datatype == 0) { - return 1; - } - else if (gdal_datatype < 8) { - if (band_num != 2) { return 1; } - } - else if (gdal_datatype < 12) { - if (band_num != 1) { return 1; } - - } - else {} - int block_num = block_num_pre_memory(width, height, gdal_datatype, 2e9);// - block_num = block_num > height ? height : block_num; // 行数 - int line_num = block_num; - for (int i = 0; i < height; i= block_num+i) { - if (height - i < block_num) { - line_num = height - i; - } - else {} - // 构建矩阵块,使用eigen 进行矩阵计算,加速计算 - 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, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - data_mat.col(0) = (real_mat.array().cast() * calibrationValue).array(); - data_mat.col(1) = (imag_mat.array().cast() * calibrationValue).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, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - data_mat.col(0) = (real_mat.array().cast() * calibrationValue).array(); - data_mat.col(1) = (imag_mat.array().cast() * calibrationValue).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, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - data_mat.col(0) = (real_mat.array().cast() * calibrationValue).array(); - data_mat.col(1) = (imag_mat.array().cast() * calibrationValue).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, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - data_mat.col(0) = (real_mat.array().cast() * calibrationValue).array(); - data_mat.col(1) = (imag_mat.array().cast() * calibrationValue).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, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - data_mat.col(0) = (real_mat.array().cast() * calibrationValue).array(); - data_mat.col(1) = (imag_mat.array().cast() * calibrationValue).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, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - // rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - // data_mat.col(0) = (real_mat.array().cast() * calibrationValue).array(); - // data_mat.col(1) = (imag_mat.array().cast() * calibrationValue).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, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - // rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - // data_mat.col(0) = (real_mat.array().cast() * calibrationValue).array(); - // data_mat.col(1) = (imag_mat.array().cast() * calibrationValue).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, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - data_mat.col(0) = (real_mat.array().cast() * calibrationValue).array(); - data_mat.col(1) = (imag_mat.array().cast() * calibrationValue).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, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - data_mat.col(0) = (real_mat.array().cast() * calibrationValue).array(); - data_mat.col(1) =( imag_mat.array().cast() * calibrationValue).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, i, 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() * calibrationValue).array(); - data_mat.col(1) = (complex_short_mat.imag().array().cast() * calibrationValue).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, i, 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() * calibrationValue).array(); - data_mat.col(1) = (complex_short_mat.imag().array().cast() * calibrationValue).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, i, 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() * calibrationValue).array(); - data_mat.col(1) = (complex_short_mat.imag().array().cast() * calibrationValue).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, i, 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() * calibrationValue).array(); - data_mat.col(1) = (complex_short_mat.imag().array().cast() * calibrationValue).array(); - _flag = true; - } - else {} - // 保存数据 - if (_flag) { - // 定义赋值矩阵 - saveDataset(out_path, i,0,1, width, line_num, data_mat.data()); - } - else { - } - } - return -1; -} - -int CalibrationComplex2dB(const QString& out_path, const QString& in_sar_path, double calibrationValue) -{ - GDALAllRegister(); - std::shared_ptr rasterDataset = OpenDataset(in_sar_path); - int width = rasterDataset->GetRasterXSize(); - int height = rasterDataset->GetRasterYSize(); - int band_num = rasterDataset->GetRasterCount(); - double* gt = new double[6]; - std::shared_ptr gt_ptr(gt); - QString projectDef = rasterDataset->GetProjectionRef(); - GDALDataType gdal_datatype = rasterDataset->GetRasterBand(1)->GetRasterDataType(); - bool _nGt_flag = false; - if (projectDef == "") { - _nGt_flag = true; - } - else { - _nGt_flag = false; - } - CreateDataset(out_path, height, width, 1, gt_ptr.get(), projectDef, GDT_CFloat64, _nGt_flag); - // 计算大小 - if (gdal_datatype == 0) { - return 1; - } - else if (gdal_datatype < 8) { - if (band_num != 2) { return 1; } - } - else if (gdal_datatype < 12) { - if (band_num != 1) { return 1; } - - } - else {} - int block_num = block_num_pre_memory(width, height, gdal_datatype, 2e9);// - block_num = block_num > height ? height : block_num; // 行数 - int line_num = block_num; - for (int i = 0; i < height; i = block_num + i) { - if (height - i < block_num) { - line_num = height - i; - } - else {} - // 构建矩阵块,使用eigen 进行矩阵计算,加速计算 - 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, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - data_mat.col(0) = (real_mat.array().cast() * calibrationValue).array(); - data_mat.col(1) = (imag_mat.array().cast() * calibrationValue).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, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - data_mat.col(0) = (real_mat.array().cast() * calibrationValue).array(); - data_mat.col(1) = (imag_mat.array().cast() * calibrationValue).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, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - data_mat.col(0) = (real_mat.array().cast() * calibrationValue).array(); - data_mat.col(1) = (imag_mat.array().cast() * calibrationValue).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, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - data_mat.col(0) = (real_mat.array().cast() * calibrationValue).array(); - data_mat.col(1) = (imag_mat.array().cast() * calibrationValue).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, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - data_mat.col(0) = (real_mat.array().cast() * calibrationValue).array(); - data_mat.col(1) = (imag_mat.array().cast() * calibrationValue).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, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - // rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - // data_mat.col(0) = (real_mat.array().cast() * calibrationValue).array(); - // data_mat.col(1) = (imag_mat.array().cast() * calibrationValue).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, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - // rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - // data_mat.col(0) = (real_mat.array().cast() * calibrationValue).array(); - // data_mat.col(1) = (imag_mat.array().cast() * calibrationValue).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, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - data_mat.col(0) = (real_mat.array().cast() * calibrationValue).array(); - data_mat.col(1) = (imag_mat.array().cast() * calibrationValue).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, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real - rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag - data_mat.col(0) = (real_mat.array().cast() * calibrationValue).array(); - data_mat.col(1) = (imag_mat.array().cast() * calibrationValue).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, i, 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() * calibrationValue).array(); - data_mat.col(1) = (complex_short_mat.imag().array().cast() * calibrationValue).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, i, 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() * calibrationValue).array(); - data_mat.col(1) = (complex_short_mat.imag().array().cast() * calibrationValue).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, i, 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() * calibrationValue).array(); - data_mat.col(1) = (complex_short_mat.imag().array().cast() * calibrationValue).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, i, 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() * calibrationValue).array(); - data_mat.col(1) = (complex_short_mat.imag().array().cast() * calibrationValue).array(); - _flag = true; - } - else {} - // 保存数据 - if (_flag) { - // 定义赋值矩阵 - - Eigen::Matrix data_out(line_num* width, 1);// 必须强制行优先 - data_out.col(0) = Complex2dB(data_mat.col(0).array(), data_mat.col(1).array()).array(); - saveDataset(out_path, i, 0, 1, width, line_num, data_out.data()); - } - else { - } - } - return -1; - - - - - return 0; -} - -int CalibrationComplex_DLL(const QString& out_path, const QString& in_sar_path, double calibrationValue) -{ - return 0; -} - -int CalibrationComplex2dB_DLL(const QString& out_path, const QString& in_sar_path, double calibrationValue) -{ - return 0; -} diff --git a/src/LAMPTool/SARBaseToolLib/SARCalibration.h b/src/LAMPTool/SARBaseToolLib/SARCalibration.h deleted file mode 100644 index cd57a9e..0000000 --- a/src/LAMPTool/SARBaseToolLib/SARCalibration.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - - -#ifndef SARCALIBRATION_H -#define SARCALIBRATION_H -/** -* SAR定标函数 -* -*/ -#include "referenceHeader.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -using namespace std; -using namespace Eigen; -// 判断是否需要输出为DLL -#define DLLOUT - - -// 定标计算 -// 输入定标系统,保证数据能够正常定标 -Eigen::Matrix2cd CalibrationMatrix(Eigen::MatrixXcd in_matrix, double calibrationValue); -int CalibrationComplex(const QString& out_path, const QString& in_sar_path, double calibrationValue); -int CalibrationComplex2dB(const QString& out_path, const QString& in_sar_path, double calibrationValue); -#ifndef DLLOUT - -#else - -#ifdef __cplusplus -extern "C" { -#endif - #define DllExport __declspec( dllexport ) - int __declspec(dllexport) CalibrationComplex_DLL(const QString& out_path, const QString& in_sar_path, double calibrationValue); - int __declspec(dllexport) CalibrationComplex2dB_DLL(const QString& out_path, const QString& in_sar_path, double calibrationValue); -#ifdef __cplusplus -} -#endif - - - -#endif - -#endif // !SARCALIBRATION_H \ No newline at end of file diff --git a/src/LAMPTool/SARBaseToolLib/SARCalibrationTool.cpp b/src/LAMPTool/SARBaseToolLib/SARCalibrationTool.cpp deleted file mode 100644 index de1d1d1..0000000 --- a/src/LAMPTool/SARBaseToolLib/SARCalibrationTool.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// SARCalibrationTool.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 -// -#include "SARCalibration.h" -#include "SARBaseTool.h" -#include -#include -#include - - - -int SiglePolarCalibration(int argc, char* argv[]) { - qDebug() << "mode : 1 "<< "\n"; - QString in_tiff_path = ""; - QString out_path = ""; - double calibration = 0; - // params prase - for (int i = 0; i < argc; i++) { - if (string(argv[i]) == "-in") - { - in_tiff_path = argv[i + 1]; - qDebug() << "in file : " << in_tiff_path << "\n"; - } - else if (string(argv[i]) == "-out") { - out_path = argv[i + 1]; - qDebug() << "out file : " << in_tiff_path << "\n"; - } - else if (string(argv[i]) == "-calibrationConst") { - calibration = strtod(argv[i + 1], NULL); - qDebug() << "calibrationConst : " << calibration << "\n"; - } - else {} - } - // excute tool - return CalibrationComplex(out_path, in_tiff_path, calibration); -} - - -int RasterComplex2dB(int argc, char* argv[]) { - qDebug() << "mode : 1 " << "\n"; - QString in_tiff_path = ""; - QString out_path = ""; - // params prase - for (int i = 0; i < argc; i++) { - if (string(argv[i]) == "-in") - { - in_tiff_path = argv[i + 1]; - qDebug() << "in file : " << in_tiff_path << "\n"; - } - else if (string(argv[i]) == "-out") { - out_path = argv[i + 1]; - qDebug() << "out file : " << in_tiff_path << "\n"; - } - else {} - } - // excute tool - return Complex2dB(in_tiff_path, out_path); -} - - -int Test_SARCalibrationTool(int argc, char* argv[]) -{ - qDebug() << "calibration tool " << "\n"; - qDebug() << "sigle polsar Amg: SARCalibrationTool.exe 1 -in filepath -out filepath -calibrationConst 43" << "\n"; - qDebug() << "complex 2 dB : SARCalibrationTool.exe 1 -in filepath -out filepath" << "\n"; - if (argc == 1) { - qDebug() << "the number of params should be than 2" << "\n"; - return 2; - } - try { - int mode = atoi(argv[1]); - if (mode == 1) { - return SiglePolarCalibration(argc, argv); - } - else if (mode == 2) { - return RasterComplex2dB(argc, argv); - } - else {} - } - catch (std::exception ex) { - std::wcerr << ex.what() << "\n"; - } - - qDebug() << "Hello World!\n"; - return 0; -} - diff --git a/src/LAMPTool/SARBaseToolLib/SARImageBase.cpp b/src/LAMPTool/SARBaseToolLib/SARImageBase.cpp deleted file mode 100644 index 29f0d9e..0000000 --- a/src/LAMPTool/SARBaseToolLib/SARImageBase.cpp +++ /dev/null @@ -1,334 +0,0 @@ -#include "BaseToollib/ImageOperatorBase.h" -#include "SARBaseTool.h" -#include "SARImageBase.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "referenceHeader.h" -#include "OCCTBase.h" -#include "BaseToollib/GeoOperator.h" -#include "SARBaseToolLib/SARImageBase.h" - - - - - -double getRangeResolution(double startfreq, double endfreq) -{ - return LIGHTSPEED / 2 / std::abs(endfreq - startfreq); -} - -double getAzimuthResolution(double AzAngleRange, double startFreq) -{ - return LIGHTSPEED / 2 / (AzAngleRange * startFreq); -} - -Eigen::MatrixXd hammingWindows(size_t num) -{ - double alpha = 25. / 46; - double beta = 1 - alpha; - double scale = 1; - size_t m = num; - Eigen::MatrixXd x = Eigen::MatrixXd::Zero(m, 1); - for (int i = 0; i < m; i++) { - x(i, 0) = alpha - beta * std::cos(2 * PI * i / (num - 1)); - } - x = x.array() * scale; - return x; -} - - -Eigen::MatrixXd Hanning(size_t Nf, size_t Nxa, double alpha) -{ - // n1 = double ? DOUBLE(n1In[0]) : FLOAT(n1In[0]) - double a = 2 * PI / Nf; // a = 2 * pi / N1 ;scale factor - double n2 = Nxa; // n2 = double ? DOUBLE(n2In[0]) : FLOAT(n2In[0]) - double b = 2 * pi / n2; // dim 2 scale fact - double one = 1.0; // double ? 1d : 1.0 - double temp_row = 0; - double temp_col = 0; - Eigen::MatrixXd result_arr = Eigen::MatrixXd::Zero(Nxa, Nf); // 结果 - for (int i = 0; i < Nxa; i++) { - for (int j = 0; j < Nf; j++) { - // index = double ? DINDGEN(n1) : FINDGEN(n1) ; Nf - temp_row = (alpha - one) * cos(j * a) + alpha; // (alpha-one) * cos(index*a) + alpha ;One row - // index = double ? DINDGEN(n2) : FINDGEN(n2) ; Nxa - temp_col = (alpha - one) * cos(i * b) + alpha; // col = (alpha-one) * cos(index*b) + alpha ;One column - result_arr(i, j) = temp_row * temp_col;// RETURN,(row # col) ;DINDGEN(n1)#DINDGEN(n2) - } - } - return result_arr; -} - - -Eigen::MatrixXcd HammingWindows(Eigen::MatrixXcd FreqEcho) -{ - size_t data_cols = FreqEcho.cols(); - size_t data_rows = FreqEcho.rows(); - - // 进行进行hanmming windows - Eigen::MatrixXd hamming_Az = hammingWindows(data_cols); - Eigen::MatrixXd hamming_Rz = hammingWindows(data_rows); - for (int i = 0; i < data_cols; i++) { - for (int j = 0; j < data_rows; j++) { - FreqEcho(j, i) = FreqEcho(j, i) * hamming_Az(i, 0) * hamming_Rz(j, 0); - } - } - return FreqEcho; -} - -Eigen::MatrixXcd InterpFreqEcho(Eigen::MatrixXcd freqEcho, Eigen::VectorXd SourceFreqlist, Eigen::VectorXd interpFreqlist) -{ - assert(freqEcho.cols() == SourceFreqlist.rows()); - - - - size_t data_rows = freqEcho.rows(); - size_t data_cols = freqEcho.cols(); - - size_t out_cols = interpFreqlist.rows(); - Eigen::MatrixXcd resultECHO = Eigen::MatrixXcd::Zero(data_rows, out_cols); - - -#pragma omp parallel for // NEW ADD - for (int i = 0; i < data_rows; i++) { // 单脉冲 - double* xs = new double[data_rows]; - for (int i = 0; i < data_cols; i++) { - xs[i] = SourceFreqlist(i); // 原始回波 - } - double* real_ys = new double[data_cols]; - double* imag_ys = new double[data_cols]; - - gsl_interp_accel* acc = gsl_interp_accel_alloc(); - const gsl_interp_type* t = gsl_interp_cspline_periodic; - gsl_spline* spline_real = gsl_spline_alloc(t, data_rows); - gsl_spline* spline_imag = gsl_spline_alloc(t, data_rows); - - for (int jj = 0; jj < data_cols; jj++) { - real_ys[jj] = freqEcho(jj, i).real(); - imag_ys[jj] = freqEcho(jj, i).imag(); - } - gsl_spline_init(spline_real, xs, real_ys, data_rows); - gsl_spline_init(spline_imag, xs, imag_ys, data_rows); - for (int j = 0; j < out_cols; j++) { // 受限于当前函数只能逐点插值,或者后期可修改为 gsl 直接插值 - double cx = interpFreqlist(j,0); - std::complex result( - gsl_spline_eval(spline_real, cx, acc),// 插值实部 - gsl_spline_eval(spline_imag, cx, acc)// 插值虚部 - ); - resultECHO(i, j) = result; - } - - gsl_spline_free(spline_real); - gsl_spline_free(spline_imag); - gsl_interp_accel_free(acc); - - delete[] xs; - delete[] real_ys, imag_ys; - } - return resultECHO; -} - -int WriteComplexData2Amp_Arg(QString out_tiff_path, Eigen::MatrixXcd data) -{ - Eigen::MatrixXd amp_data = Eigen::MatrixXd::Zero(data.rows(), data.cols()); - Eigen::MatrixXd arg_data = Eigen::MatrixXd::Zero(data.rows(), data.cols()); - size_t row_count = data.rows(); - size_t col_count = data.cols(); - for (int i = 0; i < row_count; i++) { - for (int j = 0; j < col_count; j++) { - amp_data(i, j) = std::abs(data(i, j)); - arg_data(i, j) = std::arg(data(i, j)); - } - } - - - Eigen::MatrixXd gt = Eigen::MatrixXd::Zero(2, 3); - - gdalImage image_tiff = CreategdalImage(out_tiff_path, row_count, col_count, 2, gt, "", false, true);// 注意这里保留仿真结果 - - image_tiff.saveImage(amp_data, 0, 0, 1); - image_tiff.saveImage(arg_data, 0, 0, 2); - - return 0; -} - -int WriteComplexData2AmpdB_Arg(QString out_tiff_path, Eigen::MatrixXcd data) -{ - Eigen::MatrixXd amp_data = Eigen::MatrixXd::Zero(data.rows(), data.cols()); - Eigen::MatrixXd arg_data = Eigen::MatrixXd::Zero(data.rows(), data.cols()); - size_t row_count = data.rows(); - size_t col_count = data.cols(); - for (int i = 0; i < row_count; i++) { - for (int j = 0; j < col_count; j++) { - amp_data(i, j) = 10.0*std::log10(std::abs(data(i, j))); - arg_data(i, j) = std::arg(data(i, j)); - } - } - - - Eigen::MatrixXd gt = Eigen::MatrixXd::Zero(2, 3); - - gdalImage image_tiff = CreategdalImage(out_tiff_path, row_count, col_count, 2, gt, "", false, true);// 注意这里保留仿真结果 - - image_tiff.saveImage(amp_data, 0, 0, 1); - image_tiff.saveImage(arg_data, 0, 0, 2); - - return 0; -} - -size_t nextpow2(size_t num) -{ - double n = std::round(std::log10(num * 1.0) / std::log10(2.0)); - return pow(2, (size_t)std::ceil(n) + 1); -} - - -Eigen::MatrixXcd IFFTW1D(Eigen::MatrixXcd ECHOdata) -{ - size_t data_rows = ECHOdata.rows(); - size_t data_cols = ECHOdata.cols(); - // 频域 转换到 时域 - size_t n2 = nextpow2(data_cols) ; - //qDebug() << data_rows << "," << data_cols << "," << n2 << "\n"; - // 补零 - Eigen::MatrixXcd ExpandECHO = Eigen::MatrixXcd::Zero(data_rows, n2); - for (int i = 0; i < data_rows; i++) { - for (int j = 0; j < data_cols; j++) { - ExpandECHO(i, j) = ECHOdata(i, j); - } - } - // 结果 - Eigen::MatrixXcd echoTime = Eigen::MatrixXcd::Zero(data_rows, n2); - - fftw_complex* din = (fftw_complex*)fftw_malloc(sizeof(double) * n2 * 2); - fftw_complex* dout = (fftw_complex*)fftw_malloc(sizeof(double) * n2 * 2); - fftw_plan p; - double n = 1.0 / n2; // 因为 fftw 的逆傅里叶变换,没有除于N,所以实际上是原来的N倍 - //逐行进行fftw - p = fftw_plan_dft_1d(n2, din, dout, FFTW_BACKWARD, FFTW_MEASURE);//FFTW_BACKWARD 逆, - fftw_execute(p); //FFTW_MEASURE 估计最优变换方法,后面复用变换方案 - // 傅里叶 计算进度 - for (int i = 0; i < data_rows; i++) { - for (int j = 0; j < n2; j++) { // 初始化输入 - din[j][0] = std::real(ExpandECHO(i, j)); - din[j][1] = std::imag(ExpandECHO(i, j)); - } - // 构建fftw 任务 - fftw_execute(p); - // 保存结果 - for (int j = 0; j < n2; j++) { //读取结果 - echoTime(i, j) = std::complex(dout[j][0], dout[j][1]) * n; // 每次变换后都除于n - } - printf("\rIFFT[%.2lf%%]...:", i * 100.0 / (data_rows - 1)); - } - fftw_destroy_plan(p); - fftw_free(din); - fftw_free(dout); - qDebug() << "\n"; - qDebug() << "IFFT over" << "\n"; - return echoTime; -} - -Eigen::MatrixXcd FFTW1D(Eigen::MatrixXcd ECHO) -{ - size_t data_rows = ECHO.rows(); - size_t data_cols = ECHO.cols(); - // 频域 转换到 时域 - size_t n2 = data_cols; - // 补零 - Eigen::MatrixXcd ExpandECHO = Eigen::MatrixXcd::Zero(data_rows, n2); - for (int i = 0; i < data_rows; i++) { - for (int j = 0; j < data_cols; j++) { - ExpandECHO(i, j) = ECHO(i, j); - } - } - // 结果 - Eigen::MatrixXcd echofreq = Eigen::MatrixXcd::Zero(data_rows, n2); - fftw_complex* din = (fftw_complex*)fftw_malloc(sizeof(double) * n2 * 2); - fftw_complex* dout = (fftw_complex*)fftw_malloc(sizeof(double) * n2 * 2); - fftw_plan p; - //逐行进行fftw - p = fftw_plan_dft_1d(n2, din, dout, FFTW_FORWARD, FFTW_MEASURE);//FFTW_FORWARD 顺, - fftw_execute(p); //FFTW_MEASURE 估计最优变换方法,后面复用变换方案 - for (int i = 0; i < data_rows; i++) { - for (int j = 0; j < n2; j++) { // 初始化输入 - din[j][0] = std::real(ExpandECHO(i, j)); - din[j][1] = std::imag(ExpandECHO(i, j)); - } - // 构建fftw 任务 - fftw_execute(p); - // 保存结果 - for (int j = 0; j < n2; j++) { //读取结果 - echofreq(i, j) = std::complex(dout[j][0], dout[j][1]); - } - printf("\rFFT[%.2lf%%]...:", i * 100.0 / (data_rows - 1)); - } - fftw_destroy_plan(p); - fftw_free(din); - fftw_free(dout); - qDebug() << "\n"; - qDebug() << "FFT over" << "\n"; - return echofreq; -} - - - -Eigen::MatrixXcd FFTW2D(Eigen::MatrixXcd ECHO) -{ - // 获取数据的尺寸 - int rows = ECHO.rows(); - int cols = ECHO.cols(); - - // 创建FFTW输入和输出数组 - fftw_complex* in = reinterpret_cast(ECHO.data()); - fftw_complex* out = static_cast(fftw_malloc(sizeof(fftw_complex) * rows * cols)); - - // 创建FFTW计划,执行傅立叶变换 - fftw_plan plan = fftw_plan_dft_2d(rows, cols, in, out, FFTW_FORWARD, FFTW_ESTIMATE); - fftw_execute(plan); - - // 打印傅立叶变换结果 - Eigen::MatrixXcd result(rows, cols); - result = Map(reinterpret_cast*>(out), rows, cols); - //qDebug() << "Fourier Transform Result: " << "\n" << result << "\n"; - - // 销毁FFTW计划和内存 - fftw_destroy_plan(plan); - fftw_free(out); - qDebug() << "\n"; - qDebug() << "FFT over" << "\n"; - return result; -} - - -Eigen::MatrixXcd fftshift(Eigen::MatrixXcd X) { - int rows = X.rows(); - int cols = X.cols(); - int rows_half = rows / 2; - int cols_half = cols / 2; - - Eigen::MatrixXcd tmp = X.topLeftCorner(rows_half, cols_half); - X.topLeftCorner(rows_half, cols_half) = X.bottomRightCorner(rows_half, cols_half); - X.bottomRightCorner(rows_half, cols_half) = tmp; - - tmp = X.topRightCorner(rows_half, cols_half); - X.topRightCorner(rows_half, cols_half) = X.bottomLeftCorner(rows_half, cols_half); - X.bottomLeftCorner(rows_half, cols_half) = tmp; - - return X; -} \ No newline at end of file diff --git a/src/LAMPTool/SARBaseToolLib/SARImageBase.h b/src/LAMPTool/SARBaseToolLib/SARImageBase.h deleted file mode 100644 index d963a44..0000000 --- a/src/LAMPTool/SARBaseToolLib/SARImageBase.h +++ /dev/null @@ -1,95 +0,0 @@ -#pragma once -#ifndef SARIMAGEBASE_H -#define SARIMAGEBASE_H -/** -* 成像过程中常用的计算函数 -****/ -#include "referenceHeader.h" -#include "SARBaseTool.h" -// ------------------------------------------- 成像 公用库---------------------------------------------------------- -// SAR 常用计算的方法 -double getRangeResolution(double startfreq, double endfreq); - -/// -/// 方位向分辨率计算 -/// -/// 弧度制,方位角变化范围(>=0) -/// 起始频率 -/// -double getAzimuthResolution(double AzAngleRange, double startFreq); -// 根据输入数量构建汉明窗 -Eigen::MatrixXd hammingWindows(size_t num); - - -// 频率域汉明窗口 - -/// -/// 频率域汉明窗口 -/// -/// 频率点数 -/// 脉冲数量 -/// 权重 -/// 汉明窗权重 -Eigen::MatrixXd Hanning(size_t Nf, size_t Nxa, double alpha = 0.54); - -/// -/// 获取2的平方数,大于2 -/// -/// -/// -size_t nextpow2(size_t num); - -/// -/// 对回波沿着行进行一维傅里叶逆变换 -/// -/// -/// -Eigen::MatrixXcd IFFTW1D(Eigen::MatrixXcd ECHO); - - -/// -/// 对回波沿着行进行一维傅里叶变换 -/// -/// -/// -Eigen::MatrixXcd FFTW1D(Eigen::MatrixXcd echo); -Eigen::MatrixXcd FFTW2D(Eigen::MatrixXcd ECHO); - -Eigen::MatrixXcd fftshift(Eigen::MatrixXcd X); -/// -/// 对回波 加 hamming 窗 -/// -/// 频域的回波数据(PRFnum,Freqnum) -/// -Eigen::MatrixXcd HammingWindows(Eigen::MatrixXcd FreqEcho); - - -/// -/// 对回波进行一维插值(并行),不能用来处理极坐标 -/// 插值方式为 实部虚部分别进行线性插值 -/// -/// 回波数据,(行数,列数):(PRFNUM,freqNUM) -/// 回波的 原始频率列表 -/// 回波的 插值频率列表 -/// -Eigen::MatrixXcd InterpFreqEcho(Eigen::MatrixXcd freqEcho, Eigen::VectorXd SourceFreqlist, Eigen::VectorXd interpFreqlist); - - -/// -/// 保存复数矩阵数据 为tiff, 其中,band 1: amp (linear) angle(radia) -/// -/// -/// -/// -int WriteComplexData2Amp_Arg(QString out_tiff_path, Eigen::MatrixXcd data); - - -/// -/// 保存复数矩阵数据 为tiff, 其中,band 1: amp (dB) angle(radia) -/// -/// -/// -/// -int WriteComplexData2AmpdB_Arg(QString out_tiff_path, Eigen::MatrixXcd data); -// ---------------------------------------------------------------------------------------------------------- -#endif diff --git a/src/LAMPTool/SARImage/FEKOBaseToolClass.cpp b/src/LAMPTool/SARImage/FEKOBaseToolClass.cpp deleted file mode 100644 index 90cbaac..0000000 --- a/src/LAMPTool/SARImage/FEKOBaseToolClass.cpp +++ /dev/null @@ -1,1040 +0,0 @@ -#include "SARImage/FEKOBaseToolClass.h" -#include -#include "BaseToolLib/BaseConstVariable.h" -#include -#include -#include -#include "BaseToollib/ImageOperatorBase.h" -#include -#include "SARBaseToolLib/SARBaseTool.h" -#include "BaseToollib/FileOperator.h" -#include - - - - - - - - - -QString FEKOBase::FEKOImageModeenumToString(FEKOBase::FEKOImageMode mode) -{ - switch (mode) { - case Strip: - return "STRIP"; - case Scane: - return "SCANE"; - case ISAR: - return "ISAR"; - case CircleSAR: - return "CircleSAR"; - } - // 如果枚举值不匹配任何字符串,则返回一个默认值,或者抛出异常 - return "UNKNOW"; // 默认返回Unknown -} - -FEKOBase::FEKOCoordinateSystem FEKOBase::FEKOCoordinateSystemString2Enum(QString str) -{ - if (str.toUpper() == "SPHERICAL") { return FEKOBase::Spherical; } - else if (str.toUpper() == "CARTESIAN") { return FEKOBase::Cartesian; } - else { - return FEKOBase::UNKONWFEKOCOORDINATESYSTEM; - } - -} - -QString FEKOBase::QString2FEKOCoordinateSystem(FEKOBase::FEKOCoordinateSystem mode) -{ - switch (mode) { - case FEKOBase::Spherical: - return "SPHERICAL"; - case FEKOBase::Cartesian: - return "CARTESIAN"; - default: - return "UNKONWFEKOCOORDINATESYSTEM"; - - } -} - -FEKOBase::FEKOImageMode FEKOBase::FEKOImageModeString2Enum(QString str) -{ - if (str.toUpper() == "STRIP") { - return FEKOBase::FEKOImageMode::Strip; - } - else if (str.toUpper() == "SCANE") { - return FEKOBase::FEKOImageMode::Scane; - } - else if (str.toUpper() == "ISAR") { - return FEKOBase::FEKOImageMode::ISAR; - } - else if (str.toUpper() == "CIRCLESAR") { - return FEKOBase::FEKOImageMode::CircleSAR; - } - // 如果输入的字符串不匹配任何枚举值,则返回一个默认值,或者抛出异常 - return FEKOBase::FEKOImageMode::UNKNOW; // 默认返回UNKNOW -} - -FEKOBase::freqParams FEKOBase::getFreqSetting(double centerFreq, double resolution, double bandWidth, double scenceRange, bool isResolution) { - - FEKOBase::freqParams result{ 0,0,0 }; - { - if (isResolution) { - bandWidth = 0.299792458 / 2 / resolution; // 计算带宽 - } - else { - resolution = 0.299792458 / 2 / bandWidth; // 计算分辨率 - } - } - size_t samplePoint = std::ceil((scenceRange) / resolution) + 1; - result.startfreqs = centerFreq - 0.5 * bandWidth; - result.endfreqs = centerFreq + 0.5 * bandWidth; - result.freqpoint = samplePoint; - return result; -} - -FEKOBase::FEKOSatelliteParams FEKOBase::createFEKOSatelliteParams(double Px, double Py, double Pz, double Vx, double Vy, double Vz, double incidenceAngle, double AzAngle, double theta, double phi, bool isRight, size_t PRFIdx) -{ - FEKOBase::FEKOSatelliteParams result{ - PRFIdx, - FEKOBase::SatelliteState{ - FEKOBase::SatellitePosition{Px,Py,Pz}, - FEKOBase::SatelliteVelocity{Vx,Vy,Vz} - }, - incidenceAngle,AzAngle, - FEKOBase::FEKOantPitionDirect{Px,Py,Pz,theta,phi}, - isRight - }; - return result; -} - -FEKOBase::FEKOSatelliteParams FEKOBase::createFEKOSatelliteParams(SatelliteState pose, double incidenceAngle, double AzAngle, FEKOantPitionDirect antpos, size_t PRFIdx) -{ - FEKOBase::FEKOSatelliteParams result{ - PRFIdx,pose,incidenceAngle,AzAngle,antpos - }; - return result; -} - -FEKOBase::SatelliteState FEKOBase::FEKOSatelliteParams2SatelliteState(FEKOSatelliteParams parmas) -{ - return parmas.pose; -} - -FEKOBase::FEKOantPitionDirect FEKOBase::FEKOSatelliteParams2FEKOantPitionDirect(FEKOSatelliteParams parmas) -{ - return parmas.antpos; -} - -TopoDS_Shape FEKOBase::SatellitePos2FEKOAntPos(SatelliteState satepos, double incidenceAngle, double AzAngle, bool isRIGHT, FEKOantPitionDirect* antposition_Direct, TopoDS_Shape antModel) -{ - incidenceAngle = incidenceAngle * M_PI / 180; // 转换为弧度 - AzAngle = AzAngle * M_PI / 180; // 扫描角度转换为弧度 - TopoDS_Shape tempShape; - if (!antModel.IsNull()) { - // 创建一个复制 - BRepBuilderAPI_Copy copyBuilder(antModel); - tempShape = copyBuilder.Shape(); - } - - double Sx = satepos.pos.Px; - double Sy = satepos.pos.Py; - double Sz = satepos.pos.Pz; - double Vx = satepos.vel.Vx; - double Vy = satepos.vel.Vy; - double Vz = satepos.vel.Vz; - //qDebug() << u8"// 0. 卫星状态矢量"; - gp_Vec SateVelocity(gp_Pnt(0, 0, 0), gp_Pnt(Vx, Vy, Vz)); // 卫星速度矢量 - gp_Vec SatePosition(gp_Pnt(0, 0, 0), gp_Pnt(Sx, Sy, Sz)); // 卫星位置矢量 - gp_Vec sch_X(gp_Pnt(0, 0, 0), gp_Pnt(1.0, 0.0, 0.0)); - gp_Vec sch_Y(gp_Pnt(0, 0, 0), gp_Pnt(0.0, 1.0, 0.0)); // 飞行方向 y - gp_Vec sch_Z(gp_Pnt(0, 0, 0), gp_Pnt(0.0, 0.0, 1.0)); // 雷达照射方向 - -// qDebug() << u8"// 1. 卫星坐标系 sch -->飞行坐标系 fly 保证Z轴指向不变化"; - gp_Vec sch_X_fly; - gp_Vec sch_Y_fly; // 飞行向 - gp_Vec sch_Z_fly; - - { - CartesianCoordinates Sp_car{ sch_Y.X(),sch_Y.Y(), sch_Y.Z() }; - CartesianCoordinates tp_car{ SateVelocity.X(),SateVelocity.Y(), SateVelocity.Z() }; - - SphericalCoordinates sp_sph = cartesianToSpherical(Sp_car); - SphericalCoordinates tp_sph = cartesianToSpherical(tp_car); - - // 计算 - double delta_theta = tp_sph.theta - sp_sph.theta; - double delta_phi = tp_sph.phi - sp_sph.phi; - - gp_Trsf rotationTransform_theta; - rotationTransform_theta.SetRotation(gp_Ax1(gp_Pnt(0, 0, 0), gp_Dir(0, 1, 0)), delta_theta); // 绕 y 轴旋转 - sch_X_fly = sch_X.Transformed(rotationTransform_theta); - sch_Y_fly = sch_Y.Transformed(rotationTransform_theta); - sch_Z_fly = sch_Z.Transformed(rotationTransform_theta); - - gp_Trsf rotationTransform_phi; - rotationTransform_phi.SetRotation(gp_Ax1(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), delta_phi); // 绕 z 轴旋转 - sch_X_fly = sch_X_fly.Transformed(rotationTransform_phi); - sch_Y_fly = sch_Y_fly.Transformed(rotationTransform_phi); - sch_Z_fly = sch_Z_fly.Transformed(rotationTransform_phi); - - if (!tempShape.IsNull()) { - BRepBuilderAPI_Transform shapeTransform_theta(tempShape, rotationTransform_theta); - tempShape = shapeTransform_theta.Shape(); - BRepBuilderAPI_Transform shapeTransform_phi(tempShape, rotationTransform_phi); - tempShape = shapeTransform_phi.Shape(); - } - } - -// qDebug() << u8"// 2. 根据方位角与俯仰角,调整雷达姿态 --- 此步确定 Y 轴已经调整完毕 "; -// qDebug() << u8"// 2. a 根据 incidenceAngle 调整 Z 的指向,需要先根据左右视判断出雷达照射方向"; - - { // 按照 Y 轴进行计算 - incidenceAngle = M_PI - incidenceAngle; // 下Z轴 - Standard_Real ZRotation_angle = 0; - if (isRIGHT) { // 右视 + - ZRotation_angle = incidenceAngle; - } - else { // 左视 - - ZRotation_angle = -1 * incidenceAngle; - } - gp_Trsf fly_incidence_trsf; - fly_incidence_trsf.SetRotation(gp_Ax1(gp_Pnt(0, 0, 0), sch_Y_fly), ZRotation_angle); // 计算入射角 - - sch_X_fly = sch_X_fly.Transformed(fly_incidence_trsf); - sch_Y_fly = sch_Y_fly.Transformed(fly_incidence_trsf); - sch_Z_fly = sch_Z_fly.Transformed(fly_incidence_trsf); // 此时获取雷达的照射方向 - - if (!tempShape.IsNull()) { - BRepBuilderAPI_Transform shapeTransform_incidence(tempShape, fly_incidence_trsf); // fly_Z --> incidenceAngle - tempShape = shapeTransform_incidence.Shape(); - } - - } - -// qDebug() << u8"// 2.b 根据 AzAngle 调整 Z 的指向 "; -// qDebug() << u8"// Az 应该变化在 YoZ, 也就是绕 X 轴 旋转;"; - - { // 沿Z 轴进行计算 - gp_Trsf fly_AZ_trsf; - fly_AZ_trsf.SetRotation(gp_Ax1(gp_Pnt(0, 0, 0), sch_X_fly), AzAngle); // 计算方位角变化 - - sch_X_fly = sch_X_fly.Transformed(fly_AZ_trsf); - sch_Y_fly = sch_Y_fly.Transformed(fly_AZ_trsf); - sch_Z_fly = sch_Z_fly.Transformed(fly_AZ_trsf); // 此时获取雷达的照射方向 - - if (!tempShape.IsNull()) { - BRepBuilderAPI_Transform shapeTransform_AZ(tempShape, fly_AZ_trsf); // fly_Z --> incidenceAngle - tempShape = shapeTransform_AZ.Shape(); // 旋转卫星模型 - } - - } -// qDebug() << u8"// 2.c 参数记录 "; - { - CartesianCoordinates Sp_car{ 0,0,1 }; - CartesianCoordinates tp_car{ sch_Z_fly.X(),sch_Z_fly.Y(), sch_Z_fly.Z() }; - - SphericalCoordinates sp_sph = cartesianToSpherical(Sp_car); - SphericalCoordinates tp_sph = cartesianToSpherical(tp_car); // 计算phi角度 - - double delta_theta = tp_sph.theta - sp_sph.theta; - double delta_phi = tp_sph.phi - sp_sph.phi; - - antposition_Direct->x = Sx; //-- FEKO 设置 - antposition_Direct->y = Sy; //-- FEKO 设置 - antposition_Direct->z = Sz; //-- FEKO 设置 - antposition_Direct->theta = delta_theta / M_PI * 180; //-- FEKO 设置 theta - antposition_Direct->phi = delta_phi / M_PI * 180;//--- FEKO 设置 phi - - } -// qDebug() << u8"//3. 执行模型平移"; - { - if (!tempShape.IsNull()) { - gp_Trsf fly_move_trsf; - fly_move_trsf.SetTranslation(SatePosition); - BRepBuilderAPI_Transform shapeTransform_move(tempShape, fly_move_trsf); // fly_Z --> incidenceAngle - tempShape = shapeTransform_move.Shape(); // 平移卫星模型 - - } - } - - qDebug() << QString(u8"雷达坐标与姿态(X,Y,Z,theta,phi): (%1,%2,%3,%4,%5)").arg(antposition_Direct->x) - .arg(antposition_Direct->y) - .arg(antposition_Direct->z) - .arg(antposition_Direct->theta) - .arg(antposition_Direct->phi); - - return tempShape; -} - -bool FEKOBase::compareElectricFieldDataInFreq(const ElectricFieldData& a, const ElectricFieldData& b) -{ - return a.frequency < b.frequency; -} - -bool FEKOBase::comparePRFPluseDataInPRFIdx(const PRFPluseData& a, const PRFPluseData& b) -{ - return a.prfidx < b.prfidx; -} - -FEKOBase::NearFieldEchoCSVParser::NearFieldEchoCSVParser() -{ -} - -FEKOBase::NearFieldEchoCSVParser::~NearFieldEchoCSVParser() -{ -} - -bool FEKOBase::NearFieldEchoCSVParser::checkPRFModel() -{ - - qDebug() << u8"正在检查是否可以采用脉冲计数模式 configuration Name :PRF_{脉冲计数}"; - - QRegExp regex("(\\d+)"); - // 判断是否需要按照脉冲次序排序 - bool usePRFbool = true; - QMap configName_prfidx; - // 使用迭代器遍历 QMap - QMap>::const_iterator it; - for (it = this->electricFieldDataList.constBegin(); it != this->electricFieldDataList.constEnd(); ++it) { - for (size_t i = 0; i < this->electricFieldDataList[it.key()].size(); i++) { - QString value = this->electricFieldDataList[it.key()][i].configurationName; - if (value.indexOf("PRF") != -1) { - if (regex.indexIn(value) != -1) { - // 提取匹配到的部分 - QString matchedText = regex.cap(1); - - size_t PRFidx = matchedText.toInt(&usePRFbool); - if (usePRFbool) { - configName_prfidx.insert(this->electricFieldDataList[it.key()][i].configurationName, PRFidx); - } - else { - qDebug() << u8"不能采用脉冲计数模型"; - QMessageBox::information(nullptr, u8"警告", u8"无法根据Configuration Name识别脉冲顺序,按照读取顺序,计数PRF", QMessageBox::Ok); - this->usePRFCountMode = false; - return false; - } - } - } - else { - qDebug() << u8"不能采用脉冲计数模型"; - QMessageBox::information(nullptr, u8"警告", u8"无法根据Configuration Name识别脉冲顺序,按照读取顺序,计数PRF", QMessageBox::Ok); - this->usePRFCountMode = false; - return false; - } - } - } - - // 更新prfidx - for (it = this->electricFieldDataList.constBegin(); it != this->electricFieldDataList.constEnd(); ++it) { - if (!(this->electricFieldDataList[it.key()].size() > 0)) { - QMessageBox::warning(nullptr, u8"错误", u8"发现空脉冲:" + it.key()); - qWarning() << u8"发现空脉冲:" + it.key(); - return false; - } - else {} - - QString value = this->electricFieldDataList[it.key()][0].configurationName; - - for (size_t i = 0; i < this->electricFieldDataList[it.key()].size(); i++) { - if (value != this->electricFieldDataList[it.key()][0].configurationName) { - QMessageBox::warning(nullptr, u8"错误", u8"脉冲解析错误,名称不一致:" + it.key() + " | " + value); - qWarning() << u8"脉冲解析错误,名称不一致:" + it.key() + " | " + value; - } - else {} - size_t tempprfidx = configName_prfidx[value]; - this->electricFieldDataList[it.key()][i].prfidx = tempprfidx; - } - } - - qDebug() << u8"结束检查是否可以采用脉冲计数模式 configuration Name :PRF_{脉冲计数}"; - return true; -} - -bool FEKOBase::NearFieldEchoCSVParser::resizePRFPluse() -{ - qDebug() << u8"根据数据文件,重新整理成脉冲形式"; - - QMap prfPluseMap; // 采用字典映射方式 - - qDebug() << u8"QMap> ==> QMap"; - double px; // 2. 计算姿态,近场点坐标 - double py; - double pz; - double R; - double theta; // x0y - double phi; // y0z - size_t PRFidx; - - for (QMap>::const_iterator it = this->electricFieldDataList.constBegin(); it != this->electricFieldDataList.constEnd(); ++it) { - PRFPluseData temp; - std::vector tempData = this->electricFieldDataList[it.key()]; // 脉冲已经排序号 - std::sort(tempData.begin(), tempData.end(), compareElectricFieldDataInFreq); - temp.electricFieldDataList = tempData; // 按照脉冲排序 - - temp.freqstart = tempData[0].frequency; // 1. 频率 - temp.freqend = tempData[tempData.size() - 1].frequency; - temp.freqpoints = tempData.size(); - - px = tempData[0].origin.x; // 2. 近场接收点计算姿态,近场点坐标 - py = tempData[0].origin.y; - pz = tempData[0].origin.z; - - - R = tempData[0].radius; - theta = tempData[0].theta; // x0y - phi = tempData[0].phi; // y0z - - - - - PRFidx = tempData[0].prfidx; - qDebug() << u8"分析姿态:" + it.key(); - for (size_t i = 0; i < tempData.size(); i++) { - if (abs(px - tempData[i].origin.x) > 0.001 || abs(py - tempData[i].origin.y) > 0.001 || - abs(pz - tempData[i].origin.z) > 0.001 || abs(R - tempData[i].radius) > 0.001 || - abs(theta - tempData[i].theta) > 0.001 || abs(phi - tempData[i].phi) > 0.001) - { - qDebug() << u8"发现 configuration Name:" + it.key() + u8" , 发现问题,请检查"; - QMessageBox::warning(nullptr, u8"警告", u8"发现 configuration Name:" + it.key() + u8" , 发现问题,请检查"); - return false; - } - else {} - } - // 计算增量 R, theta, phi ==> delta_R,delta_theta,delta_phi - theta = theta * M_PI / 180; - phi = phi * M_PI / 180; - - px = px + R * std::sin(theta) * std::cos(phi); - py = py + R * std::sin(theta) * std::sin(phi); - pz = pz + R * std::cos(theta); - - temp.px = px; - temp.py = py; - temp.pz = pz; - temp.prfidx = PRFidx; - - - prfPluseMap.insert(it.key(), temp); - } - - - qDebug() << u8"判断是所有回波均一性"; - this->prfData = std::vector(0); - size_t freqpointnum = prfPluseMap.first().freqpoints; - for (QMap::const_iterator it = prfPluseMap.constBegin(); it != prfPluseMap.constEnd(); ++it) { - if (it.value().freqpoints != freqpointnum) { - qDebug() << u8"回波数据频点数不一致,无法进行脉冲计数"; - QMessageBox::information(nullptr, u8"警告", u8"回波数据频点数不一致,无法进行脉冲计数", QMessageBox::Ok); - this->usePRFCountMode = false; - return false; - } - this->prfData.push_back(it.value()); - } - this->freqPoints = freqpointnum; - std::sort(this->prfData.begin(), this->prfData.end(), comparePRFPluseDataInPRFIdx); - - this->freqStart = this->prfData[0].freqstart; - this->freqEnd = this->prfData[0].freqend; - qDebug() << u8"根据数据文件,结束整理成脉冲形式"; - return true; - -} - -bool FEKOBase::NearFieldEchoCSVParser::parseCSV(const QString& filePath) -{ - - std::vector dataList; - - QFile file(filePath); - if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { - QTextStream in(&file); - - // 读取标题行 - QString headerLine = in.readLine(); - QStringList headers = headerLine.split(QRegularExpression(",(?!\\s)")); - - while (!in.atEnd()) { - QString line = in.readLine(); - - QStringList fields = line.split(QRegularExpression(",(?!\\s)")); - - ElectricFieldData data; - // 解析数据根据列名 - for (int i = 0; i < headers.size(); ++i) { - QString header = headers[i].trimmed(); - QString value = fields[i];// .trimmed(); - - if (header == "File Type") { - data.fileType = value; - } - else if (header == "File Format") { - data.fileFormat = value; - } - else if (header == "Source") { - data.source = value; - } - else if (header == "Date") { - data.date = value; - } - else if (header == "Radius") { // 半径 - data.radius = value.toDouble(); - } - else if (header == "Theta") { // theta 角 - data.theta = value.toDouble(); - } - else if (header == "Phi") {// phi 角 - data.phi = value.toDouble(); - } - else if (header == "Re(Er)") { - data.reEr = value.toDouble(); - } - else if (header == "Im(Er)") { - data.imEr = value.toDouble(); - } - else if (header == "Re(Etheta)") { - data.reEtheta = value.toDouble(); - } - else if (header == "Im(Etheta)") { - data.imEtheta = value.toDouble(); - } - else if (header == "Re(Ephi)") { - data.reEphi = value.toDouble(); - } - else if (header == "Im(Ephi)") { - data.imEphi = value.toDouble(); - } - else if (header == "Configuration Name") { // 脉冲次序名称 - data.configurationName = value.trimmed(); - } - else if (header == "Request Name") { - data.requestName = value.trimmed(); - } - else if (header == "Frequency") { - data.frequency = value.toDouble(); - } - else if (header == "Coordinate System") { - data.coordinateSystem = value; - } - else if (header == "Origin") { // 坐标参考原点 - QStringList vls = value.replace("\"", "").replace("(", "").replace(")", "").split(","); - if (vls.length() < 3) { - qDebug() << "******************** ERROR INFO ******************************************"; - qDebug() << "origin point has error ," << value; - qDebug() << "line: " << line; - qDebug() << "head: " << header; - qDebug() << "***************************************************************************"; - QMessageBox::information(nullptr, u8"警告", u8"无法解析Origin 参数,请检查", QMessageBox::Ok); - return false; - } - data.origin = Point_3d{ vls.at(0).toDouble(), - vls.at(1).toDouble(), - vls.at(2).toDouble() }; - } - else if (header == "Num Radius Samples") { - data.numRadiusSamples = value.toInt(); - } - else if (header == "Num Theta Samples") { - data.numThetaSamples = value.toInt(); - } - else if (header == "Num Phi Samples") { - data.numPhiSamples = value.toInt(); - } - else if (header == "Result Type") { - data.resultType = value; - } - else if (header == "Num Header Lines") { - data.numHeaderLines = value.toInt(); - } - // 添加其他字段的解析... - } - dataList.push_back(data); - } - - file.close(); - } - else { - qDebug() << "Failed to open the file:" << file.errorString(); - return false; - } - - //this->electricFieldDataList = dataList; - - qDebug() << u8"文件读取结果,对文件结果进行重新整理与检查"; - //获取脉冲最小值,最大值,如果是 使用软件生产的 configname 应该为 PRF_1 PRF_2 这里通过判断 1,2 来确定脉冲序号 - QSet configNameSet; - size_t curPRF = 0; - for (int i = 0; i < dataList.size(); i++) { - if (!configNameSet.contains(dataList[i].configurationName)) { - curPRF = curPRF + 1; - } - dataList[i].prfidx = curPRF; - configNameSet.insert(dataList[i].configurationName); - } - - // 初始化 - for (const QString& elementconfigName : configNameSet) { - this->electricFieldDataList.insert(elementconfigName, std::vector(0)); - } - - // 数据初始化 - for (size_t i = 0; i < dataList.size(); i++) { - this->electricFieldDataList[dataList[i].configurationName].push_back(dataList[i]); - } - // 每个Pluse 进行排序,按照频率: 小 -> 大, - QMap>::const_iterator it; - for (it = this->electricFieldDataList.constBegin(); it != this->electricFieldDataList.constEnd(); ++it) { - std::sort(this->electricFieldDataList[it.key()].begin(), this->electricFieldDataList[it.key()].end(), compareElectricFieldDataInFreq); - } - - // 检查每个electricFieldDataList 是否按照频率进行排序 - for (it = this->electricFieldDataList.constBegin(); it != this->electricFieldDataList.constEnd(); ++it) { - for (size_t i = 0; i < this->electricFieldDataList[it.key()].size() - 1; i++) { - if (this->electricFieldDataList[it.key()][i].frequency > this->electricFieldDataList[it.key()][i + 1].frequency) { - qDebug() << u8"发现 configuration Name:" + it.key() + u8" , 发现问题,请检查"; - QMessageBox::warning(nullptr, u8"警告", u8"发现 configuration Name:" + it.key() + u8" , 发现问题,请检查"); - return false; - } - } - } - - - if (!this->checkPRFModel() || !this->resizePRFPluse()) { - return false; - } - - return true; - -} - -void FEKOBase::NearFieldEchoCSVParser::toThetapolar(const QString& filePath) -{ - - this->toEchoData(filePath, 2); -} - -void FEKOBase::NearFieldEchoCSVParser::toPhiPolar(const QString& filePath) -{ - this->toEchoData(filePath, 1); -} - -void FEKOBase::NearFieldEchoCSVParser::toRPolar(const QString& filePath) -{ - this->toEchoData(filePath, 0); -} - -void FEKOBase::NearFieldEchoCSVParser::saveCSV(const QString& filePath) -{ -} - -/// -/// 输出脉冲回波文件 -/// -/// 文件路径 -/// 0: R,1: phi,2: theta -void FEKOBase::NearFieldEchoCSVParser::toEchoData(const QString& filePath, size_t outDataName) -{ - // 脉冲整理 - Eigen::MatrixXcd echoData = Eigen::MatrixXcd::Zero(this->prfData.size(), this->freqPoints); - Eigen::MatrixXd antpos = Eigen::MatrixXd::Zero(this->prfData.size(), 5); //x,y,z,theta,phi" - - for (size_t i = 0; i < this->prfData.size(); i++) { - antpos(i, 0) = this->prfData[i].px; - antpos(i, 1) = this->prfData[i].py; - antpos(i, 2) = this->prfData[i].pz; - antpos(i, 3) = this->prfData[i].electricFieldDataList[0].theta; - antpos(i, 4) = this->prfData[i].electricFieldDataList[0].phi; - for (size_t j = 0; j < this->freqPoints; j++) { - if (outDataName == 0) { - echoData(i, j) = std::complex(this->prfData[i].electricFieldDataList[j].reEr, this->prfData[i].electricFieldDataList[j].imEr); - } - else if (outDataName == 1) { - echoData(i, j) = std::complex(this->prfData[i].electricFieldDataList[j].reEphi, this->prfData[i].electricFieldDataList[j].imEphi); - } - else { - echoData(i, j) = std::complex(this->prfData[i].electricFieldDataList[j].reEtheta, this->prfData[i].electricFieldDataList[j].imEtheta); - } - - } - } - - EchoDataClass echodataTemp; - echodataTemp.setAntPos(antpos); - echodataTemp.setFreqStart(this->freqStart); - echodataTemp.setFreqEnd(this->freqEnd); - echodataTemp.setFreqpoints(this->freqPoints); - echodataTemp.setEchoData(echoData); - echodataTemp.SaveEchoData(filePath); -} - -FEKOBase::EchoDataClass::EchoDataClass(const FEKOBase::EchoDataClass& inecho) -{ - - this->echoData = inecho.getEchoData(); - this->antPos = inecho.getAntPos(); - this->freqStart = inecho.getFreqStart(); - this->freqEnd = inecho.getFreqEnd(); - this->freqpoints = inecho.getFreqpoints(); -} - - - -FEKOBase::EchoDataClass::EchoDataClass() -{ - -} - -FEKOBase::EchoDataClass::~EchoDataClass() -{ -} - - - - -void FEKOBase::EchoDataClass::setEchoData(Eigen::MatrixXcd echoData) -{ - this->echoData = echoData; -} - -Eigen::MatrixXcd FEKOBase::EchoDataClass::getEchoData() const -{ - return this->echoData; -} - -void FEKOBase::EchoDataClass::setAntPos(Eigen::MatrixXd antPos) -{ - this->antPos = antPos; -} - -Eigen::MatrixXd FEKOBase::EchoDataClass::getAntPos() const -{ - return this->antPos; -} - -void FEKOBase::EchoDataClass::setFreqStart(double freqStart) -{ - this->freqStart = freqStart; -} - -double FEKOBase::EchoDataClass::getFreqStart() const -{ - return this->freqStart; -} - -void FEKOBase::EchoDataClass::setFreqEnd(double freqEnd) -{ - this->freqEnd = freqEnd; -} - -double FEKOBase::EchoDataClass::getFreqEnd() const -{ - return this->freqEnd; -} - -void FEKOBase::EchoDataClass::setFreqpoints(int freqpoints) -{ - this->freqpoints = freqpoints; -} - -int FEKOBase::EchoDataClass::getFreqpoints() const -{ - return this->freqpoints; -} - -void FEKOBase::EchoDataClass::loadEchoData(const QString& filePath) -{ - std::ifstream file(reinterpret_cast(filePath.utf16()), std::ios::binary); - - if (file.is_open()) { - // 保存频率变量 - INT32 PRFRow = 0; - INT32 freqCol = 0; - // 读取其他成员变量 - file.read(reinterpret_cast(&freqStart), sizeof(double)); - file.read(reinterpret_cast(&freqEnd), sizeof(double)); - file.read(reinterpret_cast(&freqpoints), sizeof(INT32)); - file.read(reinterpret_cast(&PRFRow), sizeof(INT32)); - file.read(reinterpret_cast(&freqCol), sizeof(INT32)); - echoData = Eigen::MatrixXcd::Zero(PRFRow, freqCol); // 重新分配内存 - antPos = Eigen::MatrixXd::Zero(PRFRow, 5); - file.read(reinterpret_cast(antPos.data()), sizeof(double) * PRFRow * 5); // 保存天线位置 - file.read(reinterpret_cast(echoData.data()), sizeof(std::complex) * PRFRow * freqCol); // 保存回波数据 - file.close(); // 关闭文件 - - this->freqStart = freqStart; - this->freqEnd = freqEnd; - this->freqpoints = freqpoints; - this->echoData = echoData; - this->antPos = antPos; - qDebug() << u8"回波数据加载完成"; - } - else { - qWarning() << "Error: Unable to open file for reading."; - } -} - -void FEKOBase::EchoDataClass::SaveEchoData(const QString& filePath) -{ - if (echoData.rows() != antPos.rows() || antPos.cols() != 5) { - qDebug() << "Error: antPos.size()!=echoData.rows()*5" - + QString::number(echoData.rows()) + u8"!=" + QString::number(antPos.rows()) - + QString::number(antPos.cols()) + u8"!=5"; - return; - } - else {} - std::ofstream file(reinterpret_cast(filePath.utf16()), std::ios::binary); - qDebug() << "==================================================================="; - qDebug() << u8"回波脉冲文件格式说明:"; - qDebug() << u8"|freqStart(double),freqEnd(double),freqpoints(int)|PRFROW(int),PRFCol(int)|antPos|echodata|"; - qDebug() << u8"其中antPos: PRFrow*3 double x,y,z,incidence,azangle,theta,phi"; - qDebug() << u8"其中echodata: PRFrow*PRFCol complex "; - qDebug() << "==================================================================="; - if (file.is_open()) { - INT32 PRFRow = echoData.rows(); - INT32 freqCol = echoData.cols(); - file.write(reinterpret_cast(&freqStart), sizeof(double)); // 保存频率变量 - file.write(reinterpret_cast(&freqEnd), sizeof(double)); - file.write(reinterpret_cast(&freqpoints), sizeof(INT32)); - file.write(reinterpret_cast(&PRFRow), sizeof(INT32)); - file.write(reinterpret_cast(&freqCol), sizeof(INT32)); - file.write(reinterpret_cast(antPos.data()), sizeof(double) * antPos.size()); // 保存天线位置 - file.write(reinterpret_cast(echoData.data()), sizeof(std::complex) * echoData.size()); // 保存回波数据 - file.close(); // 关闭文件 - - } - else { - qDebug() << "Error: Unable to open file for writing."; - } -} - - - -Eigen::MatrixXd FEKOBase::WINDOWFun(Eigen::MatrixXcd& echo, ImageAlgWindowFun winfun) -{ - size_t Nxa = echo.rows(); - size_t Nf = echo.cols(); - Eigen::MatrixXd normw = Eigen::MatrixXd::Zero(Nxa, Nf); // 归一化窗函数 - - if (winfun == ImageAlgWindowFun::HANMMING) { - normw = Hanning(Nf, Nxa); - echo = echo.array() * normw.array(); - } - else { - normw = normw.array() * 0 + 1 / (Nxa * Nf); - } - - return normw; -} - -QList FEKOBase::getFEKOImageAlgorithmList() -{ - QList list; - FEKOImageAlgorithm alg; - for (alg = FEKOImageAlgorithm::TBP_TIME; alg < FEKOImageAlgorithm::UNKONW; alg = (FEKOImageAlgorithm)(alg + 1)) { - list.append(FEKOImageAlgorithm2String(alg)); - } - return list; -} - -FEKOBase::FEKOImageAlgorithm FEKOBase::String2FEKOImageAlgorithm(QString str) -{ - FEKOImageAlgorithm alg; - for (alg = FEKOImageAlgorithm::TBP_TIME; alg < FEKOImageAlgorithm::UNKONW; alg = (FEKOImageAlgorithm)(alg + 1)) { - if (str == FEKOImageAlgorithm2String(alg)) { - return alg; - } - else {} - } - return alg; -} - -QString FEKOBase::FEKOImageAlgorithm2String(FEKOImageAlgorithm alg) -{ - // 将FEKOImageAlgorithm 枚举转换为字符串 - switch (alg) - { - case FEKOBase::TBP_TIME: - return u8"TBP_TIME"; - case FEKOBase::TBP_FREQ: - return u8"TBP_FREQ"; - default: - return u8"UNKONW"; - } -} - -// 请仿照FEKOImageAlgorithm枚举的写法,构建QString 与 ImageAlgWindowFun 的转换函数 - -QList FEKOBase::getImageAlgWindowFunList() -{ - QList list; - ImageAlgWindowFun alg; - for (alg = ImageAlgWindowFun::NOWINDOWS; alg < ImageAlgWindowFun::UNKONWWINDOW; alg = (ImageAlgWindowFun)(alg + 1)) { - list.append(ImageAlgWindowFun2String(alg)); - } - return list; -} - -FEKOBase::ImageAlgWindowFun FEKOBase::String2ImageAlgWindowFun(QString str) -{ - ImageAlgWindowFun alg; - for (alg = ImageAlgWindowFun::UNKONWWINDOW; alg < ImageAlgWindowFun::UNKONWWINDOW; alg = (ImageAlgWindowFun)(alg + 1)) { - if (str == ImageAlgWindowFun2String(alg)) { - return alg; - } - else {} - } - return alg; -} - -QString FEKOBase::ImageAlgWindowFun2String(FEKOBase::ImageAlgWindowFun alg) -{ - switch (alg) - { - case FEKOBase::NOWINDOWS: - return u8"NOWINDOWS"; - case FEKOBase::HANMMING: - return u8"HANMMING"; - default: - return u8"UNKONWWINDOW"; - } -} - - -bool FEKOBase::BPImage_TIME(QString& restiffpath, Eigen::MatrixXcd& echoData, Eigen::MatrixXd& antPos, Eigen::MatrixXd& freqmatrix, Eigen::MatrixXd& X, Eigen::MatrixXd& Y, Eigen::MatrixXd& Z, ImageAlgWindowFun winfun) -{ - // BP成像算法 - const double c = 0.299792458; // 光速 - - return true; -} - -bool FEKOBase::FBPImage_FREQ(QString& restiffpath, Eigen::MatrixXcd& echoData, Eigen::MatrixXd& antPos, Eigen::MatrixXd& freqmatrix, Eigen::MatrixXd& X, Eigen::MatrixXd& Y, Eigen::MatrixXd& Z, ImageAlgWindowFun winfun) -{ - - // BP成像算法 - const double c = 0.299792458; // 光速 - const std::complex j(0, 1); // 虚数单位 - const size_t image_height = X.rows(); - const size_t image_width = X.cols(); - const size_t PRFCount = echoData.rows(); - const size_t frepoints = echoData.cols(); - Eigen::MatrixXcd factorj = Eigen::MatrixXcd::Zero(1, echoData.cols()); // 1 , freqs - factorj = freqmatrix.array().cast>().array() * j * 4 * M_PI / c; // 声明校正矩阵 - Eigen::MatrixXcd im_final = Eigen::MatrixXcd::Zero(image_height, image_width); - - - -#ifdef __SHOWPROCESS // 进度条展示 - QProgressDialog progressDialog(u8"BP_FREQ成像进度", u8"终止", 0, image_height); - progressDialog.setWindowTitle(u8"成像中"); - progressDialog.setWindowModality(Qt::WindowModal); - progressDialog.setAutoClose(true); - progressDialog.setValue(0); - progressDialog.setMaximum(image_height); - progressDialog.setMinimum(0); - progressDialog.show(); -#endif // __SHOWPROCESS - - - -#ifdef __SHOWIMAGEPROCESSRESULT // 加窗处理 - Eigen::MatrixXd normw = WINDOWFun(echoData, winfun); -#endif - -#ifdef __IMAGEPARALLEL -#pragma omp parallel for - for (long ii = 0; ii < image_height; ii++) - { - Eigen::MatrixXd im_R = Eigen::MatrixXd::Zero(PRFCount, 1);// 图像到脉冲矩阵 prf*1 - Eigen::MatrixXcd term_R = Eigen::MatrixXcd::Zero(1, frepoints); - Eigen::MatrixXcd pluse_R = Eigen::MatrixXcd::Zero(PRFCount, 1); - - for (size_t jj = 0; jj < image_width; jj++) { - im_R.col(0) = ((antPos.col(0).array() - X(ii, jj)).array().pow(2) + - (antPos.col(1).array() - Y(ii, jj)).array().pow(2) + - (antPos.col(2).array() - Z(ii, jj)).array().pow(2)) - .array().sqrt().array(); // 获取目标到天线矩阵 计算 ok - // im_R PRF_count x 1 - for (size_t tt = 0; tt < PRFCount; tt++) { - term_R = (im_R(tt, 0) * factorj.array()).array().exp(); // ok - pluse_R(tt, 0) = (echoData.row(tt).array() * term_R.array()).sum(); // 对每个脉冲校正求和 - } - im_final(ii, jj) = pluse_R.array().sum(); // 计算图像 - } - } -#else - - Eigen::MatrixXd im_R = Eigen::MatrixXd::Zero(PRFCount, 1);// 图像到脉冲矩阵 prf*1 - Eigen::MatrixXcd term_R = Eigen::MatrixXcd::Zero(1, frepoints); - Eigen::MatrixXcd pluse_R = Eigen::MatrixXcd::Zero(PRFCount, 1); - for (long ii = 0; ii < image_height; ii++) - { - for (size_t jj = 0; jj < image_width; jj++) { - im_R.col(0) = ((antPos.col(0).array() - X(ii, jj)).array().pow(2) + - (antPos.col(1).array() - Y(ii, jj)).array().pow(2) + - (antPos.col(2).array() - Z(ii, jj)).array().pow(2)) - .array().sqrt().array(); // 获取目标到天线矩阵 计算 ok - // im_R PRF_count x 1 - for (size_t tt = 0; tt < PRFCount; tt++) { - term_R = (im_R(tt, 0) * factorj.array()).array().exp(); // ok - pluse_R(tt, 0) = (echoData.row(tt).array() * term_R.array()).sum(); // 对每个脉冲校正求和 - } - im_final(ii, jj) = pluse_R.array().sum(); // 计算图像 - } -#ifdef __SHOWPROCESS - progressDialog.setValue(ii); -#endif - } -#endif - -#ifdef __SHOWIMAGEPROCESSRESULT // 加窗处理 - im_final = im_final.array() / (normw.array().sum()); - -#endif - - - // 3. 保存图像 - - - QString newrestiffpath = restiffpath; - - - Eigen::MatrixXd gt = Eigen::MatrixXd::Zero(2,3); - gt(0, 0) = X(0, 0); - gt(0, 1) = X(0, 1) - X(0, 0); - gt(0, 2) = 0; - gt(1, 0) = Y(0, 0); - gt(1, 1) = 0; - gt(1, 2) = Y(0, 0) - Y(1, 0); - std::cout << gt << std::endl; - gdalImageComplex im_final_gdal = CreategdalImageComplex(restiffpath,im_final.rows(),im_final.cols(),1,gt, QString(u8""), true,true); - im_final_gdal.setData(im_final); - im_final_gdal.saveImage(); - - qDebug() << QString(u8"保存文件地址:" + restiffpath); -#ifdef __SHOWPROCESS - progressDialog.setWindowTitle(u8"保存文件:" + restiffpath); - progressDialog.setValue(image_height); - progressDialog.close(); -#endif - - // 绘制图像 -#ifdef __SHOWIMAGEPROCESSRESULT - // 将复数矩阵的幅度转换为实数矩阵 - matplot::figure(); - matplot::vector_2d amplitude_im_final(im_final.rows(), matplot::vector_1d(im_final.cols())); - for (int i = 0; i < im_final.rows(); ++i) { - for (int j = 0; j < im_final.cols(); ++j) { - amplitude_im_final[i][j] = std::abs(im_final(i, j)); - } - } - matplot::imagesc(amplitude_im_final); - matplot::colorbar(); - matplot::show(); -#endif // __SHOWMATPLOTLIBCPP - - return true; -} - - - diff --git a/src/LAMPTool/SARImage/FEKOBaseToolClass.h b/src/LAMPTool/SARImage/FEKOBaseToolClass.h deleted file mode 100644 index d83b734..0000000 --- a/src/LAMPTool/SARImage/FEKOBaseToolClass.h +++ /dev/null @@ -1,338 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "referenceHeader.h" -#include "BaseToollib/GeoOperator.h" - - -/** -* 此类用于FEKO的基本类型,主要功能如下: -* 1. 根据分辨率、中心频率、带宽,近远斜距,计算频率起始点,以及采样点数 -* 2. 根据起始成像点、成像时长、PRF采样点数,获取PRF采样点数 -* 3. 结合 PRF采样点坐标,入射角,以及与飞行方向的夹角(默认为 90度), 参考高程,计算入射波的参考平面部分 -* 4. -***/ - -namespace FEKOBase { - - //========================================================== - // FEKO常用坐标系 - //========================================================== - enum FEKOCoordinateSystem { - Spherical, // 球坐标系 - Cartesian, // 笛卡尔坐标系 - UNKONWFEKOCOORDINATESYSTEM // 必须为最后一个表示未知 - }; - FEKOBase::FEKOCoordinateSystem FEKOCoordinateSystemString2Enum(QString str); - QString QString2FEKOCoordinateSystem(FEKOBase::FEKOCoordinateSystem mode); - - - //========================================================== - // FEKO成像模式枚举 - //========================================================== - enum FEKOImageMode - { - Strip, - Scane, - ISAR, - CircleSAR, - UNKNOW - }; - - FEKOImageMode FEKOImageModeString2Enum(QString str); - QString FEKOImageModeenumToString(FEKOImageMode mode); - - - - - //========================================================== - // FEKO成像仿真参数类,主要用来搭建统一的仿真成像模块 - //========================================================== - - - - - //========================================================== - // 频率参数 - //========================================================== - struct freqParams { // 频率参数 - double startfreqs; - double endfreqs; - size_t freqpoint; - }; - - //========================================================== - // 输入的卫星参数 - //========================================================== - struct SatellitePosition { // 卫星姿态 - double Px = 0, Py = 0, Pz = 0; - }; - struct SatelliteVelocity { // 卫星速度 - double Vx = 0, Vy = 0, Vz = 0; - }; - - struct SatelliteState { // 卫星矢量 - SatellitePosition pos; - SatelliteVelocity vel; - }; - - - //========================================================== - // FEKO 远场等效源姿态参数 - //========================================================== - struct FEKOantPitionDirect { - double x = 0; - double y = 0; - double z = 0; - double theta = 0; - double phi = 0; - }; - - - //=========================================================== - // FEKO成像设置参数 - //=========================================================== - struct FEKOImageSettingParams { - double min_x = 0; - double max_x = 0; - double min_y = 0; - double max_y = 0; - double plane_z = 0; // 平面高程 - size_t ImageWidth = 0; - size_t ImageHeight = 0; - - }; - - - - //========================================================== - // FEKO参数文件等效参数 - //========================================================== - struct FEKOSatelliteParams { // FEKOPRF脉冲参数 - size_t PRFidx = 0; // PRF 脉冲计数 - SatelliteState pose;// 卫星矢量 - double incidenceAngle = 0; // 入射角 - double AzAngle = 0; // 姿态角 - FEKOantPitionDirect antpos;// 天线实际姿态 - bool isRight = false; // 判断左右视,false 左,right 右 - }; - - - ///////////////////////////////////////////////// - ///// 函数类 - ////////////////////////////////////////////// - /// - /// 频率Setting - /// - /// 中心频率 GHZ - /// 分辨率 米 - /// 带宽 GHz - /// 分辨率 米 - /// - /// - freqParams getFreqSetting(double centerFreq, double resolution, double bandWidth, double scenceRange, bool isResolution = false); - - FEKOSatelliteParams createFEKOSatelliteParams(double Px, double Py, double Pz, double Vx, double Vy, double Vz, double incidenceAngle, double AzAngle, double theta, double phi, bool isRight, size_t PRFIdx = 0); - FEKOSatelliteParams createFEKOSatelliteParams(SatelliteState pose, double incidenceAngle, double AzAngle, FEKOantPitionDirect antpos, size_t PRFIdx = 0); - - SatelliteState FEKOSatelliteParams2SatelliteState(FEKOSatelliteParams parmas); - FEKOantPitionDirect FEKOSatelliteParams2FEKOantPitionDirect(FEKOSatelliteParams parmas); - - /// - /// 将卫星姿态转换为 FEKO 天线坐标, - /// 注意默认模型的Z轴为天线的指向 - /// - /// 卫星矢量 - /// 入射角 - /// 侧视角 - /// 是否为右视 - /// 结果文件 - /// 输入模型 - /// - TopoDS_Shape SatellitePos2FEKOAntPos(SatelliteState satepos, double incidenceAngle, double AzAngle, bool isRIGHT, FEKOantPitionDirect* antposition_Direct, TopoDS_Shape inDs); - - - - //=============================================== - // FEKO结果解析文件 - //=============================================== - - struct ElectricFieldData { - QString fileType; - QString fileFormat; - QString source; - QString date; - double radius; - double theta; - double phi; - double reEr; - double imEr; - double reEtheta; - double imEtheta; - double reEphi; - double imEphi; - QString configurationName; - QString requestName; - double frequency; - QString coordinateSystem; - Point_3d origin; - int numRadiusSamples; - int numThetaSamples; - int numPhiSamples; - QString resultType; - int numHeaderLines; - size_t prfidx = -1; // 脉冲计数,>0 - }; - - struct PRFPluseData { // 单个PRF脉冲数据格式 - size_t prfidx; //脉冲次数 - double freqstart; - double freqend; - size_t freqpoints; - - double px, py, pz; - //double theta, phi; - //double incidence, azangle; - //std::vector freqlist; - std::vector electricFieldDataList; // 单频点信息 - }; - - bool compareElectricFieldDataInFreq(const ElectricFieldData& a, const ElectricFieldData& b); - bool comparePRFPluseDataInPRFIdx(const PRFPluseData& a, const PRFPluseData& b); - - class NearFieldEchoCSVParser { - public: - NearFieldEchoCSVParser(); - ~NearFieldEchoCSVParser(); - private: - bool usePRFCountMode = true; - //std::vector electricFieldDataList; - QMap> electricFieldDataList; // 电场数据 - //QMap prfPluseMap; - std::vector prfData; - size_t freqPoints; - double freqStart; - double freqEnd; - // 频率参数 - private: // 内部检查函数 - bool checkPRFModel(); - bool resizePRFPluse(); //回波整理 - - public: - bool parseCSV(const QString& filePath); // 读取回波数据文件 - void toThetapolar(const QString& filePath);// 输出theta 极化 - void toPhiPolar(const QString& filePath);// 输出phi 极化 - void toRPolar(const QString& filePath);// 输出phi 极化 - void saveCSV(const QString& filePath);// 输出csv文件 - private: - void toEchoData(const QString& filePath, size_t outDataName);// 输出回波数据 - }; - - - - - //======================================================================== - // 成像回波格式 - // file type: - // freqStart,freqEnd,freqPoint,isRight, - // PRF1,Pos,incidenceAngle,AzAngle,echoDatalist - // PRF2,Pos,incidenceAngle,AzAngle,echoDatalist - // 。 - // 。 - // 。 - // 注意Bp并不关心脉冲的顺序,只是关注脉冲的坐标位置,默认按照脉冲的解析顺序进行组织 - //======================================================================== - class EchoDataClass { - private: // 成像变量 - Eigen::MatrixXcd echoData; // 回波数据 - Eigen::MatrixXd antPos;// 每个脉冲的坐标 - double freqStart; // 起始频率 - double freqEnd; // 终止频率 - int freqpoints; // 频率点数 - - public: - EchoDataClass(const FEKOBase::EchoDataClass& inecho); - EchoDataClass(); - ~EchoDataClass(); - public: - // 根据每个成员变量构建属性 - void setEchoData(Eigen::MatrixXcd echoData); - Eigen::MatrixXcd getEchoData() const; - void setAntPos(Eigen::MatrixXd antPos); - Eigen::MatrixXd getAntPos() const; - void setFreqStart(double freqStart); - double getFreqStart() const; - void setFreqEnd(double freqEnd); - double getFreqEnd() const; - void setFreqpoints(int freqpoints); - int getFreqpoints() const; - - void loadEchoData(const QString& filePath); // 加载回波数据文件 - void SaveEchoData(const QString& filePath); // 保存回波数据文件 - }; - - - - - - //========================================================== - // 仿真成像算法类 - // BP成像算法 - // 建议将所有的频率处理到 GHz 单位,避免频率过大导致的精度问题 - // 回波矩阵: - // PRF1:f1,f2,f3,f4 - // PRF2:f1,f2,f3,f4 - // PRF2:f1,f2,f3,f4 - //========================================================== - - enum ImageAlgWindowFun // 成像方法加窗方法 - { - NOWINDOWS, - HANMMING, - UNKONWWINDOW - }; - - /// - /// 加窗 - /// - /// 行:脉冲,列:频点 - /// - Eigen::MatrixXd WINDOWFun(Eigen::MatrixXcd& echo, ImageAlgWindowFun winfun = ImageAlgWindowFun::HANMMING); - - enum FEKOImageAlgorithm - { - TBP_TIME, - TBP_FREQ, - UNKONW // 必须为最后一个表示未知 - }; - - QList getFEKOImageAlgorithmList(); - FEKOImageAlgorithm String2FEKOImageAlgorithm(QString str); - QString FEKOImageAlgorithm2String(FEKOImageAlgorithm alg); - - // 请仿照FEKOImageAlgorithm枚举的写法,构建QString 与 ImageAlgWindowFun 的转换函数 - QList getImageAlgWindowFunList(); - ImageAlgWindowFun String2ImageAlgWindowFun(QString str); - QString ImageAlgWindowFun2String(ImageAlgWindowFun alg); - - - bool BPImage_TIME(QString& restiffpath, Eigen::MatrixXcd& echoData, Eigen::MatrixXd& antPos, Eigen::MatrixXd& freqmatrix, Eigen::MatrixXd& X, Eigen::MatrixXd& Y, Eigen::MatrixXd& Z, ImageAlgWindowFun winfun = ImageAlgWindowFun::HANMMING); // BP成像 - bool FBPImage_FREQ(QString& restiffpath, Eigen::MatrixXcd& echoData, Eigen::MatrixXd& antPos, Eigen::MatrixXd& freqmatrix, Eigen::MatrixXd& X, Eigen::MatrixXd& Y, Eigen::MatrixXd& Z, ImageAlgWindowFun winfun = ImageAlgWindowFun::HANMMING); // FBP成像 - - - -} \ No newline at end of file diff --git a/src/LAMPTool/SARImage/FEKONearBPBasic.cpp b/src/LAMPTool/SARImage/FEKONearBPBasic.cpp deleted file mode 100644 index 1faa790..0000000 --- a/src/LAMPTool/SARImage/FEKONearBPBasic.cpp +++ /dev/null @@ -1,1028 +0,0 @@ -#include "FEKONearBPBasic.h" -#include "BaseToolLib/interpolation.h" -#include "BaseToollib/FileOperator.h" -#include "BaseToollib/BaseTool.h" -#include "BaseToollib/ImageOperatorBase.h" -#include "SARBaseToolLib/SARImageBase.h" -#include -#include -#include -#include -#include -#include - -#include "SARBaseToolLib/SARBaseTool.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - - -// 定义插值函数,以处理复数值 -std::complex InterpolateComplex(Eigen::MatrixXd& xi, Eigen::MatrixXd& yi, Eigen::MatrixXcd& data, double x, double y) { - int m = xi.rows(); - int n = xi.cols(); - - if (x < xi(0, 0) || x > xi(m - 1, n - 1) || y < yi(0, 0) || y > yi(m - 1, n - 1)) { - std::complex defaultMatrix = std::complex(0,0); // 超出范围时返回默认值 - return defaultMatrix; - } - - int i, j; - for (i = 0; i < m - 1; i++) { - if (x >= xi(i, 0) && x <= xi(i + 1, 0)) { - break; - } - } - - for (j = 0; j < n - 1; j++) { - if (y >= yi(0, j) && y <= yi(0, j + 1)) { - break; - } - } - - double x1 = xi(i, 0); - double x2 = xi(i + 1, 0); - double y1 = yi(0, j); - double y2 = yi(0, j + 1); - - std::complex Q11 = data(i, j); - std::complex Q12 = data(i, j + 1); - std::complex Q21 = data(i + 1, j); - std::complex Q22 = data(i + 1, j + 1); - - double dx1 = x2 - x; - double dx2 = x - x1; - double dy1 = y2 - y; - double dy2 = y - y1; - double denom = (x2 - x1) * (y2 - y1); - - std::complex interpolatedValue = (Q11 * dx1 * dy1 + Q21 * dx2 * dy1 + Q12 * dx1 * dy2 + Q22 * dx2 * dy2) / denom; - return interpolatedValue; -} - - -Eigen::MatrixXd Cartesian2Spherical(Eigen::MatrixXd CartesianPoint) -{ - Eigen::MatrixXd result = CartesianPoint; - size_t rows = result.rows(); - size_t cols = result.cols(); - for (int i = 0; i < rows; i++) { - double x = CartesianPoint(i, 0); - double y = CartesianPoint(i, 1); - double z = CartesianPoint(i, 2); - result(i, 0) = std::sqrt(CartesianPoint(i, 0) * CartesianPoint(i, 0) + - CartesianPoint(i, 1) * CartesianPoint(i, 1) + - CartesianPoint(i, 2) * CartesianPoint(i, 2)); - result(i, 1) = std::acos(CartesianPoint(i, 2) / result(i, 0));// 行 theta - if (CartesianPoint(i, 0) == 0 && CartesianPoint(i, 1) == 0) { - result(i, 2) = 0; - } - else { - result(i, 2) = std::asin(y / (std::sin(result(i, 1)) * result(i, 0)));//一 三 -pi/2 pi/2 - if (CartesianPoint(i, 0) < 0 && CartesianPoint(i, 1) > 0) { // 二 - result(i, 2) = PI - result(i, 2);// phi - } - else if (CartesianPoint(i, 0) < 0 && CartesianPoint(i, 1) < 0) { - result(i, 2) = -1 * PI - result(i, 2);// phi - } - else {} - } - } - - return result; -} - -int BP2DProcess(QString in_path, QString out_path, double Rref, double minX, double maxX, double minY, double maxY, double PlaneZ, int ImageHeight, int ImageWidth) -{ - BP2DProcessClass process; - process.initProcess(in_path, out_path, Rref, minX, maxX, minY, maxY, PlaneZ, ImageHeight, ImageWidth); - process.start(); - return -1; -} - - -int FBP2DProcess(QString in_path, QString out_path, double Rref, double minX, double maxX, double minY, double maxY, double PlaneZ, int ImageHeight, int ImageWidth) -{ - FBP2DProcessClass process; - process.initProcess(in_path, out_path, Rref, minX, maxX, minY, maxY, PlaneZ, ImageHeight, ImageWidth); - process.start(); - return -1; -} - -int build2Bin(QString path, int width, int height, std::vector& freqs, Eigen::MatrixXd AntPostion, Eigen::MatrixXcd echo) -{ - /* -* % 构建回波结果 -fid=fopen("H_echo.bin","w+"); -fwrite(fid,801,'int32'); -fwrite(fid,801,'int32'); -for i=1:length(freqs) - fwrite(fid,freqs(i),'double'); -end - -for i=1:length(AntPostion) - fwrite(fid,AntPostion(i,1),'double'); - fwrite(fid,AntPostion(i,2),'double'); - fwrite(fid,AntPostion(i,3),'double'); - fwrite(fid,real(echo_H_datas(i,:)),'double'); - fwrite(fid,imag(echo_H_datas(i,:)),'double'); -end -fclose(fid); -**/ -// 构建二进制文件 - - std::ofstream file(path.toUtf8().constData(), std::ios::binary); - double freq; - - file.write(reinterpret_cast(&height), sizeof(height)); - file.write(reinterpret_cast(&width), sizeof(width)); - - for (size_t i = 0; i < freqs.size(); i++) { - freq = freqs[i]; - file.write(reinterpret_cast(&freq), sizeof(freq)); - } - - double x, y, z; - double real_val, imag_val; - - for (size_t i = 0; i < AntPostion.rows(); i++) { - x = AntPostion(i, 0); - y = AntPostion(i, 1); - z = AntPostion(i, 2); - file.write(reinterpret_cast(&x), sizeof(x)); - file.write(reinterpret_cast(&y), sizeof(y)); - file.write(reinterpret_cast(&z), sizeof(z)); - for (size_t j = 0; j < echo.cols(); j++) { - real_val = std::real(echo(i, j)); - imag_val = std::imag(echo(i, j)); - file.write(reinterpret_cast(&real_val), sizeof(real_val)); - file.write(reinterpret_cast(&imag_val), sizeof(imag_val)); - } - } - - file.close(); - return 0; -} - -template -Eigen::MatrixXcd BP2DImageByPluse(Eigen::MatrixXcd timeEcho, Eigen::MatrixXd AntPosition, double minX, double maxX, double minY, double maxY, double PlaneZ, double Rref, size_t ImageWidth, size_t ImageHeight, double startfreq, size_t timefreqnum, double timeFreqBandWidth, T* logclss) -{ - bool logfun = !(nullptr == logclss); // 空指针 - double delta_x = (maxX - minX) / (ImageWidth - 1); - double delta_y = (maxY - minY) / (ImageHeight - 1); - - double* Rs = new double[timefreqnum]; // 时域 距离插值 - for (int i = 0; i < timefreqnum; i++) { - Rs[i] = (LIGHTSPEED / timeFreqBandWidth) * i; // 参考 《雷达成像算法》-- 匹配滤波一章 - } - double wave_len = LIGHTSPEED / startfreq; - if (logfun) { - logclss->logFUN(0, "process....."); - } - - size_t process = 0; - size_t PRFNUM = timeEcho.rows(); - Eigen::MatrixXcd img = Eigen::MatrixXcd::Zero(ImageHeight, ImageWidth); - - for (int i = 0; i < PRFNUM; i++) { - gsl_interp_accel* accopm = gsl_interp_accel_alloc(); - const gsl_interp_type* tt = gsl_interp_linear; //gsl_interp_cspline_periodic; - gsl_spline* spline_time_real = gsl_spline_alloc(tt, timefreqnum); - gsl_spline* spline_time_imag = gsl_spline_alloc(tt, timefreqnum); - - double* real_time_ys = new double[timefreqnum]; - double* imag_time_ys = new double[timefreqnum]; - for (int tt = 0; tt < timefreqnum; tt++) { - real_time_ys[tt] = timeEcho(i, tt).real(); - imag_time_ys[tt] = timeEcho(i, tt).imag(); - } - gsl_spline_init(spline_time_real, Rs, real_time_ys, timefreqnum); - gsl_spline_init(spline_time_imag, Rs, imag_time_ys, timefreqnum); - for (int ii = 0; ii < ImageHeight; ii++) { - for (int jj = 0; jj < ImageWidth; jj++) { - double px = ii * delta_x + minX; - double py = jj * delta_y + minY; - double pz = PlaneZ; - double dR = 0; - double R = std::sqrt( - std::pow(AntPosition(i, 0) - px, 2) + - std::pow(AntPosition(i, 1) - py, 2) + - std::pow(AntPosition(i, 2) - pz, 2) - ); - dR = R - Rref; - std::complex echo_temp( - gsl_spline_eval(spline_time_real, R, accopm),// 插值实部 - gsl_spline_eval(spline_time_imag, R, accopm)// 插值虚部 - ); - img(ii, jj) = img(ii, jj) + echo_temp * std::exp(std::complex(0, 2 * pi * dR / wave_len)); - } - } - gsl_spline_free(spline_time_real); - gsl_spline_free(spline_time_imag); - gsl_interp_accel_free(accopm); - // 保存文件 - process = process + 1; - if (logfun) { - logclss->logFUN((size_t)(process / PRFNUM * 100), "BP process over"); - } - } - if (logfun) { - logclss->logFUN(100, "BP process over"); - } - return img; -} - - -template -Eigen::MatrixXcd BP2DImageByPixel(Eigen::MatrixXcd timeEcho, Eigen::MatrixXd AntPosition, double minX, double maxX, double minY, double maxY, double PlaneZ, double Rref, size_t ImageWidth, size_t ImageHeight, double startfreq, size_t timefreqnum, double timeFreqBandWidth, T* logclss) -{ - bool logfun = !(nullptr == logclss); - double delta_x = (maxX - minX) / (ImageWidth - 1); - double delta_y = (maxY - minY) / (ImageHeight - 1); - double maxRange = delta_x * ImageWidth > delta_y * ImageHeight ? delta_x * ImageWidth : delta_y * ImageHeight; - double halfR = Rref * 0.1; - double maxRLs = std::sqrt(Rref * Rref + halfR * halfR) - Rref; - double minR = Rref - maxRange * 2 - maxRLs; // 最小斜距 - double maxR = Rref + maxRange * 2 + maxRLs; // 最大斜距 - - double dftime = timeFreqBandWidth / (timefreqnum - 1); - - // 后续需要增加距离窗的计算方法 - - - double dRs = (LIGHTSPEED / 2.0/timeFreqBandWidth); // 距离向分辨率 - double* Rs = new double[timefreqnum]; // 时域 距离插值 - for (int i = 0; i < timefreqnum; i++) { - Rs[i] = 2*dRs * i; // 参考 《雷达成像算法》-- 匹配滤波一章 - } - //double wave_len = LIGHTSPEED / startfreq; - if (logfun) { - logclss->logFUN(0, "process....."); - } - - - size_t process = 0; - size_t PRFNUM = timeEcho.rows(); - - Eigen::MatrixXcd img = Eigen::MatrixXcd::Zero(ImageHeight, ImageWidth); - omp_lock_t lock; - omp_init_lock(&lock); // 初始化互斥锁 - size_t parallel_step = 100; - - -#pragma omp parallel for // NEW ADD - for (int ii = 0; ii < ImageHeight; ii = ii + parallel_step) { - size_t start_i = ii; - size_t max_i = ii + parallel_step; - max_i = max_i < ImageHeight ? max_i : ImageHeight; - - - double px; - double py ; - double pz; - std::complex echo_sum(0, 0); - double R = 0; - double dR = 0; - - - // 估算坐标的夹角,估算双线性距离 - Eigen::MatrixXd Rline(PRFNUM, 2); - Point_3d Vpluse_p; - Point_3d Vs_e; - double Rline_ref ; - double offer_Rline; - - Eigen::MatrixX> echoline; - double real, imag; - std::complex echo_temp; - std::complex echo_phase(0, 0); - std::complex last_value; - std::complex next_value; - size_t last_ids; - size_t next_ids; - double index = 0; - - Vector3D p; - Vector3D lineP; - Vector3D lineDirection; - double DopplerFreq; - double wave_len; - - - for (int i = start_i; i < max_i; i++) - { - for (int j = 0; j < ImageWidth; j++) { - px = i * delta_x + minX; - py = j * delta_y + minY; - pz = PlaneZ; - echo_sum.real(0); - echo_sum.imag(0); - R = 0; - dR = 0; - - - for (int mm = 0; mm < PRFNUM; mm++) { // 计算每个脉冲情况 - Rline(mm, 0) = std::sqrt( - std::pow(AntPosition(mm, 0) - px, 2) + - std::pow(AntPosition(mm, 1) - py, 2) + - std::pow(AntPosition(mm, 2) - pz, 2) - ); - - // 计算夹角 - Vpluse_p.x = px - AntPosition(mm, 0); - Vpluse_p.y = py - AntPosition(mm, 1); - Vpluse_p.z = pz - AntPosition(mm, 2); - if (mm == 0) { - Vs_e.x = AntPosition(mm + 1, 0) - AntPosition(mm, 0); - Vs_e.y = AntPosition(mm + 1, 1) - AntPosition(mm, 1); - Vs_e.z = AntPosition(mm + 1, 2) - AntPosition(mm, 2); - } - else { - Vs_e.x = AntPosition(mm, 0) - AntPosition(mm - 1, 0); - Vs_e.y = AntPosition(mm, 1) - AntPosition(mm - 1, 1); - Vs_e.z = AntPosition(mm, 2) - AntPosition(mm - 1, 2); - } - - Rline(mm, 1) = Vpluse_p.x * Vs_e.x + Vpluse_p.y * Vs_e.y + Vpluse_p.z * Vs_e.z; // cos(90)=0 - } - Rline_ref = Rref; - // 查找最小值,获取 0多普勒条件下的 最短参考路径 - for (int mm = 0; mm < PRFNUM - 1; mm++) { - if (Rline(mm, 0) == 0) { // 求解最小值 - Rline_ref = Rline(mm, 0); - break; - } - else { - double flag = Rline(mm, 1) * Rline(mm + 1, 1); - if (flag < 0) { // 不同号 - // 求解目标点到 当前直线的最短距离 - p.x = px; - p.y = py; - p.z = pz; - lineP.x = AntPosition(mm, 0); - lineP.y = AntPosition(mm, 1); - lineP.z = AntPosition(mm, 2); - lineDirection.x = AntPosition(mm + 1, 0) - AntPosition(mm, 0); - lineDirection.y = AntPosition(mm + 1, 1) - AntPosition(mm, 1); - lineDirection.z = AntPosition(mm + 1, 2) - AntPosition(mm, 2); - - Rline_ref = pointToLineDistance(p, lineP, lineDirection); - break; - } - } - } - - offer_Rline = Rline_ref - Rref; // 计算偏移线 - Rline = Rline.array() + offer_Rline; - - for (int mm = 0; mm < PRFNUM; mm++) { - R= Rline(mm, 0); // 已经校正了距离徙动线 - - //if (R maxR) { // 距离窗 - // continue; - //} - dR = R - Rref; - // 插值计算 - index = R / 2 / dRs; - last_ids = size_t(std::floor(index)); - next_ids = size_t(std::ceil(index)); - - last_value = timeEcho(mm, last_ids); - next_value = timeEcho(mm, next_ids); - - // 实部,虚部同时插值 - real = last_value.real() + ((next_value.real() - last_value.real()) / (next_ids - last_ids)) * (index - last_ids); - imag = last_value.imag() + ((next_value.imag() - last_value.imag()) / (next_ids - last_ids)) * (index - last_ids); - echo_temp.real(real); - echo_temp.imag(imag); - - DopplerFreq =std::sqrt(R*R - Rline_ref* Rline_ref) / Rline_ref * startfreq; - wave_len = std::abs(LIGHTSPEED / DopplerFreq); - echo_phase.imag(-2 * pi * dR / wave_len); - echo_sum = echo_sum + echo_temp;// *std::exp(echo_phase); - } - img(i, j) = echo_sum; - } - // 保存文件 - - } - omp_set_lock(&lock); - process = process + parallel_step; - process = process < ImageHeight ? process : ImageHeight; - if (logfun) { - logclss->logFUN(size_t(std::round(process * 1.0 / ImageHeight * 100)), "BP process over"); - } - omp_unset_lock(&lock); - } - omp_destroy_lock(&lock); //销毁互斥器 - if (logfun) { - logclss->logFUN(100, "BP process over"); - } - return img; -} - - -int BP2DProcessClass::initProcess(QString in_path, QString out_path, double Rref, double minX, double maxX, double minY, double maxY, double PlaneZ, int ImageHeight, int ImageWidth) -{ - // 初始化参数 - this->readEchoFile(in_path); - this->out_path = out_path; - this->Rref = Rref; // 成像中心的参考距离 - this->minX = minX; - this->maxX = maxX; - this->minY = minY; - this->maxY = maxY; - this->Zplane = PlaneZ; - this->ImageHeight = ImageHeight; - this->ImageWidth = ImageWidth; - // 计算坐标的到成像中心的坐标 - this->centerX = (this->maxX + this->minX) / 2; - this->centerY = (this->minY + this->maxY) / 2; - this->AntPosition.col(0) = this->AntPosition.col(0).array() - this->centerX; - this->AntPosition.col(1) = this->AntPosition.col(1).array() - this->centerY; - this->AntPosition.col(2) = this->AntPosition.col(2).array() - this->Zplane; - // 计算频率相关信息 - this->f1 = this->Frequencylist(0); - this->freqnum = this->Frequencylist.rows(); - this->fc = (this->f1 + this->Frequencylist(this->freqnum - 1)); - return -1; -} - -int BP2DProcessClass::readEchoFile(QString in_path) -{ - std::ifstream fin(in_path.toUtf8().constData(), std::ios::in | std::ios::binary); - if (!fin.is_open()) exit(2); - // 读取参数 - int height = 0; - int width = 0; - fin.read((char*)&height, sizeof(int)); - fin.read((char*)&width, sizeof(int)); - this->height = height; - this->width = width; - //frequencylist[width*double] - double* freqs = new double[width]; - fin.read((char*)freqs, sizeof(double) * width); - this->Frequencylist = Eigen::VectorXd::Zero(width, 1); // 列向量 - for (int i = 0; i < width; i++) { - this->Frequencylist(i) = freqs[i]; - } - delete[] freqs; - freqs = nullptr; - - // 读取回波并解析脉冲天线位置 - this->AntPosition = Eigen::MatrixXd::Zero(height, 3); - this->echo = Eigen::MatrixXcd::Zero(height, width); - double tempvalue = 0; - for (int i = 0; i < height; i++) { - fin.read((char*)&tempvalue, sizeof(double)); this->AntPosition(i, 0) = tempvalue; //X - fin.read((char*)&tempvalue, sizeof(double)); this->AntPosition(i, 1) = tempvalue;//Y - fin.read((char*)&tempvalue, sizeof(double)); this->AntPosition(i, 2) = tempvalue;//Z - - // echo - for (int j = 0; j < width; j++) { - fin.read((char*)&tempvalue, sizeof(double)); // real - this->echo(i, j) = this->echo(i, j) + tempvalue; - } - //imag - for (int j = 0; j < width; j++) { - fin.read((char*)&tempvalue, sizeof(double)); // real - this->echo(i, j) = this->echo(i, j) + std::complex(0, tempvalue); - } - } - fin.close(); - return -1; -} - -int BP2DProcessClass::saveTiFF(Eigen::MatrixXcd m) -{ - return saveMatrixXcd2TiFF(m, this->out_path); -} - -/// -/// 成像工作流,注意存在大量的内存浪费,后期可以根据情况进行优化 -/// -/// -int BP2DProcessClass::start() -{ - // step 0 生成文件夹路径,为中间临时文件输出,构建临时环境,正式版需要注释相关代码 - QString parantPath = getParantFolderNameFromPath(this->out_path); - - - // step 1 插值频率域 -- FEKO 频率插值是均匀插值 - size_t Nf = this->freqnum; - size_t Nxa = this->AntPosition.rows(); - double df = this->Frequencylist(1) - this->Frequencylist(0); // FEKO 的频率插值比较规整 - double startfreq = this->Frequencylist(0); // 起始频率 - - // 输出频域 图像(未处理前) 并将复数数据转换为 振幅 与 相位 ,行:方位向,列:距离向------------------- - QString before_path = JoinPath(parantPath, "freq_ampDB_angle_echo.tiff"); - WriteComplexData2AmpdB_Arg(before_path, this->echo);// 保存为频域回波 - this->logFUN(100, "Read Echo\n"); - // ---------------------------------------------------------------------------------------------- - - // ---------------------------------------------------------------------------------------------- - - this->logFUN(100, "hamming windows over"); - // ----------------- step2 傅里叶变换 (频域-->时域) ----------------------------------------- - Eigen::MatrixXcd echoTime = IFFTW1D(this->echo); - size_t timefreqnum = echoTime.cols(); - double timeFreqBandWidth = df * (timefreqnum - 1); - this->logFUN(100, "echo IFFT over"); - - // 输出频域 图像(加窗) 并将复数数据转换为 振幅 与 相位 ,行:方位向,列:距离向------------------- - QString time_echo_path = JoinPath(parantPath, "freq_ampDB_angle_echo_hanning_ifft.tiff"); - WriteComplexData2AmpdB_Arg(time_echo_path, echoTime);// 保存为频域回波 - this->logFUN(100, "after ifft ,in Time\n"); - // ---------------------------------------------------------------------------------------------- - // step 3 时域域加窗 - Nf = echoTime.cols(); - Eigen::MatrixXd wfxa = Hanning(Nf, Nxa, 0.54); // wfxa = hanning(Nf,Nxa,alpha=0.54) - double normw = wfxa.array().sum(); // normw = TOTAL(wfxa) - - Eigen::MatrixXcd dfrex = (echoTime.array())* (wfxa.array()); // dfrex = dfrex * wfxa - // 输出频域 图像(加窗) 并将复数数据转换为 振幅 与 相位 ,行:方位向,列:距离向------------------- - QString hanning_path = JoinPath(parantPath, "freq_ampDB_angle_echo_hanning.tiff"); - WriteComplexData2AmpdB_Arg(hanning_path, dfrex);// 保存为频域回波 - this->logFUN(100, "after hanning\n"); - echoTime = dfrex; - // ----------------- step4 TBP成像 (时域) ----------------------------------------------------------- - Eigen::MatrixXcd img = BP2DImageByPixel(echoTime, this->AntPosition, this->minX, this->maxX, this->minY, this->maxY, this->Zplane, this->Rref, this->ImageWidth, this->ImageHeight, startfreq, timefreqnum, timeFreqBandWidth, this); - this->logFUN(100, "echo bp over"); - - - - // 输出 最终结果图像 并将复数数据转换为 振幅 与 相位 ,行:方位向,列:距离向------------------- - QString FBP_resultDB_path = JoinPath(parantPath, "freq_ampDB_angle_echo_hanning_BP.tiff"); - WriteComplexData2AmpdB_Arg(FBP_resultDB_path, img);// 保存为频域回波 - // ---------------------------------------------------------------------------------------- - // 输出 最终结果图像 并将复数数据转换为 振幅 与 相位 ,行:方位向,列:距离向------------------- - QString FBP_result_path = JoinPath(parantPath, "freq_amp_angle_echo_hanning_BP.tiff"); - WriteComplexData2Amp_Arg(FBP_result_path, img);// 保存为频域回波 - // ---------------------------------------------------------------------------------------- - - this->saveTiFF(img); - this->logFUN(100, "out bpimag over : " + this->out_path); - return -1; -} - -int BP2DProcessClass::logFUN(int percent, QString logtext) { - qDebug() << "\rBPProcess [" << percent << "%]\t" << logtext; - if (percent < 100) { - qDebug()<<"\n"; - } - return 0; -}; - - - - - - -//////////////////////////////////////////////////////////////////////////////////////// -/// -/// FBP成像工作流(频域),参考 bp_linear_2d -/// Juan M Lopez-Sanchez, University of Alicante -/// -/// -//////////////////////////////////////////////////////////////////////////////////////// - - - - - - - - - - - - - - - - -int FBP2DProcessClass::initProcess(QString in_path, QString out_path, double Rref, double minX, double maxX, double minY, double maxY, double PlaneZ, int ImageHeight, int ImageWidth) -{ - // 初始化参数 - this->readEchoFile(in_path); - this->out_path = out_path; - this->Rref = Rref; // 成像中心的参考距离 - this->minX = minX; - this->maxX = maxX; - this->minY = minY; - this->maxY = maxY; - this->Zplane = PlaneZ; - this->ImageHeight = ImageHeight; - this->ImageWidth = ImageWidth; - // 计算坐标的到成像中心的坐标 - this->centerX = (this->maxX + this->minX) / 2; - this->centerY = (this->minY + this->maxY) / 2; - this->AntPosition.col(0) = this->AntPosition.col(0).array() - this->centerX; - this->AntPosition.col(1) = this->AntPosition.col(1).array() - this->centerY; - this->AntPosition.col(2) = this->AntPosition.col(2).array() - this->Zplane; - // 计算频率相关信息 - this->f1 = this->Frequencylist(0); - this->freqnum = this->Frequencylist.rows(); - this->fc = (this->f1 + this->Frequencylist(this->freqnum - 1)); - return -1; -} - -int FBP2DProcessClass::readEchoFile(QString in_path) -{ - std::ifstream fin(in_path.toUtf8().constData(), std::ios::in | std::ios::binary); - if (!fin.is_open()) exit(2); - // 读取参数 - int height = 0; - int width = 0; - fin.read((char*)&height, sizeof(int)); - fin.read((char*)&width, sizeof(int)); - this->height = height; - this->width = width; - //frequencylist[width*double] - double* freqs = new double[width]; - fin.read((char*)freqs, sizeof(double) * width); - this->Frequencylist = Eigen::VectorXd::Zero(width, 1); // 列向量 - for (int i = 0; i < width; i++) { - this->Frequencylist(i) = freqs[i]; - } - delete[] freqs; - freqs = nullptr; - - // 读取回波并解析脉冲天线位置 - this->AntPosition = Eigen::MatrixXd::Zero(height, 3); - this->echo = Eigen::MatrixXcd::Zero(height, width); - double tempvalue = 0; - for (int i = 0; i < height; i++) { - fin.read((char*)&tempvalue, sizeof(double)); this->AntPosition(i, 0) = tempvalue; //X - fin.read((char*)&tempvalue, sizeof(double)); this->AntPosition(i, 1) = tempvalue;//Y - fin.read((char*)&tempvalue, sizeof(double)); this->AntPosition(i, 2) = tempvalue;//Z - - // echo - for (int j = 0; j < width; j++) { - fin.read((char*)&tempvalue, sizeof(double)); // real - this->echo(i, j) = this->echo(i, j) + tempvalue; - } - //imag - for (int j = 0; j < width; j++) { - fin.read((char*)&tempvalue, sizeof(double)); // real - this->echo(i, j) = this->echo(i, j) + std::complex(0, tempvalue); - } - } - fin.close(); - return -1; -} - -int FBP2DProcessClass::saveTiFF(Eigen::MatrixXcd m) -{ - return saveMatrixXcd2TiFF(m, this->out_path); -} - - - - - - - - - - - - - - - - - -/// -/// FBP成像工作流(频域),参考 bp_linear_2d -/// Juan M Lopez-Sanchez, University of Alicante -/// -/// -int FBP2DProcessClass::start() -{ - // step 0 生成文件夹路径,为中间临时文件输出,构建临时环境,正式版需要注释相关代码 - QString parantPath = getParantFolderNameFromPath(this->out_path); - - - // step 1 插值频率域 -- FEKO 频率插值是均匀插值 - size_t Nf = this->freqnum; - size_t Nxa = this->AntPosition.rows(); - // 输出频域 图像(未处理前) 并将复数数据转换为 振幅 与 相位 ,行:方位向,列:距离向------------------- - QString before_path = JoinPath(parantPath, "freq_ampDB_angle_echo.tiff"); - WriteComplexData2AmpdB_Arg(before_path, this->echo);// 保存为频域回波 - this->logFUN(100, "Read Echo\n"); - // ---------------------------------------------------------------------------------------------- - // step 2 频率域加窗 - Eigen::MatrixXd wfxa = Hanning(Nf, Nxa, 0.54); // wfxa = hanning(Nf,Nxa,alpha=0.54) - double normw = wfxa.array().sum(); // normw = TOTAL(wfxa) - - Eigen::MatrixXcd dfrex = (this->echo.array()) * (wfxa.array()); // dfrex = dfrex * wfxa - // 输出频域 图像(加窗) 并将复数数据转换为 振幅 与 相位 ,行:方位向,列:距离向------------------- - QString hanning_path = JoinPath(parantPath, "freq_ampDB_angle_echo_hanning.tiff"); - WriteComplexData2AmpdB_Arg(hanning_path, dfrex);// 保存为频域回波 - this->logFUN(100, "after hanning\n"); - // ---------------------------------------------------------------------------------------------- - // step 3 Freq Backprojection algorithm - Eigen::MatrixXcd result_image = Eigen::MatrixXcd::Zero(this->ImageHeight, this->ImageWidth); // 构建网格,每个网格坐标根据中心点,平面点计算 - double dx = (this->maxX - this->minX) / (this->ImageWidth - 1); - double dy = (this->maxY - this->minY) / (this->ImageWidth - 1); - double px = 0, py = 0, pz = 0; // 像素坐标 - Eigen::MatrixXd Xdis = Eigen::MatrixXd::Zero(Nxa, Nf); - - // ; Nxa Nf - // mfre = fre # replicate(1, Nxa) ---- Nxa * Nf 复制每行 f1,f2,f3 ....... - // c = 0.2997925 ; Speed of light - // factorj = cj * (4.0*!PI/c) * mfre --- Nxa * Nf 复制每行 f1,f2,f3 ....... - // - - Eigen::MatrixXcd factorj = Eigen::MatrixXcd::Zero(Nxa, Nf); - for (size_t i = 0; i < Nxa; i++) { - for (size_t j = 0; j < Nf; j++) { - factorj(i, j) = std::complex(0, 4.0 * PI / (LIGHTSPEED * 1e-9)) * (this->Frequencylist(j) * 1e-9); // cj * (4.0*!PI/c) * mfre - } - } - - double R0 = this->Rref;// -- 参考斜距 - Eigen::MatrixXd R = Eigen::MatrixXd::Zero(Nxa, Nf); - Eigen::MatrixXd distR = Eigen::MatrixXd::Zero(Nxa, 1); - Eigen::MatrixXcd term = Eigen::MatrixXcd::Zero(Nxa, Nf); - Eigen::MatrixXcd data = Eigen::MatrixXcd::Zero(Nxa, Nf); - - for (size_t ix = 0; ix < this->ImageWidth; ix++) { - if (ix % 100 == 0) { - this->logFUN(size_t(ix * 1.0 / this->ImageWidth * 100), "FBP ....\n"); - } - // theta = theta / !radeg -- 根据入射角 计算 参考坐标 - // ya = Ro * sin(theta) -- 雷达 y 坐标 - // za = Ro * cos(theta) -- 雷达 z 坐标 - // - // xa_min = pos_start - // xa_max = pos_stop - // Nxa = Npos - // - // dxa = ( xa_max - xa_min ) / float(Nxa-1) - // xa = xa_min + findgen(Nxa) * dxa -- 雷达 x 坐标 - // - // dx = (x_max-x_min) / float(Nx-1) - // x = x_min + findgen(Nx) * dx - // - // dy = (y_max-y_min) / float(Ny-1) - // y = y_min + findgen(Ny) * dy - // mxa = replicate(1, Nf) # xa ;--- Nxa * Nf 每个列 ant_x1, ant_x2, ant_x3,...... - // xdis = (x[ix]-mxa)^2 + za^2 ;--- Nxa * Nf 每个列 ant_x1_z1,ant_x2_z2,ant_x3_z3,...... - // R = sqrt( xdis + (ya - y[iy])^2 ) ;--- Nxa * Nf 每个列 ant_x1, ant_x2, ant_x3,...... - // - px = ix * dx + this->minX; - pz = this->Zplane; - for (size_t iy = 0; iy < this->ImageHeight; iy++) { - py = iy * dy + this->minY; - - // mxa = replicate(1, Nf) # xa ;--- Nxa * Nf 每个列 ant_x1, ant_x2, ant_x3,...... - // xdis = (x[ix]-mxa)^2 + za^2 ;--- Nxa * Nf 每个列 ant_x1_z1,ant_x2_z2,ant_x3_z3,...... - // R = sqrt( xdis + (ya - y[iy])^2 ) ;--- Nxa * Nf 每个列 ant_x1, ant_x2, ant_x3,...... - // - - distR = ((this->AntPosition.col(0).array() - px).pow(2) + (this->AntPosition.col(1).array() - py).pow(2) + (this->AntPosition.col(2).array() - pz).pow(2)).array().sqrt().array(); // 复制 - - for (size_t jj = 0; jj < Nf; jj++) { // 逐列复制 - R.col(jj) = distR.array(); - } - // term = (R/Ro)^2 * exp( factorj * ( R - Ro ) ) ; Nxa x Nf - - term = (R.array() / R0).array().pow(2) * ((factorj.array() * (R.array() - R0)).array().exp()); - data = dfrex.array() * term.array(); - result_image(iy, ix) = data.array().sum(); - // 临时文件输出----------------------- - if (iy == this->ImageHeight / 2 && ix == this->ImageWidth / 2) { - // 输出 校正值 并将复数数据转换为 振幅 与 相位 ,行:方位向,列:距离向------------------- - QString FBP_termDB_path = JoinPath(parantPath, "freq_ampDB_angle_echo_hanning_term_FBP.tiff"); - WriteComplexData2AmpdB_Arg(FBP_termDB_path, term);// 保存为频域回波 - - // 输出 校正后图像 并将复数数据转换为 振幅 与 相位 ,行:方位向,列:距离向------------------- - QString FBP_dataDB_path = JoinPath(parantPath, "freq_ampDB_angle_echo_hanning_data_FBP.tiff"); - WriteComplexData2AmpdB_Arg(FBP_dataDB_path, data);// 保存为频域回波 - - // ---------------------------------------------------------------------------------------------- - } - - /***/ - } - } - result_image = result_image.array() / normw; - // 输出 最终结果图像 并将复数数据转换为 振幅 与 相位 ,行:方位向,列:距离向------------------- - QString FBP_resultDB_path = JoinPath(parantPath, "freq_ampDB_angle_echo_hanning_FBP.tiff"); - WriteComplexData2AmpdB_Arg(FBP_resultDB_path, result_image);// 保存为频域回波 - // ---------------------------------------------------------------------------------------------- - // 输出 最终结果图像 并将复数数据转换为 振幅 与 相位 ,行:方位向,列:距离向------------------- - QString FBP_result_path = JoinPath(parantPath, "freq_amp_angle_echo_hanning_FBP.tiff"); - WriteComplexData2Amp_Arg(FBP_result_path, result_image);// 保存为频域回波 - // ---------------------------------------------------------------------------------------------- - this->saveTiFF(result_image); - - return 0; -} - -int FBP2DProcessClass::logFUN(int percent, QString logtext) -{ - qDebug() << "\rFBPProcess [" << percent << "%]\t" << logtext; - if (percent < 100) { - qDebug() << "\n"; - } - return 0; -} - -int FEKOFarFieldProcessClass::initProcess(QString in_path, QString out_path, double Rref, double minX, double maxX, double minY, double maxY, double PlaneZ, int ImageHeight, int ImageWidth) -{ - // 初始化参数 - this->readEchoFile(in_path); - this->out_path = out_path; - this->Rref = Rref; // 成像中心的参考距离 - this->minX = minX; - this->maxX = maxX; - this->minY = minY; - this->maxY = maxY; - this->Zplane = PlaneZ; - this->ImageHeight = ImageHeight; - this->ImageWidth = ImageWidth; - // 计算坐标的到成像中心的坐标 - this->centerX = (this->maxX + this->minX) / 2; - this->centerY = (this->minY + this->maxY) / 2; - this->AntPosition.col(0) = this->AntPosition.col(0).array() - this->centerX; - this->AntPosition.col(1) = this->AntPosition.col(1).array() - this->centerY; - this->AntPosition.col(2) = this->AntPosition.col(2).array() - this->Zplane; - // 计算频率相关信息 - this->f1 = this->Frequencylist(0); - this->freqnum = this->Frequencylist.rows(); - this->fc = (this->f1 + this->Frequencylist(this->freqnum - 1)); - return -1; -} - -int FEKOFarFieldProcessClass::readEchoFile(QString in_path) -{ - std::ifstream fin(in_path.toUtf8().constData(), std::ios::in | std::ios::binary); - if (!fin.is_open()) exit(2); - // 读取参数 - int height = 0; - int width = 0; - fin.read((char*)&height, sizeof(int)); - fin.read((char*)&width, sizeof(int)); - this->height = height; - this->width = width; - //frequencylist[width*double] - double* freqs = new double[width]; - fin.read((char*)freqs, sizeof(double) * width); - this->Frequencylist = Eigen::VectorXd::Zero(width, 1); // 列向量 - for (int i = 0; i < width; i++) { - this->Frequencylist(i) = freqs[i]; - } - delete[] freqs; - freqs = nullptr; - - // 读取回波并解析脉冲天线位置 - this->AntPosition = Eigen::MatrixXd::Zero(height, 3); - this->echo = Eigen::MatrixXcd::Zero(height, width); - double tempvalue = 0; - for (int i = 0; i < height; i++) { - fin.read((char*)&tempvalue, sizeof(double)); this->AntPosition(i, 0) = tempvalue; //X - fin.read((char*)&tempvalue, sizeof(double)); this->AntPosition(i, 1) = tempvalue;//Y - fin.read((char*)&tempvalue, sizeof(double)); this->AntPosition(i, 2) = tempvalue;//Z - - // echo - for (int j = 0; j < width; j++) { - fin.read((char*)&tempvalue, sizeof(double)); // real - this->echo(i, j) = this->echo(i, j) + tempvalue; - } - //imag - for (int j = 0; j < width; j++) { - fin.read((char*)&tempvalue, sizeof(double)); // real - this->echo(i, j) = this->echo(i, j) + std::complex(0, tempvalue); - } - } - fin.close(); - return -1; -} - -int FEKOFarFieldProcessClass::saveTiFF(Eigen::MatrixXcd m) -{ - return saveMatrixXcd2TiFF(m, this->out_path); -} - -int FEKOFarFieldProcessClass::start() -{ - - //// step 0 生成文件夹路径,为中间临时文件输出,构建临时环境,正式版需要注释相关代码 - //QString parantPath = getParantFolderNameFromPath(this->out_path); - - - //double freqbandWidth = this->Frequencylist(this->get_Nf() - 1) - this->Frequencylist(0); - //double dx = LIGHTSPEED / 2.0 / std::abs(freqbandWidth); // 距离向分辨率 - //double startPhiAngle = this->AntPosition(0, 1); - //double endPhiAngle = this->AntPosition(this->get_Nxa(), 1); - //double AzAngleWidth = std::abs(endPhiAngle - startPhiAngle); - //double halfAzAngleWidth = AzAngleWidth / 2.0; - //double AzBandWidth = 2 * std::tan(Degrees2Radians(halfAzAngleWidth)) * this->get_minFreq(); - //double dy = LIGHTSPEED / 2.0 / std::abs(AzBandWidth); // 方位向分辨率 - - - - //// step 1 插值频率域 -- FEKO 频率插值是均匀插值 - //size_t Nf = this->freqnum; - //size_t Nxa = this->AntPosition.rows(); - - - - //double angStart = startPhiAngle; - //double angEnd = endPhiAngle; - //double freqEnd = this->Frequencylist(this->get_Nf() - 1); - //double fxStart = this->Frequencylist(0); - //double fyStart = std::tan(-1 * std::abs(halfAzAngleWidth)) * fxStart; - //double fyEnd = std::tan(-1 * std::abs(halfAzAngleWidth)) * fxStart; - //double fxEnd = std::sqrt(std::pow(freqEnd, 2) - std::pow(fyStart, 2)); - - //double freqSamples = this->Frequencylist.rows(); - //double angSamples = this->AntPosition.rows(); - - //double ysd = (fyEnd - fyStart) / (angSamples - 1); // 转换为 网格节点 - //double xsd = (fxEnd - fxStart) / (freqSamples - 1); // 转换为 网格节点 - - //Eigen::MatrixXd image_points_freq(angSamples, freqSamples); - //Eigen::MatrixXd image_points_ang(angSamples, freqSamples); - //Eigen::MatrixXcd Echo_data(angSamples, freqSamples); - - //Eigen::MatrixXd xi(Nxa,Nf); - //Eigen::MatrixXd yi(Nxa, Nf); - - - //// 创建网格 - //for (int f = 0; f < freqSamples; f++) { - // for (int a = 0; a < angSamples; a++) { - // double x = fxStart + f * xsd; - // double y = fyStart + a * ysd; - // image_points_freq(a, f) = std::sqrt(x * x + y * y); // 获取每个点的 频率 - // image_points_ang(a, f) = std::atan2(y, x); // 获取每个点的 角度坐标 - // Echo_data(a, f) = InterpolateComplex(xi, yi, this->echo, image_points_freq(a, f), image_points_ang(a, f)); // 插值得到区域数据 - - // } - //} - // - //// step 2 频率域加窗 - //Eigen::MatrixXd wfxa = Hanning(Nf, Nxa, 0.54); // wfxa = hanning(Nf,Nxa,alpha=0.54) - //double normw = wfxa.array().sum(); // normw = TOTAL(wfxa) - - //Eigen::MatrixXcd dfrex = (this->echo.array()) * (wfxa.array()); // dfrex = dfrex * wfxa - //// 输出频域 图像(加窗) 并将复数数据转换为 振幅 与 相位 ,行:方位向,列:距离向------------------- - //QString hanning_path = JoinPath(parantPath, "freq_ampDB_angle_echo_hanning.tiff"); - //WriteComplexData2AmpdB_Arg(hanning_path, dfrex);// 保存为频域回波 - //this->logFUN(100, "after hanning\n"); - - //Echo_data = dfrex; - - // - //// 执行二维傅立叶变换 - //Eigen::MatrixXcd H_echo_win_fft = FFTW2D(Echo_data); - - //// 获取矩阵的行数和列数 - //int n_freq = Echo_data.rows(); - //int n_angle = Echo_data.cols(); - - //// 将傅立叶变换结果归一化 - //H_echo_win_fft = H_echo_win_fft.array()/(n_freq * n_angle); - - //// 执行逆傅立叶变换(如果需要) - //// MatrixXcd H_echo_win_ifft = ifft2(H_echo_win_fft); - //// H_echo_win_ifft /= (n_freq * n_angle); - - //// 执行平移 - //Eigen::MatrixXcd result_image = fftshift(H_echo_win_fft); - - - //// 输出 最终结果图像 并将复数数据转换为 振幅 与 相位 ,行:方位向,列:距离向------------------- - //QString FBP_resultDB_path = JoinPath(parantPath, "freq_ampDB_angle_echo_hanning_FBP.tiff"); - //WriteComplexData2AmpdB_Arg(FBP_resultDB_path, result_image);// 保存为频域回波 - //// ---------------------------------------------------------------------------------------------- - //// 输出 最终结果图像 并将复数数据转换为 振幅 与 相位 ,行:方位向,列:距离向------------------- - //QString FBP_result_path = JoinPath(parantPath, "freq_amp_angle_echo_hanning_FBP.tiff"); - //WriteComplexData2Amp_Arg(FBP_result_path, result_image);// 保存为频域回波 - //// ---------------------------------------------------------------------------------------------- - //this->saveTiFF(result_image); - - - return 0; -} - -int FEKOFarFieldProcessClass::logFUN(int percent, QString logtext) -{ - qDebug() << "\rFBPProcess [" << percent << "%]\t" << logtext; - if (percent < 100) { - qDebug() << "\n"; - } - return 0; -} diff --git a/src/LAMPTool/SARImage/FEKONearBPBasic.h b/src/LAMPTool/SARImage/FEKONearBPBasic.h deleted file mode 100644 index b0edd6f..0000000 --- a/src/LAMPTool/SARImage/FEKONearBPBasic.h +++ /dev/null @@ -1,157 +0,0 @@ -#pragma once -/** -* 适用于FEKO的近场结果的 BP 成像算法 -* -**/ -#include -#include -#include -#include -#include -#include -#include -#include "referenceHeader.h" - - - -// FEKO 几何关系处理 - -/// -/// 笛卡尔坐标系,转换为 极坐标系 -/// -/// [X,Y,Z;X1,Y1,Z1] -/// -Eigen::MatrixXd Cartesian2Spherical(Eigen::MatrixXd CartesianPoint); - -/// -/// 时域BP -/// -class BP2DProcessClass { -public: - size_t height; - size_t width; - Eigen::MatrixXcd echo; - Eigen::MatrixXd AntPosition; - Eigen::VectorXd Frequencylist; - size_t freqnum; - double f1; - double fc; - double Rref; // 成像中心的参考距离 - double minX; - double maxX; - double minY; - double maxY; - double centerX; - double centerY; - double Zplane; - size_t ImageHeight; - size_t ImageWidth; - QString out_path; -public: - virtual int initProcess(QString in_path, QString out_path, double Rref, double minX, double maxX, double minY, double maxY, double PlaneZ, int ImageHeight, int ImageWidth); - virtual int readEchoFile(QString in_path); - virtual int saveTiFF(Eigen::MatrixXcd m); - virtual int start(); - virtual int logFUN(int percent, QString logtext); -}; - - -int BP2DProcess(QString in_path, QString out_path, double Rref, double minX, double maxX, double minY, double maxY, double PlaneZ,int ImageHeight,int ImageWidth); -// BP 成像时,逐像素点计算,计算速度慢,回波(PRFNUM,freqNUM) -template -Eigen::MatrixXcd BP2DImageByPixel(Eigen::MatrixXcd timeEcho,Eigen::MatrixXd AntPosition,double minX,double maxX,double minY,double maxY,double PlaneZ ,double Rref,size_t ImageWidth,size_t ImageHeight,double startfreq,size_t timefreqnum,double timeFreqBandWidth, T* logclss=nullptr); - -/// -/// 时域BP --- FBP -/// -class FBP2DProcessClass:public BP2DProcessClass { -public: - size_t height; - size_t width; - Eigen::MatrixXcd echo; - Eigen::MatrixXd AntPosition; - Eigen::VectorXd Frequencylist; - size_t freqnum; - double f1; - double fc; - double Rref; // 成像中心的参考距离 - double minX; - double maxX; - double minY; - double maxY; - double centerX; - double centerY; - double Zplane; - size_t ImageHeight; - size_t ImageWidth; - QString out_path; -public: - virtual int initProcess(QString in_path, QString out_path, double Rref, double minX, double maxX, double minY, double maxY, double PlaneZ, int ImageHeight, int ImageWidth); - virtual int readEchoFile(QString in_path); - virtual int saveTiFF(Eigen::MatrixXcd m); - virtual int start(); - virtual int logFUN(int percent, QString logtext); -}; - -// BP 成像时,逐脉冲计算,回波(PRFNUM,freqNUM) -template -Eigen::MatrixXcd BP2DImageByPluse(Eigen::MatrixXcd timeEcho, Eigen::MatrixXd AntPosition, double minX, double maxX, double minY, double maxY, double PlaneZ, double Rref, size_t ImageWidth, size_t ImageHeight, double startfreq, size_t timefreqnum, double timeFreqBandWidth, T* logclss = nullptr); - -int FBP2DProcess(QString in_path, QString out_path, double Rref, double minX, double maxX, double minY, double maxY, double PlaneZ, int ImageHeight, int ImageWidth); - -// 生成成像的数据文件 -int build2Bin(QString path,int width,int height,std::vector &freqs,Eigen::MatrixXd AntPositions,Eigen::MatrixXcd echo); - - -// 定义插值函数,以处理复数值 -std::complex InterpolateComplex(Eigen::MatrixXd& xi, Eigen::MatrixXd& yi, Eigen::MatrixXcd& data, double x, double y); - - - -/// -/// 远场成像 -/// -class FEKOFarFieldProcessClass :public BP2DProcessClass { -public: - size_t height; - size_t width; - Eigen::MatrixXcd echo; - Eigen::MatrixXd AntPosition; // theta phi 0 - Eigen::VectorXd Frequencylist; - size_t freqnum; - double f1; - double fc; - double Rref; // 成像中心的参考距离 - double minX; - double maxX; - double minY; - double maxY; - double centerX; - double centerY; - double Zplane; - size_t ImageHeight; - size_t ImageWidth; - QString out_path; -public: - virtual int initProcess(QString in_path, QString out_path, double Rref, double minX, double maxX, double minY, double maxY, double PlaneZ, int ImageHeight, int ImageWidth); - virtual int readEchoFile(QString in_path); - virtual int saveTiFF(Eigen::MatrixXcd m); - virtual int start(); - virtual int logFUN(int percent, QString logtext); - - // 平均频率间隔 - double get_df() { return (this->Frequencylist(this->get_Nf() - 1) - this->Frequencylist(0)) / (this->get_Nf() - 1); }; - // 脉冲数 - size_t get_Nxa() { return this->AntPosition.rows(); }; - // 频率点数 - size_t get_Nf() { return this->Frequencylist.rows(); }; - double get_minFreq() { this->Frequencylist(this->get_Nf() - 1) > this->Frequencylist(0) ? this->Frequencylist(0) : this->Frequencylist(this->get_Nf() - 1); }; - -}; - - - - - - - diff --git a/src/LAMPTool/SARImage/FEKONearBpBaseImage.cpp b/src/LAMPTool/SARImage/FEKONearBpBaseImage.cpp deleted file mode 100644 index 8df66d0..0000000 --- a/src/LAMPTool/SARImage/FEKONearBpBaseImage.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// FEKONearBpBaseImage.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 -// -#include "FEKONearBPBasic.h" -#include -#include -#include "LampToolTest.h" - -int TestImageBP_main(int argc, char* argv[]) -{ - qDebug() << "process starting .......\n"; - qDebug() << "-i in_echo.bin -o out_resule.bin -Rref 10 -minX -1 -maxX 1 -minY -1 -maxY 1 -PlaneZ 0 -ImageHeight 201 -ImageWidth 201" << "\n"; - qDebug() << "BP mehtod for FEKO Near field (Cartesian) " << "\n"; - qDebug() << "format: " << "\n"; - qDebug() << "height[int32] width[int32] frequencylist[width*double] echoData " << "\n"; - qDebug() << "echoData format: ant[x,y,z 3xdouble] real[width*double] imag[width*double]" << "\n"; - qDebug() << "echodata [freqNUM,PRF_num]" << "\n"; - qDebug() << "warnning:Eigen default matrix is row-major storage" << "\n"; - qDebug() << "===============params list==============================" << "\n"; - QString in_path = ""; - QString out_path = ""; - int mode = 1; - double Rref=0, minX=0, maxX = 0, minY = 0, maxY = 0, PlaneZ = 0, ImageHeight = 0, ImageWidth = 0; - for (int i = 0; i < argc; i++) { - qDebug() << argv[i] << "\n"; - } - for (int i = 0; i < argc; i++) { - if (strcmp(argv[i], "-i")==0) { - if (i == argc - 1) { return 1; } - in_path = argv[i + 1]; - qDebug() << argv[i] << " = " << argv[i + 1] << "\n"; - } - else if (strcmp(argv[i], "-o") == 0) { - if (i == argc - 1) { return 1; } - out_path = argv[i + 1]; - qDebug() << argv[i] << " = " << argv[i + 1] << "\n"; - } - else if (strcmp(argv[i], "-Rref") == 0) { - if (i == argc - 1) { return 1; } - Rref =std::stod(argv[i+1]); - qDebug() << argv[i] << " = " << argv[i + 1] << "\n"; - } - else if (strcmp(argv[i], "-minX") == 0) { - if (i == argc - 1) { return 1; } - minX = std::stod(argv[i + 1]); - qDebug() << argv[i] << " = " << argv[i + 1] << "\n"; - } - else if (strcmp(argv[i], "-maxX") == 0) { - if (i == argc - 1) { return 1; } - maxX = std::stod(argv[i + 1]); - qDebug() << argv[i] << " = " << argv[i + 1] << "\n"; - } - else if (strcmp(argv[i], "-minY") == 0) { - if (i == argc - 1) { return 1; } - minY = std::stod(argv[i + 1]); - qDebug() << argv[i] << " = " << argv[i + 1] << "\n"; - } - else if (strcmp(argv[i], "-maxY") == 0) { - if (i == argc - 1) { return 1; } - maxY = std::stod(argv[i + 1]); - qDebug() << argv[i] << " = " << argv[i + 1] << "\n"; - } - else if (strcmp(argv[i], "-PlaneZ") == 0) { - if (i == argc - 1) { return 1; } - PlaneZ = std::stod(argv[i + 1]); - qDebug() << argv[i] << " = " << argv[i + 1] << "\n"; - } - else if (strcmp(argv[i], "-ImageHeight") == 0) { - if (i == argc - 1) { return 1; } - ImageHeight = std::stod(argv[i + 1]); - qDebug() << argv[i] << " = " << argv[i + 1] << "\n"; - } - else if (strcmp(argv[i], "-ImageWidth")==0) { - if (i == argc - 1) { return 1; } - ImageWidth = std::stod(argv[i + 1]); - qDebug() << argv[i] << " = " << argv[i + 1] << "\n"; - } - else if (strcmp(argv[i], "-mode") == 0) { - if (i == argc - 1) { return 1; } - mode = std::stoi(argv[i + 1]); - qDebug() << argv[i] << " = " << argv[i + 1] << "\n"; - } - } - qDebug() << "======================================================" << "\n"; - //qDebug() << Eigen::MatrixXd::LinSpaced(1, 10).array() << "\n"; - if (mode == 0) { - //BP2DProcess(in_path, out_path, Rref, minX, maxX, minY, maxY, PlaneZ, ImageHeight, ImageWidth); - } - else if (mode == 1) { - //FBP2DProcess(in_path, out_path, Rref, minX, maxX, minY, maxY, PlaneZ, ImageHeight, ImageWidth); - } - else if (mode == 2) { - - } - - return 0; -} - - - - diff --git a/src/LAMPTool/main.cpp b/src/LAMPTool/main.cpp index 3761014..e0ce4cc 100644 --- a/src/LAMPTool/main.cpp +++ b/src/LAMPTool/main.cpp @@ -67,7 +67,7 @@ int main(int argc, char* argv[]) #ifdef __TEST_FARFIELDFILEREADPROCESS #include "LAMPTool.h" -#include "SARImage/FEKOBaseToolClass.h" +#include "FEKOBaseToolClass.h" #include "FEKOFarFieldFileClass.h" #include "FEKOSimulationSARClass.h" int main() { diff --git a/src/LAMPTool/readme.md b/src/LAMPTool/readme.md index 017b26e..671e01a 100644 --- a/src/LAMPTool/readme.md +++ b/src/LAMPTool/readme.md @@ -1,8 +1,2 @@ - - -# BaseToollib -基础操作库 - -# SARBaseToolLib -SAR处理操作库 - +# 说明 +此模块主要是通用基础模块 \ No newline at end of file diff --git a/src/LAMPTool/referenceHeader.h b/src/LAMPTool/referenceHeader.h index 4002830..e0a9586 100644 --- a/src/LAMPTool/referenceHeader.h +++ b/src/LAMPTool/referenceHeader.h @@ -9,27 +9,28 @@ #ifndef REFERENCEHEADER_H #define REFERENCEHEADER_H +#include "LAMPToolAPI.h" #include #include #include #include #include #include -#include -#include +#include +#include #include -#include -#include -#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -37,75 +38,75 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include -#include -#include -#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include #include -#include -#include +#include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include -#include -#include -#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -113,15 +114,15 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include // 并行计算库 #include @@ -130,7 +131,7 @@ //================================================ // 常用函数 //================================================ -std::vector convertQStringListToStdVector(const QStringList& qStringList); +std::vector LAMPTOOLAPI convertQStringListToStdVector(const QStringList& qStringList); diff --git a/src/MainWidgets/CMakeLists.txt b/src/MainWidgets/CMakeLists.txt index c17348b..45c7e56 100644 --- a/src/MainWidgets/CMakeLists.txt +++ b/src/MainWidgets/CMakeLists.txt @@ -31,6 +31,7 @@ add_library(MainWidgets ${_interface} ${_header} ${_source} + ) #----------------------------------------------------------------------------- @@ -38,7 +39,7 @@ add_library(MainWidgets #----------------------------------------------------------------------------- target_compile_definitions(MainWidgets PRIVATE "MAINWIDGETS_API") -list(APPEND _depend_library Common PythonModule Settings DataProperty MeshData Material Geometry ConfigOptions SelfDefObject ModelData ModuleBase PostInterface PostPlotWidget PostWidgets ProjectTree ProjectTreeExtend GeometryCommand GeometryWidgets IO SolverControl) +list(APPEND _depend_library Common PointCloudOperator PythonModule Settings DataProperty MeshData Material Geometry ConfigOptions SelfDefObject ModelData ModuleBase PostInterface PostPlotWidget PostWidgets ProjectTree ProjectTreeExtend GeometryCommand GeometryWidgets IO SolverControl) if(OpenMP_CXX_FOUND) list(APPEND _depend_library OpenMP::OpenMP_CXX) diff --git a/src/MainWidgets/DialogCreateSet.cpp b/src/MainWidgets/DialogCreateSet.cpp index b2d9682..77cd40d 100644 --- a/src/MainWidgets/DialogCreateSet.cpp +++ b/src/MainWidgets/DialogCreateSet.cpp @@ -28,7 +28,7 @@ namespace MainWidget _ui->ConplanarCheckBox->setCheckState(Qt::Unchecked); _ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("OK")); _ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel")); - connect(_ui->ConplanarCheckBox, SIGNAL(stateChanged(int)), this, SLOT(stateChangedSlot(int))); + connect(_ui->ConplanarCheckBox, SIGNAL(stateChanged(int)), this, SLOT(stateChangedSlot(int))); // 寻找共有点 connect(_ui->typeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(currentIndexChangedSlot(int))); connect(this, SIGNAL(updateSetTree()), _mainWindow, SIGNAL(updateSetTreeSig())); @@ -221,7 +221,7 @@ namespace MainWidget void CreateSetDialog::accept() { - if (_ui->ConplanarCheckBox->isChecked()) + if (_ui->ConplanarCheckBox->isChecked()) // 共有点复选框 findConplanarAccept(); else createSetAccept(); @@ -258,7 +258,7 @@ namespace MainWidget QDialog::reject(); return; } - if (_isGeo) + if (_isGeo) // OCCT 选择 { if (this->selectFromGeo()) QDialog::accept(); @@ -267,7 +267,7 @@ namespace MainWidget return; } - QMultiHash *selectItems = _preWindow->getSelectItems(); + QMultiHash *selectItems = _preWindow->getSelectItems(); // 选择 mesh if (selectItems == nullptr || selectItems->isEmpty()) { QMessageBox::warning(this, tr("Warning"), tr("No Node or Element selected !")); @@ -287,7 +287,7 @@ namespace MainWidget memList.append(s); } - QString idstring = memList.join(";"); + QString idstring = memList.join(";"); // id 节点列表 QString type = "Node"; if (_model == ModuleBase::MeshCell || _model == ModuleBase::BoxMeshCell) type = "Element"; diff --git a/src/MainWidgets/DialogCreateSet.h b/src/MainWidgets/DialogCreateSet.h index 7e87e34..612159c 100644 --- a/src/MainWidgets/DialogCreateSet.h +++ b/src/MainWidgets/DialogCreateSet.h @@ -58,10 +58,10 @@ namespace MainWidget Ui::CreateSetDialog *_ui{}; GUI::MainWindow *_mainWindow{}; PreWindow *_preWindow{}; - MeshData::MeshData *_meshData{}; + MeshData::MeshData *_meshData{}; // 选择的 vtk mesh 网格 - ModuleBase::SelectModel _model; - bool _isGeo{false}; + ModuleBase::SelectModel _model; // 选择的 OCCT 模型 + bool _isGeo{false}; // 处理OCCT 模型选择的 // vtkDataSet* _data; int _seedId{-1}; // QString _geoIds; diff --git a/src/MainWidgets/DialogPCLBilateralFilter.cpp b/src/MainWidgets/DialogPCLBilateralFilter.cpp new file mode 100644 index 0000000..7afa5ce --- /dev/null +++ b/src/MainWidgets/DialogPCLBilateralFilter.cpp @@ -0,0 +1,108 @@ +/** + * @file DialogPCLBilateralFilter.cpp + * @brief None + * @author 陈增辉 (3045316072@qq.com) + * @version 2.5.0 + * @date 2024/4/5 + * @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved. + */ + +// You may need to build the project (run Qt uic code generator) to get +// "ui_DialogPCLBilateralFilter.h" resolved + +#include "DialogPCLBilateralFilter.h" +#include "ui_DialogPCLBilateralFilter.h" + +#include "PythonModule/PyAgent.h" +#include "MeshData/meshSingleton.h" +#include "MeshData/meshSet.h" +#include +#include + + +//auto meshData = MeshData::MeshData::getInstance(); + +namespace MainWidget { + DialogPCLBilateralFilter::DialogPCLBilateralFilter(GUI::MainWindow *parent) + : QFDialog(parent), + _ui(new Ui::DialogPCLBilateralFilter), + _mw(parent), + _selectdlg(new DialogSelectComponents(parent)) + { + _ui->setupUi(this); + _ui->geoSelectPoint->setToolTip(tr("Clicked Button Selected Components")); + setWindowTitle(tr("Fast Bilateral Filter")); + _ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu); + + + connect(_ui->geoSelectPoint, &QPushButton::clicked, [=]() + { _selectdlg->clearSelectItems(); _selectdlg->exec(); }); + connect(_selectdlg, SIGNAL(selectedComponentsSig(QList)), this, SLOT(selectedComponentsSlot(QList))); + connect(_ui->listWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(customContextMenuRequestedSlot(const QPoint &))); + + } + + DialogPCLBilateralFilter::~DialogPCLBilateralFilter() + { + delete _ui; + _ui = NULL; + delete _selectdlg; + _selectdlg = NULL; + } + + void DialogPCLBilateralFilter::accept() + { + if (_components.size() == 0) + return; + + QString componentIds; + for (auto component : _components) + componentIds.append(QString(",%1").arg(component->getID())); + componentIds.remove(0, 1); + + double sigmaS=_ui->SigmaS->value(); + double sigmaR=_ui->SigmaR->value(); + + emit excuteAlg( componentIds, sigmaR, sigmaS); + + QFDialog::accept(); + } + + void DialogPCLBilateralFilter::selectedComponentsSlot(QList components) + { + for (MeshData::MeshSet *set : components) + { + if (_components.contains(set)) + continue; + _components.append(set); + _ui->listWidget->addItem(set->getName()); + } + } + + void DialogPCLBilateralFilter::customContextMenuRequestedSlot(const QPoint &point) + { + QListWidgetItem *curItem = _ui->listWidget->itemAt(point); + if (!curItem) + return; + + QMenu *menu = new QMenu(this); + QAction *deleteItem = new QAction(tr("delete this item")); + menu->addAction(deleteItem); + connect(menu, &QMenu::triggered, [=]() + { removeCurrentItem(curItem); }); + menu->exec(QCursor::pos()); + } + + void DialogPCLBilateralFilter::removeCurrentItem(QListWidgetItem *curItem) + { + auto meshData = MeshData::MeshData::getInstance(); + auto meshSet = meshData->getMeshSetByName(curItem->text()); + if (!meshSet) + return; + _components.removeOne(meshSet); + _ui->listWidget->removeItemWidget(curItem); + delete curItem; + } + + +} // namespace MainWidget diff --git a/src/MainWidgets/DialogPCLBilateralFilter.h b/src/MainWidgets/DialogPCLBilateralFilter.h new file mode 100644 index 0000000..14809b4 --- /dev/null +++ b/src/MainWidgets/DialogPCLBilateralFilter.h @@ -0,0 +1,60 @@ +/** + * @file DialogPCLBilateralFilter.h + * @brief 点云快速双边滤波 + * @author 陈增辉 (3045316072@qq.com) + * @version 2.5.0 + * @date 2024/4/5 + * @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved. + */ + +#ifndef LAMPCAE_DIALOGPCLBILATERALFILTER_H +#define LAMPCAE_DIALOGPCLBILATERALFILTER_H +#include "mainWidgetsAPI.h" +#include "SelfDefObject/QFDialog.h" +#include "DialogVTKTransform.h" + +class QListWidgetItem; + +namespace Ui +{ + class DialogPCLBilateralFilter; +} + +namespace MeshData +{ + class MeshSet; +} + + +namespace MainWidget { + class DialogSelectComponents; + class MAINWIDGETSAPI DialogPCLBilateralFilter : public QFDialog { + Q_OBJECT + + public: + DialogPCLBilateralFilter(GUI::MainWindow* parent); + ~DialogPCLBilateralFilter() ; + + private: + void removeCurrentItem(QListWidgetItem* curItem); + + signals: // 这里采用信号来直接与 主界面通信,避免参数浪费 + void excuteAlg(QString componentIds,double sigmaR,double sigmaS); + + private slots: + + virtual void accept(); + void selectedComponentsSlot(QList components); + void customContextMenuRequestedSlot(const QPoint& point); + + private: + GUI::MainWindow* _mw; + DialogSelectComponents* _selectdlg; + QList _components; + + private: + Ui::DialogPCLBilateralFilter* _ui; + }; +} // namespace MainWidget + +#endif // LAMPCAE_DIALOGPCLBILATERALFILTER_H diff --git a/src/MainWidgets/DialogPCLBilateralFilter.ui b/src/MainWidgets/DialogPCLBilateralFilter.ui new file mode 100644 index 0000000..6f8aef5 --- /dev/null +++ b/src/MainWidgets/DialogPCLBilateralFilter.ui @@ -0,0 +1,272 @@ + + + DialogPCLBilateralFilter + + + + 0 + 0 + 600 + 397 + + + + + 375 + 300 + + + + + 600 + 397 + + + + DialogPCLBilateralFilter + + + + + + + 357 + 0 + + + + + 600 + 200 + + + + Selected Component + + + + + + + 299 + 32 + + + + + 550 + 500 + + + + + + + + + 0 + 0 + + + + + 32 + 32 + + + + + 32 + 32 + + + + + + + + + + + + + + :/QUI/geometry/selectface.png:/QUI/geometry/selectface.png + + + + 32 + 32 + + + + + + + + Qt::Vertical + + + + 20 + 8 + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + 357 + 120 + + + + + 600 + 120 + + + + params + + + + + + + 238 + 25 + + + + + 238 + 25 + + + + -360.000000000000000 + + + 360.000000000000000 + + + + + + + + 91 + 25 + + + + + 300 + 25 + + + + the size of the window : + + + + + + + + 238 + 25 + + + + + 238 + 25 + + + + -360.000000000000000 + + + 360.000000000000000 + + + + + + + + 91 + 25 + + + + + 300 + 25 + + + + standard deviation of the Gaussian : + + + + + + + + + + + + + + btBox + accepted() + DialogPCLBilateralFilter + accept() + + + 189 + 493 + + + 189 + 260 + + + + + btBox + rejected() + DialogPCLBilateralFilter + reject() + + + 189 + 493 + + + 189 + 260 + + + + + diff --git a/src/MainWidgets/DialogPCLGPMesh.cpp b/src/MainWidgets/DialogPCLGPMesh.cpp new file mode 100644 index 0000000..6f90416 --- /dev/null +++ b/src/MainWidgets/DialogPCLGPMesh.cpp @@ -0,0 +1,113 @@ +/** + * @file DialogPCLGPMesh.cpp + * @brief None + * @author 陈增辉 (3045316072@qq.com) + * @version 2.5.0 + * @date 2024/4/5 + * @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved. + */ + +// You may need to build the project (run Qt uic code generator) to get "ui_DialogPCLGPMesh.h" +// resolved + +#include "DialogPCLGPMesh.h" +#include "ui_DialogPCLGPMesh.h" + +#include "PythonModule/PyAgent.h" +#include "MeshData/meshSingleton.h" +#include "MeshData/meshSet.h" +#include +#include + + +//auto meshData = MeshData::MeshData::getInstance(); + +namespace MainWidget { + DialogPCLGPMesh::DialogPCLGPMesh(GUI::MainWindow *parent) + : QFDialog(parent), + _ui(new Ui::DialogPCLGPMesh), + _mw(parent), + _selectdlg(new DialogSelectComponents(parent)) + { + _ui->setupUi(this); + _ui->geoSelectPoint->setToolTip(tr("Clicked Button Selected Components")); + setWindowTitle(tr("GP Meshing")); + _ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu); + + + connect(_ui->geoSelectPoint, &QPushButton::clicked, [=]() + { _selectdlg->clearSelectItems(); _selectdlg->exec(); }); + connect(_selectdlg, SIGNAL(selectedComponentsSig(QList)), this, SLOT(selectedComponentsSlot(QList))); + connect(_ui->listWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(customContextMenuRequestedSlot(const QPoint &))); + + } + + DialogPCLGPMesh::~DialogPCLGPMesh() + { + delete _ui; + _ui = NULL; + delete _selectdlg; + _selectdlg = NULL; + } + + void DialogPCLGPMesh::accept() + { + if (_components.size() == 0) + return; + + QString componentIds; + for (auto component : _components) + componentIds.append(QString(",%1").arg(component->getID())); + componentIds.remove(0, 1); + + double SearchRadius=_ui->SearchRadius->value(); + double Mu=_ui->Mu->value(); + int MaximumNearestNeighbors=_ui->MaximumNearestNeighbors->value(); + double MaximumSurfaceAngle=_ui->MaximumSurfaceAngle->value(); + double MaximumAngle=_ui->MaximumAngle->value(); + double MinimumAngle=_ui->MinimumAngle->value(); + + // excuteAlg( QString componentIds , double SearchRadius, double Mu,int MaximumNearestNeighbors,double MaximumSurfaceAngle,double MaximumAngle,double MinimumAngle); + emit excuteAlg( componentIds , SearchRadius, Mu, MaximumNearestNeighbors, MaximumSurfaceAngle, MaximumAngle, MinimumAngle); + + QFDialog::accept(); + } + + void DialogPCLGPMesh::selectedComponentsSlot(QList components) + { + for (MeshData::MeshSet *set : components) + { + if (_components.contains(set)) + continue; + _components.append(set); + _ui->listWidget->addItem(set->getName()); + } + } + + void DialogPCLGPMesh::customContextMenuRequestedSlot(const QPoint &point) + { + QListWidgetItem *curItem = _ui->listWidget->itemAt(point); + if (!curItem) + return; + + QMenu *menu = new QMenu(this); + QAction *deleteItem = new QAction(tr("delete this item")); + menu->addAction(deleteItem); + connect(menu, &QMenu::triggered, [=]() + { removeCurrentItem(curItem); }); + menu->exec(QCursor::pos()); + } + + void DialogPCLGPMesh::removeCurrentItem(QListWidgetItem *curItem) + { + auto meshData = MeshData::MeshData::getInstance(); + auto meshSet = meshData->getMeshSetByName(curItem->text()); + if (!meshSet) + return; + _components.removeOne(meshSet); + _ui->listWidget->removeItemWidget(curItem); + delete curItem; + } + + +} // namespace MainWidget diff --git a/src/MainWidgets/DialogPCLGPMesh.h b/src/MainWidgets/DialogPCLGPMesh.h new file mode 100644 index 0000000..1bfa4cd --- /dev/null +++ b/src/MainWidgets/DialogPCLGPMesh.h @@ -0,0 +1,58 @@ +/** + * @file DialogPCLGPMesh.h + * @brief 点云贪婪三角网 + * @author 陈增辉 (3045316072@qq.com) + * @version 2.5.0 + * @date 2024/4/5 + * @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved. + */ + +#ifndef LAMPCAE_DIALOGPCLGPMESH_H +#define LAMPCAE_DIALOGPCLGPMESH_H + +#include "mainWidgetsAPI.h" +#include "SelfDefObject/QFDialog.h" +#include "DialogVTKTransform.h" + + +class QListWidgetItem; + +namespace Ui +{ + class DialogPCLGPMesh; +} + +namespace MeshData +{ + class MeshSet; +} + +namespace MainWidget { + class DialogSelectComponents; + class MAINWIDGETSAPI DialogPCLGPMesh : public QFDialog { + Q_OBJECT + + public: + DialogPCLGPMesh(GUI::MainWindow* parent); + ~DialogPCLGPMesh() ; + private: + void removeCurrentItem(QListWidgetItem* curItem); + signals: // 这里采用信号来直接与 主界面通信,避免参数浪费 + void excuteAlg( QString componentIds , double SearchRadius, double Mu,int MaximumNearestNeighbors,double MaximumSurfaceAngle,double MaximumAngle,double MinimumAngle); + private slots: + + virtual void accept(); + void selectedComponentsSlot(QList components); + void customContextMenuRequestedSlot(const QPoint& point); + + private: + GUI::MainWindow* _mw; + DialogSelectComponents* _selectdlg; + QList _components; + + private: + Ui::DialogPCLGPMesh* _ui; + }; +} // namespace MainWidget + +#endif // LAMPCAE_DIALOGPCLGPMESH_H diff --git a/src/MainWidgets/DialogPCLGPMesh.ui b/src/MainWidgets/DialogPCLGPMesh.ui new file mode 100644 index 0000000..844d5c9 --- /dev/null +++ b/src/MainWidgets/DialogPCLGPMesh.ui @@ -0,0 +1,430 @@ + + + DialogPCLGPMesh + + + + 0 + 0 + 600 + 673 + + + + + 0 + 673 + + + + + 600 + 16777215 + + + + DialogPCLGPMesh + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + 357 + 120 + + + + + 600 + 400 + + + + params + + + + + + + 91 + 25 + + + + + 300 + 25 + + + + Search Radius: + + + + + + + + 238 + 25 + + + + + 238 + 25 + + + + -360.000000000000000 + + + 360.000000000000000 + + + + + + + + 91 + 25 + + + + + 300 + 25 + + + + nearest neighbor distance multiplier : + + + + + + + + 238 + 25 + + + + + 238 + 25 + + + + -360.000000000000000 + + + 360.000000000000000 + + + + + + + + 91 + 25 + + + + + 300 + 25 + + + + maximum number of nearest neighbors : + + + + + + + + 238 + 25 + + + + + 238 + 25 + + + + + + + + + 91 + 25 + + + + + 300 + 25 + + + + normal deviates : + + + + + + + + 238 + 25 + + + + + 238 + 25 + + + + -360.000000000000000 + + + 360.000000000000000 + + + + + + + + 91 + 25 + + + + + 300 + 25 + + + + triangle maximum Angle : + + + + + + + + 238 + 25 + + + + + 238 + 25 + + + + -360.000000000000000 + + + 360.000000000000000 + + + + + + + + 91 + 25 + + + + + 300 + 25 + + + + triangle minimum Angle : + + + + + + + + 238 + 25 + + + + + 238 + 25 + + + + -360.000000000000000 + + + 360.000000000000000 + + + + + + + + + + + 357 + 0 + + + + + 600 + 300 + + + + Selected Component + + + + + + + 299 + 32 + + + + + 550 + 500 + + + + + + + + + 0 + 0 + + + + + 32 + 32 + + + + + 32 + 32 + + + + + + + + + + + + + + :/QUI/geometry/selectface.png:/QUI/geometry/selectface.png + + + + 32 + 32 + + + + + + + + Qt::Vertical + + + + 20 + 8 + + + + + + + + + + + + + + + btBox + accepted() + DialogPCLGPMesh + accept() + + + 299 + 688 + + + 299 + 365 + + + + + btBox + rejected() + DialogPCLGPMesh + reject() + + + 299 + 688 + + + 299 + 365 + + + + + diff --git a/src/MainWidgets/DialogPCLGuassFilter.cpp b/src/MainWidgets/DialogPCLGuassFilter.cpp new file mode 100644 index 0000000..424551b --- /dev/null +++ b/src/MainWidgets/DialogPCLGuassFilter.cpp @@ -0,0 +1,112 @@ +/** + * @file DialogPCLGuassFilter.cpp + * @brief None + * @author 陈增辉 (3045316072@qq.com) + * @version 2.5.0 + * @date 2024/4/5 + * @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved. + */ + +// You may need to build the project (run Qt uic code generator) to get "ui_DialogPCLGuassFilter.h" +// resolved + +#include "DialogPCLGuassFilter.h" +#include "ui_DialogPCLGuassFilter.h" + +#include "PythonModule/PyAgent.h" +#include "MeshData/meshSingleton.h" +#include "MeshData/meshSet.h" +#include +#include + + +//auto meshData = MeshData::MeshData::getInstance(); + +namespace MainWidget { + DialogPCLGuassFilter::DialogPCLGuassFilter(GUI::MainWindow *parent) + : QFDialog(parent), + _ui(new Ui::DialogPCLGuassFilter), + _mw(parent), + _selectdlg(new DialogSelectComponents(parent)) + { + _ui->setupUi(this); + _ui->geoSelectPoint->setToolTip(tr("Clicked Button Selected Components")); + setWindowTitle(tr("Guass Filter")); + _ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu); + + + connect(_ui->geoSelectPoint, &QPushButton::clicked, [=]() + { _selectdlg->clearSelectItems(); _selectdlg->exec(); }); + connect(_selectdlg, SIGNAL(selectedComponentsSig(QList)), this, SLOT(selectedComponentsSlot(QList))); + connect(_ui->listWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(customContextMenuRequestedSlot(const QPoint &))); + + } + + DialogPCLGuassFilter::~DialogPCLGuassFilter() + { + delete _ui; + _ui = NULL; + delete _selectdlg; + _selectdlg = NULL; + } + + void DialogPCLGuassFilter::accept() + { + if (_components.size() == 0) + return; + + QString componentIds, rotate, moveLocation, scale; + for (auto component : _components) + componentIds.append(QString(",%1").arg(component->getID())); + componentIds.remove(0, 1); + + + double Sigma=_ui->Sigma->value(); + double threshold=_ui->threshold->value(); + + + emit excuteAlg( componentIds, Sigma, threshold); + + QString code = QString("MainWindow.createVTKTransform(\"%1\",\"%2\",\"%3\",\"%4\")").arg(componentIds).arg(rotate).arg(moveLocation).arg(scale); + Py::PythonAgent::getInstance()->submit(code); + QFDialog::accept(); + } + + void DialogPCLGuassFilter::selectedComponentsSlot(QList components) + { + for (MeshData::MeshSet *set : components) + { + if (_components.contains(set)) + continue; + _components.append(set); + _ui->listWidget->addItem(set->getName()); + } + } + + void DialogPCLGuassFilter::customContextMenuRequestedSlot(const QPoint &point) + { + QListWidgetItem *curItem = _ui->listWidget->itemAt(point); + if (!curItem) + return; + + QMenu *menu = new QMenu(this); + QAction *deleteItem = new QAction(tr("delete this item")); + menu->addAction(deleteItem); + connect(menu, &QMenu::triggered, [=]() + { removeCurrentItem(curItem); }); + menu->exec(QCursor::pos()); + } + + void DialogPCLGuassFilter::removeCurrentItem(QListWidgetItem *curItem) + { + auto meshData = MeshData::MeshData::getInstance(); + auto meshSet = meshData->getMeshSetByName(curItem->text()); + if (!meshSet) + return; + _components.removeOne(meshSet); + _ui->listWidget->removeItemWidget(curItem); + delete curItem; + } + + +} // namespace MainWidget diff --git a/src/MainWidgets/DialogPCLGuassFilter.h b/src/MainWidgets/DialogPCLGuassFilter.h new file mode 100644 index 0000000..0ffe40c --- /dev/null +++ b/src/MainWidgets/DialogPCLGuassFilter.h @@ -0,0 +1,57 @@ +/** + * @file DialogPCLGuassFilter.h + * @brief 高斯滤波 + * @author 陈增辉 (3045316072@qq.com) + * @version 2.5.0 + * @date 2024/4/5 + * @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved. + */ + +#ifndef LAMPCAE_DIALOGPCLGUASSFILTER_H +#define LAMPCAE_DIALOGPCLGUASSFILTER_H + +#include "mainWidgetsAPI.h" +#include "SelfDefObject/QFDialog.h" +#include "DialogVTKTransform.h" + +class QListWidgetItem; + +namespace Ui +{ + class DialogPCLGuassFilter; +} + +namespace MeshData +{ + class MeshSet; +} +namespace MainWidget { + class DialogSelectComponents; + + class MAINWIDGETSAPI DialogPCLGuassFilter : public QFDialog { + Q_OBJECT + + public: + DialogPCLGuassFilter(GUI::MainWindow* parent); + ~DialogPCLGuassFilter() ; + private: + void removeCurrentItem(QListWidgetItem* curItem); + signals: // 这里采用信号来直接与 主界面通信,避免参数浪费 + void excuteAlg(QString componentIds,double sigma,double threshold); + private slots: + + virtual void accept(); + void selectedComponentsSlot(QList components); + void customContextMenuRequestedSlot(const QPoint& point); + + private: + GUI::MainWindow* _mw; + DialogSelectComponents* _selectdlg; + QList _components; + + private: + Ui::DialogPCLGuassFilter* _ui; + }; +} // namespace MainWidget + +#endif // LAMPCAE_DIALOGPCLGUASSFILTER_H diff --git a/src/MainWidgets/DialogPCLGuassFilter.ui b/src/MainWidgets/DialogPCLGuassFilter.ui new file mode 100644 index 0000000..4490332 --- /dev/null +++ b/src/MainWidgets/DialogPCLGuassFilter.ui @@ -0,0 +1,272 @@ + + + DialogPCLGuassFilter + + + + 0 + 0 + 600 + 446 + + + + + 375 + 0 + + + + + 600 + 16777215 + + + + DialogPCLGuassFilter + + + + + + + 357 + 0 + + + + + 600 + 200 + + + + Selected Component + + + + + + + 299 + 32 + + + + + 550 + 500 + + + + + + + + + 0 + 0 + + + + + 32 + 32 + + + + + 32 + 32 + + + + + + + + + + + + + + :/QUI/geometry/selectface.png:/QUI/geometry/selectface.png + + + + 32 + 32 + + + + + + + + Qt::Vertical + + + + 20 + 8 + + + + + + + + + + + + 357 + 120 + + + + + 600 + 120 + + + + params + + + + + + + 238 + 25 + + + + + 238 + 25 + + + + -360.000000000000000 + + + 360.000000000000000 + + + + + + + + 91 + 25 + + + + + 220 + 25 + + + + the sigma of the Gaussian : + + + + + + + + 238 + 25 + + + + + 238 + 25 + + + + -360.000000000000000 + + + 360.000000000000000 + + + + + + + + 91 + 25 + + + + + 220 + 25 + + + + distance threshold : + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + btBox + accepted() + DialogPCLGuassFilter + accept() + + + 187 + 276 + + + 187 + 149 + + + + + btBox + rejected() + DialogPCLGuassFilter + reject() + + + 187 + 276 + + + 187 + 149 + + + + + diff --git a/src/MainWidgets/DialogPCLRadiusOutlierRemoval.cpp b/src/MainWidgets/DialogPCLRadiusOutlierRemoval.cpp new file mode 100644 index 0000000..95f6207 --- /dev/null +++ b/src/MainWidgets/DialogPCLRadiusOutlierRemoval.cpp @@ -0,0 +1,112 @@ +/** + * @file DialogPCLStatisticalRemoveFilter.cpp + * @brief None + * @author 陈增辉 (3045316072@qq.com) + * @version 2.5.0 + * @date 2024/4/5 + * @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved. + */ + +// You may need to build the project (run Qt uic code generator) to get +// "ui_DialogPCLStatisticalRemoveFilter.h" resolved + +#include "DialogPCLRadiusOutlierRemoval.h" +#include "ui_DialogPCLRadiusOutlierRemoval.h" + +#include "PythonModule/PyAgent.h" +#include "MeshData/meshSingleton.h" +#include "MeshData/meshSet.h" +#include +#include + + + + + +namespace MainWidget { + DialogPCLRadiusOutlierRemoval::DialogPCLRadiusOutlierRemoval(GUI::MainWindow *parent) + : QFDialog(parent), + _ui(new Ui::DialogPCLRadiusOutlierRemoval), + _mw(parent), + _selectdlg(new DialogSelectComponents(parent)) + { + _ui->setupUi(this); + _ui->geoSelectPoint->setToolTip(tr("Clicked Button Selected Components")); + setWindowTitle(tr("Radius Outlier Removal")); + _ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu); + + + connect(_ui->geoSelectPoint, &QPushButton::clicked, [=]() + { _selectdlg->clearSelectItems(); _selectdlg->exec(); }); + connect(_selectdlg, SIGNAL(selectedComponentsSig(QList)), this, SLOT(selectedComponentsSlot(QList))); + connect(_ui->listWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(customContextMenuRequestedSlot(const QPoint &))); + + } + + DialogPCLRadiusOutlierRemoval::~DialogPCLRadiusOutlierRemoval() + { + delete _ui; + _ui = NULL; + delete _selectdlg; + _selectdlg = NULL; + } + + void DialogPCLRadiusOutlierRemoval::accept() + { + if (_components.size() == 0) + return; + + QString componentIds, rotate, moveLocation, scale; + for (auto component : _components) + componentIds.append(QString(",%1").arg(component->getID())); + componentIds.remove(0, 1); + + + + double RadiusSearch=_ui->RadiusSearch->value(); + double MinNeighborsInRadius=_ui->MinNeighborsInRadius->value(); + + emit excuteAlg(componentIds,RadiusSearch, MinNeighborsInRadius); + + + QFDialog::accept(); + } + + void DialogPCLRadiusOutlierRemoval::selectedComponentsSlot(QList components) + { + for (MeshData::MeshSet *set : components) + { + if (_components.contains(set)) + continue; + _components.append(set); + _ui->listWidget->addItem(set->getName()); + } + } + + void DialogPCLRadiusOutlierRemoval::customContextMenuRequestedSlot(const QPoint &point) + { + QListWidgetItem *curItem = _ui->listWidget->itemAt(point); + if (!curItem) + return; + + QMenu *menu = new QMenu(this); + QAction *deleteItem = new QAction(tr("delete this item")); + menu->addAction(deleteItem); + connect(menu, &QMenu::triggered, [=]() + { removeCurrentItem(curItem); }); + menu->exec(QCursor::pos()); + } + + void DialogPCLRadiusOutlierRemoval::removeCurrentItem(QListWidgetItem *curItem) + { + auto meshData = MeshData::MeshData::getInstance(); + auto meshSet = meshData->getMeshSetByName(curItem->text()); + if (!meshSet) + return; + _components.removeOne(meshSet); + _ui->listWidget->removeItemWidget(curItem); + delete curItem; + } + + +} // namespace MainWidget diff --git a/src/MainWidgets/DialogPCLRadiusOutlierRemoval.h b/src/MainWidgets/DialogPCLRadiusOutlierRemoval.h new file mode 100644 index 0000000..c730b26 --- /dev/null +++ b/src/MainWidgets/DialogPCLRadiusOutlierRemoval.h @@ -0,0 +1,59 @@ +/** + * @file DialogPCLRadiusOutlierRemoval.h + * @brief 点云半径滤波 + * @author 陈增辉 (3045316072@qq.com) + * @version 2.5.0 + * @date 2024/4/5 + * @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved. + */ + +#ifndef LAMPCAE_DIALOGPCLRADIUSOUTLIERREMOVAL_H +#define LAMPCAE_DIALOGPCLRADIUSOUTLIERREMOVAL_H + +#include "mainWidgetsAPI.h" +#include "SelfDefObject/QFDialog.h" +#include "DialogVTKTransform.h" + +class QListWidgetItem; + +namespace Ui +{ + class DialogPCLRadiusOutlierRemoval; +} + +namespace MeshData +{ + class MeshSet; +} +namespace MainWidget { + class DialogSelectComponents; + + class MAINWIDGETSAPI DialogPCLRadiusOutlierRemoval : public QFDialog { + Q_OBJECT + + public: + DialogPCLRadiusOutlierRemoval(GUI::MainWindow* parent); + ~DialogPCLRadiusOutlierRemoval(); + + private: + void removeCurrentItem(QListWidgetItem* curItem); + signals: // 这里采用信号来直接与 主界面通信,避免参数浪费 + void excuteAlg(QString componentIds,double RadiusSearch,double MinNeighborsInRadius); + private slots: + + virtual void accept(); + void selectedComponentsSlot(QList components); + void customContextMenuRequestedSlot(const QPoint& point); + + private: + GUI::MainWindow* _mw; + DialogSelectComponents* _selectdlg; + QList _components; + + + private: + Ui::DialogPCLRadiusOutlierRemoval* _ui; + }; +} // namespace MainWidget + +#endif // LAMPCAE_DIALOGPCLRADIUSOUTLIERREMOVAL_H diff --git a/src/MainWidgets/DialogPCLRadiusOutlierRemoval.ui b/src/MainWidgets/DialogPCLRadiusOutlierRemoval.ui new file mode 100644 index 0000000..56326ae --- /dev/null +++ b/src/MainWidgets/DialogPCLRadiusOutlierRemoval.ui @@ -0,0 +1,275 @@ + + + DialogPCLRadiusOutlierRemoval + + + + 0 + 0 + 600 + 428 + + + + + 375 + 0 + + + + + 600 + 16777215 + + + + DialogPCLRadiusOutlierRemoval + + + + + + + 357 + 0 + + + + + 600 + 200 + + + + Selected Component + + + + + + + 299 + 32 + + + + + 550 + 500 + + + + + + + + + 0 + 0 + + + + + 32 + 32 + + + + + 32 + 32 + + + + + + + + + + + + + + :/QUI/geometry/selectface.png:/QUI/geometry/selectface.png + + + + 32 + 32 + + + + + + + + Qt::Vertical + + + + 20 + 8 + + + + + + + + + + + + 357 + 120 + + + + + 600 + 120 + + + + params + + + + + + + 238 + 25 + + + + + 238 + 25 + + + + -360.000000000000000 + + + 360.000000000000000 + + + + + + + + 91 + 25 + + + + + 200 + 25 + + + + Qt::LeftToRight + + + Radius of Search : + + + + + + + + 238 + 25 + + + + + 238 + 25 + + + + -360.000000000000000 + + + 360.000000000000000 + + + + + + + + 91 + 25 + + + + + 200 + 25 + + + + the number of neighbors : + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + btBox + accepted() + DialogPCLRadiusOutlierRemoval + accept() + + + 299 + 390 + + + 299 + 213 + + + + + btBox + rejected() + DialogPCLRadiusOutlierRemoval + reject() + + + 299 + 390 + + + 299 + 213 + + + + + diff --git a/src/MainWidgets/DialogPCLStatisticalRemoveFilter.cpp b/src/MainWidgets/DialogPCLStatisticalRemoveFilter.cpp new file mode 100644 index 0000000..3f70131 --- /dev/null +++ b/src/MainWidgets/DialogPCLStatisticalRemoveFilter.cpp @@ -0,0 +1,113 @@ +/** + * @file DialogPCLStatisticalRemoveFilter.cpp + * @brief None + * @author 陈增辉 (3045316072@qq.com) + * @version 2.5.0 + * @date 2024/4/5 + * @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved. + */ + +// You may need to build the project (run Qt uic code generator) to get +// "ui_DialogPCLStatisticalRemoveFilter.h" resolved + +#include "DialogPCLStatisticalRemoveFilter.h" +#include "ui_DialogPCLStatisticalRemoveFilter.h" + +#include "PythonModule/PyAgent.h" +#include "MeshData/meshSingleton.h" +#include "MeshData/meshSet.h" +#include +#include + + +//auto meshData = MeshData::MeshData::getInstance(); + + +namespace MainWidget { + DialogPCLStatisticalRemoveFilter::DialogPCLStatisticalRemoveFilter(GUI::MainWindow *parent) + : QFDialog(parent), + _ui(new Ui::DialogPCLStatisticalRemoveFilter), + _mw(parent), + _selectdlg(new DialogSelectComponents(parent)) + { + _ui->setupUi(this); + _ui->geoSelectPoint->setToolTip(tr("Clicked Button Selected Components")); + setWindowTitle(tr("Statistical Remove Filter")); + _ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu); + + + connect(_ui->geoSelectPoint, &QPushButton::clicked, [=]() + { _selectdlg->clearSelectItems(); _selectdlg->exec(); }); + connect(_selectdlg, SIGNAL(selectedComponentsSig(QList)), this, SLOT(selectedComponentsSlot(QList))); + connect(_ui->listWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(customContextMenuRequestedSlot(const QPoint &))); + } + + DialogPCLStatisticalRemoveFilter::~DialogPCLStatisticalRemoveFilter() + { + delete _ui; + _ui = NULL; + delete _selectdlg; + _selectdlg = NULL; + } + + + + + void DialogPCLStatisticalRemoveFilter::accept() + { + if (_components.size() == 0) + return; + + QString componentIds, rotate, moveLocation, scale; + for (auto component : _components) + componentIds.append(QString(",%1").arg(component->getID())); + componentIds.remove(0, 1); + + double MeanK=_ui->MeanK->value(); + double stddev=_ui->Stddev->value(); + + emit excuteAlg(componentIds,MeanK,stddev); + + QFDialog::accept(); + } + + void DialogPCLStatisticalRemoveFilter::selectedComponentsSlot(QList components) + { + for (MeshData::MeshSet *set : components) + { + if (_components.contains(set)) + continue; + _components.append(set); + _ui->listWidget->addItem(set->getName()); + } + } + + void DialogPCLStatisticalRemoveFilter::customContextMenuRequestedSlot(const QPoint &point) + { + QListWidgetItem *curItem = _ui->listWidget->itemAt(point); + if (!curItem) + return; + + QMenu *menu = new QMenu(this); + QAction *deleteItem = new QAction(tr("delete this item")); + menu->addAction(deleteItem); + connect(menu, &QMenu::triggered, [=]() + { removeCurrentItem(curItem); }); + menu->exec(QCursor::pos()); + } + + void DialogPCLStatisticalRemoveFilter::removeCurrentItem(QListWidgetItem *curItem) + { + auto meshData = MeshData::MeshData::getInstance(); + auto meshSet = meshData->getMeshSetByName(curItem->text()); + if (!meshSet) + return; + _components.removeOne(meshSet); + _ui->listWidget->removeItemWidget(curItem); + delete curItem; + } + + + + +} // namespace MainWidget diff --git a/src/MainWidgets/DialogPCLStatisticalRemoveFilter.h b/src/MainWidgets/DialogPCLStatisticalRemoveFilter.h new file mode 100644 index 0000000..245f9d9 --- /dev/null +++ b/src/MainWidgets/DialogPCLStatisticalRemoveFilter.h @@ -0,0 +1,57 @@ +/** + * @file DialogPCLStatisticalRemoveFilter.h + * @brief 点云统计滤波 + * @author 陈增辉 (3045316072@qq.com) + * @version 2.5.0 + * @date 2024/4/5 + * @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved. + */ + +#ifndef LAMPCAE_DIALOGPCLSTATISTICALREMOVEFILTER_H +#define LAMPCAE_DIALOGPCLSTATISTICALREMOVEFILTER_H + +#include "mainWidgetsAPI.h" +#include "SelfDefObject/QFDialog.h" +#include "DialogVTKTransform.h" + +class QListWidgetItem; + +namespace Ui +{ + class DialogPCLStatisticalRemoveFilter; +} + +namespace MeshData +{ + class MeshSet; +} +namespace MainWidget { + class DialogSelectComponents; + + class MAINWIDGETSAPI DialogPCLStatisticalRemoveFilter : public QFDialog { + Q_OBJECT + + public: + DialogPCLStatisticalRemoveFilter(GUI::MainWindow* parent); + ~DialogPCLStatisticalRemoveFilter(); + private: + void removeCurrentItem(QListWidgetItem* curItem); + signals: // 这里采用信号来直接与 主界面通信,避免参数浪费 + void excuteAlg(QString componentIds,double MeanK,double stddev); + private slots: + + virtual void accept(); + void selectedComponentsSlot(QList components); + void customContextMenuRequestedSlot(const QPoint& point); + + private: + GUI::MainWindow* _mw; + DialogSelectComponents* _selectdlg; + QList _components; + + private: // 界面 + Ui::DialogPCLStatisticalRemoveFilter* _ui; + }; +} // namespace MainWidget + +#endif // LAMPCAE_DIALOGPCLSTATISTICALREMOVEFILTER_H diff --git a/src/MainWidgets/DialogPCLStatisticalRemoveFilter.ui b/src/MainWidgets/DialogPCLStatisticalRemoveFilter.ui new file mode 100644 index 0000000..c9dc958 --- /dev/null +++ b/src/MainWidgets/DialogPCLStatisticalRemoveFilter.ui @@ -0,0 +1,272 @@ + + + DialogPCLStatisticalRemoveFilter + + + + 0 + 0 + 600 + 450 + + + + + 375 + 408 + + + + + 600 + 450 + + + + DialogPCLStatisticalRemoveFilter + + + + + + + 357 + 0 + + + + + 600 + 200 + + + + Selected Component + + + + + + + 299 + 32 + + + + + 550 + 500 + + + + + + + + + 0 + 0 + + + + + 32 + 32 + + + + + 32 + 32 + + + + + + + + + + + + + + :/QUI/geometry/selectface.png:/QUI/geometry/selectface.png + + + + 32 + 32 + + + + + + + + Qt::Vertical + + + + 20 + 8 + + + + + + + + + + + + 357 + 120 + + + + + 600 + 120 + + + + params + + + + + + + 91 + 25 + + + + + 300 + 25 + + + + number of nearest neighbors : + + + + + + + + 238 + 25 + + + + + 238 + 25 + + + + -360.000000000000000 + + + 360.000000000000000 + + + + + + + + 91 + 25 + + + + + 300 + 25 + + + + Stddev Thresh : + + + + + + + + 238 + 25 + + + + + 238 + 25 + + + + -360.000000000000000 + + + 360.000000000000000 + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + btBox + accepted() + DialogPCLStatisticalRemoveFilter + accept() + + + 299 + 408 + + + 299 + 224 + + + + + btBox + rejected() + DialogPCLStatisticalRemoveFilter + reject() + + + 299 + 408 + + + 299 + 224 + + + + + diff --git a/src/MainWidgets/DialogSelectMeshDataComponents.cpp b/src/MainWidgets/DialogSelectMeshDataComponents.cpp new file mode 100644 index 0000000..771c86d --- /dev/null +++ b/src/MainWidgets/DialogSelectMeshDataComponents.cpp @@ -0,0 +1,49 @@ +/** + * @file dialogselectmeshdatacomponents.cpp + * @brief None + * @author 陈增辉 (3045316072@qq.com) + * @version 2.5.0 + * @date 2024/4/7 + * @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved. + */ + +// You may need to build the project (run Qt uic code generator) to get +// "ui_DialogSelectMeshDataComponents.h" resolved + +#include "DialogSelectMeshDataComponents.h" +#include "ui_DialogSelectMeshDataComponents.h" +#include "MeshData/meshSingleton.h" +#include "MeshData/meshSet.h" +#include "MeshData/MeshKernal.h" + + +namespace MainWidget { + auto meshData = MeshData::MeshData::getInstance(); + + DialogSelectMeshDataComponents::DialogSelectMeshDataComponents(GUI::MainWindow* parent) + : QFDialog(parent) + { + _ui->setupUi(this); + + setWindowTitle(tr("Select Components")); + + int nSet = meshData->getMeshSetCount(); + for (int i = 0; i < nSet; i++) + { + MeshData::MeshKernal* k= meshData->getKernalAt(i); + if (!k) + continue; + _ui->listWidget->addItem(k->getName()); + } + } + + DialogSelectMeshDataComponents::~DialogSelectMeshDataComponents() + { + delete _ui; + _ui = NULL; + } + void DialogSelectMeshDataComponents::accept() + { + QDialog::accept(); + } +} \ No newline at end of file diff --git a/src/MainWidgets/DialogSelectMeshDataComponents.h b/src/MainWidgets/DialogSelectMeshDataComponents.h new file mode 100644 index 0000000..cf629e5 --- /dev/null +++ b/src/MainWidgets/DialogSelectMeshDataComponents.h @@ -0,0 +1,50 @@ +/** + * @file dialogselectmeshdatacomponents.h + * @brief None + * @author 陈增辉 (3045316072@qq.com) + * @version 2.5.0 + * @date 2024/4/7 + * @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved. + */ + +#ifndef LAMPCAE_DIALOGSELECTMESHDATACOMPONENTS_H +#define LAMPCAE_DIALOGSELECTMESHDATACOMPONENTS_H + +#include +#include "DialogVTKTransform.h" +#include "MeshData/meshSet.h" + +namespace MeshData +{ + class MeshData; + class MeshSet; + class MeshKernal; + +} + +namespace Ui { + class DialogSelectMeshDataComponents; +} + + +namespace MainWidget{ + class MAINWIDGETSAPI DialogSelectMeshDataComponents : public QFDialog { + Q_OBJECT + + public: + DialogSelectMeshDataComponents(GUI::MainWindow* parent); + ~DialogSelectMeshDataComponents() override; + void clearSelectItems(); + + signals: + void selectedComponentsSig(QList components); + + private slots: + virtual void accept(); + + private: + Ui::DialogSelectMeshDataComponents* _ui; + }; +} + +#endif // LAMPCAE_DIALOGSELECTMESHDATACOMPONENTS_H diff --git a/src/MainWidgets/DialogSelectMeshDataComponents.ui b/src/MainWidgets/DialogSelectMeshDataComponents.ui new file mode 100644 index 0000000..67769aa --- /dev/null +++ b/src/MainWidgets/DialogSelectMeshDataComponents.ui @@ -0,0 +1,55 @@ + + + DialogSelectMeshDataComponents + + + + 0 + 0 + 430 + 248 + + + + DialogSelectMeshDataComponents + + + + + + QAbstractItemView::ExtendedSelection + + + + + + + Qt::Horizontal + + + + 247 + 31 + + + + + + + + OK + + + + + + + Cancel + + + + + + + + diff --git a/src/MainWidgets/DialogVTKTransform.ui b/src/MainWidgets/DialogVTKTransform.ui index dae944f..f8fb3f3 100644 --- a/src/MainWidgets/DialogVTKTransform.ui +++ b/src/MainWidgets/DialogVTKTransform.ui @@ -1,4 +1,4 @@ - + DialogVTKTransform @@ -6,8 +6,8 @@ 0 0 - 375 - 664 + 377 + 752 @@ -18,7 +18,7 @@ - 375 + 379 752 diff --git a/src/MainWidgets/meshKernalViewObject.cpp b/src/MainWidgets/meshKernalViewObject.cpp index a3a270c..db0bcb0 100644 --- a/src/MainWidgets/meshKernalViewObject.cpp +++ b/src/MainWidgets/meshKernalViewObject.cpp @@ -56,7 +56,7 @@ namespace MainWidget void MeshKernalViewObj::setPointColor(const QColor &c, bool disOnly) { vtkDataArray *dpointColor = _displayData->GetPointData()->GetScalars(); - double col[3]{c.red(), c.green(), c.blue()}; + double col[3]{c.red()*1.0, c.green()*1.0, c.blue()*1.0}; if (nullptr == dpointColor) { dpointColor = vtkUnsignedCharArray::New(); @@ -91,7 +91,7 @@ namespace MainWidget vtkDataArray *indexArray = _displayData->GetPointData()->GetArray("IDS"); if (nullptr == colorArray || nullptr == indexArray) return; - double col[3]{color.red(), color.green(), color.blue()}; + double col[3]{color.red()*1.0, color.green()*1.0, color.blue()*1.0}; const int nPoint = indexArray->GetNumberOfTuples(); for (int i = 0; i < nPoint; ++i) { @@ -111,7 +111,7 @@ namespace MainWidget void MeshKernalViewObj::setCellColor(const QColor &c, bool disOnly) { - double col[3]{c.red(), c.green(), c.blue()}; + double col[3]{c.red()*1.0, c.green()*1.0, c.blue()*1.0}; vtkDataArray *dcellcolor = _displayData->GetCellData()->GetScalars(); if (dcellcolor == nullptr) { @@ -146,7 +146,7 @@ namespace MainWidget { vtkDataArray *colorArray = _displayData->GetCellData()->GetScalars(); vtkDataArray *indexArray = _displayData->GetCellData()->GetArray("IDS"); - double col[3]{color.red(), color.green(), color.blue()}; + double col[3]{color.red()*1.0, color.green()*1.0, color.blue()*1.0}; if (nullptr == colorArray || nullptr == indexArray) return; const int nCell = indexArray->GetNumberOfTuples(); @@ -200,7 +200,7 @@ namespace MainWidget vtkDataArray *indexArray = _displayData->GetPointData()->GetArray("IDS"); if (nullptr == colorArray || nullptr == indexArray) return; - double col[3]{color.red(), color.green(), color.blue()}; + double col[3]{color.red()*1.0, color.green()*1.0, color.blue()*1.0}; for (int index : indexs) { colorArray->SetComponent(index, 0, col[0]); @@ -216,7 +216,7 @@ namespace MainWidget vtkDataArray *indexArray = _displayData->GetCellData()->GetArray("IDS"); if (nullptr == colorArray || nullptr == indexArray) return; - double col[3]{color.red(), color.green(), color.blue()}; + double col[3]{color.red()*1.0, color.green()*1.0, color.blue()*1.0}; for (int index : indexs) { colorArray->SetComponent(index, 0, col[0]); @@ -283,11 +283,11 @@ namespace MainWidget const int id = _kernal->getID(); // cell ID与显示隐藏状态 vtkSmartPointer kcellid_index = vtkSmartPointer::New(); - kcellid_index->SetNumberOfComponents(2); + kcellid_index->SetNumberOfComponents(2); // 设置 dimension kcellid_index->SetName("IDS"); const int ncell = dataset->GetNumberOfCells(); for (int i = 0; i < ncell; ++i) - kcellid_index->InsertNextTuple2(id, i); + kcellid_index->InsertNextTuple2(id, i); // 这里添加 网格id ,与 cell 序号 dataset->GetCellData()->AddArray(kcellid_index); vtkSmartPointer cstatesArray = vtkSmartPointer::New(); diff --git a/src/MainWidgets/meshViewProvider.cpp b/src/MainWidgets/meshViewProvider.cpp index 99a94b9..a78585a 100644 --- a/src/MainWidgets/meshViewProvider.cpp +++ b/src/MainWidgets/meshViewProvider.cpp @@ -23,15 +23,21 @@ namespace MainWidget _meshData = MeshData::MeshData::getInstance(); connect(_preWindow, SIGNAL(updateMeshActorSig()), this, SLOT(updateMeshActorSlot())); - //connect(_preWindow, SIGNAL(removeSetDataSig(int)), this, SLOT(removeSetData(int))); - // connect(_preWindow, SIGNAL(highLightActorDispalyPoint(bool)), this, SLOT(highLightActorDispalyPoint(bool))); + // connect(_preWindow, SIGNAL(removeSetDataSig(int)), this, SLOT(removeSetData(int))); + // connect(_preWindow, SIGNAL(highLightActorDispalyPoint(bool)), this, + //SLOT(highLightActorDispalyPoint(bool))); connect(_preWindow, SIGNAL(clearMeshSetHighLight()), this, SLOT(clearHighLight())); connect(_preWindow, SIGNAL(clearAllHighLight()), this, SLOT(clearHighLight())); - connect(_preWindow, SIGNAL(highLighMeshSet(MeshData::MeshSet *)), this, SLOT(highLighMeshSet(MeshData::MeshSet *))); - connect(_preWindow, SIGNAL(highLighKernel(MeshData::MeshKernal *)), this, SLOT(highLighKernel(MeshData::MeshKernal *))); - // connect(_preWindow, SIGNAL(highLighDataSet(vtkDataSet*)), this, SLOT(highLighDataSet(vtkDataSet*))); - connect(_mainWindow, SIGNAL(updateMeshSetVisibleSig(MeshData::MeshSet *)), this, SLOT(updateMeshSetVisibily(MeshData::MeshSet *))); - connect(_mainWindow, SIGNAL(updateMeshSetColorSig(int)), this, SLOT(updateMeshSetColor(int))); + connect(_preWindow, SIGNAL(highLighMeshSet(MeshData::MeshSet*)), this, + SLOT(highLighMeshSet(MeshData::MeshSet*))); + connect(_preWindow, SIGNAL(highLighKernel(MeshData::MeshKernal*)), this, + SLOT(highLighKernel(MeshData::MeshKernal*))); + // connect(_preWindow, SIGNAL(highLighDataSet(vtkDataSet*)), this, + //SLOT(highLighDataSet(vtkDataSet*))); + connect(_mainWindow, SIGNAL(updateMeshSetVisibleSig(MeshData::MeshSet*)), this, + SLOT(updateMeshSetVisibily(MeshData::MeshSet*))); + connect(_mainWindow, SIGNAL(updateMeshSetColorSig(int)), this, + SLOT(updateMeshSetColor(int))); } MeshViewProvider::~MeshViewProvider() diff --git a/src/MainWidgets/preWindow.cpp b/src/MainWidgets/preWindow.cpp index 42f7d58..ebc1e52 100644 --- a/src/MainWidgets/preWindow.cpp +++ b/src/MainWidgets/preWindow.cpp @@ -19,12 +19,14 @@ namespace MainWidget PreWindow::PreWindow(GUI::MainWindow *mw, int id, ModuleBase::GraphWindowType t) : ModuleBase::Graph3DWindow(mw, id, t, true) { - _meshData = MeshData::MeshData::getInstance(); + _meshData = MeshData::MeshData::getInstance(); // 数据管理口 _geometryData = Geometry::GeometryData::getInstance(); _modelData = ModelData::ModelDataSingleton::getinstance(); - _geoProvider = new GeometryViewProvider(mw, this); + + _geoProvider = new GeometryViewProvider(mw, this); // 界面 _meshProvider = new MeshViewProvider(mw, this); _sketchProvider = new SketchViewProvider(mw, this); + this->setWindowTitle(tr("Pre-Window")); connect(this, SIGNAL(closed()), mw, SIGNAL(closePreWindowSig())); connect(mw, SIGNAL(clearAllHighLight()), this, SIGNAL(clearAllHighLight())); @@ -37,7 +39,7 @@ namespace MainWidget connect(mw, SIGNAL(startSketchSig(bool, double *, double *)), this, SLOT(startSketch(bool, double *, double *))); //网格 // connect(this, SIGNAL(updateMeshActorSig()), this, SLOT(updateMeshActor())); - connect(this, SIGNAL(highLighSet(QMultiHash *)), this, SLOT(highLighSet(QMultiHash *))); + connect(this, SIGNAL(highLighSet(QMultiHash *)), this, SLOT(highLighSet(QMultiHash *))); // 绑定父类Graph3DWindow的highLignset(信号)与本类highLighSet(槽) connect(mw, SIGNAL(updateMeshDispalyStateSig(int, bool)), this, SLOT(updateMeshDispaly(int, bool))); connect(mw, SIGNAL(removeMeshActorSig(int)), this, SLOT(removeMeshActor(int))); connect(mw, SIGNAL(removeSetDataSig(int)), this, SIGNAL(removeSetDataSig(int))); diff --git a/src/MainWindow/CMakeLists.txt b/src/MainWindow/CMakeLists.txt index 98e6325..8f66fe2 100644 --- a/src/MainWindow/CMakeLists.txt +++ b/src/MainWindow/CMakeLists.txt @@ -38,7 +38,7 @@ add_library(MainWindow #----------------------------------------------------------------------------- target_compile_definitions(MainWindow PRIVATE "MAINWINDOW_API") -list(APPEND _depend_library Common PythonModule SARibbonBar Settings DataProperty MeshData Material Geometry ConfigOptions SelfDefObject ModelData ModuleBase PluginManager GmshModule PostInterface PostRenderData PostWidgets ProjectTree GeometryCommand GeometryWidgets IO SolverControl MainWidgets UserGuidence Common) +list(APPEND _depend_library Common LAMPTool WBCLFZSystemModule PythonModule SARibbonBar Settings DataProperty MeshData Material Geometry ConfigOptions SelfDefObject ModelData ModuleBase PluginManager GmshModule PostInterface PostRenderData PostWidgets ProjectTree GeometryCommand GeometryWidgets IO SolverControl MainWidgets UserGuidence Common) if(_WIN_) list(APPEND _depend_library XGenerateReport) endif() diff --git a/src/MainWindow/MainWindow.cpp b/src/MainWindow/MainWindow.cpp index 50614cb..7a5df31 100644 --- a/src/MainWindow/MainWindow.cpp +++ b/src/MainWindow/MainWindow.cpp @@ -45,6 +45,7 @@ #include "MainWidgets/projectSolveDialog.h" #include "MainWindowPy.h" #include "MeshData/meshKernal.h" +#include "MeshData/meshSet.h" #include "MeshData/meshSingleton.h" #include "ModelData/modelDataBaseExtend.h" #include "ModelData/modelDataSingleton.h" @@ -72,6 +73,8 @@ #include #include #include +#include +#include // ribbon #include "SARibbonBar/SARibbonBar.h" #include "SARibbonBar/SARibbonCategory.h" @@ -82,12 +85,22 @@ #include "Common/Types.h" #include "PostInterface/AnimationToolBar.h" #include "PostInterface/RenderDirector.h" +// pcl +#include "MainWidgets/DialogPCLBilateralFilter.h" +#include "MainWidgets/DialogPCLGPMesh.h" +#include "MainWidgets/DialogPCLGuassFilter.h" +#include "MainWidgets/DialogPCLRadiusOutlierRemoval.h" +#include "MainWidgets/DialogPCLStatisticalRemoveFilter.h" +#include "IO/vtkDataRelated.h" +#include "LAMPTool/BaseTool.h" -//logger +// logger #include "Common/DebugLogger.h" namespace GUI { - MainWindow::MainWindow(bool useRibbon): SARibbonMainWindow(nullptr, useRibbon), _ui(new Ui::MainWindowRibbon) + MainWindow::MainWindow(bool useRibbon) + : SARibbonMainWindow(nullptr, useRibbon) + , _ui(new Ui::MainWindowRibbon) { if(useRibbon) { _ui->setupRibbonUi(this); @@ -150,7 +163,8 @@ namespace GUI { // ribbon customize // MainWindow的构造函数最后 if(useRibbon) { - const QString strCostomizePath =QApplication::applicationDirPath() + "/customization.xml"; + const QString strCostomizePath = + QApplication::applicationDirPath() + "/customization.xml"; sa_apply_customize_from_xml_file(strCostomizePath, this, m_ribbonActionMgr); } } @@ -210,6 +224,7 @@ namespace GUI { connect(this, SIGNAL(printMessageSig(Common::Message, QString)), this, SLOT(printMessage(Common::Message, QString))); + // 文件 connect(_ui->actionNew, SIGNAL(triggered()), this, SLOT(on_actionNew())); connect(_ui->actionOpen, SIGNAL(triggered()), this, SLOT(on_actionOpen())); connect(_ui->actionSave, SIGNAL(triggered()), this, SLOT(on_actionSave())); @@ -239,6 +254,10 @@ namespace GUI { connect(_ui->actionFilterMesh, SIGNAL(triggered()), this, SLOT(on_FilterMesh())); connect(_ui->actionVTKTranslation, SIGNAL(triggered()), this, SLOT(on_VTKTranslation())); + // 点云 + + + // 设置视角 _viewSignalMapper = new QSignalMapper(this); connect(_ui->actionFitView, SIGNAL(triggered()), _viewSignalMapper, SLOT(map())); @@ -261,13 +280,16 @@ namespace GUI { _selectSignalMapper = new QSignalMapper(this); connect(_ui->actionSelectOff, SIGNAL(triggered()), _selectSignalMapper, SLOT(map())); // connect(_ui->actionSelectGeoBody, SIGNAL(triggered()), _selectSignalMapper, SLOT(map())); - connect(_ui->actionSelectMeshNode, SIGNAL(triggered()), _selectSignalMapper, SLOT(map())); + connect(_ui->actionSelectMeshNode, SIGNAL(triggered()), _selectSignalMapper, + SLOT(map())); // 单点 connect(_ui->actionSelectMeshCell, SIGNAL(triggered()), _selectSignalMapper, SLOT(map())); - connect(_ui->actionBoxMeshNode, SIGNAL(triggered()), _selectSignalMapper, SLOT(map())); + connect(_ui->actionBoxMeshNode, SIGNAL(triggered()), _selectSignalMapper, + SLOT(map())); // 多选 connect(_ui->actionBoxMeshCell, SIGNAL(triggered()), _selectSignalMapper, SLOT(map())); _selectSignalMapper->setMapping(_ui->actionSelectOff, (int)ModuleBase::SelectModel::None); //_selectSignalMapper->setMapping(_ui->actionSelectGeoBody, //(int)ModuleBase::SelectModel::GeometryBody); + _selectSignalMapper->setMapping(_ui->actionSelectMeshNode, (int)ModuleBase::SelectModel::MeshNode); _selectSignalMapper->setMapping(_ui->actionSelectMeshCell, @@ -276,8 +298,9 @@ namespace GUI { (int)ModuleBase::SelectModel::BoxMeshNode); _selectSignalMapper->setMapping(_ui->actionBoxMeshCell, (int)ModuleBase::SelectModel::BoxMeshCell); - connect(_selectSignalMapper, SIGNAL(mapped(int)), this, SIGNAL(selectModelChangedSig(int))); - connect(_selectSignalMapper, SIGNAL(mapped(int)), this, SLOT(selectModelChanged(int))); + + connect(_selectSignalMapper, SIGNAL(mapped(int)), this, SIGNAL(selectModelChangedSig(int))); // 选择模式更改信号 + connect(_selectSignalMapper, SIGNAL(mapped(int)), this, SLOT(selectModelChanged(int))); // 选择模型更改为 // 网格显示模式 // _displayModeSignalMapper = new QSignalMapper(this); connect(_ui->actionDisplayNode, SIGNAL(triggered()), this, SLOT(setMeshDisplay())); @@ -330,6 +353,10 @@ namespace GUI { connect(this, SIGNAL(updatePreGeometryActorSig()), this, SLOT(updatePreGeometryActor())); connect(this, SIGNAL(openPlot()), _signalHandler, SLOT(openPlotFile())); + + // 点云模块 + + } void MainWindow::registerMoudel() @@ -380,7 +407,8 @@ namespace GUI { QString lang = Setting::BusAPI::instance()->getLanguage(); QString title; - ConfigOption::GlobalConfig* g = ConfigOption::ConfigOption::getInstance()->getGlobalConfig(); + ConfigOption::GlobalConfig* g = + ConfigOption::ConfigOption::getInstance()->getGlobalConfig(); title = g->getSoftName(); if(lang.toLower() == "chinese") @@ -466,7 +494,8 @@ namespace GUI { if(_processWindow != nullptr) _processWindow->reTranslate(); - ConfigOption::GlobalConfig* g =ConfigOption::ConfigOption::getInstance()->getGlobalConfig(); + ConfigOption::GlobalConfig* g = + ConfigOption::ConfigOption::getInstance()->getGlobalConfig(); QString title = "MicrowaveMeasurementSimulationSubSystemCAE"; // 修改 标识 LAMPCAE if(lang.toLower() == "chinese") { QString f = g->getChineseName(); @@ -626,16 +655,18 @@ namespace GUI { void MainWindow::on_importPcl() { QStringList suffixlist = IO::IOConfigure::getPclImporters(); - DebugInfo("import point cloud data file format : %s \n ",suffixlist.join(";").toUtf8().constData()); + DebugInfo("import point cloud data file format : %s \n ", + suffixlist.join(";").toUtf8().constData()); // QStringList list = IO::IOConfigure::getMeshImporters(); if(suffixlist.isEmpty()) { QMessageBox::warning(this, tr("Warning"), tr("The MeshPlugin is not installed !")); return; } - QStringList pclsuffix = - ConfigOption::ConfigOption::getInstance()->getMeshConfig()->getImportSuffix(ConfigOption::MeshDataType::PointCloud).split( - ";"); + QStringList pclsuffix = ConfigOption::ConfigOption::getInstance() + ->getMeshConfig() + ->getImportSuffix(ConfigOption::MeshDataType::PointCloud) + .split(";"); QStringList list; for(QString s : pclsuffix) { @@ -667,15 +698,12 @@ namespace GUI { if(fileName.isEmpty()) return; QString pyCode = QString("MainWindow.importPcl(\"%1\",\"%2\",%3)") - .arg(fileName) - .arg(aSuffix) - .arg(modelID); + .arg(fileName) + .arg(aSuffix) + .arg(modelID); Py::PythonAgent::getInstance()->submit(pyCode); - } - - void MainWindow::on_exportGeometry() { QString dir = Setting::BusAPI::instance()->getWorkingDir(); @@ -754,7 +782,8 @@ namespace GUI { Py::PythonAgent::getInstance()->submit(pyCode); } - void MainWindow::on_exportPcl(){ + void MainWindow::on_exportPcl() + { QStringList suffixlist = IO::IOConfigure::getPclExporters(); if(suffixlist.isEmpty()) { QMessageBox::warning(this, tr("Warning"), tr("The MeshPlugin is not installed !")); @@ -766,9 +795,10 @@ namespace GUI { return; } - QStringList meshsuffix = - ConfigOption::ConfigOption::getInstance()->getMeshConfig()->getExportSuffix(ConfigOption::MeshDataType::PointCloud).split( - ";"); + QStringList meshsuffix = ConfigOption::ConfigOption::getInstance() + ->getMeshConfig() + ->getExportSuffix(ConfigOption::MeshDataType::PointCloud) + .split(";"); QStringList list; for(QString s : meshsuffix) { @@ -916,6 +946,10 @@ namespace GUI { Setting::BusAPI::instance()->setGraphOptions(); } + /* + * 选择模式更改为 + * @param model 选择模式 ModuleBase::SelectModel + */ void MainWindow::selectModelChanged(int model) { _ui->actionSelectOff->setChecked(false); @@ -1446,4 +1480,73 @@ namespace GUI { return m_ribbonActionMgr; } + + void MainWindow::on_pclStatisticalRemoveFilter() { + MainWidget::DialogPCLStatisticalRemoveFilter dlg(this); + connect(&dlg, SIGNAL(excuteAlg(QString ,double,double )),this,SLOT(PCLStatisticalRemoveFilterAlg(QString ,double ,double ))); + dlg.exec(); + + } + void MainWindow::on_pclRadiusOutlierRemoval() { + MainWidget::DialogPCLRadiusOutlierRemoval dlg(this); + connect(&dlg, SIGNAL(excuteAlg(QString ,double ,double )),this,SLOT(PCLStatisticalRemoveFilterAlg(QString ,double ,double ))); + dlg.exec(); + } + void MainWindow::on_pclGuassFilter() { + MainWidget::DialogPCLGuassFilter dlg(this); + connect(&dlg, SIGNAL(excuteAlg(QString ,double ,double )),this,SLOT(PCLStatisticalRemoveFilterAlg(QString ,double ,double ))); + dlg.exec(); + + } + void MainWindow::on_pclBilateralFilter() { + MainWidget::DialogPCLBilateralFilter dlg(this); + connect(&dlg, SIGNAL(excuteAlg(QString ,double ,double )),this,SLOT(PCLStatisticalRemoveFilterAlg(QString ,double ,double ))); + dlg.exec(); + + } + void MainWindow::on_pclGPMesh() { + MainWidget::DialogPCLGPMesh dlg(this); + connect(&dlg, SIGNAL(excuteAlg( QString , double , double ,int ,double ,double ,double )),this,SLOT(PCLStatisticalRemoveFilterAlg( QString , double , double ,int ,double ,double ,double ))); + dlg.exec(); + + } + + void MainWindow::PCLStatisticalRemoveFilterAlg(QString componentIds, double MeanK,double StddevThresh) { + + + } + void MainWindow::PCLRadiusOutlierRemovalFilterAlg(QString componentIds, double RadiusSearch, + double MinNeighborsInRadius) + { + emit this->printMessage(Common::Message::Normal,"PCLRadiusOutlierRemovalFilterAlg"); + + + + + + + } + void MainWindow::PCLGuassFilterAlg(QString componentIds, double sigma, double threshold) { + emit this->printMessage(Common::Message::Normal,"PCLGuassFilterAlg"); + + + } + void MainWindow::PCLGPMeshAlg(QString componentIds, double SearchRadius, double Mu, + int MaximumNearestNeighbors, double MaximumSurfaceAngle, + double MaximumAngle, double MinimumAngle) + { + emit this->printMessage(Common::Message::Normal,"PCLGPMeshAlg"); + + + + + + + } + void MainWindow::PCLBilateralFilterAlg(QString componentIds, double sigmaR, double sigmaS) { + emit this->printMessage(Common::Message::Normal,"PCLBilateralFilterAlg"); + + + } + } // namespace GUI diff --git a/src/MainWindow/MainWindow.h b/src/MainWindow/MainWindow.h index 529f789..ffdce0c 100644 --- a/src/MainWindow/MainWindow.h +++ b/src/MainWindow/MainWindow.h @@ -337,6 +337,19 @@ namespace GUI { // 更新工具栏信息 // void updateActionsStates(); + // 统计滤波 + void on_pclStatisticalRemoveFilter(); + // 半径滤波 + void on_pclRadiusOutlierRemoval(); + // 高斯滤波 + void on_pclGuassFilter(); + // 双边滤波 + void on_pclBilateralFilter(); + // GP网格重建 + void on_pclGPMesh(); + + + private slots: /*关闭主窗口 */ void closeWindow(); @@ -398,6 +411,19 @@ namespace GUI { // 创建VTK空间变换窗口 void on_VTKTranslation(); + // StatisticalRemoveFilter + void PCLStatisticalRemoveFilterAlg(QString componentIds,double MeanK,double stddev); + // PCLRadiusOutlierRemoval + void PCLRadiusOutlierRemovalFilterAlg(QString componentIds,double RadiusSearch,double MinNeighborsInRadius); + // PCLGuassFilter + void PCLGuassFilterAlg(QString componentIds,double sigma,double threshold); + // PCLGPMesh + void PCLGPMeshAlg( QString componentIds , double SearchRadius, double Mu,int MaximumNearestNeighbors,double MaximumSurfaceAngle,double MaximumAngle,double MinimumAngle); + // PCLBilateralFilter + void PCLBilateralFilterAlg(QString componentIds,double sigmaR,double sigmaS); + + + private: /*初始化Menu*/ // void initMenu(); diff --git a/src/MainWindow/MainWindow.ui b/src/MainWindow/MainWindow.ui index a0fe06a..701eaae 100644 --- a/src/MainWindow/MainWindow.ui +++ b/src/MainWindow/MainWindow.ui @@ -268,7 +268,7 @@ 0 0 1678 - 17 + 26 @@ -511,9 +511,9 @@ :/PointCloudProcess/PointCloudProcess/images/algorithm/filter.png:/PointCloudProcess/PointCloudProcess/images/algorithm/filter.png - + - + @@ -1909,13 +1909,13 @@ StatisticalRemoveFilter - + - :/PointCloudProcess/PointCloudProcess/images/algorithm/DBSCAN.png:/PointCloudProcess/PointCloudProcess/images/algorithm/DBSCAN.png + :/PointCloudProcess/PointCloudProcess/images/algorithm/KMeans.png:/PointCloudProcess/PointCloudProcess/images/algorithm/KMeans.png - DBRemoveFilter + RadiusOutlierRemoval @@ -1927,13 +1927,13 @@ GuassFilter - + - :/PointCloudProcess/PointCloudProcess/images/algorithm/KMeans.png:/PointCloudProcess/PointCloudProcess/images/algorithm/KMeans.png + :/PointCloudProcess/PointCloudProcess/images/algorithm/DBSCAN.png:/PointCloudProcess/PointCloudProcess/images/algorithm/DBSCAN.png - AverageFilter + BilateralFilter diff --git a/src/MainWindow/MainWindowPy.cpp b/src/MainWindow/MainWindowPy.cpp index f7ab211..035309f 100644 --- a/src/MainWindow/MainWindowPy.cpp +++ b/src/MainWindow/MainWindowPy.cpp @@ -2365,6 +2365,7 @@ void MAINWINDOWAPI importPcl(char* f, char* s, int modelId) { GUI::MainWindowPy::importPcl(f, s, modelId); } + void MAINWINDOWAPI exportPcl(char* f, char* s, int modelId) { GUI::MainWindowPy::exportPcl(f, s, modelId); diff --git a/src/MainWindow/MainWindowPy.h b/src/MainWindow/MainWindowPy.h index a1ad144..2da9867 100644 --- a/src/MainWindow/MainWindowPy.h +++ b/src/MainWindow/MainWindowPy.h @@ -43,6 +43,8 @@ namespace GUI { static void quit(); static void solveProject(int projectIndex, int solverIndex); static void createSet(const char* name, const char* type, const char* idstring); + + static void createGeoComponent(char* name, char* type, char* strgIDs, char* striIDs); static void createVTKTransform(const char* componentIds, const char* rotate, const char* moveLocation, const char* scale); @@ -208,6 +210,16 @@ namespace GUI { int val); static void deleteGeometry(int id); + // 点云操作 + + + // 模型仿真操作 + + + // 数据分析 + + + private: static MainWindow* _mainWindow; static SignalHandler* _signalHander; @@ -403,6 +415,12 @@ void MAINWINDOWAPI script_Properties_streamline_reflection(int id, char* type, i void MAINWINDOWAPI script_Properties_streamline_reflectionAxes(int id, char* type, int obj_id, int val); void MAINWINDOWAPI deleteGeometry(int id); + +/// 点云相关模型 + + + + } #endif \ No newline at end of file diff --git a/src/MainWindow/SARibbonMWUi.cpp b/src/MainWindow/SARibbonMWUi.cpp index 4ad356f..57744d1 100644 --- a/src/MainWindow/SARibbonMWUi.cpp +++ b/src/MainWindow/SARibbonMWUi.cpp @@ -656,37 +656,38 @@ namespace Ui { actionPCLStatisticalRemoveFilter = new QAction(MainWindow); actionPCLStatisticalRemoveFilter->setObjectName(QString::fromUtf8("actionPCLStatisticalRemoveFilter")); - QIcon icon110; - icon110.addFile(QString::fromUtf8(":/PointCloudProcess/PointCloudProcess/images/algorithm/Histogram.png"), QSize(), QIcon::Normal, QIcon::Off); - actionPCLStatisticalRemoveFilter->setIcon(icon110); - actionPCLDBRemoveFilter = new QAction(MainWindow); - actionPCLDBRemoveFilter->setObjectName(QString::fromUtf8("actionPCLDBRemoveFilter")); - QIcon icon111; - icon111.addFile(QString::fromUtf8(":/PointCloudProcess/PointCloudProcess/images/algorithm/DBSCAN.png"), QSize(), QIcon::Normal, QIcon::Off); - actionPCLDBRemoveFilter->setIcon(icon111); - actionPCLGuassFilter = new QAction(MainWindow); - actionPCLGuassFilter->setObjectName(QString::fromUtf8("actionPCLGuassFilter")); - QIcon icon112; - icon112.addFile(QString::fromUtf8(":/PointCloudProcess/PointCloudProcess/images/algorithm/nihe.png"), QSize(), QIcon::Normal, QIcon::Off); - actionPCLGuassFilter->setIcon(icon112); - actionPCLAverageFilter = new QAction(MainWindow); - actionPCLAverageFilter->setObjectName(QString::fromUtf8("actionPCLAverageFilter")); - QIcon icon113; - icon113.addFile(QString::fromUtf8(":/PointCloudProcess/PointCloudProcess/images/algorithm/KMeans.png"), QSize(), QIcon::Normal, QIcon::Off); - actionPCLAverageFilter->setIcon(icon113); - actionPCLGPMesh = new QAction(MainWindow); - actionPCLGPMesh->setObjectName(QString::fromUtf8("actionPCLGPMesh")); - QIcon icon114; - icon114.addFile(QString::fromUtf8(":/PointCloudProcess/PointCloudProcess/images/grey.png"), QSize(), QIcon::Normal, QIcon::Off); - actionPCLGPMesh->setIcon(icon114); - actionLoadFile = new QAction(MainWindow); - actionLoadFile->setObjectName(QString::fromUtf8("actionLoadFile")); - centralwidget = new QWidget(MainWindow); - centralwidget->setObjectName(QString::fromUtf8("centralwidget")); - gridLayout = new QGridLayout(centralwidget); - gridLayout->setObjectName(QString::fromUtf8("gridLayout")); - mdiArea = new QMdiArea(centralwidget); - mdiArea->setObjectName(QString::fromUtf8("mdiArea")); + QIcon icon110; + icon110.addFile(QString::fromUtf8(":/PointCloudProcess/PointCloudProcess/images/algorithm/Histogram.png"), QSize(), QIcon::Normal, QIcon::Off); + actionPCLStatisticalRemoveFilter->setIcon(icon110); + actionPCLRadiusOutlierRemoval = new QAction(MainWindow); + actionPCLRadiusOutlierRemoval->setObjectName(QString::fromUtf8("actionPCLRadiusOutlierRemoval")); + QIcon icon111; + icon111.addFile(QString::fromUtf8(":/PointCloudProcess/PointCloudProcess/images/algorithm/KMeans.png"), QSize(), QIcon::Normal, QIcon::Off); + actionPCLRadiusOutlierRemoval->setIcon(icon111); + actionPCLGuassFilter = new QAction(MainWindow); + actionPCLGuassFilter->setObjectName(QString::fromUtf8("actionPCLGuassFilter")); + QIcon icon112; + icon112.addFile(QString::fromUtf8(":/PointCloudProcess/PointCloudProcess/images/algorithm/nihe.png"), QSize(), QIcon::Normal, QIcon::Off); + actionPCLGuassFilter->setIcon(icon112); + actionPCLBilateralFilter = new QAction(MainWindow); + actionPCLBilateralFilter->setObjectName(QString::fromUtf8("actionPCLBilateralFilter")); + QIcon icon113; + icon113.addFile(QString::fromUtf8(":/PointCloudProcess/PointCloudProcess/images/algorithm/DBSCAN.png"), QSize(), QIcon::Normal, QIcon::Off); + actionPCLBilateralFilter->setIcon(icon113); + actionPCLGPMesh = new QAction(MainWindow); + actionPCLGPMesh->setObjectName(QString::fromUtf8("actionPCLGPMesh")); + QIcon icon114; + icon114.addFile(QString::fromUtf8(":/PointCloudProcess/PointCloudProcess/images/grey.png"), QSize(), QIcon::Normal, QIcon::Off); + actionPCLGPMesh->setIcon(icon114); + actionLoadFile = new QAction(MainWindow); + actionLoadFile->setObjectName(QString::fromUtf8("actionLoadFile")); + centralwidget = new QWidget(MainWindow); + centralwidget->setObjectName(QString::fromUtf8("centralwidget")); + gridLayout = new QGridLayout(centralwidget); + gridLayout->setObjectName(QString::fromUtf8("gridLayout")); + mdiArea = new QMdiArea(centralwidget); + mdiArea->setObjectName(QString::fromUtf8("mdiArea")); + gridLayout->addWidget(mdiArea, 0, 0, 1, 1); @@ -882,9 +883,9 @@ namespace Ui { PCLFile_operator_pannel->addMediumAction(actionLoadPointCloud); PCLFile_operator_pannel->addMediumAction(actionSavePointCloud); PCLFilter_pannel->addMediumAction(actionPCLStatisticalRemoveFilter); - PCLFilter_pannel->addMediumAction(actionPCLDBRemoveFilter); + PCLFilter_pannel->addMediumAction(actionPCLRadiusOutlierRemoval); PCLFilter_pannel->addMediumAction(actionPCLGuassFilter); - PCLFilter_pannel->addMediumAction(actionPCLAverageFilter); + PCLFilter_pannel->addMediumAction(actionPCLBilateralFilter); PCLReSurfaceMesh_pannel->addLargeAction(actionPCLGPMesh); } @@ -1158,9 +1159,9 @@ namespace Ui { actionFilter->setText(QCoreApplication::translate("MainWindow", "Filter", nullptr)); actionPointCloudStatisticalRemove->setText(QCoreApplication::translate("MainWindow", "StatisticalRemove", nullptr)); actionPCLStatisticalRemoveFilter->setText(QCoreApplication::translate("MainWindow", "StatisticalRemoveFilter", nullptr)); - actionPCLDBRemoveFilter->setText(QCoreApplication::translate("MainWindow", "DBRemoveFilter", nullptr)); - actionPCLGuassFilter->setText(QCoreApplication::translate("MainWindow", "GuassFilter", nullptr)); - actionPCLAverageFilter->setText(QCoreApplication::translate("MainWindow", "AverageFilter", nullptr)); + actionPCLRadiusOutlierRemoval->setText(QCoreApplication::translate("MainWindow", "RadiusOutlierRemoval", nullptr)); + actionPCLGuassFilter->setText(QCoreApplication::translate("MainWindow", "GuassFilter", nullptr)); + actionPCLBilateralFilter->setText(QCoreApplication::translate("MainWindow", "BilateralFilter", nullptr)); actionPCLGPMesh->setText(QCoreApplication::translate("MainWindow", "GPMesh", nullptr)); actionLoadFile->setText(QCoreApplication::translate("MainWindow", "LoadFile", nullptr)); } // retranslateUi diff --git a/src/ModuleBase/PreWindowInteractorStyle.cpp b/src/ModuleBase/PreWindowInteractorStyle.cpp index 9e17c0c..dae386b 100644 --- a/src/ModuleBase/PreWindowInteractorStyle.cpp +++ b/src/ModuleBase/PreWindowInteractorStyle.cpp @@ -317,7 +317,7 @@ namespace ModuleBase { // emit higtLightActorDisplayPoint(true); emit clearAllHighLight(); - int *clickPos = this->GetInteractor()->GetEventPosition(); + int *clickPos = this->GetInteractor()->GetEventPosition(); // 鼠标坐标 vtkSmartPointer picker = vtkSmartPointer::New(); picker->Pick(clickPos[0], clickPos[1], 0, this->GetDefaultRenderer()); if (picker->GetPointId() >= 0) @@ -327,8 +327,8 @@ namespace ModuleBase int id = picker->GetPointId(); vtkDataSet *dataset = picker->GetActor()->GetMapper()->GetInput(); vtkDataArray *idArray = dataset->GetPointData()->GetArray("IDS"); - double *k_index = idArray->GetTuple2(id); - _selectItems.insert(k_index[0], k_index[1]); + double *k_index = idArray->GetTuple2(id); // 参考 meshKernalViewObject.cpp:generateIDProp 函数方法, + _selectItems.insert(k_index[0], k_index[1]); // (网格id,点序号) emit highLight(&_selectItems); } } diff --git a/src/PluginMeshDataExchange/CMakeLists.txt b/src/PluginMeshDataExchange/CMakeLists.txt index 4bfb247..126a6be 100644 --- a/src/PluginMeshDataExchange/CMakeLists.txt +++ b/src/PluginMeshDataExchange/CMakeLists.txt @@ -99,7 +99,7 @@ target_compile_definitions(PluginMeshDataExchange PRIVATE "NOMINMAX") # 禁用vc target_compile_definitions(PluginMeshDataExchange PRIVATE "MESHDATAEXCHANGEPLUGIN_API") list(APPEND _depend_library - Common PythonModule DataProperty MeshData Material Geometry BCBase ConfigOptions SelfDefObject ModelData ModuleBase PluginManager GeometryCommand GeometryWidgets IO MainWidgets MainWindow) + Common PointCloudOperator PythonModule DataProperty MeshData Material Geometry BCBase ConfigOptions SelfDefObject ModelData ModuleBase PluginManager GeometryCommand GeometryWidgets IO MainWidgets MainWindow) diff --git a/src/PluginMeshDataExchange/PointClouddataExchange.cpp b/src/PluginMeshDataExchange/PointClouddataExchange.cpp index 1180761..977e412 100644 --- a/src/PluginMeshDataExchange/PointClouddataExchange.cpp +++ b/src/PluginMeshDataExchange/PointClouddataExchange.cpp @@ -1,6 +1,7 @@ -// -// Created by 30453 on 2024/4/1. -// +/* + * Created by 30453 on 2024/4/1 + * 2024.4.3 陈增辉 补充了点云文件输入输出功能,但是并未考虑彩色点云的情况; + * **/ #include "PointClouddataExchange.h" #include "MeshData/meshSingleton.h" @@ -28,8 +29,8 @@ #include #include #include +#include "PointCloudOperator/PointCloudCommon.h" -// debug #include "Common/DebugLogger.h" @@ -78,6 +79,7 @@ namespace MeshData { if (suffix == "pcd") { dataset = readPCD(); + DebugInfo("pcd data point count %d \n",dataset->GetNumberOfPoints()); } else if (suffix == "ply") { @@ -138,15 +140,20 @@ namespace MeshData { { if (!_threadRuning) return nullptr; - // 打开点云数据 - - pcl::PointCloud::Ptr cloud_with_rgba(new pcl::PointCloud); - int readstate =pcl::io::loadPCDFile(_fileName.toUtf8().constData(), *cloud_with_rgba); // 读取数据 - vtkPolyData* polydata=nullptr; - polydata=vtkPolyData::New(); // 创建新的指针,智能指针会释放 - pcl::io::pointCloudTovtkPolyData(*cloud_with_rgba,polydata); - vtkDataSet* tempvtkdataset= vtkDataSet::SafeDownCast(polydata); // 默认完成 vtkpolydata --> vtkdataset - + pcl::PCLPointCloud2::Ptr cloud2(new pcl::PCLPointCloud2); + QTextCodec *codec = QTextCodec::codecForName("GB18030"); + QByteArray ba = codec->fromUnicode(_fileName); + std::string inFileName=ba.data(); + vtkSmartPointer polydata=vtkSmartPointer::New(); + if(pcl::io::loadPCDFile(inFileName,*cloud2)==0){ + pcl::io::pointCloudTovtkPolyData(cloud2,polydata); + }else { + return nullptr; + } + vtkPolyData* tempvtkdataset=vtkPolyData::New(); + tempvtkdataset->DeepCopy(polydata); + DebugInfo("deep copy sucessfully!\n"); + DebugInfo("pcd data point count %d \n",tempvtkdataset->GetNumberOfPoints()); return tempvtkdataset; // 默认完成 vtkpolydata --> vtkdataset } vtkDataSet* PointClouddataExchange::readPLY() @@ -154,15 +161,21 @@ namespace MeshData { if (!_threadRuning) return nullptr; - // 打开点云数据 - - pcl::PointCloud::Ptr cloud_with_rgba(new pcl::PointCloud); - int readstate =pcl::io::loadPLYFile(_fileName.toUtf8().constData(), *cloud_with_rgba); // 读取数据 - vtkPolyData* polydata=nullptr; - polydata=vtkPolyData::New(); // 创建新的指针,智能指针会释放 - pcl::io::pointCloudTovtkPolyData(*cloud_with_rgba,polydata); - vtkDataSet* tempvtkdataset= vtkDataSet::SafeDownCast(polydata); // 默认完成 vtkpolydata --> vtkdataset + pcl::PCLPointCloud2::Ptr cloud2(new pcl::PCLPointCloud2); + QTextCodec *codec = QTextCodec::codecForName("GB18030"); + QByteArray ba = codec->fromUnicode(_fileName); + std::string inFileName=ba.data(); + vtkSmartPointer polydata=vtkSmartPointer::New(); + if(pcl::io::loadPLYFile(inFileName,*cloud2)==0){ + pcl::io::pointCloudTovtkPolyData(cloud2,polydata); + }else { + return nullptr; + } + vtkPolyData* tempvtkdataset=vtkPolyData::New(); + tempvtkdataset->DeepCopy(polydata); + DebugInfo("deep copy sucessfully!\n"); + DebugInfo("pcd data point count %d \n",tempvtkdataset->GetNumberOfPoints()); return tempvtkdataset; // 默认完成 vtkpolydata --> vtkdataset } @@ -218,12 +231,11 @@ namespace MeshData { { QTextCodec *codec = QTextCodec::codecForName("GB18030"); QByteArray ba = codec->fromUnicode(_fileName); - DebugInfo("PointClouddataExchange::writePCD FileName :%s ",ba); // 使用 vtkGeometryFilter 提取几何信息并转换为 vtkPolyData vtkSmartPointer geometryFilter = vtkSmartPointer::New(); - DebugInfo("PointClouddataExchange::writePCD Filter prepare :ok modelID :%d\n",_modelId); + if (_modelId > 0) { @@ -248,7 +260,7 @@ namespace MeshData { if (kernal != nullptr) { vtkDataSet *dataset = kernal->getMeshData(); - DebugInfo("PointClouddataExchange::writePCD writer over : iKernal %d , %d is nullptr ,points Count %d\n",i,(int)(dataset==nullptr),dataset->GetNumberOfPoints()); + if (dataset != nullptr) geometryFilter->AddInputData(dataset); } @@ -256,14 +268,14 @@ namespace MeshData { } geometryFilter->Update(); vtkSmartPointer outputDataSet = geometryFilter->GetOutput(); - DebugInfo("PointClouddataExchange::writePCD writer over :ok outputDataSet Point Count : %d\n",outputDataSet->GetNumberOfPoints()); + // 将输出的点云数据集转换为 PCL 格式 pcl::PointCloud::Ptr cloud_with_rgba(new pcl::PointCloud); pcl::io::vtkPolyDataToPointCloud(outputDataSet,*cloud_with_rgba); - DebugInfo("PointClouddataExchange::writePCD writer over :ok cloud_with_rgba Point Count : %d\n",cloud_with_rgba->size()); + std::string outFileName=ba.data(); pcl::io::savePCDFileBinary(outFileName,*cloud_with_rgba); - DebugInfo("PointClouddataExchange::writePCD writer over :ok \n"); + return true; } bool PointClouddataExchange::writePLY() @@ -271,10 +283,8 @@ namespace MeshData { QTextCodec *codec = QTextCodec::codecForName("GB18030"); QByteArray ba = codec->fromUnicode(_fileName); vtkUnstructuredGrid *ungird = vtkUnstructuredGrid::New(); - vtkSmartPointer filter = vtkSmartPointer::New(); // 使用 vtkGeometryFilter 提取几何信息并转换为 vtkPolyData - vtkSmartPointer geometryFilter = vtkSmartPointer::New(); - + vtkSmartPointer geometryFilter = vtkSmartPointer::New(); if (_modelId > 0) { @@ -303,7 +313,7 @@ namespace MeshData { } } } - filter->Update(); + geometryFilter->Update(); vtkSmartPointer polyData = geometryFilter->GetOutput(); pcl::PointCloud::Ptr cloud_with_rgba(new pcl::PointCloud); pcl::io::vtkPolyDataToPointCloud(polyData,*cloud_with_rgba); diff --git a/src/PluginMeshDataExchange/PointClouddataExchange.h b/src/PluginMeshDataExchange/PointClouddataExchange.h index 711ead3..d9377a1 100644 --- a/src/PluginMeshDataExchange/PointClouddataExchange.h +++ b/src/PluginMeshDataExchange/PointClouddataExchange.h @@ -1,6 +1,7 @@ -// -// Created by 30453 on 2024/4/1. -// +/* +* Created by 30453 on 2024/4/1 +* 2024.4.3 陈增辉 补充了点云文件输入输出功能,但是并未考虑彩色点云的情况; +* **/ #ifndef LAMPCAE_POINTCLOUDDATAEXCHANGE_H #define LAMPCAE_POINTCLOUDDATAEXCHANGE_H @@ -116,8 +117,6 @@ #include - - namespace MeshData { class MeshData; diff --git a/src/PluginMeshDataExchange/meshDataExchangePlugin.cpp b/src/PluginMeshDataExchange/meshDataExchangePlugin.cpp index 4a7310a..f8e96dd 100644 --- a/src/PluginMeshDataExchange/meshDataExchangePlugin.cpp +++ b/src/PluginMeshDataExchange/meshDataExchangePlugin.cpp @@ -20,6 +20,7 @@ #include GUI::MainWindow* MeshData::MeshDataExchangePlugin::_mainwindow = nullptr; + namespace MeshData { MeshDataExchangePlugin::MeshDataExchangePlugin(GUI::MainWindow* m) { diff --git a/src/PointCloudData/PointCloudChecker.cpp b/src/PointCloudData/PointCloudChecker.cpp deleted file mode 100644 index 708ca4b..0000000 --- a/src/PointCloudData/PointCloudChecker.cpp +++ /dev/null @@ -1,321 +0,0 @@ -#include "PointCloudChecker.h" -#include "PointCloudKernal.h" -#include "PointCloudSingleton.h" -#include -#include -#include -#include -#include -#include -#include -#include - -namespace PointCloudData -{ -PointCloudChecker::PointCloudChecker() -{ - _PointCloudData = PointCloudData::getInstance(); - _cellQuality = vtkSmartPointer::New(); - _qualityArray = vtkSmartPointer::New(); - _cellQuality->SetUndefinedQuality(-1e66); - _cellQuality->SetUnsupportedGeometry(-1e66); -} -PointCloudChecker::~PointCloudChecker() -{ - // const int n = _resultList.size(); - // for (int i = 0; i < n; ++i) - // { - // vtkDataSet* d = _resultList.at(i); - // d->Delete(); - // } - // _resultList.clear(); -} - -void PointCloudChecker::run() -{ - _qualityArray->SetNumberOfValues(0); - _inputCount.clear(); - _checkedCount.clear(); - // const int nc = _resultList.size(); - // for (int i = 0; i < nc; ++i) - // { - // vtkDataSet* d = _resultList.at(i); - // d->Delete(); - // } - _resultList.clear(); - - if (_measure == NONE) return; - const int n = _PointCloudData->getKernalCount(); - for (int i = 0; i < n; ++i) - { - PointCloudKernal* k = _PointCloudData->getKernalAt(i); - this->checkKernal(k); - } - _qualityArray->Modified(); - countResult(); -} - -void PointCloudChecker::setQualityMeasure(QualityMeasure m) -{ - _measure = m; - _cellQuality->SetQualityMeasure(m); -} - -void PointCloudChecker::checkKernal(PointCloudKernal* k) -{ - vtkDataSet* checkingDataset = k->getPointCloudData(); - _cellQuality->SetInputData(checkingDataset); - _cellQuality->Update(); - vtkDataSet* res = _cellQuality->GetOutput(); - - // vtkUnstructuredGrid* g = vtkUnstructuredGrid::New(); - // g->DeepCopy(res); - _resultList.append(res); - - this->collectInfo(res); - -} - -void PointCloudChecker::collectInfo(vtkDataSet* res) -{ - vtkDataArray* qua = res->GetCellData()->GetScalars("CellQuality"); - - const int n = res->GetNumberOfCells(); - - for (int i = 0; i < n; ++i) - { - vtkCell* cell = res->GetCell(i); - VTKCellType type = (VTKCellType)cell->GetCellType(); - ++_inputCount[type]; - - double q = qua->GetComponent(i, 0); - if (q > -1e65) - { - _qualityArray->InsertNextValue(q); - _checkedCount[type].append(q); - } - } -} - -QString PointCloudChecker::VTKCellTypeToString(VTKCellType type) -{ - QString stype("Undefined"); - - switch (type) - { - case VTK_VERTEX: - stype = "Vertex"; break; - case VTK_POLY_VERTEX: - stype = "PolyVertex"; break; - case VTK_LINE: - stype = "Line"; break; - case VTK_POLY_LINE: - stype = "PolyLine"; break; - case VTK_TRIANGLE: - stype = "Tri3"; break; - case VTK_TRIANGLE_STRIP: - stype = "Tri3Strip"; break; - case VTK_POLYGON: - stype = "Polygon"; break; - case VTK_PIXEL: - stype = "Pixel"; break; - case VTK_QUAD: - stype = "Quad4"; break; - case VTK_TETRA: - stype = "Tet4"; break; - case VTK_VOXEL: - stype = "Voxel"; break; - case VTK_HEXAHEDRON: - stype = "Hex8"; break; - case VTK_WEDGE: - stype = "Wedge"; break; - case VTK_PYRAMID: - stype = "Pyramid"; break; - case VTK_PENTAGONAL_PRISM: - stype = "PentaPrism"; break; - case VTK_HEXAGONAL_PRISM: - stype = "HexaPrism"; break; - - - case VTK_QUADRATIC_EDGE: - stype = "QuaEdge"; break; - case VTK_QUADRATIC_TRIANGLE: - stype = "QuaTriangle"; break; - case VTK_QUADRATIC_LINEAR_QUAD: - stype = "QuaLinearQuad"; break; - case VTK_QUADRATIC_QUAD: - stype = "QuaQuad"; break; - case VTK_BIQUADRATIC_QUAD: - stype = "BiquaQuad"; break; - case VTK_QUADRATIC_TETRA: - stype = "QuaTetra"; break; - case VTK_QUADRATIC_PYRAMID: - stype = "QuaPyramid"; break; - case VTK_QUADRATIC_HEXAHEDRON: - stype = "QuaHexa"; break; - case VTK_BIQUADRATIC_QUADRATIC_HEXAHEDRON: - stype = "BiquaQuaHexa"; break; - case VTK_TRIQUADRATIC_HEXAHEDRON: - stype = "TriquaHexa"; break; - case VTK_QUADRATIC_LINEAR_WEDGE: - stype = "QuaLinearWedge"; break; - case VTK_QUADRATIC_WEDGE: - stype = "QuaWedge"; break; - case VTK_BIQUADRATIC_QUADRATIC_WEDGE: - stype = "BiquaQuaWedge"; break; - default: - break; - } - - return stype; -} - -QList PointCloudChecker::getInputCellType() -{ - return _inputCount.keys(); -} - -int PointCloudChecker::getInputCellCount(VTKCellType type) -{ - int count = 0; - if (_inputCount.contains(type)) - count = _inputCount.value(type); - return count; -} - -int PointCloudChecker::getInputCellCount() -{ - int count = 0; - QList typelist = this->getInputCellType(); - const int n = typelist.size(); - for (int i = 0; i < n; ++i) - { - VTKCellType t = typelist.at(i); - count += this->getInputCellCount(t); - } - return count; -} - -QList PointCloudChecker::getQualityCellType() -{ - return _checkedCount.keys(); -} - -int PointCloudChecker::gettQualityCellCount(VTKCellType type) -{ - int count = 0; - if (_checkedCount.contains(type)) - count = _checkedCount.value(type).size(); - return count; -} - -int PointCloudChecker::gettQualityCellCount() -{ - int count = 0; - QList typelist = this->getQualityCellType(); - const int n = typelist.size(); - for (int i = 0; i < n; ++i) - { - VTKCellType t = typelist.at(i); - count += this->gettQualityCellCount(t); - } - return count; -} - -void PointCloudChecker::getQualityRange(double* range) -{ - _qualityArray->GetRange(range); - // range[0] = r[0]; - // range[1] = r[1]; -} - -double PointCloudChecker::getAverageQuality() -{ - const int n = _qualityArray->GetNumberOfValues(); - if (n == 0) return -1e66; - double sum = 0; - for (int i = 0; i < n; ++i) - { - sum += _qualityArray->GetValue(i); - } - return sum / n; -} - -void PointCloudChecker::countResult() -{ - _ticks.clear(); - _cellCount.clear(); - const int count = gettQualityCellCount(); - if (count == 0) return; - - double range[2]; - this->getQualityRange(range); - - if (range[1] - range[0] < 1e-8) - { - _ticks.append((range[0] + range[1]) / 2); - QList types = this->getQualityCellType(); - for (int i = 0; i < types.size(); ++i) - { - VTKCellType t = types.at(i); - int n = this->gettQualityCellCount(t); - _cellCount[t].append(n); - } - return; - } - - QList types = this->getQualityCellType(); - for (int i = 0; i < types.size(); ++i) - { - VTKCellType t = types.at(i); - //int n = this->gettQualityCellCount(t); - _cellCount[t].resize(10); - } - double ran = range[1] - range[0]; - double step = ran / 10.0; - for (int i = 0; i < 10; ++i) - _ticks.append(range[0] + step / 2 + step*i); - - for (int i = 0; i < types.size(); ++i) - { - VTKCellType t = types.at(i); - QList qual = _checkedCount[t]; - int cellcount = qual.size(); - for (int c = 0; c < cellcount; ++c) - { - double v = qual.at(c); - for (int j = 0; j < 10; ++j) - { - double ti = _ticks.at(j); - if (v >= ti - step / 2 && v < ti + step / 2) - { - ++_cellCount[t][j]; - continue; - } - } - } - - } -} - -QVector PointCloudChecker::getTicks() -{ - return _ticks; -} - -QVector PointCloudChecker::getCountList(VTKCellType t) -{ - QVector d; - if (_cellCount.contains(t)) - d = _cellCount.value(t); - return d; -} - -QList PointCloudChecker::getResultList() -{ - return _resultList; -} - - - -} diff --git a/src/PointCloudData/PointCloudChecker.h b/src/PointCloudData/PointCloudChecker.h deleted file mode 100644 index def90c1..0000000 --- a/src/PointCloudData/PointCloudChecker.h +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef PointCloudCHECKER_H -#define PointCloudCHECKER_H - -#include -#include "PointCloudDataAPI.h" -#include -#include -#include -#include -#include -#include - -#define BARCOUNT 10; - -class vtkDataSet; -class vtkCell; -class vtkCellQuality; -class vtkDoubleArray; - -namespace PointCloudData -{ - class PointCloudData; - class PointCloudKernal; - - enum QualityMeasure - { - NONE = 0, - AREA, - ASPECT_BETA, - ASPECT_FROBENIUS, - ASPECT_GAMMA, - ASPECT_RATIO, - COLLAPSE_RATIO, - CONDITION, - DIAGONAL, - DIMENSION, - DISTORTION, - EDGE_RATIO, - JACOBIAN, - MAX_ANGLE, - MAX_ASPECT_FROBENIUS, - MAX_EDGE_RATIO, - MED_ASPECT_FROBENIUS, - MIN_ANGLE, - NORMAL, - ODDY, - RADIUS_RATIO, - RELATIVE_SIZE_SQUARED, - SCALED_JACOBIAN, - SHAPE, - SHAPE_AND_SIZE, - SHEAR, - SHEAR_AND_SIZE, - SKEW, - STRETCH, - TAPER, - VOLUME, - WARPAGE - }; - - class POINTCLOUDDATAAPI PointCloudChecker :public QThread - { - public: - PointCloudChecker(); - ~PointCloudChecker(); - static QString VTKCellTypeToString(VTKCellType type); - - virtual void run(); - void setQualityMeasure(QualityMeasure m); - - QList getInputCellType(); - int getInputCellCount(VTKCellType type); - int getInputCellCount(); - - QList getQualityCellType(); - int gettQualityCellCount(VTKCellType type); - int gettQualityCellCount(); - - void getQualityRange(double* r); - double getAverageQuality(); - - QVector getTicks(); - QVector getCountList(VTKCellType t); - - QList getResultList(); - - private: - void checkKernal(PointCloudKernal* k); - void collectInfo(vtkDataSet* outInfo); - void countResult(); - - - private: - vtkSmartPointer _cellQuality{}; - PointCloudData* _PointCloudData{}; - QualityMeasure _measure{ NONE }; - - vtkSmartPointer _qualityArray{}; - QHash _inputCount{}; - QHash> _checkedCount{}; - QList _resultList{}; - - QVector _ticks{}; - QHash> _cellCount{}; - - - }; - - -} - - - -#endif \ No newline at end of file diff --git a/src/PointCloudData/PointCloudCommon.cpp b/src/PointCloudData/PointCloudCommon.cpp deleted file mode 100644 index f6168b3..0000000 --- a/src/PointCloudData/PointCloudCommon.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "PointCloudCommon.h" -#include - - -int VTKCellTypeToDim(int type) -{ - int dim = -1; - switch (VTKCellType(type)) - { - case VTK_EMPTY_CELL: break; - case VTK_VERTEX: - case VTK_POLY_VERTEX: dim = 0; break; - case VTK_LINE: - case VTK_POLY_LINE: dim = 1; break; - case VTK_TRIANGLE: - case VTK_TRIANGLE_STRIP: - case VTK_POLYGON: - case VTK_PIXEL: - case VTK_QUAD: dim = 2; break; - case VTK_TETRA: - case VTK_VOXEL: - case VTK_HEXAHEDRON: - case VTK_WEDGE: - case VTK_PYRAMID: - case VTK_PENTAGONAL_PRISM: - case VTK_HEXAGONAL_PRISM: dim = 3; break; - - // Quadratic, isoparametric cells - case VTK_QUADRATIC_EDGE: dim = 1; break; - case VTK_QUADRATIC_TRIANGLE: - case VTK_QUADRATIC_QUAD: - case VTK_QUADRATIC_POLYGON: dim = 2; break; - case VTK_QUADRATIC_TETRA: - case VTK_QUADRATIC_HEXAHEDRON: - case VTK_QUADRATIC_WEDGE: - case VTK_QUADRATIC_PYRAMID: dim = 3; break; - case VTK_BIQUADRATIC_QUAD: dim = 2; break; - case VTK_TRIQUADRATIC_HEXAHEDRON: dim = 3; break; - case VTK_QUADRATIC_LINEAR_QUAD: dim = 2; break; - case VTK_QUADRATIC_LINEAR_WEDGE: - case VTK_BIQUADRATIC_QUADRATIC_WEDGE: - case VTK_BIQUADRATIC_QUADRATIC_HEXAHEDRON: dim = 3; break; - case VTK_BIQUADRATIC_TRIANGLE: dim = 2; break; - - // Cubic, isoparametric cell - case VTK_CUBIC_LINE: dim = 1; break; - - // Special class of cells formed by convex group of points - case VTK_CONVEX_POINT_SET: dim = 0; break; - - // Polyhedron cell (consisting of polygonal faces) - case VTK_POLYHEDRON: dim = 2; break; - - // Higher order cells in parametric form - case VTK_PARAMETRIC_CURVE: dim = 1; break; - case VTK_PARAMETRIC_SURFACE: - case VTK_PARAMETRIC_TRI_SURFACE: - case VTK_PARAMETRIC_QUAD_SURFACE: dim = 2; break; - case VTK_PARAMETRIC_TETRA_REGION: - case VTK_PARAMETRIC_HEX_REGION: dim = 3; break; - - // Higher order cells - case VTK_HIGHER_ORDER_EDGE: dim = 1; break; - case VTK_HIGHER_ORDER_TRIANGLE: - case VTK_HIGHER_ORDER_QUAD: - case VTK_HIGHER_ORDER_POLYGON: dim = 2; break; - case VTK_HIGHER_ORDER_TETRAHEDRON: - case VTK_HIGHER_ORDER_WEDGE: - case VTK_HIGHER_ORDER_PYRAMID: - case VTK_HIGHER_ORDER_HEXAHEDRON: dim = 3; break; - - case VTK_NUMBER_OF_CELL_TYPES: dim = -1; break; - default: break; - } - return dim; -} \ No newline at end of file diff --git a/src/PointCloudData/PointCloudCommon.h b/src/PointCloudData/PointCloudCommon.h deleted file mode 100644 index 3402c6d..0000000 --- a/src/PointCloudData/PointCloudCommon.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _MESHCOMMON_H_ -#define _MESHCOMMON_H_ - -#include "PointCloudDataAPI.h" -#include - -extern "C" -{ - int MESHDATAAPI VTKCellTypeToDim(int ctype); - -} - - -#endif \ No newline at end of file diff --git a/src/PointCloudData/PointCloudDataAPI.h b/src/PointCloudData/PointCloudDataAPI.h deleted file mode 100644 index 90e1aef..0000000 --- a/src/PointCloudData/PointCloudDataAPI.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef _POINTCLOUDDATAAPI_H_ -#define _POINTCLOUDDATAAPI_H_ - -#include - - -#if defined(POINTCLOUDDATA_API) -#define POINTCLOUDDATAAPI Q_DECL_EXPORT -#else -#define POINTCLOUDDATAAPI Q_DECL_IMPORT -#endif - -#endif diff --git a/src/PointCloudData/PointCloudFactory.cpp b/src/PointCloudData/PointCloudFactory.cpp deleted file mode 100644 index f4cdc38..0000000 --- a/src/PointCloudData/PointCloudFactory.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "PointCloudFactory.h" -#include "PointCloudSet.h" -#include "CgnsBCZone.h" -#include "CgnsFamily.h" - -namespace PointCloudData -{ - QHash PointCloudFactory::_createSetFun = QHash(); - - PointCloudData::PointCloudSet* PointCloudFactory::CreatePointCloudSet(int type) - { - SetType stype = (SetType)type; - PointCloudSet* set = nullptr; - switch (stype) - { - case PointCloudData::Node: - set = new PointCloudSet("", Node); break; - case PointCloudData::Element: - set = new PointCloudSet("", Element); break; - case PointCloudData::Family: - set = new CgnsFamily; break; - case PointCloudData::BCZone: - set = new CgnsBCZone; break; - default: - CREATEPointCloudSET fun = _createSetFun.value(type); - if (fun!= nullptr) - set = fun(type); - break; - } - return set; - - } - - void PointCloudFactory::registerFunction(int type, CREATEPointCloudSET fun) - { - _createSetFun.insert(type, fun); - } - - void PointCloudFactory::remove(int type) - { - _createSetFun.remove(type); - } - -} \ No newline at end of file diff --git a/src/PointCloudData/PointCloudFactory.h b/src/PointCloudData/PointCloudFactory.h deleted file mode 100644 index d46a68b..0000000 --- a/src/PointCloudData/PointCloudFactory.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _PointCloudFACTORY_H__ -#define _PointCloudFACTORY_H__ - -#include "PointCloudSet.h" -#include - -typedef PointCloudData::PointCloudSet* (*CREATEPointCloudSET)(int); - -namespace PointCloudData -{ - class POINTCLOUDDATAAPI PointCloudFactory - { - public: - static PointCloudSet* CreatePointCloudSet(int type); - static void registerFunction(int type, CREATEPointCloudSET fun); - static void remove(int type); - - - private: - static QHash _createSetFun; - }; - -} - - - -#endif \ No newline at end of file diff --git a/src/PointCloudData/PointCloudKernal.cpp b/src/PointCloudData/PointCloudKernal.cpp deleted file mode 100644 index 5352d78..0000000 --- a/src/PointCloudData/PointCloudKernal.cpp +++ /dev/null @@ -1,263 +0,0 @@ -#include "PointCloudKernal.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace PointCloudData -{ - int PointCloudKernal::idOffset = 0; - int PointCloudKernal::pointIDOffset = 1; - - PointCloudKernal::PointCloudKernal() - { - idOffset++; - setID(idOffset); - _pointIDOffset = pointIDOffset; -// _PointCloud = vtkSmartPointer::New(); - _specificColor.first = false; - appendProperty(QObject::tr("Visible"), _visible); - } - - void PointCloudKernal::setPointCloudData(pcl::PointCloud::Ptr dataset) - { - _PointCloud = dataset; - _pointIDOffset = pointIDOffset; - - pointIDOffset += dataset->size(); - - appendProperty(QObject::tr("Points"), (int)dataset->size()); - } - - pcl::PointCloud::Ptr PointCloudKernal::getPointCloudData() - { - return _PointCloud; - } - - pcl::PointXYZRGBA PointCloudKernal::getPointAt(const int index) - { - return _PointCloud->at(index); - } - - bool PointCloudKernal::isVisible() - { - return _visible; - } - - void PointCloudKernal::setVisible(bool v) - { - _visible = v; - appendProperty(QObject::tr("Visible"), _visible); - } - - void PointCloudKernal::dataToStream(QDataStream* s) - { - *s << _id << _name << _PointCloud->size() ; - } - - void PointCloudKernal::setID(int id) - { - DataBase::setID(id); - if (id > idOffset) - idOffset = id; - } - - void PointCloudKernal::setPath(const QString& path) - { - _path = path; - } - - QString PointCloudKernal::getPath() - { - return _path; - } - - void PointCloudKernal::setPointIDOFfset(int offset) - { - _pointIDOffset = offset; - if (pointIDOffset < offset) - pointIDOffset = offset; - } - - - QDomElement& PointCloudKernal::writeToProjectFile(QDomDocument* doc, QDomElement* parent) - { - QDomElement kernelele = doc->createElement("PointCloudKernel"); - QDomAttr idAttr = doc->createAttribute("ID"); - idAttr.setValue(QString::number(_id)); - kernelele.setAttributeNode(idAttr); - QDomAttr visible = doc->createAttribute("Visible"); - visible.setValue("True"); - if (!_visible) visible.setValue("False"); - kernelele.setAttributeNode(visible); - QDomElement nameele = doc->createElement("Name"); - QDomText nameText = doc->createTextNode(_name); - nameele.appendChild(nameText); - kernelele.appendChild(nameele); - - if (!_path.isEmpty()) - { - QDomElement pathele = doc->createElement("Path"); - QDomText pathtext = doc->createTextNode(_path); - pathele.appendChild(pathtext); - kernelele.appendChild(pathele); - this->writePCDFile(_path); - } - - return kernelele; - } - - void PointCloudKernal::readDataFromProjectFile(QDomElement* kernelele) - { - QString sid = kernelele->attribute("ID"); - this->setID(sid.toInt()); - QString svis = kernelele->attribute("Visible"); - bool visible = true; - if (svis.toLower() == "false") visible = false; - this->setVisible(visible); - - QDomNodeList nameNodeList = kernelele->elementsByTagName("Name"); - if (nameNodeList.size() != 1) return; - QString name = nameNodeList.at(0).toElement().text(); - this->setName(name); - QDomNodeList pathList = kernelele->elementsByTagName("Path"); - if (pathList.size() > 0) - { - QString path = pathList.at(0).toElement().text(); - this->setPath(path); - this->readBinaryFile(path); - } - } - - int PointCloudKernal::getPointCount() - { - if (_PointCloud != nullptr) - - return _PointCloud->size(); - return -1; - } - - - void PointCloudKernal::resetOffset() - { - idOffset = 0; - pointIDOffset = 1; - } - - void PointCloudKernal::setDimension(int d) - { - _dimension = d; - } - - int PointCloudKernal::getDimension() - { - return _dimension; - } - - //写出二进制文件 - void PointCloudKernal::writeBinaryFile(QDataStream* dataStream){ - *dataStream << _id << _visible << _name << _path; // 保存存储文件的相对文件名 - } - - //读入二进制文件 - void PointCloudKernal::readBinaryFile(QDataStream* dataStream){ - int KernalID = 0; //KernalID - bool visible = false; - QString PointCloudName, PointCloudPath; - *dataStream >> KernalID >> visible >> PointCloudName >> PointCloudPath; - - this->setID(KernalID); - this->setVisible(visible); - this->setName(PointCloudName); - this->setPath(PointCloudPath); - this->readPCDFile(PointCloudPath); - } - - - - - void PointCloudKernal::writePCDFile(const QString& datafilepath) - { - pcl::io::savePCDFileBinary(datafilepath.toUtf8().constData(),*(this->getPointCloudData())); - } - - void PointCloudKernal::readPCDFile(const QString& dataStream) - { - // 定义点云 - pcl::PointCloud::Ptr cloud(new pcl::PointCloud); - pcl::PCLPointCloud2::Ptr cloud2(new pcl::PCLPointCloud2); - // 读取点云,失败返回-1 - if (pcl::io::loadPCDFile(dataStream.toUtf8().constData(), *cloud2) == -1) - { - PCL_ERROR("couldn't read file\n"); - }else{ - pcl::fromPCLPointCloud2(*cloud2,*cloud); - this->setPointCloudData(cloud); - this->setPath(dataStream); - } - } - - void PointCloudKernal::setPointCloudSetting(DataProperty::DataBase* data) - { - _PointCloudSetting = data; - } - - DataProperty::DataBase* PointCloudKernal::getPointCloudSetting() - { - return _PointCloudSetting; - } - - void PointCloudKernal::setSpecificColor(bool enable, QColor c) - { - _specificColor.first = enable; - _specificColor.second = c; - this->UpdatePointCloudCloudColor(); - } - - void PointCloudKernal::setSpecificColor(bool enable,std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t alpha) - { - _specificColor.first = enable; - _specificColor.second.setRedF(r); - _specificColor.second.setGreenF(g); - _specificColor.second.setBlueF(b); - _specificColor.second.setAlpha(alpha); - - this->UpdatePointCloudCloudColor(); - } - - QColor PointCloudKernal::getSpecificColor(bool &isEnable) - { - isEnable = _specificColor.first; - return _specificColor.second; - this->UpdatePointCloudCloudColor(); - } - void PointCloudKernal::UpdatePointCloudCloudColor() { - std::uint8_t r= _specificColor.second.redF(); - std::uint8_t g= _specificColor.second.greenF(); - std::uint8_t b= _specificColor.second.blueF(); - std::uint8_t a= _specificColor.second.alphaF(); - - for(std::size_t i=0;i<_PointCloud->size();i++){ - (*_PointCloud)[i].r=r; - } - for(std::size_t i=0;i<_PointCloud->size();i++){ - (*_PointCloud)[i].g=g; - } - for(std::size_t i=0;i<_PointCloud->size();i++){ - (*_PointCloud)[i].b=b; - } - for(std::size_t i=0;i<_PointCloud->size();i++){ - (*_PointCloud)[i].a=a; - } - } - -} - diff --git a/src/PointCloudData/PointCloudPy.cpp b/src/PointCloudData/PointCloudPy.cpp deleted file mode 100644 index c69c069..0000000 --- a/src/PointCloudData/PointCloudPy.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include "PointCloudPy.h" -#include "PointCloudKernal.h" -#include "PointCloudSingleton.h" -#include "PointCloudSet.h" -#include "DataProperty/DataBase.h" - -PointCloudData::PointCloudData *md = PointCloudData::PointCloudData::getInstance(); - -POINTCLOUDDATAAPI int getPointCloudKernalCountPy() -{ - return md->getKernalCount(); -} - -POINTCLOUDDATAAPI const char* getPointCloudKernalNameByIndexPy(const int index) -{ - PointCloudData::PointCloudKernal *mk = md->getKernalAt(index); - if (!mk) return ""; - std::string cppStr = mk->getName().toStdString(); - const char* cStr = cppStr.c_str(); - char name[128] = { 0 }; - strcpy(name, cStr); - return name; -} - -POINTCLOUDDATAAPI const char* getPointCloudKernalNameByKidPy(const int kid) -{ - PointCloudData::PointCloudKernal *mk = md->getKernalByID(kid); - if (!mk) return ""; - std::string cppStr = mk->getName().toStdString(); - const char* cStr = cppStr.c_str(); - char name[128] = { 0 }; - strcpy(name, cStr); - return name; -} - -POINTCLOUDDATAAPI void removePointCloudKernalByIndexPy(const int index) -{ - md->removeKernalAt(index); -} - -POINTCLOUDDATAAPI void removePointCloudKernalByKidPy(const int kid) -{ - md->removeKernalByID(kid); -} - -POINTCLOUDDATAAPI int getPointCloudSetCountPy() -{ - return md->getPointCloudSetCount(); -} - -POINTCLOUDDATAAPI const char* getPointCloudSetNameByIndexPy(const int index) -{ - PointCloudData::PointCloudSet *ms = md->getPointCloudSetAt(index); - if (!ms) return ""; - std::string cppStr = ms->getName().toStdString(); - const char* cStr = cppStr.c_str(); - char name[128] = { 0 }; - strcpy(name, cStr); - return name; -} - -POINTCLOUDDATAAPI const char* getPointCloudSetNameBySidPy(const int sid) -{ - PointCloudData::PointCloudSet *ms = md->getPointCloudSetByID(sid); - if (!ms) return ""; - std::string cppStr = ms->getName().toStdString(); - const char* cStr = cppStr.c_str(); - char name[128] = { 0 }; - strcpy(name, cStr); - return name; -} - -POINTCLOUDDATAAPI void removePointCloudSetByIndexPy(const int index) -{ - md->removePointCloudSetAt(index); -} - -POINTCLOUDDATAAPI void clearPointCloudPy() -{ - md->clear(); -} - -POINTCLOUDDATAAPI void generatePointCloudDisplayDataSetPy() -{ - md->generateDisplayDataSet(); -} - -POINTCLOUDDATAAPI void setColor(char*lab, int id, char* color) -{ - QString slab(lab); - if (slab == "PointCloudSet") - { - PointCloudData::PointCloudSet* s = md->getPointCloudSetByID(id); - if (s == nullptr) return; - auto colorPar = s->getParameterByName("Color"); - if (colorPar == nullptr) return; - colorPar->setValueFromString(QString(color)); - } - else - { - } -} diff --git a/src/PointCloudData/PointCloudPy.h b/src/PointCloudData/PointCloudPy.h deleted file mode 100644 index 03a8645..0000000 --- a/src/PointCloudData/PointCloudPy.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _POINTCLOUDPY_H_ -#define _POINTCLOUDPY_H_ - -#include "PointCloudDataAPI.h" - -extern "C" -{ - //POINTCLOUDKernal - POINTCLOUDDATAAPI int getPointCloudKernalCountPy(); - POINTCLOUDDATAAPI const char* getPointCloudKernalNameByIndexPy(const int index); - POINTCLOUDDATAAPI const char* getPointCloudKernalNameByKidPy(const int kid); - POINTCLOUDDATAAPI void removePointCloudKernalByIndexPy(const int index); - POINTCLOUDDATAAPI void removePointCloudKernalByKidPy(const int kid); - POINTCLOUDDATAAPI void setColor(char*lab, int id, char* color); - //POINTCLOUDSet - POINTCLOUDDATAAPI int getPointCloudSetCountPy(); - POINTCLOUDDATAAPI const char* getPointCloudSetNameByIndexPy(const int index); - POINTCLOUDDATAAPI const char* getPointCloudSetNameBySidPy(const int sid); - POINTCLOUDDATAAPI void removePointCloudSetByIndexPy(const int index); - - POINTCLOUDDATAAPI void clearPointCloudPy(); - POINTCLOUDDATAAPI void generatePointCloudDisplayDataSetPy(); -} - -#endif \ No newline at end of file diff --git a/src/PointCloudData/PointCloudSet.cpp b/src/PointCloudData/PointCloudSet.cpp deleted file mode 100644 index 25a5e4c..0000000 --- a/src/PointCloudData/PointCloudSet.cpp +++ /dev/null @@ -1,360 +0,0 @@ -#include "PointCloudSet.h" -#include "PointCloudSingleton.h" -#include "PointCloudKernal.h" -#include "DataProperty/ParameterColor.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace PointCloudData -{ -//int PointCloudSet::maxID = 0; - -PointCloudSet::PointCloudSet(QString name, SetType t) : ComponentBase(DataProperty::ComponentType::MESH) -{ - // maxID++; - // setID(maxID); - setName(name); - setType(t); - // _member = new SetMember; - DataProperty::ParameterColor* c = new DataProperty::ParameterColor(); - c->setDescribe("Color"); - this->setModuleType(DataProperty::Module_PointCloudSet); - this->appendParameter(c); -} - -PointCloudSet::PointCloudSet() : ComponentBase(DataProperty::ComponentType::MESH) -{ - // maxID++; - // setID(maxID); - // setName(name); - // _member = new SetMember; -} - -PointCloudSet::~PointCloudSet() -{ - // if (_member != nullptr) delete _member; - if (_displayDataSet != nullptr) _displayDataSet->Delete(); -} - -// void PointCloudSet::setID(int id) -// { -// DataBase::setID(id); -// if (maxID < id) -// maxID = id; -// } - -void PointCloudSet::setType(PointCloudSetType t) -{ - _type = t; - QString stype = "Node"; - switch (t) - { - case PointXYZRGBA: stype = "PointXYZRGBA"; break; - default: break; - } - this->appendProperty("Type", stype); -} - -PointCloudSetType PointCloudSet::getSetType() -{ - return _type; -} - -QColor PointCloudSet::getColor() -{ - DataProperty::ParameterColor* c = dynamic_cast(getParameterByName("Color")); - if (c == nullptr) return QColor(); - return c->getColor(); -} - -void PointCloudSet::appendMember(int ker, int id) -{ - // if (_members.contains(ker, id)) return; - _members.insert(ker, id); -} - -QList PointCloudSet::getKernals() -{ - return _members.uniqueKeys(); -} - -QList PointCloudSet::getKernalMembers(int k) -{ - if (_members.contains(k)) - return _members.values(k); - return QList(); -} - -int PointCloudSet::getAllCount() -{ - return _members.size(); -} - -QDomElement& PointCloudSet::writeToProjectFile(QDomDocument* doc, QDomElement* parent) -{ - QDomElement setEle = doc->createElement("PointCloudSet"); - - QDomAttr idAttr = doc->createAttribute("ID"); - idAttr.setValue(QString::number(_id)); - setEle.setAttributeNode(idAttr); - QDomAttr name = doc->createAttribute("Name"); - name.setValue(_name); - setEle.setAttributeNode(name); - QString stype = "Node"; - if (_type == Element) stype = "Element"; - QDomAttr typeAttr = doc->createAttribute("Type"); - typeAttr.setValue(stype); - setEle.setAttributeNode(typeAttr); - - QList kernalids = _members.uniqueKeys(); - for (int kid : kernalids) - { - QDomElement kele = doc->createElement("Kernal"); - kele.setAttribute("ID", kid); - QDomElement memle = doc->createElement("Member"); - QList memids = _members.values(kid); - QStringList text; - for (int id : memids) - text.append(QString::number(id)); - QDomText memText = doc->createTextNode(text.join(",")); - memle.appendChild(memText); - - kele.appendChild(memle); - setEle.appendChild(kele); - } - - parent->appendChild(setEle); - return setEle; -} - -void PointCloudSet::readDataFromProjectFile(QDomElement* setEle) -{ - QString name = setEle->attribute("Name"); - QString stype = setEle->attribute("Type"); - QString sID = setEle->attribute("ID"); - PointCloudSetType type = None; - if (stype.toLower() == "node") PointCloudSetType = Node; - else if (stype.toLower() == "element") type = Element; - this->setID(sID.toInt()); - this->setName(name); - this->setType(type); - - QDomNodeList kerList = setEle->elementsByTagName("Kernal"); - for (int i = 0; i < kerList.size(); ++i) - { - QDomElement kerele = kerList.at(i).toElement(); - QString skid = kerele.attribute("ID"); - bool ok = false; - const int kid = skid.toInt(&ok); - if (!ok) continue; - QDomNodeList memList = kerele.elementsByTagName("Member"); - for (int j = 0; j < memList.size(); ++j) - { - QDomElement memele = memList.at(j).toElement(); - QString text = memele.text(); - QStringList sids = text.split(","); - for (QString s : sids) - { - int mid = s.toInt(&ok); - if (!ok) continue; - this->appendMember(kid, mid); - } - } - } -} - -void PointCloudSet::generateDisplayDataSet() -{ - if (_displayDataSet != nullptr) return; - if (_members.isEmpty()) return; - appendProperty("Count", _members.values().size()); - - PointCloudData* meshdata = PointCloudData::getInstance(); - QList kids = _members.uniqueKeys(); - - - vtkSmartPointer appendFliter = vtkSmartPointer::New(); - for (int kid : kids) - { - QList member = _members.values(kid); - auto k = meshdata->getKernalByID(kid); - if (member.isEmpty() || k ==nullptr) continue; - vtkDataSet* dataset = k->getPointCloudData(); - if (dataset == nullptr) continue; - - vtkSmartPointer idArray = vtkSmartPointer::New(); - for (int id : member) idArray->InsertNextValue(id); - - vtkSmartPointer selectionNode = vtkSmartPointer::New(); - if (_type == Element) - { - selectionNode->SetFieldType(vtkSelectionNode::CELL); - } - else if (_type == Node) - { - selectionNode->SetFieldType(vtkSelectionNode::POINT); - } - selectionNode->SetContentType(vtkSelectionNode::INDICES); - selectionNode->SetSelectionList(idArray); - - vtkSmartPointer selection = vtkSmartPointer::New(); - selection->AddNode(selectionNode); - - vtkSmartPointer extractionSelection = vtkSmartPointer::New(); - extractionSelection->SetInputData(0, dataset); - extractionSelection->SetInputData(1, selection); - extractionSelection->Update(); - appendFliter->AddInputData(extractionSelection->GetOutput()); - } - appendFliter->Update(); - - _displayDataSet = vtkUnstructuredGrid::New(); - _displayDataSet->DeepCopy(appendFliter->GetOutput()); -} - -vtkDataSet* PointCloudSet::getDisplayDataSet() -{ - return _displayDataSet; -} - -PointCloudSetType PointCloudSet::stringToSettype(QString s) -{ - PointCloudSetType t = None; - if (s == "PointXYZRGBA") t = PointXYZRGBA; - else t=None; - return t; -} -//写set部分的二进制 -void PointCloudSet::writeBinaryFile(QDataStream* dataStream) -{ - QList kids = _members.uniqueKeys(); - const int nk = kids.size(); - *dataStream << (int)_type << _id << _name << nk; //setID,setType,setName,KernalIDs - - for (int kid : kids) - { - QList memids = _members.values(kid); - const int n = memids.size(); - *dataStream << kid << n; - for (int mem : memids) - *dataStream << mem; - } - -} -//读取set部分的二进制 -void PointCloudSet::readBinaryFile(QDataStream* dataStream) -{ - int SetID{ 0 }, nKernal{ 0 }; //, nMember{0}; //setID,KernalID,MemberNumber - QString setName; - - *dataStream >> SetID >> setName >> nKernal; - this->setID(SetID); - this->setName(setName); - - for (int nk = 0; nk < nKernal; ++nk) - { - int kid = 0, ncount = 0 , mid = 0; - *dataStream >> kid >>ncount; - for (int i = 0; i < ncount; ++i) - { - *dataStream >> mid; - appendMember(kid, mid); - } - } - -} - -void PointCloudSet::appendTempMem(int m) -{ - _tempMemberID.append(m); -} - -void PointCloudSet::setKeneralID(int id) -{ - for (int m : _tempMemberID) - this->appendMember(id, m); - _tempMemberID.clear(); -} - -bool PointCloudSet::isContainsKernal(int id) -{ - return _members.contains(id); -} - -void PointCloudSet::dataToStream(QDataStream* s) -{ - *s << _id << _name << _members.size(); -} - -void PointCloudSet::isVisible(bool v) -{ - _visible = v; -} - -bool PointCloudSet::isVisible() -{ - return _visible; -} - -void PointCloudSet::merge(PointCloudSet* set) -{ - if (set->getSetType() != _type) return; - QList ks = set->getKernals(); - for (int k : ks) - { - QList mem = set->getKernalMembers(k); - for (int m : mem) - this->appendMember(k, m); - } -} - -void PointCloudSet::cut(PointCloudSet* set) -{ - if (set->getSetType() != _type) return; - QList ks = set->getKernals(); - for (int k : ks) - { - if (!_members.contains(k)) continue; - QList mem = set->getKernalMembers(k); - for (int m : mem) - _members.remove(k, m); - } -} - -QString PointCloudSet::setTypeToString(PointCloudSetType type) -{ - QString qtype{}; - switch (type) - { - case PointXYZRGBA : qtype = "PointXYZRGBA"; break; - default : break; - } - return qtype; -} - -BoundPointCloudSet::BoundPointCloudSet(): PointCloudSet() -{ - -} - -void BoundPointCloudSet::setCellFaces(const QMap> cellFaces) -{ - m_CellFaces = cellFaces; -} - -QMap> BoundPointCloudSet::getCellFaces() -{ - return m_CellFaces; -} - -} diff --git a/src/PointCloudData/PointCloudSet.h b/src/PointCloudData/PointCloudSet.h deleted file mode 100644 index 90a7e61..0000000 --- a/src/PointCloudData/PointCloudSet.h +++ /dev/null @@ -1,229 +0,0 @@ -/* - * 这是点云集合,默认由 PointCloudKernal组成,其中内存的由文件组决定 - * - * */ - -#ifndef POINTCLOUDSET_H_ -#define POINTCLOUDSET_H_ - -#include "PointCloudDataAPI.h" -#include "DataProperty/ComponentBase.h" -#include -#include -#include -#include - - -// Point Cloud Library -#include -#include -#include -#include // TicToc -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include //随机数 -#include -#include -#include // TicToc -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include // 4PCS算法 -#include //K4PCS算法头文件 -#include -#include -#include -#include -#include //贪婪投影三角化算法类定义的头文件 -#include //移动立方体 -#include -#include //MLS -#include //泊松重建 -#include -#include -#include -#include -#include - -#include // TicToc -#include // 体素滤波 -#include // 体素滤波 -#include - -#include -#include -#include -#include -#include -#include //随机参数估计方法 -#include //模型定义 -#include //RANSAC分割 -#include -#include -#include //rand()头文件 -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//可视化相关头文件 -#include -#include -#include -#include -#include -#include -#include -#include -// Boost -#include - -// Visualization Toolkit (VTK) -#include - - -namespace PointCloudData -{ - enum PointCloudSetType - { - None = 0, - PointXYZRGBA, // 表示点云类别 - UserDef = 101, - EndType = 100000, - }; - - class SetMember; - - class POINTCLOUDDATAAPI PointCloudSet : public DataProperty::ComponentBase - { - public : - //构造函数 - PointCloudSet(QString name, PointCloudSetType type); - PointCloudSet(); - ~PointCloudSet(); - //获取最大ID - //int static getMaxID(); - //重置最大ID - //void static resetMaxID(); - ///设置ID,谨慎调用 - //void setID(int id) override; - ///设置类型 - void setType(PointCloudSetType t); - ///获取类型 - PointCloudSetType getSetType(); - ///获取颜色 - QColor getColor(); - //添加成员 - void appendMember(int ker, int id); - //获取Kernal ID列表 - QList getKernals(); - //根据kernal ID获取成员 - QList getKernalMembers(int k); - //获取数量 - int getAllCount(); - //临时保存MemberID,当void setKeneralID(int id)时清空,指定为Keneral为id的的子集 - void appendTempMem(int m); - //设置Kenenal, 与 void appendTempMem(int m)配合使用 - void setKeneralID(int id); - //是否包含kernal - bool isContainsKernal(int id); - //设置可见性 - void isVisible(bool v); - //获取可见性 - bool isVisible(); - //合并组件 - void merge(PointCloudSet* set); - //减去组件 - void cut(PointCloudSet* set); - //md5 - void dataToStream(QDataStream* s) override; - //写出到XML文件 - virtual QDomElement& writeToProjectFile(QDomDocument* doc, QDomElement* parent) override; - //从XML文件读取数据 - virtual void readDataFromProjectFile(QDomElement* e) override; - //写出二进制文件 - virtual void writeBinaryFile(QDataStream* dataStream); - //读入二进制文件 - virtual void readBinaryFile(QDataStream* dataStream); - //生成可以显示的模型, 每个实例只能调用一次 - virtual void generateDisplayDataSet(); - //获取显示模型 - virtual vtkDataSet* getDisplayDataSet(); - //字符串转化为枚举 - static PointCloudSetType stringToSettype(QString s); - //枚举转字符串 - static QString setTypeToString(PointCloudSetType); - - - - protected: - PointCloudSetType _type{ None }; - bool _visible{ true }; - - QMultiHash _members{}; //keneralID - node/elementID - - QList _tempMemberID{}; - - vtkDataSet* _displayDataSet{}; - - private: - // static int maxID; - }; - - - //用于流体网格边界信息存储。边界由多个单元的一个或多个面组成。 - class POINTCLOUDDATAAPI BoundPointCloudSet : public PointCloudSet - { - public: - BoundPointCloudSet(); - ~BoundPointCloudSet() = default; - void setCellFaces(const QMap> cellFaces); - QMap> getCellFaces(); - protected: - //key为单元索引,value为该单元的面索引 - QMap> m_CellFaces{}; - - }; - - -} - - -#endif diff --git a/src/PointCloudData/PointCloudSingleton.cpp b/src/PointCloudData/PointCloudSingleton.cpp deleted file mode 100644 index fedb5f1..0000000 --- a/src/PointCloudData/PointCloudSingleton.cpp +++ /dev/null @@ -1,341 +0,0 @@ -#include "PointCloudSingleton.h" -#include "PointCloudKernal.h" -#include "PointCloudSet.h" -#include "PointCloudFactory.h" -#include -#include -#include -#include -#include -#include -#include -#include - -namespace PointCloudData -{ - PointCloudData* PointCloudData::_instance = nullptr; - - PointCloudData* PointCloudData::getInstance() - { - if (_instance == nullptr) - { - _instance = new PointCloudData; - } - return _instance; - } - - PointCloudData::~PointCloudData() - { - for (int i = 0; i < _pointcloudList.size(); ++i) - { - PointCloudKernal* k = _pointcloudList.at(i); - delete k; - } - _pointcloudList.clear(); - } - void PointCloudData::appendPointCloudKernal(PointCloudKernal* keneral) - { - _pointcloudList.append(keneral); - } - int PointCloudData::getKernalCount() - { - return _pointcloudList.size(); - } - PointCloudKernal* PointCloudData::getKernalAt(const int index) - { - if(index >= 0 && index < _pointcloudList.size()) - return _pointcloudList.at(index); - return nullptr; - } - PointCloudKernal* PointCloudData::getKernalByID(const int id) - { - const int n = _pointcloudList.size(); - for (int i = 0; i < n; ++i) - { - PointCloudKernal* k = _pointcloudList.at(i); - if (k->getID() == id) - return k; - } - return nullptr; - } - void PointCloudData::removeKernalAt(const int index) - { - PointCloudKernal* k = getKernalAt(index); - - QList setlist{}; - for (int i = 0; i < _setList.size(); ++i) - { - PointCloudSet* s = _setList.at(i); -// if (s->getDataSetID() == k->getID()) - int kid = k->getID(); - if (s->isContainsKernal(kid)) - setlist.append(s); - } - for (int i = 0; i < setlist.size(); ++i) - { - PointCloudSet* s = setlist.at(i); - _setList.removeOne(s); - delete s; - } - - delete k; - _pointcloudList.removeAt(index); - } - - void PointCloudData::removeKernalByID(const int id) - { - auto k = this->getKernalByID(id); - int index = _pointcloudList.indexOf(k); - if (index < 0) return; - this->removeKernalAt(index); - } - - void PointCloudData::clear() - { - int n = this->getKernalCount(); - for (int i = 0; i < n; ++i) - { - PointCloudKernal* k = this->getKernalAt(i); - delete k; - } - _pointcloudList.clear(); - - n = _setList.size(); - for (int i = 0; i < n; ++i) - { - PointCloudSet *s = _setList.at(i); - delete s; - } - _setList.clear(); - - PointCloudKernal::resetOffset(); - DataProperty::ComponentBase::resetMaxID(); - } - QString PointCloudData::getMD5() - { - const int n = _pointcloudList.size(); - if (n < 1) return""; - - QDataStream stream; - for (int i = 0; i < n; ++i) - { - _pointcloudList[i]->dataToStream(&stream); - } - for (auto set : _setList) - { - set->dataToStream(&stream); - } - - char* s; - stream >> s; - QString md5 = QCryptographicHash::hash(s, QCryptographicHash::Md5); - return md5; - } - QDomElement& PointCloudData::writeToProjectFile(QDomDocument* doc, QDomElement* parent) - { - QDomElement meshNode = doc->createElement("PointCloud"); - const int n = _pointcloudList.size(); - QDomElement meshKernalList = doc->createElement("Kernel"); - for (int i = 0; i < n; ++i) - { - PointCloudKernal* k = _pointcloudList.at(i); - k->writeToProjectFile(doc, &meshKernalList); - } - meshNode.appendChild(meshKernalList); - - const int nset = _setList.size(); - QDomElement setList = doc->createElement("Set"); - for (int i = 0; i < nset; ++i) - { - PointCloudSet* s = _setList.at(i); - s->writeToProjectFile(doc, &setList); - } - meshNode.appendChild(setList); - - parent->appendChild(meshNode); - return meshNode; - } - void PointCloudData::readFromProjectFile(QDomNodeList* nodelist) - { - QDomElement meshRoot = nodelist->at(0).toElement(); - QDomNodeList meshList = meshRoot.elementsByTagName("PointCloudKernel"); - const int nPointCloud = meshList.size(); - for (int i = 0; i < nPointCloud; ++i) - { - QDomElement meshKernelEle = meshList.at(i).toElement(); - { //废弃代码 - // QDomNodeList pathlist = meshKernelEle.elementsByTagName("Path"); - // if (pathlist.size() != 1) continue; - // QDomElement pathele = pathlist.at(0).toElement(); - // QString fpath = pathele.text(); - // QFileInfo finfo(fpath); - // if (!finfo.exists()) return; - // QString suffix = finfo.suffix().toLower(); - // if (suffix == "vtk" || suffix == "stl") - // { - // VTKdataExchange reader(fpath); - // if (!reader.read()) continue; - // } - // else if (suffix == "neu") - // { - // NEUdataExchange reader(fpath); - // if (!reader.read()) continue; - // } - } - PointCloudKernal* k = new PointCloudKernal; - _pointcloudList.append(k); - k->readDataFromProjectFile(&meshKernelEle); - } - QDomNodeList setList = meshRoot.elementsByTagName("PointCloudSet"); - const int nSet = setList.size(); - for (int i = 0; i < nSet; ++i) - { - PointCloudSet* s = nullptr; - QDomElement setEle = setList.at(i).toElement(); - s = new PointCloudSet; - - _setList.append(s); - s->readDataFromProjectFile(&setEle); //保存属性 -// s->generateDisplayDataSet(); - } - } - int PointCloudData::getIDByDataSet(vtkDataSet* datset) - { - const int n = _pointcloudList.size(); - for (int i = 0; i < n; ++i) - { - PointCloudKernal* k = _pointcloudList.at(i); - vtkDataSet* s = k->getPointCloudData(); - if (s == datset) - return k->getID(); - } - return -1; - } - void PointCloudData::appendPointCloudSet(PointCloudSet* s) - { - _setList.append(s); - } - int PointCloudData::getPointCloudSetCount() - { - return _setList.size(); - } - PointCloudSet* PointCloudData::getPointCloudSetAt(const int index) - { - assert(index >= 0 && index < _setList.size()); - return _setList.at(index); - } - PointCloudSet* PointCloudData::getPointCloudSetByID(const int id) - { - const int n = _setList.size(); - for (int i = 0; i < n; ++i) - { - PointCloudSet* set = _setList.at(i); - int sid = set->getID(); - if (sid == id) return set; - } - return nullptr; - } - PointCloudSet* PointCloudData::getPointCloudSetByName(const QString name) - { - const int n = _setList.size(); - for (int i = 0; i < n; ++i) - { - PointCloudSet* set = _setList.at(i); - QString n = set->getName(); - if (name == n) return set; - } - return nullptr; - - } - void PointCloudData::removePointCloudSetAt(const int index) - { - assert(index >= 0 && index < _setList.size()); - PointCloudSet* s = _setList.at(index); - delete s; - _setList.removeAt(index); - } - QList PointCloudData::getSetIDFromKernal(int kid) - { - QList ids; - int n = _setList.size(); - for (int i = 0; i < n; ++i) - { - PointCloudSet* set = _setList.at(i); - //int id = set->getDataSetID(); - //if (id == kid) - if (set->isContainsKernal(kid)) - ids.append(set->getID()); - } - return ids; - } - - bool PointCloudData::isContainsKernal(PointCloudKernal* ker) - { - return _pointcloudList.contains(ker); - } - - void PointCloudData::generateDisplayDataSet() - { - const int n = this->getPointCloudSetCount(); - for (int i = 0; i < n; ++i) - { - PointCloudSet* s = this->getPointCloudSetAt(i); - s->generateDisplayDataSet(); - } - } - - void PointCloudData::writeBinaryFile(QDataStream* dataStream) - { - //写出二进制文件 - const int nk = _pointcloudList.size(); - *dataStream << nk; - for (int i = 0; i < nk; ++i) - { - PointCloudKernal* k = _pointcloudList.at(i); - k->writePCDFile(dataStream); - } - - const int ns = _setList.size(); - *dataStream << ns; - for (int i = 0; i < ns; ++i) - { - PointCloudSet* s = _setList.at(i); - s->writeBinaryFile(dataStream); - } - } - - void PointCloudData::readBinaryFile(QDataStream* dataStream) - { - //读入二进制文件 - int nk = 0; - int ns = 0; - *dataStream >> nk; - for (int i = 0; i < nk; ++i) - { - PointCloudKernal* k = new PointCloudKernal; - _pointcloudList.append(k); - k->readBinaryFile(dataStream); - } - - *dataStream >> ns; - for (int i = 0; i < ns; ++i) - { - int type = 0; - *dataStream >> type; - PointCloudSet* s = PointCloudFactory::CreatePointCloudSet(type); -// switch (type) -// { -// case 1: -// case 2: s = new PointCloudSet(QString(), SetType(type)); break; -// case 3: s = new CgnsFamily; break; -// case 4: s = new CgnsBCZone; break; -// default:break; -// } - if (s == nullptr) continue; - _setList.append(s); - s->readBinaryFile(dataStream); - } - } - - -} diff --git a/src/PointCloudData/CMakeLists.txt b/src/PointCloudOperator/CMakeLists.txt similarity index 63% rename from src/PointCloudData/CMakeLists.txt rename to src/PointCloudOperator/CMakeLists.txt index da85e15..c8e69af 100644 --- a/src/PointCloudData/CMakeLists.txt +++ b/src/PointCloudOperator/CMakeLists.txt @@ -22,37 +22,10 @@ include_directories(C:/PCL/include/pcl-1.14) # qt5 include_directories(C:/Qt/5.15.2/msvc2019_64/include/QtQml) -# json -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../json) - -# qscintilla2 -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qscintilla2) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qscintilla2/lexers) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qscintilla2/include) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qscintilla2/lexlib) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qscintilla2/Qt4Qt5) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qscintilla2/src) - # lamptool include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../LAMPTool) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../LAMPTool/include) -# qcustomplot -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qcustomplot) - -# qhexedit -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qhexedit) - -# 内部结构 -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../WBCLFZSystemModule/SqliteDBProcess/src) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../WBCLFZSystemModule/modelProcess) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../WBCLFZSystemModule/EchoShowProcess) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../WBCLFZSystemModule/OCCViewer) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../WBCLFZSystemModule/PointCloudProcess) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../WBCLFZSystemModule/SharedModuleLib) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../WBCLFZSystemModule/TableProcess) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../WBCLFZSystemModule/TaskXml) - #----------------------------------------------------------------------------- # 链接库 #----------------------------------------------------------------------------- @@ -62,26 +35,6 @@ link_directories("C:/PCL/3rdParty/FLANN/lib") link_directories("C:/VTK/lib") link_directories("C:/PCL/lib") -# - -#----------------------------------------------------------------------------- -# 自动添加include目录 -#----------------------------------------------------------------------------- -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -#----------------------------------------------------------------------------- -# 源码扫描 -#----------------------------------------------------------------------------- -file(GLOB _header "*.h") -file(GLOB _source "*.cpp") - -#----------------------------------------------------------------------------- -# 添加动态库目标 -#----------------------------------------------------------------------------- -add_library(PointCloudData - ${_header} - ${_source} -) #----------------------------------------------------------------------------- @@ -109,52 +62,81 @@ include_directories(${PCL_INCLUDE_DIRS}) link_directories(${PCL_LIBRARY_DIRS}) add_definitions(${PCL_DEFINITIONS}) - #----------------------------------------------------------------------------- # 自动添加include目录 #----------------------------------------------------------------------------- set(CMAKE_INCLUDE_CURRENT_DIR ON) +#----------------------------------------------------------------------------- +# 添加资源文件 +#----------------------------------------------------------------------------- +set(_qrc "${CMAKE_CURRENT_SOURCE_DIR}/../qrc/WBCLFZSystemModule.qrc") +set(_qrc "${CMAKE_CURRENT_SOURCE_DIR}/../qrc/qianfan.qrc") +set(_lang "${CMAKE_CURRENT_SOURCE_DIR}/../qrc/translations.qrc") + +qt5_add_resources(_resource ${_qrc} ${_lang}) + +#----------------------------------------------------------------------------- +# 源码扫描 +#----------------------------------------------------------------------------- +file(GLOB_RECURSE _ui "*.ui") +file(GLOB_RECURSE _header "*.h" "*.hxx") +file(GLOB_RECURSE _source "*.cpp") +qt5_wrap_ui(_interface ${_ui}) + +#----------------------------------------------------------------------------- +# 添加动态库目标 +#----------------------------------------------------------------------------- +add_library(PointCloudOperator + ${_resource} + ${_interface} + ${_header} + ${_source} +) + #----------------------------------------------------------------------------- # 添加接口声明宏 #----------------------------------------------------------------------------- -target_compile_definitions(PointCloudData PRIVATE "POINTCLOUDDATA_API") - -#list(APPEND _depend_library qcustomplot LAMPTool qscintilla2 qhexedit) - +target_compile_definitions(PointCloudOperator PRIVATE "POINTCLOUDOPERATORAPI_API") +list(APPEND _depend_library Common MeshData DataProperty ) list(APPEND _runtimes_libraries Qt5::Widgets Qt5::Xml VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersStatistics VTK::FiltersVerdict VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ParallelCore VTK::ParallelDIY VTK::doubleconversion VTK::expat VTK::lz4 VTK::lzma VTK::sys VTK::verdict VTK::zlib ) +list(APPEND _runtimes_libraries + Qt5::DBus Qt5::Core Qt5::Xml Qt5::OpenGL Qt5::Gui Qt5::Svg Qt5::Widgets Qt5::Qml Qt5::DataVisualization Qt5::Charts Qt5::PrintSupport +) + +list(APPEND _runtimes_libraries + OpenCASCADE::Freetype OpenCASCADE::TKBO OpenCASCADE::TKBRep OpenCASCADE::TKBool OpenCASCADE::TKCAF OpenCASCADE::TKCDF OpenCASCADE::TKG2d OpenCASCADE::TKG3d OpenCASCADE::TKGeomAlgo OpenCASCADE::TKGeomBase OpenCASCADE::TKHLR OpenCASCADE::TKIGES OpenCASCADE::TKLCAF OpenCASCADE::TKMath OpenCASCADE::TKMesh OpenCASCADE::TKPrim OpenCASCADE::TKSTEP OpenCASCADE::TKSTEP209 OpenCASCADE::TKSTEPAttr OpenCASCADE::TKSTEPBase OpenCASCADE::TKService OpenCASCADE::TKShHealing OpenCASCADE::TKTopAlgo OpenCASCADE::TKV3d OpenCASCADE::TKVCAF OpenCASCADE::TKXCAF OpenCASCADE::TKXDEIGES OpenCASCADE::TKXSBase OpenCASCADE::TKernel Qt5::Widgets Qt5::Xml VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersSources VTK::FiltersStatistics VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingMath VTK::InteractionStyle VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2 VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::lz4 VTK::lzma VTK::sys VTK::zlib VTK::IOGeometry +) #----------------------------------------------------------------------------- # 链接依赖库 #----------------------------------------------------------------------------- -target_link_libraries(PointCloudData PRIVATE +target_link_libraries(PointCloudOperator PRIVATE ${_runtimes_libraries} ${_depend_library} ${PCL_LIBRARIES} - DataProperty + Common ) #----------------------------------------------------------------------------- # 添加依赖关系 #----------------------------------------------------------------------------- -add_dependencies(PointCloudData ${_depend_library} DataProperty) +add_dependencies(PointCloudOperator ${_depend_library} Common) #----------------------------------------------------------------------------- # 添加运行时依赖关系 #----------------------------------------------------------------------------- -set(LAMPCAE_PointCloudData_Runtimes_Libraries ${_runtimes_libraries} PARENT_SCOPE) - - +set(LAMPCAE_PointCloudOperator_Runtimes_Libraries ${_runtimes_libraries} PARENT_SCOPE) diff --git a/src/PointCloudOperator/PCLConvertor.cpp b/src/PointCloudOperator/PCLConvertor.cpp new file mode 100644 index 0000000..7e40692 --- /dev/null +++ b/src/PointCloudOperator/PCLConvertor.cpp @@ -0,0 +1,114 @@ +/** + * @file PCLConvertor.cpp + * @brief None + * @author 陈增辉 (3045316072@qq.com) + * @version 2.5.0 + * @date 2024/4/4 + * @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved. + */ + +#include "PCLConvertor.h" +// pcl 相关 +#include +#include +#include +#include +#include +#include + +#include //随机数 +#include +#include +#include // TicToc +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // 4PCS算法 +#include //K4PCS算法头文件 +#include +#include +#include +#include +#include //贪婪投影三角化算法类定义的头文件 +#include //移动立方体 +#include +#include //MLS +#include //泊松重建 +#include +#include +#include +#include +#include + +#include // TicToc +#include // 体素滤波 +#include // 体素滤波 +#include + +#include +#include +#include +#include +#include +#include //随机参数估计方法 +#include //模型定义 +#include //RANSAC分割 +#include +#include +#include //rand()头文件 +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//可视化相关头文件 +#include +#include +#include +#include +#include +#include +#include +#include +// Boost +#include + +// Visualization Toolkit (VTK) +#include + + +namespace PointCloudOperator { + + PCLConvertor::PCLConvertor(QObject* parent) + : QObject(parent) + { + } +} // namespace PointCloudOperator \ No newline at end of file diff --git a/src/PointCloudData/PointCloudKernal.h b/src/PointCloudOperator/PCLConvertor.h similarity index 50% rename from src/PointCloudData/PointCloudKernal.h rename to src/PointCloudOperator/PCLConvertor.h index 12ba13a..15c5f27 100644 --- a/src/PointCloudData/PointCloudKernal.h +++ b/src/PointCloudOperator/PCLConvertor.h @@ -1,30 +1,19 @@ -/************************* -点云模块 -最终需要重新保存点云数据 - 1. 读取并解析点云文件,只限于二进制文件 - 2. 所有点云文件部件全部都是单独的文件 -*************************/ -#ifndef POINTCLOUDKERNAL_H -#define POINTCLOUDKERNAL_H +/** + * @file PCLConvertor.h + * @brief 点云数据与其他格式数据转换类 + * @author 陈增辉 (3045316072@qq.com) + * @version 2.5.0 + * @date 2024/4/4 + * @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved. + */ -#include "PointCloudDataAPI.h" -#include "DataProperty/DataBase.h" -#include -#include -#include -#include +#ifndef LAMPCAE_PCLCONVERTOR_H +#define LAMPCAE_PCLCONVERTOR_H +#include "PointCloudOperatorAPI.h" +// qt 相关头文件 +#include -// Point Cloud Library -#include -#include -#include -#include // TicToc -#include -#include -#include -#include -#include -#include +// 常用pcl 头文件库 #include #include #include @@ -95,6 +84,8 @@ #include #include #include +#include +#include #include #include #include @@ -117,87 +108,43 @@ // Visualization Toolkit (VTK) #include +#include "ModuleBase/ThreadControl.h" -class QDataStream; +namespace PointCloudOperator { -namespace PointCloudData -{ - class POINTCLOUDDATAAPI PointCloudKernal : public DataProperty::DataBase - { + /*! + * pcl与 其他格式数据 的转换类 + */ + class POINTCLOUDOPERATORAPI PCLConvertor:public QObject { + Q_OBJECT public: - PointCloudKernal(); - ~PointCloudKernal() = default; - //重置节点和单元的偏移量 - static void resetOffset(); + PCLConvertor(QObject* parent=nullptr); + ~PCLConvertor() = default; - void setID(int id) override; -// int getID(); -// QString getName(); -// void setName(const QString &name); - //设置点云数据 - void setPointCloudData(pcl::PointCloud::Ptr dataset); - //获取网格数据,vtk表示 - pcl::PointCloud::Ptr getPointCloudData(); - //获取节点坐标 - pcl::PointXYZRGBA getPointAt(const int index); - //是否可见 - bool isVisible(); - //设置可见状态 - void setVisible(bool v); - //获取点云数目 - int getPointCount(); - void setPath(const QString& path); - QString getPath(); - //标注维度 - void setDimension(int d); - //获取维度 - int getDimension(); - - void dataToStream(QDataStream* s) override; - //写xml - QDomElement& writeToProjectFile(QDomDocument* doc, QDomElement* ele) override; - //读xml - void readDataFromProjectFile(QDomElement* e) override; - //写出pcd 文件 - void writePCDFile(const QString& datafilepath); - //读取pcd 文件 - void readPCDFile(const QString& datafilepath); - - //写出二进制文件 - void writeBinaryFile(QDataStream* dataStream); - //读入二进制文件 - void readBinaryFile(QDataStream* dataStream); - - //设置点云属性 - void setPointCloudSetting(DataProperty::DataBase* data); - //获取点云属性 - DataProperty::DataBase* getPointCloudSetting(); - //设置特有颜色 - void setSpecificColor(bool enable ,QColor color); - void setSpecificColor(bool enable, std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t alpha= 255); - - //获取特有颜色 - QColor getSpecificColor(bool& enable); - - private: - ///设置节点ID偏移量,为读入工程文件调用, - void setPointIDOFfset(int offset); // - void UpdatePointCloudCloudColor(); - private: - bool _visible{ true }; - QString _path{}; - int _pointIDOffset{ -1 }; //起始ID,终止ID=起始ID+PointCloud.pointnum-1 - pcl::PointCloud::Ptr _PointCloud{}; // 点云实体 - int _dimension{ 3 }; - QPair _specificColor; - DataProperty::DataBase* _PointCloudSetting{};// 点云的属性 - - private: - static int idOffset; - static int pointIDOffset; // 点云id + public: + template + static bool PointCloudToVtkDataset(const pcl::PointCloud& cloud, vtkDataSet* const pdata); + template + static bool VtkDatasetToPointCloud(vtkDataSet* const pdata,const pcl::PointCloud& cloud); }; -} -#endif \ No newline at end of file + + + + + + + + + + + + + + + +} // namespace PointCloudOperator + +#endif // LAMPCAE_PCLCONVERTOR_H diff --git a/src/PointCloudOperator/PointCloudCommon.cpp b/src/PointCloudOperator/PointCloudCommon.cpp new file mode 100644 index 0000000..fff144c --- /dev/null +++ b/src/PointCloudOperator/PointCloudCommon.cpp @@ -0,0 +1,94 @@ +/** + * @file PointCloudCommon.cpp + * @brief None + * @author 陈增辉 (3045316072@qq.com) + * @version 2.5.0 + * @date 2024/4/6 + * @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved. + */ + +#include "PointCloudCommon.h" +#include +#include +#include +#include + + + +namespace PointCloudOperator { + PointCloudCommon::PointCloudCommon(QObject* parent) + : QObject(parent) + { + } + void + PointCloudCommon::NormalEstimation(pcl::PointCloud::Ptr cloud_in, + pcl::PointCloud::Ptr normals) + { + pcl::NormalEstimation n; +// pcl::PointCloud::Ptr normals(new pcl::PointCloud); + pcl::search::KdTree::Ptr tree(new pcl::search::KdTree); + tree->setInputCloud(cloud_in); + n.setInputCloud(cloud_in); + n.setSearchMethod(tree); + n.setKSearch(10); + n.compute(*normals); + + } + void + PointCloudCommon::NormalEstimation(pcl::PointCloud::Ptr cloud_in, + pcl::PointCloud::Ptr normals) + { + pcl::NormalEstimation n; + pcl::search::KdTree::Ptr tree(new pcl::search::KdTree); + tree->setInputCloud(cloud_in); + n.setInputCloud(cloud_in); + n.setSearchMethod(tree); + n.setKSearch(10); + n.compute(*normals); + + + } + void + PointCloudCommon::NormalEstimation(pcl::PointCloud::Ptr cloud_in, + pcl::PointCloud::Ptr normals) + { + pcl::NormalEstimation n; + pcl::search::KdTree::Ptr tree(new pcl::search::KdTree); + tree->setInputCloud(cloud_in); + n.setInputCloud(cloud_in); + n.setSearchMethod(tree); + n.setKSearch(10); + n.compute(*normals); + } + + Eigen::Vector3i PointCloudCommon::jetColorMap(float value,float min_intensity,float max_intensity) + { + float r = 0, g = 0, b = 0; + float normalized_value = (value - min_intensity) / (max_intensity - min_intensity); + + if (normalized_value < 0.125) { + r = 0; + g = 0; + b = 0.5 + 4 * normalized_value; + } else if (normalized_value < 0.375) { + r = 0; + g = 4 * normalized_value - 0.5; + b = 1; + } else if (normalized_value < 0.625) { + r = 4 * normalized_value - 1.5; + g = 1; + b = 1.5 - 4 * normalized_value; + } else if (normalized_value < 0.875) { + r = 1; + g = 1.875 - 4 * normalized_value; + b = 0; + } else { + r = 1.75 - 4 * normalized_value; + g = 0; + b = 0; + } + + return Eigen::Vector3i(static_cast(255 * r), static_cast(255 * g), static_cast(255 * b)); + } + +} // namespace PointCloudOperator \ No newline at end of file diff --git a/src/PointCloudData/PointCloudSingleton.h b/src/PointCloudOperator/PointCloudCommon.h similarity index 52% rename from src/PointCloudData/PointCloudSingleton.h rename to src/PointCloudOperator/PointCloudCommon.h index d9b3963..c1de61d 100644 --- a/src/PointCloudData/PointCloudSingleton.h +++ b/src/PointCloudOperator/PointCloudCommon.h @@ -1,24 +1,19 @@ -/*************************** -前处理点云数据 -1. 管理点云数据 -**************************/ -#ifndef POINTCLOUDDATA_H -#define POINTCLOUDDATA_H +/** + * @file PointCloudCommon.h + * @brief None + * @author 陈增辉 (3045316072@qq.com) + * @version 2.5.0 + * @date 2024/4/6 + * @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved. + */ -#include "PointCloudDataAPI.h" -#include -#include "DataProperty/DataBase.h" -// Point Cloud Library -#include -#include -#include -#include // TicToc -#include -#include -#include -#include -#include -#include +#ifndef LAMPCAE_POINTCLOUDCOMMON_H +#define LAMPCAE_POINTCLOUDCOMMON_H +#include "PointCloudOperatorAPI.h" +// qt 相关头文件 +#include + +// 常用pcl 头文件库 #include #include #include @@ -89,6 +84,8 @@ #include #include #include +#include +#include #include #include #include @@ -115,82 +112,27 @@ -class QDomDocument; -class QDomElement; -class QDomNodeList; -class QDataStream; -namespace PointCloudData -{ - class PointCloudKernal; - class PointCloudSet; +namespace PointCloudOperator { - class POINTCLOUDDATAAPI PointCloudData : public DataProperty::DataBase + class POINTCLOUDOPERATORAPI PointCloudCommon:public QObject { + Q_OBJECT public: - //获取单例指针 - static PointCloudData* getInstance(); - //添加Kernal - void appendPointCloudKernal(PointCloudKernal* keneral); - //获取Kernal数量 - int getKernalCount(); - //获取第index个Kernal - PointCloudKernal* getKernalAt(const int index); - //通过ID获取Kernal - PointCloudKernal* getKernalByID(const int id); - //通过网格的数据表示获取Kernal ID - int getIDByDataSet(vtkDataSet* datset); - //移除第index个Kernal - void removeKernalAt(const int index); - //移除ID为i的Kernal - void removeKernalByID(const int id); - //添加组件 - void appendPointCloudSet(PointCloudSet* s); - //获取组件数目 - int getPointCloudSetCount(); - //获取第index个组件 - PointCloudSet* getPointCloudSetAt(const int index); - //通过ID获取网格组件 - PointCloudSet* getPointCloudSetByID(const int id); - //通过名字获取组件,大小写敏感 - PointCloudSet* getPointCloudSetByName(const QString name); - //移除第index个组件 - void removePointCloudSetAt(const int index); - //获取与ID为kid的Kernal相关的全部组件ID - QList getSetIDFromKernal(int kid); - /** - * @brief 判断MeshKernal是否存在 - * @param ker 需要判断的Kernal - * @return true 存在 - * @return false 不存在 - */ - bool isContainsKernal(PointCloudKernal* ker); - /** - * @brief 清空全部数据 - */ - void clear(); - QString getMD5(); - ///写出到工程文件 - QDomElement& writeToProjectFile(QDomDocument* doc, QDomElement* parent) override; - //写出二进制文件 - void writeBinaryFile(QDataStream* dataStream); - ///从工程文件读入数据 - void readFromProjectFile(QDomNodeList* nodelist); - //读入二进制文件 - void readBinaryFile(QDataStream* dataFile); - ///产生全部组件的显示模型 - void generateDisplayDataSet(); + PointCloudCommon(QObject* parent=nullptr); + ~PointCloudCommon()=default; + public: + static void NormalEstimation(pcl::PointCloud::Ptr cloud, pcl::PointCloud::Ptr normals); + static void NormalEstimation(pcl::PointCloud::Ptr cloud, pcl::PointCloud::Ptr normals); + static void NormalEstimation(pcl::PointCloud::Ptr cloud, pcl::PointCloud::Ptr normals); + + // Jet 色带颜色映射函数 + static Eigen::Vector3i jetColorMap(float value,float min_intensity,float max_intensity); + - private: - PointCloudData() = default; - ~PointCloudData(); - private: - static PointCloudData* _instance; - QList _pointcloudList{}; - QList _setList{}; }; +} // namespace PointCloudOperator -} -#endif \ No newline at end of file +#endif // LAMPCAE_POINTCLOUDCOMMON_H diff --git a/src/PointCloudOperator/PointCloudFilter.cpp b/src/PointCloudOperator/PointCloudFilter.cpp new file mode 100644 index 0000000..838af52 --- /dev/null +++ b/src/PointCloudOperator/PointCloudFilter.cpp @@ -0,0 +1,25 @@ +/** + * @file PointCloudFilter.cpp + * @brief 点云的噪声处理类 + * @author 陈增辉 (3045316072@qq.com) + * @version 2.5.0 + * @date 2024/4/4 + * @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved. + */ + +#include "PointCloudFilter.h" +#include +#include +#include +#include + + + +namespace PointCloudOperator { + + PointCloudFilter::PointCloudFilter(QObject* parent) + : QObject(parent) + { + } + +} // namespace PointCloudOperator \ No newline at end of file diff --git a/src/PointCloudOperator/PointCloudFilter.h b/src/PointCloudOperator/PointCloudFilter.h new file mode 100644 index 0000000..0feb0ca --- /dev/null +++ b/src/PointCloudOperator/PointCloudFilter.h @@ -0,0 +1,128 @@ +/** + * @file PointCloudFilter.h + * @brief 点云的噪声处理类 + * @author 陈增辉 (3045316072@qq.com) + * @version 2.5.0 + * @date 2024/4/4 + * @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved. + */ + +#ifndef LAMPCAE_POINTCLOUDFILTER_H +#define LAMPCAE_POINTCLOUDFILTER_H +// qt 相关头文件 +#include + +// 常用pcl 头文件库 +#include +#include +#include +#include +#include +#include + +#include //随机数 +#include +#include +#include // TicToc +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // 4PCS算法 +#include //K4PCS算法头文件 +#include +#include +#include +#include +#include //贪婪投影三角化算法类定义的头文件 +#include //移动立方体 +#include +#include //MLS +#include //泊松重建 +#include +#include +#include +#include +#include + +#include // TicToc +#include // 体素滤波 +#include // 体素滤波 +#include + +#include +#include +#include +#include +#include +#include //随机参数估计方法 +#include //模型定义 +#include //RANSAC分割 +#include +#include +#include //rand()头文件 +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//可视化相关头文件 +#include +#include +#include +#include +#include +#include +#include +#include +// Boost +#include + +// Visualization Toolkit (VTK) +#include + + +#include "PointCloudOperatorAPI.h" + +namespace PointCloudOperator { + + class POINTCLOUDOPERATORAPI PointCloudFilter :public QObject + { + Q_OBJECT + public: + PointCloudFilter(QObject* parent=nullptr); + ~PointCloudFilter()=default; + public: + + }; + +} // namespace PointCloudOperator + +#endif // LAMPCAE_POINTCLOUDFILTER_H diff --git a/src/PointCloudOperator/PointCloudOperatorAPI.h b/src/PointCloudOperator/PointCloudOperatorAPI.h new file mode 100644 index 0000000..e27322d --- /dev/null +++ b/src/PointCloudOperator/PointCloudOperatorAPI.h @@ -0,0 +1,13 @@ +#ifndef _POINTCLOUDOPERATORAPI_H__ +#define _POINTCLOUDOPERATORAPI_H__ + +#include + + +#if defined(POINTCLOUDOPERATORAPI_API) +#define POINTCLOUDOPERATORAPI Q_DECL_EXPORT +#else +#define POINTCLOUDOPERATORAPI Q_DECL_IMPORT +#endif + +#endif diff --git a/src/PointCloudOperator/PointCloudReMesh.cpp b/src/PointCloudOperator/PointCloudReMesh.cpp new file mode 100644 index 0000000..fe6201e --- /dev/null +++ b/src/PointCloudOperator/PointCloudReMesh.cpp @@ -0,0 +1,17 @@ +/** + * @file PointCloudReMesh.cpp + * @brief None + * @author 陈增辉 (3045316072@qq.com) + * @version 2.5.0 + * @date 2024/4/4 + * @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved. + */ + +#include "PointCloudReMesh.h" + +namespace PointCloudOperator { + PointCloudReMesh::PointCloudReMesh(QObject* parent) + : QObject(parent) + { + } +} // namespace PointCloudOperator \ No newline at end of file diff --git a/src/PointCloudOperator/PointCloudReMesh.h b/src/PointCloudOperator/PointCloudReMesh.h new file mode 100644 index 0000000..4a4878e --- /dev/null +++ b/src/PointCloudOperator/PointCloudReMesh.h @@ -0,0 +1,128 @@ +/** + * @file PointCloudReMesh.h + * @brief 基于点云的网格表面重建 + * @author 陈增辉 (3045316072@qq.com) + * @version 2.5.0 + * @date 2024/4/4 + * @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved. + */ + +#ifndef LAMPCAE_POINTCLOUDREMESH_H +#define LAMPCAE_POINTCLOUDREMESH_H +// qt 相关头文件 +#include + +// 常用pcl 头文件库 +#include +#include +#include +#include +#include +#include + +#include //随机数 +#include +#include +#include // TicToc +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // 4PCS算法 +#include //K4PCS算法头文件 +#include +#include +#include +#include +#include //贪婪投影三角化算法类定义的头文件 +#include //移动立方体 +#include +#include //MLS +#include //泊松重建 +#include +#include +#include +#include +#include + +#include // TicToc +#include // 体素滤波 +#include // 体素滤波 +#include + +#include +#include +#include +#include +#include +#include //随机参数估计方法 +#include //模型定义 +#include //RANSAC分割 +#include +#include +#include //rand()头文件 +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//可视化相关头文件 +#include +#include +#include +#include +#include +#include +#include +#include +// Boost +#include + +// Visualization Toolkit (VTK) +#include + +#include "PointCloudOperatorAPI.h" + + +namespace PointCloudOperator { + + class PointCloudReMesh:public QObject { + Q_OBJECT + public: + PointCloudReMesh(QObject* parent=nullptr); + ~PointCloudReMesh()=default; + + + + }; + +} // namespace PointCloudOperator + +#endif // LAMPCAE_POINTCLOUDREMESH_H diff --git a/src/SelfDefObject/QFDialog.h b/src/SelfDefObject/QFDialog.h index a456556..d866869 100644 --- a/src/SelfDefObject/QFDialog.h +++ b/src/SelfDefObject/QFDialog.h @@ -1,16 +1,16 @@ /** * @file QFDialog.h * @brief 对话框基类头文件 - * @author LAMPCAE研发小组(LAMPCAE@diso.cn) + * @author FastCAE研发小组(FastCAE@diso.cn) * @version 2.5.0 * @date 2022-03-28 18:19 * @copyright Copyright (c) Since 2020 青岛数智船海科技有限公司 All rights reserved. * * ============================================================================ - * Program: LAMPCAE + * Program: FastCAE * * Copyright (c) Since 2020 青岛数智船海科技有限公司 All rights reserved. - * See License or http://www.LAMPCAE.com/ for details. + * See License or http://www.FastCAE.com/ for details. * * BSD 3-Clause License * diff --git a/src/WBCLFZSystemModule/AllHead.cpp b/src/WBCLFZSystemModule/AllHead.cpp index c65b8e5..2157fc9 100644 --- a/src/WBCLFZSystemModule/AllHead.cpp +++ b/src/WBCLFZSystemModule/AllHead.cpp @@ -1,6 +1,6 @@ #include "AllHead.h" -QSettings* getQSetting() +WBCLFZSYSTEMMODULEAPI QSettings* getQSetting() { QString fileName = QCoreApplication::applicationDirPath() + "/Config.ini"; @@ -19,7 +19,7 @@ QSettings* getQSetting() return setting; } -QString getOpenFilePath(QWidget* parent, const QString& caption, const QString& filter) +QString WBCLFZSYSTEMMODULEAPI getOpenFilePath(QWidget* parent, const QString& caption, const QString& filter) { QSettings* setting = getQSetting(); QString curpath = u8"."; @@ -38,7 +38,7 @@ QString getOpenFilePath(QWidget* parent, const QString& caption, const QString& return filepath; } -QString getSaveFilePath(QWidget* parent, const QString& caption, const QString& filter) +QString WBCLFZSYSTEMMODULEAPI getSaveFilePath(QWidget* parent, const QString& caption, const QString& filter) { QSettings* setting = getQSetting(); QString curpath = u8"."; diff --git a/src/WBCLFZSystemModule/AllHead.h b/src/WBCLFZSystemModule/AllHead.h index 97dc9e4..df349c7 100644 --- a/src/WBCLFZSystemModule/AllHead.h +++ b/src/WBCLFZSystemModule/AllHead.h @@ -2,6 +2,7 @@ #ifndef ALLHEAD_H #define ALLHEAD_H +#include "WBCLFZSystemModuleAPI.h" //================================== // 线性计算库优化 @@ -14,27 +15,27 @@ //===================================================== #include "../LAMPTool/referenceHeader.h" -#include "../LAMPTool/BaseToollib/BaseConstVariable.h" +#include "BaseConstVariable.h" // Basetoollib -#include "../LAMPTool/Basetoollib/BaseConstVariable.h" -#include "../LAMPTool/Basetoollib/BaseTool.h" -#include "../LAMPTool/Basetoollib/FileOperator.h" -//#include "Basetoollib/GeoOperator.h" -#include "../LAMPTool/Basetoollib/ImageOperatorBase.h" -//#include "Basetoollib/interpolation.h" +#include "BaseConstVariable.h" +#include "BaseTool.h" +#include "FileOperator.h" +//#include "GeoOperator.h" +#include "ImageOperatorBase.h" +//#include "interpolation.h" // SARBaseToolLib -//#include "SARBaseToolLib/BackScatterModel.h" -//#include "SARBaseToolLib/SARBaseTool.h" -//#include "SARBaseToolLib/SARCalibration.h" -#include "../LAMPTool/SARBaseToolLib/SARImageBase.h" +//#include "BackScatterModel.h" +//#include "SARBaseTool.h" +//#include "SARCalibration.h" +#include "LAMPTool/SARImageBase.h" // SARImage -#include "../LAMPTool/SARImage/FEKOBaseToolClass.h" -#include "../LAMPTool/SARImage/FEKONearBPBasic.h" -#include "../LAMPTool/FEKOSimulationSARClass.h" -#include "../LAMPTool/OCCTBase.h" -#include "../LAMPTool/FEKOFarFieldFileClass.h" +#include "LAMPTool/FEKOBaseToolClass.h" +#include "LAMPTool/FEKONearBPBasic.h" +#include "LAMPTool/FEKOSimulationSARClass.h" +#include "LAMPTool/OCCTBase.h" +#include "LAMPTool/FEKOFarFieldFileClass.h" //===================================================== // 内部库 SharedModuleLib @@ -303,12 +304,11 @@ // Visualization Toolkit (VTK) #include -#include "ui_pclvisualizer.h" #include "inputdialog.h" #include "BasePCL.h" #include "ToolDialog.h" #include "PointManagerClass.h" - +#include "WBCLFZSystemModuleAPI.h" @@ -342,11 +342,11 @@ class QObject; //======================================================= // 常用基础函数 //======================================================= ] -QSettings* getQSetting(); +WBCLFZSYSTEMMODULEAPI QSettings* getQSetting(); -QString getOpenFilePath(QWidget* parent = nullptr, const QString& caption = QString(), const QString& filter = QString()); +QString WBCLFZSYSTEMMODULEAPI getOpenFilePath(QWidget* parent = nullptr, const QString& caption = QString(), const QString& filter = QString()); -QString getSaveFilePath(QWidget* parent = nullptr, const QString& caption = QString(), const QString& filter = QString()); +QString WBCLFZSYSTEMMODULEAPI getSaveFilePath(QWidget* parent = nullptr, const QString& caption = QString(), const QString& filter = QString()); /* diff --git a/src/WBCLFZSystemModule/CMakeLists.txt b/src/WBCLFZSystemModule/CMakeLists.txt index 3b9571f..620ea56 100644 --- a/src/WBCLFZSystemModule/CMakeLists.txt +++ b/src/WBCLFZSystemModule/CMakeLists.txt @@ -65,27 +65,33 @@ link_directories("C:/PCL/lib") # 自动添加include目录 #----------------------------------------------------------------------------- set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_AUTOUIC ON) find_package(Qt5 REQUIRED COMPONENTS Core Quick Sql Core Xml Opengl Gui Svg Xmlpatterns Uitools Widgets Qml Printsupport Sensors Quickwidgets Quick Concurrent Openglextensions Charts Datavisualization) find_package(PCL) include_directories(${PCL_INCLUDE_DIRS}) link_directories(${PCL_LIBRARY_DIRS}) add_definitions(${PCL_DEFINITIONS}) - +find_package(unofficial-sqlite3 CONFIG REQUIRED) #----------------------------------------------------------------------------- # 添加资源文件 #----------------------------------------------------------------------------- set(_qrc "${CMAKE_CURRENT_SOURCE_DIR}/../qrc/WBCLFZSystemModule.qrc") - +#set(_qrc "${CMAKE_CURRENT_SOURCE_DIR}/../qrc/qianfan.qrc") +set(_lang "${CMAKE_CURRENT_SOURCE_DIR}/../qrc/translations.qrc") qt5_add_resources(_resource ${_qrc} ${_lang}) +message("qrc source path ${_qrc}") + #----------------------------------------------------------------------------- # 源码扫描 #----------------------------------------------------------------------------- -file(GLOB_RECURSE _ui "*.ui") -file(GLOB_RECURSE _header "*.h" "*.hxx") -file(GLOB_RECURSE _source "*.cpp") +file(GLOB_RECURSE _ui "*.ui" ) +file(GLOB_RECURSE _header "*.h" "*.hxx" ) +file(GLOB_RECURSE _source "*.cpp" ) + + qt5_wrap_ui(_interface ${_ui}) #----------------------------------------------------------------------------- @@ -96,14 +102,12 @@ add_library(WBCLFZSystemModule ${_interface} ${_header} ${_source} - WBCLFZ.cpp - WBCLFZ.h ) #----------------------------------------------------------------------------- # 添加接口声明宏 #----------------------------------------------------------------------------- -target_compile_definitions(WBCLFZSystemModule PRIVATE "WBCLFZSystemModule_API") +target_compile_definitions(WBCLFZSystemModule PRIVATE WBCLFZSYSTEMMODULE_API) #----------------------------------------------------------------------------- @@ -120,13 +124,14 @@ list(APPEND _depend_library qcustomplot LAMPTool qscintilla2 qhexedit) list(APPEND _runtimes_libraries -Qt5::DBus Qt5::Core Qt5::Xml Qt5::OpenGL Qt5::Gui Qt5::Svg Qt5::Widgets Qt5::Qml Qt5::DataVisualization Qt5::Charts Qt5::PrintSupport + Qt5::Core Qt5::Gui Qt5::Widgets Qt5::DBus Qt5::Core Qt5::Xml Qt5::OpenGL Qt5::Gui Qt5::Svg Qt5::Widgets Qt5::Qml Qt5::DataVisualization Qt5::Charts Qt5::PrintSupport Qt5::Test ) list(APPEND _runtimes_libraries - OpenCASCADE::Freetype OpenCASCADE::TKBO OpenCASCADE::TKBRep OpenCASCADE::TKBool OpenCASCADE::TKCAF OpenCASCADE::TKCDF OpenCASCADE::TKG2d OpenCASCADE::TKG3d OpenCASCADE::TKGeomAlgo OpenCASCADE::TKGeomBase OpenCASCADE::TKHLR OpenCASCADE::TKIGES OpenCASCADE::TKLCAF OpenCASCADE::TKMath OpenCASCADE::TKMesh OpenCASCADE::TKPrim OpenCASCADE::TKSTEP OpenCASCADE::TKSTEP209 OpenCASCADE::TKSTEPAttr OpenCASCADE::TKSTEPBase OpenCASCADE::TKService OpenCASCADE::TKShHealing OpenCASCADE::TKTopAlgo OpenCASCADE::TKV3d OpenCASCADE::TKVCAF OpenCASCADE::TKXCAF OpenCASCADE::TKXDEIGES OpenCASCADE::TKXSBase OpenCASCADE::TKernel Qt5::Widgets Qt5::Xml VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersSources VTK::FiltersStatistics VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingMath VTK::InteractionStyle VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2 VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::lz4 VTK::lzma VTK::sys VTK::zlib VTK::IOGeometry + OpenCASCADE::TKOffset OpenCASCADE::TKSTL OpenCASCADE::Freetype OpenCASCADE::TKBO OpenCASCADE::TKBRep OpenCASCADE::TKFillet OpenCASCADE::TKBool OpenCASCADE::TKCAF OpenCASCADE::TKCDF OpenCASCADE::TKG2d OpenCASCADE::TKG3d OpenCASCADE::TKGeomAlgo OpenCASCADE::TKGeomBase OpenCASCADE::TKHLR OpenCASCADE::TKIGES OpenCASCADE::TKLCAF OpenCASCADE::TKMath OpenCASCADE::TKMesh OpenCASCADE::TKPrim OpenCASCADE::TKSTEP OpenCASCADE::TKSTEP209 OpenCASCADE::TKSTEPAttr OpenCASCADE::TKSTEPBase OpenCASCADE::TKService OpenCASCADE::TKShHealing OpenCASCADE::TKTopAlgo OpenCASCADE::TKV3d OpenCASCADE::TKVCAF OpenCASCADE::TKXCAF OpenCASCADE::TKXDEIGES OpenCASCADE::TKXSBase OpenCASCADE::TKernel Qt5::Widgets Qt5::Xml VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersSources VTK::FiltersStatistics VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingMath VTK::InteractionStyle VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2 VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::lz4 VTK::lzma VTK::sys VTK::zlib VTK::IOGeometry ) + target_include_directories(WBCLFZSystemModule PUBLIC ${Qwt_INCLUDE_DIRS}) @@ -134,6 +139,8 @@ target_link_libraries(WBCLFZSystemModule PUBLIC ${_runtimes_libraries} ${_depend_library} ${PCL_LIBRARIES} + unofficial::sqlite3::sqlite3 + GDAL::GDAL ) #----------------------------------------------------------------------------- diff --git a/src/WBCLFZSystemModule/EchoShowProcess/FEKOResultImport.cpp b/src/WBCLFZSystemModule/EchoShowProcess/FEKOResultImport.cpp index 989b607..3d48159 100644 --- a/src/WBCLFZSystemModule/EchoShowProcess/FEKOResultImport.cpp +++ b/src/WBCLFZSystemModule/EchoShowProcess/FEKOResultImport.cpp @@ -1,5 +1,5 @@ #include "FEKOResultImport.h" -#include "BaseToolLib/FileOperator.h" +#include "FileOperator.h" #include "SharedModuleLib/BaseUiTool.h" #include "TaskXml/TaskTreeClass.h" #include "EchoTableEditWindow.h" diff --git a/src/WBCLFZSystemModule/PointCloudProcess/pclvisualizer.h b/src/WBCLFZSystemModule/PointCloudProcess/pclvisualizer.h index 6192d5e..adfbe79 100644 --- a/src/WBCLFZSystemModule/PointCloudProcess/pclvisualizer.h +++ b/src/WBCLFZSystemModule/PointCloudProcess/pclvisualizer.h @@ -137,12 +137,11 @@ // Visualization Toolkit (VTK) #include -#include "ui_pclvisualizer.h" #include "inputdialog.h" #include "BasePCL.h" #include "ToolDialog.h" #include "PointManagerClass.h" - +#include "ui_pclvisualizer.h" QT_BEGIN_NAMESPACE namespace Ui { diff --git a/src/WBCLFZSystemModule/PointCloudProcess/pclvisualizer.ui b/src/WBCLFZSystemModule/PointCloudProcess/pclvisualizer.ui index ee6438a..bd5436f 100644 --- a/src/WBCLFZSystemModule/PointCloudProcess/pclvisualizer.ui +++ b/src/WBCLFZSystemModule/PointCloudProcess/pclvisualizer.ui @@ -106,7 +106,7 @@ 0 0 1059 - 22 + 23 @@ -1869,7 +1869,7 @@ p, li { white-space: pre-wrap; } - + diff --git a/src/WBCLFZSystemModule/WBCLFZ.h b/src/WBCLFZSystemModule/WBCLFZ.h index 1e0cd76..12dd7d0 100644 --- a/src/WBCLFZSystemModule/WBCLFZ.h +++ b/src/WBCLFZSystemModule/WBCLFZ.h @@ -4,30 +4,14 @@ #ifndef LAMPCAE_WBCLFZ_H #define LAMPCAE_WBCLFZ_H +#include "WBCLFZSystemModuleAPI.h" #include "WBCLFZ.h" #include "AllHead.h" -#include "WBCLFZSystemModuleAPI.h" + namespace WBCLFZ { - // 点云操作类 - class WBCLFZSystemModuleAPI PointCloudOperator { - pcl::PointCloud::Ptr ReadPointCloudFromFile(QString filename); - }; - - // 属性表操作类 - class WBCLFZSystemModuleAPI sqlDBOperator { - - }; - - // FEKO仿真操作类 - class WBCLFZSystemModuleAPI FekoSimulationOperator { - - - - }; - } // namespace WBCLFZ #endif // LAMPCAE_WBCLFZ_H diff --git a/src/WBCLFZSystemModule/WBCLFZSystemModule.h b/src/WBCLFZSystemModule/WBCLFZSystemModule.h index 4df8930..bb5e140 100644 --- a/src/WBCLFZSystemModule/WBCLFZSystemModule.h +++ b/src/WBCLFZSystemModule/WBCLFZSystemModule.h @@ -5,8 +5,9 @@ #include #include "ui_WBCLFZSystemModule.h" +#include "AllHead.h" -class WBCLFZSystemModule : public QMainWindow +class WBCLFZSYSTEMMODULEAPI WBCLFZSystemModule : public QMainWindow { Q_OBJECT diff --git a/src/WBCLFZSystemModule/WBCLFZSystemModule.ui b/src/WBCLFZSystemModule/WBCLFZSystemModule.ui index 2ef6a1b..f02a80c 100644 --- a/src/WBCLFZSystemModule/WBCLFZSystemModule.ui +++ b/src/WBCLFZSystemModule/WBCLFZSystemModule.ui @@ -51,7 +51,7 @@ 0 0 857 - 26 + 23 @@ -67,7 +67,7 @@ - + diff --git a/src/WBCLFZSystemModule/WBCLFZSystemModuleAPI.h b/src/WBCLFZSystemModule/WBCLFZSystemModuleAPI.h index 1e98697..4fd81aa 100644 --- a/src/WBCLFZSystemModule/WBCLFZSystemModuleAPI.h +++ b/src/WBCLFZSystemModule/WBCLFZSystemModuleAPI.h @@ -1,13 +1,13 @@ -#ifndef _WBCLFZSystemModule_H_ -#define _WBCLFZSystemModule_H_ +#ifndef _WBCLFZSYSTEMMODULE_H_ +#define _WBCLFZSYSTEMMODULE_H_ #include -#if defined(WBCLFZSystemModule_API) -#define WBCLFZSystemModuleAPI Q_DECL_EXPORT +#if defined(WBCLFZSYSTEMMODULE_API) +#define WBCLFZSYSTEMMODULEAPI Q_DECL_EXPORT #else -#define WBCLFZSystemModuleAPI Q_DECL_IMPORT +#define WBCLFZSYSTEMMODULEAPI Q_DECL_IMPORT #endif #endif diff --git a/src/qcustomplot/CMakeLists.txt b/src/qcustomplot/CMakeLists.txt index 2713191..7412fcf 100644 --- a/src/qcustomplot/CMakeLists.txt +++ b/src/qcustomplot/CMakeLists.txt @@ -15,6 +15,7 @@ set(QCUSTOMPLOT_MOC_HDR qcustomplot.h ) -add_library(qcustomplot ${QCUSTOMPLOT_SRC} ${QCUSTOMPLOT_HDR} ${QCUSTOMPLOT_MOC}) +add_library(qcustomplot STATIC + ${QCUSTOMPLOT_SRC} ${QCUSTOMPLOT_HDR} ${QCUSTOMPLOT_MOC}) target_link_libraries(qcustomplot PUBLIC Qt5::Widgets Qt5::PrintSupport) diff --git a/src/qhexedit/CMakeLists.txt b/src/qhexedit/CMakeLists.txt index 9eaf601..b777373 100644 --- a/src/qhexedit/CMakeLists.txt +++ b/src/qhexedit/CMakeLists.txt @@ -26,7 +26,7 @@ qt5_wrap_ui(_interface ${_ui}) #----------------------------------------------------------------------------- # 添加动态库目标 #----------------------------------------------------------------------------- -add_library(qhexedit +add_library(qhexedit STATIC ${_resource} ${_interface} ${_header} diff --git a/src/qrc/mesh/delete_face.png b/src/qrc/mesh/delete_face.png new file mode 100644 index 0000000..c3ae1de Binary files /dev/null and b/src/qrc/mesh/delete_face.png differ diff --git a/src/qrc/mesh/delete_facevert.png b/src/qrc/mesh/delete_facevert.png new file mode 100644 index 0000000..c810f9d Binary files /dev/null and b/src/qrc/mesh/delete_facevert.png differ diff --git a/src/qrc/mesh/delete_vert.png b/src/qrc/mesh/delete_vert.png new file mode 100644 index 0000000..ba073ae Binary files /dev/null and b/src/qrc/mesh/delete_vert.png differ diff --git a/src/qrc/qianfan.qrc b/src/qrc/qianfan.qrc index 396cbb2..f05dcd7 100644 --- a/src/qrc/qianfan.qrc +++ b/src/qrc/qianfan.qrc @@ -187,6 +187,11 @@ QUI/post/isocurve.png QUI/post/open.png + + mesh/delete_face.png + mesh/delete_facevert.png + mesh/delete_vert.png + PointCloudProcess/images/files/add.png PointCloudProcess/images/files/bgColor.png diff --git a/src/qscintilla2/CMakeLists.txt b/src/qscintilla2/CMakeLists.txt index 6f136c8..b99146a 100644 --- a/src/qscintilla2/CMakeLists.txt +++ b/src/qscintilla2/CMakeLists.txt @@ -37,7 +37,7 @@ qt5_wrap_ui(_interface ${_ui}) #----------------------------------------------------------------------------- # 添加动态库目标 #----------------------------------------------------------------------------- -add_library(qscintilla2 +add_library(qscintilla2 STATIC ${_resource} ${_interface} ${_header} @@ -54,7 +54,7 @@ get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY) #----------------------------------------------------------------------------- # 添加接口声明宏 #----------------------------------------------------------------------------- -target_compile_definitions(qscintilla2 PUBLIC "qscintilla2_API") +target_compile_definitions(qscintilla2 PUBLIC "qscintilla2_API") list(APPEND _runtimes_libraries