Salome HOME
0022104: EDF 2550 SMESH: 2D viscous layer, allow specifying edges with viscous layer
[modules/smesh.git] / src / StdMeshers / StdMeshers_ViscousLayers.cxx
index cacab8913bc95201a450854a5653ccd8415caeb6..d4a595ec569aea31bc9945bf67e9e276250fd725 100644 (file)
@@ -36,6 +36,7 @@
 #include "SMESH_Gen.hxx"
 #include "SMESH_Group.hxx"
 #include "SMESH_Mesh.hxx"
+#include "SMESH_MeshAlgos.hxx"
 #include "SMESH_MesherHelper.hxx"
 #include "SMESH_ProxyMesh.hxx"
 #include "SMESH_subMesh.hxx"
@@ -566,20 +567,17 @@ virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const
 //
 StdMeshers_ViscousLayers::StdMeshers_ViscousLayers(int hypId, int studyId, SMESH_Gen* gen)
   :SMESH_Hypothesis(hypId, studyId, gen),
-   _nbLayers(1), _thickness(1), _stretchFactor(1)
+   _isToIgnoreShapes(18), _nbLayers(1), _thickness(1), _stretchFactor(1)
 {
   _name = StdMeshers_ViscousLayers::GetHypType();
   _param_algo_dim = -3; // auxiliary hyp used by 3D algos
 } // --------------------------------------------------------------------------------
-void StdMeshers_ViscousLayers::SetBndShapesToIgnore(const std::vector<int>& faceIds)
+void StdMeshers_ViscousLayers::SetBndShapes(const std::vector<int>& faceIds, bool toIgnore)
 {
-  if ( faceIds != _ignoreBndShapeIds )
-    _ignoreBndShapeIds = faceIds, NotifySubMeshesHypothesisModification();
-} // --------------------------------------------------------------------------------
-bool StdMeshers_ViscousLayers::IsIgnoredShape(const int shapeID) const
-{
-  return ( find( _ignoreBndShapeIds.begin(), _ignoreBndShapeIds.end(), shapeID )
-           != _ignoreBndShapeIds.end() );
+  if ( faceIds != _shapeIds )
+    _shapeIds = faceIds, NotifySubMeshesHypothesisModification();
+  if ( _isToIgnoreShapes != toIgnore )
+    _isToIgnoreShapes = toIgnore, NotifySubMeshesHypothesisModification();
 } // --------------------------------------------------------------------------------
 void StdMeshers_ViscousLayers::SetTotalThickness(double thickness)
 {
@@ -637,17 +635,22 @@ std::ostream & StdMeshers_ViscousLayers::SaveTo(std::ostream & save)
   save << " " << _nbLayers
        << " " << _thickness
        << " " << _stretchFactor
-       << " " << _ignoreBndShapeIds.size();
-  for ( unsigned i = 0; i < _ignoreBndShapeIds.size(); ++i )
-    save << " " << _ignoreBndShapeIds[i];
+       << " " << _shapeIds.size();
+  for ( unsigned i = 0; i < _shapeIds.size(); ++i )
+    save << " " << _shapeIds[i];
+  save << " " << !_isToIgnoreShapes; // negate to keep the behavior in old studies.
   return save;
 } // --------------------------------------------------------------------------------
 std::istream & StdMeshers_ViscousLayers::LoadFrom(std::istream & load)
 {
-  int nbFaces, faceID;
+  int nbFaces, faceID, shapeToTreat;
   load >> _nbLayers >> _thickness >> _stretchFactor >> nbFaces;
-  while ( _ignoreBndShapeIds.size() < nbFaces && load >> faceID )
-    _ignoreBndShapeIds.push_back( faceID );
+  while ( _shapeIds.size() < nbFaces && load >> faceID )
+    _shapeIds.push_back( faceID );
+  if ( load >> shapeToTreat )
+    _isToIgnoreShapes = !shapeToTreat;
+  else
+    _isToIgnoreShapes = true; // old behavior
   return load;
 } // --------------------------------------------------------------------------------
 bool StdMeshers_ViscousLayers::SetParametersByMesh(const SMESH_Mesh*   theMesh,
@@ -1071,7 +1074,7 @@ bool _ViscousBuilder::findFacesWithLayers()
   vector<TopoDS_Shape> ignoreFaces;
   for ( unsigned i = 0; i < _sdVec.size(); ++i )
   {
-    vector<TGeomID> ids = _sdVec[i]._hyp->GetBndShapesToIgnore();
+    vector<TGeomID> ids = _sdVec[i]._hyp->GetBndShapes();
     for ( unsigned i = 0; i < ids.size(); ++i )
     {
       const TopoDS_Shape& s = getMeshDS()->IndexToShape( ids[i] );
@@ -2067,9 +2070,9 @@ bool _ViscousBuilder::inflate(_SolidData& data)
   // Limit inflation step size by geometry size found by itersecting
   // normals of _LayerEdge's with mesh faces
   double geomSize = Precision::Infinite(), intersecDist;
-  SMESH_MeshEditor editor( _mesh );
   auto_ptr<SMESH_ElementSearcher> searcher
-    ( editor.GetElementSearcher( data._proxyMesh->GetFaces( data._solid )) );
+    ( SMESH_MeshAlgos::GetElementSearcher( *getMeshDS(),
+                                           data._proxyMesh->GetFaces( data._solid )) );
   for ( unsigned i = 0; i < data._edges.size(); ++i )
   {
     if ( data._edges[i]->IsOnEdge() ) continue;
@@ -2265,9 +2268,9 @@ bool _ViscousBuilder::smoothAndCheck(_SolidData& data,
   // Check if the last segments of _LayerEdge intersects 2D elements;
   // checked elements are either temporary faces or faces on surfaces w/o the layers
 
-  SMESH_MeshEditor editor( _mesh );
   auto_ptr<SMESH_ElementSearcher> searcher
-    ( editor.GetElementSearcher( data._proxyMesh->GetFaces( data._solid )) );
+    ( SMESH_MeshAlgos::GetElementSearcher( *getMeshDS(),
+                                           data._proxyMesh->GetFaces( data._solid )) );
 
   distToIntersection = Precision::Infinite();
   double dist;
@@ -2627,10 +2630,10 @@ bool _ViscousBuilder::updateNormals( _SolidData&         data,
   // 1) to find and fix intersection
   // 2) to check that no new intersection appears as result of 1)
 
-  SMESH_MeshEditor editor( _mesh );
   SMDS_ElemIteratorPtr fIt( new SMDS_ElementVectorIterator( tmpFaces.begin(),
                                                             tmpFaces.end()));
-  auto_ptr<SMESH_ElementSearcher> searcher ( editor.GetElementSearcher( fIt ));
+  auto_ptr<SMESH_ElementSearcher> searcher
+    ( SMESH_MeshAlgos::GetElementSearcher( *getMeshDS(), fIt ));
 
   // 1) Find intersections
   double dist;
@@ -3958,8 +3961,8 @@ void _ViscousBuilder::fixBadFaces(const TopoDS_Face& F, SMESH_MesherHelper& help
       const SMDS_MeshNode* n1 = badTrias[iTia]->GetNode( iSide );
       const SMDS_MeshNode* n2 = badTrias[iTia]->GetNode(( iSide+1 ) % 3 );
       trias [iSide].first  = badTrias[iTia];
-      trias [iSide].second = SMESH_MeshEditor::FindFaceInSet( n1, n2, emptySet, involvedFaces,
-                                                              & i1, & i2 );
+      trias [iSide].second = SMESH_MeshAlgos::FindFaceInSet( n1, n2, emptySet, involvedFaces,
+                                                             & i1, & i2 );
       if ( ! trias[iSide].second || trias[iSide].second->NbCornerNodes() != 3 )
         continue;