增加部分未管理的文件
parent
7ff3aa55d6
commit
b43460b576
|
@ -0,0 +1,15 @@
|
|||
#include "LAMPToolAPI.h"
|
||||
#include "BackScatterModel.h"
|
||||
#include <complex>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
double LAMPTOOLAPI MuhlemanSimulationBackScatter(double incidentAngle)
|
||||
{
|
||||
return 0.0133*cos(incidentAngle)/pow(sin(incidentAngle)+0.1*cos(incidentAngle), 3);
|
||||
}
|
||||
|
||||
Eigen::MatrixXd LAMPTOOLAPI MuhlemanSimulationBackScatter(Eigen::MatrixXd incidentAngle)
|
||||
{
|
||||
return 0.0133 * (incidentAngle.array().cos()) / ((incidentAngle.array().sin()) + cos(incidentAngle.array().cos()*0.1).pow(3));
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
#ifndef _BACKSCATTERMODEL_H_
|
||||
#define _BACKSCATTERMODEL_H_
|
||||
|
||||
|
||||
#include "LAMPToolAPI.h"
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Dense>
|
||||
#include "LAMPToolAPI.h"
|
||||
|
||||
double LAMPTOOLAPI MuhlemanSimulationBackScatter(double incidentAngle);
|
||||
Eigen::MatrixXd LAMPTOOLAPI MuhlemanSimulationBackScatter(Eigen::MatrixXd incidentAngle);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef BASECONSTVARIABLE_H
|
||||
#define BASECONSTVARIABLE_H
|
||||
#include "LAMPToolAPI.h"
|
||||
|
||||
#include <complex>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
#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
|
|
@ -0,0 +1,256 @@
|
|||
#pragma once
|
||||
#include "BaseTool.h"
|
||||
///
|
||||
///
|
||||
//#define EIGEN_USE_MKL_ALL
|
||||
//#define EIGEN_VECTORIZE_SSE4_2
|
||||
//#include <mkl.h>
|
||||
|
||||
#include "referenceHeader.h"
|
||||
#include <iostream>
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Dense>
|
||||
#include <time.h>
|
||||
//#include <mkl.h>
|
||||
#include <string>
|
||||
#include <omp.h>
|
||||
|
||||
#include < io.h >
|
||||
#include < stdio.h >
|
||||
#include < stdlib.h >
|
||||
#include <gdal.h>
|
||||
#include <gdal_priv.h>
|
||||
#include <gdalwarper.h>
|
||||
//#include <ogr_geos.h>
|
||||
#include <ogrsf_frmts.h> //#include "ogrsf_frmts.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <proj.h>
|
||||
#include "GeoOperator.h"
|
||||
|
||||
|
||||
#include "baseTool.h"
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
|
||||
|
||||
|
||||
|
||||
QString LAMPTOOLAPI 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 LAMPTOOLAPI 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<QString> LAMPTOOLAPI splitString(const QString& str, char delimiter)
|
||||
{
|
||||
QStringList tokens = str.split(delimiter);
|
||||
return convertQStringListToStdVector(tokens);
|
||||
}
|
||||
|
||||
|
||||
complex<double> LAMPTOOLAPI Cubic_Convolution_interpolation(double u, double v, Eigen::MatrixX<complex<double>> img)
|
||||
{
|
||||
if (img.rows() != 4 || img.cols() != 4) {
|
||||
throw exception("the size of img's block is not right");
|
||||
}
|
||||
// 斤拷锟斤拷模锟斤拷
|
||||
Eigen::MatrixX<complex<double>> wrc(1, 4);// 使锟斤拷 complex<double> 斤拷锟斤拷要原斤拷为锟剿伙拷取值
|
||||
Eigen::MatrixX<complex<double>> 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<complex<double>> interValue = wrc * img * wcr;
|
||||
return interValue(0, 0);
|
||||
}
|
||||
|
||||
complex<double> LAMPTOOLAPI Cubic_kernel_weight(double s)
|
||||
{
|
||||
s = abs(s);
|
||||
if (s <= 1) {
|
||||
return complex<double>(1.5 * s * s * s - 2.5 * s * s + 1, 0);
|
||||
}
|
||||
else if (s <= 2) {
|
||||
return complex<double>(-0.5 * s * s * s + 2.5 * s * s - 4 * s + 2, 0);
|
||||
}
|
||||
else {
|
||||
return complex<double>(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// p11 p12 -- x
|
||||
/// p0(u,v)
|
||||
/// p21 p22
|
||||
/// |
|
||||
/// y
|
||||
/// p11(0,0)
|
||||
/// p21(0,1)
|
||||
/// P12(1,0)
|
||||
/// p22(1,1)
|
||||
/// </summary>
|
||||
/// <param name="p0">x,y,z</param>
|
||||
/// <param name="p1">x,y,z</param>
|
||||
/// <param name="p2">x,y,z</param>
|
||||
/// <param name="p3">x,y,z</param>
|
||||
/// <param name="p4">x,y,z</param>
|
||||
/// <returns></returns>
|
||||
double LAMPTOOLAPI 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 LAMPTOOLAPI 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 LAMPTOOLAPI 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 LAMPTOOLAPI sind(double degree)
|
||||
{
|
||||
return sin(degree * d2r);
|
||||
}
|
||||
|
||||
double LAMPTOOLAPI cosd(double d)
|
||||
{
|
||||
return cos(d * d2r);
|
||||
}
|
||||
|
||||
|
||||
string LAMPTOOLAPI Convert(float Num)
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << Num;
|
||||
string str(oss.str());
|
||||
return str;
|
||||
}
|
||||
|
||||
QString LAMPTOOLAPI 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<QString> LAMPTOOLAPI convertQStringListToStdVector(const QStringList& qStringList)
|
||||
{
|
||||
std::vector<QString> stdVector;
|
||||
|
||||
for (const QString& str : qStringList) {
|
||||
stdVector.push_back(str);
|
||||
}
|
||||
|
||||
return stdVector;
|
||||
};
|
|
@ -0,0 +1,94 @@
|
|||
#pragma once
|
||||
#pragma once
|
||||
#ifndef BASETOOL_H
|
||||
#define BASETOOL_H
|
||||
|
||||
///
|
||||
/// 基本类、基本函数
|
||||
///
|
||||
//#define EIGEN_USE_MKL_ALL
|
||||
//#define EIGEN_VECTORIZE_SSE4_2
|
||||
//#include <mkl.h>
|
||||
|
||||
//#include <mkl.h>
|
||||
#include <complex>
|
||||
#include <iostream>
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Dense>
|
||||
#include <time.h>
|
||||
#include <string>
|
||||
#include <omp.h>
|
||||
#include "referenceHeader.h"
|
||||
#include <gdal.h>
|
||||
#include <gdal_priv.h>
|
||||
#include <gdalwarper.h>
|
||||
#include <ogrsf_frmts.h>
|
||||
#include <fstream>
|
||||
#include "GeoOperator.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
|
||||
|
||||
///////////////////////////////////// 运行时间打印 //////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
QString LAMPTOOLAPI getCurrentTimeString();
|
||||
QString LAMPTOOLAPI getCurrentShortTimeString();
|
||||
|
||||
std::vector<QString> LAMPTOOLAPI splitString(const QString& str, char delimiter);
|
||||
|
||||
|
||||
|
||||
/////////////////////////////// 基本图像类 结束 //////////////////////////////////////////////////////////
|
||||
|
||||
string LAMPTOOLAPI Convert(float Num);
|
||||
QString LAMPTOOLAPI JoinPath(const QString& path, const QString& filename);
|
||||
|
||||
////////////////////////////// 坐标部分基本方法 //////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////// 坐标部分基本方法 //////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////// 插值 ////////////////////////////////////////////
|
||||
|
||||
complex<double> LAMPTOOLAPI Cubic_Convolution_interpolation(double u, double v, Eigen::MatrixX<complex<double>> img);
|
||||
|
||||
complex<double> LAMPTOOLAPI Cubic_kernel_weight(double s);
|
||||
|
||||
double LAMPTOOLAPI Bilinear_interpolation(Landpoint p0, Landpoint p11, Landpoint p21, Landpoint p12, Landpoint p22);
|
||||
|
||||
bool LAMPTOOLAPI onSegment(Point_3d Pi, Point_3d Pj, Point_3d Q);
|
||||
|
||||
Point_3d LAMPTOOLAPI 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 LAMPTOOLAPI sind(double degree);
|
||||
|
||||
double LAMPTOOLAPI cosd(double d);
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,344 @@
|
|||
#pragma once
|
||||
#ifndef _FEKOBASETOOLCLASS_H_
|
||||
#define _FEKOBASETOOLCLASS_H_
|
||||
|
||||
#include <complex>
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Dense>
|
||||
#include <omp.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gdal.h>
|
||||
#include <gdal_utils.h>
|
||||
#include <gdal_priv.h>
|
||||
#include <gdalwarper.h>
|
||||
#include <proj.h>
|
||||
#include <string.h>
|
||||
#include <memory.h>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "referenceHeader.h"
|
||||
#include "GeoOperator.h"
|
||||
|
||||
|
||||
/**
|
||||
* 此类用于FEKO的基本类型,主要功能如下:
|
||||
* 1. 根据分辨率、中心频率、带宽,近远斜距,计算频率起始点,以及采样点数
|
||||
* 2. 根据起始成像点、成像时长、PRF采样点数,获取PRF采样点数
|
||||
* 3. 结合 PRF采样点坐标,入射角,以及与飞行方向的夹角(默认为 90度), 参考高程,计算入射波的参考平面部分
|
||||
* 4.
|
||||
***/
|
||||
|
||||
namespace FEKOBase {
|
||||
|
||||
//==========================================================
|
||||
// FEKO常用坐标系
|
||||
//==========================================================
|
||||
enum FEKOCoordinateSystem {
|
||||
Spherical, // 球坐标系
|
||||
Cartesian, // 笛卡尔坐标系
|
||||
UNKONWFEKOCOORDINATESYSTEM // 必须为最后一个表示未知
|
||||
};
|
||||
FEKOBase::FEKOCoordinateSystem LAMPTOOLAPI FEKOCoordinateSystemString2Enum(QString str);
|
||||
QString LAMPTOOLAPI QString2FEKOCoordinateSystem(FEKOBase::FEKOCoordinateSystem mode);
|
||||
|
||||
|
||||
//==========================================================
|
||||
// FEKO成像模式枚举
|
||||
//==========================================================
|
||||
enum FEKOImageMode
|
||||
{
|
||||
Strip,
|
||||
Scane,
|
||||
ISAR,
|
||||
CircleSAR,
|
||||
UNKNOW
|
||||
};
|
||||
|
||||
FEKOImageMode LAMPTOOLAPI FEKOImageModeString2Enum(QString str);
|
||||
QString LAMPTOOLAPI 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 右
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
///// 函数类
|
||||
//////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// 频率Setting
|
||||
/// </summary>
|
||||
/// <param name="centerFreq">中心频率 GHZ</param>
|
||||
/// <param name="resolution">分辨率 米</param>
|
||||
/// <param name="bandWidth">带宽 GHz</param>
|
||||
/// <param name="scenceRange">分辨率 米</param>
|
||||
/// <param name="isResolution"></param>
|
||||
/// <returns></returns>
|
||||
freqParams LAMPTOOLAPI getFreqSetting(double centerFreq, double resolution, double bandWidth, double scenceRange, bool isResolution = false);
|
||||
|
||||
FEKOSatelliteParams LAMPTOOLAPI 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 LAMPTOOLAPI createFEKOSatelliteParams(SatelliteState pose, double incidenceAngle, double AzAngle, FEKOantPitionDirect antpos, size_t PRFIdx = 0);
|
||||
|
||||
SatelliteState LAMPTOOLAPI FEKOSatelliteParams2SatelliteState(FEKOSatelliteParams parmas);
|
||||
FEKOantPitionDirect LAMPTOOLAPI FEKOSatelliteParams2FEKOantPitionDirect(FEKOSatelliteParams parmas);
|
||||
|
||||
/// <summary>
|
||||
/// 将卫星姿态转换为 FEKO 天线坐标,
|
||||
/// 注意默认模型的Z轴为天线的指向
|
||||
/// </summary>
|
||||
/// <param name="satepos">卫星矢量</param>
|
||||
/// <param name="incidenceAngle">入射角</param>
|
||||
/// <param name="AzAngle">侧视角</param>
|
||||
/// <param name="isRIGHT">是否为右视</param>
|
||||
/// <param name="antposition_Direct">结果文件</param>
|
||||
/// <param name="inDs">输入模型</param>
|
||||
/// <returns></returns>
|
||||
TopoDS_Shape LAMPTOOLAPI 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<double> freqlist;
|
||||
std::vector<ElectricFieldData> electricFieldDataList; // 单频点信息
|
||||
};
|
||||
|
||||
bool LAMPTOOLAPI compareElectricFieldDataInFreq(const ElectricFieldData& a, const ElectricFieldData& b);
|
||||
bool LAMPTOOLAPI comparePRFPluseDataInPRFIdx(const PRFPluseData& a, const PRFPluseData& b);
|
||||
|
||||
class LAMPTOOLAPI NearFieldEchoCSVParser {
|
||||
public:
|
||||
NearFieldEchoCSVParser();
|
||||
~NearFieldEchoCSVParser();
|
||||
private:
|
||||
bool usePRFCountMode = true;
|
||||
//std::vector<ElectricFieldData> electricFieldDataList;
|
||||
QMap<QString, std::vector<ElectricFieldData>> electricFieldDataList; // 电场数据
|
||||
//QMap<QString, PRFPluseData> prfPluseMap;
|
||||
std::vector<PRFPluseData> 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 LAMPTOOLAPI 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
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 加窗
|
||||
/// </summary>
|
||||
/// <param name="echo">行:脉冲,列:频点</param>
|
||||
/// <returns></returns>
|
||||
Eigen::MatrixXd LAMPTOOLAPI WINDOWFun(Eigen::MatrixXcd& echo, ImageAlgWindowFun winfun = ImageAlgWindowFun::HANMMING);
|
||||
|
||||
enum FEKOImageAlgorithm
|
||||
{
|
||||
TBP_TIME,
|
||||
TBP_FREQ,
|
||||
UNKONW // 必须为最后一个表示未知
|
||||
};
|
||||
|
||||
QList<QString> LAMPTOOLAPI getFEKOImageAlgorithmList();
|
||||
FEKOImageAlgorithm LAMPTOOLAPI String2FEKOImageAlgorithm(QString str);
|
||||
QString LAMPTOOLAPI FEKOImageAlgorithm2String(FEKOImageAlgorithm alg);
|
||||
|
||||
// 请仿照FEKOImageAlgorithm枚举的写法,构建QString 与 ImageAlgWindowFun 的转换函数
|
||||
QList<QString> LAMPTOOLAPI getImageAlgWindowFunList();
|
||||
ImageAlgWindowFun LAMPTOOLAPI String2ImageAlgWindowFun(QString str);
|
||||
QString LAMPTOOLAPI ImageAlgWindowFun2String(ImageAlgWindowFun alg);
|
||||
|
||||
|
||||
bool LAMPTOOLAPI 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 LAMPTOOLAPI 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成像
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,161 @@
|
|||
#pragma once
|
||||
#ifndef _FEKONEARBPBASIC_H_
|
||||
#define _FEKONEARBPBASIC_H_
|
||||
|
||||
/**
|
||||
* 适用于FEKO的近场结果的 BP 成像算法
|
||||
*
|
||||
**/
|
||||
#include "LAMPToolAPI.h"
|
||||
#include <complex>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Dense>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "referenceHeader.h"
|
||||
|
||||
|
||||
|
||||
// FEKO 几何关系处理
|
||||
|
||||
/// <summary>
|
||||
/// 笛卡尔坐标系,转换为 极坐标系
|
||||
/// </summary>
|
||||
/// <param name="CartesianPoint">[X,Y,Z;X1,Y1,Z1]</param>
|
||||
/// <returns></returns>
|
||||
Eigen::MatrixXd LAMPTOOLAPI Cartesian2Spherical(Eigen::MatrixXd CartesianPoint);
|
||||
|
||||
/// <summary>
|
||||
/// 时域BP
|
||||
/// </summary>
|
||||
class LAMPTOOLAPI 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 LAMPTOOLAPI 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<typename T>
|
||||
Eigen::MatrixXcd LAMPTOOLAPI 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);
|
||||
|
||||
/// <summary>
|
||||
/// 时域BP --- FBP
|
||||
/// </summary>
|
||||
class LAMPTOOLAPI 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<typename T>
|
||||
Eigen::MatrixXcd LAMPTOOLAPI 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 LAMPTOOLAPI FBP2DProcess(QString in_path, QString out_path, double Rref, double minX, double maxX, double minY, double maxY, double PlaneZ, int ImageHeight, int ImageWidth);
|
||||
|
||||
// 生成成像的数据文件
|
||||
int LAMPTOOLAPI build2Bin(QString path,int width,int height,std::vector<double> &freqs,Eigen::MatrixXd AntPositions,Eigen::MatrixXcd echo);
|
||||
|
||||
|
||||
// 定义插值函数,以处理复数值
|
||||
std::complex<double> LAMPTOOLAPI InterpolateComplex(Eigen::MatrixXd& xi, Eigen::MatrixXd& yi, Eigen::MatrixXcd& data, double x, double y);
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 远场成像
|
||||
/// </summary>
|
||||
class LAMPTOOLAPI 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() { return this->Frequencylist(this->get_Nf() - 1) > this->Frequencylist(0) ? this->Frequencylist(0) : this->Frequencylist(this->get_Nf() - 1); };
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
// FEKONearBpBaseImage.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
|
||||
//
|
||||
#include "FEKONearBPBasic.h"
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,188 @@
|
|||
#include "FileOperator.h"
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <string>
|
||||
#include <memory.h>
|
||||
#include <memory>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <QDebug>
|
||||
|
||||
std::vector<QString> LAMPTOOLAPI getFilelist(const QString& folderpath, const QString& filenameExtension, int (*logfun)(QString logtext, int value))
|
||||
{
|
||||
QString filenameExtensionStr = filenameExtension;
|
||||
filenameExtensionStr = filenameExtensionStr.remove(0, 1);
|
||||
std::vector<QString> 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<QString>(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QString LAMPTOOLAPI getParantFolderNameFromPath(const QString& path)
|
||||
{
|
||||
QDir directory(path);
|
||||
directory.cdUp();
|
||||
QString parentPath = directory.absolutePath();
|
||||
return directory.dirName();
|
||||
}
|
||||
|
||||
QString LAMPTOOLAPI getParantFromPath(const QString& path)
|
||||
{
|
||||
//qDebug() << path;
|
||||
QDir directory(path);
|
||||
directory.cdUp();
|
||||
QString parentPath = directory.absolutePath();
|
||||
//qDebug() << parentPath;
|
||||
return parentPath;
|
||||
}
|
||||
|
||||
QString LAMPTOOLAPI getFileNameFromPath(const QString& path)
|
||||
{
|
||||
QFileInfo fileInfo(path);
|
||||
return fileInfo.fileName();
|
||||
}
|
||||
|
||||
bool LAMPTOOLAPI isDirectory(const QString& path)
|
||||
{
|
||||
QFileInfo fileinfo(path);
|
||||
return fileinfo.isDir();
|
||||
}
|
||||
|
||||
bool LAMPTOOLAPI isExists(const QString& path)
|
||||
{
|
||||
QFileInfo fileinfo(path);
|
||||
return fileinfo.exists();
|
||||
}
|
||||
|
||||
bool LAMPTOOLAPI isFile(const QString& path)
|
||||
{
|
||||
QFileInfo fileinfo(path);
|
||||
return fileinfo.isFile();
|
||||
}
|
||||
|
||||
int LAMPTOOLAPI 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;
|
||||
}
|
||||
|
||||
LAMPTOOLAPI 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 LAMPTOOLAPI exists_test(const QString& name)
|
||||
{
|
||||
return isExists(name);
|
||||
}
|
||||
|
||||
size_t LAMPTOOLAPI 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 LAMPTOOLAPI 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 LAMPTOOLAPI 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 LAMPTOOLAPI 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"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef FILEOPERATOR_H
|
||||
#define FILEOPERATOR_H
|
||||
|
||||
#include "../LAMPTool/referenceHeader.h"
|
||||
#include <string.h>
|
||||
#include <memory.h>
|
||||
#include <memory>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <QString>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
bool LAMPTOOLAPI isDirectory(const QString& path);
|
||||
bool LAMPTOOLAPI isExists(const QString& path);
|
||||
bool LAMPTOOLAPI isFile(const QString& path);
|
||||
void LAMPTOOLAPI removeFile(const QString& filePath);
|
||||
unsigned long LAMPTOOLAPI convertToULong(const QString& input);
|
||||
/// <summary>
|
||||
/// 获取文件(绝对路径)
|
||||
/// </summary>
|
||||
/// <param name="folderpath"></param>
|
||||
/// <param name="FilenameExtension"></param>
|
||||
/// <returns></returns>
|
||||
std::vector<QString> LAMPTOOLAPI getFilelist(const QString& folderpath, const QString& FilenameExtension = ".*",int (*logfun)(QString logtext,int value)=nullptr);
|
||||
|
||||
QString LAMPTOOLAPI getParantFolderNameFromPath(const QString& path);
|
||||
|
||||
QString LAMPTOOLAPI getFileNameFromPath(const QString& path);
|
||||
|
||||
int LAMPTOOLAPI write_binfile(char* filepath, char* data, size_t data_len);
|
||||
|
||||
LAMPTOOLAPI char* read_textfile(char* text_path, int* length);
|
||||
|
||||
bool LAMPTOOLAPI exists_test(const QString& name);
|
||||
|
||||
size_t LAMPTOOLAPI fsize(FILE* fp);
|
||||
|
||||
QString LAMPTOOLAPI getParantFromPath(const QString& path);
|
||||
void LAMPTOOLAPI copyFile(const QString& sourcePath, const QString& destinationPath);
|
||||
// QT FileOperator
|
||||
#endif
|
|
@ -0,0 +1,272 @@
|
|||
#include "GeoOperator.h"
|
||||
#include <iostream>
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Dense>
|
||||
#include <time.h>
|
||||
//#include <mkl.h>
|
||||
#include <string>
|
||||
#include <omp.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gdal.h>
|
||||
#include <gdal_priv.h>
|
||||
#include <gdalwarper.h>
|
||||
//#include <ogr_geos.h>
|
||||
#include <ogrsf_frmts.h> //#include "ogrsf_frmts.h"
|
||||
#include <fstream>
|
||||
#include <proj.h>
|
||||
#include "GeoOperator.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
|
||||
|
||||
Landpoint LAMPTOOLAPI operator +(const Landpoint& p1, const Landpoint& p2)
|
||||
{
|
||||
return Landpoint{ p1.lon + p2.lon,p1.lat + p2.lat,p1.ati + p2.ati };
|
||||
}
|
||||
|
||||
Landpoint LAMPTOOLAPI operator -(const Landpoint& p1, const Landpoint& p2)
|
||||
{
|
||||
return Landpoint{ p1.lon - p2.lon,p1.lat - p2.lat,p1.ati - p2.ati };
|
||||
}
|
||||
|
||||
bool LAMPTOOLAPI operator ==(const Landpoint& p1, const Landpoint& p2)
|
||||
{
|
||||
return p1.lat == p2.lat && p1.lon == p2.lon && p1.ati == p2.ati;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Landpoint LAMPTOOLAPI operator *(const Landpoint& p, double scale)
|
||||
{
|
||||
return Landpoint{
|
||||
p.lon * scale,
|
||||
p.lat * scale,
|
||||
p.ati * scale
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Landpoint LAMPTOOLAPI 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 LAMPTOOLAPI 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 LAMPTOOLAPI 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 LAMPTOOLAPI 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 LAMPTOOLAPI dot(const Landpoint& p1, const Landpoint& p2)
|
||||
{
|
||||
return p1.lat * p2.lat + p1.lon * p2.lon + p1.ati * p2.ati;
|
||||
}
|
||||
|
||||
double LAMPTOOLAPI getlength(const Landpoint& p1) {
|
||||
|
||||
return sqrt(dot(p1, p1));
|
||||
}
|
||||
|
||||
Landpoint LAMPTOOLAPI 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 LAMPTOOLAPI cross2d(Point_3d a, Point_3d b)
|
||||
{
|
||||
return a.x * b.y - a.y * b.x;
|
||||
}
|
||||
|
||||
Point_3d LAMPTOOLAPI operator -(Point_3d a, Point_3d b)
|
||||
{
|
||||
return Point_3d{ a.x - b.x, a.y - b.y, a.z - b.z };
|
||||
}
|
||||
|
||||
Point_3d LAMPTOOLAPI operator +(Point_3d a, Point_3d b)
|
||||
{
|
||||
return Point_3d{ a.x + b.x, a.y + b.y, a.z + b.z };
|
||||
}
|
||||
|
||||
double LAMPTOOLAPI 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 LAMPTOOLAPI 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 LAMPTOOLAPI 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 LAMPTOOLAPI pointToLineDistance(const Vector3D& point, const Vector3D& linePoint, const Vector3D& lineDirection)
|
||||
{
|
||||
Vector3D pointToLine = { point.x - linePoint.x, point.y - linePoint.y, point.z - linePoint.z };
|
||||
|
||||
// 璁$畻鐐瑰埌鐩寸嚎鐨勬姇褰辩偣鐨勪綅缃<E7B685>
|
||||
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);
|
||||
|
||||
// 璁$畻鎶曞奖鐐<E5A596>
|
||||
Vector3D projection = { linePoint.x + t * lineDirection.x, linePoint.y + t * lineDirection.y, linePoint.z + t * lineDirection.z };
|
||||
|
||||
// 璁$畻鐐瑰埌鐩寸嚎鐨勮窛绂<E7AA9B>
|
||||
return distance(point, projection);
|
||||
}
|
||||
|
||||
SphericalCoordinates LAMPTOOLAPI 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 LAMPTOOLAPI 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;
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#ifndef _GEOOPERATOR_H
|
||||
#define _GEOOPERATOR_H
|
||||
#include "LAMPToolAPI.h"
|
||||
#include "BaseConstVariable.h"
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Dense>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
|
||||
/// <summary>
|
||||
/// 三维向量,坐标表达
|
||||
/// </summary>
|
||||
struct Landpoint // 点 SAR影像的像素坐标;
|
||||
{
|
||||
/// <summary>
|
||||
/// 经度x
|
||||
/// </summary>
|
||||
double lon; // 经度x lon pixel_col
|
||||
/// <summary>
|
||||
/// 纬度y
|
||||
/// </summary>
|
||||
double lat; // 纬度y lat pixel_row
|
||||
/// <summary>
|
||||
/// 高度z
|
||||
/// </summary>
|
||||
double ati; // 高程z ati pixel_time
|
||||
};
|
||||
struct Point_3d {
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 将经纬度转换为地固参心坐标系
|
||||
/// </summary>
|
||||
/// <param name="XYZP">经纬度点--degree</param>
|
||||
/// <returns>投影坐标系点</returns>
|
||||
Landpoint LAMPTOOLAPI LLA2XYZ(const Landpoint& LLA);
|
||||
Eigen::MatrixXd LAMPTOOLAPI LLA2XYZ(Eigen::MatrixXd landpoint);
|
||||
|
||||
/// <summary>
|
||||
/// 将地固参心坐标系转换为经纬度
|
||||
/// </summary>
|
||||
/// <param name="XYZ">固参心坐标系</param>
|
||||
/// <returns>经纬度--degree</returns>
|
||||
Landpoint LAMPTOOLAPI XYZ2LLA(const Landpoint& XYZ);
|
||||
|
||||
|
||||
Landpoint LAMPTOOLAPI operator +(const Landpoint& p1, const Landpoint& p2);
|
||||
|
||||
Landpoint LAMPTOOLAPI operator -(const Landpoint& p1, const Landpoint& p2);
|
||||
|
||||
bool LAMPTOOLAPI operator ==(const Landpoint& p1, const Landpoint& p2);
|
||||
|
||||
Landpoint LAMPTOOLAPI operator *(const Landpoint& p, double scale);
|
||||
|
||||
double LAMPTOOLAPI getAngle(const Landpoint& a, const Landpoint& b);
|
||||
|
||||
double LAMPTOOLAPI dot(const Landpoint& p1, const Landpoint& p2);
|
||||
|
||||
double LAMPTOOLAPI getlength(const Landpoint& p1);
|
||||
|
||||
Landpoint LAMPTOOLAPI crossProduct(const Landpoint& a, const Landpoint& b);
|
||||
|
||||
|
||||
Landpoint LAMPTOOLAPI getSlopeVector(const Landpoint& p0, const Landpoint& p1, const Landpoint& p2, const Landpoint& p3, const Landpoint& p4);
|
||||
|
||||
|
||||
|
||||
float LAMPTOOLAPI cross2d(Point_3d a, Point_3d b);
|
||||
|
||||
Point_3d LAMPTOOLAPI operator -(Point_3d a, Point_3d b);
|
||||
|
||||
Point_3d LAMPTOOLAPI operator +(Point_3d a, Point_3d b);
|
||||
|
||||
double LAMPTOOLAPI operator /(Point_3d a, Point_3d b);
|
||||
|
||||
|
||||
|
||||
// 矢量计算
|
||||
struct Vector3D {
|
||||
double x, y, z;
|
||||
};
|
||||
|
||||
// 计算两点之间的距离
|
||||
double LAMPTOOLAPI distance(const Vector3D& p1, const Vector3D& p2);
|
||||
// 计算点到直线的最短距离
|
||||
double LAMPTOOLAPI pointToLineDistance(const Vector3D& point, const Vector3D& linePoint, const Vector3D& lineDirection);
|
||||
|
||||
|
||||
struct CartesianCoordinates {
|
||||
double x, y, z;
|
||||
};
|
||||
|
||||
struct SphericalCoordinates {
|
||||
double r, theta, phi;
|
||||
};
|
||||
|
||||
SphericalCoordinates LAMPTOOLAPI cartesianToSpherical(const CartesianCoordinates& cartesian);
|
||||
|
||||
CartesianCoordinates LAMPTOOLAPI sphericalToCartesian(const SphericalCoordinates& spherical);
|
||||
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,190 @@
|
|||
#pragma once
|
||||
/**
|
||||
* 影像数据操作项
|
||||
* 所有数据相关的操作,都是基于ENVI的数据格式
|
||||
* 影像读写操作时基于 GDAL 库
|
||||
* **/
|
||||
|
||||
|
||||
|
||||
#ifndef IMAGEOPERATORBASE_H
|
||||
#define IMAGEOPERATORBASE_H
|
||||
|
||||
#include "BaseConstVariable.h"
|
||||
#include "GeoOperator.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Dense>
|
||||
#include <complex>
|
||||
#include <gdal.h>
|
||||
#include <gdal_priv.h>
|
||||
#include <gdalwarper.h>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <QString>
|
||||
#include <cpl_conv.h> // for CPLMalloc()
|
||||
#include "referenceHeader.h"
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
|
||||
struct ImageGEOINFO {
|
||||
int width;
|
||||
int height;
|
||||
int bandnum;
|
||||
};
|
||||
|
||||
|
||||
// 判断是否需要输出为DLL
|
||||
#define DLLOUT
|
||||
// 文件打开
|
||||
std::shared_ptr<GDALDataset> LAMPTOOLAPI OpenDataset(const QString& in_path, GDALAccess rwmode= GA_ReadOnly); // 当指令销毁时,调用GDALClose 销毁类型
|
||||
void LAMPTOOLAPI CloseDataset(GDALDataset* ptr);
|
||||
|
||||
// 数据格式转换
|
||||
int LAMPTOOLAPI TIFF2ENVI(QString in_tiff_path,QString out_envi_path);
|
||||
int LAMPTOOLAPI ENVI2TIFF(QString in_envi_path,QString out_tiff_path);
|
||||
|
||||
// 保存影像数据 --直接保存 ENVI 文件
|
||||
|
||||
int LAMPTOOLAPI CreateDataset(QString new_file_path, int height, int width, int band_num, double* gt, QString projection, GDALDataType gdal_dtype, bool need_gt); // 创建文件
|
||||
|
||||
int LAMPTOOLAPI saveDataset(QString new_file_path, int start_line, int start_cols, int band_ids, int datacols, int datarows, void* databuffer);
|
||||
|
||||
// 根据限制条件估算分块大小
|
||||
int LAMPTOOLAPI block_num_pre_memory(int width, int height, GDALDataType gdal_dtype,double memey_size);
|
||||
|
||||
// 将结果转换为复数 或者 实数
|
||||
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> LAMPTOOLAPI ReadComplexMatrixData(int start_line,int width, int line_num, std::shared_ptr<GDALDataset> rasterDataset, GDALDataType gdal_datatype);
|
||||
|
||||
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> LAMPTOOLAPI ReadMatrixDoubleData(int start_line, int width, int line_num, std::shared_ptr<GDALDataset> rasterDataset, GDALDataType gdal_datatype,int band_idx);
|
||||
|
||||
Eigen::MatrixXd LAMPTOOLAPI getGeoTranslationArray(QString in_path);
|
||||
ImageGEOINFO LAMPTOOLAPI getImageINFO(QString in_path);
|
||||
|
||||
GDALDataType LAMPTOOLAPI getGDALDataType(QString fileptah);
|
||||
|
||||
|
||||
struct DemBox {
|
||||
double min_lat; //纬度
|
||||
double min_lon;//经度
|
||||
double max_lat;//纬度
|
||||
double max_lon;//经度
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// gdalImage图像操作类
|
||||
/// </summary>
|
||||
class LAMPTOOLAPI 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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// gdalImage图像操作类
|
||||
/// </summary>
|
||||
class LAMPTOOLAPI 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 LAMPTOOLAPI 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 LAMPTOOLAPI 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 LAMPTOOLAPI ResampleGDAL(const char* pszSrcFile, const char* pszOutFile, double* gt, int new_width, int new_height, GDALResampleAlg eResample);
|
||||
|
||||
int LAMPTOOLAPI ResampleGDALs(const char* pszSrcFile, int band_ids, GDALRIOResampleAlg eResample = GRIORA_Bilinear);
|
||||
|
||||
|
||||
//--------------------- 保存文博 -------------------------------
|
||||
|
||||
int LAMPTOOLAPI 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
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef _LAMPTOOLAPI_H_
|
||||
#define _LAMPTOOLAPI_H_
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
|
||||
#if defined(LAMPTOOL_API)
|
||||
#define LAMPTOOLAPI Q_DECL_EXPORT
|
||||
#else
|
||||
#define LAMPTOOLAPI Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,283 @@
|
|||
// SARBaseTool.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
|
||||
//
|
||||
|
||||
#include "ImageOperatorBase.h"
|
||||
#include "SARBaseTool.h"
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Dense>
|
||||
#include <omp.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
#include <gdal.h>
|
||||
#include <gdal_priv.h>
|
||||
#include <gdalwarper.h>
|
||||
#include <proj.h>
|
||||
#include <string.h>
|
||||
#include <memory.h>
|
||||
#include <memory>
|
||||
#include <fftw3.h>
|
||||
|
||||
|
||||
|
||||
int LAMPTOOLAPI Complex2dB(QString in_tiff, QString out_dB_path)
|
||||
{
|
||||
GDALAllRegister();
|
||||
std::shared_ptr<GDALDataset> 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<double> 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<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> data_mat(line_num * width, 1);// 必须强制行优先
|
||||
if (gdal_datatype == GDT_Byte) {
|
||||
Eigen::MatrixX<char> real_mat(line_num * width, 1);
|
||||
Eigen::MatrixX<char> 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<double>()).array().pow(2) + (imag_mat.array().cast<double>()).array().pow(2)).log10() * 10.0;
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_UInt16) {
|
||||
Eigen::MatrixX<unsigned short > real_mat(line_num * width, 1);
|
||||
Eigen::MatrixX<unsigned short > 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<double>()).array().pow(2) + (imag_mat.array().cast<double>()).array().pow(2)).log10() * 10.0;
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_Int16) {
|
||||
Eigen::MatrixX<short > real_mat(line_num * width, 1);
|
||||
Eigen::MatrixX<short > 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<double>()).array().pow(2) + (imag_mat.array().cast<double>()).array().pow(2)).log10() * 10.0;
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_UInt32) {
|
||||
Eigen::MatrixX<unsigned int > real_mat(line_num * width, 1);
|
||||
Eigen::MatrixX<unsigned int > 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<double>()).array().pow(2) + (imag_mat.array().cast<double>()).array().pow(2)).log10() * 10.0;
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_Int32) {
|
||||
Eigen::MatrixX<int > real_mat(line_num * width, 1);
|
||||
Eigen::MatrixX<int > 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<double>()).array().pow(2) + (imag_mat.array().cast<double>()).array().pow(2)).log10() * 10.0;
|
||||
_flag = true;
|
||||
}
|
||||
//else if (gdal_datatype == GDT_UInt64) {
|
||||
// Eigen::MatrixX<unsigned long> real_mat(line_num * width, 1);
|
||||
// Eigen::MatrixX<unsigned long> 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<double>()).array().pow(2) + (imag_mat.array().cast<double>()).array().pow(2)).log10() * 10.0;
|
||||
// _flag = true;
|
||||
//}
|
||||
//else if (gdal_datatype == GDT_Int64) {
|
||||
// Eigen::MatrixX<long> real_mat(line_num * width, 1);
|
||||
// Eigen::MatrixX<long> 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<double>()).array().pow(2) + (imag_mat.array().cast<double>()).array().pow(2)).log10() * 10.0;
|
||||
// _flag = true;
|
||||
//}
|
||||
else if (gdal_datatype == GDT_Float32) {
|
||||
Eigen::MatrixX<float> real_mat(line_num * width, 1);
|
||||
Eigen::MatrixX<float> 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<double>()).array().pow(2) + (imag_mat.array().cast<double>()).array().pow(2)).log10() * 10.0;
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_Float64) {
|
||||
Eigen::MatrixX<double> real_mat(line_num * width, 1);
|
||||
Eigen::MatrixX<double> 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<double>()).array().pow(2) + (imag_mat.array().cast<double>()).array().pow(2)).log10() * 10.0;
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_CInt16) {
|
||||
Eigen::MatrixX<complex<short>> 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<double>().array().pow(2) + complex_short_mat.imag().array().cast<double>().pow(2)).log10() * 10.0;
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_CInt32) {
|
||||
Eigen::MatrixX<complex<int>> 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<double>().array().pow(2) + complex_short_mat.imag().array().cast<double>().pow(2)).log10() * 10.0;
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_CFloat32) {
|
||||
Eigen::MatrixX<complex<float>> 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<double>().array().pow(2) + complex_short_mat.imag().array().cast<double>().pow(2)).log10() * 10.0;
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_CFloat64) {
|
||||
Eigen::MatrixX<complex<double>> 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<double>().array().pow(2) + complex_short_mat.imag().array().cast<double>().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 LAMPTOOLAPI Amplitude2dB(QString in_tiff, QString out_dB_path)
|
||||
{
|
||||
|
||||
GDALAllRegister();
|
||||
std::shared_ptr<GDALDataset> 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<double> 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<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> 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 LAMPTOOLAPI Complex2dB(Eigen::MatrixXcd in_matrix)
|
||||
{
|
||||
return Complex2dB(in_matrix.real().array(), in_matrix.imag().array());
|
||||
}
|
||||
|
||||
Eigen::MatrixXd LAMPTOOLAPI 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 LAMPTOOLAPI Complex2Amplitude(std::complex<double> sign)
|
||||
{
|
||||
return sqrt(pow(sign.real(),2)+pow(sign.imag(),2));
|
||||
}
|
||||
|
||||
double LAMPTOOLAPI Complex2phase(std::complex<double> 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 LAMPTOOLAPI Complex2Amplitude(Eigen::MatrixXcd in_matrix)
|
||||
{
|
||||
return in_matrix.array().abs().cast<double>().array();
|
||||
}
|
||||
|
||||
Eigen::MatrixXd LAMPTOOLAPI 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 LAMPTOOLAPI Complex2dB_DLL(QString out_path, QString in_sar_path)
|
||||
{
|
||||
return Complex2dB(in_sar_path, out_path);
|
||||
}
|
||||
|
||||
int LAMPTOOLAPI Amplitude2dB_DLL(QString in_tiff, QString out_dB_path)
|
||||
{
|
||||
return Amplitude2dB(in_tiff, out_dB_path);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
#pragma once
|
||||
/**
|
||||
* 基础SARBaseTool 操作
|
||||
*
|
||||
*/
|
||||
#include "LAMPToolAPI.h"
|
||||
#include <complex>
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Dense>
|
||||
#include <omp.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gdal.h>
|
||||
#include <gdal_utils.h>
|
||||
#include <gdal_priv.h>
|
||||
#include <gdalwarper.h>
|
||||
#include <proj.h>
|
||||
#include <string.h>
|
||||
#include <memory.h>
|
||||
#include <memory>
|
||||
|
||||
|
||||
#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 LAMPTOOLAPI Complex2dB(QString in_tiff, QString out_dB_path);
|
||||
int LAMPTOOLAPI Amplitude2dB(QString in_tiff, QString out_dB_path);
|
||||
Eigen::MatrixXd LAMPTOOLAPI Complex2dB(Eigen::MatrixXcd in_matrix);
|
||||
Eigen::MatrixXd LAMPTOOLAPI Complex2dB(Eigen::MatrixXd in_matrix_real, Eigen::MatrixXd in_matrix_imag );
|
||||
|
||||
double LAMPTOOLAPI Complex2Amplitude(std::complex<double> sign);
|
||||
double LAMPTOOLAPI Complex2phase(std::complex<double> sign);// 返回弧度制相位
|
||||
|
||||
|
||||
|
||||
Eigen::MatrixXd LAMPTOOLAPI Complex2Amplitude(Eigen::MatrixXcd in_matrix);
|
||||
Eigen::MatrixXd LAMPTOOLAPI 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
|
||||
|
|
@ -0,0 +1,384 @@
|
|||
#include "SARCalibration.h"
|
||||
#include "ImageOperatorBase.h"
|
||||
#include "SARBaseTool.h"
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Dense>
|
||||
#include <omp.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
#include <gdal.h>
|
||||
#include <gdal_priv.h>
|
||||
#include <gdalwarper.h>
|
||||
#include <proj.h>
|
||||
#include <string.h>
|
||||
#include <memory.h>
|
||||
#include <memory>
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
|
||||
/**
|
||||
* 输入数据是ENVI格式数据
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Eigen::Matrix2cd LAMPTOOLAPI CalibrationMatrix(Eigen::MatrixXcd in_matrix, double calibrationValue)
|
||||
{
|
||||
return in_matrix.array() * calibrationValue;
|
||||
}
|
||||
|
||||
int LAMPTOOLAPI CalibrationSiglePolarSAR(QString out_path, QString in_sar_path, double calibrationValue)
|
||||
{
|
||||
return CalibrationComplex(out_path, in_sar_path, calibrationValue);
|
||||
}
|
||||
|
||||
int LAMPTOOLAPI CalibrationComplex(const QString& out_path, const QString& in_sar_path, double calibrationValue)
|
||||
{
|
||||
GDALAllRegister();
|
||||
std::shared_ptr<GDALDataset> 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<double> 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<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> data_mat(line_num * width, 2);// 必须强制行优先
|
||||
if (gdal_datatype == GDT_Byte) {
|
||||
Eigen::MatrixX<char> real_mat(line_num*width,1);
|
||||
Eigen::MatrixX<char> 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_UInt16) {
|
||||
Eigen::MatrixX<unsigned short > real_mat(line_num * width, 1);
|
||||
Eigen::MatrixX<unsigned short > 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_Int16) {
|
||||
Eigen::MatrixX<short > real_mat(line_num*width, 1);
|
||||
Eigen::MatrixX<short > 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_UInt32) {
|
||||
Eigen::MatrixX<unsigned int > real_mat(line_num*width, 1);
|
||||
Eigen::MatrixX<unsigned int > 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_Int32) {
|
||||
Eigen::MatrixX<int > real_mat(line_num*width, 1);
|
||||
Eigen::MatrixX<int > 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
//else if (gdal_datatype == GDT_UInt64) {
|
||||
// Eigen::MatrixX<unsigned long> real_mat(line_num*width, 1);
|
||||
// Eigen::MatrixX<unsigned long> 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<double>() * calibrationValue).array();
|
||||
// data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
|
||||
// _flag = true;
|
||||
//}
|
||||
//else if (gdal_datatype == GDT_Int64) {
|
||||
// Eigen::MatrixX<long> real_mat(line_num*width, 1);
|
||||
// Eigen::MatrixX<long> 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<double>() * calibrationValue).array();
|
||||
// data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
|
||||
// _flag = true;
|
||||
//}
|
||||
else if (gdal_datatype == GDT_Float32) {
|
||||
Eigen::MatrixX<float> real_mat(line_num*width, 1);
|
||||
Eigen::MatrixX<float> 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_Float64) {
|
||||
Eigen::MatrixX<double> real_mat(line_num*width, 1);
|
||||
Eigen::MatrixX<double> 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) =( imag_mat.array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_CInt16) {
|
||||
Eigen::MatrixX<complex<short>> 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) = (complex_short_mat.imag().array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_CInt32) {
|
||||
Eigen::MatrixX<complex<int>> 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) = (complex_short_mat.imag().array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_CFloat32) {
|
||||
Eigen::MatrixX<complex<float>> 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) = (complex_short_mat.imag().array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_CFloat64) {
|
||||
Eigen::MatrixX<complex<double>> 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) = (complex_short_mat.imag().array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
else {}
|
||||
// 保存数据
|
||||
if (_flag) {
|
||||
// 定义赋值矩阵
|
||||
saveDataset(out_path, i,0,1, width, line_num, data_mat.data());
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int LAMPTOOLAPI CalibrationComplex2dB(const QString& out_path, const QString& in_sar_path, double calibrationValue)
|
||||
{
|
||||
GDALAllRegister();
|
||||
std::shared_ptr<GDALDataset> 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<double> 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<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> data_mat(line_num * width, 2);// 必须强制行优先
|
||||
if (gdal_datatype == GDT_Byte) {
|
||||
Eigen::MatrixX<char> real_mat(line_num * width, 1);
|
||||
Eigen::MatrixX<char> 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_UInt16) {
|
||||
Eigen::MatrixX<unsigned short > real_mat(line_num * width, 1);
|
||||
Eigen::MatrixX<unsigned short > 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_Int16) {
|
||||
Eigen::MatrixX<short > real_mat(line_num * width, 1);
|
||||
Eigen::MatrixX<short > 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_UInt32) {
|
||||
Eigen::MatrixX<unsigned int > real_mat(line_num * width, 1);
|
||||
Eigen::MatrixX<unsigned int > 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_Int32) {
|
||||
Eigen::MatrixX<int > real_mat(line_num * width, 1);
|
||||
Eigen::MatrixX<int > 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
//else if (gdal_datatype == GDT_UInt64) {
|
||||
// Eigen::MatrixX<unsigned long> real_mat(line_num * width, 1);
|
||||
// Eigen::MatrixX<unsigned long> 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<double>() * calibrationValue).array();
|
||||
// data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
|
||||
// _flag = true;
|
||||
//}
|
||||
//else if (gdal_datatype == GDT_Int64) {
|
||||
// Eigen::MatrixX<long> real_mat(line_num * width, 1);
|
||||
// Eigen::MatrixX<long> 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<double>() * calibrationValue).array();
|
||||
// data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
|
||||
// _flag = true;
|
||||
//}
|
||||
else if (gdal_datatype == GDT_Float32) {
|
||||
Eigen::MatrixX<float> real_mat(line_num * width, 1);
|
||||
Eigen::MatrixX<float> 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_Float64) {
|
||||
Eigen::MatrixX<double> real_mat(line_num * width, 1);
|
||||
Eigen::MatrixX<double> 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_CInt16) {
|
||||
Eigen::MatrixX<complex<short>> 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) = (complex_short_mat.imag().array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_CInt32) {
|
||||
Eigen::MatrixX<complex<int>> 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) = (complex_short_mat.imag().array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_CFloat32) {
|
||||
Eigen::MatrixX<complex<float>> 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) = (complex_short_mat.imag().array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
else if (gdal_datatype == GDT_CFloat64) {
|
||||
Eigen::MatrixX<complex<double>> 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<double>() * calibrationValue).array();
|
||||
data_mat.col(1) = (complex_short_mat.imag().array().cast<double>() * calibrationValue).array();
|
||||
_flag = true;
|
||||
}
|
||||
else {}
|
||||
// 保存数据
|
||||
if (_flag) {
|
||||
// 定义赋值矩阵
|
||||
|
||||
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> 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 LAMPTOOLAPI CalibrationComplex_DLL(const QString& out_path, const QString& in_sar_path, double calibrationValue)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LAMPTOOLAPI CalibrationComplex2dB_DLL(const QString& out_path, const QString& in_sar_path, double calibrationValue)
|
||||
{
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#ifndef SARCALIBRATION_H
|
||||
#define SARCALIBRATION_H
|
||||
/**
|
||||
* SAR定标函数
|
||||
*
|
||||
*/
|
||||
#include "referenceHeader.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Dense>
|
||||
#include <complex.h>
|
||||
#include <gdal.h>
|
||||
#include <gdal_priv.h>
|
||||
#include <gdalwarper.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
// 判断是否需要输出为DLL
|
||||
#define DLLOUT
|
||||
|
||||
|
||||
// 定标计算
|
||||
// 输入定标系统,保证数据能够正常定标
|
||||
Eigen::Matrix2cd LAMPTOOLAPI CalibrationMatrix(Eigen::MatrixXcd in_matrix, double calibrationValue);
|
||||
int LAMPTOOLAPI CalibrationComplex(const QString& out_path, const QString& in_sar_path, double calibrationValue);
|
||||
int LAMPTOOLAPI 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
|
|
@ -0,0 +1,87 @@
|
|||
// SARCalibrationTool.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
|
||||
//
|
||||
#include "LAMPToolAPI.h"
|
||||
#include "SARCalibration.h"
|
||||
#include "SARBaseTool.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
|
||||
|
||||
int LAMPTOOLAPI 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 LAMPTOOLAPI 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 LAMPTOOLAPI 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;
|
||||
}
|
||||
|
|
@ -0,0 +1,335 @@
|
|||
#include "LAMPToolAPI.h"
|
||||
#include "ImageOperatorBase.h"
|
||||
#include "SARBaseTool.h"
|
||||
#include "SARImageBase.h"
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Dense>
|
||||
#include <omp.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
#include <gdal.h>
|
||||
#include <gdal_priv.h>
|
||||
#include <gdalwarper.h>
|
||||
#include <proj.h>
|
||||
#include <string.h>
|
||||
#include <memory.h>
|
||||
#include <memory>
|
||||
#include <fftw3.h>
|
||||
#include <gsl/gsl_integration.h>
|
||||
#include <gsl/gsl_spline.h>
|
||||
#include "referenceHeader.h"
|
||||
#include "OCCTBase.h"
|
||||
#include "GeoOperator.h"
|
||||
#include "SARImageBase.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
double LAMPTOOLAPI getRangeResolution(double startfreq, double endfreq)
|
||||
{
|
||||
return LIGHTSPEED / 2 / std::abs(endfreq - startfreq);
|
||||
}
|
||||
|
||||
double LAMPTOOLAPI getAzimuthResolution(double AzAngleRange, double startFreq)
|
||||
{
|
||||
return LIGHTSPEED / 2 / (AzAngleRange * startFreq);
|
||||
}
|
||||
|
||||
Eigen::MatrixXd LAMPTOOLAPI 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 LAMPTOOLAPI 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 LAMPTOOLAPI 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 LAMPTOOLAPI 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<double> 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 LAMPTOOLAPI 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 LAMPTOOLAPI 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 LAMPTOOLAPI 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 LAMPTOOLAPI 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<double>(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 LAMPTOOLAPI 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<double>(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 LAMPTOOLAPI FFTW2D(Eigen::MatrixXcd ECHO)
|
||||
{
|
||||
// 获取数据的尺寸
|
||||
int rows = ECHO.rows();
|
||||
int cols = ECHO.cols();
|
||||
|
||||
// 创建FFTW输入和输出数组
|
||||
fftw_complex* in = reinterpret_cast<fftw_complex*>(ECHO.data());
|
||||
fftw_complex* out = static_cast<fftw_complex*>(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<Eigen::MatrixXcd>(reinterpret_cast<std::complex<double>*>(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 LAMPTOOLAPI 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;
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
#pragma once
|
||||
#ifndef SARIMAGEBASE_H
|
||||
#define SARIMAGEBASE_H
|
||||
/**
|
||||
* 成像过程中常用的计算函数
|
||||
****/
|
||||
#include "referenceHeader.h"
|
||||
#include "SARBaseTool.h"
|
||||
// ------------------------------------------- 成像 公用库----------------------------------------------------------
|
||||
// SAR 常用计算的方法
|
||||
double LAMPTOOLAPI getRangeResolution(double startfreq, double endfreq);
|
||||
|
||||
/// <summary>
|
||||
/// 方位向分辨率计算
|
||||
/// </summary>
|
||||
/// <param name="AzAngleRange">弧度制,方位角变化范围(>=0)</param>
|
||||
/// <param name="startFreq">起始频率</param>
|
||||
/// <returns></returns>
|
||||
double LAMPTOOLAPI getAzimuthResolution(double AzAngleRange, double startFreq);
|
||||
// 根据输入数量构建汉明窗
|
||||
Eigen::MatrixXd LAMPTOOLAPI hammingWindows(size_t num);
|
||||
|
||||
|
||||
// 频率域汉明窗口
|
||||
|
||||
/// <summary>
|
||||
/// 频率域汉明窗口
|
||||
/// </summary>
|
||||
/// <param name="Nf">频率点数</param>
|
||||
/// <param name="Nxa">脉冲数量</param>
|
||||
/// <param name="alpha">权重</param>
|
||||
/// <returns>汉明窗权重</returns>
|
||||
Eigen::MatrixXd LAMPTOOLAPI Hanning(size_t Nf, size_t Nxa, double alpha = 0.54);
|
||||
|
||||
/// <summary>
|
||||
/// 获取2的平方数,大于2
|
||||
/// </summary>
|
||||
/// <param name="num"></param>
|
||||
/// <returns></returns>
|
||||
size_t LAMPTOOLAPI nextpow2(size_t num);
|
||||
|
||||
/// <summary>
|
||||
/// 对回波沿着行进行一维傅里叶逆变换
|
||||
/// </summary>
|
||||
/// <param name="ECHO"></param>
|
||||
/// <returns></returns>
|
||||
Eigen::MatrixXcd LAMPTOOLAPI IFFTW1D(Eigen::MatrixXcd ECHO);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 对回波沿着行进行一维傅里叶变换
|
||||
/// </summary>
|
||||
/// <param name="echo"></param>
|
||||
/// <returns></returns>
|
||||
Eigen::MatrixXcd LAMPTOOLAPI FFTW1D(Eigen::MatrixXcd echo);
|
||||
Eigen::MatrixXcd LAMPTOOLAPI FFTW2D(Eigen::MatrixXcd ECHO);
|
||||
|
||||
Eigen::MatrixXcd LAMPTOOLAPI fftshift(Eigen::MatrixXcd X);
|
||||
/// <summary>
|
||||
/// 对回波 加 hamming 窗
|
||||
/// </summary>
|
||||
/// <param name="FreqEcho">频域的回波数据(PRFnum,Freqnum)</param>
|
||||
/// <returns></returns>
|
||||
Eigen::MatrixXcd LAMPTOOLAPI HammingWindows(Eigen::MatrixXcd FreqEcho);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 对回波进行一维插值(并行),不能用来处理极坐标
|
||||
/// 插值方式为 实部虚部分别进行线性插值
|
||||
/// </summary>
|
||||
/// <param name="freqEcho">回波数据,(行数,列数):(PRFNUM,freqNUM)</param>
|
||||
/// <param name="SourceFreqlist">回波的 原始频率列表</param>
|
||||
/// <param name="interpFreqlist">回波的 插值频率列表</param>
|
||||
/// <returns></returns>
|
||||
Eigen::MatrixXcd LAMPTOOLAPI InterpFreqEcho(Eigen::MatrixXcd freqEcho, Eigen::VectorXd SourceFreqlist, Eigen::VectorXd interpFreqlist);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 保存复数矩阵数据 为tiff, 其中,band 1: amp (linear) angle(radia)
|
||||
/// </summary>
|
||||
/// <param name="out_tiff_path"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
int LAMPTOOLAPI WriteComplexData2Amp_Arg(QString out_tiff_path, Eigen::MatrixXcd data);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 保存复数矩阵数据 为tiff, 其中,band 1: amp (dB) angle(radia)
|
||||
/// </summary>
|
||||
/// <param name="out_tiff_path"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
int LAMPTOOLAPI WriteComplexData2AmpdB_Arg(QString out_tiff_path, Eigen::MatrixXcd data);
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
#endif
|
|
@ -0,0 +1,13 @@
|
|||
#include "interpolation.h"
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Dense>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Dense>
|
||||
|
||||
|
||||
|
||||
namespace LampInterpolation {
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef INTERPOLATION_H
|
||||
#define INTERPOLATION_H
|
||||
|
||||
#include <complex>
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Dense>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Dense>
|
||||
|
||||
|
||||
namespace LampInterpolation {
|
||||
enum interpolationtype {
|
||||
nearest,
|
||||
linear,
|
||||
cubic,
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 矩阵为 1xn
|
||||
/// </summary>
|
||||
template<typename T>
|
||||
std::complex<T> interpolation(Eigen::MatrixX<std::complex<T>>& 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<T>(0, 0);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
std::complex<T> interpolationLinear(Eigen::MatrixX<std::complex<T>>& echo, double& index)
|
||||
{
|
||||
size_t last_ids = size_t(std::floor(index));
|
||||
size_t next_ids = size_t(std::ceil(index));
|
||||
|
||||
std::complex<T> last_value = echo(1, last_ids);
|
||||
std::complex<T> 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>(T(real), T(imag));
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
std::complex<T> interpolationNearest(Eigen::MatrixX<std::complex<T>>& echo, double& index)
|
||||
{
|
||||
size_t nearest_ids = size_t(std::round(index));
|
||||
return echo(1, nearest_ids);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,153 @@
|
|||
#-----------------------------------------------------------------------------
|
||||
# 将点云与 mesh 表达合并,不再单独处理点云
|
||||
# 加载: 点云-> mesh
|
||||
# 处理: mesh->点云-> 处理模块 -> mesh
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 头文件搜索路径
|
||||
#-----------------------------------------------------------------------------
|
||||
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)
|
||||
|
||||
# qt5
|
||||
include_directories(C:/Qt/5.15.2/msvc2019_64/include/QtQml)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 链接库
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# 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)
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 添加资源文件
|
||||
#-----------------------------------------------------------------------------
|
||||
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 _ui "*.ui")
|
||||
file(GLOB _header "*.h")
|
||||
file(GLOB _source "*.cpp")
|
||||
qt5_wrap_ui(_interface ${_ui})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 添加动态库目标
|
||||
#-----------------------------------------------------------------------------
|
||||
add_library(PluginWBFZExchangePlugin
|
||||
${_resource}
|
||||
${_interface}
|
||||
${_header}
|
||||
${_source}
|
||||
)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 链接库
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# pcl
|
||||
link_directories("C:/PCL/3rdParty/FLANN/lib")
|
||||
link_directories("C:/VTK/lib")
|
||||
link_directories("C:/PCL/lib")
|
||||
|
||||
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 )
|
||||
|
||||
# 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)
|
||||
|
||||
|
||||
include_directories(${PCL_INCLUDE_DIRS})
|
||||
link_directories(${PCL_LIBRARY_DIRS})
|
||||
add_definitions(${PCL_DEFINITIONS})
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 添加接口声明宏
|
||||
#-----------------------------------------------------------------------------
|
||||
target_compile_definitions(PluginWBFZExchangePlugin PRIVATE "NOMINMAX") # 禁用vc++ 中的min max 定义,避免与 pcl 的中 std::min,pcl::max 函数冲突
|
||||
target_compile_definitions(PluginWBFZExchangePlugin PRIVATE "WBFZ_API")
|
||||
|
||||
list(APPEND _depend_library
|
||||
LAMPTool WBCLFZSystemModule Common PointCloudOperator PythonModule DataProperty MeshData Material Geometry BCBase ConfigOptions SelfDefObject ModelData ModuleBase PluginManager GeometryCommand GeometryWidgets IO MainWidgets MainWindow
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
list(APPEND _runtimes_libraries
|
||||
LAMPCAE::CGNS Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Xml
|
||||
)
|
||||
|
||||
# 添加 点云 pcl
|
||||
list(APPEND _runtimes_libraries
|
||||
|
||||
)
|
||||
|
||||
|
||||
# 添加 VTK
|
||||
list(APPEND _runtimes_libraries
|
||||
VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::DICOMParser VTK::FiltersCore VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersHybrid VTK::FiltersModeling VTK::FiltersSources VTK::IOCore VTK::IOChemistry VTK::IOGeometry VTK::IOImage VTK::IOLegacy VTK::ImagingCore VTK::ImagingSources VTK::RenderingCore VTK::RenderingLOD VTK::doubleconversion VTK::jpeg VTK::jsoncpp VTK::lz4 VTK::lzma VTK::metaio VTK::png VTK::pugixml VTK::sys VTK::tiff VTK::zlib
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 链接依赖库
|
||||
#-----------------------------------------------------------------------------
|
||||
target_link_libraries(PluginWBFZExchangePlugin PRIVATE
|
||||
${_runtimes_libraries}
|
||||
${_depend_library}
|
||||
${PCL_LIBRARIES}
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 添加依赖关系
|
||||
#-----------------------------------------------------------------------------
|
||||
add_dependencies(PluginWBFZExchangePlugin ${_depend_library})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 添加运行时依赖关系
|
||||
#-----------------------------------------------------------------------------
|
||||
set(LAMPCAE_PluginWBFZExchangePlugin_Runtimes_Libraries ${_runtimes_libraries} PARENT_SCOPE)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 设置插件的输出目录
|
||||
#-----------------------------------------------------------------------------
|
||||
set_target_properties(PluginWBFZExchangePlugin
|
||||
PROPERTIES
|
||||
ARCHIVE_OUTPUT_DIRECTORY_RELEASE $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins
|
||||
LIBRARY_OUTPUT_DIRECTORY_RELEASE $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELEASE $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins
|
||||
ARCHIVE_OUTPUT_DIRECTORY_DEBUG $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins
|
||||
LIBRARY_OUTPUT_DIRECTORY_DEBUG $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins
|
||||
RUNTIME_OUTPUT_DIRECTORY_DEBUG $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins
|
||||
)
|
|
@ -0,0 +1,86 @@
|
|||
#include "PointCloudThreadBase.h"
|
||||
#include "MainWindow/MainWindow.h"
|
||||
#include "MainWindow/SubWindowManager.h"
|
||||
#include "PythonModule/PyAgent.h"
|
||||
#include "MeshData/meshSingleton.h"
|
||||
#include "MeshData/meshKernal.h"
|
||||
#include "Common/Types.h"
|
||||
#include "Common/DebugLogger.h"
|
||||
|
||||
namespace WBFZ
|
||||
{
|
||||
PointCloudThreadBase::PointCloudThreadBase(const QString &fileName, PointCloudOperation operation, GUI::MainWindow *mw) : ModuleBase::ThreadTask(mw),
|
||||
_fileName(fileName),
|
||||
_operation(operation)
|
||||
{
|
||||
}
|
||||
|
||||
PointCloudThreadBase::~PointCloudThreadBase()
|
||||
{
|
||||
}
|
||||
|
||||
void PointCloudThreadBase::defaultMeshFinished()
|
||||
{
|
||||
|
||||
if (_threadRuning)
|
||||
{
|
||||
QString information{};
|
||||
ModuleBase::Message msg;
|
||||
if (_operation == POINTCLOUD_FILTER)
|
||||
{
|
||||
if (_success)
|
||||
{
|
||||
emit _mainwindow->updateMeshTreeSig();
|
||||
emit _mainwindow->updateSetTreeSig();
|
||||
emit _mainwindow->updateActionStatesSig();
|
||||
// emit _mainwindow->updateActionsStatesSig();
|
||||
emit _mainwindow->getSubWindowManager()->openPreWindowSig();
|
||||
emit _mainwindow->updatePreMeshActorSig();
|
||||
information = QString("Successful Import Mesh From \"%1\"").arg(_fileName);
|
||||
msg.type = Common::Message::Normal;
|
||||
msg.message = information;
|
||||
auto meshdata = MeshData::MeshData::getInstance();
|
||||
// meshdata->generateDisplayDataSet();
|
||||
const int nk = meshdata->getKernalCount();
|
||||
if (nk <= 0)
|
||||
return;
|
||||
auto k = meshdata->getKernalAt(nk - 1);
|
||||
if (k != nullptr)
|
||||
k->setPath(_fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
information = QString("Failed Filter From \"%1\"").arg(_fileName);
|
||||
msg.type = Common::Message::Error;
|
||||
msg.message = information;
|
||||
}
|
||||
}
|
||||
else if (_operation == POINTCLOUD_MESH)
|
||||
{
|
||||
if (_success)
|
||||
{
|
||||
information = QString("Successful resurface Mesh To \"%1\"").arg(_fileName);
|
||||
msg.type = Common::Message::Normal;
|
||||
msg.message = information;
|
||||
}
|
||||
else
|
||||
{
|
||||
information = QString("Failed resurface Mesh To \"%1\"").arg(_fileName);
|
||||
msg.type = Common::Message::Error;
|
||||
msg.message = information;
|
||||
}
|
||||
}
|
||||
emit showInformation(information);
|
||||
emit _mainwindow->printMessageToMessageWindow(msg);
|
||||
}
|
||||
// emit showInformation(information);
|
||||
// emit _mainwindow->printMessageToMessageWindow(msg);
|
||||
ModuleBase::ThreadTask::threadTaskFinished();
|
||||
Py::PythonAgent::getInstance()->unLock();
|
||||
}
|
||||
void PointCloudThreadBase::setThreadRunState(bool flag){
|
||||
_success= flag;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef _MESHTHREADBASE_H_
|
||||
#define _MESHTHREADBASE_H_
|
||||
|
||||
#include "ModuleBase/ThreadTask.h"
|
||||
#include "WBFZExchangePluginAPI.h"
|
||||
#include "WBFZExchangePlugin.h"
|
||||
|
||||
namespace GUI
|
||||
{
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
namespace WBFZ
|
||||
{
|
||||
class WBFZAPI PointCloudThreadBase : public ModuleBase::ThreadTask
|
||||
{
|
||||
public:
|
||||
PointCloudThreadBase(const QString &fileName, PointCloudOperation operation, GUI::MainWindow *mw);
|
||||
virtual ~PointCloudThreadBase();
|
||||
|
||||
virtual void run() = 0;
|
||||
void defaultMeshFinished();
|
||||
void setThreadRunState(bool);
|
||||
|
||||
|
||||
private:
|
||||
bool _success{false};
|
||||
QString _fileName;
|
||||
PointCloudOperation _operation;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,55 @@
|
|||
|
||||
#include "IO/IOConfig.h"
|
||||
|
||||
#include "ModelData/modelDataBase.h"
|
||||
#include "ModuleBase/ThreadControl.h"
|
||||
#include "ModuleBase/ThreadTaskManager.h"
|
||||
#include "WBFZExchangePlugin.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
|
||||
|
||||
namespace WBFZ {
|
||||
GUI::MainWindow* WBFZ::WBFZExchangePlugin::_mainwindow = nullptr;
|
||||
|
||||
WBFZExchangePlugin::WBFZExchangePlugin(GUI::MainWindow* m)
|
||||
{
|
||||
_describe = "WBFZExchangePlugin Installed Successfully";
|
||||
_mainwindow = m;
|
||||
}
|
||||
|
||||
bool WBFZExchangePlugin::install()
|
||||
{
|
||||
IO::IOConfigure::RegisterMeshImporter("CGNS(*.cgns)", CGNSimportMesh);
|
||||
|
||||
// IO::IOConfigure::RegisterMeshExporter("CGNS(*.cgns)", CGNSexportMesh);
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WBFZExchangePlugin::uninstall()
|
||||
{
|
||||
IO::IOConfigure::RemoveMeshImporter("CGNS(*.cgns)");
|
||||
|
||||
IO::IOConfigure::RemoveMeshExporter("CGNS(*.cgns)");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void WBFZExchangePlugin::reTranslate(QString) {}
|
||||
|
||||
GUI::MainWindow* WBFZExchangePlugin::getMWpt()
|
||||
{
|
||||
return _mainwindow;
|
||||
}
|
||||
} // namespace WBFZ
|
||||
|
||||
void Register(GUI::MainWindow* m, QList<Plugins::PluginBase*>* ps)
|
||||
{
|
||||
Plugins::PluginBase* p = new WBFZ::WBFZExchangePlugin(m);
|
||||
ps->append(p);
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
#ifndef _WBFZEXCHANGEPLUGIN_H_
|
||||
#define _WBFZEXCHANGEPLUGIN_H_
|
||||
|
||||
#include "WBFZExchangePluginAPI.h"
|
||||
#include "PluginManager/pluginBase.h"
|
||||
|
||||
namespace WBFZ
|
||||
{
|
||||
enum PointCloudOperation
|
||||
{
|
||||
POINTCLOUD_NONE,
|
||||
POINTCLOUD_FILTER,
|
||||
POINTCLOUD_MESH
|
||||
};
|
||||
|
||||
class WBFZAPI WBFZExchangePlugin : public Plugins::PluginBase
|
||||
{
|
||||
public:
|
||||
WBFZExchangePlugin(GUI::MainWindow* m);
|
||||
~WBFZExchangePlugin() = default;
|
||||
bool install();
|
||||
bool uninstall();
|
||||
void reTranslate(QString);
|
||||
static GUI::MainWindow* getMWpt();
|
||||
|
||||
private:
|
||||
static GUI::MainWindow* _mainwindow;
|
||||
};
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void WBFZAPI Register(GUI::MainWindow* m, QList<Plugins::PluginBase*>* plugs);
|
||||
//函数返回值是无效的,不要通过返回值判断
|
||||
bool WBFZAPI CGNSimportMesh(QString AbFileName, int modelId);
|
||||
bool WBFZAPI MSHimportMesh(QString AbFileName, int modelId);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef _WBFZAPI_H__
|
||||
#define _WBFZAPI_H__
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
|
||||
#if defined(WBFZ_API)
|
||||
#define WBFZAPI Q_DECL_EXPORT
|
||||
#else
|
||||
#define WBFZAPI Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue