Allow local size on any face and solid

This commit is contained in:
eap 2016-08-29 19:14:55 +03:00
parent b6ac276690
commit 8b187bb352
7 changed files with 61 additions and 13 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -59,12 +59,13 @@ but are topologically different.
\image html netgen3d_local_size.png \image html netgen3d_local_size.png
- <b>Local sizes</b> - allows to define size of elements on and - <b>Local sizes</b> - allows to define size of elements on and
around specified geometrical edges and vertices. To define the local around specified geometrical objects. To define the local
size it is necessary to select a geometrical edge or vertex in the size it is necessary to select a geometrical objects in the
object browser or in the viewer, and to click <b>On Edge</b> or <b>On object browser or in the viewer, and to click a button corresponding
Vertex</b> correspondingly. <b>Name</b> of the geometrical object and to the type of the geometrical objects: <b>On Vertex</b>, <b>On
a default <b>Value</b> will be added in the table where the Edge</b> etc. <b>Name</b> of the geometrical object and a
<b>Value</b> can be changed. 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>Remove</b> - deletes a selected row from the table.
\image html netgen2d3d_simple.png \image html netgen2d3d_simple.png

View File

@ -80,6 +80,7 @@ enum {
LSZ_VERTEX_BTN, LSZ_VERTEX_BTN,
LSZ_EDGE_BTN, LSZ_EDGE_BTN,
LSZ_FACE_BTN, LSZ_FACE_BTN,
LSZ_SOLID_BTN,
LSZ_SEPARATOR2, LSZ_SEPARATOR2,
LSZ_REMOVE_BTN LSZ_REMOVE_BTN
}; };
@ -262,6 +263,8 @@ QFrame* NETGENPluginGUI_HypothesisCreator::buildFrame()
localSizeLayout->addWidget(addEdgeButton, LSZ_EDGE_BTN, 1, 1, 1); localSizeLayout->addWidget(addEdgeButton, LSZ_EDGE_BTN, 1, 1, 1);
QPushButton* addFaceButton = new QPushButton(tr("NETGEN_LSZ_FACE"), localSizeGroup); QPushButton* addFaceButton = new QPushButton(tr("NETGEN_LSZ_FACE"), localSizeGroup);
localSizeLayout->addWidget(addFaceButton, LSZ_FACE_BTN, 1, 1, 1); localSizeLayout->addWidget(addFaceButton, LSZ_FACE_BTN, 1, 1, 1);
QPushButton* addSolidButton = new QPushButton(tr("NETGEN_LSZ_SOLID"), localSizeGroup);
localSizeLayout->addWidget(addSolidButton, LSZ_SOLID_BTN, 1, 1, 1);
QFrame *line2 = new QFrame(localSizeGroup); QFrame *line2 = new QFrame(localSizeGroup);
line2->setFrameShape(QFrame::HLine); line2->setFrameShape(QFrame::HLine);
@ -274,6 +277,7 @@ QFrame* NETGENPluginGUI_HypothesisCreator::buildFrame()
connect( addVertexButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnVertex())); connect( addVertexButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnVertex()));
connect( addEdgeButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnEdge())); connect( addEdgeButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnEdge()));
connect( addFaceButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnFace())); connect( addFaceButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnFace()));
connect( addSolidButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnSolid()));
connect( removeButton, SIGNAL(clicked()), this, SLOT(onRemoveLocalSizeOnShape())); connect( removeButton, SIGNAL(clicked()), this, SLOT(onRemoveLocalSizeOnShape()));
connect( myLocalSizeTable, SIGNAL(cellChanged(int, int)), this, SLOT(onSetLocalSize(int, int))); connect( myLocalSizeTable, SIGNAL(cellChanged(int, int)), this, SLOT(onSetLocalSize(int, int)));
@ -638,6 +642,11 @@ void NETGENPluginGUI_HypothesisCreator::onAddLocalSizeOnFace()
addLocalSizeOnShape(TopAbs_FACE); addLocalSizeOnShape(TopAbs_FACE);
} }
void NETGENPluginGUI_HypothesisCreator::onAddLocalSizeOnSolid()
{
addLocalSizeOnShape(TopAbs_SOLID);
}
void NETGENPluginGUI_HypothesisCreator::addLocalSizeOnShape(TopAbs_ShapeEnum typeShapeAsked) void NETGENPluginGUI_HypothesisCreator::addLocalSizeOnShape(TopAbs_ShapeEnum typeShapeAsked)
{ {
NETGENPlugin::NETGENPlugin_Hypothesis_var h = NETGENPlugin::NETGENPlugin_Hypothesis::_narrow(initParamsHypothesis()); NETGENPlugin::NETGENPlugin_Hypothesis_var h = NETGENPlugin::NETGENPlugin_Hypothesis::_narrow(initParamsHypothesis());

View File

@ -80,6 +80,7 @@ protected slots:
virtual void onAddLocalSizeOnVertex(); virtual void onAddLocalSizeOnVertex();
virtual void onAddLocalSizeOnEdge(); virtual void onAddLocalSizeOnEdge();
virtual void onAddLocalSizeOnFace(); virtual void onAddLocalSizeOnFace();
virtual void onAddLocalSizeOnSolid();
virtual void onRemoveLocalSizeOnShape(); virtual void onRemoveLocalSizeOnShape();
virtual void onSetLocalSize(int,int); virtual void onSetLocalSize(int,int);

View File

@ -137,7 +137,11 @@
</message> </message>
<message> <message>
<source>NETGEN_LSZ_FACE</source> <source>NETGEN_LSZ_FACE</source>
<translation>On Sub-Face</translation> <translation>On Face</translation>
</message>
<message>
<source>NETGEN_LSZ_SOLID</source>
<translation>On Solid</translation>
</message> </message>
<message> <message>
<source>NETGEN_LSZ_REMOVE</source> <source>NETGEN_LSZ_REMOVE</source>

View File

@ -137,7 +137,11 @@
</message> </message>
<message> <message>
<source>NETGEN_LSZ_FACE</source> <source>NETGEN_LSZ_FACE</source>
<translation>Sur une sous-face</translation> <translation>Sur une face</translation>
</message>
<message>
<source>NETGEN_LSZ_SOLID</source>
<translation>Sur une solide</translation>
</message> </message>
<message> <message>
<source>NETGEN_LSZ_REMOVE</source> <source>NETGEN_LSZ_REMOVE</source>

View File

@ -39,6 +39,7 @@
#include <SMESH_Block.hxx> #include <SMESH_Block.hxx>
#include <SMESH_Comment.hxx> #include <SMESH_Comment.hxx>
#include <SMESH_ComputeError.hxx> #include <SMESH_ComputeError.hxx>
#include <SMESH_ControlPnt.hxx>
#include <SMESH_File.hxx> #include <SMESH_File.hxx>
#include <SMESH_Gen_i.hxx> #include <SMESH_Gen_i.hxx>
#include <SMESH_Mesh.hxx> #include <SMESH_Mesh.hxx>
@ -120,6 +121,7 @@ TopTools_IndexedMapOfShape ShapesWithLocalSize;
std::map<int,double> VertexId2LocalSize; std::map<int,double> VertexId2LocalSize;
std::map<int,double> EdgeId2LocalSize; std::map<int,double> EdgeId2LocalSize;
std::map<int,double> FaceId2LocalSize; std::map<int,double> FaceId2LocalSize;
std::map<int,double> SolidId2LocalSize;
//============================================================================= //=============================================================================
/*! /*!
@ -149,6 +151,7 @@ NETGENPlugin_Mesher::NETGENPlugin_Mesher (SMESH_Mesh* mesh,
VertexId2LocalSize.clear(); VertexId2LocalSize.clear();
EdgeId2LocalSize.clear(); EdgeId2LocalSize.clear();
FaceId2LocalSize.clear(); FaceId2LocalSize.clear();
SolidId2LocalSize.clear();
} }
//================================================================================ //================================================================================
@ -240,6 +243,8 @@ void SetLocalSize(TopoDS_Shape GeomShape, double LocalSize)
EdgeId2LocalSize[key] = LocalSize; EdgeId2LocalSize[key] = LocalSize;
} else if (GeomType == TopAbs_FACE) { } else if (GeomType == TopAbs_FACE) {
FaceId2LocalSize[key] = LocalSize; FaceId2LocalSize[key] = LocalSize;
} else if (GeomType == TopAbs_SOLID) {
SolidId2LocalSize[key] = LocalSize;
} }
} }
@ -2555,16 +2560,40 @@ bool NETGENPlugin_Mesher::Compute()
gp_Pnt p = BRep_Tool::Pnt(v); gp_Pnt p = BRep_Tool::Pnt(v);
NETGENPlugin_Mesher::RestrictLocalSize( *_ngMesh, p.XYZ(), hi ); NETGENPlugin_Mesher::RestrictLocalSize( *_ngMesh, p.XYZ(), hi );
} }
for(map<int,double>::const_iterator it=FaceId2LocalSize.begin(); for(map<int,double>::const_iterator it=FaceId2LocalSize.begin(); it!=FaceId2LocalSize.end(); it++)
it!=FaceId2LocalSize.end(); it++)
{ {
int key = (*it).first; int key = (*it).first;
double val = (*it).second; double val = (*it).second;
const TopoDS_Shape& shape = ShapesWithLocalSize.FindKey(key); const TopoDS_Shape& shape = ShapesWithLocalSize.FindKey(key);
int faceNgID = occgeo.fmap.FindIndex(shape); int faceNgID = occgeo.fmap.FindIndex(shape);
occgeo.SetFaceMaxH(faceNgID, val); if ( faceNgID >= 1 )
for ( TopExp_Explorer edgeExp( shape, TopAbs_EDGE ); edgeExp.More(); edgeExp.Next() ) {
setLocalSize( TopoDS::Edge( edgeExp.Current() ), val, *_ngMesh ); occgeo.SetFaceMaxH(faceNgID, val);
for ( TopExp_Explorer edgeExp( shape, TopAbs_EDGE ); edgeExp.More(); edgeExp.Next() )
setLocalSize( TopoDS::Edge( edgeExp.Current() ), val, *_ngMesh );
}
else
{
std::vector<SMESHUtils::ControlPnt> pnt;
SMESHUtils::createPointsSampleFromFace( TopoDS::Face( shape ), val, pnt );
if ( !pnt.empty() )
NETGENPlugin_Mesher::RestrictLocalSize( *_ngMesh, pnt[0].XYZ(), val );
for ( size_t i = 1; i < pnt.size(); ++i )
_ngMesh->RestrictLocalH( netgen::Point3d( pnt[i].X(), pnt[i].Y(), pnt[i].Z() ), val );
}
}
for(map<int,double>::const_iterator it=SolidId2LocalSize.begin(); it!=SolidId2LocalSize.end(); it++)
{
int key = (*it).first;
double val = (*it).second;
const TopoDS_Shape& shape = ShapesWithLocalSize.FindKey(key);
std::vector<SMESHUtils::ControlPnt> pnt;
SMESHUtils::createPointsSampleFromSolid( TopoDS::Solid( shape ), val, pnt );
if ( !pnt.empty() )
NETGENPlugin_Mesher::RestrictLocalSize( *_ngMesh, pnt[0].XYZ(), val );
for ( size_t i = 1; i < pnt.size(); ++i )
_ngMesh->RestrictLocalH( netgen::Point3d( pnt[i].X(), pnt[i].Y(), pnt[i].Z() ), val );
} }
} }