-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include CORBA_SERVER_HEADER(NETGENPlugin_Algorithm)
-#include <SUIT_Session.h>
+#include <SUIT_FileDlg.h>
#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
#include <SalomeApp_Tools.h>
#include <LightApp_SelectionMgr.h>
-#include <SALOME_ListIteratorOfListIO.hxx>
+#include <SALOME_ListIO.hxx>
#include <QComboBox>
#include <QLabel>
LSZ_VERTEX_BTN,
LSZ_EDGE_BTN,
LSZ_FACE_BTN,
+ LSZ_SOLID_BTN,
LSZ_SEPARATOR2,
- LSZ_REMOVE_BTN
+ LSZ_REMOVE_BTN,
+ LSZ_FILE_LE = 9
};
NETGENPluginGUI_HypothesisCreator::NETGENPluginGUI_HypothesisCreator( const QString& theHypType )
{
myGeomSelectionTools = NULL;
myLocalSizeMap.clear();
- myIs2D = ( theHypType.startsWith("NETGEN_Parameters_2D"));
+ myIs2D = ( theHypType.startsWith("NETGEN_Parameters_2D"));
myIsONLY = ( theHypType == "NETGEN_Parameters_2D_ONLY" ||
theHypType == "NETGEN_Parameters_3D");
}
if ( !myIsONLY )
{
mySecondOrder = new QCheckBox( tr( "NETGEN_SECOND_ORDER" ), GroupC1 );
- aGroupLayout->addWidget( mySecondOrder, row, 0 );
+ aGroupLayout->addWidget( mySecondOrder, row, 0, 1, 2 );
row++;
}
tr( "NETGEN_FINE" ) << tr( "NETGEN_VERYFINE" ) << tr( "NETGEN_CUSTOM" );
myFineness->addItems( types );
aGroupLayout->addWidget( myFineness, row, 1 );
+ connect( myFineness, SIGNAL( activated( int ) ), this, SLOT( onFinenessChanged() ) );
row++;
aGroupLayout->addWidget( new QLabel( tr( "NETGEN_GROWTH_RATE" ), GroupC1 ), row, 0 );
aGroupLayout->addWidget( myNbSegPerRadius, row, 1 );
row++;
}
+
+ mySurfaceCurvature = 0;
+ if ( myIs2D || !myIsONLY )
+ {
+ mySurfaceCurvature = new QCheckBox( tr( "NETGEN_SURFACE_CURVATURE" ), GroupC1 );
+ aGroupLayout->addWidget( mySurfaceCurvature, row, 0, 1, 2 );
+ connect( mySurfaceCurvature, SIGNAL( stateChanged( int ) ), this, SLOT( onSurfaceCurvatureChanged() ) );
+ row++;
+ }
+
myAllowQuadrangles = 0;
- if ( myIs2D || !myIsONLY ) // issue 0021676
+ if ( myIs2D || !myIsONLY ) // disable only for NETGEN 3D
{
myAllowQuadrangles = new QCheckBox( tr( "NETGEN_ALLOW_QUADRANGLES" ), GroupC1 );
- aGroupLayout->addWidget( myAllowQuadrangles, row, 0 );
+ aGroupLayout->addWidget( myAllowQuadrangles, row, 0, 1, 2 );
row++;
}
myOptimize = new QCheckBox( tr( "NETGEN_OPTIMIZE" ), GroupC1 );
- aGroupLayout->addWidget( myOptimize, row, 0 );
+ aGroupLayout->addWidget( myOptimize, row, 0, 1, 2 );
row++;
- connect( myFineness, SIGNAL( activated( int ) ), this, SLOT( onFinenessChanged() ) );
+ myFuseEdges = 0;
+ if (!myIsONLY)
+ {
+ myFuseEdges = new QCheckBox( tr( "NETGEN_FUSE_EDGES" ), GroupC1 );
+ aGroupLayout->addWidget( myFuseEdges, row, 0, 1, 2 );
+ row++;
+ }
myLocalSizeTable = 0;
- if ( !myIsONLY )
+ //if ( !myIsONLY )
{
QWidget* localSizeGroup = new QWidget();
QGridLayout* localSizeLayout = new QGridLayout(localSizeGroup);
myLocalSizeTable = new QTableWidget(0, LSZ_NB_COLUMNS, localSizeGroup);
- localSizeLayout->addWidget(myLocalSizeTable, 1, 0, 8, 1);
+ localSizeLayout->addWidget(myLocalSizeTable, 1, 0, 8, 2);
QStringList localSizeHeaders;
localSizeHeaders << tr( "LSZ_ENTRY_COLUMN" )<< tr( "LSZ_NAME_COLUMN" ) << tr( "LSZ_LOCALSIZE_COLUMN" );
myLocalSizeTable->setHorizontalHeaderLabels(localSizeHeaders);
myLocalSizeTable->horizontalHeader()->hideSection(LSZ_ENTRY_COLUMN);
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
myLocalSizeTable->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
+#else
+ myLocalSizeTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
+#endif
myLocalSizeTable->resizeColumnToContents(LSZ_NAME_COLUMN);
myLocalSizeTable->resizeColumnToContents(LSZ_LOCALSIZE_COLUMN);
myLocalSizeTable->setAlternatingRowColors(true);
myLocalSizeTable->verticalHeader()->hide();
QPushButton* addVertexButton = new QPushButton(tr("NETGEN_LSZ_VERTEX"), localSizeGroup);
- localSizeLayout->addWidget(addVertexButton, LSZ_VERTEX_BTN, 1, 1, 1);
+ localSizeLayout->addWidget(addVertexButton, LSZ_VERTEX_BTN, 2, 1, 1);
QPushButton* addEdgeButton = new QPushButton(tr("NETGEN_LSZ_EDGE"), localSizeGroup);
- localSizeLayout->addWidget(addEdgeButton, LSZ_EDGE_BTN, 1, 1, 1);
+ localSizeLayout->addWidget(addEdgeButton, LSZ_EDGE_BTN, 2, 1, 1);
QPushButton* addFaceButton = new QPushButton(tr("NETGEN_LSZ_FACE"), localSizeGroup);
- localSizeLayout->addWidget(addFaceButton, LSZ_FACE_BTN, 1, 1, 1);
+ localSizeLayout->addWidget(addFaceButton, LSZ_FACE_BTN, 2, 1, 1);
+ QPushButton* addSolidButton = new QPushButton(tr("NETGEN_LSZ_SOLID"), localSizeGroup);
+ localSizeLayout->addWidget(addSolidButton, LSZ_SOLID_BTN, 2, 1, 1);
QFrame *line2 = new QFrame(localSizeGroup);
line2->setFrameShape(QFrame::HLine);
line2->setFrameShadow(QFrame::Sunken);
- localSizeLayout->addWidget(line2, LSZ_SEPARATOR2, 1, 1, 1);
+ localSizeLayout->addWidget(line2, LSZ_SEPARATOR2, 2, 1, 1);
QPushButton* removeButton = new QPushButton(tr("NETGEN_LSZ_REMOVE"), localSizeGroup);
- localSizeLayout->addWidget(removeButton, LSZ_REMOVE_BTN, 1, 1, 1);
+ localSizeLayout->addWidget(removeButton, LSZ_REMOVE_BTN, 2, 1, 1);
+
+ QPushButton* fileBtn = new QPushButton(tr("NETGEN_LSZ_FILE"), localSizeGroup);
+ myMeshSizeFile = new QLineEdit(localSizeGroup);
+ myMeshSizeFile->setReadOnly( true );
+ localSizeLayout->addWidget( fileBtn, LSZ_FILE_LE, 0, 1, 1);
+ localSizeLayout->addWidget( myMeshSizeFile, LSZ_FILE_LE, 1, 1, 2);
connect( addVertexButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnVertex()));
connect( addEdgeButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnEdge()));
connect( addFaceButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnFace()));
+ connect( addSolidButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnSolid()));
connect( removeButton, SIGNAL(clicked()), this, SLOT(onRemoveLocalSizeOnShape()));
connect( myLocalSizeTable, SIGNAL(cellChanged(int, int)), this, SLOT(onSetLocalSize(int, int)));
+ connect( fileBtn, SIGNAL(clicked()), this, SLOT(onSetSizeFile()));
tab->insertTab(LSZ_TAB, localSizeGroup, tr("NETGEN_LOCAL_SIZE"));
}
myNbSegPerRadius->setValue( data.myNbSegPerRadius );
else
myNbSegPerRadius->setText( data.myNbSegPerRadiusVar );
- }
+ }
if (myAllowQuadrangles)
myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
+ if (mySurfaceCurvature)
+ mySurfaceCurvature->setChecked( data.mySurfaceCurvature );
+
+ if (myFuseEdges)
+ myFuseEdges->setChecked( data.myFuseEdges );
+
// update widgets
- bool isCustom = (myFineness->currentIndex() == UserDefined);
- myGrowthRate->setEnabled(isCustom);
- if ( myNbSegPerEdge )
- myNbSegPerEdge->setEnabled(isCustom);
- if ( myNbSegPerRadius )
- myNbSegPerRadius->setEnabled(isCustom);
+ ((NETGENPluginGUI_HypothesisCreator*) this )-> onSurfaceCurvatureChanged();
if ( myLocalSizeTable )
{
}
myLocalSizeTable->resizeColumnToContents(LSZ_NAME_COLUMN);
myLocalSizeTable->resizeColumnToContents(LSZ_LOCALSIZE_COLUMN);
+
+ myMeshSizeFile->setText( data.myMeshSizeFile );
}
}
NetgenHypothesisData data;
readParamsFromWidgets( data );
storeParamsToHypo( data );
-
+
QString valStr = tr("NETGEN_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; ";
valStr += tr("NETGEN_MIN_SIZE") + " = " + QString::number( data.myMinSize ) + "; ";
if ( data.mySecondOrder )
if ( data.myOptimize )
valStr += tr("NETGEN_OPTIMIZE") + "; ";
valStr += myFineness->currentText() + "(" + QString::number( data.myGrowthRate ) + ", " +
- QString::number( data.myNbSegPerEdge ) + ", " +
- QString::number( data.myNbSegPerRadius ) + ")";
+ QString::number( data.myNbSegPerEdge ) + ", " +
+ QString::number( data.myNbSegPerRadius ) + ")";
if ( myIs2D && data.myAllowQuadrangles )
valStr += "; " + tr("NETGEN_ALLOW_QUADRANGLES");
-
+
+ if ( data.mySurfaceCurvature )
+ valStr += "; " + tr("NETGEN_SURFACE_CURVATURE");
+
+ if ( data.myFuseEdges )
+ valStr += "; " + tr("NETGEN_FUSE_EDGES");
+
return valStr;
}
NETGENPlugin::NETGENPlugin_Hypothesis_var h =
NETGENPlugin::NETGENPlugin_Hypothesis::_narrow( initParamsHypothesis() );
- HypothesisData* data = SMESH::GetHypothesisData( hypType() );
- h_data.myName = isCreation() && data ? data->Label : "";
+ //HypothesisData* data = SMESH::GetHypothesisData( hypType() );
+ h_data.myName = isCreation() ? hypName() : "";
h_data.myMaxSize = h->GetMaxSize();
h_data.myMaxSizeVar = getVariableName("SetMaxSize");
h_data.myNbSegPerRadiusVar = getVariableName("SetNbSegPerRadius");
h_data.myMinSize = h->GetMinSize();
h_data.myMinSizeVar = getVariableName("SetMinSize");
+ h_data.mySurfaceCurvature = h->GetUseSurfaceCurvature();
+ h_data.myFuseEdges = h->GetFuseEdges();
+ h_data.myMeshSizeFile = h->GetMeshSizeFile();
//if ( myIs2D )
- {
- NETGENPlugin::NETGENPlugin_Hypothesis_var h =
- NETGENPlugin::NETGENPlugin_Hypothesis::_narrow( initParamsHypothesis() );
+ {
+ NETGENPlugin::NETGENPlugin_Hypothesis_var h =
+ NETGENPlugin::NETGENPlugin_Hypothesis::_narrow( initParamsHypothesis() );
- if ( !h->_is_nil() )
- h_data.myAllowQuadrangles = h->GetQuadAllowed();
- }
-
- NETGENPluginGUI_HypothesisCreator* that = (NETGENPluginGUI_HypothesisCreator*)this;
+ if ( !h->_is_nil() )
+ h_data.myAllowQuadrangles = h->GetQuadAllowed();
+ }
+
+ NETGENPluginGUI_HypothesisCreator* that = (NETGENPluginGUI_HypothesisCreator*)this;
NETGENPlugin::string_array_var myEntries = h->GetLocalSizeEntries();
- for ( int i=0 ; i<myEntries->length() ; i++ )
+ for ( size_t i = 0; i < myEntries->length(); i++ )
+ {
+ QString entry = myEntries[i].in();
+ double val = h->GetLocalSizeOnEntry(entry.toStdString().c_str());
+ std::ostringstream tmp;
+ tmp << val;
+ QString valstring = QString::fromStdString(tmp.str());
+ if (myLocalSizeMap.contains(entry))
{
- QString entry = myEntries[i].in();
- double val = h->GetLocalSizeOnEntry(entry.toStdString().c_str());
- std::ostringstream tmp;
- tmp << val;
- QString valstring = QString::fromStdString(tmp.str());
- if (myLocalSizeMap.contains(entry))
- {
- if (myLocalSizeMap[entry] == "__TO_DELETE__")
- {
- continue;
- }
- }
- that->myLocalSizeMap[entry] = valstring;
+ if (myLocalSizeMap[entry] == "__TO_DELETE__")
+ {
+ continue;
+ }
}
+ that->myLocalSizeMap[entry] = valstring;
+ }
return true;
}
if( isCreation() )
SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().data() );
h->SetVarParameter( h_data.myMaxSizeVar.toLatin1().constData(), "SetMaxSize");
- h->SetMaxSize( h_data.myMaxSize );
- h->SetSecondOrder( h_data.mySecondOrder );
- h->SetOptimize( h_data.myOptimize );
+ h->SetMaxSize ( h_data.myMaxSize );
+ h->SetSecondOrder ( h_data.mySecondOrder );
+ h->SetOptimize ( h_data.myOptimize );
int fineness = h_data.myFineness;
- h->SetFineness( fineness );
+ h->SetFineness ( fineness );
if( fineness==UserDefined )
- {
- h->SetVarParameter( h_data.myGrowthRateVar.toLatin1().constData(), "SetGrowthRate");
- h->SetGrowthRate( h_data.myGrowthRate );
- h->SetVarParameter( h_data.myNbSegPerEdgeVar.toLatin1().constData(), "SetNbSegPerEdge");
- h->SetNbSegPerEdge( h_data.myNbSegPerEdge );
- h->SetVarParameter( h_data.myNbSegPerRadiusVar.toLatin1().constData(), "SetNbSegPerRadius");
- h->SetNbSegPerRadius( h_data.myNbSegPerRadius );
- }
- h->SetVarParameter( h_data.myMinSizeVar.toLatin1().constData(), "SetMinSize");
- h->SetMinSize( h_data.myMinSize );
-
- if ( myIs2D )
- {
- NETGENPlugin::NETGENPlugin_Hypothesis_2D_var h_2d =
- NETGENPlugin::NETGENPlugin_Hypothesis_2D::_narrow( h );
-
- if ( !h_2d->_is_nil() )
- h_2d->SetQuadAllowed( h_data.myAllowQuadrangles );
- }
+ {
+ h->SetVarParameter ( h_data.myGrowthRateVar.toLatin1().constData(), "SetGrowthRate");
+ h->SetGrowthRate ( h_data.myGrowthRate );
+ h->SetVarParameter ( h_data.myNbSegPerEdgeVar.toLatin1().constData(), "SetNbSegPerEdge");
+ h->SetNbSegPerEdge ( h_data.myNbSegPerEdge );
+ h->SetVarParameter ( h_data.myNbSegPerRadiusVar.toLatin1().constData(), "SetNbSegPerRadius");
+ h->SetNbSegPerRadius( h_data.myNbSegPerRadius );
+ }
+ h->SetVarParameter ( h_data.myMinSizeVar.toLatin1().constData(), "SetMinSize");
+ h->SetMinSize ( h_data.myMinSize );
+ h->SetUseSurfaceCurvature( h_data.mySurfaceCurvature );
+ h->SetFuseEdges ( h_data.myFuseEdges );
+ h->SetMeshSizeFile ( h_data.myMeshSizeFile.toUtf8().constData() );
+
+ //if ( myIs2D )
+ {
+ // NETGENPlugin::NETGENPlugin_Hypothesis_2D_var h_2d =
+ // NETGENPlugin::NETGENPlugin_Hypothesis_2D::_narrow( h );
+
+ // if ( !h_2d->_is_nil() )
+ // h_2d->SetQuadAllowed( h_data.myAllowQuadrangles );
+ h->SetQuadAllowed( h_data.myAllowQuadrangles );
+ }
QMapIterator<QString,QString> i(myLocalSizeMap);
while (i.hasNext()) {
const QString entry = i.key();
const QString localSize = i.value();
if (localSize == "__TO_DELETE__")
- {
- h->UnsetLocalSizeOnEntry(entry.toLatin1().constData());
- }
+ {
+ h->UnsetLocalSizeOnEntry(entry.toLatin1().constData());
+ }
else
- {
- std::istringstream tmp(localSize.toLatin1().constData());
- double val;
- tmp >> val;
- h->SetLocalSizeOnEntry(entry.toLatin1().constData(), val);
- }
+ {
+ std::istringstream tmp(localSize.toLatin1().constData());
+ double val;
+ tmp >> val;
+ h->SetLocalSizeOnEntry(entry.toLatin1().constData(), val);
+ }
}
}
catch(const SALOME::SALOME_Exception& ex)
if ( myAllowQuadrangles )
h_data.myAllowQuadrangles = myAllowQuadrangles->isChecked();
+ if ( mySurfaceCurvature )
+ h_data.mySurfaceCurvature = mySurfaceCurvature->isChecked();
+
+ if ( myFuseEdges )
+ h_data.myFuseEdges = myFuseEdges->isChecked();
+
if ( myLocalSizeTable )
{
NETGENPluginGUI_HypothesisCreator* that = (NETGENPluginGUI_HypothesisCreator*)this;
QString localSize = myLocalSizeTable->item(row, LSZ_LOCALSIZE_COLUMN)->text().trimmed();
that->myLocalSizeMap[entry] = localSize;
}
+ h_data.myMeshSizeFile = myMeshSizeFile->text();
}
return true;
}
+void NETGENPluginGUI_HypothesisCreator::onSurfaceCurvatureChanged()
+{
+ bool isSurfaceCurvature = (mySurfaceCurvature ? mySurfaceCurvature->isChecked() : true);
+ bool isCustom = (myFineness->currentIndex() == UserDefined);
+ //myFineness->setEnabled(isSurfaceCurvature);
+ myGrowthRate->setEnabled(isCustom);
+ if ( myNbSegPerEdge )
+ myNbSegPerEdge->setEnabled(isCustom && isSurfaceCurvature);
+ if ( myNbSegPerRadius )
+ myNbSegPerRadius->setEnabled(isCustom && isSurfaceCurvature);
+}
+
void NETGENPluginGUI_HypothesisCreator::onFinenessChanged()
{
bool isCustom = (myFineness->currentIndex() == UserDefined);
addLocalSizeOnShape(TopAbs_FACE);
}
+void NETGENPluginGUI_HypothesisCreator::onAddLocalSizeOnSolid()
+{
+ addLocalSizeOnShape(TopAbs_SOLID);
+}
+
void NETGENPluginGUI_HypothesisCreator::addLocalSizeOnShape(TopAbs_ShapeEnum typeShapeAsked)
{
NETGENPlugin::NETGENPlugin_Hypothesis_var h = NETGENPlugin::NETGENPlugin_Hypothesis::_narrow(initParamsHypothesis());
SALOME_ListIO ListSelectedObjects;
mySel->selectedObjects(ListSelectedObjects, NULL, false );
SALOME_ListIteratorOfListIO Object_It(ListSelectedObjects);
- for (Object_It ; Object_It.More() ; Object_It.Next())
+ for ( ; Object_It.More() ; Object_It.Next())
{
Handle(SALOME_InteractiveObject) anObject = Object_It.Value();
std::string entry, shapeName;
}
}
+void NETGENPluginGUI_HypothesisCreator::onSetSizeFile()
+{
+ QString dir = SUIT_FileDlg::getFileName( dlg(), QString(),
+ QStringList() << tr( "ALL_FILES_FILTER" ) + " (*)");
+ myMeshSizeFile->setText( dir );
+}
+
GeomSelectionTools* NETGENPluginGUI_HypothesisCreator::getGeomSelectionTools()
{
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();