소스 검색

0920 修改解析meshsplit算法

caizm 2 년 전
부모
커밋
145223d656

+ 46 - 14
CAE_Solution/src/Rabbitmq/rabbitClient/rabbitclient.cpp

@@ -181,22 +181,54 @@ int rabbitClient::recvMsg()
                 //-----------去除paramjson里面的多余转义字符--------------------//
                 int num1 = t.find_first_of('{',0);
                 int num2 = t.find_first_of('}',0);
-                if(num1!=-1){
-                    string first_t;
-                    first_t=t.substr(0,num1);
-                    string middle_t;
-                    for(int i=num1;i<=num2;i++){
-                        if(t[i] == '"'){
-                            middle_t+='\\';
+                int num3 = t.find_last_of('}',0);
+                if(num2 == num3){//*****************{**********}*****************
+                    if(num1!=-1){
+                        string first_t;
+                        first_t=t.substr(0,num1);
+                        string middle_t;
+                        for(int i=num1;i<=num2;i++){
+                            if(t[i] == '"'){
+                                middle_t+='\\';
+                            }
+                            middle_t+=t[i];
                         }
-                        middle_t+=t[i];
+                        string end_t;
+                        end_t = t.substr(num2+1);
+                        t.clear();
+                        t = '{' + first_t + middle_t + end_t + '}';
+                    }else{
+                        t = '{' + t + '}';
                     }
-                    string end_t;
-                    end_t = t.substr(num2+1);
-                    t.clear();
-                    t = '{' + first_t + middle_t + end_t + '}';
-                }else{
-                    t = '{' + t + '}';
+                }else{//**********{*******{******}**{******}**{******}}**********
+                    string array_first_t,array_end_t,array_middle_t;
+                    string original_t,last_t;
+                    original_t = t;
+                    array_first_t = t.substr(0,num1+1);//*********{   //t=*******{******}**{******}**{******}}**********
+                    t = original_t;
+                    array_end_t = t.substr(num3);//}***********
+                    array_middle_t = original_t.substr(num1+1,num3-num1-1);//****{*****}**{****}**{****}**
+                    bool judge_flag = false;
+                    for(int i=0;i<array_middle_t.size();i++){
+                        if(!judge_flag){
+                            if(array_middle_t[i]== '"'){
+                                last_t += '\\';
+                            }else if(array_middle_t[i] == '{'){
+                                judge_flag = true;
+                            }
+                            last_t+=array_middle_t[i];
+                        }else{
+                            if(array_middle_t[i]== '"'){
+                                last_t += '\\';
+                                last_t += '\\';
+                                last_t += '\\';
+                            }else if(array_middle_t[i] == '}'){
+                                judge_flag = false;
+                            }
+                            last_t+=array_middle_t[i];
+                        }
+                    }
+                    t = '{'+array_first_t+last_t+array_end_t+'}';
                 }
 
             }

+ 14 - 7
CAE_Solution/src/threadPool_and_statemachine/dealWith/boostjsonobject.cpp

@@ -404,8 +404,9 @@ void boostJsonObject::FromParamJson(string param)
             da_struct->surfParam->min_size = sur_data.get<std::string>("min_size");
             da_struct->surfParam->SurfStyle = sur_data.get<std::string>("surfStyle");
             da_struct->surfParam->Global_physical_size = sur_data.get<std::string>("global_physical_size");
-        }catch(exception ex){
+        }catch(myException &ex){
             std::cout<<"-----no surfParam-----"<<std::endl;
+            throw myException("surfParam miss some parameters!");
             da_struct->surfParam0 = false;
         }
 
@@ -422,8 +423,9 @@ void boostJsonObject::FromParamJson(string param)
             da_struct->surfParam->force_bad_surface_element_removal = sur1_data.get<std::string>("force_bad_surface_element_removal");
             da_struct->surfParam->discard_input_topology = sur1_data.get<std::string>("discard_input_topology");
             da_struct->surfParam->create_tag_on_collision = sur1_data.get<std::string>("create_tag_on_collision");
-        }catch(exception ex){
+        }catch(myException &ex){
             std::cout<<"-----no surfParam1-----"<<std::endl;
+            throw myException("surfParam1 miss some parameters!");
             da_struct->surfParam1 = false;
         }
 
@@ -435,8 +437,9 @@ void boostJsonObject::FromParamJson(string param)
             da_struct->surfParam->scaled_jacobian_threshold_value = sur2_data.get<std::string>("scaled_jacobian_threshold_value");
             da_struct->surfParam->optimisation = sur2_data.get<std::string>("optimisation");
             da_struct->surfParam->correct_surface_intersections = sur2_data.get<std::string>("correct_surface_intersections");
-        }catch(exception ex){
+        }catch(myException &ex){
             std::cout<<"-----no surfParam2-----"<<std::endl;
+            throw myException("surfParam2 miss some parameters!");
             da_struct->surfParam2 = false;
         }
 #if 0
@@ -492,8 +495,9 @@ void boostJsonObject::FromParamJson(string param)
             da_struct->clrParam->use_default_settings_for = cleaner_data.get<std::string>("use_default_settings_for");
             da_struct->clrParam->overlap_angle = cleaner_data.get<std::string>("overlap_angle");
             da_struct->clrParam->resolution_length = cleaner_data.get<std::string>("resolution_length");
-        }catch(exception ex){
+        }catch(myException &ex){
             std::cout<<"-----no cleanerParam-----"<<std::endl;
+            throw myException("cleanerParam miss some parameters!");
             da_struct->bCleanerSection = false;
         }
 
@@ -507,8 +511,9 @@ void boostJsonObject::FromParamJson(string param)
             da_struct->tetraParam->max_size = tetra_data.get<std::string>("max_size");
             da_struct->style = 1;
 
-        }catch(exception ex){
+        }catch(myException &ex){
             std::cout<<"-----no TetraParam-----"<<std::endl;
+            throw myException("tetraParam miss some parameters!");
             da_struct->TetraParam_ = false;
         }
 
@@ -517,8 +522,9 @@ void boostJsonObject::FromParamJson(string param)
             da_struct->HexaParam_ = true;
             da_struct->hexaParam->components = hexa_data.get<std::string>("components");
             da_struct->style = 2;
-        }catch(exception ex){
+        }catch(myException &ex){
             std::cout<<"-----no HexaParam-----"<<std::endl;
+            throw myException("hexaParam miss some parameters!");
             da_struct->HexaParam_ = false;
         }
 
@@ -531,8 +537,9 @@ void boostJsonObject::FromParamJson(string param)
             da_struct->hybridParam->normal_direction = hybrid_data.get<std::string>("normal_direction");
             da_struct->hybridParam->boundary_layer_global_initial_height = hybrid_data.get<std::string>("boundary_layer_global_initial_height");
             da_struct->hybridParam->boundary_layer_geometric_progression = hybrid_data.get<std::string>("boundary_layer_geometric_progression");
-        }catch(exception ex){
+        }catch(myException &ex){
             std::cout<<"-----no HybridParam-----"<<std::endl;
+            throw myException("hybridParam miss some parameters!");
             da_struct->HybridParaml_ = false;
         }
     }

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

@@ -229,4 +229,11 @@ public:
     bool mgPhysical_,mgGeometry_,TetraParam_,HexaParam_,HybridParaml_;
 };
 
+//异常类
+class myException :public exception   //自己的异常类继承标准库中的异常类
+{
+public:                               //父类中为char*类型,把string转换为char*
+    myException(string str) :exception(str.c_str()) {}
+};
+
 #endif // DISPLAY_STRUCT_H

+ 17 - 5
CAE_Solution/src/threadPool_and_statemachine/dealWith/handlepool.cpp

@@ -69,13 +69,13 @@ void handlePool::getmsg_recvstateTohandlePool(std::string recvmsg)
     QVTKRenderer* render_=NULL;
     try{//处理异常
         json_object->FromJson(recvmsg);
-    }catch(exception ex){
+    }catch(myException &ex){
         emit sendImg_handlePoolToSendstate(json_object->ToJson("exception",buildError_msg(ex.what())));
         return;
     }
     try{
         operateRender(json_object,render_);//解析命令
-    }catch(exception ex){
+    }catch(myException &ex){
         emit sendImg_handlePoolToSendstate(json_object->ToJson("exception",buildError_msg(ex.what())));
         return;
     }
@@ -761,9 +761,20 @@ bool handlePool::result_contourinimationdisplay(boostJsonObject *object_, QVTKRe
  * @ret: bool
  * @birth:created by czm in 20230822
  */
-bool handlePool::result_readIgsFile(boostJsonObject *object_, QVTKRenderer *render_)
+bool handlePool::result_readIgsFile(boostJsonObject *object_, QVTKRenderer *renderer_)
 {
-    Q_UNUSED(render_);
+    if(!qmapRender.contains(object_->proId)){
+        renderer_ = new QVTKRenderer();
+        qmapRender.insert(object_->proId,renderer_);
+        renderer_->init();
+        w->addTab(renderer_->GetWidget(),QString::fromStdString(object_->proId));
+        renderer_->widgetFlag = QVTKRenderer::WidgetModel::NoModel;
+    }else{
+        renderer_ = qmapRender[object_->proId];
+        auto flag_ = renderer_->widgetFlag;
+        //to do
+    }
+
     cmdMainProcess* cmdp = new cmdMainProcess();
     try{
     if(cmdp->CreateProcess_(object_->da_struct->geoPath,"")){//unuse xmlpath
@@ -771,7 +782,8 @@ bool handlePool::result_readIgsFile(boostJsonObject *object_, QVTKRenderer *rend
     }else{
         return false;
     }
-    }catch(exception ex){
+    }catch(myException &ex){
+        throw myException("something error!");
         return false;
     }
 }