From: eap Date: Mon, 29 Aug 2016 16:14:55 +0000 (+0300) Subject: Allow local size on any face and solid X-Git-Tag: V8_1_0rc1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8b187bb3528051a0f98a15761bca27ce7eef0c1a;p=plugins%2Fnetgenplugin.git Allow local size on any face and solid --- diff --git a/doc/salome/gui/NETGENPLUGIN/images/netgen3d_local_size.png b/doc/salome/gui/NETGENPLUGIN/images/netgen3d_local_size.png index b93e4b0..1bac778 100644 Binary files a/doc/salome/gui/NETGENPLUGIN/images/netgen3d_local_size.png and b/doc/salome/gui/NETGENPLUGIN/images/netgen3d_local_size.png differ diff --git a/doc/salome/gui/NETGENPLUGIN/input/netgen_2d_3d_hypo.doc b/doc/salome/gui/NETGENPLUGIN/input/netgen_2d_3d_hypo.doc index fc69e0c..30ea993 100644 --- a/doc/salome/gui/NETGENPLUGIN/input/netgen_2d_3d_hypo.doc +++ b/doc/salome/gui/NETGENPLUGIN/input/netgen_2d_3d_hypo.doc @@ -59,12 +59,13 @@ but are topologically different. \image html netgen3d_local_size.png - Local sizes - allows to define size of elements on and -around specified geometrical edges and vertices. To define the local -size it is necessary to select a geometrical edge or vertex in the -object browser or in the viewer, and to click On Edge or On -Vertex correspondingly. Name of the geometrical object and -a default Value will be added in the table where the -Value can be changed. +around specified geometrical objects. To define the local +size it is necessary to select a geometrical objects in the +object browser or in the viewer, and to click a button corresponding +to the type of the geometrical objects: On Vertex, On + Edge etc. Name of the geometrical object and a +default Value will be added in the table where the Value +can be changed. - Remove - deletes a selected row from the table. \image html netgen2d3d_simple.png diff --git a/src/GUI/NETGENPluginGUI_HypothesisCreator.cxx b/src/GUI/NETGENPluginGUI_HypothesisCreator.cxx index 8d5924e..f2c685f 100644 --- a/src/GUI/NETGENPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/NETGENPluginGUI_HypothesisCreator.cxx @@ -80,6 +80,7 @@ enum { LSZ_VERTEX_BTN, LSZ_EDGE_BTN, LSZ_FACE_BTN, + LSZ_SOLID_BTN, LSZ_SEPARATOR2, LSZ_REMOVE_BTN }; @@ -262,6 +263,8 @@ QFrame* NETGENPluginGUI_HypothesisCreator::buildFrame() localSizeLayout->addWidget(addEdgeButton, LSZ_EDGE_BTN, 1, 1, 1); QPushButton* addFaceButton = new QPushButton(tr("NETGEN_LSZ_FACE"), localSizeGroup); 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); line2->setFrameShape(QFrame::HLine); @@ -274,6 +277,7 @@ QFrame* NETGENPluginGUI_HypothesisCreator::buildFrame() connect( addVertexButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnVertex())); connect( addEdgeButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnEdge())); connect( addFaceButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnFace())); + 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))); @@ -638,6 +642,11 @@ void NETGENPluginGUI_HypothesisCreator::onAddLocalSizeOnFace() addLocalSizeOnShape(TopAbs_FACE); } +void NETGENPluginGUI_HypothesisCreator::onAddLocalSizeOnSolid() +{ + addLocalSizeOnShape(TopAbs_SOLID); +} + void NETGENPluginGUI_HypothesisCreator::addLocalSizeOnShape(TopAbs_ShapeEnum typeShapeAsked) { NETGENPlugin::NETGENPlugin_Hypothesis_var h = NETGENPlugin::NETGENPlugin_Hypothesis::_narrow(initParamsHypothesis()); diff --git a/src/GUI/NETGENPluginGUI_HypothesisCreator.h b/src/GUI/NETGENPluginGUI_HypothesisCreator.h index cb7bd63..24ca59c 100644 --- a/src/GUI/NETGENPluginGUI_HypothesisCreator.h +++ b/src/GUI/NETGENPluginGUI_HypothesisCreator.h @@ -80,6 +80,7 @@ protected slots: virtual void onAddLocalSizeOnVertex(); virtual void onAddLocalSizeOnEdge(); virtual void onAddLocalSizeOnFace(); + virtual void onAddLocalSizeOnSolid(); virtual void onRemoveLocalSizeOnShape(); virtual void onSetLocalSize(int,int); diff --git a/src/GUI/NETGENPlugin_msg_en.ts b/src/GUI/NETGENPlugin_msg_en.ts index 0f0d221..d7263d5 100644 --- a/src/GUI/NETGENPlugin_msg_en.ts +++ b/src/GUI/NETGENPlugin_msg_en.ts @@ -137,7 +137,11 @@ NETGEN_LSZ_FACE - On Sub-Face + On Face + + + NETGEN_LSZ_SOLID + On Solid NETGEN_LSZ_REMOVE diff --git a/src/GUI/NETGENPlugin_msg_fr.ts b/src/GUI/NETGENPlugin_msg_fr.ts index f505467..80206f1 100755 --- a/src/GUI/NETGENPlugin_msg_fr.ts +++ b/src/GUI/NETGENPlugin_msg_fr.ts @@ -137,7 +137,11 @@ NETGEN_LSZ_FACE - Sur une sous-face + Sur une face + + + NETGEN_LSZ_SOLID + Sur une solide NETGEN_LSZ_REMOVE diff --git a/src/NETGENPlugin/NETGENPlugin_Mesher.cxx b/src/NETGENPlugin/NETGENPlugin_Mesher.cxx index a148202..9f56231 100644 --- a/src/NETGENPlugin/NETGENPlugin_Mesher.cxx +++ b/src/NETGENPlugin/NETGENPlugin_Mesher.cxx @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -120,6 +121,7 @@ TopTools_IndexedMapOfShape ShapesWithLocalSize; std::map VertexId2LocalSize; std::map EdgeId2LocalSize; std::map FaceId2LocalSize; +std::map SolidId2LocalSize; //============================================================================= /*! @@ -149,6 +151,7 @@ NETGENPlugin_Mesher::NETGENPlugin_Mesher (SMESH_Mesh* mesh, VertexId2LocalSize.clear(); EdgeId2LocalSize.clear(); FaceId2LocalSize.clear(); + SolidId2LocalSize.clear(); } //================================================================================ @@ -240,6 +243,8 @@ void SetLocalSize(TopoDS_Shape GeomShape, double LocalSize) EdgeId2LocalSize[key] = LocalSize; } else if (GeomType == TopAbs_FACE) { 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); NETGENPlugin_Mesher::RestrictLocalSize( *_ngMesh, p.XYZ(), hi ); } - for(map::const_iterator it=FaceId2LocalSize.begin(); - it!=FaceId2LocalSize.end(); it++) + for(map::const_iterator it=FaceId2LocalSize.begin(); it!=FaceId2LocalSize.end(); it++) { int key = (*it).first; double val = (*it).second; const TopoDS_Shape& shape = ShapesWithLocalSize.FindKey(key); int faceNgID = occgeo.fmap.FindIndex(shape); - occgeo.SetFaceMaxH(faceNgID, val); - for ( TopExp_Explorer edgeExp( shape, TopAbs_EDGE ); edgeExp.More(); edgeExp.Next() ) - setLocalSize( TopoDS::Edge( edgeExp.Current() ), val, *_ngMesh ); + if ( faceNgID >= 1 ) + { + 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 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::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 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 ); } }