+//=================================================================================
+// function : ClickOnApply()
+// purpose : Called when user presses <Apply> button
+//=================================================================================
+bool SMESHGUI_SmoothingDlg::ClickOnApply()
+{
+ if (mySMESHGUI->isActiveStudyLocked())
+ return false;
+
+ if (!isValid())
+ return false;
+
+ if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
+ QStringList aListElementsId = LineEditElements->text().split(" ", QString::SkipEmptyParts);
+ QStringList aListNodesId = LineEditNodes->text().split(" ", QString::SkipEmptyParts);
+
+ SMESH::long_array_var anElementsId = new SMESH::long_array;
+ SMESH::long_array_var aNodesId = new SMESH::long_array;
+
+ anElementsId->length(aListElementsId.count());
+ for (int i = 0; i < aListElementsId.count(); i++)
+ anElementsId[i] = aListElementsId[i].toInt();
+
+ if ( myNbOkNodes && aListNodesId.count() > 0 ) {
+ aNodesId->length(aListNodesId.count());
+ for (int i = 0; i < aListNodesId.count(); i++)
+ aNodesId[i] = aListNodesId[i].toInt();
+ } else {
+ aNodesId->length(0);
+ }
+
+ long anIterationLimit = (long)SpinBox_IterationLimit->value();
+ double aMaxAspectRatio = SpinBox_AspectRatio->GetValue();
+
+ QStringList aParameters;
+ aParameters << SpinBox_IterationLimit->text();
+ aParameters << SpinBox_AspectRatio->text();
+
+ SMESH::SMESH_MeshEditor::Smooth_Method aMethod = SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH;
+ if (ComboBoxMethod->currentIndex() > 0)
+ aMethod = SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH;
+
+ bool aResult = false;
+ try {
+ SUIT_OverrideCursor aWaitCursor;
+ SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
+
+ myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
+
+ if ( CheckBoxParametric->isChecked() ) {
+ if(CheckBoxMesh->isChecked())
+ aResult = aMeshEditor->SmoothParametricObject(mySelectedObject, aNodesId.inout(),
+ anIterationLimit, aMaxAspectRatio, aMethod);
+ else
+ aResult = aMeshEditor->SmoothParametric(anElementsId.inout(), aNodesId.inout(),
+ anIterationLimit, aMaxAspectRatio, aMethod);
+ }
+ else {
+ if(CheckBoxMesh->isChecked())
+ aResult = aMeshEditor->SmoothObject(mySelectedObject, aNodesId.inout(),
+ anIterationLimit, aMaxAspectRatio, aMethod);
+ else
+ aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(),
+ anIterationLimit, aMaxAspectRatio, aMethod);
+ }
+
+ } catch (...) {
+ }
+
+ if (aResult) {
+ SMESH::Update(myIO, SMESH::eDisplay);
+ SMESH::RepaintCurrentView();
+ SMESHGUI::Modified();
+ //Init();
+
+ //mySelectedObject = SMESH::SMESH_IDSource::_nil();
+ }
+ }
+
+ return true;
+}