From: Yoann Audouin Date: Mon, 19 Sep 2022 09:12:06 +0000 (+0200) Subject: Now filling param _hypParameters and _stdMaxvolume X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f48857dd37e1f790e50664b60f320c8aa348cd67;p=plugins%2Fnetgenplugin.git Now filling param _hypParameters and _stdMaxvolume --- diff --git a/src/NETGENPlugin/NETGENPlugin_DriverParam.cxx b/src/NETGENPlugin/NETGENPlugin_DriverParam.cxx index 2ddf398..dffeca8 100644 --- a/src/NETGENPlugin/NETGENPlugin_DriverParam.cxx +++ b/src/NETGENPlugin/NETGENPlugin_DriverParam.cxx @@ -26,22 +26,22 @@ // #include "NETGENPlugin_DriverParam.hxx" +#include "NETGENPlugin_Hypothesis.hxx" + +#include +#include + #include #include #include #include - -// TODO: Error handling of read/write - /** * @brief Print content of a netgen_params * * @param aParams The object to display */ void printNetgenParams(netgen_params& aParams){ - // TODO: prettier print - // TODO: Add call to print in log std::cout << "has_netgen_param: " << aParams.has_netgen_param << std::endl; std::cout << "maxh: " << aParams.maxh << std::endl; std::cout << "minh: " << aParams.minh << std::endl; @@ -76,7 +76,7 @@ void printNetgenParams(netgen_params& aParams){ * @param param_file Name of the file * @param aParams Structure to fill */ -void importNetgenParams(const std::string param_file, netgen_params& aParams){ +void importNetgenParams(const std::string param_file, netgen_params& aParams, SMESH_Gen *gen){ std::ifstream myfile(param_file); std::string line; @@ -133,7 +133,36 @@ void importNetgenParams(const std::string param_file, netgen_params& aParams){ std::getline(myfile, line); aParams.maxElementVolume = std::stoi(line); - myfile.close(); + if(aParams.has_netgen_param){ + aParams._hypParameters = new NETGENPlugin_Hypothesis(0, gen); + + aParams._hypParameters->SetMaxSize(aParams.maxh); + aParams._hypParameters->SetMinSize(aParams.minh); + aParams._hypParameters->SetNbSegPerEdge(aParams.segmentsperedge); + aParams._hypParameters->SetGrowthRate(aParams.grading); + aParams._hypParameters->SetNbSegPerRadius(aParams.curvaturesafety); + aParams._hypParameters->SetSecondOrder(aParams.secondorder); + aParams._hypParameters->SetQuadAllowed(aParams.quad); + aParams._hypParameters->SetOptimize(aParams.optimize); + aParams._hypParameters->SetFineness((NETGENPlugin_Hypothesis::Fineness)aParams.fineness); + aParams._hypParameters->SetSurfaceCurvature(aParams.uselocalh); + aParams._hypParameters->SetFuseEdges(aParams.merge_solids); + aParams._hypParameters->SetChordalErrorEnabled(aParams.chordalError); + if(aParams.optimize){ + aParams._hypParameters->SetNbSurfOptSteps(aParams.optsteps2d); + aParams._hypParameters->SetNbVolOptSteps(aParams.optsteps3d); + } + aParams._hypParameters->SetElemSizeWeight(aParams.elsizeweight); + aParams._hypParameters->SetWorstElemMeasure(aParams.opterrpow); + aParams._hypParameters->SetUseDelauney(aParams.delaunay); + aParams._hypParameters->SetCheckOverlapping(aParams.checkoverlap); + aParams._hypParameters->SetCheckChartBoundary(aParams.checkchartboundary); + aParams._hypParameters->SetMeshSizeFile(aParams.meshsizefilename); + } + if(aParams.has_maxelementvolume_hyp){ + aParams._hypMaxElementVolume = new StdMeshers_MaxElementVolume(1, gen); + } + // TODO: Handle viscous layer }; /** @@ -170,45 +199,4 @@ void exportNetgenParams(const std::string param_file, netgen_params& aParams){ myfile << aParams.has_maxelementvolume_hyp << std::endl; myfile << aParams.maxElementVolume << std::endl; myfile << aParams.has_LengthFromEdges_hyp << std::endl; - - myfile.close(); }; - -/** - * @brief Compares two netgen_parms object - * - * @param params1 Object 1 - * @param params2 Object 2 - - * @return true if the two object are identical - */ -bool diffNetgenParams(netgen_params params1, netgen_params params2){ - bool ret = true; - ret &= params1.maxh == params2.maxh; - ret &= params1.minh == params2.minh; - ret &= params1.segmentsperedge == params2.segmentsperedge; - ret &= params1.grading == params2.grading; - ret &= params1.curvaturesafety == params2.curvaturesafety; - ret &= params1.secondorder == params2.secondorder; - ret &= params1.quad == params2.quad; - ret &= params1.optimize == params2.optimize; - ret &= params1.fineness == params2.fineness; - ret &= params1.uselocalh == params2.uselocalh; - ret &= params1.merge_solids == params2.merge_solids; - ret &= params1.chordalError == params2.chordalError; - ret &= params1.optsteps2d == params2.optsteps2d; - ret &= params1.optsteps3d == params2.optsteps3d; - ret &= params1.elsizeweight == params2.elsizeweight; - ret &= params1.opterrpow == params2.opterrpow; - ret &= params1.delaunay == params2.delaunay; - ret &= params1.checkoverlap == params2.checkoverlap; - ret &= params1.checkchartboundary == params2.checkchartboundary; - ret &= params1.closeedgefac == params2.closeedgefac; - ret &= params1.has_local_size == params2.has_local_size; - ret &= params1.meshsizefilename == params2.meshsizefilename; - ret &= params1.has_maxelementvolume_hyp == params2.has_maxelementvolume_hyp; - ret &= params1.maxElementVolume == params2.maxElementVolume; - ret &= params1.has_LengthFromEdges_hyp == params2.has_LengthFromEdges_hyp; - - return ret; -} diff --git a/src/NETGENPlugin/NETGENPlugin_DriverParam.hxx b/src/NETGENPlugin/NETGENPlugin_DriverParam.hxx index 0f53512..bc05229 100644 --- a/src/NETGENPlugin/NETGENPlugin_DriverParam.hxx +++ b/src/NETGENPlugin/NETGENPlugin_DriverParam.hxx @@ -33,6 +33,7 @@ class NETGENPlugin_Hypothesis; class StdMeshers_MaxElementVolume; class StdMeshers_ViscousLayers; +class SMESH_Gen; struct netgen_params{ // Params from NETGENPlugin_Mesher @@ -60,7 +61,6 @@ struct netgen_params{ int closeedgefac; - // TODO: add localsize (pass through local size file ?) // True if we have a mesh size file or local size info bool has_local_size = false; std::string meshsizefilename; @@ -70,14 +70,13 @@ struct netgen_params{ bool has_maxelementvolume_hyp=false; double maxElementVolume=0.0; - // to replace - //NETGENPlugin_Hypothesis * _hypParameters=nullptr; - // to remove ? + NETGENPlugin_Hypothesis * _hypParameters=nullptr; StdMeshers_MaxElementVolume* _hypMaxElementVolume=nullptr; - // to remove ? StdMeshers_ViscousLayers* _viscousLayersHyp=nullptr; - //double _progressByTic; + double _progressByTic; bool _quadraticMesh=false; + int _error=0; + std::string _comment; // Params from NETGEN2D bool has_LengthFromEdges_hyp=false; @@ -88,9 +87,7 @@ struct netgen_params{ void printNetgenParams(netgen_params& aParams); -void importNetgenParams(const std::string param_file, netgen_params& aParams); +void importNetgenParams(const std::string param_file, netgen_params& aParams, SMESH_Gen * gen); void exportNetgenParams(const std::string param_file, netgen_params& aParams); -bool diffNetgenParams(netgen_params params1, netgen_params params2); - -#endif \ No newline at end of file +#endif diff --git a/src/NETGENPlugin/NETGENPlugin_Runner.cxx b/src/NETGENPlugin/NETGENPlugin_Runner.cxx index 24038db..43faa50 100644 --- a/src/NETGENPlugin/NETGENPlugin_Runner.cxx +++ b/src/NETGENPlugin/NETGENPlugin_Runner.cxx @@ -213,7 +213,7 @@ int netgen3d(const std::string input_mesh_file, // Importing hypothesis netgen_params myParams; - importNetgenParams(hypo_file, myParams); + importNetgenParams(hypo_file, myParams, &gen); auto time3 = std::chrono::high_resolution_clock::now(); elapsed = std::chrono::duration_cast(time3-time2); std::cout << "Time for import_netgen_param: " << elapsed.count() * 1e-9 << std::endl; @@ -671,7 +671,7 @@ int netgen2d(const std::string input_mesh_file, // Importing hypothesis netgen_params myParams; - importNetgenParams(hypo_file, myParams); + importNetgenParams(hypo_file, myParams, &gen); std::cout << "Meshing with netgen3d" << std::endl; int ret = netgen2dInternal(myShape, *myMesh, myParams,