Salome HOME
Add possibility to define Local Size via a file
authoreap <eap@opencascade.com>
Fri, 7 Oct 2016 14:49:45 +0000 (17:49 +0300)
committereap <eap@opencascade.com>
Fri, 7 Oct 2016 14:49:45 +0000 (17:49 +0300)
16 files changed:
doc/salome/gui/NETGENPLUGIN/images/netgen3d_local_size.png
doc/salome/gui/NETGENPLUGIN/input/netgen_2d_3d_hypo.doc
idl/NETGENPlugin_Algorithm.idl
src/GUI/NETGENPluginGUI_HypothesisCreator.cxx
src/GUI/NETGENPluginGUI_HypothesisCreator.h
src/GUI/NETGENPlugin_msg_en.ts
src/NETGENPlugin/NETGENPluginBuilder.py
src/NETGENPlugin/NETGENPlugin_Hypothesis.cxx
src/NETGENPlugin/NETGENPlugin_Hypothesis.hxx
src/NETGENPlugin/NETGENPlugin_Hypothesis_2D_i.cxx
src/NETGENPlugin/NETGENPlugin_Hypothesis_i.cxx
src/NETGENPlugin/NETGENPlugin_Hypothesis_i.hxx
src/NETGENPlugin/NETGENPlugin_Mesher.cxx
src/NETGENPlugin/NETGENPlugin_Mesher.hxx
src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx
src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx

index 1bac778f08f44cd07152b28c491d7eb31ef020eb..efc53ff34d76418427de4041c5c56c5de38d7e76 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 ff7555a734f816dc5c6a12ae596ff7b1cf2f79a5..4ef8e066a9f1e7165878bc60a9607134a946b670 100644 (file)
@@ -67,6 +67,25 @@ to the type of the geometrical objects: <b>On Vertex</b>, <b>On
 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>Mesh-size File</b> - opens a dialog to select a file defining
+size of elements. The file includes two obligatory sections. The first
+section defines the size at points. The second section defines the
+size along lines. Let's consider the following sample size file.
+\code
+2
+92.5 92.5 92.5 0.05
+42.5 42.5 42.5 0.04
+1
+25 25 0 25 25 200  0.3
+\endcode
+"2" at the first line means that there are two points in the first
+section.<br>
+"92.5 92.5 92.5 0.05" at the second line means that at the point with
+coordinates (92.5, 92.5, 92.5) size of elements should be 0.05.<br>
+"1" at the fourth line means that there is one line in the second
+section.<br>
+"25 25 0 25 25 200  0.3" means that along the line between points (25,
+25, 0) and (25, 25, 200) size of elements should be 0.3.
 
 \image html netgen2d3d_simple.png
 
index e18a1285a2232ecb280e866085460ef335da9c23..5a0b25280cbb33a286a4c90a691b3f042da7d5e2 100644 (file)
@@ -110,6 +110,9 @@ module NETGENPlugin
     double GetLocalSizeOnEntry(in string entry);
     string_array GetLocalSizeEntries();
     void UnsetLocalSizeOnEntry(in string entry);
+
+    void SetMeshSizeFile(in string fileName);
+    string GetMeshSizeFile();
   };
 
   /*!
index e5bb0aae1f479e1ff4706a399cccf654c415acb8..2db7d1ed1775ce88dceba43cd7cde7122bdbd8b5 100644 (file)
@@ -34,8 +34,9 @@
 
 #include CORBA_SERVER_HEADER(NETGENPlugin_Algorithm)
 
-#include <SUIT_Session.h>
+#include <SUIT_FileDlg.h>
 #include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
 
 #include <SalomeApp_Tools.h>
 #include <LightApp_SelectionMgr.h>
@@ -82,7 +83,8 @@ enum {
   LSZ_FACE_BTN,
   LSZ_SOLID_BTN,
   LSZ_SEPARATOR2,
-  LSZ_REMOVE_BTN
+  LSZ_REMOVE_BTN,
+  LSZ_FILE_LE = 9
 };
 
 NETGENPluginGUI_HypothesisCreator::NETGENPluginGUI_HypothesisCreator( const QString& theHypType )
@@ -242,7 +244,7 @@ QFrame* NETGENPluginGUI_HypothesisCreator::buildFrame()
     QGridLayout* localSizeLayout = new QGridLayout(localSizeGroup);
 
     myLocalSizeTable = new QTableWidget(0, LSZ_NB_COLUMNS, localSizeGroup);
-    localSizeLayout->addWidget(myLocalSizeTable, 1, 0, 8, 1);
+    localSizeLayout->addWidget(myLocalSizeTable, 1, 0, 8, 2);
     QStringList localSizeHeaders;
     localSizeHeaders << tr( "LSZ_ENTRY_COLUMN" )<< tr( "LSZ_NAME_COLUMN" ) << tr( "LSZ_LOCALSIZE_COLUMN" );
     myLocalSizeTable->setHorizontalHeaderLabels(localSizeHeaders);
@@ -258,21 +260,27 @@ QFrame* NETGENPluginGUI_HypothesisCreator::buildFrame()
     myLocalSizeTable->verticalHeader()->hide();
 
     QPushButton* addVertexButton = new QPushButton(tr("NETGEN_LSZ_VERTEX"), localSizeGroup);
-    localSizeLayout->addWidget(addVertexButton, LSZ_VERTEX_BTN, 1, 1, 1);
+    localSizeLayout->addWidget(addVertexButton, LSZ_VERTEX_BTN, 2, 1, 1);
     QPushButton* addEdgeButton = new QPushButton(tr("NETGEN_LSZ_EDGE"), localSizeGroup);
-    localSizeLayout->addWidget(addEdgeButton, LSZ_EDGE_BTN, 1, 1, 1);
+    localSizeLayout->addWidget(addEdgeButton, LSZ_EDGE_BTN, 2, 1, 1);
     QPushButton* addFaceButton = new QPushButton(tr("NETGEN_LSZ_FACE"), localSizeGroup);
-    localSizeLayout->addWidget(addFaceButton, LSZ_FACE_BTN, 1, 1, 1);
+    localSizeLayout->addWidget(addFaceButton, LSZ_FACE_BTN, 2, 1, 1);
     QPushButton* addSolidButton = new QPushButton(tr("NETGEN_LSZ_SOLID"), localSizeGroup);
-    localSizeLayout->addWidget(addSolidButton, LSZ_SOLID_BTN, 1, 1, 1);
+    localSizeLayout->addWidget(addSolidButton, LSZ_SOLID_BTN, 2, 1, 1);
 
     QFrame *line2 = new QFrame(localSizeGroup);
     line2->setFrameShape(QFrame::HLine);
     line2->setFrameShadow(QFrame::Sunken);
-    localSizeLayout->addWidget(line2, LSZ_SEPARATOR2, 1, 1, 1);
+    localSizeLayout->addWidget(line2, LSZ_SEPARATOR2, 2, 1, 1);
 
     QPushButton* removeButton = new QPushButton(tr("NETGEN_LSZ_REMOVE"), localSizeGroup);
-    localSizeLayout->addWidget(removeButton, LSZ_REMOVE_BTN, 1, 1, 1);
+    localSizeLayout->addWidget(removeButton, LSZ_REMOVE_BTN, 2, 1, 1);
+
+    QPushButton* fileBtn = new QPushButton(tr("NETGEN_LSZ_FILE"), localSizeGroup);
+    myMeshSizeFile = new QLineEdit(localSizeGroup);
+    myMeshSizeFile->setReadOnly( true );
+    localSizeLayout->addWidget( fileBtn, LSZ_FILE_LE, 0, 1, 1);
+    localSizeLayout->addWidget( myMeshSizeFile, LSZ_FILE_LE, 1, 1, 2);
 
     connect( addVertexButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnVertex()));
     connect( addEdgeButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnEdge()));
@@ -280,6 +288,7 @@ QFrame* NETGENPluginGUI_HypothesisCreator::buildFrame()
     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)));
+    connect( fileBtn, SIGNAL(clicked()), this, SLOT(onSetSizeFile()));
 
     tab->insertTab(LSZ_TAB, localSizeGroup, tr("NETGEN_LOCAL_SIZE"));
   }
@@ -327,7 +336,7 @@ void NETGENPluginGUI_HypothesisCreator::retrieveParams() const
       myNbSegPerRadius->setValue( data.myNbSegPerRadius );
     else
       myNbSegPerRadius->setText( data.myNbSegPerRadiusVar );
-  }  
+  }
   if (myAllowQuadrangles)
     myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
 
@@ -361,6 +370,8 @@ void NETGENPluginGUI_HypothesisCreator::retrieveParams() const
     }
     myLocalSizeTable->resizeColumnToContents(LSZ_NAME_COLUMN);
     myLocalSizeTable->resizeColumnToContents(LSZ_LOCALSIZE_COLUMN);
+
+    myMeshSizeFile->setText( data.myMeshSizeFile );
   }
 }
 
@@ -369,7 +380,7 @@ QString NETGENPluginGUI_HypothesisCreator::storeParams() const
   NetgenHypothesisData data;
   readParamsFromWidgets( data );
   storeParamsToHypo( data );
-  
+
   QString valStr = tr("NETGEN_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; ";
   valStr += tr("NETGEN_MIN_SIZE") + " = " + QString::number( data.myMinSize ) + "; ";
   if ( data.mySecondOrder )
@@ -377,12 +388,12 @@ QString NETGENPluginGUI_HypothesisCreator::storeParams() const
   if ( data.myOptimize )
     valStr +=  tr("NETGEN_OPTIMIZE") + "; ";
   valStr += myFineness->currentText() + "(" +  QString::number( data.myGrowthRate )     + ", " +
-                                               QString::number( data.myNbSegPerEdge )   + ", " +
-                                               QString::number( data.myNbSegPerRadius ) + ")";
+    QString::number( data.myNbSegPerEdge )   + ", " +
+    QString::number( data.myNbSegPerRadius ) + ")";
 
   if ( myIs2D && data.myAllowQuadrangles )
     valStr += "; " + tr("NETGEN_ALLOW_QUADRANGLES");
-  
+
   if ( data.mySurfaceCurvature )
     valStr += "; " + tr("NETGEN_SURFACE_CURVATURE");
 
@@ -416,34 +427,35 @@ bool NETGENPluginGUI_HypothesisCreator::readParamsFromHypo( NetgenHypothesisData
   h_data.myMinSizeVar = getVariableName("SetMinSize");
   h_data.mySurfaceCurvature = h->GetUseSurfaceCurvature();
   h_data.myFuseEdges = h->GetFuseEdges();
+  h_data.myMeshSizeFile = h->GetMeshSizeFile();
 
   //if ( myIs2D )
-    {
-      NETGENPlugin::NETGENPlugin_Hypothesis_var h =
-        NETGENPlugin::NETGENPlugin_Hypothesis::_narrow( initParamsHypothesis() );
+  {
+    NETGENPlugin::NETGENPlugin_Hypothesis_var h =
+      NETGENPlugin::NETGENPlugin_Hypothesis::_narrow( initParamsHypothesis() );
+
+    if ( !h->_is_nil() )
+      h_data.myAllowQuadrangles = h->GetQuadAllowed();
+  }
 
-      if ( !h->_is_nil() )
-        h_data.myAllowQuadrangles = h->GetQuadAllowed();
-    }
-  
   NETGENPluginGUI_HypothesisCreator*  that = (NETGENPluginGUI_HypothesisCreator*)this;
   NETGENPlugin::string_array_var myEntries = h->GetLocalSizeEntries();
   for ( size_t i = 0; i < myEntries->length(); i++ )
+  {
+    QString entry = myEntries[i].in();
+    double val = h->GetLocalSizeOnEntry(entry.toStdString().c_str());
+    std::ostringstream tmp;
+    tmp << val;
+    QString valstring = QString::fromStdString(tmp.str());
+    if (myLocalSizeMap.contains(entry))
     {
-      QString entry = myEntries[i].in();
-      double val = h->GetLocalSizeOnEntry(entry.toStdString().c_str());
-      std::ostringstream tmp;
-      tmp << val;
-      QString valstring = QString::fromStdString(tmp.str());
-      if (myLocalSizeMap.contains(entry))
-        {
-          if (myLocalSizeMap[entry] == "__TO_DELETE__")
-            {
-              continue;
-            }
-        }
-      that->myLocalSizeMap[entry] = valstring;
+      if (myLocalSizeMap[entry] == "__TO_DELETE__")
+      {
+        continue;
+      }
     }
+    that->myLocalSizeMap[entry] = valstring;
+  }
 
   return true;
 }
@@ -466,28 +478,29 @@ bool NETGENPluginGUI_HypothesisCreator::storeParamsToHypo( const NetgenHypothesi
     h->SetFineness    ( fineness );
 
     if( fineness==UserDefined )
-      {
-        h->SetVarParameter  ( h_data.myGrowthRateVar.toLatin1().constData(), "SetGrowthRate");
-        h->SetGrowthRate    ( h_data.myGrowthRate );
-        h->SetVarParameter  ( h_data.myNbSegPerEdgeVar.toLatin1().constData(), "SetNbSegPerEdge");
-        h->SetNbSegPerEdge  ( h_data.myNbSegPerEdge );
-        h->SetVarParameter  ( h_data.myNbSegPerRadiusVar.toLatin1().constData(), "SetNbSegPerRadius");
-        h->SetNbSegPerRadius( h_data.myNbSegPerRadius );
-      }
+    {
+      h->SetVarParameter  ( h_data.myGrowthRateVar.toLatin1().constData(), "SetGrowthRate");
+      h->SetGrowthRate    ( h_data.myGrowthRate );
+      h->SetVarParameter  ( h_data.myNbSegPerEdgeVar.toLatin1().constData(), "SetNbSegPerEdge");
+      h->SetNbSegPerEdge  ( h_data.myNbSegPerEdge );
+      h->SetVarParameter  ( h_data.myNbSegPerRadiusVar.toLatin1().constData(), "SetNbSegPerRadius");
+      h->SetNbSegPerRadius( h_data.myNbSegPerRadius );
+    }
     h->SetVarParameter       ( h_data.myMinSizeVar.toLatin1().constData(), "SetMinSize");
     h->SetMinSize            ( h_data.myMinSize );
     h->SetUseSurfaceCurvature( h_data.mySurfaceCurvature );
     h->SetFuseEdges          ( h_data.myFuseEdges );
-    
+    h->SetMeshSizeFile       ( h_data.myMeshSizeFile.toUtf8().constData() );
+
     //if ( myIs2D )
-      {
-        // NETGENPlugin::NETGENPlugin_Hypothesis_2D_var h_2d =
-        //   NETGENPlugin::NETGENPlugin_Hypothesis_2D::_narrow( h );
-        
-        // if ( !h_2d->_is_nil() )
-        //   h_2d->SetQuadAllowed( h_data.myAllowQuadrangles );
-        h->SetQuadAllowed( h_data.myAllowQuadrangles );
-      }
+    {
+      // NETGENPlugin::NETGENPlugin_Hypothesis_2D_var h_2d =
+      //   NETGENPlugin::NETGENPlugin_Hypothesis_2D::_narrow( h );
+
+      // if ( !h_2d->_is_nil() )
+      //   h_2d->SetQuadAllowed( h_data.myAllowQuadrangles );
+      h->SetQuadAllowed( h_data.myAllowQuadrangles );
+    }
 
     QMapIterator<QString,QString> i(myLocalSizeMap);
     while (i.hasNext()) {
@@ -495,16 +508,16 @@ bool NETGENPluginGUI_HypothesisCreator::storeParamsToHypo( const NetgenHypothesi
       const QString entry = i.key();
       const QString localSize = i.value();
       if (localSize == "__TO_DELETE__")
-        {
-          h->UnsetLocalSizeOnEntry(entry.toLatin1().constData());
-        }
+      {
+        h->UnsetLocalSizeOnEntry(entry.toLatin1().constData());
+      }
       else
-        {
-          std::istringstream tmp(localSize.toLatin1().constData());
-          double val;
-          tmp >> val;
-          h->SetLocalSizeOnEntry(entry.toLatin1().constData(), val);
-        }
+      {
+        std::istringstream tmp(localSize.toLatin1().constData());
+        double val;
+        tmp >> val;
+        h->SetLocalSizeOnEntry(entry.toLatin1().constData(), val);
+      }
     }
   }
   catch(const SALOME::SALOME_Exception& ex)
@@ -559,6 +572,7 @@ bool NETGENPluginGUI_HypothesisCreator::readParamsFromWidgets( NetgenHypothesisD
       QString localSize = myLocalSizeTable->item(row, LSZ_LOCALSIZE_COLUMN)->text().trimmed();
       that->myLocalSizeMap[entry] = localSize;
     }
+    h_data.myMeshSizeFile = myMeshSizeFile->text();
   }
   return true;
 }
@@ -744,6 +758,13 @@ void NETGENPluginGUI_HypothesisCreator::onSetLocalSize(int row,int col)
   }
 }
 
+void NETGENPluginGUI_HypothesisCreator::onSetSizeFile()
+{
+  QString dir = SUIT_FileDlg::getFileName( dlg(), QString(),
+                                           QStringList() << tr( "ALL_FILES_FILTER" ) + "  (*)");
+  myMeshSizeFile->setText( dir );
+}
+
 GeomSelectionTools* NETGENPluginGUI_HypothesisCreator::getGeomSelectionTools()
 {
   _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
index 24ca59c767bf2784d87e3200c4795bae320ac39a..64a1616f60fe0574ea38e6c87cdf267bd457d045 100644 (file)
@@ -47,7 +47,7 @@ typedef struct
   double              myMaxSize, myMinSize, myGrowthRate, myNbSegPerEdge, myNbSegPerRadius;
   int                 myFineness;
   bool                mySecondOrder, myAllowQuadrangles, myOptimize, mySurfaceCurvature, myFuseEdges;
-  QString             myName;
+  QString             myName, myMeshSizeFile;
   QString             myMaxSizeVar, myMinSizeVar, myGrowthRateVar, myNbSegPerEdgeVar, myNbSegPerRadiusVar;
 } NetgenHypothesisData;
 
@@ -83,6 +83,7 @@ protected slots:
   virtual void     onAddLocalSizeOnSolid();
   virtual void     onRemoveLocalSizeOnShape();
   virtual void     onSetLocalSize(int,int);
+  virtual void     onSetSizeFile();
 
 private:
   bool readParamsFromHypo( NetgenHypothesisData& ) const;
@@ -108,8 +109,9 @@ private:
  bool myIs2D;
  bool myIsONLY;
 
- QTableWidget* myLocalSizeTable;
- GeomSelectionTools* myGeomSelectionTools;
+ QLineEdit*             myMeshSizeFile;
+ QTableWidget*          myLocalSizeTable;
+ GeomSelectionTools*    myGeomSelectionTools;
  QMap<QString, QString> myLocalSizeMap;
 };
 
index c90b5044f5b073b75c42fe994cb9dfa4f301c485..139fb85280c2e7bc6455b68ba369fce260bfdb55 100644 (file)
         <source>LSZ_LOCALSIZE_COLUMN</source>
         <translation>Value</translation>
     </message>
+    <message>
+        <source>NETGEN_LSZ_FILE</source>
+        <translation>Mesh-size File</translation>
+    </message>
 </context>
 </TS>
index 39c5a70473fa733a52574cc18a3d10afe532fe00..d5f9460d588489a986fc1e477dbe0ad326026e84 100644 (file)
@@ -169,6 +169,12 @@ class NETGEN_Algorithm(Mesh_Algorithm):
 
         return self.params
 
+    ## Defines a file specifying size of elements at points and lines
+    #  @param file name of the file
+    def SetMeshSizeFile(self, file):
+        self.Parameters().SetMeshSizeFile(file)
+        pass
+
     pass # end of NETGEN_Algorithm class
 
 
index 42ea851db7469ddb1808dfcb15944b342e9c4ec2..fe4c2eeae63b139c4a7459ef02af4ecccac5212e 100644 (file)
@@ -247,6 +247,20 @@ void NETGENPlugin_Hypothesis::UnsetLocalSizeOnEntry(const std::string& entry)
   NotifySubMeshesHypothesisModification();
 }
 
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+void NETGENPlugin_Hypothesis::SetMeshSizeFile(const std::string& fileName)
+{
+  if ( fileName != _meshSizeFile )
+  {
+    _meshSizeFile = fileName;
+    NotifySubMeshesHypothesisModification();
+  }
+}
+
 //=============================================================================
 /*!
  *  
@@ -347,6 +361,8 @@ ostream & NETGENPlugin_Hypothesis::SaveTo(ostream & save)
   save << " " << _surfaceCurvature;
   save << " " << _fuseEdges;
 
+  save << " " << _meshSizeFile.size() << " " << _meshSizeFile;
+
   return save;
 }
 
@@ -432,19 +448,34 @@ istream & NETGENPlugin_Hypothesis::LoadFrom(istream & load)
 
   if ( !hasLocalSize && !option_or_sm.empty() )
     _minSize = atof( option_or_sm.c_str() );
+  else
+    load >> _minSize;
 
-  isOK = static_cast<bool>( load >> _quadAllowed );
-  if ( !isOK )
+  isOK = static_cast<bool>( load >> is );
+  if ( isOK )
+    _quadAllowed = (bool) is;
+  else
     _quadAllowed = GetDefaultQuadAllowed();
 
-  isOK = static_cast<bool>( load >> _surfaceCurvature );
-  if ( !isOK )
+  isOK = static_cast<bool>( load >> is );
+  if ( isOK )
+    _surfaceCurvature = (bool) is;
+  else
     _surfaceCurvature = GetDefaultSurfaceCurvature();
 
-  isOK = static_cast<bool>( load >> _fuseEdges );
-  if ( !isOK )
+  isOK = static_cast<bool>( load >> is );
+  if ( isOK )
+    _fuseEdges = (bool) is;
+  else
     _fuseEdges = GetDefaultFuseEdges();
 
+  isOK = static_cast<bool>( load >> is >> std::ws ); // size of meshSizeFile
+  if ( isOK && is > 0 )
+  {
+    _meshSizeFile.resize( is );
+    load.get( &_meshSizeFile[0], is+1 );
+  }
+
   return load;
 }
 
index 3b818b8625b93fb854f04970bb7103193b9fcec8..7d6da32fcd776601914ef29e7a3321ea6d136c23 100644 (file)
@@ -90,6 +90,9 @@ public:
   const TLocalSize& GetLocalSizesAndEntries() const { return _localSize; }
   void UnsetLocalSizeOnEntry(const std::string& entry);
 
+  void SetMeshSizeFile(const std::string& fileName);
+  const std::string& GetMeshSizeFile() const { return _meshSizeFile; }
+
   void SetQuadAllowed(bool theVal);
   bool GetQuadAllowed() const { return _quadAllowed; }
 
@@ -141,6 +144,7 @@ private:
   bool          _secondOrder;
   bool          _optimize;
   TLocalSize    _localSize;
+  std::string   _meshSizeFile;
   bool          _quadAllowed;
   bool          _surfaceCurvature;
   bool          _fuseEdges;
index 3a5f334975f31ba483894495c064a277280214dd..e889033058eb60a1402151cc237f1ddcec104bad 100644 (file)
@@ -51,7 +51,6 @@ NETGENPlugin_Hypothesis_2D_i (PortableServer::POA_ptr thePOA,
     SMESH_Hypothesis_i( thePOA ),
     NETGENPlugin_Hypothesis_i( thePOA, theStudyId, theGenImpl )
 {
-  MESSAGE( "NETGENPlugin_Hypothesis_2D_i::NETGENPlugin_Hypothesis_2D_i" );
   if (myBaseImpl)
     delete (::NETGENPlugin_Hypothesis*)myBaseImpl;
   myBaseImpl = new ::NETGENPlugin_Hypothesis_2D (theGenImpl->GetANewId(),
@@ -68,7 +67,6 @@ NETGENPlugin_Hypothesis_2D_i (PortableServer::POA_ptr thePOA,
 //=============================================================================
 NETGENPlugin_Hypothesis_2D_i::~NETGENPlugin_Hypothesis_2D_i()
 {
-  MESSAGE( "NETGENPlugin_Hypothesis_2D_i::~NETGENPlugin_Hypothesis_2D_i" );
 }
 
 //=============================================================================
index 26048f7753f1b0489e69d415bc00d4a8c6e0698e..d60d666040ee615b061bebda29157443f0fd983c 100644 (file)
@@ -366,6 +366,24 @@ void NETGENPlugin_Hypothesis_i::UnsetLocalSizeOnEntry(const char* entry)
 
 //=============================================================================
 
+void NETGENPlugin_Hypothesis_i::SetMeshSizeFile(const char* fileName)
+{
+  if ( GetImpl()->GetMeshSizeFile() != fileName )
+  {
+    GetImpl()->SetMeshSizeFile( fileName );
+    SMESH::TPythonDump() << _this() << ".SetMeshSizeFile( '" << fileName << "' )";
+  }
+}
+
+//=============================================================================
+
+char* NETGENPlugin_Hypothesis_i::GetMeshSizeFile()
+{
+  return CORBA::string_dup( GetImpl()->GetMeshSizeFile().c_str() );
+}
+
+//=============================================================================
+
 void NETGENPlugin_Hypothesis_i::SetQuadAllowed (CORBA::Boolean theValue)
 {
   if ( NETGENPlugin_Hypothesis_i::isToSetParameter( GetQuadAllowed(),
index d03b2422f6eba027cf830d04ad5711dbd6c7f1b9..12ffa7b31453132fe7d4bae18d59dd3d82517273 100644 (file)
@@ -86,6 +86,9 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis_i:
   NETGENPlugin::string_array* GetLocalSizeEntries();
   void UnsetLocalSizeOnEntry(const char* entry);
 
+  void SetMeshSizeFile(const char* fileName);
+  char* GetMeshSizeFile();
+
   void SetQuadAllowed(CORBA::Boolean theVal);
   CORBA::Boolean GetQuadAllowed();
 
index ed36d22f47410ac69c21bdbacf18410e3e24bf6a..5d5c401002498e3878c19df461a38adc993caf63 100644 (file)
@@ -283,6 +283,8 @@ void NETGENPlugin_Mesher::SetParameters(const NETGENPlugin_Hypothesis* hyp)
     mparams.uselocalh       = hyp->GetSurfaceCurvature();
     netgen::merge_solids    = hyp->GetFuseEdges();
     _simpleHyp              = NULL;
+    // mesh size file
+    mparams.meshsizefilename= hyp->GetMeshSizeFile().empty() ? 0 : hyp->GetMeshSizeFile().c_str();
 
     SMESH_Gen_i*              smeshGen_i = SMESH_Gen_i::GetSMESHGen();
     CORBA::Object_var           anObject = smeshGen_i->GetNS()->Resolve("/myStudyManager");
@@ -661,7 +663,7 @@ void NETGENPlugin_Mesher::SetLocalSize( netgen::OCCGeometry& occgeo,
 
   if ( !ControlPoints.empty() )
   {
-    for ( size_t i = 1; i < ControlPoints.size(); ++i )
+    for ( size_t i = 0; i < ControlPoints.size(); ++i )
       NETGENPlugin_Mesher::RestrictLocalSize( ngMesh, ControlPoints[i].XYZ(), ControlPoints[i].Size() );
   }
 }
@@ -2486,16 +2488,6 @@ bool NETGENPlugin_Mesher::Compute()
   NETGENPlugin_NetgenLibWrapper ngLib;
 
   netgen::MeshingParameters& mparams = netgen::mparam;
-  MESSAGE("Compute with:\n"
-          " max size = " << mparams.maxh << "\n"
-          " segments per edge = " << mparams.segmentsperedge);
-  MESSAGE("\n"
-          " growth rate = " << mparams.grading << "\n"
-          " elements per radius = " << mparams.curvaturesafety << "\n"
-          " second order = " << mparams.secondorder << "\n"
-          " quad allowed = " << mparams.quad << "\n"
-          " surface curvature = " << mparams.uselocalh << "\n"
-          " fuse edges = " << netgen::merge_solids);
 
   SMESH_ComputeErrorPtr error = SMESH_ComputeError::New();
   SMESH_MesherHelper quadHelper( *_mesh );
@@ -2585,6 +2577,12 @@ bool NETGENPlugin_Mesher::Compute()
     {
       comment << text(ex);
     }
+    catch (netgen::NgException & ex)
+    {
+      comment << text(ex);
+      if ( mparams.meshsizefilename )
+        throw SMESH_ComputeError(COMPERR_BAD_PARMETERS, comment );
+    }
     err = 0; //- MESHCONST_ANALYSE isn't so important step
     if ( !_ngMesh )
       return false;
@@ -2592,6 +2590,9 @@ bool NETGENPlugin_Mesher::Compute()
 
     _ngMesh->ClearFaceDescriptors(); // we make descriptors our-self
 
+    if ( !mparams.uselocalh ) // mparams.grading is not taken into account yet
+      _ngMesh->LocalHFunction().SetGrading( mparams.grading );
+
     if ( _simpleHyp )
     {
       // Pass 1D simple parameters to NETGEN
@@ -3475,10 +3476,10 @@ NETGENPlugin_Mesher::ReadErrors(const vector<const SMDS_MeshNode* >& nodeVec)
  */
 //================================================================================
 
-void NETGENPlugin_Mesher::toPython( const netgen::Mesh* ngMesh,
-                                    const std::string&  pyFile)
+void NETGENPlugin_Mesher::toPython( const netgen::Mesh* ngMesh )
 {
-  ofstream outfile(pyFile.c_str(), ios::out);
+  const char*  pyFile = "/tmp/ngMesh.py";
+  ofstream outfile( pyFile, ios::out );
   if ( !outfile ) return;
 
   outfile << "import SMESH" << endl
index 2335b84d08e1060c1eac95cd5154a78d057d1666..01a387f59d755780d0bd98cabb66f2611863ca8f 100644 (file)
@@ -191,8 +191,7 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Mesher
   static SMESH_ComputeErrorPtr ReadErrors(const std::vector< const SMDS_MeshNode* >& nodeVec);
 
 
-  static void toPython( const netgen::Mesh* ngMesh,
-                        const std::string&  pyFile); // debug
+  static void toPython( const netgen::Mesh* ngMesh ); // debug
 
  private:
 
index c383e5f1ddbdf6b524f34c48d7d86f1fc7e51f13..16baad443a8091906207d676ee791b7f6ac416e6 100644 (file)
@@ -298,8 +298,7 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh&         aMesh,
     for ( int iE = 1; iE <= edgeMap.Extent(); ++iE )
     {
       const TopoDS_Shape& edge = edgeMap( iE );
-      if ( SMESH_Algo::isDegenerated( TopoDS::Edge( edge ))/* ||
-           helper.IsSubShape( edge, aShape )*/)
+      if ( SMESH_Algo::isDegenerated( TopoDS::Edge( edge )))
         continue;
       SMESHDS_SubMesh* smDS = meshDS->MeshElements( edge );
       if ( !smDS ) continue;
@@ -317,6 +316,11 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh&         aMesh,
 
     // set local size defined on shapes
     aMesher.SetLocalSize( occgeoComm, *ngMeshes[0] );
+    try {
+      ngMeshes[0]->LoadLocalMeshSize( mparam.meshsizefilename );
+    } catch (NgException & ex) {
+      return error( COMPERR_BAD_PARMETERS, ex.What() );
+    }
   }
   netgen::mparam.uselocalh = toOptimize; // restore as it is used at surface optimization
 
@@ -453,6 +457,11 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh&         aMesh,
         bb.Increase (bb.Diam()/10);
         ngMesh->SetLocalH (bb.PMin(), bb.PMax(), mparam.grading);
         aMesher.SetLocalSize( occgeom, *ngMesh );
+        try {
+          ngMesh->LoadLocalMeshSize( mparam.meshsizefilename );
+        } catch (NgException & ex) {
+          return error( COMPERR_BAD_PARMETERS, ex.What() );
+        }
       }
 
       nodeVec.clear();
index 17a33c9740df067c98cc7f2749d709504970c647..8fe43bb2a07b8d59574a5f5df73f3e8b7aaeb396 100644 (file)
@@ -71,6 +71,7 @@
 #define OCCGEOMETRY
 #endif
 #include <occgeom.hpp>
+#include <ngexception.hpp>
 namespace nglib {
 #include <nglib.h>
 }
@@ -438,7 +439,8 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh&                     aMesh,
   {
     aMesher.SetParameters( _hypParameters );
 
-    if ( !_hypParameters->GetLocalSizesAndEntries().empty() )
+    if ( !_hypParameters->GetLocalSizesAndEntries().empty() ||
+         !_hypParameters->GetMeshSizeFile().empty() )
     {
       if ( ! &ngMesh->LocalHFunction() )
       {
@@ -447,6 +449,12 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh&                     aMesh,
         ngMesh->SetLocalH( pmin, pmax, _hypParameters->GetGrowthRate() );
       }
       aMesher.SetLocalSize( occgeo, *ngMesh );
+
+      try {
+        ngMesh->LoadLocalMeshSize( netgen::mparam.meshsizefilename );
+      } catch (netgen::NgException & ex) {
+        return error( COMPERR_BAD_PARMETERS, ex.What() );
+      }
     }
     if ( !_hypParameters->GetOptimize() )
       endWith = netgen::MESHCONST_MESHVOLUME;