From 8730f3b8770e2c9e36b1ccc9405381895e8143b2 Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 1 Jul 2011 15:18:55 +0000 Subject: [PATCH] Add "Allow quadrangles" to "Simple netgen parameters" hypothesis --- idl/NETGENPlugin_Algorithm.idl | 9 ++++++ src/GUI/NETGENPluginGUI_SimpleCreator.cxx | 8 +++++ src/GUI/NETGENPluginGUI_SimpleCreator.h | 1 + src/NETGENPlugin/NETGENPlugin_Mesher.cxx | 3 +- src/NETGENPlugin/NETGENPlugin_NETGEN_2D.cxx | 3 -- .../NETGENPlugin_NETGEN_2D_ONLY.cxx | 11 ++++++- .../NETGENPlugin_NETGEN_2D_ONLY.hxx | 3 +- .../NETGENPlugin_SimpleHypothesis_2D.cxx | 31 +++++++++++++++++-- .../NETGENPlugin_SimpleHypothesis_2D.hxx | 10 ++++++ .../NETGENPlugin_SimpleHypothesis_2D_i.cxx | 31 +++++++++++++++++-- .../NETGENPlugin_SimpleHypothesis_2D_i.hxx | 2 ++ 11 files changed, 100 insertions(+), 12 deletions(-) diff --git a/idl/NETGENPlugin_Algorithm.idl b/idl/NETGENPlugin_Algorithm.idl index d0e32c8..344b112 100644 --- a/idl/NETGENPlugin_Algorithm.idl +++ b/idl/NETGENPlugin_Algorithm.idl @@ -162,6 +162,15 @@ module NETGENPlugin * Can be zero in case of LengthFromEdges() */ double GetMaxElementArea(); + + /*! + * Enables/disables generation of quadrangular faces + */ + void SetAllowQuadrangles(in boolean toAllow); + /*! + * Returns true if generation of quadrangular faces is enabled + */ + boolean GetAllowQuadrangles(); }; /*! diff --git a/src/GUI/NETGENPluginGUI_SimpleCreator.cxx b/src/GUI/NETGENPluginGUI_SimpleCreator.cxx index fd7ebfd..e203d6f 100644 --- a/src/GUI/NETGENPluginGUI_SimpleCreator.cxx +++ b/src/GUI/NETGENPluginGUI_SimpleCreator.cxx @@ -71,6 +71,7 @@ NETGENPluginGUI_SimpleCreator::NETGENPluginGUI_SimpleCreator(const QString& theH myLengthRadioBut(0), myLenFromEdgesCheckBox(0), myArea(0), + myAllowQuadCheckBox(0), myLenFromFacesCheckBox(0), myVolume(0) { @@ -183,6 +184,11 @@ QFrame* NETGENPluginGUI_SimpleCreator::buildFrame() dimLay->addWidget( myArea, dimRow, 1 ); dimRow++; + // * allow quadrangles + myAllowQuadCheckBox = new QCheckBox( tr( "NETGEN_ALLOW_QUADRANGLES" ), dimGroup ); + dimLay->addWidget( myAllowQuadCheckBox, dimRow, 0, 1, 2 ); + dimRow++; + // 3D params group if ( hypType()=="NETGEN_SimpleParameters_3D" ) { @@ -283,6 +289,7 @@ void NETGENPluginGUI_SimpleCreator::retrieveParams() const myLenFromEdgesCheckBox->setChecked( true ); myArea->setEnabled( false ); } + myAllowQuadCheckBox->setChecked( h->GetAllowQuadrangles() ); // 3D if ( myVolume ) { @@ -342,6 +349,7 @@ QString NETGENPluginGUI_SimpleCreator::storeParams() const valStr += "; lenFromEdges"; aVariablesList.append(QString()); } + h->SetAllowQuadrangles( myAllowQuadCheckBox->isChecked() ); h->SetParameters(aVariablesList.join(":").toLatin1().constData()); diff --git a/src/GUI/NETGENPluginGUI_SimpleCreator.h b/src/GUI/NETGENPluginGUI_SimpleCreator.h index 7cdb5f7..e42fe61 100644 --- a/src/GUI/NETGENPluginGUI_SimpleCreator.h +++ b/src/GUI/NETGENPluginGUI_SimpleCreator.h @@ -67,6 +67,7 @@ private: QCheckBox* myLenFromEdgesCheckBox; SMESHGUI_SpinBox* myArea; + QCheckBox* myAllowQuadCheckBox; QCheckBox* myLenFromFacesCheckBox; SMESHGUI_SpinBox* myVolume; diff --git a/src/NETGENPlugin/NETGENPlugin_Mesher.cxx b/src/NETGENPlugin/NETGENPlugin_Mesher.cxx index a75a272..28ecc76 100644 --- a/src/NETGENPlugin/NETGENPlugin_Mesher.cxx +++ b/src/NETGENPlugin/NETGENPlugin_Mesher.cxx @@ -1916,7 +1916,7 @@ bool NETGENPlugin_Mesher::Compute() if( visitedEdges.Add(exp.Current()) ) edgeLength += SMESH_Algo::EdgeLength( TopoDS::Edge( exp.Current() )); // we have to multiply length by 2 since for each TopoDS_Edge there - // are double set of NETGEN edges or, in other words, we have to + // are double set of NETGEN edges, in other words, we have to // divide ngMesh->GetNSeg() by 2. mparams.maxh = 2*edgeLength / ngMesh->GetNSeg(); } @@ -1925,6 +1925,7 @@ bool NETGENPlugin_Mesher::Compute() } mparams.grading = 0.2; // slow size growth } + mparams.quad = _simpleHyp->GetAllowQuadrangles(); mparams.maxh = min( mparams.maxh, occgeo.boundingbox.Diam()/2 ); ngMesh->SetGlobalH (mparams.maxh); netgen::Box<3> bb = occgeo.GetBoundingBox(); diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D.cxx index 0117ac1..ad2f079 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D.cxx @@ -25,7 +25,6 @@ // Author : Michael Sazonov (OCN) // Date : 20/03/2006 // Project : SALOME -// $Header$ //============================================================================= // #include "NETGENPlugin_NETGEN_2D.hxx" @@ -132,10 +131,8 @@ bool NETGENPlugin_NETGEN_2D::Compute(SMESH_Mesh& aMesh, #ifdef WITH_SMESH_CANCEL_COMPUTE netgen::multithread.terminate = 0; #endif - //SMESHDS_Mesh* meshDS = aMesh.GetMeshDS(); NETGENPlugin_Mesher mesher(&aMesh, aShape, false); -// NETGENPlugin_Mesher mesher(meshDS, aShape, false); mesher.SetParameters(dynamic_cast(_hypothesis)); mesher.SetParameters(dynamic_cast(_hypothesis)); return mesher.Compute(); diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx index 32c088f..c54c8fa 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx @@ -87,7 +87,14 @@ NETGENPlugin_NETGEN_2D_ONLY::NETGENPlugin_NETGEN_2D_ONLY(int hypId, int studyId, _compatibleHypothesis.push_back("MaxElementArea"); _compatibleHypothesis.push_back("LengthFromEdges"); - _compatibleHypothesis.push_back("QuadranglePreference"); + //_compatibleHypothesis.push_back("QuadranglePreference"); + _compatibleHypothesis.push_back("QuadrangleParams"); /* QuadranglePreference was removed and + it is converted into QuadrangleParams + at reading an old study; so we use + QuadrangleParams insead of + QuadranglePreference for backward + compatibility + */ _compatibleHypothesis.push_back("NETGEN_Parameters_2D"); _hypMaxElementArea = 0; @@ -144,6 +151,8 @@ bool NETGENPlugin_NETGEN_2D_ONLY::CheckHypothesis (SMESH_Mesh& aMesh, _hypLengthFromEdges = static_cast (hyp); else if ( hypName == "NETGEN_Parameters_2D" ) _hypParameters = static_cast(hyp); + else if ( hypName == "QuadrangleParams" ) + _hypQuadranglePreference = hyp; else { aStatus = HYP_INCOMPATIBLE; return false; diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.hxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.hxx index 619e650..cdb7ff4 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.hxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.hxx @@ -29,7 +29,6 @@ class StdMeshers_MaxElementArea; class StdMeshers_LengthFromEdges; -class StdMeshers_QuadranglePreference; class NETGENPlugin_Hypothesis_2D; /*! @@ -63,7 +62,7 @@ public: protected: const StdMeshers_MaxElementArea* _hypMaxElementArea; const StdMeshers_LengthFromEdges* _hypLengthFromEdges; - const StdMeshers_QuadranglePreference* _hypQuadranglePreference; + const SMESHDS_Hypothesis* _hypQuadranglePreference; const NETGENPlugin_Hypothesis_2D* _hypParameters; }; diff --git a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D.cxx b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D.cxx index 7979aab..feeeabe 100644 --- a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D.cxx +++ b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D.cxx @@ -47,7 +47,8 @@ NETGENPlugin_SimpleHypothesis_2D::NETGENPlugin_SimpleHypothesis_2D (int : SMESH_Hypothesis(hypId, studyId, gen), _nbSegments ((int)NETGENPlugin_Hypothesis::GetDefaultNbSegPerEdge()), _segmentLength(0), - _area (0.) + _area (0.), + _allowQuad (false) { _name = "NETGEN_SimpleParameters_2D"; _param_algo_dim = 2; @@ -118,6 +119,30 @@ void NETGENPlugin_SimpleHypothesis_2D::SetMaxElementArea(double area) } } +//======================================================================= +//function : SetAllowQuadrangles +//purpose : Enables/disables generation of quadrangular faces +//======================================================================= + +void NETGENPlugin_SimpleHypothesis_2D::SetAllowQuadrangles(bool toAllow) +{ + if ( _allowQuad != toAllow ) + { + _allowQuad = toAllow; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetAllowQuadrangles +//purpose : Returns true if generation of quadrangular faces is enabled +//======================================================================= + +bool NETGENPlugin_SimpleHypothesis_2D::GetAllowQuadrangles() const +{ + return _allowQuad; +} + //============================================================================= /*! * @@ -125,7 +150,7 @@ void NETGENPlugin_SimpleHypothesis_2D::SetMaxElementArea(double area) //============================================================================= ostream & NETGENPlugin_SimpleHypothesis_2D::SaveTo(ostream & save) { - save << _nbSegments << " " << _segmentLength << " " << _area; + save << _nbSegments << " " << _segmentLength << " " << _area << " " << _allowQuad; return save; } @@ -158,6 +183,8 @@ istream & NETGENPlugin_SimpleHypothesis_2D::LoadFrom(istream & load) else load.clear(ios::badbit | load.rdstate()); + load >> _allowQuad; + return load; } diff --git a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D.hxx b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D.hxx index 6fa6f1b..5c49126 100644 --- a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D.hxx +++ b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D.hxx @@ -78,6 +78,15 @@ public: */ double GetMaxElementArea() const { return _area; } + /*! + * Enables/disables generation of quadrangular faces + */ + void SetAllowQuadrangles(bool toAllow); + /*! + * Returns true if generation of quadrangular faces is enabled + */ + bool GetAllowQuadrangles() const; + // Persistence virtual ostream & SaveTo(ostream & save); virtual istream & LoadFrom(istream & load); @@ -99,6 +108,7 @@ public: private: int _nbSegments; double _segmentLength, _area; + bool _allowQuad; }; #endif diff --git a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.cxx b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.cxx index 556bf52..f3a32d0 100644 --- a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.cxx +++ b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.cxx @@ -161,12 +161,37 @@ void NETGENPlugin_SimpleHypothesis_2D_i::SetMaxElementArea(CORBA::Double area) * NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea() */ //============================================================================= + CORBA::Double NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea() { MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea"); ASSERT(myBaseImpl); return this->GetImpl()->GetMaxElementArea(); } + +//============================================================================= +/*! + * Enables/disables generation of quadrangular faces + */ +//============================================================================= + +void NETGENPlugin_SimpleHypothesis_2D_i::SetAllowQuadrangles(CORBA::Boolean toAllow) +{ + ASSERT(myBaseImpl); + SMESH::TPythonDump() << _this() << ".SetAllowQuadrangles( " << toAllow << " )"; + this->GetImpl()->SetAllowQuadrangles(toAllow); +} + +//============================================================================= +/*! + * Returns true if generation of quadrangular faces is enabled + */ +//============================================================================= + +CORBA::Boolean NETGENPlugin_SimpleHypothesis_2D_i::GetAllowQuadrangles() +{ + return this->GetImpl()->GetAllowQuadrangles(); +} //============================================================================= /*! * NETGENPlugin_SimpleHypothesis_2D_i::GetImpl @@ -181,9 +206,9 @@ CORBA::Double NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea() //================================================================================ /*! * \brief Verify whether hypothesis supports given entity type - * \param type - dimension (see SMESH::Dimension enumeration) - * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise - * + * \param type - dimension (see SMESH::Dimension enumeration) + * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise + * * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration) */ //================================================================================ diff --git a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.hxx b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.hxx index e0297ac..50b709b 100644 --- a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.hxx +++ b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.hxx @@ -62,6 +62,8 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_SimpleHypothesis_2D_i: void SetMaxElementArea(CORBA::Double area); CORBA::Double GetMaxElementArea(); + void SetAllowQuadrangles(CORBA::Boolean toAllow); + CORBA::Boolean GetAllowQuadrangles(); // Get implementation ::NETGENPlugin_SimpleHypothesis_2D* GetImpl(); -- 2.39.2