Przeglądaj źródła

0615 tecplt ascii

caizm 2 lat temu
rodzic
commit
460231cd84

+ 18 - 13
CAE_Solution/src/VTK/Manager/ResultMeshManager.cpp

@@ -12,6 +12,7 @@
 #include "../display/solidsurfacewidget.h"
 #include "../display/streamwidget.h"
 #include "../display/vectordisplay.h"
+#include "../display/contourinimationdisplay.h"
 #include "../visualization_VTK/vtkVISUnContour.h"
 #include "../visualization_VTK/vtkvisunstructuredgridsource.h"
 #include "ResultMeshManager.h"
@@ -39,6 +40,7 @@
 #include "../widget/vectorDisplaywidget.h"
 #include "../widget/contourinimationw.h"
 
+
 //ResultMeshManager* ResultMeshManager::m_pInstance = 0;
 
 /**
@@ -78,7 +80,7 @@ ResultMeshManager::ResultMeshManager()
     titleSize_ = 6;
     labelSize_ = 5;
 
-//    animationWidget_ = NULL;
+    animationWidget_ = NULL;
     contourWidget_ = NULL;
     lineWidget_ = NULL;
     vectorWidget_ = NULL;
@@ -358,6 +360,9 @@ bool ResultMeshManager::LoadData(QString name)
                 HaveModalMeshFlag = true;
             MeshVec_ = TimeMeshVec_;
         }
+    }else if(extType == "dat"){
+        meshObj_ = new Mesh_Tecplot;
+        loadstate = meshObj_->Load_Ascii(name.toStdString());//0614append
     }
     else
     {
@@ -1110,7 +1115,7 @@ void ResultMeshManager::SetAnimationWidget(ContourInimationW *w)
     animationWidget_ = w;
     if (meshObj_ != NULL)
     {
-        //w->SetTypeEnable(HaveModalMeshFlag);
+        w->SetTypeEnable(HaveModalMeshFlag);
         animationWidget_->SetSolveTime(GetSolveTime());
         animationWidget_->SetZoneNameVector(zoneNameVec_);
     }
@@ -1357,12 +1362,12 @@ void ResultMeshManager::SetDisplayType(int type)
   */
 void ResultMeshManager::InitWidgetsParameter()
 {
-//    if (animationWidget_ != NULL)
-//    {
-//        animationWidget_->SetTypeEnable(HaveModalMeshFlag);
-//        animationWidget_->SetSolveTime(GetSolveTime());
-//        animationWidget_->SetZoneNameVector(zoneNameVec_);
-//    }
+    if (animationWidget_ != NULL)
+    {
+        animationWidget_->SetTypeEnable(HaveModalMeshFlag);
+        animationWidget_->SetSolveTime(GetSolveTime());
+        animationWidget_->SetZoneNameVector(zoneNameVec_);
+    }
     if (contourWidget_ != NULL)
     {
         contourWidget_->SetNameTypeMap(GetNameTypeMap());
@@ -2146,7 +2151,7 @@ void ResultMeshManager::UpdataZoomModel(double factor)
     DisplayMesh(render_);
     HideAllActors();
     DisplayMeshByIndex(0);
-    //animationWidget_->SlotStart();
+    animationWidget_->SlotStart();
     render_->ZoomToExtents();
 }
 
@@ -2302,8 +2307,8 @@ void ResultMeshManager::ChangeMeshType(int type)
             DisplayMeshByIndex(0);
             SetNameTypeMap();
             InitWidgetsParameter();
-//            animationWidget_->SlotStart();
-//            animationWidget_->InitScaleFactor();
+            animationWidget_->SlotStart();
+            animationWidget_->InitScaleFactor();
             render_->ZoomToExtents();
         }else if (type == 1)
         {
@@ -2314,8 +2319,8 @@ void ResultMeshManager::ChangeMeshType(int type)
             DisplayMeshByIndex(0);
             SetNameTypeMap();
             InitWidgetsParameter();
-//            animationWidget_->SlotStart();
-//            animationWidget_->InitScaleFactor();
+            animationWidget_->SlotStart();
+            animationWidget_->InitScaleFactor();
             render_->ZoomToExtents();
         }
     }

+ 4 - 1
CAE_Solution/src/VTK/MeshDS/CellDS.h

@@ -24,7 +24,10 @@ class  CellBase
 protected:
     CellBase() {type_ = UnknowCell; pointNum_ = 0; tag_ = NULLTAG;}
 public:
-    virtual ~CellBase() {}
+    virtual ~CellBase() {
+        pointsVec_.clear();
+        pointsVec_.shrink_to_fit();
+                        }
     CellType GetType() const {return type_;}
     size_t GetPointNumber() const {return pointNum_;}
     int GetPoint(size_t id) const

+ 56 - 0
CAE_Solution/src/VTK/display/contourinimationdisplay.cpp

@@ -0,0 +1,56 @@
+#include "contourinimationdisplay.h"
+
+/*
+ * @brief: the constructor
+ * @param:
+ * @ret:
+ * @birth: created by czm in 20230607
+ */
+contourinimationDisplay::contourinimationDisplay(ResultManager* c)
+{
+    this->Cmanager = c;
+}
+
+/*
+ * @brief: the destructor
+ * @param:
+ * @ret:
+ * @birth: created by czm in 20230607
+ */
+contourinimationDisplay::~contourinimationDisplay()
+{
+    this->Cmanager = NULL;
+}
+
+/*
+ * @brief: update from inters
+ * @param:void
+ * @ret:void
+ * @birth: created by czm in 20230607
+ */
+void contourinimationDisplay::updateFromInters()
+{
+    //update setting data from widgets.
+}
+
+/*
+ * @brief: update from params
+ * @param: void
+ * @ret: void
+ * @birth: created by czm in 20230607
+ */
+void contourinimationDisplay::updateFromParams()
+{
+    //update setting data from params.
+}
+
+/*
+ * @brief: execute
+ * @param: void
+ * @ret: void
+ * @birth: created by czm in 20230607
+ */
+void contourinimationDisplay::execute()
+{
+    //apply setting data.
+}

+ 22 - 0
CAE_Solution/src/VTK/display/contourinimationdisplay.h

@@ -0,0 +1,22 @@
+#ifndef CONTOURINIMATIONDISPLAY_H
+#define CONTOURINIMATIONDISPLAY_H
+#include <QString>
+#include <QObject>
+#include "../widget/contourinimationw.h"
+class ResultManager;
+
+class contourinimationDisplay
+{
+public:
+    contourinimationDisplay(ResultManager* c);
+    virtual ~contourinimationDisplay();
+    virtual QString getName() { return QObject::tr("Contour"); }
+
+    virtual void updateFromInters();
+    virtual void updateFromParams();
+    virtual void execute();
+private:
+    ResultManager* Cmanager;
+};
+
+#endif // CONTOURINIMATIONDISPLAY_H

+ 4 - 2
CAE_Solution/src/VTK/display/display.pri

@@ -1,10 +1,12 @@
 HEADERS += \ 
-    $$PWD/*.h
+    $$PWD/*.h \
+    $$PWD/contourinimationdisplay.h
 
 
 
 		
 		
 SOURCES += \ 
-     $$PWD/*.cpp
+     $$PWD/*.cpp \
+    $$PWD/contourinimationdisplay.cpp
 

+ 251 - 3
CAE_Solution/src/VTK/mesh/mesh_tecplot.cpp

@@ -2,7 +2,7 @@
 #include "../MeshDS/PointDS.h"
 #include "../MeshDS/meshunstructured.h"
 #include "mesh_tecplot.h"
-
+#include <QStringList>
 
 
 /**
@@ -40,8 +40,7 @@ Mesh_Tecplot::~Mesh_Tecplot()
 bool Mesh_Tecplot::Load_Ascii(const string &gridFile)
 {
     ifstream infile(gridFile);
-    //return Load_Tecp_Ascii(infile);
-    return true;
+    return Load_Tecp_Ascii(infile);
 }
 
 /**
@@ -71,6 +70,173 @@ bool Mesh_Tecplot::Load_Binary(const string &gridFile)
   */
 bool Mesh_Tecplot::Load_Tecp_Ascii(ifstream &infile)
 {
+    if(!infile.good())
+    {
+        cout<<"Source Tecplot File is not found!"<<endl;
+        return false;
+    }
+    char str[1024];
+    infile.getline(str,1024);
+    string title = str;
+    title = title.substr(title.find_first_of("\"")+1);
+    title = title.substr(0,title.find_first_of("\""));
+    title_ = (char*)title.c_str();
+    char str1[1024];
+    infile.getline(str1,1024);
+    string variables = str1;
+    variables = variables.substr(variables.find_first_of("=")+1);
+    QStringList var_l= QString::fromStdString(variables).split(" ");
+    scalarName_.resize(var_l.size()-3);
+    scalarNumber_ = var_l.size()-3;
+    for(int i =3;i<var_l.size();i++){
+        scalarName_[i-3]=var_l[i].toStdString();
+    }
+    char str2[1024];
+    infile.getline(str2,1024);
+    string zone_temp = str2;
+    QStringList temp_vec = QString::fromStdString(zone_temp).split(",");
+    string temp = temp_vec[0].toStdString();
+    temp = temp.substr(temp.find_first_of("\"")+1);
+    temp = temp.substr(0,temp.find_first_of("\""));
+    zoneName_.push_back(temp);
+    solutionTime_=((temp_vec[1].split("=")[1]).simplified()).toDouble();
+    zoneNumber_ = 1;
+//    strandid_vec.push_back(((temp_vec[2].split("=")[1]).simplified()).toStdString());
+    int numOfPoint = temp_vec[3].split("=")[1].simplified().toInt();
+    int numOfCell = temp_vec[4].split("=")[1].simplified().toInt();
+    string datatype = temp_vec[5].split("=")[1].simplified().toStdString();
+    string celltype = temp_vec[6].split("=")[1].simplified().toStdString();
+    if(datatype == "feblock"){
+        ScalarsData_.resize(zoneNumber_);
+
+        vector<double*> temp_vec_data;
+        temp_vec_data.resize(scalarNumber_+3);
+        double * temp_data_x = new double[numOfPoint];
+        for(int i = 0;i<numOfPoint;i++){
+            infile>>temp_data_x[i];//x
+        }
+        temp_vec_data[0]=temp_data_x;
+
+        double * temp_data_y = new double[numOfPoint];
+        for(int i =0;i<numOfPoint;i++){
+            infile>>temp_data_y[i];//y
+        }
+        temp_vec_data[1]=temp_data_y;
+
+        double * temp_data_z = new double[numOfPoint];
+        for(int i =0;i<numOfPoint;i++){
+            infile>>temp_data_z[i];//z
+        }
+        temp_vec_data[2]=temp_data_z;
+
+        double * temp_data_rho = new double[numOfPoint];
+        for(int i =0;i<numOfPoint;i++){
+            infile>>temp_data_rho[i];//r
+        }
+        temp_vec_data[3]=temp_data_rho;
+
+        double * temp_data_u = new double[numOfPoint];
+        for(int i =0;i<numOfPoint;i++){
+            infile>>temp_data_u[i];//u
+        }
+        temp_vec_data[4]=temp_data_u;
+
+        double * temp_data_v = new double[numOfPoint];
+        for(int i =0;i<numOfPoint;i++){
+            infile>>temp_data_v[i];//v
+        }
+        temp_vec_data[5]=temp_data_v;
+
+        double * temp_data_w = new double[numOfPoint];
+        for(int i =0;i<numOfPoint;i++){
+            infile>>temp_data_w[i];//w
+        }
+        temp_vec_data[6]=temp_data_w;
+
+        double * temp_data_p = new double[numOfPoint];
+        for(int i =0;i<numOfPoint;i++){
+            infile>>temp_data_p[i];//p
+        }
+        temp_vec_data[7]=temp_data_p;
+
+        double * temp_data_cp = new double[numOfPoint];
+        for(int i =0;i<numOfPoint;i++){
+            infile>>temp_data_cp[i];//cp
+        }
+        temp_vec_data[8]=temp_data_cp;
+
+        double * temp_data_mach = new double[numOfPoint];
+        for(int i =0;i<numOfPoint;i++){
+            infile>>temp_data_mach[i];//mach
+        }
+        temp_vec_data[9]=temp_data_mach;
+
+        ScalarsData_[0] = temp_vec_data;
+    }else if(datatype=="fepoint"){
+        ScalarsData_.resize(zoneNumber_);
+
+        vector<double*> temp_vec_data;
+        double * temp_data_x = new double[numOfPoint];
+        double * temp_data_y = new double[numOfPoint];
+        double * temp_data_z = new double[numOfPoint];
+        double * temp_data_rho = new double[numOfPoint];
+        double * temp_data_u = new double[numOfPoint];
+        double * temp_data_v = new double[numOfPoint];
+        double * temp_data_w = new double[numOfPoint];
+        double * temp_data_p = new double[numOfPoint];
+        double * temp_data_cp = new double[numOfPoint];
+        double * temp_data_mach = new double[numOfPoint];
+        for(int i=0;i<numOfPoint;i++){
+            infile>>temp_data_x[i]>>temp_data_y[i]>>temp_data_z[i]>>temp_data_rho[i]>>temp_data_u[i]>>temp_data_v[i]>>temp_data_w[i]>>temp_data_p[i]>>temp_data_cp[i]>>temp_data_mach[i];
+        }
+        temp_vec_data.push_back(temp_data_x);
+        temp_vec_data.push_back(temp_data_y);
+        temp_vec_data.push_back(temp_data_z);
+        temp_vec_data.push_back(temp_data_rho);
+        temp_vec_data.push_back(temp_data_u);
+        temp_vec_data.push_back(temp_data_v);
+        temp_vec_data.push_back(temp_data_w);
+        temp_vec_data.push_back(temp_data_p);
+        temp_vec_data.push_back(temp_data_cp);
+        temp_vec_data.push_back(temp_data_mach);
+
+        ScalarsData_[0] = temp_vec_data;
+    }
+    vector<vector<int>> cell_vec;
+    if(celltype == "tetrahedron"){//tetrahedron四节点四面体   
+        cell_vec.resize(numOfCell);
+        for(int i=0;i<numOfCell;i++){
+            vector<int> cell_tmp;
+            cell_tmp.resize(4);
+            infile>>cell_tmp[0]>>cell_tmp[1]>>cell_tmp[2]>>cell_tmp[3];
+            cell_vec[i] = cell_tmp;
+        }
+    }else if(celltype == "triangle"){//triangle 三节点三角形
+        cell_vec.resize(numOfCell);
+        for(int i=0;i<numOfCell;i++){
+            vector<int> cell_tmp;
+            cell_tmp.resize(3);
+            infile>>cell_tmp[0]>>cell_tmp[1]>>cell_tmp[2];
+            cell_vec[i] = cell_tmp;
+        }
+    }else if(celltype == "quadrilateral"){//quadrilateral 四节点四边形单元
+        cell_vec.resize(numOfCell);
+        for(int i=0;i<numOfCell;i++){
+            vector<int> cell_tmp;
+            cell_tmp.resize(4);
+            infile>>cell_tmp[0]>>cell_tmp[1]>>cell_tmp[2]>>cell_tmp[3];
+            cell_vec[i] = cell_tmp;
+        }
+    }else if(celltype == "brick"){//brick八节点六面体
+        cell_vec.resize(numOfCell);
+        for(int i=0;i<numOfCell;i++){
+            vector<int> cell_tmp;
+            cell_tmp.resize(8);
+            infile>>cell_tmp[0]>>cell_tmp[1]>>cell_tmp[2]>>cell_tmp[3]>>cell_tmp[4]>>cell_tmp[5]>>cell_tmp[6]>>cell_tmp[7];
+            cell_vec[i] = cell_tmp;
+        }
+    }
+    SaveData_Ascii(numOfPoint,numOfCell,celltype,cell_vec);
     return true;
 }
 
@@ -614,6 +780,88 @@ void Mesh_Tecplot::SaveData_Binary(
     }
 }
 
+/*
+ * @brief: save data inte unmesh
+ * @param: point number,cell number,cell type,cell vector
+ * @ret: void
+ * @birth: created by czm in 20230613
+ */
+void Mesh_Tecplot::SaveData_Ascii(int numofpoint, int numofcell, string celltype, vector<vector<int> > &cell_vec)
+{
+    MeshUnstructured* unMesh = new MeshUnstructured();
+    int scalarNumber= scalarNumber_;
+    //unMesh->SetType(MeshType::Unstructured);//设置非结构化类型
+    PointsDS* points  = new PointsDS();
+    points->SetPointNumber(numofpoint);
+    for(int i =0;i<numofpoint;i++){
+        points->SetPoint(i,ScalarsData_[0][0][i],ScalarsData_[0][1][i],ScalarsData_[0][2][i]);
+    }
+    zonePointsVec_.push_back(points);
+    unMesh->SetPoints(points);
+
+    CellBase* cell =0;
+    if(celltype == "tetrahedron"){
+        for(int i =0;i<numofcell;i++){
+            cell = new CellTetra();
+            cell->SetPoint(0,cell_vec[i][0]-1);
+            cell->SetPoint(1,cell_vec[i][1]-1);
+            cell->SetPoint(2,cell_vec[i][2]-1);
+            cell->SetPoint(3,cell_vec[i][3]-1);
+            unMesh->SetCell(i,cell);
+            delete cell;
+        }
+    }else if(celltype == "triangle"){
+        for(int i =0;i<numofcell;i++){
+            cell = new CellTetra();
+            cell->SetPoint(0,cell_vec[i][0]);
+            cell->SetPoint(1,cell_vec[i][1]);
+            cell->SetPoint(2,cell_vec[i][2]);
+            unMesh->SetCell(i,cell);
+            delete cell;
+        }
+    }else if(celltype == "quadrilateral"){
+        for(int i =0;i<numofcell;i++){
+            cell = new CellTetra();
+            cell->SetPoint(0,cell_vec[i][0]);
+            cell->SetPoint(1,cell_vec[i][1]);
+            cell->SetPoint(2,cell_vec[i][2]);
+            cell->SetPoint(3,cell_vec[i][3]);
+            unMesh->SetCell(i,cell);
+            delete cell;
+        }
+    }else if(celltype == "brick"){
+        for(int i =0;i<numofcell;i++){
+            cell = new CellTetra();
+            cell->SetPoint(0,cell_vec[i][0]);
+            cell->SetPoint(1,cell_vec[i][1]);
+            cell->SetPoint(2,cell_vec[i][2]);
+            cell->SetPoint(3,cell_vec[i][3]);
+            cell->SetPoint(4,cell_vec[i][4]);
+            cell->SetPoint(5,cell_vec[i][5]);
+            cell->SetPoint(6,cell_vec[i][6]);
+            cell->SetPoint(7,cell_vec[i][7]);
+            unMesh->SetCell(i,cell);
+            delete cell;
+        }
+    }
+    /*************************************/
+    //方便使用meshtovtksource这个接口进行转换拓扑
+    zoneScalarType_.resize(1);//tecplt单个文件只有一个zone
+    zoneScalarShareVec_.resize(1);
+    vector<int> scalar_share_tmp;
+    vector<int> scalar_type_tmp;
+    scalar_share_tmp.resize(scalarNumber+3);
+    scalar_type_tmp.resize(scalarNumber+3);
+    for(int i = 0;i<scalarNumber+3;i++){
+        scalar_type_tmp[i] = 0;//pointscalar
+        scalar_share_tmp[i] = -1;//unshare
+    }
+    zoneScalarType_[0] = scalar_type_tmp;
+    zoneScalarShareVec_[0] = scalar_share_tmp;
+    /*****************************************/
+    zoneMeshVec_.push_back(unMesh);
+}
+
 /**
   * @brief save ascii ugrid file.
   *

+ 6 - 0
CAE_Solution/src/VTK/mesh/mesh_tecplot.h

@@ -33,6 +33,12 @@ private:
         vector<int> &zoneNE_Vec,
         int **zoneEleConnectivity
     );
+
+    void SaveData_Ascii(
+            int numofpoint,
+            int numofcell,
+            string celltype,
+            vector<vector<int>> &cell_vec);
 };
 
 

+ 61 - 7
CAE_Solution/src/VTK/widget/contourinimationw.cpp

@@ -13,6 +13,7 @@ ContourInimationW::ContourInimationW()
     m_time.clear();
     ZoneNameVec.clear();
     m_speed = 25.0;
+    slider = 0;
 }
 
 /*
@@ -34,7 +35,7 @@ ContourInimationW::~ContourInimationW(){
 void ContourInimationW::SetSolveTime(set<double> time)
 {
     //slider->setSingleStep(1);
-   // slider->setMinimum(0);
+    // slider->setMinimum(0);
     max = time.size();
     //slider->setMaximum(max - 1);
     m_time.clear();
@@ -42,6 +43,7 @@ void ContourInimationW::SetSolveTime(set<double> time)
     {
         m_time.append(*it);
     }
+    //InitTimer();
     le_firstStep = 1;
     le_endStep = max;
     SetLeText();
@@ -49,12 +51,17 @@ void ContourInimationW::SetSolveTime(set<double> time)
 
 void ContourInimationW::SetScaleFactor(double factor)
 {
-    ldt_scale = factor;
+    ldt_scale = QString::number(factor);
 }
 
 double ContourInimationW::GetScaleFactor()
 {
-    return ldt_scale;
+    if(!ldt_scale.isEmpty()){
+        double factor = ldt_scale.toDouble();
+        return factor;
+    }else{
+        return 0;
+    }
 }
 
 /*
@@ -110,7 +117,7 @@ void ContourInimationW::SlotNext()
 void ContourInimationW::SlotQuick()
 {
     m_speed /= 2;
-    le_time = 1000.0/m_speed;
+    le_time = 1000.0/m_speed;//interval后的值
 }
 
 /*
@@ -140,11 +147,29 @@ void ContourInimationW::SlotChange()
             pb_end = true;
             pb_next = true;
             flag = false;
-
+            //SlotPlay();
+        }else{
+            pb_start = false;
+            pb_last = false;
+            pb_end = false;
+            pb_next = false;
         }
     }
 }
 
+//void ContourInimationW::SlotPlay()
+//{
+//    if (flag)
+//    {
+//        flag = false;
+//        timer->start(m_speed);
+//    }else
+//    {
+//        flag = true;
+//        timer->stop();
+//    }
+//}
+
 /*
  * @brief: set letext
  * @param: void
@@ -170,12 +195,17 @@ int ContourInimationW::GetIndex()
     return le_currStep-1;
 }
 
+void ContourInimationW::FrameNumberEdit()
+{
+    le_time_state = true;
+}
+
 void ContourInimationW::InitScaleFactor(double factor)
 {
     if(factor == 1.0){
-        ldt_scale = 1;
+        ldt_scale = "1";
     }else{
-        ldt_scale =factor;
+        ldt_scale =QString::number(factor);
     }
 }
 
@@ -188,6 +218,28 @@ void ContourInimationW::InitScaleFactor(double factor)
 void ContourInimationW::SetFrameNumber()
 {
     m_speed = 1000/le_time;
+    le_time_state = false;
+}
+
+/*
+ * @brief: get vector m_time
+ * @param: void
+ * @ret: vector
+ * @birth: created by czm in 20230607
+ */
+QVector<double> ContourInimationW::getm_time()
+{
+    return m_time;
+}
+
+int ContourInimationW::getSlider()
+{
+    return slider;
+}
+
+void ContourInimationW::SetTypeEnable(bool flag)
+{
+    cbx_type = flag;
 }
 
 /*
@@ -204,3 +256,5 @@ void ContourInimationW::SetZoneNameVector(vector<string> Zone)
         ZoneNameVec.push_back(*it);
     }
 }
+
+

+ 11 - 3
CAE_Solution/src/VTK/widget/contourinimationw.h

@@ -1,8 +1,10 @@
 #ifndef CONTOURINIMATIONW_H
 #define CONTOURINIMATIONW_H
 #include <vector>
+#include <QObject>
 #include <set>
 #include <QVector>
+
 using namespace std;
 
 class ContourInimationW
@@ -17,6 +19,7 @@ public:
     void SetZoneNameVector(vector<string> Zone);
     void SetLeText();
     int GetIndex();
+    void FrameNumberEdit();
     void InitScaleFactor(double factor = 1);
     void SlotStart();
     void SlotEnd();
@@ -25,8 +28,12 @@ public:
     void SlotQuick();
     void SlotLow();
     void SlotChange();
+    //void SlotPlay();
     void SetFrameNumber();
-private:
+    QVector<double> getm_time();
+    int getSlider();
+    void SetTypeEnable(bool flag);
+public:
     QVector<double> m_time;
     int max;
     bool flag;
@@ -38,12 +45,13 @@ private:
     int le_time;
     int le_currStep;
     int lb_solveTime;
-    int ldt_scale;
+    QString ldt_scale;
     bool pb_start;
     bool pb_end;
     bool pb_last;
     bool pb_next;
-
+    bool le_time_state;
+    bool cbx_type;
 };
 
 #endif // CONTOURINIMATIONW_H

+ 42 - 0
CAE_Solution/src/threadPool_and_statemachine/dealWith/boostjsonobject.cpp

@@ -14,6 +14,7 @@ boostJsonObject::boostJsonObject()
     sf_struct = NULL;
     sd_struct = NULL;
     sm_struct = NULL;
+    ci_struct = NULL;
     usrId.clear();
     solverConfigid.clear();
     proId.clear();
@@ -57,6 +58,10 @@ boostJsonObject::~boostJsonObject()
         delete sm_struct;
         sm_struct = NULL;
     }
+    if(ci_struct){
+        delete ci_struct;
+        ci_struct = NULL;
+    }
     qDeleteAll(vec_sd_struct);
 }
 
@@ -132,6 +137,7 @@ boostJsonObject *boostJsonObject::operator=(boostJsonObject *object)
     this->sd_struct = object->sd_struct;
     this->vec_sd_struct = object->vec_sd_struct;
     this->sm_struct = object->sm_struct;
+    this->ci_struct = object->ci_struct;
     return this;
 }
 
@@ -213,6 +219,25 @@ std::string boostJsonObject::ToJson(std::string type, QMap<QString, std::string>
         item.put("dataW",map_["dataW"]);
     }else if(type == "exception"){
         item.put("Error",map_["Error"]);
+    }else if(type == "animation_quick"){
+        item.put("msgType","animation_quick");
+        item.put("le_time",map_["le_time"]);
+    }else if(type == "animation_low"){
+        item.put("msgType","animation_low");
+        item.put("le_time",map_["le_time"]);
+    }else if(type == "animation_slider"){
+        item.put("msgType","animation_slider");
+        item.put("slider",map_["slider"]);
+    }else if(type == "importResult_animation"){
+        item.put("msgType","animation_param");
+        item.put("min_slider",map_["min_slider"]);
+        item.put("slider",map_["slider"]);
+        item.put("max_slider",map_["max_slider"]);
+        item.put("firststep",map_["firststep"]);
+        item.put("endstep",map_["endstep"]);
+        item.put("currstep",map_["currstep"]);
+        item.put("zone",map_["zone"]);
+        item.put("le_time",map_[""]);
     }
     stringstream tmp;
     boost::property_tree::json_parser::write_json(tmp,item);
@@ -350,4 +375,21 @@ string boostJsonObject::ToJson_updateslice(QMap<int, SliceDisplayWidget *>map_)
     return mmsg.str();
 }
 
+string boostJsonObject::ToJson(string type, QMap<QString, string> map_, int num)
+{
+    boost::property_tree::ptree root;
+    root.put("usrId",this->usrId);
+    root.put("solverConfigid",this->solverConfigid);
+    root.put("proId",this->proId);
+    root.put("action",this->action);
+    if(type == "img"){
+        root.put("img",map_["img"]);
+        root.put("step",num);
+    }
+    root.put("paramJson","");
+    stringstream mmsg;
+    boost::property_tree::json_parser::write_json (mmsg,root);
+    return mmsg.str();
+}
+
 

+ 2 - 0
CAE_Solution/src/threadPool_and_statemachine/dealWith/boostjsonobject.h

@@ -23,6 +23,7 @@ public:
     std::string ToJson(std::string type,QMap<QString,std::string> map_);
     void FromParamJson(std::string);
     std::string ToJson_updateslice(QMap<int,SliceDisplayWidget*>);
+    std::string ToJson(std::string type, QMap<QString, std::string> map_,int num);
 public:
     std::string usrId;
     std::string solverConfigid;
@@ -39,6 +40,7 @@ public:
     sliceDisplay_struct* sd_struct;//slice
     vector<sliceDisplay_struct*> vec_sd_struct;
     streamDisplay_struct* sm_struct;//stream
+    contourinimationw_struct* ci_struct;//contourinimation;
 };
 
 #endif // BOOSTJSONOBJECT_H

+ 10 - 0
CAE_Solution/src/threadPool_and_statemachine/dealWith/display_struct.h

@@ -83,5 +83,15 @@ public:
     bool showstate;
     bool toolstate;
 };
+//结果动画msg类
+class contourinimationw_struct
+{
+public:
+    contourinimationw_struct(){}
+    ~contourinimationw_struct(){}
+    string order;
+    int type;
+    int slider;
+};
 
 #endif // DISPLAY_STRUCT_H

+ 147 - 14
CAE_Solution/src/threadPool_and_statemachine/dealWith/handlepool.cpp

@@ -201,8 +201,8 @@ void handlePool::operateRender(boostJsonObject* object,QVTKRenderer* render_)
             cout<<"please import tecplot result first!"<<endl;
         }
         return;
-    }else if(object->action == ""){
-        if(!result_contourinimationdisplay(object,render_,"")){
+    }else if(object->action == "ContourInimationwDisplay"){
+        if(!result_contourinimationdisplay(object,render_)){
             cout<<"please import tecplot result forst!"<<endl;
         }
         return;
@@ -291,6 +291,7 @@ void handlePool::judgeLoaddata(boostJsonObject *object, QVTKRenderer *render_)
 bool handlePool::resultImport(boostJsonObject *object_, QVTKRenderer *renderer_)
 {
     string type_;
+    //object_->fileName = "tfg_part1_tec_volume_timestep100.dat,tfg_part1_tec_volume_timestep200.dat";//单个文件?
     //object_->fileName = "whole_part1.plt,whole_part2.plt";
     size_t found = object_->fileName.find_first_of(',');
     if(found==string::npos){//单个文件
@@ -333,7 +334,7 @@ bool handlePool::resultImport(boostJsonObject *object_, QVTKRenderer *renderer_)
         }
     }
     //object_->filePath = "C:\\Users\\Administrator\\Desktop\\Postprocess_Binary";//测试路径
-    //object_->filePath = "C:\\Users\\Administrator\\Desktop\\VTK";//测试路径
+    //object_->filePath = "C:\\Users\\Administrator\\Documents\\WeChat Files\\wxid_18qjhi0tq90d22\\FileStorage\\File\\2023-06";//测试路径
     QDir dir(QString::fromStdString(object_->filePath));
     if(!dir.exists()){
         return false;
@@ -356,11 +357,15 @@ bool handlePool::resultImport(boostJsonObject *object_, QVTKRenderer *renderer_)
         bool flag = true;
         rsManager = new ResultMeshManager();
         rsManager->Clear();
-        rsManager->fileType = "plt";
+        if(object_->fileType == "ascii"){
+            rsManager->fileType ="plt_ascii";
+        }else if(object_->fileType == "binary"){
+           rsManager->fileType = "plt_binary";
+        }
         for(int i =0;i<fileName_list.size();i++){
-            bool f =rsManager->LoadData(QString::fromStdString(object_->filePath)+"/"+fileName_list[i]);//加载
+            bool f =rsManager->LoadData(QString::fromStdString(object_->filePath)+"/"+fileName_list[0]);//加载
             if(f){
-                rsManager->SetSaveIndex(i);
+                rsManager->SetSaveIndex(0);
                 if(renderer_){
                     rsManager->DisplayMesh(renderer_);
                 }
@@ -430,6 +435,9 @@ bool handlePool::resultImport(boostJsonObject *object_, QVTKRenderer *renderer_)
 
     StreamDisplayWidget* streamW = new StreamDisplayWidget();//流线窗口初始化参数
     rsManager->SetStremWidget(streamW);
+
+    ContourInimationW* cinimationW = new ContourInimationW();
+    rsManager->SetAnimationWidget(cinimationW);
     /********************************************/
     renderer_->widgetFlag = QVTKRenderer::WidgetModel::ResultModel;//设置当前窗口模型状态
     if(qmapResultmanager.contains(object_->proId)){//加载不同的结果文件
@@ -445,6 +453,7 @@ bool handlePool::resultImport(boostJsonObject *object_, QVTKRenderer *renderer_)
     emit sendImg_handlePoolToSendstate(object_->ToJson("importResult_vector",buildResultImport_msg("Vector",rsManager)));//发送矢量结果数据
     emit sendImg_handlePoolToSendstate(object_->ToJson("importResult_solidsurface",buildResultImport_msg("Solidsurface",rsManager)));//发送实体表面结果数据
     emit sendImg_handlePoolToSendstate(object_->ToJson("importResult_stream",buildResultImport_msg("Stream",rsManager)));//发送流线结果数据
+    emit sendImg_handlePoolToSendstate(object_->ToJson("importResult_animation",buildResultImport_msg("animation",rsManager)));
     send_picture(object_,renderer_);
     return true;
 }
@@ -659,8 +668,69 @@ bool handlePool::result_streamdisplay(boostJsonObject *object_, QVTKRenderer *re
  * @ret: bool
  * @birth: created by czm in 20230606
  */
-bool handlePool::result_contourinimationdisplay(boostJsonObject *, QVTKRenderer *, QString)
+bool handlePool::result_contourinimationdisplay(boostJsonObject *object_, QVTKRenderer *render_)
 {
+    contourinimationDisplay* cidisplay = NULL;
+    string order_ = object_->ci_struct->order;
+    if(!qmapResultmanager.contains(object_->proId))return false;
+    render_ = qmapRender[object_->proId];
+    ResultManager* resultmm = qmapResultmanager[object_->proId]->resultManager_;
+    if(map_cinimationDisplay.contains(object_->proId)){
+        cidisplay = map_cinimationDisplay[object_->proId];
+    }else{
+        cidisplay = new contourinimationDisplay(resultmm);
+        map_cinimationDisplay.insert(object_->proId,cidisplay);
+    }
+
+    ContourInimationW* ciw = resultmm->animationWidget_;
+    if(order_ == "quick"){
+        ciw->SlotQuick();
+        emit sendImg_handlePoolToSendstate(object_->ToJson("animation_quick",buildResultImport_msg("animation_quick",resultmm,object_)));
+        return true;
+    }else if(order_ == "low"){
+        ciw->SlotLow();
+        emit sendImg_handlePoolToSendstate(object_->ToJson("animation_low",buildResultImport_msg("animation_low",resultmm,object_)));
+        return true;
+    }else if(order_ == "play"){
+        ciw->slider = object_->ci_struct->slider;
+        for(int i = ciw->slider;i<ciw->max;i++){
+            animationSliderChanged(QString::fromStdString(object_->proId));
+            send_picture(object_,render_,i);
+        }
+        return true;
+    }else if(order_ == "start"){
+        ciw->SlotStart();
+        animationSliderChanged(QString::fromStdString(object_->proId));
+        emit sendImg_handlePoolToSendstate(object_->ToJson("animation_slider",buildResultImport_msg("animation_slider",resultmm,object_)));
+    }else if(order_ == "end"){
+        ciw->SlotEnd();
+        animationSliderChanged(QString::fromStdString(object_->proId));
+        emit sendImg_handlePoolToSendstate(object_->ToJson("animation_slider",buildResultImport_msg("animation_slider",resultmm,object_)));
+    }else if(order_ == "next"){
+        ciw->SlotNext();
+        animationSliderChanged(QString::fromStdString(object_->proId));
+        emit sendImg_handlePoolToSendstate(object_->ToJson("animation_slider",buildResultImport_msg("animation_slider",resultmm,object_)));
+    }else if(order_ == "last"){
+        ciw->SlotLast();
+        animationSliderChanged(QString::fromStdString(object_->proId));
+        emit sendImg_handlePoolToSendstate(object_->ToJson("animation_slider",buildResultImport_msg("animation_slider",resultmm,object_)));
+    }else if(order_ == "edit"){//interval apply
+        ciw->FrameNumberEdit();
+        return true;
+    }else if(order_ == "apply"){//interval apply
+        ciw->SetFrameNumber();
+        return true;
+    }else if(order_ == "scaleApply"){//scale apply
+        resultmm->UpdataZoomModel(ciw->GetScaleFactor());
+        emit sendImg_handlePoolToSendstate(object_->ToJson("animation_slider",buildResultImport_msg("animation_slider",resultmm,object_)));
+    }else if(order_ == "typeChange"){//下拉框改变
+        resultmm->ChangeMeshType(object_->ci_struct->type);
+        emit sendImg_handlePoolToSendstate(object_->ToJson("animation_slider",buildResultImport_msg("animation_slider",resultmm,object_)));
+    }else if(order_ == "checkboxchange"){//checkbox选择
+        //resultmm->SetShowHideState(vec);
+        resultmm->DisplayMeshByIndex(resultmm->animationWidget_->GetIndex());
+    }
+    send_picture(object_,render_);
     return true;
 }
 
@@ -680,7 +750,7 @@ QMap<QString,string> handlePool::buildResultImport_msg(QString type,ResultManage
         map<string,int> map_ = cmanager->GetNameTypeMap();
         string msg;
         for(map<string,int>::iterator it=map_.begin();it!=map_.end();it++){
-            if(cmanager->fileType!="VTK"){
+            if(cmanager->fileType =="plt_binary"){
                 msg+=removeSpaces(it->first);
             }else{
                 msg+=it->first;
@@ -693,7 +763,7 @@ QMap<QString,string> handlePool::buildResultImport_msg(QString type,ResultManage
         map_tmp.insert("nameTypes",msg);
         msg.clear();
         for(int i=0;i<cmanager->GetMeshScalarNameVec().size();i++){
-            if(cmanager->fileType!="VTK"){
+            if(cmanager->fileType=="plt_binary"){
                 msg += removeSpaces(cmanager->GetMeshScalarNameVec()[i]);
             }else{
                 msg+=cmanager->GetMeshScalarNameVec()[i];
@@ -711,7 +781,7 @@ QMap<QString,string> handlePool::buildResultImport_msg(QString type,ResultManage
         map_tmp.insert("range1",msg);
         msg.clear();
         msg = cmanager->GetMeshScalarNameVec()[0];
-        if(cmanager->fileType!="VTK"){
+        if(cmanager->fileType=="plt_binary"){
             map_tmp.insert("scalarName",removeSpaces(msg));
         }else{
             map_tmp.insert("scalarName",msg);
@@ -759,7 +829,7 @@ QMap<QString,string> handlePool::buildResultImport_msg(QString type,ResultManage
         string msg;
         StreamDisplayWidget* smdW = cmanager->streamW_;
         for(int i = 0; i<smdW->dataU.size();i++){
-            if(cmanager->fileType!="VTK"){
+            if(cmanager->fileType=="plt_binary"){
                 msg+=removeSpaces(smdW->dataU[i]);
             }else{
                 msg+=smdW->dataU[i];
@@ -770,7 +840,7 @@ QMap<QString,string> handlePool::buildResultImport_msg(QString type,ResultManage
         map_tmp.insert("dataU",msg);
         msg.clear();
         for(int j = 0;j<smdW->dataV.size();j++){
-            if(cmanager->fileType!="VTK"){
+            if(cmanager->fileType=="plt_binary"){
                 msg+=removeSpaces(smdW->dataV[j]);
             }else{
                 msg+=smdW->dataV[j];
@@ -781,7 +851,7 @@ QMap<QString,string> handlePool::buildResultImport_msg(QString type,ResultManage
         map_tmp.insert("dataV",msg);
         msg.clear();
         for(int k = 0; k <smdW->dataW.size();k++){
-            if(cmanager->fileType!="VTK"){
+            if(cmanager->fileType=="plt_binary"){
                 msg+=removeSpaces(smdW->dataW[k]);
             }else{
                 msg+=smdW->dataW[k];
@@ -791,6 +861,25 @@ QMap<QString,string> handlePool::buildResultImport_msg(QString type,ResultManage
         msg = msg.erase(msg.size()-1);
         map_tmp.insert("dataW",msg);
         msg.clear();
+    }else if(type=="Animation"){
+        string msg;
+        ContourInimationW* ciw = cmanager->animationWidget_;
+        map_tmp.insert("min_slider","0");
+        map_tmp.insert("slider","0");
+        map_tmp.insert("max_slider",to_string(ciw->max-1));
+        map_tmp.insert("firststep",to_string(ciw->le_firstStep));
+        map_tmp.insert("endstep",to_string(ciw->le_endStep));
+        map_tmp.insert("currstep",to_string(ciw->le_currStep));
+        for(int i =0;i<ciw->ZoneNameVec.size();i++){
+            msg+=ciw->ZoneNameVec[i];
+            msg+=",";
+        }
+        msg=msg.erase(msg.size()-1);
+        map_tmp.insert("zone",msg);
+        msg.clear();
+        map_tmp.insert("le_time","40");
+        map_tmp.insert("ldt_scale","1");
+        map_tmp.insert("lb_solvtime",to_string(ciw->m_time[0]));//time后的值
     }
     return map_tmp;
 }
@@ -819,7 +908,7 @@ QMap<QString, string> handlePool::buildResultImport_msg(QString type, ResultMana
         map_tmp.insert("min_position_z",to_string(sdwidget->GetPositionRange()[4]));
         map_tmp.insert("max_position_z",to_string(sdwidget->GetPositionRange()[5]));
         for(int i =0; i<sdwidget->GetVariableName_vector().size();i++){
-            if(cmanager->fileType!="VTK"){
+            if(cmanager->fileType=="plt_binary"){
                msg+= removeSpaces(sdwidget->GetVariableName_vector()[i]);
             }else{
                msg+= sdwidget->GetVariableName_vector()[i];
@@ -846,6 +935,18 @@ QMap<QString, string> handlePool::buildResultImport_msg(QString type, ResultMana
         map_tmp.insert("initialStep",to_string(smdW->initialStep));
         map_tmp.insert("maxPropagation",to_string(smdW->MaxPropagation));
         map_tmp.insert("minimumStep",to_string(smdW->MinimumStep));
+    }else if(type == "animation_quick")
+    {
+        ContourInimationW* ciw = cmanager->animationWidget_;
+        map_tmp.insert("le_time",to_string(ciw->le_time));
+    }else if(type == "animation_low")
+    {
+        ContourInimationW* ciw = cmanager->animationWidget_;
+        map_tmp.insert("le_time",to_string(ciw->le_time));
+    }else if(type == "animation_slider")
+    {
+        ContourInimationW* ciw = cmanager->animationWidget_;
+        map_tmp.insert("slider",to_string(ciw->slider));
     }
     return map_tmp;
 }
@@ -883,6 +984,20 @@ void handlePool::send_picture(boostJsonObject *object, QVTKRenderer *render_)
     object = NULL;
 }
 
+void handlePool::send_picture(boostJsonObject *object, QVTKRenderer *render_, int step)
+{
+    render_->CaptureWindowImages();
+    if(!render_->img.isEmpty()){
+        std::string img_ = render_->img.toStdString();
+        QMap<QString,string> map;
+        map["img"] = img_;
+        std::string json_ = object->ToJson("img",map,step);
+        emit sendImg_handlePoolToSendstate(json_);//信号
+    }
+    delete object;
+    object = NULL;
+}
+
 /*
  * @brief: remove string's spaces
  * @param: string
@@ -951,6 +1066,24 @@ pid_resultManager *handlePool::set_map_resultManager(boostJsonObject *object, Re
     return resultManager_p;
 }
 
+/*
+ * @brief: animation slider change
+ * @param: proid
+ * @ret: void
+ * @birth: created by czm in 20230608
+ */
+void handlePool::animationSliderChanged(QString str)
+{
+    if(qmapResultmanager[str.toStdString()]->resultManager_!=NULL){
+        ResultManager* resultmm = qmapResultmanager[str.toStdString()]->resultManager_;
+        if(!resultmm->animationWidget_->getm_time().isEmpty()){
+            resultmm->HideAllActors();
+            resultmm->DisplayMeshByIndex(resultmm->animationWidget_->getSlider());
+            resultmm->animationWidget_->SlotChange();
+        }
+    }
+}
+
 /*
  * @brief: get map which save meshmanager
  * @param: void

+ 5 - 1
CAE_Solution/src/threadPool_and_statemachine/dealWith/handlepool.h

@@ -19,6 +19,7 @@
 #include "../../VTK/display/solidsurfacewidget.h"
 #include "../../VTK/display/slicewidget.h"
 #include "../../VTK/display/streamwidget.h"
+#include "../../VTK/display/contourinimationdisplay.h"
 #include "../../VTK/widget/contourdispalyWidget.h"
 #include "../../VTK/widget/linedisplayWidget.h"
 #include "../../VTK/widget/slicedisplaywidget.h"
@@ -57,11 +58,12 @@ public:
     bool result_solidsurfacedisplay(boostJsonObject*, QVTKRenderer *);
     bool result_slicedisplay(boostJsonObject*, QVTKRenderer *,QString);
     bool result_streamdisplay(boostJsonObject*, QVTKRenderer *,QString);
-    bool result_contourinimationdisplay(boostJsonObject*,QVTKRenderer*,QString);
+    bool result_contourinimationdisplay(boostJsonObject*,QVTKRenderer*);
     QMap<QString,string> buildResultImport_msg(QString,ResultManager*);
     QMap<QString,string> buildResultImport_msg(QString,ResultManager*,boostJsonObject*);
     QMap<QString,string> buildError_msg(string);
     void send_picture(boostJsonObject*,QVTKRenderer*);
+    void send_picture(boostJsonObject*,QVTKRenderer*,int);
     string removeSpaces(string);
     vector<string> stringSplit(const string& str, char delim);
 
@@ -70,6 +72,7 @@ public:
     QMap<string,pid_resultManager*> getMapResultManager();
     pid_meshManager* set_map_meshManager(boostJsonObject*,MeshManager*);
     pid_resultManager* set_map_resultManager(boostJsonObject*,ResultManager*);
+    void animationSliderChanged(QString);
 
 
 private:
@@ -82,6 +85,7 @@ private:
     QMap<string,SolidSurface*> map_solidsdisplay;
     QMap<string,SliceWidget*> map_slicedisplay;
     QMap<string,StreamWidget*> map_streamdisplay;
+    QMap<string,contourinimationDisplay*> map_cinimationDisplay;
     QTabWidget* w;
     bool contour_sendrange_flag;
     bool line_sendrange_flag;