Salome HOME
Cleanup use of netgen_params + restoring use of netgen error functions
[plugins/netgenplugin.git] / src / NETGENPlugin / NETGENPlugin_DriverParam.cxx
1 // Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  File   : NETGENPlugin_DriverParam.hxx
24 //  Author : Yoann AUDOUIN, EDF
25 //  Module : NETGEN
26 //
27 #include "NETGENPlugin_DriverParam.hxx"
28
29
30 #include <iostream>
31 #include <fstream>
32 #include <string>
33 #include <cassert>
34
35 /**
36  * @brief Print content of a netgen_params
37  *
38  * @param aParams The object to display
39  */
40 void printNetgenParams(netgen_params& aParams){
41   std::cout << "has_netgen_param: " << aParams.has_netgen_param << std::endl;
42   std::cout << "maxh: " << aParams.maxh << std::endl;
43   std::cout << "minh: " << aParams.minh << std::endl;
44   std::cout << "segmentsperedge: " << aParams.segmentsperedge << std::endl;
45   std::cout << "grading: " << aParams.grading << std::endl;
46   std::cout << "curvaturesafety: " << aParams.curvaturesafety << std::endl;
47   std::cout << "secondorder: " << aParams.secondorder << std::endl;
48   std::cout << "quad: " << aParams.quad << std::endl;
49   std::cout << "optimize: " << aParams.optimize << std::endl;
50   std::cout << "fineness: " << aParams.fineness << std::endl;
51   std::cout << "uselocalh: " << aParams.uselocalh << std::endl;
52   std::cout << "merge_solids: " << aParams.merge_solids << std::endl;
53   std::cout << "chordalError: " << aParams.chordalError << std::endl;
54   std::cout << "optsteps2d: " << aParams.optsteps2d << std::endl;
55   std::cout << "optsteps3d: " << aParams.optsteps3d << std::endl;
56   std::cout << "elsizeweight: " << aParams.elsizeweight << std::endl;
57   std::cout << "opterrpow: " << aParams.opterrpow << std::endl;
58   std::cout << "delaunay: " << aParams.delaunay << std::endl;
59   std::cout << "checkoverlap: " << aParams.checkoverlap << std::endl;
60   std::cout << "checkchartboundary: " << aParams.checkchartboundary << std::endl;
61   std::cout << "closeedgefac: " << aParams.closeedgefac << std::endl;
62   std::cout << "has_local_size: " << aParams.has_local_size << std::endl;
63   std::cout << "meshsizefilename: " << aParams.meshsizefilename << std::endl;
64   std::cout << "has_maxelementvolume_hyp: " << aParams.has_maxelementvolume_hyp << std::endl;
65   std::cout << "maxElementVolume: " << aParams.maxElementVolume << std::endl;
66   std::cout << "has_LengthFromEdges_hyp: " << aParams.has_LengthFromEdges_hyp << std::endl;
67 }
68
69 /**
70  * @brief Import a param_file into a netgen_params structure
71  *
72  * @param param_file Name of the file
73  * @param aParams Structure to fill
74  */
75 void importNetgenParams(const std::string param_file, netgen_params& aParams){
76   std::ifstream myfile(param_file);
77   std::string line;
78
79   std::getline(myfile, line);
80   aParams.has_netgen_param = std::stoi(line);
81   std::getline(myfile, line);
82   aParams.maxh = std::stod(line);
83   std::getline(myfile, line);
84   aParams.minh = std::stod(line);
85   std::getline(myfile, line);
86   aParams.segmentsperedge = std::stod(line);
87   std::getline(myfile, line);
88   aParams.grading = std::stod(line);
89   std::getline(myfile, line);
90   aParams.curvaturesafety = std::stod(line);
91   std::getline(myfile, line);
92   aParams.secondorder = std::stoi(line);
93   std::getline(myfile, line);
94   aParams.quad = std::stoi(line);
95   std::getline(myfile, line);
96   aParams.optimize = std::stoi(line);
97   std::getline(myfile, line);
98   aParams.fineness = std::stoi(line);
99   std::getline(myfile, line);
100   aParams.uselocalh = std::stoi(line);
101   std::getline(myfile, line);
102   aParams.merge_solids = std::stoi(line);
103   std::getline(myfile, line);
104   aParams.chordalError = std::stod(line);
105   std::getline(myfile, line);
106   aParams.optsteps2d = std::stoi(line);
107   std::getline(myfile, line);
108   aParams.optsteps3d = std::stoi(line);
109   std::getline(myfile, line);
110   aParams.elsizeweight = std::stod(line);
111   std::getline(myfile, line);
112   aParams.opterrpow = std::stoi(line);
113   std::getline(myfile, line);
114   aParams.delaunay = std::stoi(line);
115   std::getline(myfile, line);
116   aParams.checkoverlap = std::stoi(line);
117   std::getline(myfile, line);
118   aParams.checkchartboundary = std::stoi(line);
119   std::getline(myfile, line);
120   aParams.closeedgefac = std::stoi(line);
121   std::getline(myfile, line);
122   aParams.has_local_size = std::stoi(line);
123   std::getline(myfile, line);
124   aParams.meshsizefilename = line;
125   std::getline(myfile, line);
126   aParams.has_maxelementvolume_hyp = std::stoi(line);
127   std::getline(myfile, line);
128   aParams.maxElementVolume = std::stod(line);
129   std::getline(myfile, line);
130   aParams.maxElementVolume = std::stoi(line);
131
132 };
133
134 /**
135  * @brief Writes the content of a netgen_param into a file
136  *
137  * @param param_file the file
138  * @param aParams the object
139  */
140 void exportNetgenParams(const std::string param_file, netgen_params& aParams){
141   std::ofstream myfile(param_file);
142   myfile << aParams.has_netgen_param << std::endl;
143   myfile << aParams.maxh << std::endl;
144   myfile << aParams.minh << std::endl;
145   myfile << aParams.segmentsperedge << std::endl;
146   myfile << aParams.grading << std::endl;
147   myfile << aParams.curvaturesafety << std::endl;
148   myfile << aParams.secondorder << std::endl;
149   myfile << aParams.quad << std::endl;
150   myfile << aParams.optimize << std::endl;
151   myfile << aParams.fineness << std::endl;
152   myfile << aParams.uselocalh << std::endl;
153   myfile << aParams.merge_solids << std::endl;
154   myfile << aParams.chordalError << std::endl;
155   myfile << aParams.optsteps2d << std::endl;
156   myfile << aParams.optsteps3d << std::endl;
157   myfile << aParams.elsizeweight << std::endl;
158   myfile << aParams.opterrpow << std::endl;
159   myfile << aParams.delaunay << std::endl;
160   myfile << aParams.checkoverlap << std::endl;
161   myfile << aParams.checkchartboundary << std::endl;
162   myfile << aParams.closeedgefac << std::endl;
163   myfile << aParams.has_local_size << std::endl;
164   myfile << aParams.meshsizefilename << std::endl;
165   myfile << aParams.has_maxelementvolume_hyp << std::endl;
166   myfile << aParams.maxElementVolume << std::endl;
167   myfile << aParams.has_LengthFromEdges_hyp << std::endl;
168 };