Add possibility to define Local Size via a file

This commit is contained in:
eap 2016-10-07 17:49:45 +03:00
parent 7d8f8a32b5
commit e1a0d0a23f
16 changed files with 216 additions and 90 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -67,6 +67,25 @@ to the type of the geometrical objects: <b>On Vertex</b>, <b>On
default <b>Value</b> will be added in the table where the <b>Value</b>
can be changed.
- <b>Remove</b> - deletes a selected row from the table.
- <b>Mesh-size File</b> - opens a dialog to select a file defining
size of elements. The file includes two obligatory sections. The first
section defines the size at points. The second section defines the
size along lines. Let's consider the following sample size file.
\code
2
92.5 92.5 92.5 0.05
42.5 42.5 42.5 0.04
1
25 25 0 25 25 200 0.3
\endcode
"2" at the first line means that there are two points in the first
section.<br>
"92.5 92.5 92.5 0.05" at the second line means that at the point with
coordinates (92.5, 92.5, 92.5) size of elements should be 0.05.<br>
"1" at the fourth line means that there is one line in the second
section.<br>
"25 25 0 25 25 200 0.3" means that along the line between points (25,
25, 0) and (25, 25, 200) size of elements should be 0.3.
\image html netgen2d3d_simple.png

View File

@ -110,6 +110,9 @@ module NETGENPlugin
double GetLocalSizeOnEntry(in string entry);
string_array GetLocalSizeEntries();
void UnsetLocalSizeOnEntry(in string entry);
void SetMeshSizeFile(in string fileName);
string GetMeshSizeFile();
};
/*!

View File

@ -34,8 +34,9 @@
#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>
@ -82,7 +83,8 @@ enum {
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 )
@ -242,7 +244,7 @@ QFrame* NETGENPluginGUI_HypothesisCreator::buildFrame()
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);
@ -258,21 +260,27 @@ QFrame* NETGENPluginGUI_HypothesisCreator::buildFrame()
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, 1, 1, 1);
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()));
@ -280,6 +288,7 @@ QFrame* NETGENPluginGUI_HypothesisCreator::buildFrame()
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"));
}
@ -327,7 +336,7 @@ void NETGENPluginGUI_HypothesisCreator::retrieveParams() const
myNbSegPerRadius->setValue( data.myNbSegPerRadius );
else
myNbSegPerRadius->setText( data.myNbSegPerRadiusVar );
}
}
if (myAllowQuadrangles)
myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
@ -361,6 +370,8 @@ void NETGENPluginGUI_HypothesisCreator::retrieveParams() const
}
myLocalSizeTable->resizeColumnToContents(LSZ_NAME_COLUMN);
myLocalSizeTable->resizeColumnToContents(LSZ_LOCALSIZE_COLUMN);
myMeshSizeFile->setText( data.myMeshSizeFile );
}
}
@ -369,7 +380,7 @@ QString NETGENPluginGUI_HypothesisCreator::storeParams() const
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 )
@ -377,12 +388,12 @@ QString NETGENPluginGUI_HypothesisCreator::storeParams() const
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");
@ -416,34 +427,35 @@ bool NETGENPluginGUI_HypothesisCreator::readParamsFromHypo( NetgenHypothesisData
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();
}
if ( !h->_is_nil() )
h_data.myAllowQuadrangles = h->GetQuadAllowed();
}
NETGENPluginGUI_HypothesisCreator* that = (NETGENPluginGUI_HypothesisCreator*)this;
NETGENPlugin::string_array_var myEntries = h->GetLocalSizeEntries();
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;
}
@ -466,28 +478,29 @@ bool NETGENPluginGUI_HypothesisCreator::storeParamsToHypo( const NetgenHypothesi
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.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 );
}
{
// 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()) {
@ -495,16 +508,16 @@ bool NETGENPluginGUI_HypothesisCreator::storeParamsToHypo( const NetgenHypothesi
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)
@ -559,6 +572,7 @@ bool NETGENPluginGUI_HypothesisCreator::readParamsFromWidgets( NetgenHypothesisD
QString localSize = myLocalSizeTable->item(row, LSZ_LOCALSIZE_COLUMN)->text().trimmed();
that->myLocalSizeMap[entry] = localSize;
}
h_data.myMeshSizeFile = myMeshSizeFile->text();
}
return true;
}
@ -744,6 +758,13 @@ void NETGENPluginGUI_HypothesisCreator::onSetLocalSize(int row,int col)
}
}
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();

View File

@ -47,7 +47,7 @@ typedef struct
double myMaxSize, myMinSize, myGrowthRate, myNbSegPerEdge, myNbSegPerRadius;
int myFineness;
bool mySecondOrder, myAllowQuadrangles, myOptimize, mySurfaceCurvature, myFuseEdges;
QString myName;
QString myName, myMeshSizeFile;
QString myMaxSizeVar, myMinSizeVar, myGrowthRateVar, myNbSegPerEdgeVar, myNbSegPerRadiusVar;
} NetgenHypothesisData;
@ -83,6 +83,7 @@ protected slots:
virtual void onAddLocalSizeOnSolid();
virtual void onRemoveLocalSizeOnShape();
virtual void onSetLocalSize(int,int);
virtual void onSetSizeFile();
private:
bool readParamsFromHypo( NetgenHypothesisData& ) const;
@ -108,8 +109,9 @@ private:
bool myIs2D;
bool myIsONLY;
QTableWidget* myLocalSizeTable;
GeomSelectionTools* myGeomSelectionTools;
QLineEdit* myMeshSizeFile;
QTableWidget* myLocalSizeTable;
GeomSelectionTools* myGeomSelectionTools;
QMap<QString, QString> myLocalSizeMap;
};

View File

@ -159,5 +159,9 @@
<source>LSZ_LOCALSIZE_COLUMN</source>
<translation>Value</translation>
</message>
<message>
<source>NETGEN_LSZ_FILE</source>
<translation>Mesh-size File</translation>
</message>
</context>
</TS>

View File

@ -169,6 +169,12 @@ class NETGEN_Algorithm(Mesh_Algorithm):
return self.params
## Defines a file specifying size of elements at points and lines
# @param file name of the file
def SetMeshSizeFile(self, file):
self.Parameters().SetMeshSizeFile(file)
pass
pass # end of NETGEN_Algorithm class

View File

@ -247,6 +247,20 @@ void NETGENPlugin_Hypothesis::UnsetLocalSizeOnEntry(const std::string& entry)
NotifySubMeshesHypothesisModification();
}
//=============================================================================
/*!
*
*/
//=============================================================================
void NETGENPlugin_Hypothesis::SetMeshSizeFile(const std::string& fileName)
{
if ( fileName != _meshSizeFile )
{
_meshSizeFile = fileName;
NotifySubMeshesHypothesisModification();
}
}
//=============================================================================
/*!
*
@ -347,6 +361,8 @@ ostream & NETGENPlugin_Hypothesis::SaveTo(ostream & save)
save << " " << _surfaceCurvature;
save << " " << _fuseEdges;
save << " " << _meshSizeFile.size() << " " << _meshSizeFile;
return save;
}
@ -432,19 +448,34 @@ istream & NETGENPlugin_Hypothesis::LoadFrom(istream & load)
if ( !hasLocalSize && !option_or_sm.empty() )
_minSize = atof( option_or_sm.c_str() );
else
load >> _minSize;
isOK = static_cast<bool>( load >> _quadAllowed );
if ( !isOK )
isOK = static_cast<bool>( load >> is );
if ( isOK )
_quadAllowed = (bool) is;
else
_quadAllowed = GetDefaultQuadAllowed();
isOK = static_cast<bool>( load >> _surfaceCurvature );
if ( !isOK )
isOK = static_cast<bool>( load >> is );
if ( isOK )
_surfaceCurvature = (bool) is;
else
_surfaceCurvature = GetDefaultSurfaceCurvature();
isOK = static_cast<bool>( load >> _fuseEdges );
if ( !isOK )
isOK = static_cast<bool>( load >> is );
if ( isOK )
_fuseEdges = (bool) is;
else
_fuseEdges = GetDefaultFuseEdges();
isOK = static_cast<bool>( load >> is >> std::ws ); // size of meshSizeFile
if ( isOK && is > 0 )
{
_meshSizeFile.resize( is );
load.get( &_meshSizeFile[0], is+1 );
}
return load;
}

View File

@ -90,6 +90,9 @@ public:
const TLocalSize& GetLocalSizesAndEntries() const { return _localSize; }
void UnsetLocalSizeOnEntry(const std::string& entry);
void SetMeshSizeFile(const std::string& fileName);
const std::string& GetMeshSizeFile() const { return _meshSizeFile; }
void SetQuadAllowed(bool theVal);
bool GetQuadAllowed() const { return _quadAllowed; }
@ -141,6 +144,7 @@ private:
bool _secondOrder;
bool _optimize;
TLocalSize _localSize;
std::string _meshSizeFile;
bool _quadAllowed;
bool _surfaceCurvature;
bool _fuseEdges;

View File

@ -51,7 +51,6 @@ NETGENPlugin_Hypothesis_2D_i (PortableServer::POA_ptr thePOA,
SMESH_Hypothesis_i( thePOA ),
NETGENPlugin_Hypothesis_i( thePOA, theStudyId, theGenImpl )
{
MESSAGE( "NETGENPlugin_Hypothesis_2D_i::NETGENPlugin_Hypothesis_2D_i" );
if (myBaseImpl)
delete (::NETGENPlugin_Hypothesis*)myBaseImpl;
myBaseImpl = new ::NETGENPlugin_Hypothesis_2D (theGenImpl->GetANewId(),
@ -68,7 +67,6 @@ NETGENPlugin_Hypothesis_2D_i (PortableServer::POA_ptr thePOA,
//=============================================================================
NETGENPlugin_Hypothesis_2D_i::~NETGENPlugin_Hypothesis_2D_i()
{
MESSAGE( "NETGENPlugin_Hypothesis_2D_i::~NETGENPlugin_Hypothesis_2D_i" );
}
//=============================================================================

View File

@ -366,6 +366,24 @@ void NETGENPlugin_Hypothesis_i::UnsetLocalSizeOnEntry(const char* entry)
//=============================================================================
void NETGENPlugin_Hypothesis_i::SetMeshSizeFile(const char* fileName)
{
if ( GetImpl()->GetMeshSizeFile() != fileName )
{
GetImpl()->SetMeshSizeFile( fileName );
SMESH::TPythonDump() << _this() << ".SetMeshSizeFile( '" << fileName << "' )";
}
}
//=============================================================================
char* NETGENPlugin_Hypothesis_i::GetMeshSizeFile()
{
return CORBA::string_dup( GetImpl()->GetMeshSizeFile().c_str() );
}
//=============================================================================
void NETGENPlugin_Hypothesis_i::SetQuadAllowed (CORBA::Boolean theValue)
{
if ( NETGENPlugin_Hypothesis_i::isToSetParameter( GetQuadAllowed(),

View File

@ -86,6 +86,9 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis_i:
NETGENPlugin::string_array* GetLocalSizeEntries();
void UnsetLocalSizeOnEntry(const char* entry);
void SetMeshSizeFile(const char* fileName);
char* GetMeshSizeFile();
void SetQuadAllowed(CORBA::Boolean theVal);
CORBA::Boolean GetQuadAllowed();

View File

@ -283,6 +283,8 @@ void NETGENPlugin_Mesher::SetParameters(const NETGENPlugin_Hypothesis* hyp)
mparams.uselocalh = hyp->GetSurfaceCurvature();
netgen::merge_solids = hyp->GetFuseEdges();
_simpleHyp = NULL;
// mesh size file
mparams.meshsizefilename= hyp->GetMeshSizeFile().empty() ? 0 : hyp->GetMeshSizeFile().c_str();
SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
CORBA::Object_var anObject = smeshGen_i->GetNS()->Resolve("/myStudyManager");
@ -661,7 +663,7 @@ void NETGENPlugin_Mesher::SetLocalSize( netgen::OCCGeometry& occgeo,
if ( !ControlPoints.empty() )
{
for ( size_t i = 1; i < ControlPoints.size(); ++i )
for ( size_t i = 0; i < ControlPoints.size(); ++i )
NETGENPlugin_Mesher::RestrictLocalSize( ngMesh, ControlPoints[i].XYZ(), ControlPoints[i].Size() );
}
}
@ -2486,16 +2488,6 @@ bool NETGENPlugin_Mesher::Compute()
NETGENPlugin_NetgenLibWrapper ngLib;
netgen::MeshingParameters& mparams = netgen::mparam;
MESSAGE("Compute with:\n"
" max size = " << mparams.maxh << "\n"
" segments per edge = " << mparams.segmentsperedge);
MESSAGE("\n"
" growth rate = " << mparams.grading << "\n"
" elements per radius = " << mparams.curvaturesafety << "\n"
" second order = " << mparams.secondorder << "\n"
" quad allowed = " << mparams.quad << "\n"
" surface curvature = " << mparams.uselocalh << "\n"
" fuse edges = " << netgen::merge_solids);
SMESH_ComputeErrorPtr error = SMESH_ComputeError::New();
SMESH_MesherHelper quadHelper( *_mesh );
@ -2585,6 +2577,12 @@ bool NETGENPlugin_Mesher::Compute()
{
comment << text(ex);
}
catch (netgen::NgException & ex)
{
comment << text(ex);
if ( mparams.meshsizefilename )
throw SMESH_ComputeError(COMPERR_BAD_PARMETERS, comment );
}
err = 0; //- MESHCONST_ANALYSE isn't so important step
if ( !_ngMesh )
return false;
@ -2592,6 +2590,9 @@ bool NETGENPlugin_Mesher::Compute()
_ngMesh->ClearFaceDescriptors(); // we make descriptors our-self
if ( !mparams.uselocalh ) // mparams.grading is not taken into account yet
_ngMesh->LocalHFunction().SetGrading( mparams.grading );
if ( _simpleHyp )
{
// Pass 1D simple parameters to NETGEN
@ -3475,10 +3476,10 @@ NETGENPlugin_Mesher::ReadErrors(const vector<const SMDS_MeshNode* >& nodeVec)
*/
//================================================================================
void NETGENPlugin_Mesher::toPython( const netgen::Mesh* ngMesh,
const std::string& pyFile)
void NETGENPlugin_Mesher::toPython( const netgen::Mesh* ngMesh )
{
ofstream outfile(pyFile.c_str(), ios::out);
const char* pyFile = "/tmp/ngMesh.py";
ofstream outfile( pyFile, ios::out );
if ( !outfile ) return;
outfile << "import SMESH" << endl

View File

@ -191,8 +191,7 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Mesher
static SMESH_ComputeErrorPtr ReadErrors(const std::vector< const SMDS_MeshNode* >& nodeVec);
static void toPython( const netgen::Mesh* ngMesh,
const std::string& pyFile); // debug
static void toPython( const netgen::Mesh* ngMesh ); // debug
private:

View File

@ -298,8 +298,7 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
for ( int iE = 1; iE <= edgeMap.Extent(); ++iE )
{
const TopoDS_Shape& edge = edgeMap( iE );
if ( SMESH_Algo::isDegenerated( TopoDS::Edge( edge ))/* ||
helper.IsSubShape( edge, aShape )*/)
if ( SMESH_Algo::isDegenerated( TopoDS::Edge( edge )))
continue;
SMESHDS_SubMesh* smDS = meshDS->MeshElements( edge );
if ( !smDS ) continue;
@ -317,6 +316,11 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
// set local size defined on shapes
aMesher.SetLocalSize( occgeoComm, *ngMeshes[0] );
try {
ngMeshes[0]->LoadLocalMeshSize( mparam.meshsizefilename );
} catch (NgException & ex) {
return error( COMPERR_BAD_PARMETERS, ex.What() );
}
}
netgen::mparam.uselocalh = toOptimize; // restore as it is used at surface optimization
@ -453,6 +457,11 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
bb.Increase (bb.Diam()/10);
ngMesh->SetLocalH (bb.PMin(), bb.PMax(), mparam.grading);
aMesher.SetLocalSize( occgeom, *ngMesh );
try {
ngMesh->LoadLocalMeshSize( mparam.meshsizefilename );
} catch (NgException & ex) {
return error( COMPERR_BAD_PARMETERS, ex.What() );
}
}
nodeVec.clear();

View File

@ -71,6 +71,7 @@
#define OCCGEOMETRY
#endif
#include <occgeom.hpp>
#include <ngexception.hpp>
namespace nglib {
#include <nglib.h>
}
@ -438,7 +439,8 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh,
{
aMesher.SetParameters( _hypParameters );
if ( !_hypParameters->GetLocalSizesAndEntries().empty() )
if ( !_hypParameters->GetLocalSizesAndEntries().empty() ||
!_hypParameters->GetMeshSizeFile().empty() )
{
if ( ! &ngMesh->LocalHFunction() )
{
@ -447,6 +449,12 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh,
ngMesh->SetLocalH( pmin, pmax, _hypParameters->GetGrowthRate() );
}
aMesher.SetLocalSize( occgeo, *ngMesh );
try {
ngMesh->LoadLocalMeshSize( netgen::mparam.meshsizefilename );
} catch (netgen::NgException & ex) {
return error( COMPERR_BAD_PARMETERS, ex.What() );
}
}
if ( !_hypParameters->GetOptimize() )
endWith = netgen::MESHCONST_MESHVOLUME;