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: 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 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 #if 1 62 #include "vtkConfigure.h" 63 #else 64 #include "vtkVersionMacros.h" 65 #endif 66 67 class QMenu; 68 class QAction; 69 #if VTK_MAJOR_VERSION >= 8 70 class QVTKOpenGLNativeWidget; 71 #else 72 class QVTKWidget; 73 #endif 74 class vtkRenderer; 75 class vtkActor; 76 class vtkPolyData; 77 class vtkAppendPolyData; 78 79 class pt { 80 public: 81 int n; 82 double x; 83 double y; 84 }; 85 86 class seg { 87 public: 88 int p0; 89 int p1; 90 int bc; 91 }; 92 93 class CadView : public QMainWindow { 94 Q_OBJECT 95 96 public: 97 CadView(QWidget *parent = 0); 98 ~CadView(); 99 100 QSize minimumSizeHint() const; 101 QSize sizeHint() const; 102 103 #if VTK_MAJOR_VERSION >= 8 104 QVTKOpenGLNativeWidget* GetQVTKWidget(); 105 #else 106 QVTKWidget* GetQVTKWidget(); 107 #endif 108 109 bool readFile(QString); 110 void generateSTL(); 111 112 void setMesh(nglib::Ng_Mesh *); 113 void setGeom(nglib::Ng_STL_Geometry *); 114 void setMp(nglib::Ng_Meshing_Parameters *); 115 void setDeflection(double); 116 double lengthOf(double *); 117 void differenceOf(double *, double *, double *); 118 int getFaceNumber(vtkActor *); 119 int getDim(); 120 void generateIn2dFile(); 121 122 private slots: 123 void closeSlot(); 124 void generateSTLSlot(); 125 void cadPreferencesSlot(); 126 void reloadSlot(); 127 128 private: 129 void createActions(); 130 void createMenus(); 131 void clearScreen(); 132 TopoDS_Shape readBrep(QString); 133 TopoDS_Shape readStep(QString); 134 TopoDS_Shape readIges(QString); 135 void restrictMeshSizeLocal(nglib::Ng_Mesh *, vtkPolyData *, double, double); 136 137 QMenu *fileMenu; 138 QMenu *modelMenu; 139 140 QAction *exitAct; 141 QAction *reloadAct; 142 QAction *cadPreferencesAct; 143 144 #if VTK_MAJOR_VERSION >= 8 145 QVTKOpenGLNativeWidget* qVTKWidget; 146 #else 147 QVTKWidget* qVTKWidget; 148 #endif 149 vtkRenderer* renderer; 150 151 vtkAppendPolyData *stlSurfaceData; 152 vtkAppendPolyData *stlEdgeData; 153 154 int numberOfFaces; 155 double modelLength; 156 157 nglib::Ng_Mesh *mesh; 158 nglib::Ng_STL_Geometry *geom; 159 nglib::Ng_Meshing_Parameters *mp; 160 161 CadPreferences *cadPreferences; 162 163 QString fileName; 164 165 QHash<vtkActor *, int> actorToFace; 166 167 int modelDim; 168 169 TopoDS_Shape shape; 170 }; 171 172 #endif // CADVIEW_H 173