From: imn Date: Wed, 4 Dec 2013 07:55:08 +0000 (+0000) Subject: Integrated in BR_imps_2013 branch: 0022357: EDF NETGENPLUGIN: NETGEN options X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fd28f4083f766e532cfdeb758843c77b9a7b7c92;p=plugins%2Fnetgenplugin.git Integrated in BR_imps_2013 branch: 0022357: EDF NETGENPLUGIN: NETGEN options --- diff --git a/src/GUI/NETGENPluginGUI_HypothesisCreator.cxx b/src/GUI/NETGENPluginGUI_HypothesisCreator.cxx index 7a0a094..4b1f71f 100644 --- a/src/GUI/NETGENPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/NETGENPluginGUI_HypothesisCreator.cxx @@ -203,14 +203,29 @@ QFrame* NETGENPluginGUI_HypothesisCreator::buildFrame() aGroupLayout->addWidget( myNbSegPerRadius, row, 1 ); row++; } + myAllowQuadrangles = 0; + mySurfaceCurvature = 0; + myFuseEdges = 0; if ( myIs2D || !myIsONLY ) // issue 0021676 { myAllowQuadrangles = new QCheckBox( tr( "NETGEN_ALLOW_QUADRANGLES" ), GroupC1 ); aGroupLayout->addWidget( myAllowQuadrangles, row, 0 ); row++; + + mySurfaceCurvature = new QCheckBox( tr( "NETGEN_SURFACE_CURVATURE" ), GroupC1 ); + aGroupLayout->addWidget( mySurfaceCurvature, row, 0 ); + row++; + } + if (!myIsONLY) + { + myFuseEdges = new QCheckBox( tr( "NETGEN_FUSE_EDGES" ), GroupC1 ); + aGroupLayout->addWidget( myFuseEdges, row, 0 ); + row++; } + connect( mySurfaceCurvature, SIGNAL( stateChanged( int ) ), this, SLOT( onSurfaceCurvatureChanged() ) ); + myOptimize = new QCheckBox( tr( "NETGEN_OPTIMIZE" ), GroupC1 ); aGroupLayout->addWidget( myOptimize, row, 0 ); row++; @@ -306,13 +321,21 @@ void NETGENPluginGUI_HypothesisCreator::retrieveParams() const 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); + bool isSurfaceCurvature = (mySurfaceCurvature->checkState() == Qt::Checked); + myFineness->setEnabled(isSurfaceCurvature); + myGrowthRate->setEnabled(isCustom && isSurfaceCurvature); if ( myNbSegPerEdge ) - myNbSegPerEdge->setEnabled(isCustom); + myNbSegPerEdge->setEnabled(isCustom && isSurfaceCurvature); if ( myNbSegPerRadius ) - myNbSegPerRadius->setEnabled(isCustom); + myNbSegPerRadius->setEnabled(isCustom && isSurfaceCurvature); if ( myLocalSizeTable ) { @@ -357,6 +380,12 @@ QString NETGENPluginGUI_HypothesisCreator::storeParams() const 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; } @@ -382,6 +411,8 @@ bool NETGENPluginGUI_HypothesisCreator::readParamsFromHypo( NetgenHypothesisData h_data.myNbSegPerRadiusVar = getVariableName("SetNbSegPerRadius"); h_data.myMinSize = h->GetMinSize(); h_data.myMinSizeVar = getVariableName("SetMinSize"); + h_data.mySurfaceCurvature = h->GetSurfaceCurvature(); + h_data.myFuseEdges = h->GetFuseEdges(); //if ( myIs2D ) { @@ -442,6 +473,8 @@ bool NETGENPluginGUI_HypothesisCreator::storeParamsToHypo( const NetgenHypothesi } h->SetVarParameter( h_data.myMinSizeVar.toLatin1().constData(), "SetMinSize"); h->SetMinSize( h_data.myMinSize ); + h->SetSurfaceCurvature( h_data.mySurfaceCurvature ); + h->SetFuseEdges( h_data.myFuseEdges ); if ( myIs2D ) { @@ -506,6 +539,12 @@ bool NETGENPluginGUI_HypothesisCreator::readParamsFromWidgets( NetgenHypothesisD 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; @@ -520,6 +559,18 @@ bool NETGENPluginGUI_HypothesisCreator::readParamsFromWidgets( NetgenHypothesisD return true; } +void NETGENPluginGUI_HypothesisCreator::onSurfaceCurvatureChanged() +{ + bool isSurfaceCurvature = (mySurfaceCurvature->checkState() == Qt::Checked); + bool isCustom = (myFineness->currentIndex() == UserDefined); + myFineness->setEnabled(isSurfaceCurvature); + myGrowthRate->setEnabled(isCustom && isSurfaceCurvature); + if ( myNbSegPerEdge ) + myNbSegPerEdge->setEnabled(isCustom && isSurfaceCurvature); + if ( myNbSegPerRadius ) + myNbSegPerRadius->setEnabled(isCustom && isSurfaceCurvature); +} + void NETGENPluginGUI_HypothesisCreator::onFinenessChanged() { bool isCustom = (myFineness->currentIndex() == UserDefined); diff --git a/src/GUI/NETGENPluginGUI_HypothesisCreator.h b/src/GUI/NETGENPluginGUI_HypothesisCreator.h index aaba4fc..395ecfb 100644 --- a/src/GUI/NETGENPluginGUI_HypothesisCreator.h +++ b/src/GUI/NETGENPluginGUI_HypothesisCreator.h @@ -46,7 +46,7 @@ typedef struct { double myMaxSize, myMinSize, myGrowthRate, myNbSegPerEdge, myNbSegPerRadius; int myFineness; - bool mySecondOrder, myAllowQuadrangles, myOptimize; + bool mySecondOrder, myAllowQuadrangles, myOptimize, mySurfaceCurvature, myFuseEdges; QString myName; QString myMaxSizeVar, myMinSizeVar, myGrowthRateVar, myNbSegPerEdgeVar, myNbSegPerRadiusVar; } NetgenHypothesisData; @@ -76,6 +76,7 @@ protected: protected slots: virtual void onFinenessChanged(); + virtual void onSurfaceCurvatureChanged(); virtual void onAddLocalSizeOnVertex(); virtual void onAddLocalSizeOnEdge(); virtual void onAddLocalSizeOnFace(); @@ -100,6 +101,8 @@ private: SMESHGUI_SpinBox* myNbSegPerEdge; SMESHGUI_SpinBox* myNbSegPerRadius; QCheckBox* myAllowQuadrangles; + QCheckBox* mySurfaceCurvature; + QCheckBox* myFuseEdges; bool myIs2D; bool myIsONLY; diff --git a/src/GUI/NETGENPlugin_msg_en.ts b/src/GUI/NETGENPlugin_msg_en.ts index 55e4ceb..32e72db 100644 --- a/src/GUI/NETGENPlugin_msg_en.ts +++ b/src/GUI/NETGENPlugin_msg_en.ts @@ -55,6 +55,10 @@ NETGEN_FINENESS Fineness + + NETGEN_FUSE_EDGES + Fuse consignment Edges and Vertices + NETGEN_GROWTH_RATE Growth Rate @@ -87,6 +91,10 @@ NETGEN_SEG_PER_RADIUS Nb. Segs per Radius + + NETGEN_SURFACE_CURVATURE + Set size by Surface Curvature + NETGEN_VERYCOARSE Very Coarse diff --git a/src/GUI/NETGENPlugin_msg_fr.ts b/src/GUI/NETGENPlugin_msg_fr.ts index 01acbc0..3beb2a9 100755 --- a/src/GUI/NETGENPlugin_msg_fr.ts +++ b/src/GUI/NETGENPlugin_msg_fr.ts @@ -55,6 +55,10 @@ NETGEN_FINENESS Finesse + + NETGEN_FUSE_EDGES + Fuse consignment Edges and Vertices + NETGEN_GROWTH_RATE Taux d'accroissement @@ -87,6 +91,10 @@ NETGEN_SEG_PER_RADIUS Nb. segments par rayon + + NETGEN_SURFACE_CURVATURE + Set size by Surface Curvature + NETGEN_VERYCOARSE Très grossier diff --git a/src/NETGENPlugin/NETGENPluginBuilder.py b/src/NETGENPlugin/NETGENPluginBuilder.py index 11369c7..f6a6f23 100644 --- a/src/NETGENPlugin/NETGENPluginBuilder.py +++ b/src/NETGENPlugin/NETGENPluginBuilder.py @@ -218,6 +218,16 @@ class NETGEN_1D2D3D_Algorithm(NETGEN_Algorithm): def SetQuadAllowed(self, toAllow=True): if self.Parameters(): self.params.SetQuadAllowed(toAllow) pass + ## Sets @c SurfaceCurvature flag + # @param toAllow new value of the @c SurfaceCurvature parameter (@c True by default) + def SetSurfaceCurvature(self, toAllow=True): + if self.Parameters(): self.params.SetSurfaceCurvature(toAllow) + pass + ## Sets @c FuseEdges flag + # @param toAllow new value of the @c FuseEdges parameter (@c False by default) + def SetFuseEdges(self, toAllow=False): + if self.Parameters(): self.params.SetFuseEdges(toAllow) + pass ## Sets number of segments overriding the value set by SetLocalLength() # @param theVal new value of number of segments parameter @@ -335,6 +345,12 @@ class NETGEN_2D_Only_Algorithm(NETGEN_Algorithm): def LengthFromEdges(self): hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp) return hyp + + ## Sets @c SurfaceCurvature flag + # @param toAllow new value of the @c SurfaceCurvature parameter (@c True by default) + def SetSurfaceCurvature(self, toAllow=True): + if self.Parameters(): self.params.SetSurfaceCurvature(toAllow) + pass ## Sets @c QuadAllowed flag. # @param toAllow new value of the @c QuadAllowed parameter (@c True by default) diff --git a/src/NETGENPlugin/NETGENPlugin_Hypothesis.cxx b/src/NETGENPlugin/NETGENPlugin_Hypothesis.cxx index e33e401..ad439a2 100644 --- a/src/NETGENPlugin/NETGENPlugin_Hypothesis.cxx +++ b/src/NETGENPlugin/NETGENPlugin_Hypothesis.cxx @@ -43,16 +43,18 @@ using namespace std; NETGENPlugin_Hypothesis::NETGENPlugin_Hypothesis (int hypId, int studyId, SMESH_Gen * gen) : SMESH_Hypothesis(hypId, studyId, gen), - _maxSize (GetDefaultMaxSize()), - _minSize (0), - _growthRate (GetDefaultGrowthRate()), - _nbSegPerEdge (GetDefaultNbSegPerEdge()), - _nbSegPerRadius(GetDefaultNbSegPerRadius()), - _fineness (GetDefaultFineness()), - _secondOrder (GetDefaultSecondOrder()), - _optimize (GetDefaultOptimize()), - _localSize (GetDefaultLocalSize()), - _quadAllowed (GetDefaultQuadAllowed()) + _maxSize (GetDefaultMaxSize()), + _minSize (0), + _growthRate (GetDefaultGrowthRate()), + _nbSegPerEdge (GetDefaultNbSegPerEdge()), + _nbSegPerRadius (GetDefaultNbSegPerRadius()), + _fineness (GetDefaultFineness()), + _secondOrder (GetDefaultSecondOrder()), + _optimize (GetDefaultOptimize()), + _localSize (GetDefaultLocalSize()), + _quadAllowed (GetDefaultQuadAllowed()), + _surfaceCurvature(GetDefaultSurfaceCurvature()), + _fuseEdges (GetDefaultFuseEdges()) { _name = "NETGEN_Parameters"; _param_algo_dim = 3; @@ -274,6 +276,54 @@ bool NETGENPlugin_Hypothesis::GetDefaultQuadAllowed() * */ //============================================================================= +void NETGENPlugin_Hypothesis::SetSurfaceCurvature(bool theVal) +{ + if (theVal != _surfaceCurvature) + { + _surfaceCurvature = theVal; + NotifySubMeshesHypothesisModification(); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= +bool NETGENPlugin_Hypothesis::GetDefaultSurfaceCurvature() +{ + return true; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void NETGENPlugin_Hypothesis::SetFuseEdges(bool theVal) +{ + if (theVal != _fuseEdges) + { + _fuseEdges = theVal; + NotifySubMeshesHypothesisModification(); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= +bool NETGENPlugin_Hypothesis::GetDefaultFuseEdges() +{ + return false; +} + +//============================================================================= +/*! + * + */ +//============================================================================= ostream & NETGENPlugin_Hypothesis::SaveTo(ostream & save) { save << _maxSize << " " << _fineness; @@ -294,6 +344,8 @@ ostream & NETGENPlugin_Hypothesis::SaveTo(ostream & save) } save << " " << _minSize; save << " " << _quadAllowed; + save << " " << _surfaceCurvature; + save << " " << _fuseEdges; return save; } @@ -385,6 +437,14 @@ istream & NETGENPlugin_Hypothesis::LoadFrom(istream & load) if ( !isOK ) _quadAllowed = GetDefaultQuadAllowed(); + isOK = ( load >> _surfaceCurvature ); + if ( !isOK ) + _surfaceCurvature = GetDefaultSurfaceCurvature(); + + isOK = ( load >> _fuseEdges ); + if ( !isOK ) + _fuseEdges = GetDefaultFuseEdges(); + return load; } diff --git a/src/NETGENPlugin/NETGENPlugin_Hypothesis.hxx b/src/NETGENPlugin/NETGENPlugin_Hypothesis.hxx index 9d4b654..3c95ce8 100644 --- a/src/NETGENPlugin/NETGENPlugin_Hypothesis.hxx +++ b/src/NETGENPlugin/NETGENPlugin_Hypothesis.hxx @@ -93,6 +93,12 @@ public: void SetQuadAllowed(bool theVal); bool GetQuadAllowed() const { return _quadAllowed; } + void SetSurfaceCurvature(bool theVal); + bool GetSurfaceCurvature() const { return _surfaceCurvature; } + + void SetFuseEdges(bool theVal); + bool GetFuseEdges() const { return _fuseEdges; } + // the default values (taken from NETGEN 4.5 sources) static double GetDefaultMaxSize(); @@ -103,6 +109,8 @@ public: static bool GetDefaultSecondOrder(); static bool GetDefaultOptimize(); static bool GetDefaultQuadAllowed(); + static bool GetDefaultSurfaceCurvature(); + static bool GetDefaultFuseEdges(); // Persistence virtual ostream & SaveTo(ostream & save); @@ -134,6 +142,8 @@ private: bool _optimize; TLocalSize _localSize; bool _quadAllowed; + bool _surfaceCurvature; + bool _fuseEdges; }; #endif diff --git a/src/NETGENPlugin/NETGENPlugin_Hypothesis_i.cxx b/src/NETGENPlugin/NETGENPlugin_Hypothesis_i.cxx index 0deff9a..60edf28 100644 --- a/src/NETGENPlugin/NETGENPlugin_Hypothesis_i.cxx +++ b/src/NETGENPlugin/NETGENPlugin_Hypothesis_i.cxx @@ -382,6 +382,46 @@ CORBA::Boolean NETGENPlugin_Hypothesis_i::GetQuadAllowed() return this->GetImpl()->GetQuadAllowed(); } +//============================================================================= + +void NETGENPlugin_Hypothesis_i::SetSurfaceCurvature (CORBA::Boolean theValue) +{ + if ( NETGENPlugin_Hypothesis_i::isToSetParameter( GetSurfaceCurvature(), + theValue, + METH_SetSurfaceCurvature )) + { + this->GetImpl()->SetSurfaceCurvature(theValue); + SMESH::TPythonDump() << _this() << ".SetSurfaceCurvature( " << theValue << " )"; + } +} + +//============================================================================= + +CORBA::Boolean NETGENPlugin_Hypothesis_i::GetSurfaceCurvature() +{ + return this->GetImpl()->GetSurfaceCurvature(); +} + +//============================================================================= + +void NETGENPlugin_Hypothesis_i::SetFuseEdges (CORBA::Boolean theValue) +{ + if ( NETGENPlugin_Hypothesis_i::isToSetParameter( GetFuseEdges(), + theValue, + METH_SetFuseEdges )) + { + this->GetImpl()->SetFuseEdges(theValue); + SMESH::TPythonDump() << _this() << ".SetFuseEdges( " << theValue << " )"; + } +} + +//============================================================================= + +CORBA::Boolean NETGENPlugin_Hypothesis_i::GetFuseEdges() +{ + return this->GetImpl()->GetFuseEdges(); +} + //============================================================================= /*! * NETGENPlugin_Hypothesis_i::GetImpl diff --git a/src/NETGENPlugin/NETGENPlugin_Hypothesis_i.hxx b/src/NETGENPlugin/NETGENPlugin_Hypothesis_i.hxx index 075cd12..5ac1068 100644 --- a/src/NETGENPlugin/NETGENPlugin_Hypothesis_i.hxx +++ b/src/NETGENPlugin/NETGENPlugin_Hypothesis_i.hxx @@ -88,6 +88,12 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis_i: void SetQuadAllowed(CORBA::Boolean theVal); CORBA::Boolean GetQuadAllowed(); + void SetSurfaceCurvature(CORBA::Boolean theVal); + CORBA::Boolean GetSurfaceCurvature(); + + void SetFuseEdges(CORBA::Boolean theVal); + CORBA::Boolean GetFuseEdges(); + // Get implementation ::NETGENPlugin_Hypothesis* GetImpl(); @@ -109,7 +115,9 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis_i: METH_SetNbSegPerRadius = 128, METH_SetLocalSizeOnEntry = 256, METH_SetQuadAllowed = METH_SetLocalSizeOnEntry * 2, - METH_LAST = METH_SetQuadAllowed + METH_SetSurfaceCurvature = METH_SetQuadAllowed * 2, + METH_SetFuseEdges = METH_SetSurfaceCurvature * 2, + METH_LAST = METH_SetFuseEdges }; int mySetMethodFlags; diff --git a/src/NETGENPlugin/NETGENPlugin_Mesher.cxx b/src/NETGENPlugin/NETGENPlugin_Mesher.cxx index 5992141..9b51fe4 100644 --- a/src/NETGENPlugin/NETGENPlugin_Mesher.cxx +++ b/src/NETGENPlugin/NETGENPlugin_Mesher.cxx @@ -83,6 +83,7 @@ namespace netgen { //extern void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh); extern MeshingParameters mparam; extern volatile multithreadt multithread; + extern bool merge_solids; } #include @@ -200,6 +201,8 @@ void NETGENPlugin_Mesher::SetDefaultParameters() else mparams.quad = NETGENPlugin_Hypothesis_2D::GetDefaultQuadAllowed() ? 1 : 0; _fineness = NETGENPlugin_Hypothesis::GetDefaultFineness(); + mparams.uselocalh = NETGENPlugin_Hypothesis::GetDefaultSurfaceCurvature(); + netgen::merge_solids = NETGENPlugin_Hypothesis::GetDefaultFuseEdges(); } //============================================================================= @@ -259,6 +262,8 @@ void NETGENPlugin_Mesher::SetParameters(const NETGENPlugin_Hypothesis* hyp) mparams.quad = hyp->GetQuadAllowed() ? 1 : 0; _optimize = hyp->GetOptimize(); _fineness = hyp->GetFineness(); + mparams.uselocalh = hyp->GetSurfaceCurvature(); + netgen::merge_solids = hyp->GetFuseEdges(); _simpleHyp = NULL; SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen(); @@ -2114,8 +2119,9 @@ bool NETGENPlugin_Mesher::Compute() " growth rate = " << mparams.grading << "\n" " elements per radius = " << mparams.curvaturesafety << "\n" " second order = " << mparams.secondorder << "\n" - " quad allowed = " << mparams.quad); - //cout << " quad allowed = " << mparams.quad<