Salome HOME
Merge from V6_main 01/04/2013
[plugins/netgenplugin.git] / src / NETGENPlugin / NETGENPlugin_NETGEN_2D.cxx
index bf56622e2afb2d89935a6d1d388e38dbe1e26a33..1187fe2c6f37d69fc5994d0ed024898dac924baf 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 #include "NETGENPlugin_SimpleHypothesis_2D.hxx"
 #include "NETGENPlugin_Mesher.hxx"
 
+#include <SMESHDS_Mesh.hxx>
+#include <SMESH_ControlsDef.hxx>
 #include <SMESH_Gen.hxx>
 #include <SMESH_Mesh.hxx>
-#include <SMESH_ControlsDef.hxx>
-#include <SMESHDS_Mesh.hxx>
+#include <StdMeshers_ViscousLayers2D.hxx>
 #include <utilities.h>
 
 #include <list>
@@ -64,10 +65,11 @@ NETGENPlugin_NETGEN_2D::NETGENPlugin_NETGEN_2D(int hypId, int studyId,
   _shapeType = (1 << TopAbs_FACE); // 1 bit /shape type
   _compatibleHypothesis.push_back("NETGEN_Parameters_2D");
   _compatibleHypothesis.push_back("NETGEN_SimpleParameters_2D");
+  _compatibleHypothesis.push_back( StdMeshers_ViscousLayers2D::GetHypType() );
   _requireDiscreteBoundary = false;
-  _onlyUnaryInput = false;
-  _hypothesis = NULL;
-  _supportSubmeshes = true;
+  _onlyUnaryInput          = false;
+  _hypothesis              = NULL;
+  _supportSubmeshes        = true;
 }
 
 //=============================================================================
@@ -87,33 +89,28 @@ NETGENPlugin_NETGEN_2D::~NETGENPlugin_NETGEN_2D()
  */
 //=============================================================================
 
-bool NETGENPlugin_NETGEN_2D::CheckHypothesis
-                         (SMESH_Mesh& aMesh,
-                          const TopoDS_Shape& aShape,
-                          SMESH_Hypothesis::Hypothesis_Status& aStatus)
+bool NETGENPlugin_NETGEN_2D::CheckHypothesis (SMESH_Mesh&         aMesh,
+                                              const TopoDS_Shape& aShape,
+                                              Hypothesis_Status&  aStatus)
 {
-  _hypothesis = NULL;
+  _hypothesis        = NULL;
+  _isViscousLayers2D = false;
 
-  const list<const SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape);
-  int nbHyp = hyps.size();
-  if (!nbHyp)
-  {
-    aStatus = SMESH_Hypothesis::HYP_OK;
-    return true;  // can work with no hypothesis
-  }
-  // use only the first hypothesis
-  const SMESHDS_Hypothesis* theHyp = hyps.front();
+  // can work with no hypothesis
+  aStatus = SMESH_Hypothesis::HYP_OK;
 
-  string hypName = theHyp->GetName();
-  if ( find( _compatibleHypothesis.begin(), _compatibleHypothesis.end(),
-             hypName ) != _compatibleHypothesis.end() )
-  {
-    _hypothesis = theHyp;
-    aStatus = SMESH_Hypothesis::HYP_OK;
-  }
-  else
+  const list<const SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape, /*skipAux=*/false);
+  list<const SMESHDS_Hypothesis*>::const_iterator h = hyps.begin();
+  for ( ; h != hyps.end(); ++h )
   {
-    aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
+    const SMESHDS_Hypothesis* theHyp = *h;
+    string hypName = theHyp->GetName();
+    if ( hypName == StdMeshers_ViscousLayers2D::GetHypType() )
+      _isViscousLayers2D = true;
+    else if ( _hypothesis )
+      aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
+    else
+      _hypothesis = theHyp;
   }
 
   return aStatus == SMESH_Hypothesis::HYP_OK;
@@ -132,9 +129,10 @@ bool NETGENPlugin_NETGEN_2D::Compute(SMESH_Mesh&         aMesh,
   netgen::multithread.terminate = 0;
 #endif
 
-  NETGENPlugin_Mesher mesher(&aMesh, aShape, false);
+  NETGENPlugin_Mesher mesher(&aMesh, aShape, /*is3D = */false);
   mesher.SetParameters(dynamic_cast<const NETGENPlugin_Hypothesis*>(_hypothesis));
   mesher.SetParameters(dynamic_cast<const NETGENPlugin_SimpleHypothesis_2D*>(_hypothesis));
+  mesher.SetViscousLayers2DAssigned( _isViscousLayers2D );
   return mesher.Compute();
 }