Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/ElmerGUI/Application/cad/cadview.h
3203 views
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 cadview *
27
* *
28
*****************************************************************************
29
* *
30
* Authors: Mikko Lyly, Juha Ruokolainen and Peter Råback *
31
* Email: [email protected] *
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 CADVIEW_H
42
#define CADVIEW_H
43
44
#include <QHash>
45
#include <QMainWindow>
46
47
48
#include "cadpreferences.h"
49
50
namespace nglib {
51
#include "nglib.h"
52
}
53
54
#include <TopoDS_Shape.hxx>
55
#include <Standard_Version.hxx>
56
57
#if OCC_VERSION_HEX >= 0x060800
58
#include <BRepMesh_IncrementalMesh.hxx>
59
#endif
60
61
#ifndef VTK_MAJOR_VERSION
62
#include "vtkVersionMacros.h"
63
#endif
64
65
class QMenu;
66
class QAction;
67
#if VTK_MAJOR_VERSION >= 8
68
class QVTKOpenGLNativeWidget;
69
#else
70
class QVTKWidget;
71
#endif
72
class vtkRenderer;
73
class vtkActor;
74
class vtkPolyData;
75
class vtkAppendPolyData;
76
77
class pt {
78
public:
79
int n;
80
double x;
81
double y;
82
};
83
84
class seg {
85
public:
86
int p0;
87
int p1;
88
int bc;
89
};
90
91
class CadView : public QMainWindow {
92
Q_OBJECT
93
94
public:
95
CadView(QWidget *parent = 0);
96
~CadView();
97
98
QSize minimumSizeHint() const;
99
QSize sizeHint() const;
100
101
#if VTK_MAJOR_VERSION >= 8
102
QVTKOpenGLNativeWidget* GetQVTKWidget();
103
#else
104
QVTKWidget* GetQVTKWidget();
105
#endif
106
107
bool readFile(QString);
108
void generateSTL();
109
110
void setMesh(nglib::Ng_Mesh *);
111
void setGeom(nglib::Ng_STL_Geometry *);
112
void setMp(nglib::Ng_Meshing_Parameters *);
113
void setDeflection(double);
114
double lengthOf(double *);
115
void differenceOf(double *, double *, double *);
116
int getFaceNumber(vtkActor *);
117
int getDim();
118
void generateIn2dFile();
119
120
private slots:
121
void closeSlot();
122
void generateSTLSlot();
123
void cadPreferencesSlot();
124
void reloadSlot();
125
126
private:
127
void createActions();
128
void createMenus();
129
void clearScreen();
130
TopoDS_Shape readBrep(QString);
131
TopoDS_Shape readStep(QString);
132
TopoDS_Shape readIges(QString);
133
void restrictMeshSizeLocal(nglib::Ng_Mesh *, vtkPolyData *, double, double);
134
135
QMenu *fileMenu;
136
QMenu *modelMenu;
137
138
QAction *exitAct;
139
QAction *reloadAct;
140
QAction *cadPreferencesAct;
141
142
#if VTK_MAJOR_VERSION >= 8
143
QVTKOpenGLNativeWidget* qVTKWidget;
144
#else
145
QVTKWidget* qVTKWidget;
146
#endif
147
vtkRenderer* renderer;
148
149
vtkAppendPolyData *stlSurfaceData;
150
vtkAppendPolyData *stlEdgeData;
151
152
int numberOfFaces;
153
double modelLength;
154
155
nglib::Ng_Mesh *mesh;
156
nglib::Ng_STL_Geometry *geom;
157
nglib::Ng_Meshing_Parameters *mp;
158
159
CadPreferences *cadPreferences;
160
161
QString fileName;
162
163
QHash<vtkActor *, int> actorToFace;
164
165
int modelDim;
166
167
TopoDS_Shape shape;
168
};
169
170
#endif // CADVIEW_H
171
172