diff --git a/BaseCommonLibrary/BaseCommonLibrary.vcxproj b/BaseCommonLibrary/BaseCommonLibrary.vcxproj
index 92885c4..d1fd1fa 100644
--- a/BaseCommonLibrary/BaseCommonLibrary.vcxproj
+++ b/BaseCommonLibrary/BaseCommonLibrary.vcxproj
@@ -187,6 +187,7 @@
+
@@ -200,6 +201,7 @@
+
diff --git a/BaseCommonLibrary/BaseCommonLibrary.vcxproj.filters b/BaseCommonLibrary/BaseCommonLibrary.vcxproj.filters
index f50236e..81cb853 100644
--- a/BaseCommonLibrary/BaseCommonLibrary.vcxproj.filters
+++ b/BaseCommonLibrary/BaseCommonLibrary.vcxproj.filters
@@ -57,6 +57,9 @@
BaseTool
+
+ BaseTool
+
@@ -98,6 +101,9 @@
ToolAbstract
+
+ BaseTool
+
diff --git a/BaseCommonLibrary/BaseTool/BaseTool.cpp b/BaseCommonLibrary/BaseTool/BaseTool.cpp
index 9d1c0f0..5cd20e5 100644
--- a/BaseCommonLibrary/BaseTool/BaseTool.cpp
+++ b/BaseCommonLibrary/BaseTool/BaseTool.cpp
@@ -35,6 +35,9 @@
#include
#include
+#include // 包含SSE指令集头文件
+#include // 包含SSE2指令集头文件
+#include // 包含OpenMP头文件
QString longDoubleToQStringScientific(long double value) {
@@ -634,4 +637,46 @@ Eigen::VectorXd linspace(double start, double stop, int num) {
}
return result;
-}
\ No newline at end of file
+}
+
+void initializeMatrixWithSSE2(Eigen::MatrixXd& mat, const double* data, long rowcount, long colcount) {
+ __m128d zero = _mm_setzero_pd();
+
+#pragma omp parallel for
+ for (long i = 0; i < rowcount; ++i) {
+ for (long j = 0; j < colcount; j += 2) { // 每次处理2个double
+ if (j + 2 <= colcount) {
+ __m128d src = _mm_loadu_pd(&data[i * colcount + j]);
+ _mm_storeu_pd(&mat(i, j), src);
+ }
+ else {
+ // 处理剩余部分
+ for (long k = j; k < colcount; ++k) {
+ mat(i, k) = data[i * colcount + k];
+ }
+ }
+ }
+ }
+}
+
+void initializeMatrixWithSSE2(Eigen::MatrixXf& mat, const float* data, long rowcount, long colcount) {
+ __m128 zero = _mm_setzero_ps();
+
+#pragma omp parallel for
+ for (long i = 0; i < rowcount; ++i) {
+ for (long j = 0; j < colcount; j += 4) { // 每次处理4个float
+ if (j + 4 <= colcount) {
+ __m128 src = _mm_loadu_ps(&data[i * colcount + j]);
+ _mm_storeu_ps(&mat(i, j), src);
+ }
+ else {
+ // 处理剩余部分
+ for (long k = j; k < colcount; ++k) {
+ mat(i, k) = data[i * colcount + k];
+ }
+ }
+ }
+ }
+}
+
+
diff --git a/BaseCommonLibrary/BaseTool/BaseTool.h b/BaseCommonLibrary/BaseTool/BaseTool.h
index e5c5277..7990656 100644
--- a/BaseCommonLibrary/BaseTool/BaseTool.h
+++ b/BaseCommonLibrary/BaseTool/BaseTool.h
@@ -32,6 +32,7 @@
#include
#include
+
///////////////////////////////////// 基础数学函数 /////////////////////////////////////////////////////////////
@@ -122,4 +123,31 @@ QVector BASECONSTVARIABLEAPI SatelliteAntPos2SatellitePos(QVector
QString BASECONSTVARIABLEAPI getDebugDataPath(QString filename);
std::vector BASECONSTVARIABLEAPI split(const std::string& str, char delimiter);
Eigen::VectorXd BASECONSTVARIABLEAPI linspace(double start, double stop, int num);
+
+
+/** 内存赋值 ***********************************************************************************************************/
+void initializeMatrixWithSSE2(Eigen::MatrixXd& mat, const double* data, long rowcount, long colcount);
+void initializeMatrixWithSSE2(Eigen::MatrixXf& mat, const float* data, long rowcount, long colcount);
+
+
+/** 模板函数类 ***********************************************************************************************************/
+template
+inline void BASECONSTVARIABLEAPI memsetInitArray(std::shared_ptr ptr, long arrcount,T ti) {
+ for (long i = 0; i < arrcount; i++) {
+ ptr.get()[i] = ti;
+ }
+}
+
+template
+inline void BASECONSTVARIABLEAPI memcpyArray(std::shared_ptr srct, std::shared_ptr dest, long arrcount) {
+ for (long i = 0; i < arrcount; i++) {
+ dest.get()[i] = srct.get()[i];
+ }
+}
+
+
+
+
+
+
#endif
\ No newline at end of file
diff --git a/BaseCommonLibrary/BaseTool/FileOperator.cpp b/BaseCommonLibrary/BaseTool/FileOperator.cpp
index 7127be3..d2b1343 100644
--- a/BaseCommonLibrary/BaseTool/FileOperator.cpp
+++ b/BaseCommonLibrary/BaseTool/FileOperator.cpp
@@ -97,6 +97,13 @@ QString getFileNameWidthoutExtend(QString path)
return fileNameWithoutExtension;
}
+QString BASECONSTVARIABLEAPI getFileExtension(QString path)
+{
+ QFileInfo fileInfo(path);
+ QString fileExtension = fileInfo.suffix(); // 获取无后缀文件名
+ return fileExtension;
+}
+
bool isDirectory(const QString& path)
{
QFileInfo fileinfo(path);
diff --git a/BaseCommonLibrary/BaseTool/FileOperator.h b/BaseCommonLibrary/BaseTool/FileOperator.h
index 5ee61b6..72d542a 100644
--- a/BaseCommonLibrary/BaseTool/FileOperator.h
+++ b/BaseCommonLibrary/BaseTool/FileOperator.h
@@ -37,6 +37,8 @@ QString BASECONSTVARIABLEAPI getFileNameFromPath(const QString& path);
QString BASECONSTVARIABLEAPI getFileNameWidthoutExtend(QString path);
+QString BASECONSTVARIABLEAPI getFileExtension(QString path);
+
int BASECONSTVARIABLEAPI write_binfile(char* filepath, char* data, size_t data_len);
char* read_textfile(char* text_path, int* length);
diff --git a/BaseCommonLibrary/BaseTool/ImageOperatorBase.cpp b/BaseCommonLibrary/BaseTool/ImageOperatorBase.cpp
index fe8b74b..7551a5e 100644
--- a/BaseCommonLibrary/BaseTool/ImageOperatorBase.cpp
+++ b/BaseCommonLibrary/BaseTool/ImageOperatorBase.cpp
@@ -629,6 +629,137 @@ Eigen::MatrixXd gdalImage::getData(int start_row, int start_col, int rows_count,
return datamatrix;
}
+Eigen::MatrixXf gdalImage::getDataf(int start_row, int start_col, int rows_count, int cols_count,
+ int band_ids = 1)
+{
+ omp_lock_t lock;
+ omp_init_lock(&lock);
+ omp_set_lock(&lock);
+ GDALAllRegister();
+ CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
+ GDALDataset* rasterDataset = (GDALDataset*)(GDALOpen(
+ this->img_path.toUtf8().constData(), GA_ReadOnly)); // 锟斤拷只斤拷式锟斤拷取斤拷影锟斤拷
+
+ GDALDataType gdal_datatype = rasterDataset->GetRasterBand(1)->GetRasterDataType();
+ GDALRasterBand* demBand = rasterDataset->GetRasterBand(band_ids);
+
+ rows_count = start_row + rows_count <= this->height ? rows_count : this->height - start_row;
+ cols_count = start_col + cols_count <= this->width ? cols_count : this->width - start_col;
+
+ Eigen::MatrixXf datamatrix(rows_count, cols_count);
+
+ if (gdal_datatype == GDT_Byte) {
+ char* temp = new char[rows_count * cols_count];
+ demBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, temp, cols_count,
+ rows_count, gdal_datatype, 0, 0);
+ for (int i = 0; i < rows_count; i++) {
+ for (int j = 0; j < cols_count; j++) {
+ datamatrix(i, j) = temp[i * cols_count + j];
+ }
+ }
+ delete[] temp;
+ }
+ else if (gdal_datatype == GDT_UInt16) {
+ unsigned short* temp = new unsigned short[rows_count * cols_count];
+ demBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, temp, cols_count,
+ rows_count, gdal_datatype, 0, 0);
+ for (int i = 0; i < rows_count; i++) {
+ for (int j = 0; j < cols_count; j++) {
+ datamatrix(i, j) = temp[i * cols_count + j];
+ }
+ }
+ delete[] temp;
+ }
+ else if (gdal_datatype == GDT_Int16) {
+ short* temp = new short[rows_count * cols_count];
+ demBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, temp, cols_count,
+ rows_count, gdal_datatype, 0, 0);
+ for (int i = 0; i < rows_count; i++) {
+ for (int j = 0; j < cols_count; j++) {
+ datamatrix(i, j) = temp[i * cols_count + j];
+ }
+ }
+ delete[] temp;
+ }
+ else if (gdal_datatype == GDT_UInt32) {
+ unsigned int* temp = new unsigned int[rows_count * cols_count];
+ demBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, temp, cols_count,
+ rows_count, gdal_datatype, 0, 0);
+ for (int i = 0; i < rows_count; i++) {
+ for (int j = 0; j < cols_count; j++) {
+ datamatrix(i, j) = temp[i * cols_count + j];
+ }
+ }
+ delete[] temp;
+ }
+ else if (gdal_datatype == GDT_Int32) {
+ int* temp = new int[rows_count * cols_count];
+ demBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, temp, cols_count,
+ rows_count, gdal_datatype, 0, 0);
+ for (int i = 0; i < rows_count; i++) {
+ for (int j = 0; j < cols_count; j++) {
+ datamatrix(i, j) = temp[i * cols_count + j];
+ }
+ }
+ delete[] temp;
+ }
+ //else if (gdal_datatype == GDT_UInt64) {
+ // unsigned long* temp = new unsigned long[rows_count * cols_count];
+ // demBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, temp, cols_count,
+ // rows_count, gdal_datatype, 0, 0); for (int i = 0; i < rows_count; i++) {
+ // for (int j = 0; j <
+ // cols_count; j++) {
+ // datamatrix(i, j) = temp[i * cols_count + j];
+ // }
+ // }
+ // delete[] temp;
+ //}
+ //else if (gdal_datatype == GDT_Int64) {
+ // long* temp = new long[rows_count * cols_count];
+ // demBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, temp, cols_count,
+ // rows_count, gdal_datatype, 0, 0); for (int i = 0; i < rows_count; i++) {
+ // for (int j = 0; j <
+ // cols_count; j++) {
+ // datamatrix(i, j) = temp[i * cols_count + j];
+ // }
+ // }
+ // delete[] temp;
+ //}
+ else if (gdal_datatype == GDT_Float32) {
+ float* temp = new float[rows_count * cols_count];
+ demBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, temp, cols_count,
+ rows_count, gdal_datatype, 0, 0);
+
+ for (int i = 0; i < rows_count; i++) {
+ for (int j = 0; j < cols_count; j++) {
+ datamatrix(i, j) = temp[i * cols_count + j];
+ }
+ }
+ delete[] temp;
+ }
+ else if (gdal_datatype == GDT_Float64) {
+ double* temp = new double[rows_count * cols_count];
+ demBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, temp, cols_count,
+ rows_count, gdal_datatype, 0, 0);
+
+ for (int i = 0; i < rows_count; i++) {
+ for (int j = 0; j < cols_count; j++) {
+ datamatrix(i, j) = temp[i * cols_count + j];
+ }
+ }
+ delete[] temp;
+ }
+ else {
+ }
+ GDALClose((GDALDatasetH)rasterDataset);
+ omp_unset_lock(&lock); // 锟酵放伙拷斤拷
+ omp_destroy_lock(&lock); // 劫伙拷斤拷
+ // GDALDestroy(); // or, DllMain at DLL_PROCESS_DETACH
+ return datamatrix;
+}
+
+
+
Eigen::MatrixXi gdalImage::getDatai(int start_row, int start_col, int rows_count, int cols_count, int band_ids)
{
omp_lock_t lock;
@@ -848,7 +979,10 @@ void gdalImage::saveImage(Eigen::MatrixXd data, int start_row = 0, int start_col
}
GDALAllRegister();
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
- GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName("GTiff");
+
+ QString filesuffer = getFileExtension(this->img_path).toLower();
+ bool isTiff = filesuffer.contains("tif");
+ GDALDriver* poDriver = isTiff? GetGDALDriverManager()->GetDriverByName("GTiff"): GetGDALDriverManager()->GetDriverByName("ENVI");
GDALDataset* poDstDS = nullptr;
if(exists_test(this->img_path)) {
poDstDS = (GDALDataset*)(GDALOpen(this->img_path.toUtf8().constData(), GA_Update));
@@ -912,9 +1046,90 @@ void gdalImage::saveImage(Eigen::MatrixXd data, int start_row = 0, int start_col
omp_destroy_lock(&lock); // 劫伙拷斤拷
}
+void gdalImage::saveImage(Eigen::MatrixXf data, int start_row = 0, int start_col = 0,
+ int band_ids = 1)
+{
+ GDALDataType datetype = this->getDataType();
+ omp_lock_t lock;
+ omp_init_lock(&lock);
+ omp_set_lock(&lock);
+ if (start_row + data.rows() > this->height || start_col + data.cols() > this->width) {
+ QString tip = u8"file path: " + this->img_path + " image size :( " + QString::number(this->height) + " , " + QString::number(this->width) + " ) " + " input size (" + QString::number(start_row + data.rows()) + ", " + QString::number(start_col + data.cols()) + ") ";
+ qDebug() << tip;
+ throw std::exception(tip.toUtf8().constData());
+ }
+ GDALAllRegister();
+ CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
+ QString filesuffer = getFileExtension(this->img_path).toLower();
+ bool isTiff = filesuffer.contains("tif");
+ GDALDriver* poDriver = isTiff ? GetGDALDriverManager()->GetDriverByName("GTiff") : GetGDALDriverManager()->GetDriverByName("ENVI");
+ GDALDataset* poDstDS = nullptr;
+ if (exists_test(this->img_path)) {
+ poDstDS = (GDALDataset*)(GDALOpen(this->img_path.toUtf8().constData(), GA_Update));
+ }
+ else {
+ poDstDS = poDriver->Create(this->img_path.toUtf8().constData(), this->width, this->height,
+ this->band_num, datetype, NULL); // 斤拷锟斤拷
+
+ if (nullptr == poDstDS) {
+ QString tip = u8"file path: " + this->img_path + " image size :( " + QString::number(this->height) + " , " + QString::number(this->width) + " ) " + " input size (" + QString::number(start_row + data.rows()) + ", " + QString::number(start_col + data.cols()) + ") ";
+ qDebug() << tip;
+ throw std::exception(tip.toUtf8().constData());
+ return;
+ }
+
+ poDstDS->SetProjection(this->projection.toUtf8().constData());
+
+ double gt_ptr[6];
+ for (int i = 0; i < this->gt.rows(); i++) {
+ for (int j = 0; j < this->gt.cols(); j++) {
+ gt_ptr[i * 3 + j] = this->gt(i, j);
+ }
+ }
+ poDstDS->SetGeoTransform(gt_ptr);
+ //delete gt_ptr;
+ }
+
+
+ int datarows = data.rows();
+ int datacols = data.cols();
+ void* databuffer = nullptr;
+ if (datetype == GDT_Float32) {
+ databuffer = new float[datarows * datacols];
+ for (int i = 0; i < datarows; i++) {
+ for (int j = 0; j < datacols; j++) {
+ ((float*)databuffer)[i * datacols + j] = float(data(i, j));
+ }
+ }
+
+ poDstDS->GetRasterBand(band_ids)->RasterIO(GF_Write, start_col, start_row, datacols, datarows,
+ databuffer, datacols, datarows, datetype, 0, 0);
+ }
+ else if (datetype == GDT_Float64) {
+ databuffer = new double[datarows * datacols];
+ for (int i = 0; i < datarows; i++) {
+ for (int j = 0; j < datacols; j++) {
+ ((double*)databuffer)[i * datacols + j] = double(data(i, j));
+ }
+ }
+
+ poDstDS->GetRasterBand(band_ids)->RasterIO(GF_Write, start_col, start_row, datacols, datarows,
+ databuffer, datacols, datarows, datetype, 0, 0);
+ }
+ else {
+
+ }
+ GDALFlushCache(poDstDS);
+ GDALClose((GDALDatasetH)poDstDS);
+ // GDALDestroy(); // or, DllMain at DLL_PROCESS_DETACH
+ delete[] databuffer;
+ omp_unset_lock(&lock); // 锟酵放伙拷斤拷
+ omp_destroy_lock(&lock); // 劫伙拷斤拷
+}
+
+
void gdalImage::saveImage(Eigen::MatrixXi data, int start_row, int start_col, int band_ids)
{
-
GDALDataType datetype=this->getDataType();
omp_lock_t lock;
omp_init_lock(&lock);
@@ -926,7 +1141,9 @@ void gdalImage::saveImage(Eigen::MatrixXi data, int start_row, int start_col, in
}
GDALAllRegister();
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
- GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName("GTiff");
+ QString filesuffer = getFileExtension(this->img_path).toLower();
+ bool isTiff = filesuffer.contains("tif");
+ GDALDriver* poDriver = isTiff ? GetGDALDriverManager()->GetDriverByName("GTiff") : GetGDALDriverManager()->GetDriverByName("ENVI");
GDALDataset* poDstDS = nullptr;
if (exists_test(this->img_path)) {
poDstDS = (GDALDataset*)(GDALOpen(this->img_path.toUtf8().constData(), GA_Update));
@@ -969,6 +1186,191 @@ void gdalImage::saveImage(Eigen::MatrixXi data, int start_row, int start_col, in
omp_destroy_lock(&lock); // 劫伙拷斤拷
}
+void gdalImage::saveImage(std::shared_ptr data, int start_row, int start_col, int rowcount, int colcount, int band_ids)
+{
+ GDALDataType datetype = this->getDataType();
+ omp_lock_t lock;
+ omp_init_lock(&lock);
+ omp_set_lock(&lock);
+ if (start_row + rowcount > this->height || start_col + colcount > this->width) {
+ QString tip = u8"file path: " + this->img_path + " image size :( " + QString::number(this->height) + " , " + QString::number(this->width) + " ) " + " input size (" + QString::number(start_row + rowcount) + ", " + QString::number(start_col + colcount) + ") ";
+ qDebug() << tip;
+ throw std::exception(tip.toUtf8().constData());
+ }
+ GDALAllRegister();
+ CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
+ QString filesuffer = getFileExtension(this->img_path).toLower();
+ bool isTiff = filesuffer.contains("tif");
+ GDALDriver* poDriver = isTiff ? GetGDALDriverManager()->GetDriverByName("GTiff") : GetGDALDriverManager()->GetDriverByName("ENVI");
+ GDALDataset* poDstDS = nullptr;
+ if (exists_test(this->img_path)) {
+ poDstDS = (GDALDataset*)(GDALOpen(this->img_path.toUtf8().constData(), GA_Update));
+ }
+ else {
+ poDstDS = poDriver->Create(this->img_path.toUtf8().constData(), this->width, this->height,
+ this->band_num, GDT_Float32, NULL); // 斤拷锟斤拷
+ poDstDS->SetProjection(this->projection.toUtf8().constData());
+
+ double gt_ptr[6];
+ for (int i = 0; i < this->gt.rows(); i++) {
+ for (int j = 0; j < this->gt.cols(); j++) {
+ gt_ptr[i * 3 + j] = this->gt(i, j);
+ }
+ }
+ poDstDS->SetGeoTransform(gt_ptr);
+ }
+
+ long datarows = rowcount;
+ long datacols = colcount;
+ double* databuffer = new double[datarows * datacols];
+ if (datetype == GDT_Float64) {
+ memcpy(databuffer, data.get(), sizeof(double) * datarows * datacols);
+ }
+ else {
+ for (long i = 0; i < datarows; i++) {
+ for (long j = 0; j < datacols; j++) {
+ databuffer[i * datacols + j] = data.get()[i * datacols + j];
+ }
+ }
+ }
+
+ // poDstDS->RasterIO(GF_Write,start_col, start_row, datacols, datarows, databuffer, datacols,
+ // datarows, GDT_Float32,band_ids, num,0,0,0);
+ poDstDS->GetRasterBand(band_ids)->RasterIO(GF_Write, start_col, start_row, datacols, datarows,
+ databuffer, datacols, datarows, datetype, 0, 0);
+
+ GDALFlushCache(poDstDS);
+ GDALClose((GDALDatasetH)poDstDS);
+ // GDALDestroy(); // or, DllMain at DLL_PROCESS_DETACH
+ delete[] databuffer;
+ omp_unset_lock(&lock); // 锟酵放伙拷斤拷
+ omp_destroy_lock(&lock); // 劫伙拷斤拷
+}
+
+void gdalImage::saveImage(std::shared_ptr data, int start_row, int start_col, int rowcount, int colcount, int band_ids)
+{
+ GDALDataType datetype = this->getDataType();
+ omp_lock_t lock;
+ omp_init_lock(&lock);
+ omp_set_lock(&lock);
+ if (start_row + rowcount > this->height || start_col + colcount > this->width) {
+ QString tip = u8"file path: " + this->img_path + " image size :( " + QString::number(this->height) + " , " + QString::number(this->width) + " ) " + " input size (" + QString::number(start_row + rowcount) + ", " + QString::number(start_col + colcount) + ") ";
+ qDebug() << tip;
+ throw std::exception(tip.toUtf8().constData());
+ }
+ GDALAllRegister();
+ CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
+ QString filesuffer = getFileExtension(this->img_path).toLower();
+ bool isTiff = filesuffer.contains("tif");
+ GDALDriver* poDriver = isTiff ? GetGDALDriverManager()->GetDriverByName("GTiff") : GetGDALDriverManager()->GetDriverByName("ENVI");
+ GDALDataset* poDstDS = nullptr;
+ if (exists_test(this->img_path)) {
+ poDstDS = (GDALDataset*)(GDALOpen(this->img_path.toUtf8().constData(), GA_Update));
+ }
+ else {
+ poDstDS = poDriver->Create(this->img_path.toUtf8().constData(), this->width, this->height,
+ this->band_num, GDT_Float32, NULL); // 斤拷锟斤拷
+ poDstDS->SetProjection(this->projection.toUtf8().constData());
+
+ double gt_ptr[6];
+ for (int i = 0; i < this->gt.rows(); i++) {
+ for (int j = 0; j < this->gt.cols(); j++) {
+ gt_ptr[i * 3 + j] = this->gt(i, j);
+ }
+ }
+ poDstDS->SetGeoTransform(gt_ptr);
+ }
+
+ long datarows = rowcount;
+ long datacols = colcount;
+ float* databuffer = new float[datarows * datacols];
+ if (datetype == GDT_Float32) {
+ memcpy(databuffer, data.get(), sizeof(float) * datarows * datacols);
+ }
+ else {
+ for (long i = 0; i < datarows; i++) {
+ for (long j = 0; j < datacols; j++) {
+ databuffer[i * datacols + j] = data.get()[i * datacols + j];
+ }
+ }
+ }
+
+ // poDstDS->RasterIO(GF_Write,start_col, start_row, datacols, datarows, databuffer, datacols,
+ // datarows, GDT_Float32,band_ids, num,0,0,0);
+ poDstDS->GetRasterBand(band_ids)->RasterIO(GF_Write, start_col, start_row, datacols, datarows,
+ databuffer, datacols, datarows, datetype, 0, 0);
+
+ GDALFlushCache(poDstDS);
+ GDALClose((GDALDatasetH)poDstDS);
+ // GDALDestroy(); // or, DllMain at DLL_PROCESS_DETACH
+ delete[] databuffer;
+ omp_unset_lock(&lock); // 锟酵放伙拷斤拷
+ omp_destroy_lock(&lock); // 劫伙拷斤拷
+}
+
+
+void gdalImage::saveImage(std::shared_ptr data, int start_row, int start_col, int rowcount, int colcount, int band_ids)
+{
+ GDALDataType datetype = this->getDataType();
+ omp_lock_t lock;
+ omp_init_lock(&lock);
+ omp_set_lock(&lock);
+ if (start_row + rowcount > this->height || start_col + colcount > this->width) {
+ QString tip = u8"file path: " + this->img_path + " image size :( " + QString::number(this->height) + " , " + QString::number(this->width) + " ) " + " input size (" + QString::number(start_row + rowcount) + ", " + QString::number(start_col + colcount) + ") ";
+ qDebug() << tip;
+ throw std::exception(tip.toUtf8().constData());
+ }
+ GDALAllRegister();
+ CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
+ QString filesuffer = getFileExtension(this->img_path).toLower();
+ bool isTiff = filesuffer.contains("tif");
+ GDALDriver* poDriver = isTiff ? GetGDALDriverManager()->GetDriverByName("GTiff") : GetGDALDriverManager()->GetDriverByName("ENVI");
+ GDALDataset* poDstDS = nullptr;
+ if (exists_test(this->img_path)) {
+ poDstDS = (GDALDataset*)(GDALOpen(this->img_path.toUtf8().constData(), GA_Update));
+ }
+ else {
+ poDstDS = poDriver->Create(this->img_path.toUtf8().constData(), this->width, this->height,
+ this->band_num, GDT_Float32, NULL); // 斤拷锟斤拷
+ poDstDS->SetProjection(this->projection.toUtf8().constData());
+
+ double gt_ptr[6];
+ for (int i = 0; i < this->gt.rows(); i++) {
+ for (int j = 0; j < this->gt.cols(); j++) {
+ gt_ptr[i * 3 + j] = this->gt(i, j);
+ }
+ }
+ poDstDS->SetGeoTransform(gt_ptr);
+ }
+
+ long datarows = rowcount;
+ long datacols = colcount;
+ int* databuffer = new int[datarows * datacols];
+ if (datetype == GDT_Int32) {
+ memcpy(databuffer, data.get(), sizeof(int) * datarows * datacols);
+ }
+ else {
+ for (long i = 0; i < datarows; i++) {
+ for (long j = 0; j < datacols; j++) {
+ databuffer[i * datacols + j] = data.get()[i * datacols + j];
+ }
+ }
+ }
+
+ // poDstDS->RasterIO(GF_Write,start_col, start_row, datacols, datarows, databuffer, datacols,
+ // datarows, GDT_Float32,band_ids, num,0,0,0);
+ poDstDS->GetRasterBand(band_ids)->RasterIO(GF_Write, start_col, start_row, datacols, datarows,
+ databuffer, datacols, datarows, datetype, 0, 0);
+
+ GDALFlushCache(poDstDS);
+ GDALClose((GDALDatasetH)poDstDS);
+ // GDALDestroy(); // or, DllMain at DLL_PROCESS_DETACH
+ delete[] databuffer;
+ omp_unset_lock(&lock); // 锟酵放伙拷斤拷
+ omp_destroy_lock(&lock); // 劫伙拷斤拷
+}
+
+
void gdalImage::saveImage()
{
this->saveImage(this->data, this->start_row, this->start_col, this->data_band_ids);
@@ -1500,7 +1902,8 @@ int ResampleGDAL(const char* pszSrcFile, const char* pszOutFile, double* gt, int
pDDst->SetGeoTransform(gt);
GDALWarpOptions* psWo = GDALCreateWarpOptions();
-
+ CPLSetConfigOption("GDAL_NUM_THREADS", "ALL_CPUS"); // 使用所有可用的CPU核心
+ CPLSetConfigOption("GDAL_CACHEMAX", "16000"); // 设置缓存大小为500MB
// psWo->papszWarpOptions = CSLDuplicate(NULL);
psWo->eWorkingDataType = dataType;
psWo->eResampleAlg = eResample;
diff --git a/BaseCommonLibrary/BaseTool/ImageOperatorBase.h b/BaseCommonLibrary/BaseTool/ImageOperatorBase.h
index 7f7fecd..153e33d 100644
--- a/BaseCommonLibrary/BaseTool/ImageOperatorBase.h
+++ b/BaseCommonLibrary/BaseTool/ImageOperatorBase.h
@@ -71,14 +71,14 @@ enum GDALREADARRCOPYMETHOD {
VARIABLEMETHOD // 变量赋值
};
-
-class BASECONSTVARIABLEAPI ShowProessAbstract{
+
+class BASECONSTVARIABLEAPI ShowProessAbstract {
public:
- virtual void showProcess(double precent,QString tip);
- virtual void showToolInfo( QString tip) ;
+ virtual void showProcess(double precent, QString tip);
+ virtual void showToolInfo(QString tip);
};
@@ -91,7 +91,7 @@ public:
/// \param long 经度
/// \param lat 纬度
/// \return 对应投影坐标系统的 EPSG编码,-1 表示计算错误
-long BASECONSTVARIABLEAPI getProjectEPSGCodeByLon_Lat(double long, double lat,ProjectStripDelta stripState );
+long BASECONSTVARIABLEAPI getProjectEPSGCodeByLon_Lat(double long, double lat, ProjectStripDelta stripState);
long BASECONSTVARIABLEAPI getProjectEPSGCodeByLon_Lat_inStrip3(double lon, double lat);
@@ -106,15 +106,15 @@ long BASECONSTVARIABLEAPI GetEPSGFromRasterFile(QString filepath);
std::shared_ptr BASECONSTVARIABLEAPI GetCenterPointInRaster(QString filepath);
CoordinateSystemType BASECONSTVARIABLEAPI getCoordinateSystemTypeByEPSGCode(long EPSGCODE);
-
-
+
+
// 文件打开 // 当指令销毁时,调用GDALClose 销毁类型
-std::shared_ptr BASECONSTVARIABLEAPI OpenDataset(const QString& in_path, GDALAccess rwmode= GA_ReadOnly);
+std::shared_ptr BASECONSTVARIABLEAPI OpenDataset(const QString& in_path, GDALAccess rwmode = GA_ReadOnly);
void BASECONSTVARIABLEAPI CloseDataset(GDALDataset* ptr);
// 数据格式转换
-int BASECONSTVARIABLEAPI TIFF2ENVI(QString in_tiff_path,QString out_envi_path);
-int BASECONSTVARIABLEAPI ENVI2TIFF(QString in_envi_path,QString out_tiff_path);
+int BASECONSTVARIABLEAPI TIFF2ENVI(QString in_tiff_path, QString out_envi_path);
+int BASECONSTVARIABLEAPI ENVI2TIFF(QString in_envi_path, QString out_tiff_path);
// 保存影像数据 --直接保存 ENVI 文件
@@ -123,12 +123,12 @@ int BASECONSTVARIABLEAPI CreateDataset(QString new_file_path, int height, in
int BASECONSTVARIABLEAPI saveDataset(QString new_file_path, int start_line, int start_cols, int band_ids, int datacols, int datarows, void* databuffer);
// 根据限制条件估算分块大小
-int BASECONSTVARIABLEAPI block_num_pre_memory(int width, int height, GDALDataType gdal_dtype,double memey_size);
+int BASECONSTVARIABLEAPI block_num_pre_memory(int width, int height, GDALDataType gdal_dtype, double memey_size);
// 将结果转换为复数 或者 实数
-Eigen::Matrix BASECONSTVARIABLEAPI ReadComplexMatrixData(int start_line,int width, int line_num, std::shared_ptr rasterDataset, GDALDataType gdal_datatype);
+Eigen::Matrix BASECONSTVARIABLEAPI ReadComplexMatrixData(int start_line, int width, int line_num, std::shared_ptr rasterDataset, GDALDataType gdal_datatype);
-Eigen::Matrix BASECONSTVARIABLEAPI ReadMatrixDoubleData(int start_line, int width, int line_num, std::shared_ptr rasterDataset, GDALDataType gdal_datatype,int band_idx);
+Eigen::Matrix BASECONSTVARIABLEAPI ReadMatrixDoubleData(int start_line, int width, int line_num, std::shared_ptr rasterDataset, GDALDataType gdal_datatype, int band_idx);
Eigen::MatrixXd BASECONSTVARIABLEAPI getGeoTranslationArray(QString in_path);
ImageGEOINFO BASECONSTVARIABLEAPI getImageINFO(QString in_path);
@@ -143,7 +143,7 @@ struct RasterExtend {
double max_y;//经度
};
-
+
@@ -161,15 +161,23 @@ public: // 方法
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 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::MatrixXf getDataf(int start_row, int start_col, int rows_count, int cols_count, int band_ids);
virtual Eigen::MatrixXi getDatai(int start_row, int start_col, int rows_count, int cols_count, int band_ids);
virtual ErrorCode getData(double* data, int start_row, int start_col, int rows_count, int cols_count, int band_ids);
virtual ErrorCode getData(long* data, 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(Eigen::MatrixXf, int start_row, int start_col, int band_ids);
virtual void saveImage(Eigen::MatrixXi, int start_row, int start_col, int band_ids);
+ virtual void saveImage(std::shared_ptr, int start_row, int start_col,int rowcount,int colcount, int band_ids);
+ virtual void saveImage(std::shared_ptr, int start_row, int start_col, int rowcount, int colcount, int band_ids);
+ virtual void saveImage(std::shared_ptr, int start_row, int start_col, int rowcount, int colcount, int band_ids);
+
+
+
virtual void saveImage();
virtual void setNoDataValue(double nodatavalue, int band_ids);
virtual void setNoDataValuei(int nodatavalue, int band_ids);
@@ -186,7 +194,7 @@ public: // 方法
double BandminValue(int bandids = 1);
virtual GDALRPCInfo getRPC();
virtual Eigen::MatrixXd getLandPoint(Eigen::MatrixXd points);
-
+
virtual Eigen::MatrixXd getHist(int bandids);
virtual RasterExtend getExtend();
@@ -210,7 +218,7 @@ public:
///
/// gdalImage图像操作类
///
-class BASECONSTVARIABLEAPI gdalImageComplex:public gdalImage
+class BASECONSTVARIABLEAPI gdalImageComplex :public gdalImage
{
public: // 方法
@@ -219,7 +227,7 @@ public: // 方法
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;
void savePreViewImage();
public:
@@ -230,7 +238,7 @@ public:
gdalImage BASECONSTVARIABLEAPI CreategdalImageDouble(const QString& img_path, int height, int width, int band_num, Eigen::MatrixXd gt, QString projection, bool need_gt = true, bool overwrite = false, bool isEnvi = false);
gdalImage BASECONSTVARIABLEAPI CreategdalImage(const QString& img_path, int height, int width, int band_num, Eigen::MatrixXd gt, QString projection, bool need_gt = true, bool overwrite = false, bool isEnvi = false);
-gdalImage BASECONSTVARIABLEAPI CreategdalImage(const QString& img_path, int height, int width, int band_num, Eigen::MatrixXd gt, long espgcode, GDALDataType eType=GDT_Float32, bool need_gt = true, bool overwrite = false,bool isENVI=false);
+gdalImage BASECONSTVARIABLEAPI CreategdalImage(const QString& img_path, int height, int width, int band_num, Eigen::MatrixXd gt, long espgcode, GDALDataType eType = GDT_Float32, bool need_gt = true, bool overwrite = false, bool isENVI = false);
gdalImageComplex BASECONSTVARIABLEAPI CreategdalImageComplex(const QString& img_path, int height, int width, int band_num, Eigen::MatrixXd gt, QString projection, bool need_gt = true, bool overwrite = false);
@@ -255,7 +263,7 @@ int BASECONSTVARIABLEAPI alignRaster(QString inputPath, QString referencePath
//--------------------- 保存文博 -------------------------------
int BASECONSTVARIABLEAPI saveMatrixXcd2TiFF(Eigen::MatrixXcd data, QString out_tiff_path);
-
+
//----------------------------------------------------
void BASECONSTVARIABLEAPI clipRaster(QString inRasterPath, QString outRasterPath, long minRow, long maxRow, long minCol, long maxCol);
@@ -270,11 +278,11 @@ enum MERGEMODE
};
-ErrorCode BASECONSTVARIABLEAPI MergeRasterProcess(QVector filepath, QString outfileptah, QString mainString, MERGEMODE mergecode = MERGEMODE::MERGE_GEOCODING, bool isENVI = false, ShowProessAbstract* dia=nullptr);
+ErrorCode BASECONSTVARIABLEAPI MergeRasterProcess(QVector filepath, QString outfileptah, QString mainString, MERGEMODE mergecode = MERGEMODE::MERGE_GEOCODING, bool isENVI = false, ShowProessAbstract* dia = nullptr);
-ErrorCode BASECONSTVARIABLEAPI MergeRasterInGeoCoding(QVector inimgs, gdalImage resultimg,gdalImage maskimg, ShowProessAbstract* dia = nullptr);
-
+ErrorCode BASECONSTVARIABLEAPI MergeRasterInGeoCoding(QVector inimgs, gdalImage resultimg, gdalImage maskimg, ShowProessAbstract* dia = nullptr);
+
// 保存矩阵转换为envi文件,默认数据格式为double
bool BASECONSTVARIABLEAPI saveEigenMatrixXd2Bin(Eigen::MatrixXd data, QString dataStrPath);
@@ -293,7 +301,7 @@ void BASECONSTVARIABLEAPI testOutClsArr(QString filename, long* amp, long rowc
//--------------------- 图像文件读写 ------------------------------
template
-inline std::shared_ptr readDataArr(gdalImage& imgds, int start_row, int start_col, int rows_count, int cols_count, int band_ids, GDALREADARRCOPYMETHOD method)
+inline std::shared_ptr readDataArr(gdalImage& imgds, int start_row, int start_col, int& rows_count, int& cols_count, int band_ids, GDALREADARRCOPYMETHOD method)
{
std::shared_ptr result = nullptr;
@@ -492,7 +500,7 @@ inline std::shared_ptr readDataArr(gdalImage& imgds, int start_row, int start
}
template
-inline std::shared_ptr readDataArrComplex(gdalImageComplex& imgds, int start_row, int start_col, int rows_count, int cols_count, int band_ids, GDALREADARRCOPYMETHOD method)
+inline std::shared_ptr readDataArrComplex(gdalImageComplex& imgds, int start_row, int start_col, int& rows_count, int& cols_count, int band_ids, GDALREADARRCOPYMETHOD method)
{
std::shared_ptr result = nullptr;
@@ -565,6 +573,8 @@ inline std::shared_ptr readDataArrComplex(gdalImageComplex& imgds, int start_
}
+
+
//--------------------- 图像分块 ------------------------------
diff --git a/BaseCommonLibrary/BaseTool/PrintMsgToQDebug.cpp b/BaseCommonLibrary/BaseTool/PrintMsgToQDebug.cpp
new file mode 100644
index 0000000..a8475f6
--- /dev/null
+++ b/BaseCommonLibrary/BaseTool/PrintMsgToQDebug.cpp
@@ -0,0 +1,7 @@
+#include "PrintMsgToQDebug.h"
+#include
+BASECONSTVARIABLEAPI void PrintMsgToQDebug(char* msg)
+{
+ qDebug() << QString(msg);
+ return ;
+}
diff --git a/BaseCommonLibrary/BaseTool/PrintMsgToQDebug.h b/BaseCommonLibrary/BaseTool/PrintMsgToQDebug.h
new file mode 100644
index 0000000..ad99a59
--- /dev/null
+++ b/BaseCommonLibrary/BaseTool/PrintMsgToQDebug.h
@@ -0,0 +1,10 @@
+#pragma once
+#ifndef PRINTMSGTOQDEBUG_H_
+#define PRINTMSGTOQDEBUG_H_
+#include "BaseConstVariable.h"
+
+extern "C" BASECONSTVARIABLEAPI void PrintMsgToQDebug(char* msg);
+#endif // !PRINTMSGTOQDEBUG_H_
+
+
+
\ No newline at end of file
diff --git a/LAMPSARProcessProgram/RasterProcessTool.vcxproj b/LAMPSARProcessProgram/RasterProcessTool.vcxproj
index 85f2c20..91bfab9 100644
--- a/LAMPSARProcessProgram/RasterProcessTool.vcxproj
+++ b/LAMPSARProcessProgram/RasterProcessTool.vcxproj
@@ -148,6 +148,7 @@
+
diff --git a/LAMPSARProcessProgram/RasterProcessTool.vcxproj.filters b/LAMPSARProcessProgram/RasterProcessTool.vcxproj.filters
index 99e980b..c3463ef 100644
--- a/LAMPSARProcessProgram/RasterProcessTool.vcxproj.filters
+++ b/LAMPSARProcessProgram/RasterProcessTool.vcxproj.filters
@@ -64,5 +64,8 @@
Header Files
+
+ Header Files
+
\ No newline at end of file
diff --git a/LAMPSARProcessProgram/RasterProcessToolWidgetCFunAPI.h b/LAMPSARProcessProgram/RasterProcessToolWidgetCFunAPI.h
new file mode 100644
index 0000000..524bbf5
--- /dev/null
+++ b/LAMPSARProcessProgram/RasterProcessToolWidgetCFunAPI.h
@@ -0,0 +1,12 @@
+#pragma once
+#ifndef RASTERPROCESSTOOLWIDGETCFUNAPI_H_
+#define RASTERPROCESSTOOLWIDGETCFUNAPI_H_
+
+#ifdef RASTERPROCESSTOOLWIDGET_LIB
+#define RASTERPROCESSTOOLWIDGETCFUNAPI_EXPORT __declspec(dllexport)
+#else
+#define RASTERPROCESSTOOLWIDGETCFUNAPI_EXPORT __declspec(dllimport)
+#endif
+
+
+#endif
diff --git a/RasterMainWidgetGUI/PrintMessage_C.cpp b/RasterMainWidgetGUI/PrintMessage_C.cpp
new file mode 100644
index 0000000..011c04f
--- /dev/null
+++ b/RasterMainWidgetGUI/PrintMessage_C.cpp
@@ -0,0 +1,10 @@
+#include "PrintMessage_C.h"
+#include
+
+
+
+RASTERMAINWIDGETGUICFUNAPI_EXPORT void PrintMessageWindowsShow_C_Fun(char* msg)
+{
+ qDebug() << QString(msg);
+ return ;
+}
diff --git a/RasterMainWidgetGUI/PrintMessage_C.h b/RasterMainWidgetGUI/PrintMessage_C.h
new file mode 100644
index 0000000..75c0227
--- /dev/null
+++ b/RasterMainWidgetGUI/PrintMessage_C.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#ifndef PRINTMESSAGE_C_H_
+#define PRINTMESSAGE_C_H_
+
+#include "RasterMainWidgetGUICFunAPI.h"
+
+
+extern "C" RASTERMAINWIDGETGUICFUNAPI_EXPORT void PrintMessageWindowsShow_C_Fun(char* msg);
+
+
+
+#endif
diff --git a/RasterMainWidgetGUI/RasterMainWidgetGUI.vcxproj b/RasterMainWidgetGUI/RasterMainWidgetGUI.vcxproj
index b647dd0..796ebba 100644
--- a/RasterMainWidgetGUI/RasterMainWidgetGUI.vcxproj
+++ b/RasterMainWidgetGUI/RasterMainWidgetGUI.vcxproj
@@ -99,6 +99,7 @@
+
@@ -135,7 +136,9 @@
+
+
diff --git a/RasterMainWidgetGUI/RasterMainWidgetGUI.vcxproj.filters b/RasterMainWidgetGUI/RasterMainWidgetGUI.vcxproj.filters
index 5add534..35b42fa 100644
--- a/RasterMainWidgetGUI/RasterMainWidgetGUI.vcxproj.filters
+++ b/RasterMainWidgetGUI/RasterMainWidgetGUI.vcxproj.filters
@@ -118,6 +118,9 @@
Source Files
+
+ Source Files
+
@@ -201,6 +204,12 @@
Header Files
+
+ Header Files
+
+
+ Header Files
+
diff --git a/RasterMainWidgetGUI/RasterMainWidgetGUICFunAPI.h b/RasterMainWidgetGUI/RasterMainWidgetGUICFunAPI.h
new file mode 100644
index 0000000..9bcddb3
--- /dev/null
+++ b/RasterMainWidgetGUI/RasterMainWidgetGUICFunAPI.h
@@ -0,0 +1,11 @@
+#pragma once
+#ifndef RASTERMAINWIDGETGUICFUNAPI_H_
+#define RASTERMAINWIDGETGUICFUNAPI_H_
+
+#ifdef RASTERMAINWIDGETGUI_LIB
+#define RASTERMAINWIDGETGUICFUNAPI_EXPORT __declspec(dllexport)
+#else
+#define RASTERMAINWIDGETGUICFUNAPI_EXPORT __declspec(dllimport)
+#endif
+
+#endif
diff --git a/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableComputerClass.cpp b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableComputerClass.cpp
index d2c12bf..9f8664f 100644
--- a/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableComputerClass.cpp
+++ b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableComputerClass.cpp
@@ -1,17 +1,44 @@
#include "LookTableComputerClass.h"
#include "SatelliteOribtModel.h"
#include "SARSimulationTaskSetting.h"
+#include "ImageOperatorBase.h"
+#include "FileOperator.h"
+#include "BaseConstVariable.h"
+#include "GPUTool.cuh"
#include
+
// dingy
namespace LookTableSimualtionMainProcessSpace {
- void LookTableSimualtionMainProcess(QString orbitpath, QString SatePath, QString DEMPath, QString outDirPath,
- double gridX, double gridY, bool gpuflag, bool looktableflag, bool checkBoxIncAngle, bool BoxDopplerFlag)
+ void LookTableSimualtionMainProcess(
+ QString sateName,
+ QString orbitpath, QString SatePath, QString DEMPath, QString outDirPath,
+ bool gpuflag,
+ bool looktableflag,
+ bool checkBoxIncAngle,
+ bool DopplerFlag)
{
+ if (!isExists(orbitpath)) {
+ qDebug() << "Orbit model file is not exist !!!";
+ return;
+ }
+ if (!isExists(SatePath)) {
+ qDebug() << "Satellite Model file is not exist !!!";
+ return;
+ }
+ if (!isExists(DEMPath)) {
+ qDebug() << "DEM file is not exist !!!";
+ return;
+ }
+
+
+
+
+
// ȡģ
qDebug() << "load orbit model params from xml :" << orbitpath;
PolyfitSatelliteOribtModel orbitmodel;
@@ -19,12 +46,12 @@ namespace LookTableSimualtionMainProcessSpace {
//
long double OribtStartTime = orbitmodel.getOribtStartTime();
- std::vector PolyfitPx = orbitmodel.getPolyfitPx();
- std::vector PolyfitPy = orbitmodel.getPolyfitPy();
- std::vector PolyfitPz = orbitmodel.getPolyfitPz();
- std::vector PolyfitVx = orbitmodel.getPolyfitVx();
- std::vector PolyfitVy = orbitmodel.getPolyfitVy();
- std::vector PolyfitVz = orbitmodel.getPolyfitVz();
+ std::vector PolyfitPx = orbitmodel.getPolyfitPx();
+ std::vector PolyfitPy = orbitmodel.getPolyfitPy();
+ std::vector PolyfitPz = orbitmodel.getPolyfitPz();
+ std::vector PolyfitVx = orbitmodel.getPolyfitVx();
+ std::vector PolyfitVy = orbitmodel.getPolyfitVy();
+ std::vector PolyfitVz = orbitmodel.getPolyfitVz();
// ģ
@@ -36,11 +63,248 @@ namespace LookTableSimualtionMainProcessSpace {
std::vector DopplerCentroidCoefficients = SARSetting->getDopplerCentroidCoefficients();
std::vector DopplerRateValuesCoefficient = SARSetting->getDopplerRateValuesCoefficients();
- // ݴ
+ //
+ double startTime = SARSetting->getSARImageStartTime();
+ double endTime = SARSetting->getSARImageStartTime();
+
+ double PRF = SARSetting->getPRF();
+ double Fs = SARSetting->getFs();
+ double nearRange = SARSetting->getNearRange();
+ double farRange = SARSetting->getFarRange();
+ double lamda = SARSetting->getCenterLamda();
+ //
+ QString outLookTablePath = "";
+ QString outIncPath = "";
+ gdalImage demimg(DEMPath);
+
+
+
+
+ if (looktableflag|| checkBoxIncAngle) {
+ outLookTablePath = JoinPath(outDirPath, sateName+"__looktable.bin");
+
+
+ LookTableSimulationDopplerProcess(
+ DEMPath, outLookTablePath,
+ OribtStartTime,
+ PolyfitPx, PolyfitPy, PolyfitPz,
+ PolyfitVx, PolyfitVy, PolyfitVz,
+ dopplerRefrenceTime,
+ DopplerCentroidCoefficients,
+ startTime,
+ endTime,
+ nearRange,
+ farRange,
+ PRF,
+ Fs,
+ lamda,
+ gpuflag,
+ looktableflag,
+ checkBoxIncAngle
+ );
+ }
+ if (checkBoxIncAngle) {
+ outIncPath = JoinPath(outDirPath, sateName + "__incAngle.bin");
+ }
}
+ void LookTableSimulationDopplerProcess(
+ QString DEMPath,
+ QString outLookTablePath,
+
+ long double OribtStartTime,
+ std::vector PolyfitPx,
+ std::vector PolyfitPy,
+ std::vector PolyfitPz,
+ std::vector PolyfitVx,
+ std::vector PolyfitVy,
+ std::vector PolyfitVz,
+ double dopplerRefrenceTime,
+ std::vector
+ DopplerCentroidCoefficients,
+ double starttime,
+ double endtime,
+ double nearRange,
+ double farRange,
+ double PRF,
+ double Fs,
+ double lamda,
+ bool gpuflag,
+ bool looktableflag,
+ bool incflag
+ )
+ {
+ qDebug() << "generate look table ";
+ qDebug() << "DEMPath\t" << DEMPath;
+ qDebug() << "outLookTablePath\t" << outLookTablePath;
+
+
+ gdalImage demimg(DEMPath);
+ gdalImage outLookTable = CreategdalImage( // ұ
+ outLookTablePath,
+ demimg.height, demimg.width, 2,
+ demimg.gt,
+ demimg.projection,
+ true,
+ true,
+ true
+ );
+
+
+ starttime = starttime - OribtStartTime; // ʱ
+ endtime = endtime - OribtStartTime;
+
+ // ģ
+ double Xp0=0,Yp0=0,Zp0=0,Xv0=0,Yv0=0,Zv0=0;
+ double Xp1=0,Yp1=0,Zp1=0,Xv1=0,Yv1=0,Zv1=0;
+ double Xp2=0,Yp2=0,Zp2=0,Xv2=0,Yv2=0,Zv2=0;
+ double Xp3=0,Yp3=0,Zp3=0,Xv3=0,Yv3=0,Zv3=0;
+ double Xp4=0,Yp4=0,Zp4=0,Xv4=0,Yv4=0,Zv4=0;
+ double Xp5=0,Yp5=0,Zp5=0,Xv5=0,Yv5=0,Zv5=0;
+ int degree = PolyfitPx.size();
+ switch (degree){
+ case(6):
+ Xp5 = PolyfitPx[5];
+ Yp5 = PolyfitPy[5];
+ Zp5 = PolyfitPz[5];
+ Xv5 = PolyfitVx[5];
+ Yv5 = PolyfitVy[5];
+ Zv5 = PolyfitVz[5];
+ case(5):
+ Xp4 = PolyfitPx[4];
+ Yp4 = PolyfitPy[4];
+ Zp4 = PolyfitPz[4];
+ Xv4 = PolyfitVx[4];
+ Yv4 = PolyfitVy[4];
+ Zv4 = PolyfitVz[4];
+ case(4):
+ Xp3 = PolyfitPx[3];
+ Yp3 = PolyfitPy[3];
+ Zp3 = PolyfitPz[3];
+ Xv3 = PolyfitVx[3];
+ Yv3 = PolyfitVy[3];
+ Zv3 = PolyfitVz[3];
+ case(3):
+ Xp2 = PolyfitPx[2];
+ Yp2 = PolyfitPy[2];
+ Zp2 = PolyfitPz[2];
+ Xv2 = PolyfitVx[2];
+ Yv2 = PolyfitVy[2];
+ Zv2 = PolyfitVz[2];
+ case(2):
+ Xp1 = PolyfitPx[1];
+ Yp1 = PolyfitPy[1];
+ Zp1 = PolyfitPz[1];
+ Xv1 = PolyfitVx[1];
+ Yv1 = PolyfitVy[1];
+ Zv1 = PolyfitVz[1];
+ case(1):
+ Xp0 = PolyfitPx[0];
+ Yp0 = PolyfitPy[0];
+ Zp0 = PolyfitPz[0];
+ Xv0 = PolyfitVx[0];
+ Yv0 = PolyfitVy[0];
+ Zv0 = PolyfitVz[0];
+ default:
+ break;
+ }
+
+ // ղ
+ double r0 = 0, r1 = 0, r2 = 0, r3 = 0, r4 = 0;
+ degree = DopplerCentroidCoefficients.size();
+ switch (degree)
+ {
+ case(5):
+ r4 = DopplerCentroidCoefficients[4];
+ case(4):
+ r3 = DopplerCentroidCoefficients[3];
+ case(3):
+ r2 = DopplerCentroidCoefficients[2];
+ case(2):
+ r1 = DopplerCentroidCoefficients[1];
+ case(1):
+ r0 = DopplerCentroidCoefficients[0];
+ default:
+ break;
+ }
+
+ // ֿ
+ long GPUMemoryline = floor((Memory1MB * 2.0 / 8.0/3.0 / demimg.width*1000));//2GB
+ GPUMemoryline = GPUMemoryline < 1 ? 1 : GPUMemoryline;
+
+ // ڴԤ
+
+ //
+ std::shared_ptr host_Rid((float*)mallocCUDAHost(sizeof(float) * GPUMemoryline * demimg.width), FreeCUDAHost);
+ std::shared_ptr host_Cid((float*)mallocCUDAHost(sizeof(float) * GPUMemoryline * demimg.width), FreeCUDAHost);
+
+ std::shared_ptr device_Rid((float*)mallocCUDADevice(sizeof(float) * GPUMemoryline * demimg.width), FreeCUDADevice);
+ std::shared_ptr device_Cid((float*)mallocCUDADevice(sizeof(float) * GPUMemoryline * demimg.width), FreeCUDADevice);
+
+ //
+ std::shared_ptr host_demX((double*)mallocCUDAHost(sizeof(double) * GPUMemoryline * demimg.width), FreeCUDAHost);
+ std::shared_ptr host_demY((double*)mallocCUDAHost(sizeof(double) * GPUMemoryline * demimg.width), FreeCUDAHost);
+ std::shared_ptr host_demZ((double*)mallocCUDAHost(sizeof(double) * GPUMemoryline * demimg.width), FreeCUDAHost);
+
+ std::shared_ptr device_demX((double*)mallocCUDADevice(sizeof(double) * GPUMemoryline * demimg.width), FreeCUDADevice);
+ std::shared_ptr device_demY((double*)mallocCUDADevice(sizeof(double) * GPUMemoryline * demimg.width), FreeCUDADevice);
+ std::shared_ptr device_demZ((double*)mallocCUDADevice(sizeof(double) * GPUMemoryline * demimg.width), FreeCUDADevice);
+
+
+ // ƽ
+
+ int rowcount = 0;
+ int colcount = 0;
+ for (long rid = 0; rid < demimg.height; rid = rid + GPUMemoryline) {
+ rowcount = GPUMemoryline;
+ colcount = demimg.width;
+ std::shared_ptr demX = readDataArr(demimg, rid, 0, rowcount, colcount, 1,GDALREADARRCOPYMETHOD::MEMCPYMETHOD);//
+ std::shared_ptr demY = readDataArr(demimg, rid, 0, rowcount, colcount, 2,GDALREADARRCOPYMETHOD::MEMCPYMETHOD);
+ std::shared_ptr demZ = readDataArr(demimg, rid, 0, rowcount, colcount, 3,GDALREADARRCOPYMETHOD::MEMCPYMETHOD);
+
+
+
+ // ݸ
+ memcpy(host_demX.get(), demX.get(), sizeof(double)* rowcount* colcount);
+ memcpy(host_demY.get(), demY.get(), sizeof(double)* rowcount* colcount);
+ memcpy(host_demZ.get(), demZ.get(), sizeof(double)* rowcount* colcount);
+
+ //ڴ->GPU
+ HostToDevice(host_demX.get(), device_demX.get(), sizeof(double)* GPUMemoryline* demimg.width);
+ HostToDevice(host_demY.get(), device_demY.get(), sizeof(double)* GPUMemoryline* demimg.width);
+ HostToDevice(host_demZ.get(), device_demZ.get(), sizeof(double)* GPUMemoryline* demimg.width);
+
+
+
+
+
+ // GPU -> ڴ
+ DeviceToHost(host_Rid.get(), device_Rid.get(), sizeof(float)* GPUMemoryline* demimg.width);
+ DeviceToHost(host_Cid.get(), device_Cid.get(), sizeof(float)* GPUMemoryline* demimg.width);
+
+ // ݴ洢
+ outLookTable.saveImage(host_Rid, rid, 0, rowcount, colcount,1);
+ outLookTable.saveImage(host_Cid, rid, 0, rowcount, colcount,2);
+ }
+
+ qDebug() << "look table computed finished!!!";
+ }
+
+ void LocalIncidenceAngleSimulationCompter(QString DEMPath, QString LookTablePath, QString outIncPath, long double OribtStartTime, std::vector PolyfitPx, std::vector PolyfitPy, std::vector PolyfitPz, std::vector PolyfitVx, std::vector PolyfitVy, std::vector PolyfitVz, double starttime, double endtime, double nearRange, double farRange, double PRF, double Fs)
+ {
+ //gdalImage outInc = CreategdalImageDouble(
+ // outIncPath,
+ // demimg.height, demimg.width, 1,
+ // demimg.gt,
+ // demimg.projection,
+ // true,
+ // true,
+ // true
+ //);
+ }
+
}
\ No newline at end of file
diff --git a/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableComputerClass.h b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableComputerClass.h
index c1d1d2c..febecc6 100644
--- a/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableComputerClass.h
+++ b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableComputerClass.h
@@ -2,7 +2,7 @@
#include
#include
#include
-
+#include
/**
@@ -21,9 +21,66 @@
namespace LookTableSimualtionMainProcessSpace {
- void LookTableSimualtionMainProcess(QString orbitpath, QString SatePath, QString DEMPath, QString outDirPath
- , double gridX, double gridY, bool gpuflag, bool looktableflag, bool checkBoxIncAngle, bool BoxDopplerFlag
+ void LookTableSimualtionMainProcess(
+ QString sateName,
+ QString orbitpath, QString SatePath, QString DEMPath, QString outDirPath
+ , bool gpuflag, bool looktableflag, bool checkBoxIncAngle, bool DopplerFlag
+ );
+
+ void LookTableSimulationDopplerProcess(
+ QString DEMPath,
+ QString outLookTablePath,
+
+ // ʽ
+ long double OribtStartTime, // ģͲοʱ
+ std::vector PolyfitPx , // 50
+ std::vector PolyfitPy , // 50
+ std::vector PolyfitPz , // 50
+ std::vector PolyfitVx , // 50
+ std::vector PolyfitVy , // 50
+ std::vector PolyfitVz , // 50
+
+
+ // ղ
+ double dopplerRefrenceTime,
+ std::vector DopplerCentroidCoefficients,// d0 ~ d5
+
+ //
+ double starttime, // ʼʱ
+ double endtime, // ʱ
+ double nearRange, // б
+ double farRange, // Զб
+ double PRF, // ظƵ
+ double Fs, // Ƶ
+ double lamda,
+ bool gpuflag,
+ bool looktableflag,
+ bool incflag
+ );
+
+ void LocalIncidenceAngleSimulationCompter(
+ QString DEMPath,
+ QString LookTablePath,
+ QString outIncPath,
+ long double OribtStartTime, // ģͲοʱ
+ std::vector PolyfitPx, // 50
+ std::vector PolyfitPy, // 50
+ std::vector PolyfitPz, // 50
+ std::vector PolyfitVx, // 50
+ std::vector PolyfitVy, // 50
+ std::vector PolyfitVz, // 50
+
+
+ double starttime, // ʼʱ
+ double endtime, // ʱ
+ double nearRange, // б
+ double farRange, // Զб
+ double PRF, // ظƵ
+ double Fs // Ƶ
+
);
+
+
}
diff --git a/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableSimulationComputer.cu b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableSimulationComputer.cu
new file mode 100644
index 0000000..092910c
--- /dev/null
+++ b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableSimulationComputer.cu
@@ -0,0 +1,37 @@
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "BaseConstVariable.h"
+
+#include "LookTableSimulationComputer.cuh"
+
+
+extern __device__ __host__ double getNumberDopplerCenterRate(double R, double r0, double r1, double r2, double r3, double r4, double reftime)
+{
+ double t=R / LIGHTSPEED - reftime;
+ double dopplerCenterRate = r0 + r1*t + r2*t*t + r3*t*t*t + r4*t*t*t*t;
+ return dopplerCenterRate;
+}
+
+__device__ __host__ double getDopplerCenterRate(double Rx, double Ry, double Rz, double Vx, double Vy, double Vz, double lamda)
+{
+ return __device__ __host__ double();
+}
+
+__device__ __host__ double getPolyfitNumber(double x, double a0, double a1, double a2, double a3, double a4, double a5)
+{
+ return a0 + a1 * x + a2 * x * x + a3 * x * x * x + a4 * x * x * x * x + a5 * x * x * x * x * x;
+}
+
+
+
+
+
+
diff --git a/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableSimulationComputer.cuh b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableSimulationComputer.cuh
new file mode 100644
index 0000000..2d9740f
--- /dev/null
+++ b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableSimulationComputer.cuh
@@ -0,0 +1,37 @@
+#include "GPUTool.cuh"
+#include
+#include
+#include
+#include "BaseConstVariable.h"
+
+
+
+
+
+extern __device__ __host__ double getNumberDopplerCenterRate(double R, double r0, double r1, double r2, double r3, double r4,double reftime);
+
+extern __device__ __host__ double getDopplerCenterRate(double Rx,double Ry,double Rz,double Vx,double Vy,double Vz,double lamda);
+
+extern __device__ __host__ double getPolyfitNumber(double x, double a0, double a1, double a2, double a3, double a4,double a5);
+
+
+
+
+
+
+
+
+
+
+
+
+//
+extern "C" void RDProcess_doppler(
+
+
+);
+
+
+
+
+
diff --git a/Toolbox/SimulationSARTool/PowerSimulationIncoherent/QSimulationLookTableDialog.cpp b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/QSimulationLookTableDialog.cpp
index 2d90103..86ec396 100644
--- a/Toolbox/SimulationSARTool/PowerSimulationIncoherent/QSimulationLookTableDialog.cpp
+++ b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/QSimulationLookTableDialog.cpp
@@ -90,17 +90,18 @@ void QSimulationLookTableDialog::onaccepted()
QString DEMPath = this->ui->DEMLineEdit->text();
QString outDirPath = this->ui->outDirLineEdit->text();
- double gridX = this->ui->doubleSpinBoxGridX->value();
- double gridY = this->ui->doubleSpinBoxGridY->value();
+ //double gridX = this->ui->doubleSpinBoxGridX->value();
+ //double gridY = this->ui->doubleSpinBoxGridY->value();
bool gpuflag = this->ui->radioButtonGPU->isChecked();
bool looktableflag = this->ui->LookTableCheck->isChecked();
bool checkBoxIncAngle = this->ui->checkBoxIncAngle->isChecked();
bool BoxDopplerFlag = this->ui->checkBoxDoppler->isChecked();
-
+ QString simulationName = this->ui->lineEditLookName->text();
LookTableSimualtionMainProcessSpace::LookTableSimualtionMainProcess(
- orbitpath, SatePath, DEMPath, outDirPath
- , gridX, gridY, gpuflag, looktableflag, checkBoxIncAngle, BoxDopplerFlag
+ simulationName,
+ orbitpath, SatePath, DEMPath, outDirPath,
+ gpuflag, looktableflag, checkBoxIncAngle, BoxDopplerFlag
);
diff --git a/Toolbox/SimulationSARTool/PowerSimulationIncoherent/QSimulationLookTableDialog.ui b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/QSimulationLookTableDialog.ui
index f7c4752..52efdb6 100644
--- a/Toolbox/SimulationSARTool/PowerSimulationIncoherent/QSimulationLookTableDialog.ui
+++ b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/QSimulationLookTableDialog.ui
@@ -23,7 +23,7 @@
- DEM文件
+ DEM文件(XYZ)
@@ -37,7 +37,7 @@
- -
+
-
@@ -89,7 +89,7 @@
- -
+
-
Qt::Vertical
@@ -102,6 +102,16 @@
+ -
+
+
+ 采用多普勒参数
+
+
+ true
+
+
+
-
@@ -141,7 +151,7 @@
- -
+
-
@@ -154,7 +164,7 @@
- -
+
-
计算资源
@@ -171,6 +181,9 @@
GPU
+
+ true
+
-
@@ -189,7 +202,7 @@
- -
+
-
Qt::Vertical
@@ -215,7 +228,7 @@
- -
+
-
产品输出类型
@@ -232,6 +245,9 @@
查找表
+
+ true
+
-
@@ -245,19 +261,22 @@
局地入射角
+
+ true
+
- -
+
-
QDialogButtonBox::Cancel|QDialogButtonBox::Ok
- -
+
-
@@ -270,13 +289,29 @@
- -
-
-
- 采用多普勒参数
+
-
+
+
+
+ 0
+ 30
+
-
- true
+
+ 查找表名
+
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+
diff --git a/Toolbox/SimulationSARTool/SimulationSARTool.vcxproj b/Toolbox/SimulationSARTool/SimulationSARTool.vcxproj
index 4fdea5b..c4b511d 100644
--- a/Toolbox/SimulationSARTool/SimulationSARTool.vcxproj
+++ b/Toolbox/SimulationSARTool/SimulationSARTool.vcxproj
@@ -127,6 +127,7 @@
+
@@ -145,6 +146,7 @@
+
Document
diff --git a/Toolbox/SimulationSARTool/SimulationSARTool.vcxproj.filters b/Toolbox/SimulationSARTool/SimulationSARTool.vcxproj.filters
index d5b2990..85bcbf8 100644
--- a/Toolbox/SimulationSARTool/SimulationSARTool.vcxproj.filters
+++ b/Toolbox/SimulationSARTool/SimulationSARTool.vcxproj.filters
@@ -163,5 +163,11 @@
SimulationSAR
+
+ PowerSimulationIncoherent
+
+
+ PowerSimulationIncoherent
+
\ No newline at end of file