2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008,2009 Oliver Gloth +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #include "guimainwindow.h"
24 #include "guiselectboundarycodes.h"
25 #include "guiimproveaspectratio.h"
26 #include "guinormalextrusion.h"
27 #include "guisetboundarycode.h"
30 #include "vtkEgPolyDataToUnstructuredGridFilter.h"
31 #include "stlreader.h"
32 #include "gmshreader.h"
33 #include "gmshwriter.h"
34 #include "neutralwriter.h"
35 #include "stlwriter.h"
36 #include "correctsurfaceorientation.h"
37 #include "guieditboundaryconditions.h"
39 #include <vtkRenderer.h>
40 #include <vtkRenderWindow.h>
41 #include <vtkXMLUnstructuredGridWriter.h>
42 #include <vtkXMLUnstructuredGridReader.h>
43 #include <vtkProperty.h>
44 #include <vtkCallbackCommand.h>
45 #include <vtkCamera.h>
46 #include <vtkCharArray.h>
47 #include <vtkTextActor.h>
48 #include <vtkVectorText.h>
49 #include <vtkFollower.h>
50 #include <vtkLookupTable.h>
51 #include <vtkScalarBarActor.h>
53 #include <QFileDialog>
54 #include <QFileSystemWatcher>
58 #include "geometrytools.h"
59 using namespace GeometryTools
;
61 #include "guisettingsviewer.h"
62 #include "guitransform.h"
64 // GuiOutputWindow::GuiOutputWindow()
69 QString
GuiMainWindow::cwd
= ".";
70 QSettings
GuiMainWindow::qset("enGits","enGrid");
71 GuiMainWindow
* GuiMainWindow::THIS
= NULL
;
72 QMutex
GuiMainWindow::mutex
;
73 vtkIdType
GuiMainWindow::PickedPoint
;
74 vtkIdType
GuiMainWindow::PickedCell
;
75 bool GuiMainWindow::m_UseVTKInteractor
;
77 GuiMainWindow::GuiMainWindow() : QMainWindow(NULL
)
82 QPoint pos
= qset
.value("pos", QPoint(200, 200)).toPoint();
83 QSize size
= qset
.value("size", QSize(400, 400)).toSize();
87 // dock_widget = new QDockWidget(tr("output"), this);
88 // dock_widget->setFeatures(QDockWidget::AllDockWidgetFeatures);
89 // output_window = new GuiOutputWindow();
90 // dock_widget->setWidget(output_window);
91 // addDockWidget(Qt::LeftDockWidgetArea, dock_widget);
92 // ui.menuView->addAction(dock_widget->toggleViewAction());
94 connect(ui
.actionImportSTL
, SIGNAL(activated()), this, SLOT(importSTL()));
95 connect(ui
.actionImportGmsh1Ascii
, SIGNAL(activated()), this, SLOT(importGmsh1Ascii()));
96 connect(ui
.actionImportGmsh2Ascii
, SIGNAL(activated()), this, SLOT(importGmsh2Ascii()));
97 connect(ui
.actionExportGmsh1Ascii
, SIGNAL(activated()), this, SLOT(exportGmsh1Ascii()));
98 connect(ui
.actionExportGmsh2Ascii
, SIGNAL(activated()), this, SLOT(exportGmsh2Ascii()));
99 connect(ui
.actionExportNeutral
, SIGNAL(activated()), this, SLOT(exportNeutral()));
100 connect(ui
.actionExportAsciiStl
, SIGNAL(activated()), this, SLOT(exportAsciiStl()));
101 connect(ui
.actionExportBinaryStl
, SIGNAL(activated()), this, SLOT(exportBinaryStl()));
102 connect(ui
.actionExit
, SIGNAL(activated()), this, SLOT(exit()));
103 connect(ui
.actionZoomAll
, SIGNAL(activated()), this, SLOT(zoomAll()));
104 connect(ui
.actionOpen
, SIGNAL(activated()), this, SLOT(open()));
105 connect(ui
.actionSave
, SIGNAL(activated()), this, SLOT(save()));
106 connect(ui
.actionSaveAs
, SIGNAL(activated()), this, SLOT(saveAs()));
107 connect(ui
.actionBoundaryCodes
, SIGNAL(activated()), this, SLOT(selectBoundaryCodes()));
108 connect(ui
.actionNormalExtrusion
, SIGNAL(activated()), this, SLOT(normalExtrusion()));
109 connect(ui
.actionViewAxes
, SIGNAL(changed()), this, SLOT(setAxesVisibility()));
110 connect(ui
.actionViewOrthogonal
, SIGNAL(changed()), this, SLOT(setViewingMode()));
111 connect(ui
.actionViewNodeIDs
, SIGNAL(changed()), this, SLOT(ViewNodeIDs()));
112 connect(ui
.actionViewCellIDs
, SIGNAL(changed()), this, SLOT(ViewCellIDs()));
113 connect(ui
.actionChangeOrientation
, SIGNAL(activated()), this, SLOT(changeSurfaceOrientation()));
114 connect(ui
.actionCheckOrientation
, SIGNAL(activated()), this, SLOT(checkSurfaceOrientation()));
115 connect(ui
.actionImproveAspectRatio
, SIGNAL(activated()), this, SLOT(improveAspectRatio()));
116 connect(ui
.actionRedraw
, SIGNAL(activated()), this, SLOT(updateActors()));
117 connect(ui
.actionScaleToData
, SIGNAL(activated()), this, SLOT(ScaleToData()));
118 connect(ui
.actionClearOutputWindow
, SIGNAL(activated()), this, SLOT(clearOutput()));
119 connect(ui
.actionEditBoundaryConditions
, SIGNAL(activated()), this, SLOT(editBoundaryConditions()));
120 connect(ui
.actionConfigure
, SIGNAL(activated()), this, SLOT(configure()));
121 connect(ui
.actionAbout
, SIGNAL(activated()), this, SLOT(about()));
123 connect(ui
.checkBox_UseVTKInteractor
, SIGNAL(stateChanged(int)), this, SLOT(setUseVTKInteractor(int)));
125 connect(ui
.actionViewXP
, SIGNAL(activated()), this, SLOT(viewXP()));
126 connect(ui
.actionViewXM
, SIGNAL(activated()), this, SLOT(viewXM()));
127 connect(ui
.actionViewYP
, SIGNAL(activated()), this, SLOT(viewYP()));
128 connect(ui
.actionViewYM
, SIGNAL(activated()), this, SLOT(viewYM()));
129 connect(ui
.actionViewZP
, SIGNAL(activated()), this, SLOT(viewZP()));
130 connect(ui
.actionViewZM
, SIGNAL(activated()), this, SLOT(viewZM()));
133 #include "std_connections.h"
135 if (qset
.contains("working_directory")) {
136 cwd
= qset
.value("working_directory").toString();
138 grid
= vtkUnstructuredGrid::New();
139 renderer
= vtkRenderer::New();
140 getRenderWindow()->AddRenderer(renderer
);
141 surface_actor
= vtkActor::New();
142 surface_wire_actor
= vtkActor::New();
144 tetra_mapper
= vtkPolyDataMapper::New();
145 pyramid_mapper
= vtkPolyDataMapper::New();
146 wedge_mapper
= vtkPolyDataMapper::New();
147 hexa_mapper
= vtkPolyDataMapper::New();
148 volume_wire_mapper
= vtkPolyDataMapper::New();
149 surface_mapper
= vtkPolyDataMapper::New();
150 surface_wire_mapper
= vtkPolyDataMapper::New();
152 backface_property
= vtkProperty::New();
155 pyramid_actor
= NULL
;
158 volume_wire_actor
= NULL
;
159 iamlegend_actor
= NULL
;
163 surface_filter
= vtkGeometryFilter::New();
164 bcodes_filter
= vtkEgBoundaryCodesFilter::New();
165 renderer
->AddActor(surface_actor
);
166 renderer
->AddActor(surface_wire_actor
);
167 pick_sphere
= vtkSphereSource::New();
168 pick_mapper
= vtkPolyDataMapper::New();
171 extr_vol
= vtkEgExtractVolumeCells::New();
172 extr_tetras
= vtkEgExtractVolumeCells::New();
173 extr_pyramids
= vtkEgExtractVolumeCells::New();
174 extr_wedges
= vtkEgExtractVolumeCells::New();
175 extr_hexas
= vtkEgExtractVolumeCells::New();
177 volume_geometry
= vtkGeometryFilter::New();
178 tetra_geometry
= vtkGeometryFilter::New();
179 pyramid_geometry
= vtkGeometryFilter::New();
180 wedge_geometry
= vtkGeometryFilter::New();
181 hexa_geometry
= vtkGeometryFilter::New();
183 extr_tetras
->SetAllOff();
184 extr_tetras
->SetTetrasOn();
185 extr_pyramids
->SetAllOff();
186 extr_pyramids
->SetPyramidsOn();
187 extr_wedges
->SetAllOff();
188 extr_wedges
->SetWedgesOn();
189 extr_hexas
->SetAllOff();
190 extr_hexas
->SetHexasOn();
192 boundary_pd
= vtkPolyData::New();
193 tetras_pd
= vtkPolyData::New();
194 wedges_pd
= vtkPolyData::New();
195 pyras_pd
= vtkPolyData::New();
196 hexas_pd
= vtkPolyData::New();
197 volume_pd
= vtkPolyData::New();
199 current_filename
= "untitled.vtu";
200 setWindowTitle(current_filename
+ " - enGrid");
202 status_bar
= new QStatusBar(this);
203 setStatusBar(status_bar
);
204 status_label
= new QLabel(this);
205 status_bar
->addWidget(status_label
);
206 QString txt
= "0 volume cells (0 tetras, 0 hexas, 0 pyramids, 0 prisms), ";
207 txt
+= "0 surface cells (0 triangles, 0 quads), 0 nodes";
208 status_label
->setText(txt
);
210 axes
= vtkCubeAxesActor2D::New();
211 axes
->SetCamera(getRenderer()->GetActiveCamera());
212 getRenderer()->AddActor(axes
);
215 CellPicker
= vtkCellPicker::New();
216 // getInteractor()->SetPicker(CellPicker);
217 PointPicker
= vtkPointPicker::New();
218 // getInteractor()->SetPicker(PointPicker);
220 pick_sphere
->SetRadius(0.25);//in case the user starts picking points instead of cells
222 vtkCallbackCommand
*cbc
= vtkCallbackCommand::New();
223 cbc
->SetCallback(pickCellCallBack
);
224 CellPicker
->AddObserver(vtkCommand::EndPickEvent
, cbc
);
225 cbc
->SetCallback(pickPointCallBack
);
226 PointPicker
->AddObserver(vtkCommand::EndPickEvent
, cbc
);
229 QString user
= QString(getenv("USER"));
230 QString basename
="enGrid_output_"+user
+".txt";
232 if (qset
.contains("tmp_directory")) {
233 log_file_name
= qset
.value("tmp_directory").toString() + "/" + basename
;
235 log_file_name
= "/tmp/" + basename
;
237 system_stdout
= stdout
;
238 freopen (log_file_name
.toAscii().data(), "w", stdout
);
243 connect(&garbage_timer
, SIGNAL(timeout()), this, SLOT(periodicUpdate()));
244 garbage_timer
.start(1000);
246 connect(&log_timer
, SIGNAL(timeout()), this, SLOT(updateOutput()));
247 log_timer
.start(1000);
252 getSet("","enable experimental features",false,exp_features
);
253 ui
.actionFoamWriter
->setEnabled(exp_features
);
257 // ui.checkBox_UseVTKInteractor->setCheckState(Qt::Checked);
258 // ui.radioButton_CellPicker->setChecked(true);
259 setPickMode(true,true);
263 ui
.doubleSpinBox_HueMin
->setValue(0.667);
264 ui
.doubleSpinBox_HueMax
->setValue(0);
267 GuiMainWindow::~GuiMainWindow()
269 qset
.setValue("pos", pos());
270 qset
.setValue("size", size());
273 void GuiMainWindow::updateOutput()
275 QFile
log_file(log_file_name
);
276 log_file
.open(QIODevice::ReadOnly
);
277 QByteArray buffer
= log_file
.readAll();
278 if (buffer
.size() > N_chars
) {
279 QByteArray newchars
= buffer
.right(buffer
.size() - N_chars
);
280 N_chars
= buffer
.size();
281 QString
txt(newchars
);
282 if (txt
.right(1) == "\n") {
283 txt
= txt
.left(txt
.size()-1);
285 ui
.textEditOutput
->append(txt
);
289 void GuiMainWindow::exit()
291 QCoreApplication::exit();
294 vtkRenderWindow
* GuiMainWindow::getRenderWindow()
296 return ui
.qvtkWidget
->GetRenderWindow();
299 vtkRenderer
* GuiMainWindow::getRenderer()
304 QVTKInteractor
* GuiMainWindow::getInteractor()
306 return ui
.qvtkWidget
->GetInteractor();
309 QString
GuiMainWindow::getCwd()
314 void GuiMainWindow::setCwd(QString dir
)
317 qset
.setValue("working_directory",dir
);
320 void GuiMainWindow::ScaleToData()
322 int current_field
=ui
.comboBox_Field
->currentIndex();
326 boundary_pd
->GetPointData()->GetArray(current_field
-1)->GetRange(range
);
327 cout
<<"current_field="<<current_field
<<endl
;
328 cout
<<"range[0]="<<range
[0]<<endl
;
329 cout
<<"range[1]="<<range
[1]<<endl
;
330 ui
.doubleSpinBox_FieldMin
->setRange(range
[0],range
[1]);
331 ui
.doubleSpinBox_FieldMax
->setRange(range
[0],range
[1]);
332 ui
.doubleSpinBox_FieldMin
->setValue(range
[0]);
333 ui
.doubleSpinBox_FieldMax
->setValue(range
[1]);
337 void GuiMainWindow::updateActors()
339 if (!tryLock()) return;
343 if (!grid
->GetCellData()->GetScalars("cell_index")) {
344 EG_VTKSP(vtkLongArray_t
, cell_idx
);
345 cell_idx
->SetName("cell_index");
346 cell_idx
->SetNumberOfValues(grid
->GetNumberOfCells());
347 grid
->GetCellData()->AddArray(cell_idx
);
350 EG_VTKDCC(vtkLongArray_t
, cell_index
, grid
, "cell_index");
351 for (vtkIdType cellId
= 0; cellId
< grid
->GetNumberOfCells(); ++cellId
) {
352 cell_index
->SetValue(cellId
, cellId
);
356 axes
->SetInput(grid
);
364 for (vtkIdType nodeId
= 0; nodeId
< grid
->GetNumberOfPoints(); ++nodeId
) {
366 grid
->GetPoints()->GetPoint(nodeId
, x
.data());
367 xmin
= min(x
[0], xmin
);
368 xmax
= max(x
[0], xmax
);
369 ymin
= min(x
[1], ymin
);
370 ymax
= max(x
[1], ymax
);
371 zmin
= min(x
[2], zmin
);
372 zmax
= max(x
[2], zmax
);
376 getRenderer()->RemoveActor(surface_actor
);
377 surface_actor
->Delete();
378 surface_actor
= NULL
;
380 if (surface_wire_actor
) {
381 getRenderer()->RemoveActor(surface_wire_actor
);
382 surface_wire_actor
->Delete();
383 surface_wire_actor
= NULL
;
386 getRenderer()->RemoveActor(tetra_actor
);
387 tetra_actor
->Delete();
391 getRenderer()->RemoveActor(pyramid_actor
);
392 pyramid_actor
->Delete();
393 pyramid_actor
= NULL
;
396 getRenderer()->RemoveActor(wedge_actor
);
397 wedge_actor
->Delete();
401 getRenderer()->RemoveActor(hexa_actor
);
402 hexa_actor
->Delete();
405 if (volume_wire_actor
) {
406 getRenderer()->RemoveActor(volume_wire_actor
);
407 volume_wire_actor
->Delete();
408 volume_wire_actor
= NULL
;
411 getRenderer()->RemoveActor(pick_actor
);
412 pick_actor
->Delete();
415 if (iamlegend_actor
) {
416 getRenderer()->RemoveActor(iamlegend_actor
);
417 iamlegend_actor
->Delete();
418 iamlegend_actor
= NULL
;
425 field_mapper
->Delete();
429 if (ui
.checkBoxSurface
->isChecked()) {
430 bcodes_filter
->SetBoundaryCodes(&display_boundary_codes
);
432 bcodes_filter
->SetInput(grid
);
434 surface_filter
->SetInput(bcodes_filter
->GetOutput());
436 surface_filter
->Update();
438 boundary_pd
->DeepCopy(surface_filter
->GetOutput());
440 surface_mapper
->SetInput(boundary_pd
);
442 surface_wire_mapper
->SetInput(boundary_pd
);
443 surface_actor
= vtkActor::New();
444 surface_actor
->GetProperty()->SetRepresentationToSurface();
446 int current_field
=ui
.comboBox_Field
->currentIndex();
447 ui
.comboBox_Field
->clear();
448 ui
.comboBox_Field
->addItem("None");
449 int N_Arrays
=boundary_pd
->GetPointData()->GetNumberOfArrays();
450 cout
<<"N_Arrays="<<N_Arrays
<<endl
;
451 for (int i
=0; i
<N_Arrays
; i
++)
453 ui
.comboBox_Field
->addItem(boundary_pd
->GetPointData()->GetArrayName(i
));
456 if(current_field
==-1) ui
.comboBox_Field
->setCurrentIndex(0);
457 else ui
.comboBox_Field
->setCurrentIndex(current_field
);
459 cout
<<"index="<<ui
.comboBox_Field
->currentIndex()<<endl
;
460 cout
<<"name="<<ui
.comboBox_Field
->currentText().toLatin1().data()<<endl
;
462 current_field
=ui
.comboBox_Field
->currentIndex();
466 boundary_pd
->GetPointData()->GetArray(current_field
-1)->GetRange(range
);
467 cout
<<"current_field="<<current_field
<<endl
;
468 cout
<<"range[0]="<<range
[0]<<endl
;
469 cout
<<"range[1]="<<range
[1]<<endl
;
470 ui
.doubleSpinBox_FieldMin
->setRange(range
[0],range
[1]);
471 ui
.doubleSpinBox_FieldMax
->setRange(range
[0],range
[1]);
474 if(ui
.comboBox_Field
->currentIndex()<=0) {
475 surface_actor
->SetBackfaceProperty(backface_property
);
476 surface_actor
->GetProperty()->SetColor(0.5,1,0.5);
477 surface_actor
->GetBackfaceProperty()->SetColor(1,1,0.5);
478 surface_actor
->SetMapper(surface_mapper
);
481 lut
=vtkLookupTable::New();
482 lut
->SetNumberOfColors(256);
483 lut
->SetHueRange(ui
.doubleSpinBox_HueMin
->value(),ui
.doubleSpinBox_HueMax
->value());
485 field_mapper
=vtkPolyDataMapper::New();
486 field_mapper
->SetLookupTable(lut
);
487 field_mapper
->SetInput(boundary_pd
);
488 field_mapper
->SetColorModeToMapScalars();
489 field_mapper
->SetScalarModeToUsePointFieldData();
490 field_mapper
->ColorByArrayComponent(ui
.comboBox_Field
->currentText().toLatin1().data(),0);
491 field_mapper
->SetScalarRange(ui
.doubleSpinBox_FieldMin
->value(),ui
.doubleSpinBox_FieldMax
->value());
492 surface_actor
->SetMapper(field_mapper
);
494 if(ui
.checkBox_Legend
->checkState()) {
495 iamlegend_actor
= vtkScalarBarActor::New();
496 iamlegend_actor
->SetLookupTable (lut
);
497 getRenderer()->AddActor(iamlegend_actor
);
501 vtkDoubleArray
*newScalars
= vtkDoubleArray::New();
503 newScalars
=(vtkDoubleArray
*)boundary_pd
->GetPointData()->GetArray("node_meshdensity_current",index
);
504 cout
<<"index="<<index
<<endl
;
506 cout
<<"=========="<<endl
;
507 boundary_pd
->GetPointData()->GetArray("node_status",index
);
508 cout
<<"index="<<index
<<endl
;
509 boundary_pd
->GetPointData()->GetArray("node_layer",index
);
510 cout
<<"index="<<index
<<endl
;
511 boundary_pd
->GetPointData()->GetArray("node_index",index
);
512 cout
<<"index="<<index
<<endl
;
513 boundary_pd
->GetPointData()->GetArray("node_meshdensity",index
);
514 cout
<<"index="<<index
<<endl
;
515 boundary_pd
->GetPointData()->GetArray("node_meshdensity_current",index
);
516 cout
<<"index="<<index
<<endl
;
517 boundary_pd
->GetPointData()->GetArray("node_type",index
);
518 cout
<<"index="<<index
<<endl
;
519 cout
<<"=========="<<endl
;
521 int N2
=newScalars
->GetNumberOfComponents();
522 int N3
=newScalars
->GetNumberOfTuples();
523 cout
<<"Number of components=N2="<<N2
<<endl
;
524 cout
<<"Number of tuples=N3="<<N3
<<endl
;
527 /* for (int i=0; i<N3; i++)
529 double D=newScalars->GetComponent(i,0);//strange, but works. O.o
530 cout<<"D["<<i<<"]="<<D<<endl;
533 surface_wire_actor
= vtkActor::New();
534 surface_wire_actor
->GetProperty()->SetRepresentationToWireframe();
535 surface_wire_actor
->GetProperty()->SetColor(0,0,1);
537 surface_wire_actor
->SetMapper(surface_wire_mapper
);
538 getRenderer()->AddActor(surface_actor
);
539 getRenderer()->AddActor(surface_wire_actor
);
540 bcodes_filter
->Update();
542 if(m_UseVTKInteractor
)
544 if(ui
.radioButton_CellPicker
->isChecked())
546 // CellPicker->Pick(0,0,0, getRenderer());
547 getInteractor()->SetPicker(CellPicker
);
548 // CellPicker->Pick(0,0,0, getRenderer());
549 vtkIdType cellId
= getPickedCell();
554 getInteractor()->SetPicker(PointPicker
);
555 vtkIdType nodeId
= getPickedPoint();
561 if(ui
.radioButton_CellPicker
->isChecked()) pickCell(PickedCell
);
562 else pickPoint(PickedPoint
);
564 /* getInteractor()->SetPicker(CellPicker);
565 vtkIdType cellId = getPickedCell();
567 getInteractor()->SetPicker(PointPicker);
568 vtkIdType nodeId = getPickedPoint();
574 x
[0] = ui
.lineEditClipX
->text().toDouble();
575 x
[1] = ui
.lineEditClipY
->text().toDouble();
576 x
[2] = ui
.lineEditClipZ
->text().toDouble();
577 n
[0] = ui
.lineEditClipNX
->text().toDouble();
578 n
[1] = ui
.lineEditClipNY
->text().toDouble();
579 n
[2] = ui
.lineEditClipNZ
->text().toDouble();
581 x
= x
+ ui
.lineEditOffset
->text().toDouble()*n
;
582 extr_vol
->SetAllOff();
583 if (ui
.checkBoxTetra
->isChecked()) {
584 extr_vol
->SetTetrasOn();
585 extr_tetras
->SetInput(grid
);
586 if (ui
.checkBoxClip
->isChecked()) {
587 extr_tetras
->SetClippingOn();
588 extr_tetras
->SetX(x
);
589 extr_tetras
->SetN(n
);
591 extr_tetras
->SetClippingOff();
593 tetra_actor
= vtkActor::New();
594 tetra_geometry
->SetInput(extr_tetras
->GetOutput());
595 tetra_geometry
->Update();
596 tetras_pd
->DeepCopy(tetra_geometry
->GetOutput());
597 tetra_mapper
->SetInput(tetras_pd
);
598 tetra_actor
= vtkActor::New();
599 tetra_actor
->SetMapper(tetra_mapper
);
600 tetra_actor
->GetProperty()->SetColor(1,0,0);
601 getRenderer()->AddActor(tetra_actor
);
603 if (ui
.checkBoxPyramid
->isChecked()) {
604 extr_vol
->SetPyramidsOn();
605 extr_pyramids
->SetInput(grid
);
606 if (ui
.checkBoxClip
->isChecked()) {
607 extr_pyramids
->SetClippingOn();
608 extr_pyramids
->SetX(x
);
609 extr_pyramids
->SetN(n
);
611 extr_pyramids
->SetClippingOff();
613 pyramid_actor
= vtkActor::New();
614 pyramid_geometry
->SetInput(extr_pyramids
->GetOutput());
615 pyramid_geometry
->Update();
616 pyras_pd
->DeepCopy(pyramid_geometry
->GetOutput());
617 pyramid_mapper
->SetInput(pyras_pd
);
618 pyramid_actor
= vtkActor::New();
619 pyramid_actor
->SetMapper(pyramid_mapper
);
620 pyramid_actor
->GetProperty()->SetColor(1,1,0);
621 getRenderer()->AddActor(pyramid_actor
);
623 if (ui
.checkBoxWedge
->isChecked()) {
624 extr_vol
->SetWedgesOn();
625 extr_wedges
->SetInput(grid
);
626 if (ui
.checkBoxClip
->isChecked()) {
627 extr_wedges
->SetClippingOn();
628 extr_wedges
->SetX(x
);
629 extr_wedges
->SetN(n
);
631 extr_wedges
->SetClippingOff();
633 wedge_actor
= vtkActor::New();
634 wedge_geometry
->SetInput(extr_wedges
->GetOutput());
635 wedge_geometry
->Update();
636 wedges_pd
->DeepCopy(wedge_geometry
->GetOutput());
637 wedge_mapper
->SetInput(wedges_pd
);
638 wedge_actor
= vtkActor::New();
639 wedge_actor
->SetMapper(wedge_mapper
);
640 wedge_actor
->GetProperty()->SetColor(0,1,0);
641 getRenderer()->AddActor(wedge_actor
);
643 if (ui
.checkBoxHexa
->isChecked()) {
644 extr_vol
->SetHexasOn();
645 extr_hexas
->SetInput(grid
);
646 if (ui
.checkBoxClip
->isChecked()) {
647 extr_hexas
->SetClippingOn();
651 extr_hexas
->SetClippingOff();
653 hexa_actor
= vtkActor::New();
654 hexa_geometry
->SetInput(extr_hexas
->GetOutput());
655 hexa_geometry
->Update();
656 hexas_pd
->DeepCopy(hexa_geometry
->GetOutput());
657 hexa_mapper
->SetInput(hexas_pd
);
658 hexa_actor
= vtkActor::New();
659 hexa_actor
->SetMapper(hexa_mapper
);
660 hexa_actor
->GetProperty()->SetColor(0,0.7,1);
661 getRenderer()->AddActor(hexa_actor
);
665 extr_vol
->SetInput(grid
);
666 if (ui
.checkBoxClip
->isChecked()) {
667 extr_vol
->SetClippingOn();
671 extr_vol
->SetClippingOff();
673 volume_wire_actor
= vtkActor::New();
674 volume_geometry
->SetInput(extr_vol
->GetOutput());
675 volume_geometry
->Update();
676 volume_pd
->DeepCopy(volume_geometry
->GetOutput());
677 volume_wire_mapper
->SetInput(volume_pd
);
678 volume_wire_actor
->SetMapper(volume_wire_mapper
);
679 volume_wire_actor
->GetProperty()->SetRepresentationToWireframe();
680 volume_wire_actor
->GetProperty()->SetColor(0,0,1);
681 getRenderer()->AddActor(volume_wire_actor
);
685 getRenderWindow()->Render();
686 } catch (Error err
) {
692 void GuiMainWindow::setPickMode(bool a_UseVTKInteractor
,bool a_CellPickerMode
)
694 m_UseVTKInteractor
=a_UseVTKInteractor
;
695 if(a_UseVTKInteractor
) ui
.checkBox_UseVTKInteractor
->setCheckState(Qt::Checked
);
696 else ui
.checkBox_UseVTKInteractor
->setCheckState(Qt::Unchecked
);
697 if(a_CellPickerMode
) ui
.radioButton_CellPicker
->toggle();
698 else ui
.radioButton_PointPicker
->toggle();
699 // cout<<"m_UseVTKInteractor="<<m_UseVTKInteractor<<endl;
702 void GuiMainWindow::setUseVTKInteractor(int a_UseVTKInteractor
)
704 m_UseVTKInteractor
=a_UseVTKInteractor
;
705 // cout<<"m_UseVTKInteractor="<<m_UseVTKInteractor<<endl;
708 bool GuiMainWindow::pickPoint(vtkIdType nodeId
)
710 if (nodeId
>= 0 && nodeId
<grid
->GetNumberOfPoints()) {
712 grid
->GetPoints()->GetPoint(nodeId
, x
.data());
713 pick_sphere
->SetCenter(x
.data());
714 pick_mapper
->SetInput(pick_sphere
->GetOutput());
715 pick_actor
= vtkActor::New();
716 pick_actor
->SetMapper(pick_mapper
);
717 pick_actor
->GetProperty()->SetRepresentationToSurface();
718 pick_actor
->GetProperty()->SetColor(0,0,1);
719 getRenderer()->AddActor(pick_actor
);
726 bool GuiMainWindow::pickCell(vtkIdType cellId
)
728 if (cellId
>= 0 && cellId
<grid
->GetNumberOfCells()) {
729 vtkIdType
*pts
, Npts
;
730 grid
->GetCellPoints(cellId
, Npts
, pts
);
732 for (vtkIdType i
= 0; i
< Npts
; ++i
) {
734 grid
->GetPoints()->GetPoint(pts
[i
], xp
.data());
735 x
+= double(1)/Npts
* xp
;
737 pick_sphere
->SetCenter(x
.data());
739 for (vtkIdType i
= 0; i
< Npts
; ++i
) {
741 grid
->GetPoints()->GetPoint(pts
[i
], xp
.data());
742 R
= min(R
, 0.25*(xp
-x
).abs());
744 ReferenceSize
=R
;//Used for text annotations too!
745 pick_sphere
->SetRadius(R
);
746 pick_mapper
->SetInput(pick_sphere
->GetOutput());
747 pick_actor
= vtkActor::New();
748 pick_actor
->SetMapper(pick_mapper
);
749 pick_actor
->GetProperty()->SetRepresentationToSurface();
750 pick_actor
->GetProperty()->SetColor(1,0,0);
751 getRenderer()->AddActor(pick_actor
);
758 void GuiMainWindow::importSTL()
762 updateBoundaryCodes(true);
768 void GuiMainWindow::importGmsh1Ascii()
773 updateBoundaryCodes(true);
779 void GuiMainWindow::exportGmsh1Ascii()
786 void GuiMainWindow::importGmsh2Ascii()
791 updateBoundaryCodes(true);
797 void GuiMainWindow::exportGmsh2Ascii()
804 void GuiMainWindow::exportNeutral()
806 NeutralWriter neutral
;
810 void GuiMainWindow::zoomAll()
812 getRenderer()->ResetCamera();
813 getRenderWindow()->Render();
816 void GuiMainWindow::open()
818 current_filename
= QFileDialog::getOpenFileName
821 "open grid from file",
823 "VTK unstructured grid files (*.vtu *.VTU)"
825 if (!current_filename
.isNull()) {
826 GuiMainWindow::setCwd(QFileInfo(current_filename
).absolutePath());
827 EG_VTKSP(vtkXMLUnstructuredGridReader
,vtu
);
828 vtu
->SetFileName(current_filename
.toAscii().data());
830 grid
->DeepCopy(vtu
->GetOutput());
831 createBasicFields(grid
, grid
->GetNumberOfCells(), grid
->GetNumberOfPoints(), false);
832 setWindowTitle(current_filename
+ " - enGrid");
834 updateBoundaryCodes(true);
841 void GuiMainWindow::undo()
845 void GuiMainWindow::redo()
849 void GuiMainWindow::openBC()
851 QString bc_file
= current_filename
+ ".bcs";
855 file
.open(QIODevice::ReadOnly
| QIODevice::Text
);
856 QTextStream
f(&file
);
860 f
>> i
>> name
>> type
;
861 bcmap
[i
] = BoundaryCondition(name
,type
);
866 void GuiMainWindow::saveBC()
868 QString bc_file
= current_filename
+ ".bcs";
870 file
.open(QIODevice::WriteOnly
| QIODevice::Text
);
871 QTextStream
f(&file
);
872 foreach(int i
, all_boundary_codes
) {
873 BoundaryCondition bc
= bcmap
[i
];
874 f
<< i
<< " " << bc
.getName() << " " << bc
.getType() << "\n";
878 void GuiMainWindow::save()
880 cout
<< current_filename
.toAscii().data() << endl
;
881 if (current_filename
== "untitled.vtu") {
884 EG_VTKDCC(vtkDoubleArray
, cell_VA
, grid
, "cell_VA");
885 for (vtkIdType cellId
= 0; cellId
< grid
->GetNumberOfCells(); ++cellId
) {
886 cell_VA
->SetValue(cellId
, GeometryTools::cellVA(grid
, cellId
, true));
888 EG_VTKSP(vtkXMLUnstructuredGridWriter
,vtu
);
891 vtu
->SetFileName(current_filename
.toAscii().data());
892 vtu
->SetDataModeToBinary();
899 void GuiMainWindow::saveAs()
901 current_filename
= QFileDialog::getSaveFileName
904 "write grid to file",
906 "VTK unstructured grid files (*.vtu *.VTU)"
908 if (!current_filename
.isNull()) {
909 if (current_filename
.right(4) != ".vtu") {
910 if (current_filename
.right(4) != ".VTU") {
911 current_filename
+= ".vtu";
914 EG_VTKDCC(vtkDoubleArray
, cell_VA
, grid
, "cell_VA");
915 for (vtkIdType cellId
= 0; cellId
< grid
->GetNumberOfCells(); ++cellId
) {
916 cell_VA
->SetValue(cellId
, GeometryTools::cellVA(grid
, cellId
, true));
918 GuiMainWindow::setCwd(QFileInfo(current_filename
).absolutePath());
919 EG_VTKSP(vtkXMLUnstructuredGridWriter
,vtu
);
922 vtu
->SetFileName(current_filename
.toAscii().data());
923 vtu
->SetDataModeToBinary();
927 setWindowTitle(current_filename
+ " - enGrid");
931 void GuiMainWindow::QuickSave(QString a_filename
)
933 cout
<< a_filename
.toAscii().data() << endl
;
935 EG_VTKDCC(vtkDoubleArray
, cell_VA
, grid
, "cell_VA");
936 for (vtkIdType cellId
= 0; cellId
< grid
->GetNumberOfCells(); ++cellId
) {
937 cell_VA
->SetValue(cellId
, GeometryTools::cellVA(grid
, cellId
, true));
939 EG_VTKSP(vtkXMLUnstructuredGridWriter
,vtu
);
942 vtu
->SetFileName(a_filename
.toAscii().data());
943 vtu
->SetDataModeToBinary();
950 void GuiMainWindow::updateStatusBar()
952 QString num
, txt
= "enGrid is currently busy with an operation ...";
957 status_label
->setText(txt
);
960 vtkIdType Ncells
= grid
->GetNumberOfCells();
961 vtkIdType Nnodes
= grid
->GetNumberOfPoints();
963 vtkIdType Nquads
= 0;
965 vtkIdType Npyras
= 0;
966 vtkIdType Nprism
= 0;
967 vtkIdType Nhexas
= 0;
968 for (vtkIdType i
= 0; i
< Ncells
; ++i
) {
969 int ct
= grid
->GetCellType(i
);
970 if (ct
== VTK_TRIANGLE
) ++Ntris
;
971 else if (ct
== VTK_QUAD
) ++Nquads
;
972 else if (ct
== VTK_TETRA
) ++Ntets
;
973 else if (ct
== VTK_WEDGE
) ++Nprism
;
974 else if (ct
== VTK_PYRAMID
) ++Npyras
;
975 else if (ct
== VTK_HEXAHEDRON
) ++Nhexas
;
977 num
.setNum(Ntets
+ Npyras
+ Nprism
+ Nhexas
); txt
+= num
+ " volume cells(";
978 num
.setNum(Ntets
); txt
+= num
+ " tetras, ";
979 num
.setNum(Npyras
); txt
+= num
+ " pyramids, ";
980 num
.setNum(Nprism
); txt
+= num
+ " prisms, ";
981 num
.setNum(Nhexas
); txt
+= num
+ " hexas), ";
982 num
.setNum(Ntris
+ Nquads
); txt
+= num
+ " surface cells(";
983 num
.setNum(Ntris
); txt
+= num
+ " triangles, ";
984 num
.setNum(Nquads
); txt
+= num
+ " quads), ";
985 num
.setNum(Nnodes
); txt
+= num
+ " nodes";
987 if(ui
.radioButton_CellPicker
->isChecked())
989 QString pick_txt
= ", picked cell: ";
990 vtkIdType id_cell
= getPickedCell();
992 pick_txt
+= "no cell picked";
994 vtkIdType type_cell
= grid
->GetCellType(id_cell
);
995 if (type_cell
== VTK_TRIANGLE
) pick_txt
+= "triangle";
996 else if (type_cell
== VTK_QUAD
) pick_txt
+= "quad";
997 else if (type_cell
== VTK_TETRA
) pick_txt
+= "tetrahedron";
998 else if (type_cell
== VTK_PYRAMID
) pick_txt
+= "pyramid";
999 else if (type_cell
== VTK_WEDGE
) pick_txt
+= "prism";
1000 else if (type_cell
== VTK_HEXAHEDRON
) pick_txt
+= "hexahedron";
1001 vtkIdType N_pts
, *pts
;
1002 grid
->GetCellPoints(id_cell
, N_pts
, pts
);
1004 for (int i_pts
= 0; i_pts
< N_pts
; ++i_pts
) {
1006 num
.setNum(pts
[i_pts
]);
1008 if (i_pts
< N_pts
-1) {
1014 tmp
.setNum(id_cell
);
1015 pick_txt
+= " id_cell=" + tmp
;
1021 QString pick_txt
= ", picked node: ";
1022 vtkIdType id_node
= getPickedPoint();
1024 pick_txt
+= "no node picked";
1027 grid
->GetPoints()->GetPoint(id_node
,x
.data());
1029 for (int i
= 0; i
< 3; i
++) {
1039 tmp
.setNum(id_node
);
1040 pick_txt
+= " id_node=" + tmp
;
1041 EG_VTKDCN(vtkDoubleArray
, node_meshdensity
, grid
, "node_meshdensity");
1042 tmp
.setNum(node_meshdensity
->GetValue(id_node
));
1043 pick_txt
+= " wanted density=" + tmp
;
1044 EG_VTKDCN(vtkDoubleArray
, node_meshdensity_current
, grid
, "node_meshdensity_current");
1045 tmp
.setNum(node_meshdensity_current
->GetValue(id_node
));
1046 pick_txt
+= " current density=" + tmp
;
1047 EG_VTKDCN(vtkCharArray
, node_type
, grid
, "node_type");
1048 pick_txt
+= " type=" + QString(VertexType2Str( node_type
->GetValue(id_node
)));
1054 status_label
->setText(txt
);
1058 void GuiMainWindow::selectBoundaryCodes()
1060 GuiSelectBoundaryCodes bcodes
;
1061 bcodes
.setDisplayBoundaryCodes(display_boundary_codes
);
1062 bcodes
.setBoundaryCodes(all_boundary_codes
);
1064 bcodes
.getThread().wait();
1065 bcodes
.getSelectedBoundaryCodes(display_boundary_codes
);
1069 void GuiMainWindow::updateBoundaryCodes(bool all_on
)
1072 all_boundary_codes
.clear();
1073 EG_VTKDCC(vtkIntArray
, cell_code
, grid
, "cell_code");
1074 for (vtkIdType i
= 0; i
< grid
->GetNumberOfCells(); ++i
) {
1075 int ct
= grid
->GetCellType(i
);
1076 if ((ct
== VTK_TRIANGLE
) || (ct
== VTK_QUAD
)) {
1077 all_boundary_codes
.insert(cell_code
->GetValue(i
));
1081 display_boundary_codes
.clear();
1082 foreach (int bc
, all_boundary_codes
) {
1083 display_boundary_codes
.insert(bc
);
1087 foreach (int bc
, display_boundary_codes
) {
1088 if (all_boundary_codes
.contains(bc
)) {
1092 display_boundary_codes
.clear();
1093 foreach (int bc
, all_boundary_codes
) {
1094 if (dbcs
.contains(bc
)) {
1095 display_boundary_codes
.insert(bc
);
1099 } catch (Error err
) {
1104 void GuiMainWindow::normalExtrusion()
1106 GuiNormalExtrusion extr
;
1108 updateBoundaryCodes(false);
1112 void GuiMainWindow::setAxesVisibility()
1114 if (ui
.actionViewAxes
->isChecked()) axes
->SetVisibility(1);
1115 else axes
->SetVisibility(0);
1116 getRenderWindow()->Render();
1119 void GuiMainWindow::setViewingMode()
1121 if (ui
.actionViewOrthogonal
->isChecked()) getRenderer()->GetActiveCamera()->ParallelProjectionOn();
1122 else getRenderer()->GetActiveCamera()->ParallelProjectionOff();
1123 getRenderWindow()->Render();
1126 void GuiMainWindow::ViewNodeIDs()
1128 int N
=grid
->GetNumberOfPoints();
1129 cout
<<"N="<<N
<<endl
;
1130 if (ui
.actionViewNodeIDs
->isChecked()) {
1131 cout
<<"Activating node ID view"<<endl
;
1132 NodeText_VectorText
.resize(N
);
1133 NodeText_PolyDataMapper
.resize(N
);
1134 NodeText_Follower
.resize(N
);
1135 for(int i
=0;i
<N
;i
++){
1136 NodeText_VectorText
[i
]=vtkVectorText::New();
1139 NodeText_VectorText
[i
]->SetText(tmp
.toLatin1().data());
1140 NodeText_PolyDataMapper
[i
]=vtkPolyDataMapper::New();
1141 NodeText_PolyDataMapper
[i
]->SetInputConnection(NodeText_VectorText
[i
]->GetOutputPort());
1142 NodeText_Follower
[i
]=vtkFollower::New();
1143 NodeText_Follower
[i
]->SetMapper(NodeText_PolyDataMapper
[i
]);
1144 NodeText_Follower
[i
]->SetScale(ReferenceSize
,ReferenceSize
,ReferenceSize
);
1146 grid
->GetPoint(i
,M
.data());
1148 vec3_t OffSet
=ReferenceSize
*tmp_M
.normalise();
1150 NodeText_Follower
[i
]->AddPosition(M
[0],M
[1],M
[2]);
1151 NodeText_Follower
[i
]->SetCamera(getRenderer()->GetActiveCamera());
1152 NodeText_Follower
[i
]->GetProperty()->SetColor(0,0,1);
1153 getRenderer()->AddActor(NodeText_Follower
[i
]);
1157 cout
<<"Deactivating node ID view"<<endl
;
1158 for(unsigned int i
=0;i
<NodeText_Follower
.size();i
++){
1159 getRenderer()->RemoveActor(NodeText_Follower
[i
]);
1160 NodeText_Follower
[i
]->Delete();
1161 NodeText_PolyDataMapper
[i
]->Delete();
1162 NodeText_VectorText
[i
]->Delete();
1164 NodeText_Follower
.clear();
1165 NodeText_PolyDataMapper
.clear();
1166 NodeText_VectorText
.clear();
1169 getRenderWindow()->Render();
1172 void GuiMainWindow::ViewCellIDs()
1174 int N
=grid
->GetNumberOfCells();
1175 cout
<<"N="<<N
<<endl
;
1176 if (ui
.actionViewCellIDs
->isChecked()) {
1177 cout
<<"Activating cell ID view"<<endl
;
1178 CellText_VectorText
.resize(N
);
1179 CellText_PolyDataMapper
.resize(N
);
1180 CellText_Follower
.resize(N
);
1181 for(int i
=0;i
<N
;i
++){
1182 CellText_VectorText
[i
]=vtkVectorText::New();
1185 CellText_VectorText
[i
]->SetText(tmp
.toLatin1().data());
1186 CellText_PolyDataMapper
[i
]=vtkPolyDataMapper::New();
1187 CellText_PolyDataMapper
[i
]->SetInputConnection(CellText_VectorText
[i
]->GetOutputPort());
1188 CellText_Follower
[i
]=vtkFollower::New();
1189 CellText_Follower
[i
]->SetMapper(CellText_PolyDataMapper
[i
]);
1190 CellText_Follower
[i
]->SetScale(ReferenceSize
,ReferenceSize
,ReferenceSize
);
1191 vtkIdType N_pts
,*pts
;
1192 grid
->GetCellPoints(i
,N_pts
,pts
);
1193 vec3_t
Center(0,0,0);
1194 for(int p
=0;p
<N_pts
;p
++)
1197 grid
->GetPoint(pts
[p
],M
.data());
1200 vec3_t OffSet
=ReferenceSize
*triNormal(grid
,pts
[0],pts
[1],pts
[2]).normalise();
1201 Center
=1.0/(double)N_pts
*Center
+OffSet
;
1202 CellText_Follower
[i
]->AddPosition(Center
[0],Center
[1],Center
[2]);
1203 CellText_Follower
[i
]->SetCamera(getRenderer()->GetActiveCamera());
1204 CellText_Follower
[i
]->GetProperty()->SetColor(1,0,0);
1205 getRenderer()->AddActor(CellText_Follower
[i
]);
1209 cout
<<"Deactivating cell ID view"<<endl
;
1210 for(unsigned int i
=0;i
<CellText_Follower
.size();i
++){
1211 getRenderer()->RemoveActor(CellText_Follower
[i
]);
1212 CellText_Follower
[i
]->Delete();
1213 CellText_PolyDataMapper
[i
]->Delete();
1214 CellText_VectorText
[i
]->Delete();
1216 CellText_Follower
.clear();
1217 CellText_PolyDataMapper
.clear();
1218 CellText_VectorText
.clear();
1221 getRenderWindow()->Render();
1224 void GuiMainWindow::addVtkTypeInfo()
1226 EG_VTKSP(vtkIntArray
, vtk_type
);
1227 vtk_type
->SetName("vtk_type");
1228 vtk_type
->SetNumberOfValues(grid
->GetNumberOfCells());
1229 for (vtkIdType cellId
= 0; cellId
< grid
->GetNumberOfCells(); ++cellId
) {
1230 vtk_type
->SetValue(cellId
, grid
->GetCellType(cellId
));
1232 grid
->GetCellData()->AddArray(vtk_type
);
1235 void GuiMainWindow::pickCellCallBack
1238 unsigned long int eid
,
1245 clientdata
= clientdata
;
1246 calldata
= calldata
;
1247 THIS
->updateActors();
1248 THIS
->updateStatusBar();
1251 void GuiMainWindow::pickPointCallBack
1254 unsigned long int eid
,
1261 clientdata
= clientdata
;
1262 calldata
= calldata
;
1263 THIS
->updateActors();
1264 THIS
->updateStatusBar();
1267 vtkIdType
GuiMainWindow::getPickedCell()
1269 vtkIdType picked_cell
= -1;
1270 if (THIS
->grid
->GetNumberOfCells() > 0) {
1271 THIS
->bcodes_filter
->Update();
1272 EG_VTKDCC(vtkLongArray_t
, cell_index
, THIS
->bcodes_filter
->GetOutput(), "cell_index");
1275 if(m_UseVTKInteractor
) cellId
= THIS
->CellPicker
->GetCellId();
1276 else cellId
= PickedCell
;
1279 if (cellId
< THIS
->bcodes_filter
->GetOutput()->GetNumberOfCells()) {
1280 picked_cell
= cell_index
->GetValue(cellId
);
1287 vtkIdType
GuiMainWindow::getPickedPoint()
1289 vtkIdType picked_point
= -1;
1290 if (THIS
->grid
->GetNumberOfCells() > 0) {
1291 THIS
->bcodes_filter
->Update();
1294 if(m_UseVTKInteractor
) pointId
= THIS
->PointPicker
->GetPointId();
1295 else pointId
= PickedPoint
;
1298 picked_point
= pointId
;
1301 return picked_point
;
1304 void GuiMainWindow::changeSurfaceOrientation()
1306 for (vtkIdType cellId
= 0; cellId
< grid
->GetNumberOfCells(); ++cellId
) {
1307 vtkIdType Npts
, *pts
;
1308 grid
->GetCellPoints(cellId
, Npts
, pts
);
1309 QVector
<vtkIdType
> nodes(Npts
);
1310 for (vtkIdType j
= 0; j
< Npts
; ++j
) nodes
[j
] = pts
[j
];
1311 for (vtkIdType j
= 0; j
< Npts
; ++j
) pts
[Npts
- j
- 1] = nodes
[j
];
1316 void GuiMainWindow::checkSurfaceOrientation()
1318 CorrectSurfaceOrientation corr_surf
;
1319 vtkIdType picked_cell
= getPickedCell();
1320 if (picked_cell
>= 0) {
1321 corr_surf
.setStart(picked_cell
);
1327 void GuiMainWindow::improveAspectRatio()
1329 GuiImproveAspectRatio impr_ar
;
1334 void GuiMainWindow::exportAsciiStl()
1340 void GuiMainWindow::exportBinaryStl()
1344 void GuiMainWindow::periodicUpdate()
1346 Operation::collectGarbage();
1350 void GuiMainWindow::viewXP()
1352 getRenderer()->ResetCamera();
1354 getRenderer()->GetActiveCamera()->GetFocalPoint(x
);
1356 getRenderer()->GetActiveCamera()->SetPosition(x
);
1357 getRenderer()->GetActiveCamera()->ComputeViewPlaneNormal();
1358 getRenderer()->GetActiveCamera()->SetViewUp(0,1,0);
1359 getRenderer()->ResetCamera();
1360 getRenderWindow()->Render();
1363 void GuiMainWindow::viewXM()
1365 getRenderer()->ResetCamera();
1367 getRenderer()->GetActiveCamera()->GetFocalPoint(x
);
1369 getRenderer()->GetActiveCamera()->SetPosition(x
);
1370 getRenderer()->GetActiveCamera()->ComputeViewPlaneNormal();
1371 getRenderer()->GetActiveCamera()->SetViewUp(0,1,0);
1372 getRenderer()->ResetCamera();
1373 getRenderWindow()->Render();
1376 void GuiMainWindow::viewYP()
1378 getRenderer()->ResetCamera();
1380 getRenderer()->GetActiveCamera()->GetFocalPoint(x
);
1382 getRenderer()->GetActiveCamera()->SetPosition(x
);
1383 getRenderer()->GetActiveCamera()->ComputeViewPlaneNormal();
1384 getRenderer()->GetActiveCamera()->SetViewUp(0,0,-1);
1385 getRenderer()->ResetCamera();
1386 getRenderWindow()->Render();
1389 void GuiMainWindow::viewYM()
1391 getRenderer()->ResetCamera();
1393 getRenderer()->GetActiveCamera()->GetFocalPoint(x
);
1395 getRenderer()->GetActiveCamera()->SetPosition(x
);
1396 getRenderer()->GetActiveCamera()->ComputeViewPlaneNormal();
1397 getRenderer()->GetActiveCamera()->SetViewUp(0,0,-1);
1398 getRenderer()->ResetCamera();
1399 getRenderWindow()->Render();
1402 void GuiMainWindow::viewZP()
1404 getRenderer()->ResetCamera();
1406 getRenderer()->GetActiveCamera()->GetFocalPoint(x
);
1408 getRenderer()->GetActiveCamera()->SetPosition(x
);
1409 getRenderer()->GetActiveCamera()->ComputeViewPlaneNormal();
1410 getRenderer()->GetActiveCamera()->SetViewUp(0,1,0);
1411 getRenderer()->ResetCamera();
1412 getRenderWindow()->Render();
1415 void GuiMainWindow::viewZM()
1417 getRenderer()->ResetCamera();
1419 getRenderer()->GetActiveCamera()->GetFocalPoint(x
);
1421 getRenderer()->GetActiveCamera()->SetPosition(x
);
1422 getRenderer()->GetActiveCamera()->ComputeViewPlaneNormal();
1423 getRenderer()->GetActiveCamera()->SetViewUp(0,1,0);
1424 getRenderer()->ResetCamera();
1425 getRenderWindow()->Render();
1428 void GuiMainWindow::callFixSTL()
1434 updateBoundaryCodes(false);
1438 void GuiMainWindow::editBoundaryConditions()
1440 GuiEditBoundaryConditions editbcs
;
1441 editbcs
.setBoundaryCodes(all_boundary_codes
);
1442 editbcs
.setMap(&bcmap
);
1446 void GuiMainWindow::configure()
1449 // Just to create initial entries in the settings file
1450 // so that the options menu isn't empty at first start.
1452 GuiCreateBoundaryLayer tmp02
;
1454 GuiSettingsViewer
settings(&qset
);
1458 void GuiMainWindow::about()
1460 QMessageBox
box(this);
1462 QString title
="ENGRID";
1463 QString version
= QString("version ") + ENGRID_VERSION
;
1464 if (version
== "version CVS") {
1465 version
+= " build on ";
1466 version
+= QString(__DATE__
);
1468 version
+= QString(__TIME__
);
1470 QString address
= tr("ENGRID is being developed and maintained by:<br/>"
1472 "Marie-Curie-Strasse 8<br/>"
1473 "79539 Loerrach<br/>"
1476 QString mainurl
="<a href=\"http://www.engits.com\">www.engits.com</a>";
1477 QString mail
="<a href=\"mailto:info@engits.com\">info@engits.com</a>";
1478 QString gnuurl
="<a href=\"http://www.gnu.org/licenses\">http://www.gnu.org/licenses</a>";
1479 QString license
=tr("ENGRID is licenced under the GPL version 3.<br/>"
1480 "(see ")+gnuurl
+tr(" for details)<br/>");
1481 QString bugurl
="<a href=\"http://sourceforge.net/tracker2/?func=add&group_id=245110&atid=1126548\">the bugtracker available on Sourceforge</a>";
1482 QString bugreporting
=tr("To submit a bug report, please use ")+bugurl
;
1483 box
.setText(QString::fromLatin1("<center><img src=\":/icons/resources/icons/G.png\">"
1487 "<p>Homepage: %4</p>"
1490 "<p>%7</p></center>")
1491 .arg(title
).arg(version
).arg(address
).arg(mainurl
).arg(mail
).arg(license
).arg(bugreporting
));
1492 box
.setWindowTitle(tr("about ENGRID"));
1493 box
.setIcon(QMessageBox::NoIcon
);
1498 void GuiMainWindow::getAllBoundaryCodes(QSet
<int> &bcs
)
1501 foreach (int bc
, all_boundary_codes
) {