]> SALOME platform Git repositories - plugins/netgenplugin.git/commitdiff
Salome HOME
Allow local size on any face and solid
authoreap <eap@opencascade.com>
Mon, 29 Aug 2016 16:14:55 +0000 (19:14 +0300)
committereap <eap@opencascade.com>
Mon, 29 Aug 2016 16:14:55 +0000 (19:14 +0300)
doc/salome/gui/NETGENPLUGIN/images/netgen3d_local_size.png
doc/salome/gui/NETGENPLUGIN/input/netgen_2d_3d_hypo.doc
src/GUI/NETGENPluginGUI_HypothesisCreator.cxx
src/GUI/NETGENPluginGUI_HypothesisCreator.h
src/GUI/NETGENPlugin_msg_en.ts
src/GUI/NETGENPlugin_msg_fr.ts
src/NETGENPlugin/NETGENPlugin_Mesher.cxx

index b93e4b0d070039e77972fe2dd6b2a6b8e07f423e..1bac778f08f44cd07152b28c491d7eb31ef020eb 100644 (file)
Binary files a/doc/salome/gui/NETGENPLUGIN/images/netgen3d_local_size.png and b/doc/salome/gui/NETGENPLUGIN/images/netgen3d_local_size.png differ
index fc69e0ca5a1b0a24a2d9b65e6f50bb7afb5771b8..30ea99329b9367931b18a20d1515ba51b608300b 100644 (file)
@@ -59,12 +59,13 @@ but are topologically different.
 \image html netgen3d_local_size.png
 
 - <b>Local sizes</b> - 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 <b>On Edge</b> or <b>On
-Vertex</b> correspondingly. <b>Name</b> of the geometrical object and
-a default <b>Value</b> will be added in the table where the
-<b>Value</b> 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: <b>On Vertex</b>, <b>On
+  Edge</b> etc. <b>Name</b> of the geometrical object and a
+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.
 
 \image html netgen2d3d_simple.png
index 8d5924e26a642d013e36f4761fae205c0a6665e8..f2c685fe011a465f417c52a08a0dc8584ef8fef3 100644 (file)
@@ -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());
index cb7bd634768195657ca3c5ef72f3aff2605b3623..24ca59c767bf2784d87e3200c4795bae320ac39a 100644 (file)
@@ -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);
 
index 0f0d22137344b1531f6eccab45a76381e60bfa43..d7263d55ba87babfebe7c3123814ea1ac4fe612f 100644 (file)
     </message>
     <message>
         <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>
         <source>NETGEN_LSZ_REMOVE</source>
index f505467fcc98d011ca0f64f85ac76abaa1a76537..80206f1ae000d26b62c26ee3af5352735413c931 100755 (executable)
     </message>
     <message>
         <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>
         <source>NETGEN_LSZ_REMOVE</source>
index a1482021f7a694d1716688ea404d4603b890be16..9f562314f066d278690363769334a17e7656a962 100644 (file)
@@ -39,6 +39,7 @@
 #include <SMESH_Block.hxx>
 #include <SMESH_Comment.hxx>
 #include <SMESH_ComputeError.hxx>
+#include <SMESH_ControlPnt.hxx>
 #include <SMESH_File.hxx>
 #include <SMESH_Gen_i.hxx>
 #include <SMESH_Mesh.hxx>
@@ -120,6 +121,7 @@ TopTools_IndexedMapOfShape ShapesWithLocalSize;
 std::map<int,double> VertexId2LocalSize;
 std::map<int,double> EdgeId2LocalSize;
 std::map<int,double> FaceId2LocalSize;
+std::map<int,double> 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<int,double>::const_iterator it=FaceId2LocalSize.begin();
-          it!=FaceId2LocalSize.end(); it++)
+      for(map<int,double>::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<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 );
       }
     }