From 0b2086df2c3851063bef068539d80ae840f131c4 Mon Sep 17 00:00:00 2001 From: Oliver Gloth Date: Fri, 20 Feb 2015 16:47:49 +0100 Subject: [PATCH] improved pass-band editing --- src/libengrid/boundarylayeroperation.cpp | 57 ++++++++++++++++---------------- src/libengrid/guicreatesurfacemesh.cpp | 15 ++++++++- src/libengrid/guicreatesurfacemesh.h | 2 ++ src/libengrid/guicreatesurfacemesh.ui | 23 +++++++++++-- 4 files changed, 66 insertions(+), 31 deletions(-) diff --git a/src/libengrid/boundarylayeroperation.cpp b/src/libengrid/boundarylayeroperation.cpp index f8a50dc3..f9806180 100644 --- a/src/libengrid/boundarylayeroperation.cpp +++ b/src/libengrid/boundarylayeroperation.cpp @@ -81,7 +81,7 @@ void BoundaryLayerOperation::readSettings() in >> m_NumBoundaryLayerVectorRelaxations; in >> m_NumBoundaryLayerHeightRelaxations; in >> m_ShellPassBand; - m_ShellPassBand = 2*pow(10.0, 3*m_ShellPassBand - 3); + m_ShellPassBand = 2*pow(10.0, -3*m_ShellPassBand); in >> m_FaceSizeLowerLimit; in >> m_FaceSizeUpperLimit; in >> m_FaceAngleLimit; @@ -606,31 +606,6 @@ void BoundaryLayerOperation::computeHeights() // limit face size and angle difference //limitSizeAndAngleErrors(); - // smoothing - { - QVector h_safe = m_Height; - for (int iter = 0; iter < m_NumBoundaryLayerHeightRelaxations; ++iter) { - QVector h_new = m_Height; - for (vtkIdType id_node = 0; id_node < m_Grid->GetNumberOfPoints(); ++id_node) { - if (m_BoundaryLayerNode[id_node]) { - int count = 0; - h_new[id_node] = 0; - for (int i = 0; i < m_Part.n2nGSize(id_node); ++i) { - vtkIdType id_neigh = m_Part.n2nGG(id_node, i); - if (m_BoundaryLayerNode[id_neigh]) { - ++count; - h_new[id_node] += min(h_safe[id_node], m_Height[id_neigh]); - } - } - if (count == 0) { - EG_BUG; - } - h_new[id_node] /= count; - } - } - m_Height = h_new; - } - } // The mesh smoothing methods start here // General variables kind of useful for push out, smoothing, etc @@ -666,6 +641,32 @@ void BoundaryLayerOperation::computeHeights() //angleSmoother(on_boundary, is_convex, grid_pnts); smoothUsingBLVectors(); + // laplacian smoothing + { + QVector h_safe = m_Height; + for (int iter = 0; iter < m_NumBoundaryLayerHeightRelaxations; ++iter) { + QVector h_new = m_Height; + for (vtkIdType id_node = 0; id_node < m_Grid->GetNumberOfPoints(); ++id_node) { + if (m_BoundaryLayerNode[id_node]) { + int count = 0; + h_new[id_node] = 0; + for (int i = 0; i < m_Part.n2nGSize(id_node); ++i) { + vtkIdType id_neigh = m_Part.n2nGG(id_node, i); + if (m_BoundaryLayerNode[id_neigh]) { + ++count; + h_new[id_node] += min(h_safe[id_node], m_Height[id_neigh]); + } + } + if (count == 0) { + EG_BUG; + } + h_new[id_node] /= count; + } + } + m_Height = h_new; + } + } + //limitHeights(1.0); cout << "heights computed" << endl; @@ -703,7 +704,7 @@ void BoundaryLayerOperation::createSmoothShell(vtkUnstructuredGrid *shell_grid, //EG_VTKSP(vtkSmoothPolyDataFilter, smooth); EG_VTKSP(vtkWindowedSincPolyDataFilter, smooth); smooth->SetInputConnection(subdiv->GetOutputPort()); - smooth->BoundarySmoothingOff(); + smooth->BoundarySmoothingOn(); smooth->FeatureEdgeSmoothingOn(); smooth->SetFeatureAngle(180); smooth->SetEdgeAngle(180); @@ -923,7 +924,7 @@ void BoundaryLayerOperation::smoothUsingBLVectors() createSmoothShell(shell_grid, m_ShellPassBand); newHeightFromShellIntersect(shell_grid, 1.0); - //writeGrid(shell_grid, "shell"); + writeGrid(shell_grid, "shell"); EG_VTKDCC(vtkIntArray, cell_code, m_Grid, "cell_code"); //writeWallGrid("walls", 0); diff --git a/src/libengrid/guicreatesurfacemesh.cpp b/src/libengrid/guicreatesurfacemesh.cpp index 757f04d8..2444c347 100644 --- a/src/libengrid/guicreatesurfacemesh.cpp +++ b/src/libengrid/guicreatesurfacemesh.cpp @@ -117,6 +117,17 @@ GuiCreateSurfaceMesh::GuiCreateSurfaceMesh() connect(m_Ui.m_PushButtonCalc2, SIGNAL(clicked()), this, SLOT(calc2())); connect(m_Ui.m_PushButtonCalc3, SIGNAL(clicked()), this, SLOT(calc3())); + connect(m_Ui.m_PassBandSlider, SIGNAL(valueChanged(int)), this, SLOT(displayPb(int))); + +} + + +void GuiCreateSurfaceMesh::displayPb(int v) +{ + double dv = 1e-3*v; + QString num; + num.setNum(2*pow(10.0, -3*dv)); + m_Ui.m_LabelPassBand->setText(num); } /////////////////////////////////////////// @@ -183,7 +194,9 @@ int GuiCreateSurfaceMesh::readSettings() in >> iv; m_Ui.m_SpinBoxNormalRelaxationIterations->setValue(iv); in >> iv; m_Ui.m_SpinBoxHeightRelaxationIterations->setValue(iv); - in >> dv; num.setNum(dv); m_Ui.m_PassBandSlider->setValue(int(1000*dv)); + in >> dv; m_Ui.m_PassBandSlider->setValue(int(1000*dv)); + num.setNum(2*pow(10.0, -3*dv)); + m_Ui.m_LabelPassBand->setText(num); in >> dv; m_Ui.m_DoubleSpinBoxBoundaryLayerLowerFaceLimit->setValue(dv); in >> dv; m_Ui.m_DoubleSpinBoxBoundaryLayerUpperFaceLimit->setValue(dv); diff --git a/src/libengrid/guicreatesurfacemesh.h b/src/libengrid/guicreatesurfacemesh.h index d3e6bed0..d4cb04c8 100644 --- a/src/libengrid/guicreatesurfacemesh.h +++ b/src/libengrid/guicreatesurfacemesh.h @@ -76,6 +76,8 @@ public slots: void calc2(); void calc3(); + void displayPb(int v); + }; #endif diff --git a/src/libengrid/guicreatesurfacemesh.ui b/src/libengrid/guicreatesurfacemesh.ui index 0c7078c5..7d279709 100644 --- a/src/libengrid/guicreatesurfacemesh.ui +++ b/src/libengrid/guicreatesurfacemesh.ui @@ -24,7 +24,7 @@ true - 3 + 0 @@ -754,7 +754,7 @@ - + 1000 @@ -767,6 +767,25 @@ + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + TextLabel + + + -- 2.11.4.GIT