Add "Allow quadrangles" to "Simple netgen parameters" hypothesis

This commit is contained in:
eap 2011-07-01 15:18:55 +00:00
parent 33726b59c7
commit 8730f3b877
11 changed files with 100 additions and 12 deletions

View File

@ -162,6 +162,15 @@ module NETGENPlugin
* Can be zero in case of LengthFromEdges() * Can be zero in case of LengthFromEdges()
*/ */
double GetMaxElementArea(); double GetMaxElementArea();
/*!
* Enables/disables generation of quadrangular faces
*/
void SetAllowQuadrangles(in boolean toAllow);
/*!
* Returns true if generation of quadrangular faces is enabled
*/
boolean GetAllowQuadrangles();
}; };
/*! /*!

View File

@ -71,6 +71,7 @@ NETGENPluginGUI_SimpleCreator::NETGENPluginGUI_SimpleCreator(const QString& theH
myLengthRadioBut(0), myLengthRadioBut(0),
myLenFromEdgesCheckBox(0), myLenFromEdgesCheckBox(0),
myArea(0), myArea(0),
myAllowQuadCheckBox(0),
myLenFromFacesCheckBox(0), myLenFromFacesCheckBox(0),
myVolume(0) myVolume(0)
{ {
@ -183,6 +184,11 @@ QFrame* NETGENPluginGUI_SimpleCreator::buildFrame()
dimLay->addWidget( myArea, dimRow, 1 ); dimLay->addWidget( myArea, dimRow, 1 );
dimRow++; dimRow++;
// * allow quadrangles
myAllowQuadCheckBox = new QCheckBox( tr( "NETGEN_ALLOW_QUADRANGLES" ), dimGroup );
dimLay->addWidget( myAllowQuadCheckBox, dimRow, 0, 1, 2 );
dimRow++;
// 3D params group // 3D params group
if ( hypType()=="NETGEN_SimpleParameters_3D" ) if ( hypType()=="NETGEN_SimpleParameters_3D" )
{ {
@ -283,6 +289,7 @@ void NETGENPluginGUI_SimpleCreator::retrieveParams() const
myLenFromEdgesCheckBox->setChecked( true ); myLenFromEdgesCheckBox->setChecked( true );
myArea->setEnabled( false ); myArea->setEnabled( false );
} }
myAllowQuadCheckBox->setChecked( h->GetAllowQuadrangles() );
// 3D // 3D
if ( myVolume ) { if ( myVolume ) {
@ -342,6 +349,7 @@ QString NETGENPluginGUI_SimpleCreator::storeParams() const
valStr += "; lenFromEdges"; valStr += "; lenFromEdges";
aVariablesList.append(QString()); aVariablesList.append(QString());
} }
h->SetAllowQuadrangles( myAllowQuadCheckBox->isChecked() );
h->SetParameters(aVariablesList.join(":").toLatin1().constData()); h->SetParameters(aVariablesList.join(":").toLatin1().constData());

View File

@ -67,6 +67,7 @@ private:
QCheckBox* myLenFromEdgesCheckBox; QCheckBox* myLenFromEdgesCheckBox;
SMESHGUI_SpinBox* myArea; SMESHGUI_SpinBox* myArea;
QCheckBox* myAllowQuadCheckBox;
QCheckBox* myLenFromFacesCheckBox; QCheckBox* myLenFromFacesCheckBox;
SMESHGUI_SpinBox* myVolume; SMESHGUI_SpinBox* myVolume;

View File

@ -1916,7 +1916,7 @@ bool NETGENPlugin_Mesher::Compute()
if( visitedEdges.Add(exp.Current()) ) if( visitedEdges.Add(exp.Current()) )
edgeLength += SMESH_Algo::EdgeLength( TopoDS::Edge( exp.Current() )); edgeLength += SMESH_Algo::EdgeLength( TopoDS::Edge( exp.Current() ));
// we have to multiply length by 2 since for each TopoDS_Edge there // 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. // divide ngMesh->GetNSeg() by 2.
mparams.maxh = 2*edgeLength / ngMesh->GetNSeg(); mparams.maxh = 2*edgeLength / ngMesh->GetNSeg();
} }
@ -1925,6 +1925,7 @@ bool NETGENPlugin_Mesher::Compute()
} }
mparams.grading = 0.2; // slow size growth mparams.grading = 0.2; // slow size growth
} }
mparams.quad = _simpleHyp->GetAllowQuadrangles();
mparams.maxh = min( mparams.maxh, occgeo.boundingbox.Diam()/2 ); mparams.maxh = min( mparams.maxh, occgeo.boundingbox.Diam()/2 );
ngMesh->SetGlobalH (mparams.maxh); ngMesh->SetGlobalH (mparams.maxh);
netgen::Box<3> bb = occgeo.GetBoundingBox(); netgen::Box<3> bb = occgeo.GetBoundingBox();

View File

@ -25,7 +25,6 @@
// Author : Michael Sazonov (OCN) // Author : Michael Sazonov (OCN)
// Date : 20/03/2006 // Date : 20/03/2006
// Project : SALOME // Project : SALOME
// $Header$
//============================================================================= //=============================================================================
// //
#include "NETGENPlugin_NETGEN_2D.hxx" #include "NETGENPlugin_NETGEN_2D.hxx"
@ -132,10 +131,8 @@ bool NETGENPlugin_NETGEN_2D::Compute(SMESH_Mesh& aMesh,
#ifdef WITH_SMESH_CANCEL_COMPUTE #ifdef WITH_SMESH_CANCEL_COMPUTE
netgen::multithread.terminate = 0; netgen::multithread.terminate = 0;
#endif #endif
//SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
NETGENPlugin_Mesher mesher(&aMesh, aShape, false); NETGENPlugin_Mesher mesher(&aMesh, aShape, false);
// NETGENPlugin_Mesher mesher(meshDS, aShape, false);
mesher.SetParameters(dynamic_cast<const NETGENPlugin_Hypothesis*>(_hypothesis)); mesher.SetParameters(dynamic_cast<const NETGENPlugin_Hypothesis*>(_hypothesis));
mesher.SetParameters(dynamic_cast<const NETGENPlugin_SimpleHypothesis_2D*>(_hypothesis)); mesher.SetParameters(dynamic_cast<const NETGENPlugin_SimpleHypothesis_2D*>(_hypothesis));
return mesher.Compute(); return mesher.Compute();

View File

@ -87,7 +87,14 @@ NETGENPlugin_NETGEN_2D_ONLY::NETGENPlugin_NETGEN_2D_ONLY(int hypId, int studyId,
_compatibleHypothesis.push_back("MaxElementArea"); _compatibleHypothesis.push_back("MaxElementArea");
_compatibleHypothesis.push_back("LengthFromEdges"); _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"); _compatibleHypothesis.push_back("NETGEN_Parameters_2D");
_hypMaxElementArea = 0; _hypMaxElementArea = 0;
@ -144,6 +151,8 @@ bool NETGENPlugin_NETGEN_2D_ONLY::CheckHypothesis (SMESH_Mesh& aMesh,
_hypLengthFromEdges = static_cast<const StdMeshers_LengthFromEdges*> (hyp); _hypLengthFromEdges = static_cast<const StdMeshers_LengthFromEdges*> (hyp);
else if ( hypName == "NETGEN_Parameters_2D" ) else if ( hypName == "NETGEN_Parameters_2D" )
_hypParameters = static_cast<const NETGENPlugin_Hypothesis_2D*>(hyp); _hypParameters = static_cast<const NETGENPlugin_Hypothesis_2D*>(hyp);
else if ( hypName == "QuadrangleParams" )
_hypQuadranglePreference = hyp;
else { else {
aStatus = HYP_INCOMPATIBLE; aStatus = HYP_INCOMPATIBLE;
return false; return false;

View File

@ -29,7 +29,6 @@
class StdMeshers_MaxElementArea; class StdMeshers_MaxElementArea;
class StdMeshers_LengthFromEdges; class StdMeshers_LengthFromEdges;
class StdMeshers_QuadranglePreference;
class NETGENPlugin_Hypothesis_2D; class NETGENPlugin_Hypothesis_2D;
/*! /*!
@ -63,7 +62,7 @@ public:
protected: protected:
const StdMeshers_MaxElementArea* _hypMaxElementArea; const StdMeshers_MaxElementArea* _hypMaxElementArea;
const StdMeshers_LengthFromEdges* _hypLengthFromEdges; const StdMeshers_LengthFromEdges* _hypLengthFromEdges;
const StdMeshers_QuadranglePreference* _hypQuadranglePreference; const SMESHDS_Hypothesis* _hypQuadranglePreference;
const NETGENPlugin_Hypothesis_2D* _hypParameters; const NETGENPlugin_Hypothesis_2D* _hypParameters;
}; };

View File

@ -47,7 +47,8 @@ NETGENPlugin_SimpleHypothesis_2D::NETGENPlugin_SimpleHypothesis_2D (int
: SMESH_Hypothesis(hypId, studyId, gen), : SMESH_Hypothesis(hypId, studyId, gen),
_nbSegments ((int)NETGENPlugin_Hypothesis::GetDefaultNbSegPerEdge()), _nbSegments ((int)NETGENPlugin_Hypothesis::GetDefaultNbSegPerEdge()),
_segmentLength(0), _segmentLength(0),
_area (0.) _area (0.),
_allowQuad (false)
{ {
_name = "NETGEN_SimpleParameters_2D"; _name = "NETGEN_SimpleParameters_2D";
_param_algo_dim = 2; _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) ostream & NETGENPlugin_SimpleHypothesis_2D::SaveTo(ostream & save)
{ {
save << _nbSegments << " " << _segmentLength << " " << _area; save << _nbSegments << " " << _segmentLength << " " << _area << " " << _allowQuad;
return save; return save;
} }
@ -158,6 +183,8 @@ istream & NETGENPlugin_SimpleHypothesis_2D::LoadFrom(istream & load)
else else
load.clear(ios::badbit | load.rdstate()); load.clear(ios::badbit | load.rdstate());
load >> _allowQuad;
return load; return load;
} }

View File

@ -78,6 +78,15 @@ public:
*/ */
double GetMaxElementArea() const { return _area; } 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 // Persistence
virtual ostream & SaveTo(ostream & save); virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load); virtual istream & LoadFrom(istream & load);
@ -99,6 +108,7 @@ public:
private: private:
int _nbSegments; int _nbSegments;
double _segmentLength, _area; double _segmentLength, _area;
bool _allowQuad;
}; };
#endif #endif

View File

@ -161,12 +161,37 @@ void NETGENPlugin_SimpleHypothesis_2D_i::SetMaxElementArea(CORBA::Double area)
* NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea() * NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea()
*/ */
//============================================================================= //=============================================================================
CORBA::Double NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea() CORBA::Double NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea()
{ {
MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea"); MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea");
ASSERT(myBaseImpl); ASSERT(myBaseImpl);
return this->GetImpl()->GetMaxElementArea(); 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 * NETGENPlugin_SimpleHypothesis_2D_i::GetImpl

View File

@ -62,6 +62,8 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_SimpleHypothesis_2D_i:
void SetMaxElementArea(CORBA::Double area); void SetMaxElementArea(CORBA::Double area);
CORBA::Double GetMaxElementArea(); CORBA::Double GetMaxElementArea();
void SetAllowQuadrangles(CORBA::Boolean toAllow);
CORBA::Boolean GetAllowQuadrangles();
// Get implementation // Get implementation
::NETGENPlugin_SimpleHypothesis_2D* GetImpl(); ::NETGENPlugin_SimpleHypothesis_2D* GetImpl();