Salome HOME
NETGEN_2D_Remote.Paramters was returning a 3D Hypotesis
[plugins/netgenplugin.git] / src / NETGENPlugin / NETGENPlugin_Runner_main.cxx
1 // Copyright (C) 2007-2023  CEA, EDF, 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_Runnner_main.cxx
24 //  Author : Yoann AUDOUIN, EDF
25 //  Module : NETGEN
26 //
27
28 #include "NETGENPlugin_NETGEN_2D_SA.hxx"
29 #include "NETGENPlugin_NETGEN_3D_SA.hxx"
30 #include "NETGENPlugin_NETGEN_1D2D3D_SA.hxx"
31
32 #include <stdio.h>
33 #include <string.h>
34 #include <iostream>
35 #include <chrono>
36
37 /**
38  * @brief Main function
39  *
40  * @param argc Number of arguments
41  * @param argv Arguments
42  *
43  * @return error code
44  */
45 int main(int argc, char *argv[]){
46
47   if(argc!=8||(argc==2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help")==0))){
48     std::cout << "Error in number of arguments "<< argc-1<<" given expected 7" <<std::endl;
49     std::cout << "Syntax:"<<std::endl;
50     std::cout << "run_mesher MESHER INPUT_MESH_FILE SHAPE_FILE HYPO_FILE" << std::endl;
51     std::cout << "           ELEM_ORIENT_FILE " << std::endl;
52     std::cout << "           NEW_ELEMENT_FILE OUTPUT_MESH_FILE" << std::endl;
53     std::cout << std::endl;
54     std::cout << " Set argument to NONE to ignore them " << std::endl;
55     std::cout << std::endl;
56     std::cout << "Args:" << std::endl;
57     std::cout << "  MESHER: mesher to use from (NETGEN3D, NETGEN2D)" << std::endl;
58     std::cout << "  INPUT_MESH_FILE: MED File containing lower-dimension-elements already meshed" << std::endl;
59     std::cout << "  SHAPE_FILE: STEP file containing the shape to mesh" << std::endl;
60     std::cout << "  HYPO_FILE: Ascii file containint the list of parameters" << std::endl;
61     std::cout << "  (optional) ELEM_ORIENT_FILE: binary file containing the list of element from INPUT_MESH_FILE associated to the shape and their orientation" << std::endl;
62     std::cout << "  (optional) NEW_ELEMENT_FILE: (out) contains elements and nodes added by the meshing" << std::endl;
63     std::cout << "  (optional) OUTPUT_MESH_FILE: (out) MED File containing the mesh after the run of the mesher" << std::endl;
64     return 1;
65   }
66   std::string mesher=argv[1];
67   std::string input_mesh_file=argv[2];
68   std::string shape_file=argv[3];
69   std::string hypo_file=argv[4];
70   std::string element_orientation_file=argv[5];
71   std::string new_element_file=argv[6];
72   std::string output_mesh_file=argv[7];
73
74   //std::string thing;
75   //std::cin >> thing;
76
77   if (output_mesh_file == "NONE")
78     output_mesh_file = "";
79   if (element_orientation_file == "NONE")
80     element_orientation_file = "";
81   if (new_element_file == "NONE")
82     new_element_file = "";
83   int ret = 0;
84   if (mesher=="NETGEN3D"){
85     NETGENPlugin_NETGEN_3D_SA myplugin;
86     ret = myplugin.run(input_mesh_file,
87              shape_file,
88              hypo_file,
89              element_orientation_file,
90              new_element_file,
91              output_mesh_file );
92   }
93   else if ( mesher=="NETGEN1D" || 
94             mesher=="NETGEN1D2D" || 
95             mesher=="NETGEN1D2D3D" ) 
96   {
97     NETGENPlugin_NETGEN_1D2D3D_SA myplugin;    
98     NETGENPlugin_Mesher::DIM DIM = mesher=="NETGEN1D" ? NETGENPlugin_Mesher::D1 
99                                     : ( mesher=="NETGEN1D2D" ? NETGENPlugin_Mesher::D2 
100                                     : NETGENPlugin_Mesher::D3 );
101
102     ret = myplugin.run(input_mesh_file,
103                   shape_file,
104                   hypo_file,
105                   element_orientation_file,
106                   new_element_file,
107                   output_mesh_file, 
108                   DIM );
109   } 
110   else if ( mesher=="NETGEN2D" ) 
111   {
112     NETGENPlugin_NETGEN_2D_SA myplugin;    
113     ret = myplugin.run(input_mesh_file,
114                   shape_file,
115                   hypo_file,
116                   element_orientation_file,
117                   new_element_file,
118                   output_mesh_file );
119   }  
120   else {
121     std::cerr << "Unknown mesher:" << mesher << std::endl;
122     return 1;
123   }
124   return ret;
125 }