添加后处理vtu、pvtu格式支持,优化cgns格式的读取以及其它问题优化

master
禅元天道 2023-06-07 10:15:08 +08:00
parent 2b3fb38cea
commit d148d592f3
197 changed files with 2361 additions and 1717 deletions

View File

@ -149,7 +149,7 @@ PointerAlignment: Left
# 允许重新排版注释 # 允许重新排版注释
ReflowComments: true ReflowComments: true
# 允许排序#include # 允许排序#include
SortIncludes: CaseInsensitive SortIncludes: Never
# 在C风格类型转换后添加空格 # 在C风格类型转换后添加空格
SpaceAfterCStyleCast: false SpaceAfterCStyleCast: false
# 在赋值运算符之前添加空格 # 在赋值运算符之前添加空格

1
.gitignore vendored
View File

@ -1,6 +1,5 @@
.vscode .vscode
.vs .vs
.idea
/build /build
/install /install
/extlib /extlib

View File

@ -66,6 +66,7 @@ option(FASTCAE_ENABLE_OPENMP "使用OpenMP" OFF)
option(FASTCAE_ENABLE_MPI "使用MPI" OFF) option(FASTCAE_ENABLE_MPI "使用MPI" OFF)
option(FASTCAE_DOXYGEN_DOC "生成Doxygen文档" OFF) option(FASTCAE_DOXYGEN_DOC "生成Doxygen文档" OFF)
option(FASTCAE_INSTALLATION_PACKAGE "生成${PROJECT_NAME}安装包" ON) option(FASTCAE_INSTALLATION_PACKAGE "生成${PROJECT_NAME}安装包" ON)
option(FASTCAE_DEBUG_INFO "输出调试信息" ON)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# #
@ -109,6 +110,13 @@ if(FASTCAE_ENABLE_MPI)
endif() endif()
endif() endif()
#-----------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------
if(FASTCAE_DEBUG_INFO)
add_definitions(-DOUTPUT_DEBUG_INFO)
endif()
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Qt,Qt # Qt,Qt
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------

View File

@ -10,6 +10,7 @@ Version2.5.x
- 加入OpenGL版本检测函数当环境OPenGL版本低于3.3时,给出错误提示。 - 加入OpenGL版本检测函数当环境OPenGL版本低于3.3时,给出错误提示。
- 新增自动打包功能Windows需要NSIS 3.03+、Linux需要dpkg-deb或者rpmbuild(需要python3 - 新增自动打包功能Windows需要NSIS 3.03+、Linux需要dpkg-deb或者rpmbuild(需要python3
- 新增文档自动生成功能需要安装Doxygen和Graphviz。 - 新增文档自动生成功能需要安装Doxygen和Graphviz。
- 增加vtu、pvtu格式的后处理文件支持
**功能优化** **功能优化**
- 代码全部采用cmake进行管理可任意选择vscode、Visual Studio、Clion、Qtcreator等支持cmake系统的IDE。 - 代码全部采用cmake进行管理可任意选择vscode、Visual Studio、Clion、Qtcreator等支持cmake系统的IDE。
@ -17,6 +18,9 @@ Version2.5.x
- 删除Qt浏览器组建及相关依赖Qt安装不再需要QWebEngine组件 - 删除Qt浏览器组建及相关依赖Qt安装不再需要QWebEngine组件
- 优化Python调用不再依赖系统配置简化操作。 - 优化Python调用不再依赖系统配置简化操作。
- 从依赖库中移除未使用的VTK、OpenCASCADE模块。 - 从依赖库中移除未使用的VTK、OpenCASCADE模块。
- 优化CGNS后处理文件解析添加MIXED类型单元区域的解析。
- 优化后处理属性面板场变量数据类型的显示方式。
- 优化日志输出方式,便于错误定位
**功能修复** **功能修复**
- 修复linux环境卸载插件时崩溃的问题 - 修复linux环境卸载插件时崩溃的问题

View File

@ -9,6 +9,39 @@
- src FastCAE源码 - src FastCAE源码
- test 包含单元测试代码(待整理) - test 包含单元测试代码(待整理)
## 构建编译
### FastCAE相关的cmake构建选项说明
- `FASTCAE_AUTO_DOWNLOAD`如果源码目录不存在extlib目录时是否会自动从gitee克隆依赖包。
- `FASTCAE_DOXYGEN_DOC`是否需要构建目标Doxygen需要本地安装Doxygen软件
- `FASTCAE_ENABLE_DEV`:是否在构建完成时自动拷贝依赖文件到调试目录。(开启该选项会在每次编译完拷贝第三方依赖库文件到构建目录,会增加构建时间)
- `FASTCAE_ENABLE_MPI`是否开启MPI支持目前无效
- `FASTCAE_ENABLE_OPENMP`是否开启OpenMP。
- `FASTCAE_ENABLE_TEST`:是否构建单元测试模块(目前无效)。
- `FASTCAE_INSTALLATION_PACKAGE`是否构建安装包制作PACKAGE。
### cmake预定义目标说明
- ALL_BUILD生成所有项目。
- INSTALL安装FastCAE到CMAKE_INSTALL_PREFIX定义的目录。
- PACKAGE或者package: 在Visual Studio中该目标为大写在其它构建系统中该目标为小写用于将FastCAE打包成安装包exe、deb、rpm
- DOXYGEN: 生成FastCAE的Doxygen格式文档html
### 编译视频教程
#### Windows
- <a href="https://www.bilibili.com/video/BV1U24y1R73n/" target="_blank">cmake 3.24.1 + Visual Studio Community 2017</a>
- <a href="https://www.bilibili.com/video/BV1FX4y1y7T4/" target="_blank">QtCreator编译</a>
#### Linux
- <a href="https://www.bilibili.com/video/BV1iW4y1Y79p/" target="_blank">cmake + GNU GCC + make</a>
- <a href="https://www.bilibili.com/video/BV1xd4y1q7Cm/" target="_blank">借助vscode构建、编译、安装、打包</a>
### 编译说明
- windows环境下使用vscode时编译工具链只能使用Visual Studio目前不支持MinGW工具
### extlib目录结构 ### extlib目录结构

111
src/Common/DebugLogger.cpp Normal file
View File

@ -0,0 +1,111 @@
#include "DebugLogger.h"
#include <cstdio>
#include <cstring>
#include <ctime>
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
#define filename(x) strrchr(x, '\\') ? strrchr(x, '\\') + 1 : x
#else
#define filename(x) strrchr(x, '/') ? strrchr(x, '/') + 1 : x
#endif
namespace Common {
void DebugLogger::info(const char* file, int line, const char* format, ...)
{
va_list args;
va_start(args, format);
output(file, line, format, 0, args);
va_end(args);
}
void DebugLogger::warning(const char* file, int line, const char* format, ...)
{
va_list args;
va_start(args, format);
output(file, line, format, 1, args);
va_end(args);
}
void DebugLogger::error(const char* file, int line, const char* format, ...)
{
va_list args;
va_start(args, format);
output(file, line, format, 2, args);
va_end(args);
}
char* DebugLogger::currentTime()
{
time_t rawtime;
struct tm* timeS;
char* buffer = new char[80];
time(&rawtime);
timeS = localtime(&rawtime);
sprintf(buffer, "%d-%s%d-%s%d %s%d:%s%d:%s%d", timeS->tm_year + 1900,
timeS->tm_mon < 10 ? "0" : "", timeS->tm_mon, timeS->tm_mday < 10 ? "0" : "",
timeS->tm_mday, timeS->tm_hour < 10 ? "0" : "", timeS->tm_hour,
timeS->tm_min < 10 ? "0" : "", timeS->tm_min, timeS->tm_sec < 10 ? "0" : "",
timeS->tm_sec);
return buffer;
}
/**
* ESC[{attr1};{attr2};;{attrn}m
*
* 0
* 1便
* 2
* 22
* 4线
* 5
* 25
* 7
* 27
* 8
*
*
* 30
* 31
* 32绿
* 33
* 34
* 35
* 36
* 37
*
* 40
* 41
* 42绿
* 43
* 44
* 45
* 46
* 47
*/
void DebugLogger::output(const char* file, int line, const char* format, int level,
va_list args)
{
char type[15] = "";
switch(level) {
case 1:
printf("\033[33m"); // 红色
strcpy(type, "WARNING");
break;
case 2:
printf("\033[31m"); // 黄色
strcpy(type, "ERROR");
break;
default:
strcpy(type, "INFO");
break;
}
printf("[%s][%s:%d][%s]: ", currentTime(), filename(file), line, type);
vprintf(format, args);
printf("\033[0m");
}
} // namespace Common

58
src/Common/DebugLogger.h Normal file
View File

@ -0,0 +1,58 @@
/**
* @file DebugLogger.h
* @brief
* @author FastCAE(fastcae@diso.cn)
* @version 2.5.0
* @date 2023-05-11 16:12
* @copyright Copyright (c) Since 2020 All rights reserved.
*
* ============================================================================
* Program: FastCAE
*
* Copyright (c) Since 2020 All rights reserved.
* See License or http://www.fastcae.com/ for details.
*
* BSD 3-Clause License
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED.
* ==================================================================================
*/
#ifndef DEBUGLOGGER_H
#define DEBUGLOGGER_H
#include "CommonAPI.h"
#include <cstdarg>
namespace Common {
class COMMONAPI DebugLogger {
public:
DebugLogger() = delete;
~DebugLogger() = delete;
public:
static void info(const char* file, int line, const char* format, ...);
static void warning(const char* file, int line, const char* format, ...);
static void error(const char* file, int line, const char* format, ...);
protected:
static char* currentTime();
static void output(const char* file, int line, const char* format, int level, va_list args);
};
} // namespace Common
// 用宏OUTPUT_DEBUG_INFO控制调试信息是否输出的开关
#ifdef OUTPUT_DEBUG_INFO
#define DebugInfo(FORMAT, ...) Common::DebugLogger::info(__FILE__, __LINE__, FORMAT, __VA_ARGS__)
#define DebugWarn(FORMAT, ...) Common::DebugLogger::warning(__FILE__, __LINE__, FORMAT, __VA_ARGS__)
#define DebugError(FORMAT, ...) Common::DebugLogger::error(__FILE__, __LINE__, FORMAT, __VA_ARGS__)
#else
#define DebugInfo(FORMAT, ...)
#define DebugWarn(FORMAT, ...)
#define DebugError(FORMAT, ...)
#endif // OUTPUT_DEBUG_INFO
#endif

View File

@ -31,7 +31,7 @@ set_property(DIRECTORY ${CMAKE_SOURCE_DIR}
VS_STARTUP_PROJECT FastCAE VS_STARTUP_PROJECT FastCAE
) )
list(APPEND _depend_library PythonModule SARibbonBar Settings DataProperty MeshData Material Geometry ConfigOptions SelfDefObject ModelData ModuleBase PluginManager GmshModule PostInterface PostWidgets ProjectTree GeometryCommand GeometryWidgets IO SolverControl MainWidgets UserGuidence MainWindow) list(APPEND _depend_library Common PythonModule SARibbonBar Settings DataProperty MeshData Material Geometry ConfigOptions SelfDefObject ModelData ModuleBase PluginManager GmshModule PostInterface PostWidgets ProjectTree GeometryCommand GeometryWidgets IO SolverControl MainWidgets UserGuidence MainWindow)
if(_WIN_) if(_WIN_)
#list(APPEND _depend_library XGenerateReport License) #list(APPEND _depend_library XGenerateReport License)
endif() endif()

View File

@ -20,19 +20,21 @@
* DISCLAIMED. * DISCLAIMED.
* ================================================================================== * ==================================================================================
*/ */
#include "CommandLine.h"
#include "FastCAEVersionMacros.h"
#include "MainWindow/MainWindow.h"
#include "XBeautyUI.h"
#include <QApplication> #include <QApplication>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QProcess>
#include <QOpenGLContext>
#include <QMessageBox> #include <QMessageBox>
#include "MainWindow/MainWindow.h" #include <QOpenGLContext>
#include "XBeautyUI.h" #include <QProcess>
#include "CommandLine.h"
#include "FastCAEVersionMacros.h"
// #include "ConfigOptions/ConfigDataReader.h" // #include "ConfigOptions/ConfigDataReader.h"
// #include "ConfigOptions/ConfigOptions.h" // #include "ConfigOptions/ConfigOptions.h"
// #include "ConfigOptions/GlobalConfig.h" // #include "ConfigOptions/GlobalConfig.h"
#include "Common/DebugLogger.h"
#include "Settings/BusAPI.h" #include "Settings/BusAPI.h"
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
@ -46,24 +48,25 @@
bool testOpenGL() bool testOpenGL()
{ {
bool supportOpenGLCore = false; bool supportOpenGLCore = false;
QString currentOpenGLVersion = ""; QString currentOpenGLVersion = "";
QOpenGLContext ctx; QOpenGLContext ctx;
if (ctx.create()) if(ctx.create()) {
{
auto version = ctx.format(); auto version = ctx.format();
if (version.majorVersion() > 3 || (version.majorVersion() == 3 && version.minorVersion() >= 3)) if(version.majorVersion() > 3
{ || (version.majorVersion() == 3 && version.minorVersion() >= 3)) {
supportOpenGLCore = true; supportOpenGLCore = true;
} } else {
else currentOpenGLVersion =
{ QString("%1.%2").arg(version.majorVersion()).arg(version.minorVersion());
currentOpenGLVersion = QString("%1.%2").arg(version.majorVersion()).arg(version.minorVersion());
} }
} }
if (!supportOpenGLCore) if(!supportOpenGLCore) {
{ QMessageBox::critical(nullptr, "OpenGL Error",
QMessageBox::critical(nullptr, "OpenGL Error", "Startup failed: FastCAE requires OpenGL version greater than or equal to 3.3, but the current version is " + currentOpenGLVersion, QMessageBox::Ok); "Startup failed: FastCAE requires OpenGL version greater than or "
"equal to 3.3, but the current version is "
+ currentOpenGLVersion,
QMessageBox::Ok);
} }
return supportOpenGLCore; return supportOpenGLCore;
} }
@ -74,29 +77,28 @@ bool testOpenGL()
* @return int * @return int
* @since 2.5.0 * @since 2.5.0
*/ */
int main(int argc, char *argv[]) int main(int argc, char* argv[])
{ {
// 添加Qt的对高分屏的支持 // 添加Qt的对高分屏的支持
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) #if(QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif #endif
CommandPara para(argc, argv); CommandPara para(argc, argv);
if (para.isHelp()) if(para.isHelp())
return 1; return 1;
QApplication app(argc, argv); QApplication app(argc, argv);
if (!testOpenGL()) if(!testOpenGL()) {
{
return 1; return 1;
} }
// QString path = qApp->applicationDirPath(); // QString path = qApp->applicationDirPath();
// ConfigOption::ConfigDataReader reader(path + "/../ConfigFiles/", ConfigOption::ConfigOption::getInstance()); // ConfigOption::ConfigDataReader reader(path + "/../ConfigFiles/",
// reader.read(); // ConfigOption::ConfigOption::getInstance()); reader.read(); QString qUseRibbon =
// QString qUseRibbon = ConfigOption::ConfigOption::getInstance()->getGlobalConfig()->getUseRibbon(); // ConfigOption::ConfigOption::getInstance()->getGlobalConfig()->getUseRibbon(); bool
// bool bUseRibbon = qUseRibbon == "yes" ? true : false; // bUseRibbon = qUseRibbon == "yes" ? true : false;
bool isRibbon = Setting::BusAPI::instance()->isUseRibbon(); bool isRibbon = Setting::BusAPI::instance()->isUseRibbon();
GUI::MainWindow mainwindow(isRibbon); GUI::MainWindow mainwindow(isRibbon);
@ -106,9 +108,8 @@ int main(int argc, char *argv[])
QString qssFileName = XBeautyUI::instance()->qssFilePath(); QString qssFileName = XBeautyUI::instance()->qssFilePath();
//**************加载qss****************** //**************加载qss******************
QFile qssFile(qssFileName); QFile qssFile(qssFileName);
if (qssFile.exists()) if(qssFile.exists()) {
{
qssFile.open(QIODevice::ReadOnly); qssFile.open(QIODevice::ReadOnly);
QString style = qssFile.readAll(); QString style = qssFile.readAll();
qApp->setStyleSheet(style); qApp->setStyleSheet(style);
@ -127,7 +128,7 @@ int main(int argc, char *argv[])
#endif #endif
//***************************************** //*****************************************
if (para.exec(&mainwindow)) if(para.exec(&mainwindow))
emit mainwindow.sendInfoToStatesBar(QString("Version: %1").arg(FASTCAE_VERSION)); emit mainwindow.sendInfoToStatesBar(QString("Version: %1").arg(FASTCAE_VERSION));
else else
return 1; return 1;
@ -147,8 +148,7 @@ int main(int argc, char *argv[])
#endif #endif
#endif #endif
if (e == -1000) if(e == -1000) {
{
QProcess::startDetached(qApp->applicationFilePath(), QStringList()); QProcess::startDetached(qApp->applicationFilePath(), QStringList());
return 0; return 0;
} }

View File

@ -38,7 +38,7 @@ add_library(MainWindow
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
target_compile_definitions(MainWindow PRIVATE "MAINWINDOW_API") target_compile_definitions(MainWindow PRIVATE "MAINWINDOW_API")
list(APPEND _depend_library PythonModule SARibbonBar Settings DataProperty MeshData Material Geometry ConfigOptions SelfDefObject ModelData ModuleBase PluginManager GmshModule PostInterface PostRenderData PostWidgets ProjectTree GeometryCommand GeometryWidgets IO SolverControl MainWidgets UserGuidence Common) list(APPEND _depend_library Common PythonModule SARibbonBar Settings DataProperty MeshData Material Geometry ConfigOptions SelfDefObject ModelData ModuleBase PluginManager GmshModule PostInterface PostRenderData PostWidgets ProjectTree GeometryCommand GeometryWidgets IO SolverControl MainWidgets UserGuidence Common)
if(_WIN_) if(_WIN_)
list(APPEND _depend_library XGenerateReport) list(APPEND _depend_library XGenerateReport)
endif() endif()

View File

@ -328,7 +328,7 @@ namespace GUI {
connect(this, SIGNAL(updatePreMeshActorSig()), this, SLOT(updatePreMeshActor())); connect(this, SIGNAL(updatePreMeshActorSig()), this, SLOT(updatePreMeshActor()));
connect(this, SIGNAL(updatePreGeometryActorSig()), this, SLOT(updatePreGeometryActor())); connect(this, SIGNAL(updatePreGeometryActorSig()), this, SLOT(updatePreGeometryActor()));
connect(this, SIGNAL(openPlot()), _signalHandler, SLOT(openPlotFile())); connect(this, SIGNAL(openPlot()), _signalHandler, SLOT(openPlotFile()));
} }
void MainWindow::registerMoudel() void MainWindow::registerMoudel()

View File

@ -289,7 +289,7 @@ namespace GUI {
/** /**
* @brief * @brief
*/ */
void updatePostTreeSig(); void updatePostTreeSig();
// //
// 更新二维曲线模型树 // 更新二维曲线模型树
@ -389,7 +389,7 @@ namespace GUI {
// 网格过滤 // 网格过滤
void on_FilterMesh(); void on_FilterMesh();
// 创建VTK空间变换窗口 // 创建VTK空间变换窗口
void on_VTKTranslation(); void on_VTKTranslation();
private: private:
/*初始化Menu*/ /*初始化Menu*/

View File

@ -1248,7 +1248,7 @@ namespace GUI {
FileDirectoryDialog dlg; FileDirectoryDialog dlg;
QStringList filterTypes = { "VTK(*.vtk)", "CGNS(*.cgns)", "Plot3D(*.x)", QStringList filterTypes = { "VTK(*.vtk)", "CGNS(*.cgns)", "Plot3D(*.x)",
"Tecplot(*.szplt)" }; "Tecplot(*.szplt)","VTU(*.vtu)","PVTU(*.pvtu)" };
dlg.iniFileFilterType(filterTypes); dlg.iniFileFilterType(filterTypes);
if(dlg.exec() != QDialog::Accepted) if(dlg.exec() != QDialog::Accepted)
return; return;

View File

@ -5,7 +5,7 @@
#include <QDebug> #include <QDebug>
#include <QStringList> #include <QStringList>
#include <QTranslator> #include <QTranslator>
#include "Common/DebugLogger.h"
namespace GUI { namespace GUI {
const static QStringList Lang_List = { const static QStringList Lang_List = {
":/translations/MainWindow_zh_CN", ":/translations/MainWidgets_zh_CN", ":/translations/MainWindow_zh_CN", ":/translations/MainWidgets_zh_CN",
@ -34,8 +34,11 @@ namespace GUI {
_app->removeTranslator(tranlator); _app->removeTranslator(tranlator);
const QString lang = Lang_List.at(i); const QString lang = Lang_List.at(i);
bool ok = tranlator->load(lang); bool ok = tranlator->load(lang);
qDebug() << lang; if(ok) {
assert(ok); DebugInfo("Success to load lang file: %s\n", lang.toStdString().c_str());
} else {
DebugError("Failed to load lang file: %s\n", lang.toStdString().c_str());
}
_app->installTranslator(tranlator); _app->installTranslator(tranlator);
} }
} }

View File

@ -1,359 +1,375 @@
#include "CGNSReaderAlgorithm.h" #include "CGNSReaderAlgorithm.h"
//#include <vtkCGNSReader.h> // #include <vtkCGNSReader.h>
#include <vtkSmartPointer.h>
#include <vtkAppendFilter.h> #include <vtkAppendFilter.h>
#include <vtkMultiBlockDataSet.h> #include <vtkMultiBlockDataSet.h>
//#include <vtkDataSetMapper.h> #include <vtkSmartPointer.h>
#include <vtkDataSet.h> // #include <vtkDataSetMapper.h>
#include <vtkUnstructuredGrid.h>
#include <vtkPointData.h>
#include <vtkCellData.h> #include <vtkCellData.h>
#include <vtkDataArray.h> #include <vtkDataArray.h>
#include <vtkDataSet.h>
#include <vtkDemandDrivenPipeline.h>
#include <vtkDoubleArray.h> #include <vtkDoubleArray.h>
#include <vtkFieldData.h> #include <vtkFieldData.h>
#include <vtkInformation.h> #include <vtkInformation.h>
#include <vtkDemandDrivenPipeline.h> #include <vtkPointData.h>
#include <vtkStreamingDemandDrivenPipeline.h> #include <vtkStreamingDemandDrivenPipeline.h>
//#include <vtkCGNSFileSeriesReader.h> #include <vtkUnstructuredGrid.h>
#include <vtkInformation.h> // #include <vtkCGNSFileSeriesReader.h>
#include "FCGNSReader.h" #include "FCGNSReader.h"
#include <vtkInformationStringKey.h>
#include <cgns_io.h> #include <cgns_io.h>
#include <cgnslib.h> #include <cgnslib.h>
#include <QDebug> #include <QDebug>
#include <vtkInformation.h>
#include <vtkInformationStringKey.h>
#define MAXBLOCKNUM 2000 #define MAXBLOCKNUM 2000
CGNSReaderAlgorithm::CGNSReaderAlgorithm() CGNSReaderAlgorithm::CGNSReaderAlgorithm()
{ {
this->FileName = NULL; this->FileName = NULL;
this->SetNumberOfInputPorts(0); // 设置输入端口的数量
this->SetNumberOfOutputPorts(MAXBLOCKNUM+1); this->SetNumberOfInputPorts(0);
// 设置输出端口的数量
this->SetNumberOfOutputPorts(MAXBLOCKNUM + 1);
for (int i = 0 ;i<MAXBLOCKNUM; ++i) for(int i = 0; i < MAXBLOCKNUM; ++i)
_visibleStates.append(true); _visibleStates.append(true);
} }
CGNSReaderAlgorithm::~CGNSReaderAlgorithm() CGNSReaderAlgorithm::~CGNSReaderAlgorithm()
{ {
this->FileName = NULL; this->FileName = NULL;
} }
int CGNSReaderAlgorithm::ProcessRequest(vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector) /**
* ProcessRequest()
* ProcessRequest()
*/
int CGNSReaderAlgorithm::ProcessRequest(vtkInformation* request, vtkInformationVector** inputVector,
vtkInformationVector* outputVector)
{ {
if (request->Has(vtkDemandDrivenPipeline::REQUEST_INFORMATION())) // vtkDemandDrivenPipeline::REQUEST_INFORMATION()定义请求以确保输出信息是最新的
{ if(request->Has(vtkDemandDrivenPipeline::REQUEST_INFORMATION())) {
return this->RequestInformation(request, inputVector, return this->RequestInformation(request, inputVector, outputVector);
outputVector); }
} // vtkDemandDrivenPipeline::REQUEST_DATA()定义了向上游传播更新范围的请求。
if (request->Has( if(request->Has(vtkStreamingDemandDrivenPipeline::REQUEST_UPDATE_EXTENT())) {
vtkStreamingDemandDrivenPipeline::REQUEST_UPDATE_EXTENT())) return this->RequestUpdateExtent(request, inputVector, outputVector);
{ }
return this->RequestUpdateExtent(request, inputVector, // vtkDemandDrivenPipeline::REQUEST_DATA()定义请求以确保输出数据是最新的
outputVector); if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA())) {
} return this->RequestData(request, inputVector, outputVector);
if (request->Has(vtkDemandDrivenPipeline::REQUEST_DATA())) }
{ return this->Superclass::ProcessRequest(request, inputVector, outputVector);
return this->RequestData(request, inputVector, outputVector);
}
return this->Superclass::ProcessRequest(request, inputVector,
outputVector);
} }
/**
* @brief
int CGNSReaderAlgorithm::RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector) * @param[in]
* @param[in] vtkInformationVector**
* vtkInformationVector
* @param[in]
* outputVectorvtkInformationVector
* @note
* vtkDataObjectvtkDataObobject::DATA_OBJECT()
* @since 2.5.0
*/
int CGNSReaderAlgorithm::RequestData(vtkInformation*, vtkInformationVector**,
vtkInformationVector* outputVector)
{ {
if (!this->FileName) if(!this->FileName) {
{ vtkErrorMacro("A FileName must be specified.");
vtkErrorMacro("A FileName must be specified."); return 0;
return 0; }
}
_blockList.clear();
_blockNames.clear();
_blockList.clear(); vtkMultiBlockDataSet* mBlock = nullptr;
_blockNames.clear(); // bool useVTK = useVTKCGNSReader();
vtkMultiBlockDataSet* mBlock = nullptr; vtkSmartPointer<FCGNSReader> reader = vtkSmartPointer<FCGNSReader>::New();
//bool useVTK = useVTKCGNSReader(); reader->SetFileName(FileName);
reader->Update();
mBlock = reader->GetOutput();
// vtkSmartPointer<vtkCGNSReader> vtkReader = vtkSmartPointer<vtkCGNSReader>::New();
// if (useVTK)
// {
// vtkReader->SetFileName(FileName);
// vtkReader->Update();
// mBlock = vtkReader->GetOutput();
// }
// else
// {
// reader->SetFileName(FileName);
// reader->Update();
// mBlock = reader->GetOutput();
// }
vtkSmartPointer<vtkAppendFilter> appFilter = vtkSmartPointer<vtkAppendFilter>::New();
appFilter->MergePointsOn();
vtkSmartPointer<FCGNSReader> reader = vtkSmartPointer<FCGNSReader>::New(); if(mBlock == nullptr)
reader->SetFileName(FileName); return 0;
reader->Update(); getBlocks(mBlock);
mBlock = reader->GetOutput();
// vtkSmartPointer<vtkCGNSReader> vtkReader = vtkSmartPointer<vtkCGNSReader>::New();
// if (useVTK)
// {
// vtkReader->SetFileName(FileName);
// vtkReader->Update();
// mBlock = vtkReader->GetOutput();
// }
// else
// {
// reader->SetFileName(FileName);
// reader->Update();
// mBlock = reader->GetOutput();
// }
vtkSmartPointer<vtkAppendFilter> appFilter = vtkSmartPointer<vtkAppendFilter>::New();
appFilter->MergePointsOn();
if (mBlock == nullptr) return 0; for(int i = 0; i < _blockList.size(); ++i) {
getBlocks(mBlock); if(!_visibleStates[i])
continue;
auto dataset = _blockList.at(i);
for (int i =0;i< _blockList.size(); ++i) fillPointArray(dataset);
{ fillCellArray(dataset);
if(!_visibleStates[i]) continue; appFilter->AddInputData(dataset);
auto dataset = _blockList.at(i); }
fillPointArray(dataset); appFilter->Update();
fillCellArray(dataset);
appFilter->AddInputData(dataset);
}
vtkUnstructuredGrid* output = vtkUnstructuredGrid::GetData(outputVector);
output->CopyStructure(appFilter->GetOutput());
output->GetPointData()->PassData(appFilter->GetOutput()->GetPointData());
output->GetCellData()->PassData(appFilter->GetOutput()->GetCellData());
appFilter->Update(); for(int i = 1; i <= _blockList.size(); i++) {
if(i > MAXBLOCKNUM)
vtkUnstructuredGrid* output = vtkUnstructuredGrid::GetData(outputVector); break;
output->CopyStructure(appFilter->GetOutput()); auto data = _blockList.at(i - 1);
output->GetPointData()->PassData(appFilter->GetOutput()->GetPointData()); vtkUnstructuredGrid* outData = vtkUnstructuredGrid::GetData(outputVector, i);
output->GetCellData()->PassData(appFilter->GetOutput()->GetCellData()); vtkSmartPointer<vtkAppendFilter> appFilter = vtkSmartPointer<vtkAppendFilter>::New();
appFilter->AddInputData(data);
for (int i =1;i<=_blockList.size();i++) appFilter->Update();
{ outData->CopyStructure(appFilter->GetOutput());
if (i > MAXBLOCKNUM) break; outData->GetPointData()->PassData(appFilter->GetOutput()->GetPointData());
auto data = _blockList.at(i-1); outData->GetCellData()->PassData(appFilter->GetOutput()->GetCellData());
vtkUnstructuredGrid* outData = vtkUnstructuredGrid::GetData(outputVector,i); ;
vtkSmartPointer<vtkAppendFilter> appFilter = vtkSmartPointer<vtkAppendFilter>::New(); }
appFilter->AddInputData(data); return 1;
appFilter->Update();
outData->CopyStructure(appFilter->GetOutput());
outData->GetPointData()->PassData(appFilter->GetOutput()->GetPointData());
outData->GetCellData()->PassData(appFilter->GetOutput()->GetCellData());;
}
return 1;
} }
bool CGNSReaderAlgorithm::useVTKCGNSReader() bool CGNSReaderAlgorithm::useVTKCGNSReader()
{ {
int currentFileIndex = 0; int currentFileIndex = 0;
int OK = cg_open(FileName, CG_MODE_READ, &currentFileIndex); int OK = cg_open(FileName, CG_MODE_READ, &currentFileIndex);
if (CG_OK != OK) return false; if(CG_OK != OK)
bool useVTK = false; return false;
int nBase = 0; bool useVTK = false;
OK = cg_nbases(currentFileIndex, &nBase); int nBase = 0;
OK = cg_nbases(currentFileIndex, &nBase);
for (int ibase = 1; ibase <= nBase; ++ibase) for(int ibase = 1; ibase <= nBase; ++ibase) {
{ int zone_node_number = 0;
int zone_node_number = 0; cg_nzones(currentFileIndex, ibase, &zone_node_number);
cg_nzones(currentFileIndex, ibase, &zone_node_number);
for (int izone = 1; izone <= zone_node_number; ++izone)
{
CGNS_ENUMT(ZoneType_t) zonetype;
cg_zone_type(currentFileIndex, ibase, izone, &zonetype);
if (zonetype == CGNS_ENUMV(Unstructured))
{
int nSection{ 0 };
cg_nsections(currentFileIndex, ibase, izone, &nSection);
for (int iSec = 1;iSec <= nSection; ++iSec)
{
char sectionName[33] = { 0 };
cgsize_t istart = 0, iend = 0;
int nbndry = 0, iparent_flag = 0;
CGNS_ENUMT(ElementType_t) itype;
OK = cg_section_read(currentFileIndex, ibase, izone, iSec, sectionName, &itype
, &istart, &iend, &nbndry, &iparent_flag);
if (itype >= 20)
{
cg_close(currentFileIndex);
return true;
}
} for(int izone = 1; izone <= zone_node_number; ++izone) {
CGNS_ENUMT(ZoneType_t) zonetype;
} cg_zone_type(currentFileIndex, ibase, izone, &zonetype);
} if(zonetype == CGNS_ENUMV(Unstructured)) {
} int nSection{ 0 };
cg_close(currentFileIndex); cg_nsections(currentFileIndex, ibase, izone, &nSection);
return useVTK; for(int iSec = 1; iSec <= nSection; ++iSec) {
char sectionName[33] = { 0 };
cgsize_t istart = 0, iend = 0;
int nbndry = 0, iparent_flag = 0;
CGNS_ENUMT(ElementType_t) itype;
OK = cg_section_read(currentFileIndex, ibase, izone, iSec, sectionName, &itype,
&istart, &iend, &nbndry, &iparent_flag);
if(itype >= 20) {
cg_close(currentFileIndex);
return true;
}
}
}
}
}
cg_close(currentFileIndex);
return useVTK;
} }
CGNSReaderAlgorithm* CGNSReaderAlgorithm::New() CGNSReaderAlgorithm* CGNSReaderAlgorithm::New()
{ {
auto reader = new CGNSReaderAlgorithm; auto reader = new CGNSReaderAlgorithm;
reader->InitializeObjectBase(); reader->InitializeObjectBase();
return reader; return reader;
} }
void CGNSReaderAlgorithm::PrintSelf(ostream& os, vtkIndent indent) void CGNSReaderAlgorithm::PrintSelf(ostream& os, vtkIndent indent)
{ {
this->Superclass::PrintSelf(os, indent); this->Superclass::PrintSelf(os, indent);
os << indent << "FileName:" << (this->FileName ? this->FileName : "(none)") << "\n"; os << indent << "FileName:" << (this->FileName ? this->FileName : "(none)") << "\n";
} }
void CGNSReaderAlgorithm::setVisible(int blockIndex, bool vis) void CGNSReaderAlgorithm::setVisible(int blockIndex, bool vis)
{ {
if (blockIndex >= MAXBLOCKNUM) return; if(blockIndex >= MAXBLOCKNUM)
_visibleStates[blockIndex] = vis; return;
// this->Modified(); _visibleStates[blockIndex] = vis;
// this->Modified();
} }
int CGNSReaderAlgorithm::getNumberOfBlocks() int CGNSReaderAlgorithm::getNumberOfBlocks()
{ {
return _blockList.size(); return _blockList.size();
} }
QStringList CGNSReaderAlgorithm::getBlockNames() QStringList CGNSReaderAlgorithm::getBlockNames()
{ {
return _blockNames; return _blockNames;
} }
QStringList CGNSReaderAlgorithm::getBlockBCTypes() QStringList CGNSReaderAlgorithm::getBlockBCTypes()
{ {
return _bcTypes; return _bcTypes;
} }
int CGNSReaderAlgorithm::FillOutputPortInformation(int port, vtkInformation* info) int CGNSReaderAlgorithm::FillInputPortInformation(int, vtkInformation*)
{ {
Q_UNUSED(port) // 该算法没有输入端口
info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkUnstructuredGrid"); // info->Set(vtkAlgorithm::INPUT_IS_REPEATABLE(), 1);
return 1; // info->Set(vtkAlgorithm::INPUT_IS_OPTIONAL(), 1);
// info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet");
return 1;
} }
void CGNSReaderAlgorithm::getBlocks(vtkDataObject* blockData,const char* Name) int CGNSReaderAlgorithm::FillOutputPortInformation(int, vtkInformation* info)
{ {
auto block = vtkMultiBlockDataSet::SafeDownCast(blockData); info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkUnstructuredGrid");
return 1;
}
if (block == nullptr) void CGNSReaderAlgorithm::getBlocks(vtkDataObject* blockData, const char* Name)
{ {
auto dataset = vtkDataSet::SafeDownCast(blockData); auto block = vtkMultiBlockDataSet::SafeDownCast(blockData);
if (dataset == nullptr) return;
dataset->Modified();
QString totalName = QString::fromLocal8Bit(Name);
QStringList NameBC = totalName.split("!|||!");
if (NameBC.size() == 2)
{
_blockNames.append(NameBC.at(0));
_bcTypes.append(NameBC.at(1));
}
else
{
_blockNames.append(totalName);
_bcTypes.append("None");
}
_blockList.append(dataset);
getPointArray(dataset);
getCellArray(dataset);
return;
}
block->Modified(); if(block == nullptr) {
const int nBlock = block->GetNumberOfBlocks(); auto dataset = vtkDataSet::SafeDownCast(blockData);
if(dataset == nullptr)
return;
dataset->Modified();
QString totalName = QString::fromLocal8Bit(Name);
QStringList NameBC = totalName.split("!|||!");
for (int i = 0; i < nBlock; i++) if(NameBC.size() == 2) {
{ _blockNames.append(NameBC.at(0));
vtkDataObject* obj = block->GetBlock(i); _bcTypes.append(NameBC.at(1));
const char* currentName = block->GetMetaData(i)->Get(vtkCompositeDataSet::NAME()); } else {
getBlocks(obj,currentName); _blockNames.append(totalName);
} _bcTypes.append("None");
}
_blockList.append(dataset);
getPointArray(dataset);
getCellArray(dataset);
return;
}
block->Modified();
const int nBlock = block->GetNumberOfBlocks();
for(int i = 0; i < nBlock; i++) {
vtkDataObject* obj = block->GetBlock(i);
const char* currentName = block->GetMetaData(i)->Get(vtkCompositeDataSet::NAME());
getBlocks(obj, currentName);
}
} }
void CGNSReaderAlgorithm::getPointArray(vtkDataSet* dataset) void CGNSReaderAlgorithm::getPointArray(vtkDataSet* dataset)
{ {
if (dataset == nullptr) return; if(dataset == nullptr)
return;
auto pointData = dataset->GetPointData(); auto pointData = dataset->GetPointData();
if (pointData == nullptr) return; if(pointData == nullptr)
return;
const int nPointArray = pointData->GetNumberOfArrays(); const int nPointArray = pointData->GetNumberOfArrays();
for (int i = 0; i < nPointArray; i++) for(int i = 0; i < nPointArray; i++) {
{ const char* aName = pointData->GetArrayName(i);
const char* aName = pointData->GetArrayName(i); auto dataArray = pointData->GetArray(aName);
auto dataArray = pointData->GetArray(aName); if(dataArray == nullptr)
if (dataArray == nullptr) return; //continue; return; // continue;
int aNum[2]{ 0 }; int aNum[2]{ 0 };
aNum[0] = dataArray->GetNumberOfComponents(); aNum[0] = dataArray->GetNumberOfComponents();
aNum[1] = dataArray->GetNumberOfTuples(); aNum[1] = dataArray->GetNumberOfTuples();
if (_pointDataArray.contains(aName)) continue; if(_pointDataArray.contains(aName))
_pointDataArray.insert(aName, aNum); continue;
} _pointDataArray.insert(aName, aNum);
}
} }
void CGNSReaderAlgorithm::getCellArray(vtkDataSet* dataset) void CGNSReaderAlgorithm::getCellArray(vtkDataSet* dataset)
{ {
if (dataset == nullptr) return; if(dataset == nullptr)
return;
auto cellData = dataset->GetCellData(); auto cellData = dataset->GetCellData();
if (cellData == nullptr) return; if(cellData == nullptr)
return;
const int nCellArray = cellData->GetNumberOfArrays(); const int nCellArray = cellData->GetNumberOfArrays();
for (int i = 0; i < nCellArray; i++) for(int i = 0; i < nCellArray; i++) {
{ const char* aName = cellData->GetArrayName(i);
const char* aName = cellData->GetArrayName(i); auto dataArray = cellData->GetArray(aName);
auto dataArray = cellData->GetArray(aName); if(dataArray == nullptr)
if (dataArray == nullptr) return; //continue; return; // continue;
int aNum[2]{ 0 }; int aNum[2]{ 0 };
aNum[0] = dataArray->GetNumberOfComponents(); aNum[0] = dataArray->GetNumberOfComponents();
aNum[1] = dataArray->GetNumberOfTuples(); aNum[1] = dataArray->GetNumberOfTuples();
if (_cellDataArray.contains(aName)) continue; if(_cellDataArray.contains(aName))
_cellDataArray.insert(aName, aNum); continue;
} _cellDataArray.insert(aName, aNum);
}
} }
void CGNSReaderAlgorithm::fillPointArray(vtkDataSet* dataset) void CGNSReaderAlgorithm::fillPointArray(vtkDataSet* dataset)
{ {
Q_UNUSED(dataset) Q_UNUSED(dataset)
// if (dataset == nullptr) return; //continue; // if (dataset == nullptr) return; //continue;
// //
// vtkPointData* pointData = dataset->GetPointData(); // vtkPointData* pointData = dataset->GetPointData();
// if (pointData == nullptr) return; // if (pointData == nullptr) return;
// //
// QList<QString> pArrayNames = _pointDataArray.uniqueKeys(); // QList<QString> pArrayNames = _pointDataArray.uniqueKeys();
// for (auto name : pArrayNames) // for (auto name : pArrayNames)
// { // {
// QString2Char(name, cName) // QString2Char(name, cName)
// vtkDataArray* array = pointData->GetArray(cName); // vtkDataArray* array = pointData->GetArray(cName);
// if (array != nullptr)continue; // if (array != nullptr)continue;
// //
// int* aNum = _pointDataArray.value(name); // int* aNum = _pointDataArray.value(name);
// vtkSmartPointer<vtkDoubleArray> dataArray = vtkSmartPointer<vtkDoubleArray>::New(); // vtkSmartPointer<vtkDoubleArray> dataArray = vtkSmartPointer<vtkDoubleArray>::New();
// dataArray->SetName(cName); // dataArray->SetName(cName);
// dataArray->SetNumberOfComponents(aNum[0]); // dataArray->SetNumberOfComponents(aNum[0]);
// dataArray->SetNumberOfTuples(aNum[1]); // dataArray->SetNumberOfTuples(aNum[1]);
// dataArray->Fill(0); // dataArray->Fill(0);
// //
// pointData->AddArray(dataArray); // pointData->AddArray(dataArray);
// } // }
} }
void CGNSReaderAlgorithm::fillCellArray(vtkDataSet* dataset) void CGNSReaderAlgorithm::fillCellArray(vtkDataSet* dataset)
{ {
Q_UNUSED(dataset) Q_UNUSED(dataset)
// if (dataset == nullptr) return; //continue; // if (dataset == nullptr) return; //continue;
// //
// vtkCellData* cellData = dataset->GetCellData(); // vtkCellData* cellData = dataset->GetCellData();
// if (cellData == nullptr) return; // if (cellData == nullptr) return;
// //
// QList<QString> cArrayNames = _cellDataArray.uniqueKeys(); // QList<QString> cArrayNames = _cellDataArray.uniqueKeys();
// for (auto name : cArrayNames) // for (auto name : cArrayNames)
// { // {
// QString2Char(name, cName) // QString2Char(name, cName)
// vtkDataArray* array = cellData->GetArray(cName); // vtkDataArray* array = cellData->GetArray(cName);
// if (array != nullptr)continue; // if (array != nullptr)continue;
// //
// int* aNum = _pointDataArray.value(name); // int* aNum = _pointDataArray.value(name);
// vtkSmartPointer<vtkDoubleArray> dataArray = vtkSmartPointer<vtkDoubleArray>::New(); // vtkSmartPointer<vtkDoubleArray> dataArray = vtkSmartPointer<vtkDoubleArray>::New();
// dataArray->SetName(cName); // dataArray->SetName(cName);
// dataArray->SetNumberOfComponents(aNum[0]); // dataArray->SetNumberOfComponents(aNum[0]);
// dataArray->SetNumberOfTuples(aNum[1]); // dataArray->SetNumberOfTuples(aNum[1]);
// dataArray->Fill(0); // dataArray->Fill(0);
// //
// cellData->AddArray(dataArray); // cellData->AddArray(dataArray);
// } // }
} }

View File

@ -3,100 +3,133 @@
#include "PostAlgorithmAPI.h" #include "PostAlgorithmAPI.h"
#include "PostRenderData/Macros.hxx" #include "PostRenderData/Macros.hxx"
#include <vtkUnstructuredGridAlgorithm.h>
#include <QString>
#include <QHash> #include <QHash>
#include <QString>
#include <vtkUnstructuredGridAlgorithm.h>
ForwardDeclar(vtkInformation) ForwardDeclar(vtkInformation);
ForwardDeclar(vtkDataSet) ForwardDeclar(vtkDataSet);
ForwardDeclar(vtkDataObject) ForwardDeclar(vtkDataObject);
ForwardDeclar(vtkDataArray) ForwardDeclar(vtkDataArray);
class POSTALGORITHMAPI CGNSReaderAlgorithm :public vtkUnstructuredGridAlgorithm class POSTALGORITHMAPI CGNSReaderAlgorithm : public vtkUnstructuredGridAlgorithm {
{
public: public:
static CGNSReaderAlgorithm* New(); static CGNSReaderAlgorithm* New();
vtkTypeMacro(CGNSReaderAlgorithm, vtkUnstructuredGridAlgorithm); vtkTypeMacro(CGNSReaderAlgorithm, vtkUnstructuredGridAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent); /**
* @brief ()
*
* @param[in] os
* @param[in] indent
*/
void PrintSelf(ostream& os, vtkIndent indent) override;
/** @name Set/Get宏
* setter/gettervtkSetMacro(FileName, char*)/vtkGetMacro(FileName, char*)
* @{
*/
vtkSetStringMacro(FileName); vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName); vtkGetStringMacro(FileName);
/** @} */
void setVisible(int blockIndex, bool vis); void setVisible(int blockIndex, bool vis);
int getNumberOfBlocks(); int getNumberOfBlocks();
QStringList getBlockNames(); QStringList getBlockNames();
QStringList getBlockBCTypes(); QStringList getBlockBCTypes();
int FillOutputPortInformation(int port, vtkInformation* info);
/** /**
* @brief * @brief
* @param block * @param[in] port 0
*/ */
void getBlocks(vtkDataObject* block, const char* cuttentName =""); int FillInputPortInformation(int port, vtkInformation* info) override;
/** /**
* @brief datasetpoint * @brief
* @param dataset * @param[in] port 0
*/ */
void getPointArray(vtkDataSet* dataset); int FillOutputPortInformation(int port, vtkInformation* info) override;
/** /**
* @brief datasetcell * @brief
* @param dataset * @param block
*/ */
void getCellArray(vtkDataSet* dataset); void getBlocks(vtkDataObject* block, const char* cuttentName = "");
/** /**
* @brief point * @brief datasetpoint
* @param dataset * @param dataset
*/ */
void fillPointArray(vtkDataSet* dataset); void getPointArray(vtkDataSet* dataset);
/** /**
* @brief cell * @brief datasetcell
* @param dataset * @param dataset
*/ */
void fillCellArray(vtkDataSet* dataset); void getCellArray(vtkDataSet* dataset);
/**
* @brief point
* @param dataset
*/
void fillPointArray(vtkDataSet* dataset);
/**
* @brief cell
* @param dataset
*/
void fillCellArray(vtkDataSet* dataset);
protected: protected:
CGNSReaderAlgorithm(); CGNSReaderAlgorithm();
~CGNSReaderAlgorithm(); ~CGNSReaderAlgorithm();
int ProcessRequest(vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector);
int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*);
bool useVTKCGNSReader(); /**
* @brief VTK/
*
* vtkAlgorithm::ProcessRequest()
*
* ProcessRequest().
*
* \param request
* \param inputVector
* \param outputVector
* \return
*/
int ProcessRequest(vtkInformation* request, vtkInformationVector** inputVector,
vtkInformationVector* outputVector) override;
int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
bool useVTKCGNSReader();
protected: protected:
char* FileName; char* FileName;
private: private:
CGNSReaderAlgorithm(const CGNSReaderAlgorithm&); CGNSReaderAlgorithm(const CGNSReaderAlgorithm&);
void operator=(const CGNSReaderAlgorithm&); void operator=(const CGNSReaderAlgorithm&);
/** /**
* @brief * @brief
* @since Version: 1.0.0 * @since Version: 1.0.0
*/ */
QList<vtkDataSet*> _blockList{}; QList<vtkDataSet*> _blockList{};
/** /**
* @brief point * @brief point
* @note tuple * @note tuple
* @since Version: 1.0.0 * @since Version: 1.0.0
*/ */
QHash<QString, int*> _pointDataArray{}; QHash<QString, int*> _pointDataArray{};
/** /**
* @brief cell * @brief cell
* @note tuple * @note tuple
* @since Version: 1.0.0 * @since Version: 1.0.0
*/ */
QHash<QString, int*> _cellDataArray{}; QHash<QString, int*> _cellDataArray{};
QList<bool> _visibleStates{}; QList<bool> _visibleStates{};
QStringList _blockNames{}; QStringList _blockNames{};
QStringList _bcTypes; QStringList _bcTypes;
}; };
#endif #endif

View File

@ -28,6 +28,8 @@ add_library(PostAlgorithm
target_compile_definitions(PostAlgorithm PRIVATE "POSTALGORITHM_API") target_compile_definitions(PostAlgorithm PRIVATE "POSTALGORITHM_API")
#target_compile_definitions(PostAlgorithm PRIVATE "H5_BUILT_AS_DYNAMIC_LIB") #target_compile_definitions(PostAlgorithm PRIVATE "H5_BUILT_AS_DYNAMIC_LIB")
list(APPEND _depend_library Common)
list(APPEND _runtimes_libraries list(APPEND _runtimes_libraries
FASTCAE::CGNS FASTCAE::HDF5 FASTCAE::HDF5CPP FASTCAE::TECIO Qt5::Core VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::DICOMParser VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersHybrid VTK::FiltersModeling VTK::FiltersParallel VTK::FiltersSources VTK::FiltersStatistics VTK::FiltersTexture VTK::IOCore VTK::IOGeometry VTK::IOImage VTK::IOLegacy VTK::IOParallel VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingSources VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::doubleconversion VTK::expat VTK::jpeg VTK::jsoncpp VTK::lz4 VTK::lzma VTK::metaio VTK::png VTK::pugixml VTK::sys VTK::tiff VTK::zlib FASTCAE::CGNS FASTCAE::HDF5 FASTCAE::HDF5CPP FASTCAE::TECIO Qt5::Core VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::DICOMParser VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersHybrid VTK::FiltersModeling VTK::FiltersParallel VTK::FiltersSources VTK::FiltersStatistics VTK::FiltersTexture VTK::IOCore VTK::IOGeometry VTK::IOImage VTK::IOLegacy VTK::IOParallel VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingSources VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::doubleconversion VTK::expat VTK::jpeg VTK::jsoncpp VTK::lz4 VTK::lzma VTK::metaio VTK::png VTK::pugixml VTK::sys VTK::tiff VTK::zlib
) )
@ -37,8 +39,14 @@ list(APPEND _runtimes_libraries
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
target_link_libraries(PostAlgorithm PRIVATE target_link_libraries(PostAlgorithm PRIVATE
${_runtimes_libraries} ${_runtimes_libraries}
${_depend_library}
) )
#-----------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------
add_dependencies(PostAlgorithm ${_depend_library})
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# #
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------

View File

@ -1,17 +1,19 @@
#include "FCGNSGridReaderBase.h" #include "FCGNSGridReaderBase.h"
#include <cgnstypes.h>
#include "Common/DebugLogger.h"
#include <cgns_io.h> #include <cgns_io.h>
#include <cgnslib.h> #include <cgnslib.h>
#include <QDebug> #include <cgnstypes.h>
#include <vtkDataSet.h>
#include <vtkPointData.h>
#include <vtkCellData.h> #include <vtkCellData.h>
#include <vtkDataSet.h>
#include <vtkDoubleArray.h> #include <vtkDoubleArray.h>
#include <vtkFloatArray.h> #include <vtkFloatArray.h>
#include <vtkStructuredGrid.h>
#include <vtkNew.h> #include <vtkNew.h>
#include <vtkPointData.h>
#include <vtkStructuredGrid.h>
FCGNSGridReaderBase::FCGNSGridReaderBase(vtkMultiBlockDataSet *root) FCGNSGridReaderBase::FCGNSGridReaderBase(vtkMultiBlockDataSet* root)
: _root(root) : _root(root)
{ {
} }
@ -23,299 +25,308 @@ void FCGNSGridReaderBase::setInfo(int fileIndex, int baseIndex, int zoneIndex)
_zoneIndex = zoneIndex; _zoneIndex = zoneIndex;
} }
void FCGNSGridReaderBase::readCoordinate(int dim, int count, cgsize_t rangeMin[3], cgsize_t rangeMax[3]) void FCGNSGridReaderBase::readCoordinate(int dim, int count, cgsize_t rangeMin[3],
cgsize_t rangeMax[3])
{ {
_vertexList.clear(); _vertexList.clear();
_vertexList.fill(VPoint(), count); _vertexList.fill(VPoint(), count);
char coordinate_name[33] = {0}; // 坐标名称CoordinateXCoordinateYCoordinateZCoordinateRCoordinateThetaCoordinatePhi等
CGNS_ENUMV(DataType_t) // 参考http://cgns.github.io/CGNS_docs_current/sids/dataname.html#dataname_grid
datatype; char coordinate_name[33] = { 0 };
int OK = 0; // 坐标值的数据类型RealSingle 或者 RealDouble
for (int i = 1; i <= dim; ++i) CGNS_ENUMV(DataType_t) datatype;
{ int result = 0;
OK = cg_coord_info(_fileIndex, _baseIndex, _zoneIndex, i, &datatype, coordinate_name); for(int i = 1; i <= dim; ++i) {
if (CG_OK != OK) // 读取坐标信息,构建数据存储数组
continue; result = cg_coord_info(_fileIndex, _baseIndex, _zoneIndex, i, &datatype, coordinate_name);
void *xyz{nullptr}; if(CG_OK != result) {
if (datatype == CGNS_ENUMV(RealSingle)) DebugError("Failed to get coordinate(index = %d) info\n", i);
break;
}
void* xyz{ nullptr };
if(datatype == CGNS_ENUMV(RealSingle)) {
xyz = new float[count]; xyz = new float[count];
else if (datatype == CGNS_ENUMV(RealDouble)) } else if(datatype == CGNS_ENUMV(RealDouble)) {
xyz = new double[count]; xyz = new double[count];
if (xyz == nullptr) } else {
continue; DebugError("Invalid data type for coordinate: %s\n", coordinate_name);
break;
}
OK = cg_coord_read(_fileIndex, _baseIndex, _zoneIndex, coordinate_name, datatype, rangeMin, rangeMax, xyz); // 读取坐标数据
if (OK != 0) // 官方文档datatype不需要区分RealSingle或者RealDouble可以自动处理但是由于数据量一般比较大考虑
continue; // 节约内存也可以做区分The function cg_coord_read returns the coordinate array
// coord_array, for the range prescribed by range_min and range_max. The array is returned
// to the application in the data type requested in mem_datatype. This data type does not
// need to be the same as the one in which the coordinates are stored in the file. A
// coordinate array stored as double precision in the CGNS file can be returned to the
// application as single precision, or vice versa. The functions cg_coord_general_read and
// cg_coord_general_write allow for type conversion when both reading from and writing to
// the file.
result = cg_coord_read(_fileIndex, _baseIndex, _zoneIndex, coordinate_name, datatype,
rangeMin, rangeMax, xyz);
if(CG_OK != result) {
DebugError("Failed to read grid coordinate: %s\n", coordinate_name);
break;
}
if (!strcmp(coordinate_name, "CoordinateX")) if(strcmp(coordinate_name, "CoordinateX") == 0) {
{ if(datatype == CGNS_ENUMV(RealDouble)) {
if (datatype == CGNS_ENUMV(RealDouble)) auto* c = static_cast<double*>(xyz);
{ for(int ipt = 0; ipt < count; ++ipt)
auto *c = static_cast<double *>(xyz); _vertexList[ipt].x = c[ipt];
for (int ipt = 0; ipt < count; ++ipt) } else if(datatype == CGNS_ENUMV(RealSingle)) {
auto* c = static_cast<float*>(xyz);
for(int ipt = 0; ipt < count; ++ipt)
_vertexList[ipt].x = c[ipt]; _vertexList[ipt].x = c[ipt];
} }
else if (datatype == CGNS_ENUMV(RealSingle)) } else if(strcmp(coordinate_name, "CoordinateY") == 0) {
{ if(datatype == CGNS_ENUMV(RealDouble)) {
auto *c = static_cast<float *>(xyz); auto* c = static_cast<double*>(xyz);
for (int ipt = 0; ipt < count; ++ipt) for(int ipt = 0; ipt < count; ++ipt)
_vertexList[ipt].x = c[ipt]; _vertexList[ipt].y = c[ipt];
} } else if(datatype == CGNS_ENUMV(RealSingle)) {
} auto* c = static_cast<float*>(xyz);
else if (!strcmp(coordinate_name, "CoordinateY")) for(int ipt = 0; ipt < count; ++ipt)
{
if (datatype == CGNS_ENUMV(RealDouble))
{
auto *c = static_cast<double *>(xyz);
for (int ipt = 0; ipt < count; ++ipt)
_vertexList[ipt].y = c[ipt]; _vertexList[ipt].y = c[ipt];
} }
else if (datatype == CGNS_ENUMV(RealSingle)) } else if(dim == 3 && (strcmp(coordinate_name, "CoordinateZ") == 0)) {
{ if(datatype == CGNS_ENUMV(RealDouble)) {
auto *c = static_cast<float *>(xyz); auto* c = static_cast<double*>(xyz);
for (int ipt = 0; ipt < count; ++ipt) for(int ipt = 0; ipt < count; ++ipt)
_vertexList[ipt].y = c[ipt];
}
}
else if (!strcmp(coordinate_name, "CoordinateZ"))
{
if (datatype == CGNS_ENUMV(RealDouble))
{
auto *c = static_cast<double *>(xyz);
for (int ipt = 0; ipt < count; ++ipt)
_vertexList[ipt].z = c[ipt]; _vertexList[ipt].z = c[ipt];
} } else if(datatype == CGNS_ENUMV(RealSingle)) {
else if (datatype == CGNS_ENUMV(RealSingle)) auto* c = static_cast<float*>(xyz);
{ for(int ipt = 0; ipt < count; ++ipt)
auto *c = static_cast<float *>(xyz);
for (int ipt = 0; ipt < count; ++ipt)
_vertexList[ipt].z = c[ipt]; _vertexList[ipt].z = c[ipt];
} }
_dim = 3; _dim = 3;
} }
if (datatype == CGNS_ENUMV(RealSingle)) if(datatype == CGNS_ENUMV(RealSingle))
delete (float *)xyz; delete[](float*)xyz;
else if (datatype == CGNS_ENUMV(RealDouble)) else if(datatype == CGNS_ENUMV(RealDouble))
delete (double *)xyz; delete[](double*)xyz;
} }
} }
void FCGNSGridReaderBase::readFlowSolution(vtkDataSet *grid) void FCGNSGridReaderBase::readFlowSolution(vtkDataSet* grid)
{ {
int OK = 0; int result = 0;
int nsol = 0; int nsol = 0;
OK = cg_nsols(_fileIndex, _baseIndex, _zoneIndex, &nsol); result = cg_nsols(_fileIndex, _baseIndex, _zoneIndex, &nsol);
if (CG_OK != OK) if(CG_OK != result) {
DebugError("Failed to read number of flow solution\n");
return; return;
} else {
DebugInfo("Number of flow solution is %d\n", nsol);
}
_dataSet = grid; _dataSet = grid;
for (int isol = 1; isol <= nsol; ++isol) for(int isol = 1; isol <= nsol; ++isol) {
{ CGNS_ENUMT(GridLocation_t) varloc;
CGNS_ENUMT(GridLocation_t) char sol_name[33] = { 0 };
varloc; result = cg_sol_info(_fileIndex, _baseIndex, _zoneIndex, isol, sol_name, &varloc);
char sol_name[33] = {0}; if(CG_OK != result) {
OK = cg_sol_info(_fileIndex, _baseIndex, _zoneIndex, isol, sol_name, &varloc); DebugError("Failed to read info of flow solution\n");
if (CG_OK != OK) return;
continue; } else {
qDebug() << sol_name << varloc; DebugInfo("Flow solution: %s, var location: %d\n", sol_name, varloc);
}
QList<QString> varNames; QList<QString> varNames;
QList<void *> values; QList<void*> values;
QList<int> valueType; // 3-float 4-double QList<int> valueType; // 3-float 4-double
readFieldData(isol, varloc, varNames, valueType, values); readFieldData(isol, varloc, varNames, valueType, values);
addValueToGrid(varloc, varNames, valueType, values); addValueToGrid(varloc, varNames, valueType, values);
for (auto v : values) for(auto v : values)
delete v; delete v;
values.clear(); values.clear();
} }
} }
void FCGNSGridReaderBase::readFieldData(int solIndex, CGNS_ENUMT(GridLocation_t) loc, void FCGNSGridReaderBase::readFieldData(int solIndex, CGNS_ENUMT(GridLocation_t) loc,
QList<QString> &varNames, QList<int> &valueType, QList<void *> &values) QList<QString>& varNames, QList<int>& valueType,
QList<void*>& values)
{ {
qDebug() << loc; if(loc != CGNS_ENUMT(Vertex) && loc != CGNS_ENUMT(CellCenter))
if (loc != CGNS_ENUMT(Vertex) && loc != CGNS_ENUMT(CellCenter))
return;
int OK = 0;
int var_num = 0;
OK = cg_nfields(_fileIndex, _baseIndex, _zoneIndex, solIndex, &var_num);
if (CG_OK != OK)
return;
int valNum = 0;
for (int iFiled = 1; iFiled <= var_num; ++iFiled)
{ {
CGNS_ENUMT(DataType_t) DebugError("Unsupported grid location: %d\n", loc);
datatype; return;
char var_name[33] = {0}; }
OK = cg_field_info(_fileIndex, _baseIndex, _zoneIndex, solIndex, iFiled, &datatype, var_name); int OK = 0;
if (CG_OK != OK) int nFields = 0;
continue; OK = cg_nfields(_fileIndex, _baseIndex, _zoneIndex, solIndex, &nFields);
qDebug() << var_name << datatype; if(CG_OK != OK)
{
cgsize_t min[3] = {1, 1, 1}, max[3] = {0}; DebugError("Failed to read number of fields\n");
if (!_isStructedGrid) return;
}
int valNum = 0;
for(int iField = 1; iField <= nFields; ++iField) {
CGNS_ENUMT(DataType_t) datatype;
char fieldName[33] = { 0 };
OK = cg_field_info(_fileIndex, _baseIndex, _zoneIndex, solIndex, iField, &datatype,
fieldName);
if(CG_OK != OK) {
DebugError("Failed to read info of field[%d]\n", iField);
return;
} else
{ {
switch (loc) DebugInfo("Begin to parse field: %s\n", fieldName);
{
case CGNS_ENUMT(Vertex):
valNum = max[0] = max[1] = max[2] = _dataSet->GetNumberOfPoints();
break;
case CGNS_ENUMT(CellCenter):
valNum = max[0] = max[1] = max[2] = _dataSet->GetNumberOfCells();
break;
default:
break;
}
} }
else
{ cgsize_t min[3] = { 1, 1, 1 }, max[3] = { 0 };
if(!_isStructedGrid) {
switch(loc) {
case CGNS_ENUMT(Vertex):
valNum = max[0] = max[1] = max[2] = _dataSet->GetNumberOfPoints();
break;
case CGNS_ENUMT(CellCenter):
valNum = max[0] = max[1] = max[2] = _dataSet->GetNumberOfCells();
break;
default:
break;
}
} else {
auto sG = vtkStructuredGrid::SafeDownCast(_dataSet); auto sG = vtkStructuredGrid::SafeDownCast(_dataSet);
int dims[3]; int dims[3];
sG->GetDimensions(dims); sG->GetDimensions(dims);
switch (loc) switch(loc) {
{ case CGNS_ENUMT(Vertex):
case CGNS_ENUMT(Vertex): max[0] = dims[0];
max[0] = dims[0]; max[1] = dims[1];
max[1] = dims[1]; max[2] = dims[2];
max[2] = dims[2]; valNum = max[0] * max[1] * max[2];
valNum = max[0] * max[1] * max[2]; break;
break; case CGNS_ENUMT(CellCenter):
case CGNS_ENUMT(CellCenter): max[0] = dims[0] - 1;
max[0] = dims[0] - 1; max[1] = dims[1] - 1;
max[1] = dims[1] - 1; max[2] = dims[2] - 1;
max[2] = dims[2] - 1; valNum = max[0] * max[1] * max[2];
valNum = max[0] * max[1] * max[2]; break;
break;
default: default:
break; break;
} }
} }
void *valuesArr = nullptr; void* valuesArr = nullptr;
if (datatype == CGNS_ENUMT(RealSingle)) if(datatype == CGNS_ENUMT(RealSingle))
valuesArr = new float[valNum]; valuesArr = new float[valNum];
else if (datatype == CGNS_ENUMT(RealDouble)) else if(datatype == CGNS_ENUMT(RealDouble))
valuesArr = new double[valNum]; valuesArr = new double[valNum];
OK = cg_field_read(_fileIndex, _baseIndex, _zoneIndex, solIndex, var_name, datatype, min, max, valuesArr); OK = cg_field_read(_fileIndex, _baseIndex, _zoneIndex, solIndex, fieldName, datatype, min,
if (CG_OK != OK) max, valuesArr);
continue; if(CG_OK != OK) {
DebugError("Failed to read flow solution for %s\n", fieldName);
return;
}
varNames.append(var_name); varNames.append(fieldName);
values.append(valuesArr);
valueType.append(datatype); valueType.append(datatype);
values.append(valuesArr);
} }
} }
void FCGNSGridReaderBase::addValueToGrid(CGNS_ENUMT(GridLocation_t) loc, void FCGNSGridReaderBase::addValueToGrid(CGNS_ENUMT(GridLocation_t) loc, QList<QString> varNames,
QList<QString> varNames, QList<int> vType, QList<void *> valueList) QList<int> vType, QList<void*> valueList)
{ {
QHash<QString, QHash<QString, QString>> vectorName; QHash<QString, QHash<QString, QString>> vectorName;
QStringList scalarName; QStringList scalarName;
for (QString varName : varNames) for(QString varName : varNames) {
{
QString component, vecName; QString component, vecName;
bool isV = isVectorComponent(varName, vecName, component); bool isV = isVectorComponent(varName, vecName, component);
if (!isV) if(isV) {
vectorName[vecName].insert(component.toLower(), varName);
} else
{ {
scalarName.append(varName); scalarName.append(varName);
continue;
} }
vectorName[vecName].insert(component.toLower(), varName);
} }
QStringList vecKeys = vectorName.keys(); QStringList vecKeys = vectorName.keys();
QStringList unVkeys; QStringList unVkeys;
for (QString vecKey : vecKeys) for(QString vecKey : vecKeys) {
{
QHash<QString, QString> vvs = vectorName.value(vecKey); QHash<QString, QString> vvs = vectorName.value(vecKey);
if (vvs.size() == _dim) if(vvs.size() == _dim)
continue; continue;
unVkeys.append(vecKey); unVkeys.append(vecKey);
scalarName.append(vvs.values()); scalarName.append(vvs.values());
} }
for (QString uk : unVkeys) for(QString uk : unVkeys)
vectorName.remove(uk); vectorName.remove(uk);
if (CGNS_ENUMT(Vertex) == loc) if(CGNS_ENUMT(Vertex) == loc) {
{ int nc = _dataSet->GetNumberOfPoints();
int nc = _dataSet->GetNumberOfPoints(); auto* pointArray = _dataSet->GetPointData();
auto pointArray = _dataSet->GetPointData(); for(QString sca : scalarName) {
for (QString sca : scalarName) int index = varNames.indexOf(sca);
{ int type = vType.at(index);
int index = varNames.indexOf(sca); void* v = valueList.at(index);
int type = vType.at(index); auto array = generateScalarArray(sca, nc, type, v);
void *v = valueList.at(index);
auto array = generateScalarArray(sca, nc, type, v);
pointArray->AddArray(array); pointArray->AddArray(array);
} }
for (QString vec : vectorName.keys()) for(QString vec : vectorName.keys()) {
{
QHash<QString, QString> comps = vectorName.value(vec); QHash<QString, QString> comps = vectorName.value(vec);
QString comp = comps.value("x"); QString comp = comps.value("x");
int index = varNames.indexOf(comp); int index = varNames.indexOf(comp);
void *x = valueList.at(index); void* x = valueList.at(index);
int xtype = vType.at(index); int xtype = vType.at(index);
comp = comps.value("y"); comp = comps.value("y");
index = varNames.indexOf(comp); index = varNames.indexOf(comp);
void *y = valueList.at(index); void* y = valueList.at(index);
int ytype = vType.at(index); int ytype = vType.at(index);
comp = comps.value("z"); comp = comps.value("z");
index = varNames.indexOf(comp); index = varNames.indexOf(comp);
void *z = nullptr; void* z = nullptr;
int ztype = 0; int ztype = 0;
if (index >= 0) if(index >= 0) {
{ z = valueList.at(index);
z = valueList.at(index);
ztype = vType.at(index); ztype = vType.at(index);
} }
auto array = generateVectorArray(vec, nc, xtype, x, ytype, y, ztype, z); auto array = generateVectorArray(vec, nc, xtype, x, ytype, y, ztype, z);
pointArray->AddArray(array); pointArray->AddArray(array);
} }
} } else if(CGNS_ENUMT(CellCenter) == loc) {
else if (CGNS_ENUMT(CellCenter) == loc) int nc = _dataSet->GetNumberOfCells();
{
int nc = _dataSet->GetNumberOfCells();
auto cellArray = _dataSet->GetCellData(); auto cellArray = _dataSet->GetCellData();
for (QString sca : scalarName) for(QString sca : scalarName) {
{ int index = varNames.indexOf(sca);
int index = varNames.indexOf(sca); void* v = valueList.at(index);
void *v = valueList.at(index); int type = vType.at(index);
int type = vType.at(index); auto array = generateScalarArray(sca, nc, type, v);
auto array = generateScalarArray(sca, nc, type, v);
cellArray->AddArray(array); cellArray->AddArray(array);
} }
for (QString vec : vectorName.keys()) for(QString vec : vectorName.keys()) {
{
QHash<QString, QString> comps = vectorName.value(vec); QHash<QString, QString> comps = vectorName.value(vec);
QString comp = comps.value("x"); QString comp = comps.value("x");
int index = varNames.indexOf(comp); int index = varNames.indexOf(comp);
void *x = valueList.at(index); void* x = valueList.at(index);
int xtype = vType.at(index); int xtype = vType.at(index);
comp = comps.value("y"); comp = comps.value("y");
index = varNames.indexOf(comp); index = varNames.indexOf(comp);
void *y = valueList.at(index); void* y = valueList.at(index);
int ytype = vType.at(index); int ytype = vType.at(index);
comp = comps.value("z"); comp = comps.value("z");
index = varNames.indexOf(comp); index = varNames.indexOf(comp);
void *z = nullptr; void* z = nullptr;
int ztype = 0; int ztype = 0;
if (index >= 0) if(index >= 0) {
{ z = valueList.at(index);
z = valueList.at(index);
ztype = vType.at(index); ztype = vType.at(index);
} }
@ -325,64 +336,59 @@ void FCGNSGridReaderBase::addValueToGrid(CGNS_ENUMT(GridLocation_t) loc,
} }
} }
bool FCGNSGridReaderBase::isVectorComponent(QString name, QString &vecName, QString &comp) bool FCGNSGridReaderBase::isVectorComponent(QString name, QString& vecName, QString& comp)
{ {
QRegExp pattern("\\s*x$|\\s*X$|\\s*y$|\\s*Y$|\\s*z$|\\s*Z$"); QRegExp pattern("\\s*x$|\\s*X$|\\s*y$|\\s*Y$|\\s*z$|\\s*Z$");
bool is = false; bool is = false;
is = name.contains(pattern); is = name.contains(pattern);
if (is) if(is) {
{ comp = name.right(1);
comp = name.right(1);
vecName = name.remove(comp); vecName = name.remove(comp);
if (vecName.isEmpty()) if(vecName.isEmpty())
return false; return false;
} }
return is; return is;
} }
vtkDataArray *FCGNSGridReaderBase::generateScalarArray(QString varName, int num, int type, void *va) vtkDataArray* FCGNSGridReaderBase::generateScalarArray(QString varName, int num, int type, void* va)
{ {
vtkDataArray *array = nullptr; vtkDataArray* array = nullptr;
float *valueFloat = nullptr; float* valueFloat = nullptr;
double *valueDouble = nullptr; double* valueDouble = nullptr;
if (type == 3) // float if(type == 3) // float
{ {
array = vtkFloatArray::New(); array = vtkFloatArray::New();
valueFloat = static_cast<float *>(va); valueFloat = static_cast<float*>(va);
} } else if(type == 4) // double
else if (type == 4) // double
{ {
array = vtkDoubleArray::New(); array = vtkDoubleArray::New();
valueDouble = static_cast<double *>(va); valueDouble = static_cast<double*>(va);
} }
double v = 0; double v = 0;
array->SetName(varName.toLatin1().data()); array->SetName(varName.toLatin1().data());
for (int i = 0; i < num; ++i) for(int i = 0; i < num; ++i) {
{ switch(type) {
switch (type) case 3:
{ v = valueFloat[i];
case 3: break;
v = valueFloat[i]; case 4:
break; v = valueDouble[i];
case 4: break;
v = valueDouble[i]; default:
break; break;
default:
break;
} }
array->InsertNextTuple1(v); array->InsertNextTuple1(v);
} }
double range[2]; double range[2];
array->GetRange(range); array->GetRange(range);
qDebug() << varName << range[0] << range[1];
return array; return array;
} }
vtkDataArray *FCGNSGridReaderBase::generateVectorArray(QString varName, int num, vtkDataArray* FCGNSGridReaderBase::generateVectorArray(QString varName, int num, int xType, void* x,
int xType, void *x, int yType, void *y, int zType, void *z) int yType, void* y, int zType, void* z)
{ {
auto array = vtkDoubleArray::New(); auto array = vtkDoubleArray::New();
array->SetName(varName.toLatin1().data()); array->SetName(varName.toLatin1().data());
@ -391,61 +397,57 @@ vtkDataArray *FCGNSGridReaderBase::generateVectorArray(QString varName, int num,
array->SetComponentName(1, "y"); array->SetComponentName(1, "y");
array->SetComponentName(2, "z"); array->SetComponentName(2, "z");
float *xFV = nullptr, *yFV = nullptr, *zFV = nullptr; float * xFV = nullptr, *yFV = nullptr, *zFV = nullptr;
double *xDV = nullptr, *yDV = nullptr, *zDV = nullptr; double *xDV = nullptr, *yDV = nullptr, *zDV = nullptr;
if (xType == 3) // float if(xType == 3) // float
xFV = static_cast<float *>(x); xFV = static_cast<float*>(x);
else if (xType == 4) // double else if(xType == 4) // double
xDV = static_cast<double *>(x); xDV = static_cast<double*>(x);
if (yType == 3) // float if(yType == 3) // float
yFV = static_cast<float *>(y); yFV = static_cast<float*>(y);
else if (yType == 4) // double else if(yType == 4) // double
yDV = static_cast<double *>(y); yDV = static_cast<double*>(y);
if (zType == 3) // float if(zType == 3) // float
zFV = static_cast<float *>(z); zFV = static_cast<float*>(z);
else if (zType == 4) // double else if(zType == 4) // double
zDV = static_cast<double *>(z); zDV = static_cast<double*>(z);
double vx = 0, vy = 0, vz = 0; double vx = 0, vy = 0, vz = 0;
for (int i = 0; i < num; ++i) for(int i = 0; i < num; ++i) {
{ switch(xType) {
switch (xType) case 3:
{ vx = xFV[i];
case 3: break;
vx = xFV[i]; case 4:
break; vx = xDV[i];
case 4: break;
vx = xDV[i]; default:
break; break;
default:
break;
} }
switch (yType) switch(yType) {
{ case 3:
case 3: vy = yFV[i];
vy = yFV[i]; break;
break; case 4:
case 4: vy = yDV[i];
vy = yDV[i]; break;
break; default:
default: break;
break;
} }
switch (zType) switch(zType) {
{ case 3:
case 3: vz = zFV[i];
vz = zFV[i]; break;
break; case 4:
case 4: vz = zDV[i];
vz = zDV[i]; break;
break; default:
default: break;
break;
} }
array->InsertNextTuple3(vx, vy, vz); array->InsertNextTuple3(vx, vy, vz);

View File

@ -1,59 +1,154 @@
#ifndef _FCGNSGRIDREADER_H__ #ifndef _FCGNSGRIDREADER_H__
#define _FCGNSGRIDREADER_H__ #define _FCGNSGRIDREADER_H__
#include <QVector>
#include <cgnstypes.h>
#include <cgnslib.h> #include <cgnslib.h>
#include <cgnstypes.h>
#include <QHash> #include <QHash>
#include <QVector>
class vtkMultiBlockDataSet; class vtkMultiBlockDataSet;
class vtkDataSet; class vtkDataSet;
class vtkDataArray; class vtkDataArray;
struct VPoint /**
{ * @brief
double x{0}; * @since 2.5.0
double y{0}; */
double z{0}; struct VPoint {
double x{ 0 };
double y{ 0 };
double z{ 0 };
}; };
class FCGNSGridReaderBase class FCGNSGridReaderBase {
{
public: public:
FCGNSGridReaderBase(vtkMultiBlockDataSet* root); /**
virtual ~FCGNSGridReaderBase() = default; * @brief
* @param[out] root vtkMultiBlockDataSet
*/
FCGNSGridReaderBase(vtkMultiBlockDataSet* root);
virtual ~FCGNSGridReaderBase() = default;
void setInfo(int fileIndex, int baseIndex, int zoneIndex); /**
* @brief zone
*
* @param[in] fileIndex
* @param[in] baseIndex base
* @param[in] zoneIndex zone
*/
void setInfo(int fileIndex, int baseIndex, int zoneIndex);
virtual void read()=0; /**
* @brief zone
* @since 2.5.0
*/
virtual void read() = 0;
protected: protected:
void readCoordinate(int dim,int count, cgsize_t range_from[3], cgsize_t range_to[3]); /**
* @brief zone
* @param[in] dim
* @param[in] count
* @param[out] range_from 1
* @param[out] range_to
* @since 2.5.0
*/
void readCoordinate(int dim, int count, cgsize_t range_from[3], cgsize_t range_to[3]);
/**
* @brief zone
* @param[out] grid vtkDataSet
* @since 2.5.0
*/
void readFlowSolution(vtkDataSet* grid);
/**
* @brief
* @param[in] solIndex
* @param[in] loc
* @param[out] varNames
* @param[out] valueType
* @param[out] values
* @since 2.5.0
*/
void readFieldData(int solIndex, CGNS_ENUMT(GridLocation_t) loc, QList<QString>& varNames,
QList<int>& valueType, QList<void*>& values);
/**
* @brief vtk
* @param[in] loc
* @param[in] varNames
* @param[in] valueType
* @param[in] values
* @since 2.5.0
*/
void addValueToGrid(CGNS_ENUMT(GridLocation_t) loc, QList<QString> varNames,
QList<int> valueType, QList<void*> values);
void readFlowSolution(vtkDataSet* grid); /**
* @brief
* @param[in] name
* @param[out] vecName x,y,z
* @param[out] comp (x,y,z)
* @note x,y,z()
* @since 2.5.0
*/
bool isVectorComponent(QString name, QString& vecName, QString& comp);
/**
* @brief vtkDataArray
* @param[in] varName
* @param[in] num
* @param[in] type
* @param[in] va
* @since 2.5.0
*/
vtkDataArray* generateScalarArray(QString varName, int num, int type, void* va);
void readFieldData(int solIndex, CGNS_ENUMT(GridLocation_t) loc,QList<QString> &varNames, /**
QList<int> &valueType, QList<void*> &values); * @brief vtkDataArray
* @param[in] varName
void addValueToGrid(CGNS_ENUMT(GridLocation_t) loc, QList<QString> varNames, * @param[in] num
QList<int> valueType, QList<void*> values); * @param[in] xtype x
* @param[in] x x
bool isVectorComponent(QString name, QString& vecName, QString& comp); * @param[in] ytype y
* @param[in] y y
vtkDataArray* generateScalarArray(QString varName, int num, int type,void* va); * @param[in] ztype z
* @param[in] z z
vtkDataArray* generateVectorArray(QString varName, int num, * @since 2.5.0
int xtype, void * x,int ytype, void* y, int ztype, void* z); */
vtkDataArray* generateVectorArray(QString varName, int num, int xtype, void* x, int ytype,
void* y, int ztype, void* z);
protected: protected:
vtkMultiBlockDataSet* _root{}; /**
int _fileIndex{ -1 }, _baseIndex{ -1 }, _zoneIndex{ -1 }; * @brief
bool _isStructedGrid{ false }; */
int _dim{ 2 }; vtkMultiBlockDataSet* _root{};
vtkDataSet* _dataSet{}; /**
QString _zoneName; * @brief CGNS
*/
int _fileIndex{ -1 };
/**
* @brief base
*/
int _baseIndex{ -1 };
/**
* @brief zone
*/
int _zoneIndex{ -1 };
/**
* @brief
*/
bool _isStructedGrid{ false };
/**
* @brief
*/
int _dim{ 2 };
vtkDataSet* _dataSet{};
QString _zoneName;
QVector<VPoint> _vertexList{}; /**
* @brief
* @since 2.5.0
*/
QVector<VPoint> _vertexList{};
}; };
#endif #endif

View File

@ -1,234 +1,288 @@
#include "FCGNSReader.h" #include "FCGNSReader.h"
#include "Common/DebugLogger.h"
#include "FCGNSStructureZoneReader.h"
#include "FCGNSUnStructureZoneReader.h"
#include <cgns_io.h>
#include <cgnslib.h>
#include <QFile>
#include <vtkDemandDrivenPipeline.h>
#include <vtkInformation.h> #include <vtkInformation.h>
#include <vtkInformationVector.h> #include <vtkInformationVector.h>
#include <vtkDemandDrivenPipeline.h>
#include <vtkStreamingDemandDrivenPipeline.h>
#include <vtkMultiBlockDataSet.h> #include <vtkMultiBlockDataSet.h>
#include <vtkSetGet.h> #include <vtkSetGet.h>
#include <QFile> #include <vtkStreamingDemandDrivenPipeline.h>
#include <cgnslib.h>
#include <cgns_io.h>
#include "FCGNSUnStructureZoneReader.h"
#include "FCGNSStructureZoneReader.h"
FCGNSReader* FCGNSReader::New() FCGNSReader* FCGNSReader::New()
{ {
auto reader = new FCGNSReader; auto reader = new FCGNSReader;
reader->InitializeObjectBase(); reader->InitializeObjectBase();
return reader; return reader;
} }
void FCGNSReader::PrintSelf(ostream& os, vtkIndent indent) void FCGNSReader::PrintSelf(ostream& os, vtkIndent indent)
{ {
Q_UNUSED(os) Q_UNUSED(os)
Q_UNUSED(indent) Q_UNUSED(indent)
} }
FCGNSReader::FCGNSReader() FCGNSReader::FCGNSReader()
{ {
this->SetNumberOfInputPorts(0); this->SetNumberOfInputPorts(0);
this->SetNumberOfOutputPorts(1); this->SetNumberOfOutputPorts(1);
this->FileName = nullptr; this->FileName = nullptr;
} }
FCGNSReader::~FCGNSReader() FCGNSReader::~FCGNSReader() {}
void FCGNSReader::readZone(int fileIndex, int baseIndex, int zoneIndex,
vtkMultiBlockDataSet* output)
{ {
// 读取zonetypeStructured 或 Unstructured
CGNS_ENUMT(ZoneType_t) zonetype;
if(CG_OK != cg_zone_type(fileIndex, baseIndex, zoneIndex, &zonetype)){
DebugError("Failed to read zone(index = %d) type\n", zoneIndex);
return;
}
if(zonetype == CGNS_ENUMV(Structured)) {
FCGNSStructeGridReader r(output);
r.setInfo(fileIndex, baseIndex, zoneIndex);
r.setReadBC(_readBC);
r.read();
} else if(zonetype == CGNS_ENUMV(Unstructured)) {
FCGNSUnStructeGridReader r(output);
r.setInfo(fileIndex, baseIndex, zoneIndex);
r.read();
}
} }
void FCGNSReader::readZone(int fileIndex, int baseIndex, int zoneIndex, vtkMultiBlockDataSet* output) int FCGNSReader::ProcessRequest(vtkInformation* request, vtkInformationVector** inputVector,
vtkInformationVector* outputVector)
{ {
CGNS_ENUMT(ZoneType_t) zonetype; if(request->Has(vtkDemandDrivenPipeline::REQUEST_INFORMATION())) {
if (CG_OK != cg_zone_type(fileIndex, baseIndex, zoneIndex, &zonetype)) return this->RequestInformation(request, inputVector, outputVector);
return ; }
if(request->Has(vtkStreamingDemandDrivenPipeline::REQUEST_UPDATE_EXTENT())) {
if (zonetype == CGNS_ENUMV(Structured)) return this->RequestUpdateExtent(request, inputVector, outputVector);
{ }
FCGNSStructeGridReader r(output); if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA())) {
r.setInfo(fileIndex, baseIndex, zoneIndex); return this->RequestData(request, inputVector, outputVector);
r.setReadBC(_readBC); }
r.read(); return this->Superclass::ProcessRequest(request, inputVector, outputVector);
}
else if (zonetype == CGNS_ENUMV(Unstructured))
{
FCGNSUnStructeGridReader r(output);
r.setInfo(fileIndex, baseIndex, zoneIndex);
r.read();
}
} }
int FCGNSReader::ProcessRequest(vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector) int FCGNSReader::RequestData(vtkInformation*, vtkInformationVector**,
vtkInformationVector* outputVector)
{ {
if (request->Has(vtkDemandDrivenPipeline::REQUEST_INFORMATION())) auto output = vtkMultiBlockDataSet::GetData(outputVector);
{
return this->RequestInformation(request, inputVector,
outputVector);
}
if (request->Has(
vtkStreamingDemandDrivenPipeline::REQUEST_UPDATE_EXTENT()))
{
return this->RequestUpdateExtent(request, inputVector,
outputVector);
}
if (request->Has(vtkDemandDrivenPipeline::REQUEST_DATA()))
{
return this->RequestData(request, inputVector, outputVector);
}
return this->Superclass::ProcessRequest(request, inputVector,
outputVector);
}
int FCGNSReader::RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector) bool ok = canReadFile();
{ if(!ok) {
auto output = vtkMultiBlockDataSet::GetData(outputVector); return 0;
}
bool ok = canReadFile(); // 打开文件
if (!ok) return 0; int currentFileIndex = 0;
if(CG_OK != cg_open(FileName, CG_MODE_READ, &currentFileIndex)) {
DebugError("Failed to open file %s\n", FileName);
return 0;
} else {
DebugInfo("Success to open file %s\n", FileName);
}
int currentFileIndex = 0; // 获取CGNS数据库的单库CGNSBase_t的数量一般为1
if (cg_open(FileName, CG_MODE_READ, &currentFileIndex)) int nBase = 0;
{ if(CG_OK != cg_nbases(currentFileIndex, &nBase)) {
return 0; DebugError("Failed to get number of base\n");
} return 0;
}
int nBase = 0; // 遍历读取zonebase和zone节点的索引都是从1开始的
if (cg_nbases(currentFileIndex, &nBase)) for(int ibase = 1; ibase <= nBase; ++ibase) {
{ int zone_node_number = 0;
return 0; if(CG_OK != cg_nzones(currentFileIndex, ibase, &zone_node_number)) {
} return false;
}
for (int ibase = 1; ibase <= nBase; ++ibase) for(int izone = 1; izone <= zone_node_number; ++izone) {
{ readZone(currentFileIndex, ibase, izone, output);
int zone_node_number = 0; }
if (cg_nzones(currentFileIndex, ibase, &zone_node_number)) }
{ // 关闭文件
return false; cg_close(currentFileIndex);
} return 1;
for (int izone = 1; izone <= zone_node_number; ++izone)
{
readZone(currentFileIndex, ibase, izone, output);
}
}
cgio_close_file(currentFileIndex);
return 1;
} }
bool FCGNSReader::canReadFile() bool FCGNSReader::canReadFile()
{ {
int cgioFile; int cgioFile;
int ierr = 1; bool ierr = true;
double rootNodeId; double rootNodeId;
double childId; double childId;
float FileVersion = 0.0; float FileVersion = 0.0;
int intFileVersion = 0; int intFileVersion = 0;
char dataType[CGIO_MAX_DATATYPE_LENGTH + 1]; char dataType[CGIO_MAX_DATATYPE_LENGTH + 1];
char errmsg[CGIO_MAX_ERROR_LENGTH + 1]; char errmsg[CGIO_MAX_ERROR_LENGTH + 1];
int ndim = 0; int ndim = 0;
cgsize_t dimVals[12]; cgsize_t dimVals[12];
int fileType = CG_FILE_NONE; int fileType = CGIO_FILE_NONE;
char* fileTypeStr = new char[20];
if (cgio_open_file(FileName, CG_MODE_READ, CG_FILE_NONE, &cgioFile) != CG_OK) // 检查文件文件名以确定它是否是有效的数据库
{ auto result = cgio_check_file(FileName, &fileType);
cgio_error_message(errmsg); if(CGIO_ERR_NONE != result || CGIO_FILE_NONE == fileType) {
vtkErrorMacro(<< "vtkCGNSReader::CanReadFile : " << errmsg); DebugError("%s is a invalid database!\n", FileName);
return 0; return false;
} } else {
DebugInfo("Check database: %s?\tpass!\n", FileName);
}
cgio_get_root_id(cgioFile, &rootNodeId); // 确定当前库是否支持fileType给出的数据库类型
cgio_get_file_type(cgioFile, &fileType); // 始终支持CGIO_FILE_ADF;如果库是用HDF5构建的则支持CGIO_FILE_HDF5;在32位模式下构建时支持CGIO_FILE_ADF2。
result = cgio_is_supported(fileType);
switch(fileType) {
case CGIO_FILE_ADF:
strcpy(fileTypeStr, "CGIO_FILE_ADF");
break;
case CGIO_FILE_HDF5:
strcpy(fileTypeStr, "CGIO_FILE_HDF5");
break;
case CGIO_FILE_ADF2:
strcpy(fileTypeStr, "CGIO_FILE_ADF2");
break;
case CGIO_FILE_NONE:
strcpy(fileTypeStr, "CGIO_FILE_NONE");
break;
default:
fileTypeStr = "Unknown";
break;
}
if(CGIO_ERR_FILE_TYPE == result) {
DebugError("FileType: %s is not support!\n", fileTypeStr);
return false;
} else {
DebugInfo("FileType: support by library?\tyes!\n");
}
if (cgio_get_node_id(cgioFile, rootNodeId, "CGNSLibraryVersion", &childId)) // 打开数据库设置数据库标识cgioFile用于后续操作
{ if(cgio_open_file(FileName, CG_MODE_READ, fileType, &cgioFile) != CG_OK) {
cgio_error_message(errmsg); cgio_error_message(errmsg);
vtkErrorMacro(<< "vtkCGNSReader::CanReadFile : " << errmsg); DebugError("Failed to open file %s, error: %s\n", FileName, errmsg);
ierr = 0; return 0;
goto CanReadError; } else {
} DebugInfo("Success to open file %s, identifier = %d\n", FileName, cgioFile);
}
if (cgio_get_data_type(cgioFile, childId, dataType)) // 获取数据库中根节点的标识
{ if(CG_OK != cgio_get_root_id(cgioFile, &rootNodeId)) {
vtkErrorMacro(<< "CGNS Version data type"); DebugError("Failed to get root node identifier of database(%d)\n", cgioFile);
ierr = 0; goto CloseDataBase;
goto CanReadError; } else {
} DebugInfo("Success to get root node identifier of database(%d), identifier = %d\n",
cgioFile, rootNodeId);
}
if (cgio_get_dimensions(cgioFile, childId, &ndim, dimVals)) // 为什么还要获取一次fileType
{ // cgio_get_file_type(cgioFile, &fileType);
vtkErrorMacro(<< "cgio_get_dimensions");
ierr = 0;
goto CanReadError;
}
// check data type // 获取生成文件的CGNS动态库版本
if (strcmp(dataType, "R4") != 0) if(CG_OK != cgio_get_node_id(cgioFile, rootNodeId, "CGNSLibraryVersion", &childId)) {
{ cgio_error_message(errmsg);
vtkErrorMacro(<< "Unexpected data type for CGNS-Library-Version=" << dataType); DebugError("Failed to get CGNSLibraryVersion node, error: %s\n", errmsg);
ierr = 0; ierr = false;
goto CanReadError; goto CloseDataBase;
} } else {
DebugInfo("Success to get CGNSLibraryVersion node, identifier = %f\n", childId);
}
// check data dim // 获取CGNSLibraryVersion节点的数据类型 "MT", "I4", "I8", "U4", "U8", "R4", "C1", "B1"
if ((ndim != 1) || (dimVals[0] != 1)) // "MT" 不包含数据的空节点
{ // "I4" 32位整数(4字节)
vtkDebugMacro(<< "Wrong data dimension for CGNS-Library-Version"); // "I8" 64位整数(8字节)
ierr = 0; // "U4" 32位无符号整数(4字节)
goto CanReadError; // "U8" 64位无符号整数(8字节)
} // "R4" 32位实数(4字节)
// "R8" 64位实数(8字节)
// "C1" 字符
// "B1" 无符号字节
if(CG_OK != cgio_get_data_type(cgioFile, childId, dataType)) {
cgio_error_message(errmsg);
DebugError("Failed to get CGNSLibraryVersion value type, error: %s\n", errmsg);
ierr = false;
goto CloseDataBase;
} else {
DebugInfo("Success to get CGNSLibraryVersion value type: %s\n", dataType);
}
// read data // 获取CGNSLibraryVersion节点的数据的维度
if (cgio_read_all_data_type(cgioFile, childId, "R4", &FileVersion)) if(CG_OK != cgio_get_dimensions(cgioFile, childId, &ndim, dimVals)) {
{ cgio_error_message(errmsg);
vtkErrorMacro(<< "read CGNS version number"); DebugError("Failed to get CGNSLibraryVersion value dimensions, error: %s\n", errmsg);
ierr = 0; ierr = false;
goto CanReadError; goto CloseDataBase;
} } else {
DebugInfo("Success to get CGNSLibraryVersion value dimensions, num of dimensions: %d\n",
ndim);
}
// Check that the library version is at least as recent as the one used // 检查CGNSLibraryVersion节点的数据类型float参考cg_version函数http://cgns.github.io/CGNS_docs_current/midlevel/fileops.html
// to create the file being read if(strcmp(dataType, "R4") != 0) {
DebugError("Unexpected data type for CGNS library version: %s\n", dataType);
ierr = false;
goto CloseDataBase;
}
intFileVersion = static_cast<int>(FileVersion * 1000 + 0.5); // 检查CGNSLibraryVersion节点的数据的维度
if((ndim != 1) || (dimVals[0] != 1)) {
DebugError("Invalid data dimension for CGNS library version\n");
ierr = false;
goto CloseDataBase;
}
if (intFileVersion > CGNS_VERSION) // 读取CGNSLibraryVersion节点的数据
{ if(cgio_read_all_data_type(cgioFile, childId, "R4", &FileVersion)) {
// This code allows reading version newer than the lib, DebugError("An error occurred reading the CGNS library version\n");
// as long as the 1st digit of the versions are equal ierr = false;
if ((intFileVersion / 1000) > (CGNS_VERSION / 1000)) goto CloseDataBase;
{ } else {
vtkErrorMacro(<< "The file " << FileName DebugInfo("CGNS library version: %f\n", FileVersion);
<< " was written with a more recent version" }
"of the CGNS library. You must update your CGNS"
"library before trying to read this file.");
ierr = 0;
}
// warn only if different in second digit
if ((intFileVersion / 100) > (CGNS_VERSION / 100))
{
vtkWarningMacro(<< "The file being read is more recent"
"than the CGNS library used");
}
}
if ((intFileVersion / 10) < 255)
{
vtkWarningMacro(<< "The file being read was written with an old version"
"of the CGNS library. Please update your file"
"to a more recent version.");
}
vtkDebugMacro(<< "FileVersion=" << FileVersion << "\n");
CanReadError: // 检测生成CGNS文件的库版本号是否比当前版本FastCAE使用的CGNS库版本更新
cgio_close_file(cgioFile); intFileVersion = static_cast<int>(FileVersion * 1000 + 0.5);
return ierr ? true : false;
if(intFileVersion > CGNS_VERSION) {
// 主版本号一样的,可以读取
if(floor(intFileVersion / 1000) > floor(CGNS_VERSION / 1000)) {
DebugError("The file %s was written with a more newer version of the CGNS library\n",
FileName);
ierr = false;
}
// warn only if different in second digit
if((intFileVersion / 100) > (CGNS_VERSION / 100)) {
vtkWarningMacro(<< "The file being read is more recent"
"than the CGNS library used");
}
}
if((intFileVersion / 10) < 255) {
vtkWarningMacro(<< "The file being read was written with an old version"
"of the CGNS library. Please update your file"
"to a more recent version.");
}
CloseDataBase:
cgio_close_file(cgioFile);
return ierr;
} }
void FCGNSReader::setReadBC(bool read) void FCGNSReader::setReadBC(bool read)
{ {
_readBC = read; _readBC = read;
this->Modified(); this->Modified();
} }
bool FCGNSReader::isReadBC() bool FCGNSReader::isReadBC()
{ {
return _readBC; return _readBC;
} }

View File

@ -3,36 +3,49 @@
#include <vtkMultiBlockDataSetAlgorithm.h> #include <vtkMultiBlockDataSetAlgorithm.h>
class FCGNSReader : public vtkMultiBlockDataSetAlgorithm class FCGNSReader : public vtkMultiBlockDataSetAlgorithm {
{
public: public:
static FCGNSReader* New(); static FCGNSReader* New();
vtkTypeMacro(FCGNSReader, vtkMultiBlockDataSetAlgorithm); vtkTypeMacro(FCGNSReader, vtkMultiBlockDataSetAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent) override; void PrintSelf(ostream& os, vtkIndent indent) override;
vtkSetStringMacro(FileName); /**@name Getter和Setter宏
vtkGetStringMacro(FileName); * setter/gettervtkSetMacro(FileName, char*)/vtkGetMacro(FileName, char*)
* @{
*/
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
//@}
int ProcessRequest(vtkInformation* request, vtkInformationVector** inputVector,
vtkInformationVector* outputVector) override;
int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
int ProcessRequest(vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector); /**
int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*); * @brief CGNS
*/
bool canReadFile();
bool canReadFile(); void setReadBC(bool read);
void setReadBC(bool read); bool isReadBC();
bool isReadBC();
private: private:
FCGNSReader(); FCGNSReader();
~FCGNSReader(); ~FCGNSReader();
/**
void readZone(int fileIndex, int baseIndex, int zoneIndex, vtkMultiBlockDataSet* output); * @brief CGNSzone
* @param[in] fileIndex
* @param[in] baseIndex base1
* @param[in] zoneIndex zone1
* @param[out] output
* @since 2.5.0
*/
void readZone(int fileIndex, int baseIndex, int zoneIndex, vtkMultiBlockDataSet* output);
protected: protected:
char* FileName; char* FileName;
bool _readBC{true}; bool _readBC{ true };
}; };
#endif #endif

View File

@ -1,245 +1,219 @@
#include "FCGNSStructureZoneReader.h" #include "FCGNSStructureZoneReader.h"
#include <vtkStructuredGrid.h>
#include <vtkMultiBlockDataSet.h>
#include <vtkInformation.h>
#include <vtkDataSetWriter.h>
#include <vtkPointData.h>
#include <QDebug>
#include <cgnstypes.h>
#include <cgnslib.h>
#include <cgns_io.h>
#include <vtkFloatArray.h>
#include <vtkDoubleArray.h>
#include <vtkInformationStringKey.h>
#include <vtkNew.h>
#include "PostRenderData/Macros.hxx" #include "PostRenderData/Macros.hxx"
#include <cgns_io.h>
#include <cgnslib.h>
#include <cgnstypes.h>
#include <vtkDataSetWriter.h>
#include <vtkDoubleArray.h>
#include <vtkFloatArray.h>
#include <vtkInformation.h>
#include <vtkInformationStringKey.h>
#include <vtkMultiBlockDataSet.h>
#include <vtkNew.h>
#include <vtkPointData.h>
#include <vtkStructuredGrid.h>
FCGNSStructeGridReader::FCGNSStructeGridReader(vtkMultiBlockDataSet* root) FCGNSStructeGridReader::FCGNSStructeGridReader(vtkMultiBlockDataSet* root)
:FCGNSGridReaderBase(root) : FCGNSGridReaderBase(root)
{ {
_isStructedGrid = true; _isStructedGrid = true;
} }
void FCGNSStructeGridReader::read() void FCGNSStructeGridReader::read()
{ {
char zone_name[33] = { 0 }; char zone_name[33] = { 0 };
cgsize_t zoneSize[3][3] = { 0 }; cgsize_t zoneSize[3][3] = { 0 };
int OK = cg_zone_read(_fileIndex, _baseIndex, _zoneIndex, zone_name, zoneSize[0]); int OK = cg_zone_read(_fileIndex, _baseIndex, _zoneIndex, zone_name, zoneSize[0]);
if (CG_OK != OK) return; if(CG_OK != OK)
_zoneName = QString(zone_name); return;
_zoneName = QString(zone_name);
int dim{ 0 };
OK = cg_ncoords(_fileIndex, _baseIndex, _zoneIndex, &dim);
if (CG_OK != OK) return;
cgsize_t read_range[2][3] = { 0 }; int dim{ 0 };
for (int ijk = 0; ijk < 3; ++ijk) OK = cg_ncoords(_fileIndex, _baseIndex, _zoneIndex, &dim);
{ if(CG_OK != OK)
read_range[0][ijk] = 1; return;
read_range[1][ijk] = zoneSize[0][ijk];
}
int nVertex = zoneSize[0][0] * zoneSize[0][1] * zoneSize[0][2];
this->readCoordinate(dim, nVertex, read_range[0], read_range[1]);
vtkStructuredGrid* sGrid = vtkStructuredGrid::New(); cgsize_t read_range[2][3] = { 0 };
sGrid->SetDimensions(zoneSize[0][0], zoneSize[0][1], zoneSize[0][2]); for(int ijk = 0; ijk < 3; ++ijk) {
// vtkNew<vtkPoints> points; //形成整体点集合 read_range[0][ijk] = 1;
DecCreVTKSmartPtr(vtkPoints,points) read_range[1][ijk] = zoneSize[0][ijk];
}
for (int i = 0; i < _vertexList.size(); ++i) int nVertex = zoneSize[0][0] * zoneSize[0][1] * zoneSize[0][2];
{ this->readCoordinate(dim, nVertex, read_range[0], read_range[1]);
VPoint po = _vertexList.at(i);
points->InsertNextPoint(po.x, po.y, po.z);
}
sGrid->SetPoints(points); vtkStructuredGrid* sGrid = vtkStructuredGrid::New();
sGrid->SetDimensions(zoneSize[0][0], zoneSize[0][1], zoneSize[0][2]);
// vtkNew<vtkPoints> points; //形成整体点集合
DecCreVTKSmartPtr(vtkPoints, points)
this->readFlowSolution(sGrid); for(int i = 0; i < _vertexList.size(); ++i)
{
VPoint po = _vertexList.at(i);
points->InsertNextPoint(po.x, po.y, po.z);
}
if(_readBC) sGrid->SetPoints(points);
this->readBC();
this->spllitSection(sGrid); this->readFlowSolution(sGrid);
if(_readBC)
this->readBC();
this->spllitSection(sGrid);
} }
void FCGNSStructeGridReader::setReadBC(bool r) void FCGNSStructeGridReader::setReadBC(bool r)
{ {
_readBC = r; _readBC = r;
} }
bool FCGNSStructeGridReader::isReadBC() bool FCGNSStructeGridReader::isReadBC()
{ {
return _readBC; return _readBC;
} }
void FCGNSStructeGridReader::readBC() void FCGNSStructeGridReader::readBC()
{ {
int nbc{ 0 }; int nbc{ 0 };
int OK = cg_nbocos(_fileIndex, _baseIndex, _zoneIndex, &nbc); int OK = cg_nbocos(_fileIndex, _baseIndex, _zoneIndex, &nbc);
if (CG_OK != OK) return; if(CG_OK != OK)
for (int ibc = 1; ibc <= nbc; ++ibc) return;
{ for(int ibc = 1; ibc <= nbc; ++ibc) {
CGNS_ENUMT(BCType_t) bctype; CGNS_ENUMT(BCType_t) bctype;
CGNS_ENUMT(PointSetType_t) ptype; CGNS_ENUMT(PointSetType_t) ptype;
//CGNS_ENUMT(GridLocation_t) location; // CGNS_ENUMT(GridLocation_t) location;
CGNS_ENUMT(DataType_t) datatype; CGNS_ENUMT(DataType_t) datatype;
char bc_name[33] = { 0 }; char bc_name[33] = { 0 };
int nrmlindex[3] = { 0 }; int nrmlindex[3] = { 0 };
cgsize_t np = 0, is = 0; cgsize_t np = 0, is = 0;
int ib = 0; int ib = 0;
OK = cg_boco_info(_fileIndex,_baseIndex, _zoneIndex, ibc, bc_name, &bctype, OK = cg_boco_info(_fileIndex, _baseIndex, _zoneIndex, ibc, bc_name, &bctype, &ptype, &np,
&ptype, &np, nrmlindex, &is, &datatype, &ib); nrmlindex, &is, &datatype, &ib);
if (CG_OK != OK) continue; if(CG_OK != OK)
if(ptype != CGNS_ENUMV(PointRange)) continue; continue;
if(ptype != CGNS_ENUMV(PointRange))
continue;
cgsize_t * pnpnts = new cgsize_t[6]; cgsize_t* pnpnts = new cgsize_t[6];
OK = cg_boco_read(_fileIndex, _baseIndex, _zoneIndex, ibc, pnpnts, NULL); OK = cg_boco_read(_fileIndex, _baseIndex, _zoneIndex, ibc, pnpnts, NULL);
if(OK != CG_OK) continue; if(OK != CG_OK)
continue;
BCInfo info(bc_name, pnpnts,bctype);
_bcList.append(info);
}
BCInfo info(bc_name, pnpnts, bctype);
_bcList.append(info);
}
} }
void FCGNSStructeGridReader::spllitSection(vtkStructuredGrid* gird) void FCGNSStructeGridReader::spllitSection(vtkStructuredGrid* gird)
{ {
int n = _root->GetNumberOfBlocks(); int n = _root->GetNumberOfBlocks();
_root->SetBlock(n, gird); _root->SetBlock(n, gird);
QString NameBC = _zoneName + "!|||!" + "None"; QString NameBC = _zoneName + "!|||!" + "None";
_root->GetMetaData(n)->Set(vtkCompositeDataSet::NAME(), NameBC.toLatin1().data()); _root->GetMetaData(n)->Set(vtkCompositeDataSet::NAME(), NameBC.toLatin1().data());
extractBCs(gird); extractBCs(gird);
} }
void FCGNSStructeGridReader::extractBCs(vtkStructuredGrid *grid) void FCGNSStructeGridReader::extractBCs(vtkStructuredGrid* grid)
{ {
qDebug() << "BC in zone: " << _zoneName; int dim[3] = { 0 };
int dim[3] = { 0 }; grid->GetDimensions(dim);
grid->GetDimensions(dim); for(BCInfo bc : _bcList) {
for (BCInfo bc: _bcList) QList<int> ptIndexs;
{ for(int k = bc.kMin; k <= bc.kMax; ++k) {
QList<int> ptIndexs; for(int j = bc.jMin; j <= bc.jMax; ++j) {
for (int k = bc.kMin; k <= bc.kMax; ++k) for(int i = bc.iMin; i <= bc.iMax; ++i) {
{ int index = dim[0] * dim[1] * k + dim[0] * j + i;
for (int j = bc.jMin; j <= bc.jMax; ++j) ptIndexs.append(index);
{ }
for (int i = bc.iMin; i <= bc.iMax; ++i) }
{ }
int index = dim[0]*dim[1]*k+ dim[0]*j+i; extractBCGrid(grid, &bc, ptIndexs);
ptIndexs.append(index); }
}
}
}
extractBCGrid(grid, &bc, ptIndexs);
}
} }
void FCGNSStructeGridReader::extractBCGrid(vtkStructuredGrid* grid, BCInfo* info,
void FCGNSStructeGridReader::extractBCGrid(vtkStructuredGrid* grid, BCInfo* info, QList<int> & indexs) QList<int>& indexs)
{ {
vtkStructuredGrid* bcMesh = vtkStructuredGrid::New(); vtkStructuredGrid* bcMesh = vtkStructuredGrid::New();
const int iDim = info->iMax - info->iMin + 1; const int iDim = info->iMax - info->iMin + 1;
const int jDim = info->jMax - info->jMin + 1; const int jDim = info->jMax - info->jMin + 1;
const int kDim = info->kMax - info->kMin + 1; const int kDim = info->kMax - info->kMin + 1;
bcMesh->SetDimensions(iDim, jDim, kDim); bcMesh->SetDimensions(iDim, jDim, kDim);
qDebug() << indexs.size(); DecCreVTKSmartPtr(vtkPoints, points) for(int index : indexs)
qDebug() << iDim * jDim*kDim; {
double* coor = grid->GetPoint(index);
points->InsertNextPoint(coor);
}
bcMesh->SetPoints(points);
// vtkNew<vtkPoints> points; vtkPointData* pointData = grid->GetPointData();
DecCreVTKSmartPtr(vtkPoints,points) const int nArray = pointData->GetNumberOfArrays();
for (int index : indexs)
{
double* coor = grid->GetPoint(index);
points->InsertNextPoint(coor);
}
bcMesh->SetPoints(points);
vtkPointData* pointData = grid->GetPointData(); for(int iArray = 0; iArray < nArray; ++iArray) {
const int nArray = pointData->GetNumberOfArrays(); const char* name = pointData->GetArrayName(iArray);
vtkDataArray* array = pointData->GetArray(name);
const int nComp = array->GetNumberOfComponents();
for (int iArray = 0; iArray < nArray; ++iArray) vtkDataArray* copyArray = nullptr;
{
const char* name = pointData->GetArrayName(iArray);
vtkDataArray* array = pointData->GetArray(name);
const int nComp = array->GetNumberOfComponents();
vtkDataArray* copyArray = nullptr; if(array->IsA("vtkDoubleArray"))
copyArray = vtkDoubleArray::New();
if (array->IsA("vtkDoubleArray")) else if(array->IsA("vtkFloatArray"))
copyArray = vtkDoubleArray::New(); copyArray = vtkFloatArray::New();
else if (array->IsA("vtkFloatArray")) if(copyArray == nullptr)
copyArray = vtkFloatArray::New(); continue;
if(copyArray == nullptr) continue; copyArray->SetName(name);
copyArray->SetName(name);
copyArray->SetNumberOfComponents(nComp); copyArray->SetNumberOfComponents(nComp);
for (int ic = 0; ic < nComp; ++ic) for(int ic = 0; ic < nComp; ++ic) {
{ const char* arrName = array->GetComponentName(ic);
const char* arrName= array->GetComponentName(ic); copyArray->SetComponentName(ic, arrName);
copyArray->SetComponentName(ic, arrName); }
} // copyArray->Resize(indexs.size());
// copyArray->Resize(indexs.size()); for(int in = 0; in < indexs.size(); ++in) {
for (int in =0;in<indexs.size(); ++in) int index = indexs.at(in);
{ for(int ic = 0; ic < nComp; ++ic) {
int index = indexs.at(in); double v = array->GetComponent(index, ic);
for (int ic = 0; ic < nComp; ++ic) copyArray->InsertComponent(in, ic, v);
{ }
double v = array->GetComponent(index, ic); }
copyArray->InsertComponent(in, ic, v); bcMesh->GetPointData()->AddArray(copyArray);
} }
}
bcMesh->GetPointData()->AddArray(copyArray);
} int n = _root->GetNumberOfBlocks();
_root->SetBlock(n, bcMesh);
int n = _root->GetNumberOfBlocks(); QString NameBC = info->name + "!|||!" + info->BCType;
_root->SetBlock(n, bcMesh); _root->GetMetaData(n)->Set(vtkCompositeDataSet::NAME(), NameBC.toLatin1().data());
QString NameBC = info->name + "!|||!" + info->BCType;
_root->GetMetaData(n)->Set(vtkCompositeDataSet::NAME(), NameBC.toLatin1().data());
} }
QString GetBCType(QString name, int bcType) QString GetBCType(QString name, int bcType)
{ {
QString sBCType{ "None" }; QString sBCType{ "None" };
QString sName = name.toLower(); QString sName = name.toLower();
if (bcType == 7) if(bcType == 7) {
{ sBCType = "Far";
sBCType = "Far"; return sBCType;
return sBCType; } else if(bcType >= 16 && bcType <= 17) {
} sBCType = "Sym";
else if (bcType >= 16 && bcType <= 17) return sBCType;
{ } else if(bcType >= 20 && bcType <= 24) {
sBCType = "Sym"; sBCType = "Wall";
return sBCType; return sBCType;
} } else if(sName.contains("far")) {
else if (bcType >= 20 && bcType <= 24) sBCType = "Far";
{ return sBCType;
sBCType = "Wall"; } else if(sName.contains("sym")) {
return sBCType; sBCType = "Sym";
} return sBCType;
else if(sName.contains("far")) } else if(sName.contains("wall")) {
{ sBCType = "Wall";
sBCType = "Far"; return sBCType;
return sBCType; }
} return sBCType;
else if (sName.contains("sym"))
{
sBCType = "Sym";
return sBCType;
}
else if (sName.contains("wall"))
{
sBCType = "Wall";
return sBCType;
}
return sBCType;
} }

View File

@ -1,23 +1,25 @@
#include "FCGNSUnStructureZoneReader.h" #include "FCGNSUnStructureZoneReader.h"
#include <vtkMultiBlockDataSet.h>
#include <cgnstypes.h> #include "Common/DebugLogger.h"
#include <cgns_io.h>
#include <cgnslib.h>
#include <QDebug>
#include <vtkUnstructuredGrid.h>
#include <vtkNew.h>
#include <vtkPoints.h>
#include <vtkDataSetWriter.h>
#include <vtkSelectionNode.h>
#include <vtkSelection.h>
#include <vtkExtractSelection.h>
#include <vtkIdTypeArray.h>
#include <vtkMultiBlockDataSet.h>
#include <vtkInformation.h>
#include <vtkCellType.h>
#include "PostRenderData/Macros.hxx" #include "PostRenderData/Macros.hxx"
FCGNSUnStructeGridReader::FCGNSUnStructeGridReader(vtkMultiBlockDataSet *root) #include <cgns_io.h>
#include <cgnslib.h>
#include <cgnstypes.h>
#include <QDebug>
#include <vtkCellType.h>
#include <vtkDataSetWriter.h>
#include <vtkExtractSelection.h>
#include <vtkIdTypeArray.h>
#include <vtkInformation.h>
#include <vtkMultiBlockDataSet.h>
#include <vtkNew.h>
#include <vtkPoints.h>
#include <vtkSelection.h>
#include <vtkSelectionNode.h>
#include <vtkUnstructuredGrid.h>
FCGNSUnStructeGridReader::FCGNSUnStructeGridReader(vtkMultiBlockDataSet* root)
: FCGNSGridReaderBase(root) : FCGNSGridReaderBase(root)
{ {
_isStructedGrid = false; _isStructedGrid = false;
@ -25,188 +27,361 @@ FCGNSUnStructeGridReader::FCGNSUnStructeGridReader(vtkMultiBlockDataSet *root)
void FCGNSUnStructeGridReader::read() void FCGNSUnStructeGridReader::read()
{ {
char zone_name[33] = {0}; if(_fileIndex < 0 || _baseIndex < 0 || _zoneIndex < 0) {
cgsize_t zoneSize[3] = {0, 0, 0}; DebugError("Invalid zone(file: %d, base: %d, zone: %d)\n", _fileIndex, _baseIndex,
int OK = cg_zone_read(_fileIndex, _baseIndex, _zoneIndex, zone_name, zoneSize); _zoneIndex);
if (CG_OK != OK)
return; return;
_zoneName = QString(zone_name); }
DebugInfo("Start reading zone(file: %d, base: %d, zone: %d)...\n", _fileIndex, _baseIndex,
_zoneIndex);
// 读取zone信息
char zone_name[33] = { 0 };
// 在非结构化网格数据中zonesize的元素分别对应NVertex, NCell, NBoundVertex
cgsize_t zoneSize[3] = { 0, 0, 0 };
auto result = cg_zone_read(_fileIndex, _baseIndex, _zoneIndex, zone_name, zoneSize);
if(CG_OK != result) {
DebugError("Failed to read zone(index = %d) information\n", _zoneIndex);
return;
} else {
DebugInfo("NVertex = %d, NCell = %d, NBoundVertex = %d\n", zoneSize[0], zoneSize[1],
zoneSize[2]);
}
_zoneName = QString(zone_name);
const int nVertex = zoneSize[0], nCell = zoneSize[1], nBoundary = zoneSize[2]; const int nVertex = zoneSize[0], nCell = zoneSize[1], nBoundary = zoneSize[2];
int dim{0}; // 坐标数组的个数
OK = cg_ncoords(_fileIndex, _baseIndex, _zoneIndex, &dim); int dim{ 0 };
if (CG_OK != OK) result = cg_ncoords(_fileIndex, _baseIndex, _zoneIndex, &dim);
if(CG_OK != result) {
DebugError("Failed to read number of coordinate arrays for zone %d\n", _zoneIndex);
return; return;
} else {
DebugInfo("Number of coordinate arrays for zone %d is %d\n", _zoneIndex, dim);
}
// vtkUnstructuredGrid* unsGrid = vtkUnstructuredGrid::New(); // 需要读取全部数据所以range=[1,nVertex]
cgsize_t read_range[2][3] = { 0 };
DecCreVTKSmartPtr(vtkUnstructuredGrid, unsGrid) for(int ijk = 0; ijk < 3; ++ijk) {
cgsize_t read_range[2][3] = {0};
for (int ijk = 0; ijk < 3; ++ijk)
{
read_range[0][ijk] = 1; read_range[0][ijk] = 1;
read_range[1][ijk] = nVertex; read_range[1][ijk] = nVertex;
} }
// 读取坐标数据信息
this->readCoordinate(dim, nVertex, read_range[0], read_range[1]); this->readCoordinate(dim, nVertex, read_range[0], read_range[1]);
if(_vertexList.size() != nVertex) {
DecCreVTKSmartPtr(vtkPoints, points) //形成整体点集合 DebugError("Failed to read coordinate arrays for zone %d\n", _zoneIndex);
for (int i = 0; i < _vertexList.size(); ++i) return;
{
VPoint po = _vertexList.at(i);
points->InsertNextPoint(po.x, po.y, po.z);
} }
// 准备vtk数据并插入点
DecCreVTKSmartPtr(vtkPoints, points);
for(int i = 0; i < _vertexList.size(); ++i) {
auto po = _vertexList.at(i);
points->InsertNextPoint(po.x, po.y, po.z);
}
DecCreVTKSmartPtr(vtkUnstructuredGrid, unsGrid);
unsGrid->SetPoints(points); unsGrid->SetPoints(points);
int nSection{0}; // 获取网格单元的节点数量
cg_nsections(_fileIndex, _baseIndex, _zoneIndex, &nSection); int nSection{ 0 };
result = cg_nsections(_fileIndex, _baseIndex, _zoneIndex, &nSection);
if(CG_OK != result) {
DebugError("Failed to get number of element sections\n");
return;
} else {
DebugInfo("Number of element sections is %d\n", nSection);
}
QList<int> sectionList = sectionOrder(nSection); QList<int> sectionList = sectionOrder(nSection);
if(sectionList.size() == 0) {
DebugError("Failed to order sections\n");
return;
}
for (int iSection : sectionList) for(int iSection : sectionList) {
{ char sectionName[33] = { 0 };
char sectionName[33] = {0};
cgsize_t istart = 0, iend = 0; cgsize_t istart = 0, iend = 0;
int nbndry = 0, iparent_flag = 0; int nbndry = 0, iparent_flag = 0;
CGNS_ENUMT(ElementType_t) CGNS_ENUMT(ElementType_t)
itype; itype;
OK = cg_section_read(_fileIndex, _baseIndex, _zoneIndex, iSection, sectionName, &itype, &istart, &iend, &nbndry, &iparent_flag); result = cg_section_read(_fileIndex, _baseIndex, _zoneIndex, iSection, sectionName, &itype,
const int ncellCount = iend - istart + 1; &istart, &iend, &nbndry, &iparent_flag);
qDebug() << QString(sectionName) << istart << iend; if(CG_OK != result) {
cgsize_t elementDataSize = 0; DebugError("Failed to read element section: %d\n", iSection);
OK = cg_ElementDataSize(_fileIndex, _baseIndex, _zoneIndex, iSection, &elementDataSize); return;
if (CG_OK != 0) } else {
continue; DebugInfo("element section: %s, element type: %d, first element index: %d, last "
cgsize_t *elements = new cgsize_t[elementDataSize]; "element index: %d\n",
OK = cg_elements_read(_fileIndex, _baseIndex, _zoneIndex, iSection, elements, NULL); sectionName, static_cast<int>(itype), istart, iend);
if (CG_OK != 0) }
continue;
FSection section(QString(sectionName), istart, iend); //记录section const int ncellCount = iend - istart + 1;
cgsize_t elementDataSize = 0;
result = cg_ElementDataSize(_fileIndex, _baseIndex, _zoneIndex, iSection, &elementDataSize);
if(CG_OK != result) {
DebugError("Failed to get size of element connectivity data array\n");
return;
}
cgsize_t* elements = new cgsize_t[elementDataSize];
cgsize_t* connectOffset = nullptr;
/** */
if(itype == CGNS_ENUMT(MIXED)) {
connectOffset = new cgsize_t[elementDataSize];
result = cg_poly_elements_read(_fileIndex, _baseIndex, _zoneIndex, iSection, elements,
connectOffset, NULL);
} else {
// 只能读取固定大小的单元类型
result = cg_elements_read(_fileIndex, _baseIndex, _zoneIndex, iSection, elements, NULL);
}
if(CG_OK != result) {
DebugError("Failed to read fixed size element data, error: %s\n", cg_get_error());
return;
}
FSection section(QString(sectionName), istart, iend);
_sections.append(section); _sections.append(section);
this->addCells(unsGrid, ncellCount, itype, elements); this->addCells(unsGrid, ncellCount, itype, elements, connectOffset);
} }
this->readFlowSolution(unsGrid); this->readFlowSolution(unsGrid);
this->spllitSection(unsGrid); this->spllitSection(unsGrid);
} }
void FCGNSUnStructeGridReader::addCells(vtkUnstructuredGrid *grid, int ncell, CGNS_ENUMT(ElementType_t) type, cgsize_t *elements) /**
* typehttp://cgns.github.io/CGNS_docs_current/sids/conv.html#unstructgrid
* ElementTypeNull, ElementTypeUserDefined, NODE, BAR_2, BAR_3, TRI_3, TRI_6, QUAD_4, QUAD_8,
* QUAD_9, TETRA_4, TETRA_10, PYRA_5, PYRA_14, PENTA_6, PENTA_15, PENTA_18, HEXA_8, HEXA_20,
* HEXA_27, MIXED, PYRA_13, NGON_n, NFACE_n, BAR_4, TRI_9, TRI_10, QUAD_12, QUAD_16, TETRA_16,
* TETRA_20, PYRA_21, PYRA_29, PYRA_30, PENTA_24, PENTA_38, PENTA_40, HEXA_32, HEXA_56, HEXA_64,
* BAR_5, TRI_12, TRI_15, QUAD_P4_16, QUAD_25, TETRA_22, TETRA_34, TETRA_35, PYRA_P4_29, PYRA_50,
* PYRA_55, PENTA_33, PENTA_66, PENTA_75, HEXA_44, HEXA_98, HEXA_125
*
* CGNS1VTK0
*/
void FCGNSUnStructeGridReader::addCells(vtkUnstructuredGrid* grid, int ncell,
CGNS_ENUMT(ElementType_t) type, cgsize_t* elements,
cgsize_t* connectOffset)
{ {
if (CGNS_ENUMT(TRI_3) == type) //三角形 if(CGNS_ENUMT(TRI_3) == type) // 三角形
{ {
for(int iCnt = 0; iCnt < ncell; ++iCnt) {
for (int iCnt = 0; iCnt < ncell; ++iCnt) addTri3Cell(grid, elements[iCnt * 3 + 0] - 1, elements[iCnt * 3 + 1] - 1,
{ elements[iCnt * 3 + 2] - 1);
vtkSmartPointer<vtkIdList> idlist = vtkSmartPointer<vtkIdList>::New();
idlist->InsertNextId(elements[iCnt * 3 + 0] - 1);
idlist->InsertNextId(elements[iCnt * 3 + 1] - 1);
idlist->InsertNextId(elements[iCnt * 3 + 2] - 1);
grid->InsertNextCell(VTK_TRIANGLE, idlist);
} }
} } else if(CGNS_ENUMT(BAR_2) == type) // 二节点梁单元
else if (CGNS_ENUMT(BAR_2) == type) //二节点梁单元
{ {
for (int iCnt = 0; iCnt < ncell; ++iCnt) for(int iCnt = 0; iCnt < ncell; ++iCnt) {
{ addBar2Cell(grid, elements[iCnt * 2 + 0] - 1, elements[iCnt * 2 + 1] - 1);
vtkSmartPointer<vtkIdList> idlist = vtkSmartPointer<vtkIdList>::New();
idlist->InsertNextId(elements[iCnt * 2 + 0] - 1);
idlist->InsertNextId(elements[iCnt * 2 + 1] - 1);
grid->InsertNextCell(VTK_LINE, idlist);
} }
} } else if(CGNS_ENUMT(TETRA_4) == type) // 四节点四面体
else if (CGNS_ENUMT(TETRA_4) == type) //四节点四面体
{ {
for (int iCnt = 0; iCnt < ncell; ++iCnt) for(int iCnt = 0; iCnt < ncell; ++iCnt) {
{ addTetra4Cell(grid, elements[iCnt * 4 + 0] - 1, elements[iCnt * 4 + 1] - 1,
vtkSmartPointer<vtkIdList> idlist = vtkSmartPointer<vtkIdList>::New(); elements[iCnt * 4 + 2] - 1, elements[iCnt * 4 + 3] - 1);
idlist->InsertNextId(elements[iCnt * 4 + 0] - 1);
idlist->InsertNextId(elements[iCnt * 4 + 1] - 1);
idlist->InsertNextId(elements[iCnt * 4 + 2] - 1);
idlist->InsertNextId(elements[iCnt * 4 + 3] - 1);
grid->InsertNextCell(VTK_TETRA, idlist);
} }
} } else if(CGNS_ENUMT(QUAD_4) == type) // 四节点四边形
else if (CGNS_ENUMT(QUAD_4) == type) //四节点四边形
{ {
for (int iCnt = 0; iCnt < ncell; ++iCnt) for(int iCnt = 0; iCnt < ncell; ++iCnt) {
{ addQuad4Cell(grid, elements[iCnt * 4 + 0] - 1, elements[iCnt * 4 + 1] - 1,
vtkSmartPointer<vtkIdList> idlist = vtkSmartPointer<vtkIdList>::New(); elements[iCnt * 4 + 2] - 1, elements[iCnt * 4 + 3] - 1);
idlist->InsertNextId(elements[iCnt * 4 + 0] - 1);
idlist->InsertNextId(elements[iCnt * 4 + 1] - 1);
idlist->InsertNextId(elements[iCnt * 4 + 2] - 1);
idlist->InsertNextId(elements[iCnt * 4 + 3] - 1);
grid->InsertNextCell(VTK_QUAD, idlist);
} }
} } else if(CGNS_ENUMT(HEXA_8) == type) // 八节点六面体
else if (CGNS_ENUMT(HEXA_8) == type) //八节点六面体
{ {
for (int iCnt = 0; iCnt < ncell; ++iCnt) for(int iCnt = 0; iCnt < ncell; ++iCnt) {
{ addHexa8Cell(grid, elements[iCnt * 8 + 0] - 1, elements[iCnt * 8 + 1] - 1,
vtkSmartPointer<vtkIdList> idlist = vtkSmartPointer<vtkIdList>::New(); elements[iCnt * 8 + 2] - 1, elements[iCnt * 8 + 3] - 1,
idlist->InsertNextId(elements[iCnt * 8 + 0] - 1); elements[iCnt * 8 + 4] - 1, elements[iCnt * 8 + 5] - 1,
idlist->InsertNextId(elements[iCnt * 8 + 1] - 1); elements[iCnt * 8 + 6] - 1, elements[iCnt * 8 + 7] - 1);
idlist->InsertNextId(elements[iCnt * 8 + 2] - 1);
idlist->InsertNextId(elements[iCnt * 8 + 3] - 1);
idlist->InsertNextId(elements[iCnt * 8 + 4] - 1);
idlist->InsertNextId(elements[iCnt * 8 + 5] - 1);
idlist->InsertNextId(elements[iCnt * 8 + 6] - 1);
idlist->InsertNextId(elements[iCnt * 8 + 7] - 1);
grid->InsertNextCell(VTK_HEXAHEDRON, idlist);
} }
} } else if(CGNS_ENUMT(PENTA_6) == type) // 六节点三棱柱
else if (CGNS_ENUMT(PENTA_6) == type) //六节点三棱柱
{ {
for (int iCnt = 0; iCnt < ncell; ++iCnt) for(int iCnt = 0; iCnt < ncell; ++iCnt) {
{ addPenta6Cell(grid, elements[iCnt * 6 + 0] - 1, elements[iCnt * 6 + 1] - 1,
vtkSmartPointer<vtkIdList> idlist = vtkSmartPointer<vtkIdList>::New(); elements[iCnt * 6 + 2] - 1, elements[iCnt * 6 + 3] - 1,
idlist->InsertNextId(elements[iCnt * 6 + 0] - 1); elements[iCnt * 6 + 4] - 1, elements[iCnt * 6 + 5] - 1);
idlist->InsertNextId(elements[iCnt * 6 + 1] - 1);
idlist->InsertNextId(elements[iCnt * 6 + 2] - 1);
idlist->InsertNextId(elements[iCnt * 6 + 3] - 1);
idlist->InsertNextId(elements[iCnt * 6 + 4] - 1);
idlist->InsertNextId(elements[iCnt * 6 + 5] - 1);
grid->InsertNextCell(VTK_WEDGE, idlist);
} }
} } else if(CGNS_ENUMT(PYRA_5) == type) // 金字塔单元
else if (CGNS_ENUMT(PYRA_5) == type) //金字塔单元
{ {
for (int iCnt = 0; iCnt < ncell; ++iCnt) for(int iCnt = 0; iCnt < ncell; ++iCnt) {
{ addPyra5Cell(grid, elements[iCnt * 5 + 0] - 1, elements[iCnt * 5 + 1] - 1,
vtkSmartPointer<vtkIdList> idlist = vtkSmartPointer<vtkIdList>::New(); elements[iCnt * 5 + 2] - 1, elements[iCnt * 5 + 3] - 1,
idlist->InsertNextId(elements[iCnt * 5 + 0] - 1); elements[iCnt * 5 + 4] - 1);
idlist->InsertNextId(elements[iCnt * 5 + 1] - 1);
idlist->InsertNextId(elements[iCnt * 5 + 2] - 1);
idlist->InsertNextId(elements[iCnt * 5 + 3] - 1);
idlist->InsertNextId(elements[iCnt * 5 + 4] - 1);
// idlist->InsertNextId(elements[iCnt * 5 + 0] - 1);
grid->InsertNextCell(VTK_PYRAMID, idlist);
} }
} else if(CGNS_ENUMT(MIXED) == type && connectOffset != nullptr) { // 混合单元
int iCnt = 0;
int iEle = 0;
while((iCnt < ncell) && (iEle == connectOffset[iCnt])) {
// 混合单元比其他单元多存储一个值,即第一个值存储单元类型,后面是节点编号
auto type = elements[iEle];
switch(type) {
case CGNS_ENUMT(BAR_2): {
auto id1 = elements[++iEle] - 1;
auto id2 = elements[++iEle] - 1;
addBar2Cell(grid, id1, id2);
} break;
case CGNS_ENUMT(TRI_3): {
auto id1 = elements[++iEle] - 1;
auto id2 = elements[++iEle] - 1;
auto id3 = elements[++iEle] - 1;
addTri3Cell(grid, id1, id2, id3);
} break;
case CGNS_ENUMT(TETRA_4): {
auto id1 = elements[++iEle] - 1;
auto id2 = elements[++iEle] - 1;
auto id3 = elements[++iEle] - 1;
auto id4 = elements[++iEle] - 1;
addTetra4Cell(grid, id1, id2, id3, id4);
} break;
case CGNS_ENUMT(QUAD_4): {
auto id1 = elements[++iEle] - 1;
auto id2 = elements[++iEle] - 1;
auto id3 = elements[++iEle] - 1;
auto id4 = elements[++iEle] - 1;
addQuad4Cell(grid, id1, id2, id3, id4);
} break;
case CGNS_ENUMT(HEXA_8): {
auto id1 = elements[++iEle] - 1;
auto id2 = elements[++iEle] - 1;
auto id3 = elements[++iEle] - 1;
auto id4 = elements[++iEle] - 1;
auto id5 = elements[++iEle] - 1;
auto id6 = elements[++iEle] - 1;
auto id7 = elements[++iEle] - 1;
auto id8 = elements[++iEle] - 1;
addHexa8Cell(grid, id1, id2, id3, id4, id5, id6, id7, id8);
} break;
case CGNS_ENUMT(PENTA_6): {
auto id1 = elements[++iEle] - 1;
auto id2 = elements[++iEle] - 1;
auto id3 = elements[++iEle] - 1;
auto id4 = elements[++iEle] - 1;
auto id5 = elements[++iEle] - 1;
auto id6 = elements[++iEle] - 1;
addPenta6Cell(grid, id1, id2, id3, id4, id5, id6);
} break;
case CGNS_ENUMT(PYRA_5): {
auto id1 = elements[++iEle] - 1;
auto id2 = elements[++iEle] - 1;
auto id3 = elements[++iEle] - 1;
auto id4 = elements[++iEle] - 1;
auto id5 = elements[++iEle] - 1;
addPyra5Cell(grid, id1, id2, id3, id4, id5);
} break;
default:
DebugError("Unsupported element type was found: %d\n", static_cast<int>(type));
break;
}
++iEle;
++iCnt;
}
} else {
DebugError("Unsupported element type was found: %d\n", static_cast<int>(type));
} }
} }
void FCGNSUnStructeGridReader::spllitSection(vtkUnstructuredGrid *gird) vtkIdType FCGNSUnStructeGridReader::addBar2Cell(vtkUnstructuredGrid* grid, vtkIdType id1,
vtkIdType id2)
{ {
if (_sections.isEmpty()) auto idlist = vtkSmartPointer<vtkIdList>::New();
{ idlist->InsertNextId(id1);
idlist->InsertNextId(id2);
return grid->InsertNextCell(VTK_LINE, idlist);
}
vtkIdType FCGNSUnStructeGridReader::addTri3Cell(vtkUnstructuredGrid* grid, vtkIdType id1,
vtkIdType id2, vtkIdType id3)
{
auto idlist = vtkSmartPointer<vtkIdList>::New();
idlist->InsertNextId(id1);
idlist->InsertNextId(id2);
idlist->InsertNextId(id3);
return grid->InsertNextCell(VTK_TRIANGLE, idlist);
}
vtkIdType FCGNSUnStructeGridReader::addTetra4Cell(vtkUnstructuredGrid* grid, vtkIdType id1,
vtkIdType id2, vtkIdType id3, vtkIdType id4)
{
auto idlist = vtkSmartPointer<vtkIdList>::New();
idlist->InsertNextId(id1);
idlist->InsertNextId(id2);
idlist->InsertNextId(id3);
idlist->InsertNextId(id4);
return grid->InsertNextCell(VTK_TETRA, idlist);
}
vtkIdType FCGNSUnStructeGridReader::addQuad4Cell(vtkUnstructuredGrid* grid, vtkIdType id1,
vtkIdType id2, vtkIdType id3, vtkIdType id4)
{
auto idlist = vtkSmartPointer<vtkIdList>::New();
idlist->InsertNextId(id1);
idlist->InsertNextId(id2);
idlist->InsertNextId(id3);
idlist->InsertNextId(id4);
return grid->InsertNextCell(VTK_QUAD, idlist);
}
vtkIdType FCGNSUnStructeGridReader::addHexa8Cell(vtkUnstructuredGrid* grid, vtkIdType id1,
vtkIdType id2, vtkIdType id3, vtkIdType id4,
vtkIdType id5, vtkIdType id6, vtkIdType id7,
vtkIdType id8)
{
auto idlist = vtkSmartPointer<vtkIdList>::New();
idlist->InsertNextId(id1);
idlist->InsertNextId(id2);
idlist->InsertNextId(id3);
idlist->InsertNextId(id4);
idlist->InsertNextId(id5);
idlist->InsertNextId(id6);
return grid->InsertNextCell(VTK_WEDGE, idlist);
}
vtkIdType FCGNSUnStructeGridReader::addPenta6Cell(vtkUnstructuredGrid* grid, vtkIdType id1,
vtkIdType id2, vtkIdType id3, vtkIdType id4,
vtkIdType id5, vtkIdType id6)
{
auto idlist = vtkSmartPointer<vtkIdList>::New();
idlist->InsertNextId(id1);
idlist->InsertNextId(id2);
idlist->InsertNextId(id3);
idlist->InsertNextId(id4);
idlist->InsertNextId(id5);
idlist->InsertNextId(id6);
return grid->InsertNextCell(VTK_WEDGE, idlist);
}
vtkIdType FCGNSUnStructeGridReader::addPyra5Cell(vtkUnstructuredGrid* grid, vtkIdType id1,
vtkIdType id2, vtkIdType id3, vtkIdType id4,
vtkIdType id5)
{
auto idlist = vtkSmartPointer<vtkIdList>::New();
idlist->InsertNextId(id1);
idlist->InsertNextId(id2);
idlist->InsertNextId(id3);
idlist->InsertNextId(id4);
idlist->InsertNextId(id5);
return grid->InsertNextCell(VTK_PYRAMID, idlist);
}
void FCGNSUnStructeGridReader::spllitSection(vtkUnstructuredGrid* gird)
{
if(_sections.isEmpty()) {
int n = _root->GetNumberOfBlocks(); int n = _root->GetNumberOfBlocks();
_root->SetBlock(n, gird); _root->SetBlock(n, gird);
QString NameBC = _zoneName + "!|||!" + "None"; QString NameBC = _zoneName + "!|||!" + "None";
_root->GetMetaData(n)->Set(vtkCompositeDataSet::NAME(), NameBC.toLatin1().data()); _root->GetMetaData(n)->Set(vtkCompositeDataSet::NAME(), NameBC.toLatin1().data());
} }
for (FSection sec : _sections) for(FSection sec : _sections) {
{
// vtkNew<vtkIdTypeArray> ids; // vtkNew<vtkIdTypeArray> ids;
DecCreVTKSmartPtr(vtkIdTypeArray, ids) DecCreVTKSmartPtr(vtkIdTypeArray, ids) ids->SetNumberOfComponents(1);
ids->SetNumberOfComponents(1); for(int i = sec._begin - 1; i <= sec._end - 1; ++i)
for (int i = sec._begin - 1; i <= sec._end - 1; ++i)
ids->InsertNextValue(i); ids->InsertNextValue(i);
// vtkNew<vtkSelectionNode> node; // vtkNew<vtkSelectionNode> node;
DecCreVTKSmartPtr(vtkSelectionNode, node) DecCreVTKSmartPtr(vtkSelectionNode, node) node->SetFieldType(vtkSelectionNode::CELL);
node->SetFieldType(vtkSelectionNode::CELL);
node->SetContentType(vtkSelectionNode::INDICES); node->SetContentType(vtkSelectionNode::INDICES);
node->SetSelectionList(ids); node->SetSelectionList(ids);
@ -215,57 +390,58 @@ void FCGNSUnStructeGridReader::spllitSection(vtkUnstructuredGrid *gird)
section->AddNode(node); section->AddNode(node);
// vtkNew<vtkExtractSelection> exctra; // vtkNew<vtkExtractSelection> exctra;
DecCreVTKSmartPtr(vtkExtractSelection, exctra) DecCreVTKSmartPtr(vtkExtractSelection, exctra) exctra->SetInputData(0, gird);
exctra->SetInputData(0, gird);
exctra->SetInputData(1, section); exctra->SetInputData(1, section);
exctra->Update(); exctra->Update();
auto secGrid = exctra->GetOutput(); auto secGrid = exctra->GetOutput();
int n = _root->GetNumberOfBlocks(); int n = _root->GetNumberOfBlocks();
_root->SetBlock(n, secGrid); _root->SetBlock(n, secGrid);
QString NameBC = sec._name + "!|||!" + "None"; QString NameBC = sec._name + "!|||!" + "None";
_root->GetMetaData(n)->Set(vtkCompositeDataSet::NAME(), NameBC.toLatin1().data()); _root->GetMetaData(n)->Set(vtkCompositeDataSet::NAME(), NameBC.toLatin1().data());
// _root->GetMetaData(n)->Set(vtkCompositeDataSet::NAME(), sec._name.toLatin1().data()); // _root->GetMetaData(n)->Set(vtkCompositeDataSet::NAME(),
// sec._name.toLatin1().data());
} }
} }
QList<int> FCGNSUnStructeGridReader::sectionOrder(int nsec) QList<int> FCGNSUnStructeGridReader::sectionOrder(int nsec)
{ {
struct sectionInfo struct sectionInfo {
{
sectionInfo(int index, int s) sectionInfo(int index, int s)
{ {
Index = index; Index = index;
startNum = s; startNum = s;
} }
int Index; int Index;
int startNum; int startNum;
}; };
auto compare = [](const sectionInfo &s1, const sectionInfo &s2) -> bool auto compare = [](const sectionInfo& s1, const sectionInfo& s2) -> bool {
{
return s1.startNum <= s2.startNum; return s1.startNum <= s2.startNum;
}; };
QList<sectionInfo> secs; QList<sectionInfo> secs;
for (int iSection = 1; iSection <= nsec; ++iSection) for(int iSection = 1; iSection <= nsec; ++iSection) {
{ char sectionName[33] = { 0 };
char sectionName[33] = {0};
cgsize_t istart = 0, iend = 0; cgsize_t istart = 0, iend = 0;
int nbndry = 0, iparent_flag = 0; // 最后一个边界单元的索引如果单元未排序则设为0
CGNS_ENUMT(ElementType_t) int nbndry = 0;
itype; // 指示父级数据是否定义如果存在则为1否则为0
int OK = cg_section_read(_fileIndex, _baseIndex, _zoneIndex, iSection, sectionName, &itype, &istart, &iend, &nbndry, &iparent_flag); int iparent_flag = 0;
if (OK != CG_OK) CGNS_ENUMT(ElementType_t) itype;
continue; int result = cg_section_read(_fileIndex, _baseIndex, _zoneIndex, iSection, sectionName,
&itype, &istart, &iend, &nbndry, &iparent_flag);
if(result != CG_OK) {
DebugError("Failed to get info for an element section\n");
return {};
}
sectionInfo sinfo(iSection, istart); sectionInfo sinfo(iSection, istart);
secs.append(sinfo); secs.append(sinfo);
} }
std::sort(secs.begin(), secs.end(), compare); std::sort(secs.begin(), secs.end(), compare);
QList<int> secOrders; QList<int> secOrders;
for (auto s : secs) for(auto s : secs) {
{
secOrders.append(s.Index); secOrders.append(s.Index);
} }
return secOrders; return secOrders;

View File

@ -2,38 +2,81 @@
#define _FCGNSUNSTRUCTEGRIDREADER_H__ #define _FCGNSUNSTRUCTEGRIDREADER_H__
#include "FCGNSGridReaderBase.h" #include "FCGNSGridReaderBase.h"
#include <cgnslib.h>
#include <cgnstypes.h>
#include <QList> #include <QList>
#include <QString> #include <QString>
#include <cgnstypes.h>
#include <cgnslib.h>
#include <vtkUnstructuredGrid.h> #include <vtkUnstructuredGrid.h>
struct FSection /**
{ * @brief section
FSection(QString name, int b, int e) :_name(name),_begin(b), _end(e){} * @since 2.5.0
QString _name{}; */
int _begin{0}; struct FSection {
int _end{0}; FSection(QString name, int b, int e)
: _name(name)
, _begin(b)
, _end(e)
{
}
/**
* @brief
* @since 2.5.0
*/
QString _name{};
/**
* @brief
* @since 2.5.0
*/
int _begin{ 0 };
/**
* @brief
* @since 2.5.0
*/
int _end{ 0 };
}; };
class FCGNSUnStructeGridReader :public FCGNSGridReaderBase class FCGNSUnStructeGridReader : public FCGNSGridReaderBase {
{
public: public:
FCGNSUnStructeGridReader(vtkMultiBlockDataSet* root); FCGNSUnStructeGridReader(vtkMultiBlockDataSet* root);
~FCGNSUnStructeGridReader() = default; ~FCGNSUnStructeGridReader() = default;
void read() override; void read() override;
private: private:
void addCells(vtkUnstructuredGrid* grid, int ncell, CGNS_ENUMT(ElementType_t) type, cgsize_t* eles); /**
* @brief vtkUnstructuredGrid
* @param[out] grid vtkUnstructuredGrid
* @param[in] ncell
* @param[in] type
* @param[in] eles
* @param[in] connectOffset type=mixed
* @since 2.5.0
*/
void addCells(vtkUnstructuredGrid* grid, int ncell, CGNS_ENUMT(ElementType_t) type,
cgsize_t* eles, cgsize_t* connectOffset);
void spllitSection(vtkUnstructuredGrid* gird); vtkIdType addBar2Cell(vtkUnstructuredGrid* grid, vtkIdType id1, vtkIdType id2);
vtkIdType addTri3Cell(vtkUnstructuredGrid* grid, vtkIdType id1, vtkIdType id2, vtkIdType id3);
vtkIdType addTetra4Cell(vtkUnstructuredGrid* grid, vtkIdType id1, vtkIdType id2, vtkIdType id3,
vtkIdType id4);
vtkIdType addQuad4Cell(vtkUnstructuredGrid* grid, vtkIdType id1, vtkIdType id2, vtkIdType id3,
vtkIdType id4);
vtkIdType addHexa8Cell(vtkUnstructuredGrid* grid, vtkIdType id1, vtkIdType id2, vtkIdType id3,
vtkIdType id4, vtkIdType id5, vtkIdType id6, vtkIdType id7,
vtkIdType id8);
vtkIdType addPenta6Cell(vtkUnstructuredGrid* grid, vtkIdType id1, vtkIdType id2, vtkIdType id3,
vtkIdType id4, vtkIdType id5, vtkIdType id6);
vtkIdType addPyra5Cell(vtkUnstructuredGrid* grid, vtkIdType id1, vtkIdType id2, vtkIdType id3,
vtkIdType id4, vtkIdType id5);
QList<int> sectionOrder(int nsec); void spllitSection(vtkUnstructuredGrid* gird);
QList<int> sectionOrder(int nsec);
private: private:
QList<FSection> _sections; QList<FSection> _sections;
}; };
#endif #endif

View File

@ -1,17 +1,19 @@
#include "DialogCreateCalculate.h" #include "DialogCreateCalculate.h"
#include "ui_DialogCreateCalculate.h"
#include "PostTreeWidget.h"
#include "RenderDirector.h"
#include "PostRenderData/RenderDataObject.h"
#include "PostRenderData/CalculateRenderDataAlg.h" #include "PostRenderData/CalculateRenderDataAlg.h"
#include "PostRenderData/RenderDataObject.h"
#include "PostTreeWidget.h"
#include "PythonModule/PyAgent.h" #include "PythonModule/PyAgent.h"
#include "RenderDirector.h"
#include "ui_DialogCreateCalculate.h"
#include <QMenu> #include <QMenu>
#include <QMessageBox> #include <QMessageBox>
namespace Post namespace Post {
{ CreateCalculateDialog::CreateCalculateDialog(PostTreeWidget* tree, QWidget* parent)
CreateCalculateDialog::CreateCalculateDialog(PostTreeWidget *tree, QWidget *parent) : PostFunctionDialogBase(tree, parent), : PostFunctionDialogBase(tree, parent)
_ui(new Ui::CreateCalculateDialog) , _ui(new Ui::CreateCalculateDialog)
{ {
_ui->setupUi(this); _ui->setupUi(this);
init(); init();
@ -37,14 +39,13 @@ namespace Post
void CreateCalculateDialog::accept() void CreateCalculateDialog::accept()
{ {
if (_parentObject == nullptr) if(_parentObject == nullptr) {
{
QMessageBox::warning(this, tr("Warning!"), tr("No selected data!")); QMessageBox::warning(this, tr("Warning!"), tr("No selected data!"));
return; return;
} }
QString name = _ui->nameLineEdit->text(); QString name = _ui->nameLineEdit->text();
QString exp = _ui->expressionLineEdit->text().trimmed(); QString exp = _ui->expressionLineEdit->text().trimmed();
QStringList codes{}; QStringList codes{};
@ -54,9 +55,9 @@ namespace Post
codes += QString("calculate.setUsePointData(%1)").arg(_isPoint); codes += QString("calculate.setUsePointData(%1)").arg(_isPoint);
codes += QString("calculate.setFunction('%1')").arg(exp); codes += QString("calculate.setFunction('%1')").arg(exp);
for (auto v : _scalarList) for(auto v : _scalarList)
codes += QString("calculate.appendScalar('%1')").arg(v); codes += QString("calculate.appendScalar('%1')").arg(v);
for (auto v : _vectorList) for(auto v : _vectorList)
codes += QString("calculate.appendVector('%1')").arg(v); codes += QString("calculate.appendVector('%1')").arg(v);
codes += this->getSeletedDataCode("calculate"); codes += this->getSeletedDataCode("calculate");
@ -83,7 +84,8 @@ namespace Post
// alg->update(); // alg->update();
// //
// _parentObject->appendSubObjects(alg); // _parentObject->appendSubObjects(alg);
// RenderDirector::getInstance()->renderDataObjectToWindow(alg, _parentObject->getRenderWinID()); // RenderDirector::getInstance()->renderDataObjectToWindow(alg,
// _parentObject->getRenderWinID());
// _tree->updatePostTree(); // _tree->updatePostTree();
QDialog::accept(); QDialog::accept();
this->close(); this->close();
@ -97,46 +99,38 @@ namespace Post
void CreateCalculateDialog::updateDisplayInterface() void CreateCalculateDialog::updateDisplayInterface()
{ {
if (_parentObject == nullptr) if(_parentObject == nullptr)
return; return;
QAction *action = nullptr; QAction* action = nullptr;
_scalarMenu->clear(); _scalarMenu->clear();
_vectorMenu->clear(); _vectorMenu->clear();
auto createMenu = [=, &action](QStringList arrayList) auto createMenu = [=, &action](QStringList arrayList) {
{ for(auto array : arrayList) {
for (auto array : arrayList) auto type = _parentObject->variableType(1, array);
{ if(type == "scalar") {
int type = _parentObject->variableType(1, array);
if (type == 1)
{
action = _scalarMenu->addAction(array); action = _scalarMenu->addAction(array);
connect(action, &QAction::triggered, [=] connect(action, &QAction::triggered, [=] {
{
setExpression(array);
if (!_scalarList.contains(array))
_scalarList.append(array); });
}
else if (type == 2)
{
action = _vectorMenu->addAction(array);
connect(action, &QAction::triggered, [=]
{
setExpression(array); setExpression(array);
if (!_vectorList.contains(array)) if(!_scalarList.contains(array))
_vectorList.append(array); }); _scalarList.append(array);
});
} else if(type == "vector") {
action = _vectorMenu->addAction(array);
connect(action, &QAction::triggered, [=] {
setExpression(array);
if(!_vectorList.contains(array))
_vectorList.append(array);
});
} }
} }
}; };
if (_isPoint) if(_isPoint) {
{
QStringList pArray = _parentObject->getPointDataArray(); QStringList pArray = _parentObject->getPointDataArray();
createMenu(pArray); createMenu(pArray);
} } else {
else
{
QStringList cArray = _parentObject->getCellDataArray(); QStringList cArray = _parentObject->getCellDataArray();
createMenu(cArray); createMenu(cArray);
} }
@ -343,17 +337,17 @@ namespace Post
{ {
QString exp = _operationList.join(""); QString exp = _operationList.join("");
text.remove(exp); text.remove(exp);
if (text.isEmpty()) if(text.isEmpty())
return; return;
_operationList.append(text); _operationList.append(text);
} }
void CreateCalculateDialog::on_typeComboBox_currentIndexChanged(int index) void CreateCalculateDialog::on_typeComboBox_currentIndexChanged(int index)
{ {
if (index == 0) if(index == 0)
_isPoint = true; _isPoint = true;
else else
_isPoint = false; _isPoint = false;
} }
} } // namespace Post

View File

@ -1,20 +1,19 @@
#include "DialogRenderSetting.h" #include "DialogRenderSetting.h"
#include "ui_DialogRenderSetting.h"
#include "GraphWidget.h" #include "GraphWidget.h"
#include "PostTreeWidget.h" #include "PostInterface/RenderWindowManager.h"
#include "PostRenderData/RenderDataObject.h" #include "PostRenderData/RenderDataObject.h"
#include "PostRenderData/RenderProperty.h" #include "PostRenderData/RenderProperty.h"
#include "PostInterface/RenderWindowManager.h" #include "PostTreeWidget.h"
#include "PythonModule/PyAgent.h" #include "PythonModule/PyAgent.h"
#include "ui_DialogRenderSetting.h"
#include <QColorDialog> #include <QColorDialog>
#include <QHeaderView> #include <QHeaderView>
namespace Post namespace Post {
{ // RenderSettingDialog::RenderSettingDialog(RenderDataObject* obj, int index, QWidget *parent)
// RenderSettingDialog::RenderSettingDialog(RenderDataObject* obj, int index, QWidget *parent) : // : QDialog(parent), _ui(new Ui::RenderSettingDialog), _dataObject(obj)
// QDialog(parent),
// _ui(new Ui::RenderSettingDialog),
// _dataObject(obj)
// { // {
// _ui->setupUi(this); // _ui->setupUi(this);
// this->setWindowFlags(Qt::WindowCloseButtonHint | Qt::WindowStaysOnTopHint); // this->setWindowFlags(Qt::WindowCloseButtonHint | Qt::WindowStaysOnTopHint);
@ -31,15 +30,19 @@ namespace Post
// //
// init(); // init();
// //
// connect(_ui->variableTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(setColorByVariable(QTreeWidgetItem*))); // connect(_ui->variableTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this,
// connect(_ui->transparencyHorizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(setTransparency(const int))); // SLOT(setColorByVariable(QTreeWidgetItem*))); connect(_ui->transparencyHorizontalSlider,
// connect(_ui->transparencySpinBox, SIGNAL(valueChanged(int)), this, SLOT(setTransparency(const int))); // SIGNAL(valueChanged(int)), this, SLOT(setTransparency(const int)));
// connect(_ui->transparencySpinBox, SIGNAL(valueChanged(int)), this,
// SLOT(setTransparency(const int)));
// } // }
RenderSettingDialog::RenderSettingDialog(PostTreeWidget *tree, RenderDataObject *obj, QWidget *parent /*= nullptr*/) : QDialog(parent), RenderSettingDialog::RenderSettingDialog(PostTreeWidget* tree, RenderDataObject* obj,
_ui(new Ui::RenderSettingDialog), QWidget* parent /*= nullptr*/)
_dataObject(obj), : QDialog(parent)
_tree(tree) , _ui(new Ui::RenderSettingDialog)
, _dataObject(obj)
, _tree(tree)
{ {
_ui->setupUi(this); _ui->setupUi(this);
@ -47,7 +50,8 @@ namespace Post
this->setAttribute(Qt::WA_DeleteOnClose); this->setAttribute(Qt::WA_DeleteOnClose);
_ui->variableTreeWidget->header()->setSectionResizeMode(QHeaderView::Stretch); _ui->variableTreeWidget->header()->setSectionResizeMode(QHeaderView::Stretch);
_renderWindow = RenderWindowManager::getInstance()->getRenderWindowByID(_dataObject->getRenderWinID()); _renderWindow =
RenderWindowManager::getInstance()->getRenderWindowByID(_dataObject->getRenderWinID());
init(); init();
} }
@ -59,10 +63,8 @@ namespace Post
void RenderSettingDialog::init() void RenderSettingDialog::init()
{ {
auto initInterfaceUI = [=](RenderProperty* pro) {
auto initInterfaceUI = [=](RenderProperty *pro) double color[3] = { 0 };
{
double color[3] = {0};
pro->getPropertyColor(color); pro->getPropertyColor(color);
_ui->variableColorPushButton->setStyleSheet(QString("background-color: rgb(%1,%2,%3);") _ui->variableColorPushButton->setStyleSheet(QString("background-color: rgb(%1,%2,%3);")
.arg(color[0] * 255) .arg(color[0] * 255)
@ -72,15 +74,12 @@ namespace Post
_ui->transparencyHorizontalSlider->setValue(trans * 100); _ui->transparencyHorizontalSlider->setValue(trans * 100);
_ui->transparencySpinBox->setValue(trans * 100); _ui->transparencySpinBox->setValue(trans * 100);
auto type = pro->getVariableType(); auto type = pro->getVariableType();
if (type == 0) if(type == 0) {
{
_ui->colorBarCheckBox->setChecked(false); _ui->colorBarCheckBox->setChecked(false);
_ui->colorBarCheckBox->setEnabled(false); _ui->colorBarCheckBox->setEnabled(false);
_ui->variableColorCheckBox->setChecked(false); _ui->variableColorCheckBox->setChecked(false);
_ui->variableColorCheckBox->setEnabled(false); _ui->variableColorCheckBox->setEnabled(false);
} } else {
else
{
_ui->colorBarCheckBox->setChecked(pro->getShowColorMap()); _ui->colorBarCheckBox->setChecked(pro->getShowColorMap());
_ui->colorBarCheckBox->setEnabled(true); _ui->colorBarCheckBox->setEnabled(true);
_ui->variableColorCheckBox->setChecked(true); _ui->variableColorCheckBox->setChecked(true);
@ -90,18 +89,14 @@ namespace Post
QMultiHash<int, int> dataList = _tree->getSelectedData(_dataObject); QMultiHash<int, int> dataList = _tree->getSelectedData(_dataObject);
if (dataList.size() > 0) if(dataList.size() > 0) {
{ auto id = dataList.uniqueKeys().at(0);
auto id = dataList.uniqueKeys().at(0);
auto index = dataList.values(id).at(0); auto index = dataList.values(id).at(0);
if (index == -1) if(index == -1) {
{ auto obj = _dataObject->getObjectByID(id);
auto obj = _dataObject->getObjectByID(id);
auto objPro = obj->getPropertyListAt(0); auto objPro = obj->getPropertyListAt(0);
initInterfaceUI(objPro); initInterfaceUI(objPro);
} } else {
else
{
auto objPro = _dataObject->getPropertyListAt(index); auto objPro = _dataObject->getPropertyListAt(index);
initInterfaceUI(objPro); initInterfaceUI(objPro);
} }
@ -112,15 +107,18 @@ namespace Post
initVariableTreeWidget(1, pArrayList); initVariableTreeWidget(1, pArrayList);
initVariableTreeWidget(2, cArrayList); initVariableTreeWidget(2, cArrayList);
connect(_ui->variableTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(setColorByVariable(QTreeWidgetItem *))); connect(_ui->variableTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this,
connect(_ui->transparencyHorizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(setTransparency(const int))); SLOT(setColorByVariable(QTreeWidgetItem*)));
connect(_ui->transparencySpinBox, SIGNAL(valueChanged(int)), this, SLOT(setTransparency(const int))); connect(_ui->transparencyHorizontalSlider, SIGNAL(valueChanged(int)), this,
SLOT(setTransparency(const int)));
connect(_ui->transparencySpinBox, SIGNAL(valueChanged(int)), this,
SLOT(setTransparency(const int)));
} }
void RenderSettingDialog::initVariableTreeWidget(int loc, QStringList arrayList) void RenderSettingDialog::initVariableTreeWidget(int loc, QStringList arrayList)
{ {
QString locName = tr("Point"); QString locName = tr("Point");
if (loc == 2) if(loc == 2)
locName = tr("Cell"); locName = tr("Cell");
// int cType = 1; // int cType = 1;
// int cIndex = -1; // int cIndex = -1;
@ -128,8 +126,7 @@ namespace Post
// //
// getCurrentVariable(cVariable, cType, cIndex); // getCurrentVariable(cVariable, cType, cIndex);
auto createTreeItem = [=](QString name, QString type, int loc, int index = -1) auto createTreeItem = [=](QString name, QString type, int loc, int index = -1) {
{
auto item = new QTreeWidgetItem; auto item = new QTreeWidgetItem;
item->setText(0, name); item->setText(0, name);
item->setText(1, type); item->setText(1, type);
@ -144,23 +141,15 @@ namespace Post
// } // }
}; };
for (auto name : arrayList) for(auto name : arrayList) {
{ const auto vType = _dataObject->variableType(loc, name);
const int vType = _dataObject->variableType(loc, name); if(vType == "scalar") {
if (vType == 0)
;
else if (vType == 1)
{
createTreeItem(name, tr("%1Scalar").arg(locName), loc); createTreeItem(name, tr("%1Scalar").arg(locName), loc);
} } else if(vType == "vector") {
else if (vType == 2)
{
createTreeItem(name, tr("%1Vector-X").arg(locName), loc, 0); createTreeItem(name, tr("%1Vector-X").arg(locName), loc, 0);
createTreeItem(name, tr("%1Vector-Y").arg(locName), loc, 1); createTreeItem(name, tr("%1Vector-Y").arg(locName), loc, 1);
createTreeItem(name, tr("%1Vector-Z").arg(locName), loc, 2); createTreeItem(name, tr("%1Vector-Z").arg(locName), loc, 2);
} } else if(vType == "tensor") {
else if (vType == 3)
{
createTreeItem(name, tr("%1Tensor").arg(locName), loc); createTreeItem(name, tr("%1Tensor").arg(locName), loc);
} }
} }
@ -169,43 +158,40 @@ namespace Post
QString RenderSettingDialog::getVariableType(int loc, int type) QString RenderSettingDialog::getVariableType(int loc, int type)
{ {
QString locName = tr("Point"); QString locName = tr("Point");
if (loc == 1) if(loc == 1)
locName = tr("Cell"); locName = tr("Cell");
QString typeName; QString typeName;
switch (type) switch(type) {
{ case 1:
case 1: typeName = tr("Scalar");
typeName = tr("Scalar"); break;
break; case 2:
case 2: typeName = tr("Vector");
typeName = tr("Vector"); break;
break; case 3:
case 3: typeName = tr("Tensor");
typeName = tr("Tensor"); break;
break; default:
default: break;
break;
} }
if (typeName.isEmpty()) if(typeName.isEmpty())
return typeName; return typeName;
return locName + typeName; return locName + typeName;
} }
void RenderSettingDialog::getCurrentVariable(QString &name, int &loc, int &index) void RenderSettingDialog::getCurrentVariable(QString& name, int& loc, int& index)
{ {
Q_UNUSED(name) Q_UNUSED(name)
Q_UNUSED(loc) Q_UNUSED(loc)
Q_UNUSED(index) Q_UNUSED(index)
// if (_renderProperty == nullptr) // if (_renderProperty == nullptr)
// { // {
// auto pro = _dataObject->getPropertyListAt(_dataObject->getPropertyListCount() - 1); // auto pro = _dataObject->getPropertyListAt(_dataObject->getPropertyListCount() -
// if (pro == nullptr) return; // 1); if (pro == nullptr) return; name = pro->getVariableName(); loc =
// name = pro->getVariableName(); // pro->getVariableType(); index = pro->getComponentIndex();
// loc = pro->getVariableType();
// index = pro->getComponentIndex();
// } // }
// else // else
// { // {
@ -221,25 +207,20 @@ namespace Post
QMultiHash<int, int> dataList = _tree->getSelectedData(_dataObject); QMultiHash<int, int> dataList = _tree->getSelectedData(_dataObject);
for (auto id : dataList.uniqueKeys()) for(auto id : dataList.uniqueKeys()) {
{
auto obj = _dataObject->getObjectByID(id); auto obj = _dataObject->getObjectByID(id);
if (obj == nullptr) if(obj == nullptr)
continue; continue;
for (auto bIndex : dataList.values(id)) for(auto bIndex : dataList.values(id)) {
{ if(bIndex == -1) {
if (bIndex == -1)
{
auto cPro = obj->getPropertyListAt(0); auto cPro = obj->getPropertyListAt(0);
if (cPro == nullptr) if(cPro == nullptr)
continue; continue;
_propertyList.append(cPro); _propertyList.append(cPro);
} } else {
else
{
auto bPro = obj->getPropertyListAt(bIndex); auto bPro = obj->getPropertyListAt(bIndex);
if (bPro == nullptr) if(bPro == nullptr)
continue; continue;
_propertyList.append(bPro); _propertyList.append(bPro);
} }
@ -249,11 +230,10 @@ namespace Post
void RenderSettingDialog::on_variableColorPushButton_clicked() void RenderSettingDialog::on_variableColorPushButton_clicked()
{ {
QColor c = _ui->variableColorPushButton->palette().color(QPalette::Background); QColor c = _ui->variableColorPushButton->palette().color(QPalette::Background);
QColor color = QColorDialog::getColor(c, this); QColor color = QColorDialog::getColor(c, this);
if (color.isValid()) if(color.isValid()) {
{
_ui->variableColorCheckBox->setChecked(false); _ui->variableColorCheckBox->setChecked(false);
_ui->variableColorCheckBox->setEnabled(false); _ui->variableColorCheckBox->setEnabled(false);
_ui->colorBarCheckBox->setChecked(false); _ui->colorBarCheckBox->setChecked(false);
@ -268,17 +248,18 @@ namespace Post
// for (auto pro : _propertyList) // for (auto pro : _propertyList)
// pro->setPropertyColor(color.redF(), color.greenF(), color.blueF()); // pro->setPropertyColor(color.redF(), color.greenF(), color.blueF());
auto dataHash = _tree->getSelectedData(_dataObject); auto dataHash = _tree->getSelectedData(_dataObject);
QStringList codes{}; QStringList codes{};
codes += QString("variablecolor = PostProcess.VariableColor()"); codes += QString("variablecolor = PostProcess.VariableColor()");
codes += QString("variablecolor.setColor(%1,%2,%3)").arg(color.redF()).arg(color.greenF()).arg(color.blueF()); codes += QString("variablecolor.setColor(%1,%2,%3)")
.arg(color.redF())
.arg(color.greenF())
.arg(color.blueF());
for (auto obj : dataHash.uniqueKeys()) for(auto obj : dataHash.uniqueKeys()) {
{
auto blockList = dataHash.values(obj); auto blockList = dataHash.values(obj);
for (auto block : blockList) for(auto block : blockList) {
{
codes += QString("variablecolor.appendBlock(%1,%2)").arg(obj).arg(block); codes += QString("variablecolor.appendBlock(%1,%2)").arg(obj).arg(block);
} }
} }
@ -294,29 +275,29 @@ namespace Post
void RenderSettingDialog::on_variableColorCheckBox_clicked() void RenderSettingDialog::on_variableColorCheckBox_clicked()
{ {
if (!_ui->variableColorCheckBox->isChecked()) if(!_ui->variableColorCheckBox->isChecked()) {
{
_ui->variableColorCheckBox->setEnabled(false); _ui->variableColorCheckBox->setEnabled(false);
_ui->colorBarCheckBox->setChecked(false); _ui->colorBarCheckBox->setChecked(false);
_ui->colorBarCheckBox->setEnabled(false); _ui->colorBarCheckBox->setEnabled(false);
QColor color = _ui->variableColorPushButton->palette().color(QPalette::Background); QColor color = _ui->variableColorPushButton->palette().color(QPalette::Background);
// getRenderPropertyList(); // getRenderPropertyList();
// //
// for (auto pro : _propertyList) // for (auto pro : _propertyList)
// pro->setPropertyColor(color.redF(), color.greenF(), color.blueF()); // pro->setPropertyColor(color.redF(), color.greenF(), color.blueF());
auto dataHash = _tree->getSelectedData(_dataObject); auto dataHash = _tree->getSelectedData(_dataObject);
QStringList codes{}; QStringList codes{};
codes += QString("variablecolor = PostProcess.VariableColor()"); codes += QString("variablecolor = PostProcess.VariableColor()");
codes += QString("variablecolor.setColor(%1,%2,%3)").arg(color.redF()).arg(color.greenF()).arg(color.blueF()); codes += QString("variablecolor.setColor(%1,%2,%3)")
.arg(color.redF())
.arg(color.greenF())
.arg(color.blueF());
for (auto obj : dataHash.uniqueKeys()) for(auto obj : dataHash.uniqueKeys()) {
{
auto blockList = dataHash.values(obj); auto blockList = dataHash.values(obj);
for (auto block : blockList) for(auto block : blockList) {
{
codes += QString("variablecolor.appendBlock(%1,%2)").arg(obj).arg(block); codes += QString("variablecolor.appendBlock(%1,%2)").arg(obj).arg(block);
} }
} }
@ -332,12 +313,11 @@ namespace Post
void RenderSettingDialog::on_colorBarCheckBox_clicked() void RenderSettingDialog::on_colorBarCheckBox_clicked()
{ {
bool show = _ui->colorBarCheckBox->isChecked(); bool show = _ui->colorBarCheckBox->isChecked();
getRenderPropertyList(); getRenderPropertyList();
for (auto pro : _propertyList) for(auto pro : _propertyList)
pro->setShowColorMap(show); pro->setShowColorMap(show);
_renderWindow->reRender(); _renderWindow->reRender();
@ -352,46 +332,44 @@ namespace Post
_ui->transparencyHorizontalSlider->blockSignals(false); _ui->transparencyHorizontalSlider->blockSignals(false);
_ui->transparencySpinBox->blockSignals(false); _ui->transparencySpinBox->blockSignals(false);
if (_dataObject == nullptr) if(_dataObject == nullptr)
return; return;
double trans = (double)value / 100; double trans = (double)value / 100;
getRenderPropertyList(); getRenderPropertyList();
for (auto pro : _propertyList) for(auto pro : _propertyList)
pro->setTransparency(trans); pro->setTransparency(trans);
_renderWindow->reRender(); _renderWindow->reRender();
_tree->updatePostTree(); _tree->updatePostTree();
} }
void RenderSettingDialog::setColorByVariable(QTreeWidgetItem *item) void RenderSettingDialog::setColorByVariable(QTreeWidgetItem* item)
{ {
_ui->variableColorCheckBox->setEnabled(true); _ui->variableColorCheckBox->setEnabled(true);
_ui->variableColorCheckBox->setChecked(true); _ui->variableColorCheckBox->setChecked(true);
_ui->colorBarCheckBox->setEnabled(true); _ui->colorBarCheckBox->setEnabled(true);
QString name = item->text(0); QString name = item->text(0);
int type = item->data(0, Qt::UserRole).toInt(); int type = item->data(0, Qt::UserRole).toInt();
int index = item->data(1, Qt::UserRole).toInt(); int index = item->data(1, Qt::UserRole).toInt();
// getRenderPropertyList(); // getRenderPropertyList();
// //
// for (auto pro : _propertyList) // for (auto pro : _propertyList)
// pro->setCurrentVariable(type, name, index); // pro->setCurrentVariable(type, name, index);
auto dataHash = _tree->getSelectedData(_dataObject); auto dataHash = _tree->getSelectedData(_dataObject);
QStringList codes{}; QStringList codes{};
codes += QString("variablecolor = PostProcess.VariableColor()"); codes += QString("variablecolor = PostProcess.VariableColor()");
codes += QString("variablecolor.selectVariable(%1,'%2',%3)").arg(type).arg(name).arg(index); codes += QString("variablecolor.selectVariable(%1,'%2',%3)").arg(type).arg(name).arg(index);
for (auto obj : dataHash.uniqueKeys()) for(auto obj : dataHash.uniqueKeys()) {
{
auto blockList = dataHash.values(obj); auto blockList = dataHash.values(obj);
for (auto block : blockList) for(auto block : blockList) {
{
codes += QString("variablecolor.appendBlock(%1,%2)").arg(obj).arg(block); codes += QString("variablecolor.appendBlock(%1,%2)").arg(obj).arg(block);
} }
} }
@ -405,4 +383,4 @@ namespace Post
_tree->updatePostTree(); _tree->updatePostTree();
} }
} } // namespace Post

View File

@ -1,55 +1,51 @@
#include "PostInfoWidget.h" #include "PostInfoWidget.h"
#include "ui_PostInfoWidget.h"
#include "PostRenderData/RenderDataAlgorithm.h"
#include "PostRenderData/RenderDataImportSteady.h"
#include "PostRenderData/RenderDataImportUnSteady.h"
#include "PostRenderData/RenderDataManager.h" #include "PostRenderData/RenderDataManager.h"
#include "PostRenderData/RenderDataObject.h" #include "PostRenderData/RenderDataObject.h"
#include "PostRenderData/RenderProperty.h" #include "PostRenderData/RenderProperty.h"
#include "PostRenderData/RenderDataAlgorithm.h" #include "ui_PostInfoWidget.h"
#include "PostRenderData/RenderDataImportUnSteady.h"
#include "PostRenderData/RenderDataImportSteady.h" #include <QDebug>
#include <QLabel> #include <QLabel>
#include <QStringList> #include <QStringList>
#include <QDebug>
namespace Post {
namespace Post PostInfoWidget::PostInfoWidget(GUI::MainWindow* m, QWidget* parent)
{ : _ui(new Ui::PostInfoWidget)
, _parent(parent)
PostInfoWidget::PostInfoWidget(GUI::MainWindow* m, QWidget* parent) : , _mainWindow(m)
_ui(new Ui::PostInfoWidget), _parent(parent), _mainWindow(m) {
{ _ui->setupUi(this);
_ui->setupUi(this); _dataManager = RenderDataManager::getInstance();
_dataManager = RenderDataManager::getInstance(); _ui->tableWidget->setColumnCount(4);
_ui->tableWidget->setColumnCount(4); QStringList header;
QStringList header;
header << tr("Property") << tr("Name") << tr("Type") << tr("Range"); header << tr("Property") << tr("Name") << tr("Type") << tr("Range");
_ui->tableWidget->setHorizontalHeaderLabels(header); _ui->tableWidget->setHorizontalHeaderLabels(header);
_ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); _ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
_ui->tableWidget->verticalHeader()->setVisible(false); _ui->tableWidget->verticalHeader()->setVisible(false);
}
} PostInfoWidget::~PostInfoWidget()
{
delete _ui;
}
PostInfoWidget::~PostInfoWidget() QString PostInfoWidget::enumToString(Post::ObjType type)
{ {
delete _ui; QString types;
} if(type == Post::ObjType::Alg) {
types = "Alg";
QString PostInfoWidget::enumToString(Post::ObjType type) } else if(type == Post::ObjType::Imp) {
{ types = tr("Imp");
QString types; } else if(type == Post::ObjType::TNone) {
if(type == Post::ObjType::Alg) types = "TNone";
{ }
types = "Alg"; return types;
} }
else if(type == Post::ObjType::Imp)
{
types = tr("Imp");
}
else if(type == Post::ObjType::TNone)
{
types = "TNone";
}
return types;
}
void PostInfoWidget::reTranslate() void PostInfoWidget::reTranslate()
{ {
@ -65,78 +61,92 @@ namespace Post
QString PostInfoWidget::getRenderDataObjectType(RenderDataObject* obj) QString PostInfoWidget::getRenderDataObjectType(RenderDataObject* obj)
{ {
QString sType = "TNone"; QString sType = "TNone";
auto type = obj->getDataType(); auto type = obj->getDataType();
if (type == Post::ObjType::Alg) if(type == Post::ObjType::Alg) {
{ sType = tr("Alg");
sType = tr("Alg");
auto alg = RenderDataAlgorithm::SafeDownCast(obj); auto alg = RenderDataAlgorithm::SafeDownCast(obj);
if (alg == nullptr) return sType; if(alg == nullptr)
return sType;
switch (alg->getAlgoType()) switch(alg->getAlgoType()) {
{ case Post::ISO:
case Post::ISO: sType = tr("ISOSurface"); break; sType = tr("ISOSurface");
case Post::ISOCurve: sType = tr("ISOCurve"); break; break;
case Post::Vector: sType = tr("Vector"); break; case Post::ISOCurve:
case Post::Slice: sType = tr("Slice"); break; sType = tr("ISOCurve");
case Post::Clip: sType = tr("Clip"); break; break;
case Post::StreamLine: sType = tr("StreamLine"); break; case Post::Vector:
case Post::Simplify: sType = tr("Simplify"); break; sType = tr("Vector");
case Post::Calculator: sType = tr("Calculator"); break; break;
case Post::Reflection: sType = tr("Reflection"); break; case Post::Slice:
sType = tr("Slice");
break;
case Post::Clip:
sType = tr("Clip");
break;
case Post::StreamLine:
sType = tr("StreamLine");
break;
case Post::Simplify:
sType = tr("Simplify");
break;
case Post::Calculator:
sType = tr("Calculator");
break;
case Post::Reflection:
sType = tr("Reflection");
break;
} }
} } else if(type == Post::ObjType::Imp) {
else if (type == Post::ObjType::Imp) sType = tr("Steady");
{
sType = tr("Steady");
auto usteady = RenderDataImportUnSteady::SafeDownCast(obj); auto usteady = RenderDataImportUnSteady::SafeDownCast(obj);
if (usteady != nullptr) sType = tr("UnSteady"); if(usteady != nullptr)
sType = tr("UnSteady");
} }
return sType; return sType;
} }
void PostInfoWidget::updatePostTable(QTreeWidgetItem* item) void PostInfoWidget::updatePostTable(QTreeWidgetItem* item)
{ {
if (item == nullptr) return; if(item == nullptr)
return;
bool ok = false; bool ok = false;
int id = item->data(0, Qt::UserRole).toInt(&ok); int id = item->data(0, Qt::UserRole).toInt(&ok);
if (!ok)return; if(!ok)
return;
auto obj = _dataManager->getObjectByID(id);
if (obj == nullptr) return;
auto obj = _dataManager->getObjectByID(id);
if(obj == nullptr)
return;
int index = item->data(1, Qt::UserRole).toInt(&ok); int index = item->data(1, Qt::UserRole).toInt(&ok);
if (!ok) return; if(!ok)
return;
auto setRangeItem = [=](int row, int type, QString var) { auto setRangeItem = [=](int row, int type, QString var) {
int vtype = obj->variableType(type, var); auto vtype = obj->variableType(type, var);
double range[2]{ 0 }; double range[2]{ 0 };
QString sRange; QString sRange;
if (vtype == 1) if(vtype == "scalar") {
{
obj->getRange(range, type, var, -1); obj->getRange(range, type, var, -1);
sRange = QString("[%1,%2]").arg(range[0]).arg(range[1]); sRange = QString("[%1,%2]").arg(range[0]).arg(range[1]);
} } else if(vtype == "vector") {
else if (vtype == 2)
{
obj->getRange(range, type, var, 0); obj->getRange(range, type, var, 0);
sRange = QString("[%1,%2];").arg(range[0]).arg(range[1]); sRange = QString("[%1,%2];").arg(range[0]).arg(range[1]);
obj->getRange(range, type, var, 1); obj->getRange(range, type, var, 1);
sRange += QString("[%1,%2];").arg(range[0]).arg(range[1]); sRange += QString("[%1,%2];").arg(range[0]).arg(range[1]);
obj->getRange(range, type, var, 2); obj->getRange(range, type, var, 2);
sRange += QString("[%1,%2]").arg(range[0]).arg(range[1]); sRange += QString("[%1,%2]").arg(range[0]).arg(range[1]);
} } else
else return; return;
_ui->tableWidget->setItem(row, 3, new QTableWidgetItem(sRange)); _ui->tableWidget->setItem(row, 3, new QTableWidgetItem(sRange));
}; };
if (index == -1) if(index == -1) {
{
_ui->FileNameValue->setText(obj->getName()); _ui->FileNameValue->setText(obj->getName());
_ui->TypeValue->setText(getRenderDataObjectType(obj)); _ui->TypeValue->setText(getRenderDataObjectType(obj));
_ui->PointNumValue->setText(QString::number(obj->getPointDataNum())); _ui->PointNumValue->setText(QString::number(obj->getPointDataNum()));
@ -144,35 +154,33 @@ namespace Post
QStringList PointData; QStringList PointData;
QStringList CellData; QStringList CellData;
PointData = obj->getPointDataArray(); PointData = obj->getPointDataArray();
CellData = obj->getCellDataArray(); CellData = obj->getCellDataArray();
int Rowcount = PointData.size() + CellData.size(); int Rowcount = PointData.size() + CellData.size();
_ui->tableWidget->setRowCount(Rowcount); _ui->tableWidget->setRowCount(Rowcount);
for(int i = 0; i < PointData.size(); i++) {
for (int i = 0; i < PointData.size(); i++)
{
double range[2]{ 0 }; double range[2]{ 0 };
obj->getRange(range, 1, PointData[i], -1); obj->getRange(range, 1, PointData[i], -1);
_ui->tableWidget->setItem(i, 0, new QTableWidgetItem(tr("PointProperty"))); _ui->tableWidget->setItem(i, 0, new QTableWidgetItem(tr("PointProperty")));
_ui->tableWidget->setItem(i, 1, new QTableWidgetItem(PointData[i])); _ui->tableWidget->setItem(i, 1, new QTableWidgetItem(PointData[i]));
_ui->tableWidget->setItem(i, 2, new QTableWidgetItem(QString::number(obj->variableType(1, PointData[i])))); _ui->tableWidget->setItem(i, 2,
// qDebug() << obj->variableType(1, PointData[i]); new QTableWidgetItem(obj->variableType(1, PointData[i])));
// qDebug() << obj->variableType(1, PointData[i]);
setRangeItem(i, 1, PointData[i]); setRangeItem(i, 1, PointData[i]);
} }
for (int j = 0; j < CellData.size(); j++) for(int j = 0; j < CellData.size(); j++) {
{ _ui->tableWidget->setItem(PointData.size() + j, 0,
_ui->tableWidget->setItem(PointData.size() + j, 0, new QTableWidgetItem(tr("CellProperty"))); new QTableWidgetItem(tr("CellProperty")));
_ui->tableWidget->setItem(PointData.size() + j, 1, new QTableWidgetItem(CellData[j])); _ui->tableWidget->setItem(PointData.size() + j, 1,
_ui->tableWidget->setItem(PointData.size() + j, 2, new QTableWidgetItem(QString::number(obj->variableType(2, CellData[j])))); new QTableWidgetItem(CellData[j]));
_ui->tableWidget->setItem(PointData.size() + j, 2,
new QTableWidgetItem(obj->variableType(2, CellData[j])));
setRangeItem(PointData.size() + j, 2, CellData[j]); setRangeItem(PointData.size() + j, 2, CellData[j]);
} }
} } else {
else
{
_ui->FileNameValue->setText(obj->getBlockName(index)); _ui->FileNameValue->setText(obj->getBlockName(index));
_ui->TypeValue->setText(getRenderDataObjectType(obj)); _ui->TypeValue->setText(getRenderDataObjectType(obj));
_ui->PointNumValue->setText(QString::number(obj->getNumberOfBlockPoints(index + 1))); _ui->PointNumValue->setText(QString::number(obj->getNumberOfBlockPoints(index + 1)));
@ -180,105 +188,111 @@ namespace Post
QStringList PointData; QStringList PointData;
QStringList CellData; QStringList CellData;
PointData = obj->getBlockPointDataArray(index + 1); PointData = obj->getBlockPointDataArray(index + 1);
CellData = obj->getBlockCellDataArray(index + 1); CellData = obj->getBlockCellDataArray(index + 1);
int Rowcount = PointData.size() + CellData.size(); int Rowcount = PointData.size() + CellData.size();
_ui->tableWidget->setRowCount(Rowcount); _ui->tableWidget->setRowCount(Rowcount);
for (int i = 0; i < PointData.size(); i++) for(int i = 0; i < PointData.size(); i++) {
{
double range[2]{ 0 }; double range[2]{ 0 };
obj->getRange(range, 1, PointData[i], -1); obj->getRange(range, 1, PointData[i], -1);
_ui->tableWidget->setItem(i, 0, new QTableWidgetItem(tr("PointProperty"))); _ui->tableWidget->setItem(i, 0, new QTableWidgetItem(tr("PointProperty")));
_ui->tableWidget->setItem(i, 1, new QTableWidgetItem(PointData[i])); _ui->tableWidget->setItem(i, 1, new QTableWidgetItem(PointData[i]));
_ui->tableWidget->setItem(i, 2, new QTableWidgetItem(QString::number(obj->variableType(1, PointData[i])))); _ui->tableWidget->setItem(i, 2,
new QTableWidgetItem(obj->variableType(1, PointData[i])));
// qDebug() << obj->variableType(1, PointData[i]); // qDebug() << obj->variableType(1, PointData[i]);
setRangeItem(i, 1, PointData[i]); setRangeItem(i, 1, PointData[i]);
} }
for (int j = 0; j < CellData.size(); j++) for(int j = 0; j < CellData.size(); j++) {
{ _ui->tableWidget->setItem(PointData.size() + j, 0,
_ui->tableWidget->setItem(PointData.size() + j, 0, new QTableWidgetItem(tr("CellProperty"))); new QTableWidgetItem(tr("CellProperty")));
_ui->tableWidget->setItem(PointData.size() + j, 1, new QTableWidgetItem(CellData[j])); _ui->tableWidget->setItem(PointData.size() + j, 1,
_ui->tableWidget->setItem(PointData.size() + j, 2, new QTableWidgetItem(QString::number(obj->variableType(2, CellData[j])))); new QTableWidgetItem(CellData[j]));
_ui->tableWidget->setItem(PointData.size() + j, 2,
new QTableWidgetItem(obj->variableType(2, CellData[j])));
setRangeItem(PointData.size() + j, 2, CellData[j]); setRangeItem(PointData.size() + j, 2, CellData[j]);
} }
} }
// if(item->childCount() > 0) // if(item->childCount() > 0)
// { // {
// //
// //
// // int idBlock = item->data(1, Qt::UserRole).toInt(&ok); // // int idBlock = item->data(1, Qt::UserRole).toInt(&ok);
// //
// _ui->FileNameValue->setText(obj->getName()); // _ui->FileNameValue->setText(obj->getName());
// _ui->TypeValue->setText(enumToString(obj->getDataType())); // _ui->TypeValue->setText(enumToString(obj->getDataType()));
// _ui->PointNumValue->setText(QString::number(obj->getPointDataNum())); // _ui->PointNumValue->setText(QString::number(obj->getPointDataNum()));
// _ui->CellNumValue->setText(QString::number(obj->getCellDataNum())); // _ui->CellNumValue->setText(QString::number(obj->getCellDataNum()));
// //
// QStringList PointData; // QStringList PointData;
// QStringList CellData; // QStringList CellData;
// PointData = obj->getPointDataArray(); // PointData = obj->getPointDataArray();
// CellData = obj->getCellDataArray(); // CellData = obj->getCellDataArray();
// //
// int Rowcount = PointData.size()+CellData.size(); // int Rowcount = PointData.size()+CellData.size();
// _ui->tableWidget->setRowCount(Rowcount); // _ui->tableWidget->setRowCount(Rowcount);
// //
// for(int i=0; i<PointData.size(); i++) // for(int i=0; i<PointData.size(); i++)
// { // {
// //
// _ui->tableWidget->setItem(i,0,new QTableWidgetItem("PointProperty")); // _ui->tableWidget->setItem(i,0,new QTableWidgetItem("PointProperty"));
// _ui->tableWidget->setItem(i,1,new QTableWidgetItem(PointData[i])); // _ui->tableWidget->setItem(i,1,new QTableWidgetItem(PointData[i]));
// _ui->tableWidget->setItem(i,2,new QTableWidgetItem(QString::number(obj->variableType(1,PointData[i])))); // _ui->tableWidget->setItem(i,2,new
// qDebug()<<obj->variableType(1,PointData[i]); // QTableWidgetItem(QString::number(obj->variableType(1,PointData[i]))));
// // qDebug()<<obj->variableType(1,PointData[i]);
// } //
// for(int j=0; j<CellData.size(); j++) // }
// { // for(int j=0; j<CellData.size(); j++)
// _ui->tableWidget->setItem(PointData.size()+j,0,new QTableWidgetItem("CellProperty")); // {
// _ui->tableWidget->setItem(PointData.size()+j,1,new QTableWidgetItem(CellData[j])); // _ui->tableWidget->setItem(PointData.size()+j,0,new
// _ui->tableWidget->setItem(PointData.size()+j,2,new QTableWidgetItem(QString::number(obj->variableType(2,CellData[j])))); // QTableWidgetItem("CellProperty"));
// } // _ui->tableWidget->setItem(PointData.size()+j,1,new
// } // QTableWidgetItem(CellData[j]));
// // _ui->tableWidget->setItem(PointData.size()+j,2,new
// if(item->childCount() == 0) // QTableWidgetItem(QString::number(obj->variableType(2,CellData[j]))));
// { // }
// _ui->FileNameValue->setText(obj->getBlockName(item->parent()->indexOfChild(item))); // }
// _ui->TypeValue->setText(""); //
// _ui->PointNumValue->setText(QString::number(obj->getNumberOfBlockPoints(item->parent()->indexOfChild(item)+1))); // if(item->childCount() == 0)
// _ui->CellNumValue->setText(QString::number(obj->getNumberOfBlockCells(item->parent()->indexOfChild(item)+1))); // {
// // _ui->FileNameValue->setText(obj->getBlockName(item->parent()->indexOfChild(item)));
// QStringList PointData; // _ui->TypeValue->setText("");
// QStringList CellData; // _ui->PointNumValue->setText(QString::number(obj->getNumberOfBlockPoints(item->parent()->indexOfChild(item)+1)));
// PointData = obj->getPointDataArray(); // _ui->CellNumValue->setText(QString::number(obj->getNumberOfBlockCells(item->parent()->indexOfChild(item)+1)));
// CellData = obj->getCellDataArray(); //
// // QStringList PointData;
// int Rowcount = PointData.size()+CellData.size(); // QStringList CellData;
// _ui->tableWidget->setRowCount(Rowcount); // PointData = obj->getPointDataArray();
// // CellData = obj->getCellDataArray();
// for(int i=0; i<PointData.size(); i++) //
// { // int Rowcount = PointData.size()+CellData.size();
// // _ui->tableWidget->setRowCount(Rowcount);
// _ui->tableWidget->setItem(i,0,new QTableWidgetItem("PointProperty")); //
// _ui->tableWidget->setItem(i,1,new QTableWidgetItem(PointData[i])); // for(int i=0; i<PointData.size(); i++)
// _ui->tableWidget->setItem(i,2,new QTableWidgetItem(QString::number(obj->variableType(1,PointData[i])))); // {
// qDebug()<<obj->variableType(1,PointData[i]); //
// // _ui->tableWidget->setItem(i,0,new QTableWidgetItem("PointProperty"));
// } // _ui->tableWidget->setItem(i,1,new QTableWidgetItem(PointData[i]));
// for(int j=0; j<CellData.size(); j++) // _ui->tableWidget->setItem(i,2,new
// { // QTableWidgetItem(QString::number(obj->variableType(1,PointData[i]))));
// _ui->tableWidget->setItem(PointData.size()+j,0,new QTableWidgetItem("CellProperty")); // qDebug()<<obj->variableType(1,PointData[i]);
// _ui->tableWidget->setItem(PointData.size()+j,1,new QTableWidgetItem(CellData[j])); //
// _ui->tableWidget->setItem(PointData.size()+j,2,new QTableWidgetItem(QString::number(obj->variableType(2,CellData[j])))); // }
// } // for(int j=0; j<CellData.size(); j++)
// // {
// // _ui->tableWidget->setItem(PointData.size()+j,0,new
// } // QTableWidgetItem("CellProperty"));
// _ui->tableWidget->setItem(PointData.size()+j,1,new
} // QTableWidgetItem(CellData[j]));
// _ui->tableWidget->setItem(PointData.size()+j,2,new
// QTableWidgetItem(QString::number(obj->variableType(2,CellData[j]))));
} // }
//
//
// }
}
} // namespace Post

View File

@ -17,7 +17,6 @@
#include "PostRenderData/StreamLineRenderDataAlg.h" #include "PostRenderData/StreamLineRenderDataAlg.h"
#include "PostRenderData/CalculateRenderDataAlg.h" #include "PostRenderData/CalculateRenderDataAlg.h"
#include "PostRenderData/ReflectionRenderDataAlg.h" #include "PostRenderData/ReflectionRenderDataAlg.h"
#include "MainWindow/MainWindow.h"
namespace Post namespace Post
{ {
@ -57,16 +56,19 @@ namespace Post
{ {
RenderDataObject *dataObj = nullptr; RenderDataObject *dataObj = nullptr;
if (FileDirectoryDialog::isGourpFiles(file)) if (FileDirectoryDialog::isGourpFiles(file))
dataObj = new RenderDataImportUnSteady(file); {
dataObj = new RenderDataImportUnSteady(file);
}
else else
dataObj = new RenderDataImportSteady(file); {
dataObj = new RenderDataImportSteady(file);
}
dataObj->update(); dataObj->update();
auto dataset = dataObj->getOutputData(); auto dataset = dataObj->getOutputData();
RenderDataManager::getInstance()->appendRenderObjectList(dataObj); RenderDataManager::getInstance()->appendRenderObjectList(dataObj);
// RenderDirector::getInstance()->renderDataObjectToWindow(dataObj, wID); // RenderDirector::getInstance()->renderDataObjectToWindow(dataObj, wID);
emit _director->signal_renderDataObject(dataObj, wID); emit _director->signal_renderDataObject(dataObj, wID);
_tree->updatePostTree(); _tree->updatePostTree();
// emit _mainWindow->updatePostTreeSig(); // emit _mainWindow->updatePostTreeSig();

View File

@ -15,7 +15,7 @@ namespace Post {
{ {
Q_OBJECT Q_OBJECT
Singleton(RenderDirector) Singleton(RenderDirector)
signals: signals:
void signal_renderDataObject(RenderDataObject* obj,int wID); void signal_renderDataObject(RenderDataObject* obj,int wID);
@ -55,4 +55,4 @@ namespace Post {
#endif #endif

View File

@ -18,6 +18,8 @@
#include <vtkDataSetWriter.h> #include <vtkDataSetWriter.h>
#include <QFile> #include <QFile>
#include <QString> #include <QString>
#include <vtkXMLUnstructuredGridReader.h>
#include <vtkXMLPUnstructuredGridReader.h>
namespace Post namespace Post
{ {
@ -97,6 +99,26 @@ namespace Post
mapper->SetInputConnection(_vtkAlg->GetOutputPort(i + 1)); mapper->SetInputConnection(_vtkAlg->GetOutputPort(i + 1));
} }
} }
else if (_Suffix == "vtu")
{
CreateVTKSmartPtr(vtkXMLUnstructuredGridReader, _vtkAlg) auto r = vtkXMLUnstructuredGridReader::SafeDownCast(_vtkAlg);
QString2Char(_FileName, c);
r->SetFileName(c);
r->Update();
_blockNumber = 1;
auto mapper = createMapper(true);
mapper->SetInputConnection(_vtkAlg->GetOutputPort(0));
}
else if (_Suffix == "pvtu")
{
CreateVTKSmartPtr(vtkXMLPUnstructuredGridReader, _vtkAlg) auto r = vtkXMLPUnstructuredGridReader::SafeDownCast(_vtkAlg);
QString2Char(_FileName, c);
r->SetFileName(c);
r->Update();
_blockNumber = 1;
auto mapper = createMapper(true);
mapper->SetInputConnection(_vtkAlg->GetOutputPort(0));
}
} }
RenderDataImportSteady *RenderDataImportSteady::SafeDownCast(RenderDataObject *obj) RenderDataImportSteady *RenderDataImportSteady::SafeDownCast(RenderDataObject *obj)
@ -144,4 +166,4 @@ namespace Post
ac->SetVisibility(vis); ac->SetVisibility(vis);
} }
} }

View File

@ -5,6 +5,8 @@
#include "PostAlgorithm/CGNSReaderAlgorithm.h" #include "PostAlgorithm/CGNSReaderAlgorithm.h"
#include "PostAlgorithm/Plot3DReaderAlgorithm.h" #include "PostAlgorithm/Plot3DReaderAlgorithm.h"
#include "Macros.hxx" #include "Macros.hxx"
#include <vtkXMLUnstructuredGridReader.h>
#include <vtkXMLPUnstructuredGridReader.h>
namespace Post { namespace Post {
QStringList getSelectGroupFiles(const QString path) QStringList getSelectGroupFiles(const QString path)
@ -124,8 +126,27 @@ namespace Post {
auto mapper = createMapper(true); auto mapper = createMapper(true);
mapper->SetInputConnection(_vtkAlg->GetOutputPort(i + 1)); mapper->SetInputConnection(_vtkAlg->GetOutputPort(i + 1));
} }
}
} else if (Suffix == "vtu")
{
CreateVTKSmartPtr(vtkXMLUnstructuredGridReader, _vtkAlg)
auto r = vtkXMLUnstructuredGridReader::SafeDownCast(_vtkAlg);
QString2Char(fileName, c)
r->SetFileName(c);
_blockNumber = 1;
auto mapper = createMapper(true);
mapper->SetInputConnection(_vtkAlg->GetOutputPort(0));
}
else if (Suffix == "pvtu")
{
CreateVTKSmartPtr(vtkXMLPUnstructuredGridReader, _vtkAlg)
auto r = vtkXMLPUnstructuredGridReader::SafeDownCast(_vtkAlg);
QString2Char(fileName, c)
r->SetFileName(c);
_blockNumber = 1;
auto mapper = createMapper(true);
mapper->SetInputConnection(_vtkAlg->GetOutputPort(0));
}
} }
void RenderDataImportUnSteady::ReadFile() void RenderDataImportUnSteady::ReadFile()
@ -148,7 +169,19 @@ namespace Post {
auto r = Plot3DReaderAlgorithm::SafeDownCast(_vtkAlg); auto r = Plot3DReaderAlgorithm::SafeDownCast(_vtkAlg);
QString2Char(f, c); QString2Char(f, c);
r->SetFileName(c); r->SetFileName(c);
} }
else if (this->getSuffix() == "vtu")
{
auto r = vtkXMLUnstructuredGridReader::SafeDownCast(_vtkAlg);
QString2Char(f, c);
r->SetFileName(c);
}
else if (this->getSuffix() == "pvtu")
{
auto r = vtkXMLPUnstructuredGridReader::SafeDownCast(_vtkAlg);
QString2Char(f, c);
r->SetFileName(c);
}
} }
RenderDataImportUnSteady::~RenderDataImportUnSteady() RenderDataImportUnSteady::~RenderDataImportUnSteady()
@ -166,4 +199,4 @@ namespace Post {
_CurrentIndex = index; _CurrentIndex = index;
this->ReadFile(); this->ReadFile();
} }
} }

View File

@ -201,9 +201,9 @@ QStringList RenderDataObject::getBlockCellDataArray(int index)
return nameList; return nameList;
} }
int RenderDataObject::variableType(int vaLocation, QString vaName) QString RenderDataObject::variableType(int vaLocation, QString vaName)
{ {
int type = 0; QString type = "Unknown";
vtkDataSet* data = getOutputData(); vtkDataSet* data = getOutputData();
if (data == nullptr) return 0; if (data == nullptr) return 0;
QString2Char(vaName, cName) QString2Char(vaName, cName)
@ -215,11 +215,11 @@ int RenderDataObject::variableType(int vaLocation, QString vaName)
if (dataArray == nullptr) return 0; if (dataArray == nullptr) return 0;
const int cNum = dataArray->GetNumberOfComponents(); const int cNum = dataArray->GetNumberOfComponents();
if (cNum == 1) if (cNum == 1)
type = 1; type = "scalar";
else if (cNum == 3) else if (cNum == 3)
type = 2; type = "vector";
else if (cNum >= 4) else if (cNum == 9)
type = 3; type = "tensor";
return type; return type;
} }

View File

@ -120,9 +120,10 @@ namespace Post {
* @brief * @brief
* @param vaLocation 1-pointData 2-cellData * @param vaLocation 1-pointData 2-cellData
* @param vaName * @param vaName
* @return int 1- 2- 3- 0- * @return QString :scalar\vector\tensor\Unknown
* @note vtk
*/ */
int variableType(int vaLocation, QString vaName); QString variableType(int vaLocation, QString vaName);
/** /**
* @brief * @brief
* @param vaLocation 1-pointData 2-cellData * @param vaLocation 1-pointData 2-cellData

View File

@ -27,6 +27,8 @@ add_library(PythonModule
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
target_compile_definitions(PythonModule PRIVATE "PYTHONMODULE_API") target_compile_definitions(PythonModule PRIVATE "PYTHONMODULE_API")
list(APPEND _depend_library Common)
list(APPEND _runtimes_libraries list(APPEND _runtimes_libraries
Qt5::Widgets FASTCAE::PYTHON Qt5::Widgets FASTCAE::PYTHON
) )
@ -39,7 +41,14 @@ endif()
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# #
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
target_link_libraries(PythonModule ${_runtimes_libraries}) target_link_libraries(PythonModule
${_runtimes_libraries}
${_depend_library})
#-----------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------
add_dependencies(PythonModule ${_depend_library})
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# #

View File

@ -1,17 +1,16 @@
#include <Python.h> #include <Python.h>
#include "PyAgent.h"
#include <QString>
#include <QCoreApplication> #include <QCoreApplication>
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#include <QFile>
#include <QString>
#include <QTextStream>
#include <wchar.h>
#include "PyAgent.h"
#include "MainWindow/MainWindow.h" #include "MainWindow/MainWindow.h"
#include "PyInterpreter.h" #include "PyInterpreter.h"
#include "RecordScript.h" #include "RecordScript.h"
#include "ScriptReader.h" #include "ScriptReader.h"
#include <QFile>
#include <QDebug>
#include <QTextStream>
#include <wchar.h>
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
#include <atlconv.h> #include <atlconv.h>
@ -19,13 +18,12 @@
#include <locale.h> #include <locale.h>
namespace Py namespace Py {
{ PythonAgent* PythonAgent::_instance = nullptr;
PythonAgent *PythonAgent::_instance = nullptr;
PythonAgent *PythonAgent::getInstance() PythonAgent* PythonAgent::getInstance()
{ {
if (_instance == nullptr) if(_instance == nullptr)
_instance = new PythonAgent; _instance = new PythonAgent;
return _instance; return _instance;
@ -33,13 +31,14 @@ namespace Py
void PythonAgent::connectSignals() void PythonAgent::connectSignals()
{ {
connect(this, SIGNAL(printInfo(Common::Message, QString)), _mainWindow, SIGNAL(printMessageSig(Common::Message, QString))); connect(this, SIGNAL(printInfo(Common::Message, QString)), _mainWindow,
SIGNAL(printMessageSig(Common::Message, QString)));
connect(this, SIGNAL(closeMainWindow()), _mainWindow, SIGNAL(closeMainWindow())); connect(this, SIGNAL(closeMainWindow()), _mainWindow, SIGNAL(closeMainWindow()));
} }
void PythonAgent::appCodeList(QString code) void PythonAgent::appCodeList(QString code)
{ {
if (!_append) if(!_append)
return; return;
emit printInfo(Common::Message::Python, code); emit printInfo(Common::Message::Python, code);
_interpreter->codeListAppend(code); _interpreter->codeListAppend(code);
@ -50,40 +49,13 @@ namespace Py
_interpreter = new PyInterpreter; _interpreter = new PyInterpreter;
} }
void PythonAgent::initialize(GUI::MainWindow *m) void PythonAgent::initialize(GUI::MainWindow* m)
{ {
_mainWindow = m; _mainWindow = m;
connectSignals(); connectSignals();
/*
QString path = qApp->applicationDirPath() + "/../python37";
path = QDir::cleanPath(path);
char *ch;
QByteArray ba = path.toLocal8Bit();
ch = ba.data();
wchar_t *wc;
#ifdef Q_OS_WIN32
USES_CONVERSION;
wc = A2W(ch);
#endif
#ifdef Q_OS_LINUX
setlocale(LC_CTYPE, "zh_CN.utf8");
int w_size = mbstowcs(NULL, ba, 0) + 1;
wc = new wchar_t[w_size];
mbstowcs(wc, ba, strlen(ba) + 1);
#endif
QDir d(path);
if (d.exists())
{
#ifdef Q_OS_WIN32
Py_SetPythonHome(wc);
#endif
}*/
Py_SetProgramName(L"FastCAE"); Py_SetProgramName(L"FastCAE");
Py_Initialize(); Py_Initialize();
if (!_interpreter->init(this)) if(!_interpreter->init(this))
emit printInfo(Common::Message::Error, tr("Python Initialize failed!")); emit printInfo(Common::Message::Error, tr("Python Initialize failed!"));
else else
emit printInfo(Common::Message::Normal, tr("Python Initialized")); emit printInfo(Common::Message::Normal, tr("Python Initialized"));
@ -93,15 +65,13 @@ namespace Py
void PythonAgent::finalize() void PythonAgent::finalize()
{ {
if (_reader != nullptr) if(_reader != nullptr) {
{ if(_reader->isRunning()) {
if (_reader->isRunning())
{
_reader->stop(); _reader->stop();
_reader->quit(); _reader->quit();
_reader->wait(); _reader->wait();
} }
while (_reader->isRunning()) while(_reader->isRunning())
; ;
delete _reader; delete _reader;
_reader = nullptr; _reader = nullptr;
@ -112,23 +82,20 @@ namespace Py
_recordScript->wait(); _recordScript->wait();
delete _recordScript; delete _recordScript;
if (_interpreter != nullptr) if(_interpreter != nullptr)
delete _interpreter; delete _interpreter;
if (Py_IsInitialized()) if(Py_IsInitialized())
Py_Finalize(); Py_Finalize();
} }
void PythonAgent::submit(QString code, bool s) void PythonAgent::submit(QString code, bool s)
{ {
// this->lock();
qDebug() << "submit: " << code;
emit printInfo(Common::Message::Python, code); emit printInfo(Common::Message::Python, code);
// lock(); // lock();
int ok = _interpreter->execCode(code, s); int ok = _interpreter->execCode(code, s);
if (ok == -1) if(ok == -1) {
{ if(_reader != nullptr)
if (_reader != nullptr)
_reader->restart(); _reader->restart();
} }
} }
@ -136,8 +103,7 @@ namespace Py
void PythonAgent::submit(QStringList codes, bool save /*= true*/) void PythonAgent::submit(QStringList codes, bool save /*= true*/)
{ {
const int n = codes.size(); const int n = codes.size();
for (int i = 0; i < n; ++i) for(int i = 0; i < n; ++i) {
{
this->submit(codes.at(i), save); this->submit(codes.at(i), save);
} }
} }
@ -145,15 +111,13 @@ namespace Py
void PythonAgent::saveScript(QString fileName) void PythonAgent::saveScript(QString fileName)
{ {
QFile file(fileName); QFile file(fileName);
if (!file.open(QIODevice::Text | QIODevice::WriteOnly)) if(!file.open(QIODevice::Text | QIODevice::WriteOnly)) {
{
emit printInfo(Common::Message::Error, tr("Script open failed")); emit printInfo(Common::Message::Error, tr("Script open failed"));
return; return;
} }
QTextStream stream(&file); QTextStream stream(&file);
const int n = _interpreter->getCodeCount(); const int n = _interpreter->getCodeCount();
for (int i = 0; i < n; ++i) for(int i = 0; i < n; ++i) {
{
QString s = _interpreter->getCodeAt(i); QString s = _interpreter->getCodeAt(i);
stream << s << endl; stream << s << endl;
} }
@ -163,7 +127,7 @@ namespace Py
bool PythonAgent::execScript(QString fileName) bool PythonAgent::execScript(QString fileName)
{ {
if (_reader != nullptr) if(_reader != nullptr)
return false; return false;
_reader = new ScriptReader(fileName, this); _reader = new ScriptReader(fileName, this);
_recordScript->pause(); _recordScript->pause();
@ -174,23 +138,23 @@ namespace Py
void PythonAgent::readerFinished() void PythonAgent::readerFinished()
{ {
if (_reader != nullptr) if(_reader != nullptr)
delete _reader; delete _reader;
_reader = nullptr; _reader = nullptr;
_recordScript->reStart(); _recordScript->reStart();
if (_noGUI) if(_noGUI)
emit closeMainWindow(); emit closeMainWindow();
} }
void PythonAgent::lock() void PythonAgent::lock()
{ {
if (_reader != nullptr) if(_reader != nullptr)
_reader->pause(); _reader->pause();
} }
void PythonAgent::unLock() void PythonAgent::unLock()
{ {
if (_reader != nullptr) if(_reader != nullptr)
_reader->restart(); _reader->restart();
} }
@ -201,7 +165,7 @@ namespace Py
QStringList PythonAgent::getcodelist() QStringList PythonAgent::getcodelist()
{ {
if (_interpreter != nullptr) if(_interpreter != nullptr)
return _interpreter->getCode(); return _interpreter->getCode();
return QStringList(); return QStringList();
} }
@ -229,4 +193,4 @@ namespace Py
{ {
_interpreter->execCode(code, false); _interpreter->execCode(code, false);
} }
} } // namespace Py

View File

@ -8,14 +8,13 @@
#include <string> #include <string>
#include <QReadWriteLock> #include <QReadWriteLock>
#include "Common/Types.h" #include "Common/Types.h"
#include "Common/DebugLogger.h"
namespace Py namespace Py {
{
bool PyInterpreter::init(PythonAgent *agent) bool PyInterpreter::init(PythonAgent* agent)
{ {
if (!Py_IsInitialized()) if(!Py_IsInitialized()) {
{
return false; return false;
} }
_agent = agent; _agent = agent;
@ -23,19 +22,18 @@ namespace Py
this->execCode("import sys", false); this->execCode("import sys", false);
this->execCode("import os", false); this->execCode("import os", false);
QString path = QDir::cleanPath(qApp->applicationDirPath()); QString path = QDir::cleanPath(qApp->applicationDirPath());
QString qs = QString("sys.path.append(\"%1\")").arg(path); QString qs = QString("sys.path.append(\"%1\")").arg(path);
this->execCode(qs, false); this->execCode(qs, false);
QDir dir(path); QDir dir(path);
QStringList suffix; QStringList suffix;
suffix << "*.py"; suffix << "*.py";
dir.setNameFilters(suffix); dir.setNameFilters(suffix);
QList<QFileInfo> files = dir.entryInfoList(suffix); QList<QFileInfo> files = dir.entryInfoList(suffix);
for (int i = 0; i < files.size(); ++i) for(int i = 0; i < files.size(); ++i) {
{
QFileInfo fileinfo = files.at(i); QFileInfo fileinfo = files.at(i);
QString name = fileinfo.baseName(); QString name = fileinfo.baseName();
QString command = QString("import %1").arg(name); QString command = QString("import %1").arg(name);
this->execCode(command, false); this->execCode(command, false);
} }
@ -47,18 +45,18 @@ namespace Py
QReadWriteLock lock; QReadWriteLock lock;
lock.lockForRead(); lock.lockForRead();
std::string s = code.toStdString(); std::string s = code.toStdString();
const char *c = s.c_str(); const char* c = s.c_str();
qDebug() << "exec: " << code;
DebugInfo("Exec python script: %s\n", code.toStdString().c_str());
int ok = PyRun_SimpleStringFlags(c, NULL); int ok = PyRun_SimpleStringFlags(c, NULL);
if (ok == -1) if(ok == -1) {
{
QString error = QString(tr("Exception occurred at: \"%1\"")).arg(code); QString error = QString(tr("Exception occurred at: \"%1\"")).arg(code);
_agent->printInfo(Common::Message::Warning, error); _agent->printInfo(Common::Message::Warning, error);
} }
if (save) if(save)
_codelist.append(code); _codelist.append(code);
lock.unlock(); lock.unlock();
return ok; return ok;
@ -67,10 +65,10 @@ namespace Py
void PyInterpreter::execFile(QString file) void PyInterpreter::execFile(QString file)
{ {
QByteArray la = file.toLocal8Bit(); QByteArray la = file.toLocal8Bit();
char *c = la.data(); char* c = la.data();
FILE *fp = nullptr; FILE* fp = nullptr;
fp = fopen(c, "r"); fp = fopen(c, "r");
if (fp != nullptr) if(fp != nullptr)
PyRun_SimpleFile(fp, c); PyRun_SimpleFile(fp, c);
} }
@ -82,7 +80,7 @@ namespace Py
QString PyInterpreter::getCodeAt(int i) QString PyInterpreter::getCodeAt(int i)
{ {
QString c; QString c;
if (i >= 0 && i < _codelist.size()) if(i >= 0 && i < _codelist.size())
c = _codelist.at(i); c = _codelist.at(i);
return c; return c;
} }
@ -96,4 +94,4 @@ namespace Py
{ {
return _codelist; return _codelist;
} }
} } // namespace Py

View File

@ -47,7 +47,6 @@ SARibbonMainWindow::SARibbonMainWindow(QWidget *parent, bool useRibbon)
{ {
m_d->init(); m_d->init();
m_d->useRibbon = useRibbon; m_d->useRibbon = useRibbon;
qDebug() << windowFlags();
if (useRibbon) { if (useRibbon) {
qDebug() << "sa ribbon version:" << SA_RIBBON_BAR_VERSION_STR; qDebug() << "sa ribbon version:" << SA_RIBBON_BAR_VERSION_STR;
setRibbonTheme(ribbonTheme()); setRibbonTheme(ribbonTheme());

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1011 B

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1010 B

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 319 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1014 B

After

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1016 B

After

Width:  |  Height:  |  Size: 115 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 475 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 377 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1013 B

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1018 B

After

Width:  |  Height:  |  Size: 127 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 405 KiB

After

Width:  |  Height:  |  Size: 360 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 961 B

After

Width:  |  Height:  |  Size: 736 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 886 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 991 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 691 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 458 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 531 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 525 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 513 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 621 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 534 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 590 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 532 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 646 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 753 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 948 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 562 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 543 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 382 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 754 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 457 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 588 B

Some files were not shown because too many files have changed in this diff Show More