1 /*****************************************************************************
2  *                                                                           *
3  *  Elmer, A Finite Element Software for Multiphysical Problems              *
4  *                                                                           *
5  *  Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland    *
6  *                                                                           *
7  *  This program is free software; you can redistribute it and/or            *
8  *  modify it under the terms of the GNU General Public License              *
9  *  as published by the Free Software Foundation; either version 2           *
10  *  of the License, or (at your option) any later version.                   *
11  *                                                                           *
12  *  This program is distributed in the hope that it will be useful,          *
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
15  *  GNU General Public License for more details.                             *
16  *                                                                           *
17  *  You should have received a copy of the GNU General Public License        *
18  *  along with this program (in file fem/GPL-2); if not, write to the        *
19  *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,         *
20  *  Boston, MA 02110-1301, USA.                                              *
21  *                                                                           *
22  *****************************************************************************/
23 
24 /*****************************************************************************
25  *                                                                           *
26  *  ElmerGUI meshingthread                                                   *
27  *                                                                           *
28  *****************************************************************************
29  *                                                                           *
30  *  Authors: Mikko Lyly, Juha Ruokolainen and Peter Råback                   *
31  *  Email:   Juha.Ruokolainen@csc.fi                                         *
32  *  Web:     http://www.csc.fi/elmer                                         *
33  *  Address: CSC - IT Center for Science Ltd.                                 *
34  *           Keilaranta 14                                                   *
35  *           02101 Espoo, Finland                                            *
36  *                                                                           *
37  *  Original Date: 15 Mar 2008                                               *
38  *                                                                           *
39  *****************************************************************************/
40 
41 #ifndef MESHINGTHREAD_H
42 #define MESHINGTHREAD_H
43 
44 #include <QThread>
45 
46 #ifdef WIN32
47 #include <windows.h>
48 #else
49 #include <dlfcn.h>
50 #endif
51 
52 #include "plugins/tetlib_api.h"
53 #include "plugins/nglib_api.h"
54 
55 namespace nglib {
56 #include "nglib.h"
57 }
58 
59 class MeshingThread : public QThread
60 {
61   Q_OBJECT
62 
63 public:
64   MeshingThread(QObject *parent = 0);
65   ~MeshingThread();
66 
67   void generate(int generatorType, QString cs,
68 		TetlibAPI *tetlibAPI,
69 		nglib::Ng_Mesh *ngmesh,
70 		nglib::Ng_STL_Geometry *nggeom,
71 		nglib::Ng_Geometry_2D *nggeom2d,
72 		int ngDim, nglib::Ng_Meshing_Parameters *mp);
73 
74   void stopMeshing();
75 
76   nglib::Ng_Mesh *getNgMesh();
77 
78 protected:
79   void run();
80 
81 private:
82   int generatorType;
83 
84   // tetlib:
85   QString tetgenControlString;
86   TetlibAPI *tetlibAPI;
87   tetgenio *in;
88   tetgenio *out;
89   delegate_tetrahedralize_t delegate_tetrahedralize;
90 
91   // nglib:
92   NglibAPI *nglibAPI;
93   nglib::Ng_Mesh *ngmesh;
94   nglib::Ng_STL_Geometry *nggeom;
95   nglib::Ng_Geometry_2D *nggeom2d;
96   nglib::Ng_Meshing_Parameters *mp;
97   int ngDim;
98 };
99 
100 #endif // MESHINGTHREAD_H
101