Salome HOME
Copyright update 2022
[modules/smesh.git] / src / StdMeshers / StdMeshers_HexaFromSkin_3D.cxx
index 0cd90264c4dcd0a2d5592caa0ba1934693775a13..e91c8806cb7a5c7272cecb4a7cc442a3f00b1751 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -27,6 +27,7 @@
 #include "SMDS_VolumeTool.hxx"
 #include "SMESHDS_Mesh.hxx"
 #include "SMESH_Block.hxx"
+#include "SMESH_Indexer.hxx"
 #include "SMESH_Mesh.hxx"
 #include "SMESH_MeshAlgos.hxx"
 #include "SMESH_MesherHelper.hxx"
@@ -59,6 +60,10 @@ using namespace std;
 
 namespace
 {
+  // typedefs for struct's moved to SMESHUtils
+  typedef SMESH_Indexer         _Indexer;
+  typedef SMESH_OrientedIndexer _OrientedIndexer;
+
   enum EBoxSides //!< sides of the block
     {
       B_BOTTOM=0, B_RIGHT, B_TOP, B_LEFT, B_FRONT, B_BACK, NB_BLOCK_SIDES
@@ -143,67 +148,6 @@ namespace
     return quad->GetNode( (iNode+2) % 4 );
   }
 
-  //================================================================================
-  /*!
-   * \brief Converter of a pair of integers to a sole index
-   */
-  struct _Indexer
-  {
-    int _xSize, _ySize;
-    _Indexer( int xSize=0, int ySize=0 ): _xSize(xSize), _ySize(ySize) {}
-    int size() const { return _xSize * _ySize; }
-    int operator()(int x, int y) const { return y * _xSize + x; }
-  };
-  //================================================================================
-  /*!
-   * \brief Oriented converter of a pair of integers to a sole index 
-   */
-  class _OrientedIndexer : public _Indexer
-  {
-  public:
-    enum OriFlags //!< types of block side orientation
-      {
-        REV_X = 1, REV_Y = 2, SWAP_XY = 4, MAX_ORI = REV_X|REV_Y|SWAP_XY
-      };
-    _OrientedIndexer( const _Indexer& indexer, const int oriFlags ):
-      _Indexer( indexer._xSize, indexer._ySize ),
-      _xSize (indexer._xSize), _ySize(indexer._ySize),
-      _xRevFun((oriFlags & REV_X) ? & reverse : & lazy),
-      _yRevFun((oriFlags & REV_Y) ? & reverse : & lazy),
-      _swapFun((oriFlags & SWAP_XY ) ? & swap : & lazy)
-    {
-      (*_swapFun)( _xSize, _ySize );
-    }
-    //!< Return index by XY
-    int operator()(int x, int y) const
-    {
-      (*_xRevFun)( x, const_cast<int&>( _xSize ));
-      (*_yRevFun)( y, const_cast<int&>( _ySize ));
-      (*_swapFun)( x, y );
-      return _Indexer::operator()(x,y);
-    }
-    //!< Return index for a corner
-    int corner(bool xMax, bool yMax) const
-    {
-      int x = xMax, y = yMax, size = 2;
-      (*_xRevFun)( x, size );
-      (*_yRevFun)( y, size );
-      (*_swapFun)( x, y );
-      return _Indexer::operator()(x ? _Indexer::_xSize-1 : 0 , y ? _Indexer::_ySize-1 : 0);
-    }
-    int xSize() const { return _xSize; }
-    int ySize() const { return _ySize; }
-  private:
-    _Indexer _indexer;
-    int _xSize, _ySize;
-
-    typedef void (*TFun)(int& x, int& y);
-    TFun _xRevFun, _yRevFun, _swapFun;
-    
-    static void lazy   (int&, int&) {}
-    static void reverse(int& x, int& size) { x = size - x - 1; }
-    static void swap   (int& x, int& y) { std::swap(x,y); }
-  };
   //================================================================================
   /*!
    * \brief Structure corresponding to the meshed side of block
@@ -216,7 +160,7 @@ namespace
     int                          _nbBlocksFound;
 
 #ifdef _DEBUG_ // want to get SIGSEGV in case of invalid index
-#define _grid_access_(pobj, i) pobj->_grid[ ((i) < (int)pobj->_grid.size()) ? i : int(1e100)]
+#define _grid_access_(pobj, i) pobj->_grid[ ((i) < pobj->_grid.size()) ? i : int(1e100)]
 #else
 #define _grid_access_(pobj, i) pobj->_grid[ i ]
 #endif
@@ -386,7 +330,7 @@ namespace
 
     // Find a node at any block corner
 
-    SMDS_NodeIteratorPtr nIt = meshDS->nodesIterator(/*idInceasingOrder=*/true);
+    SMDS_NodeIteratorPtr nIt = meshDS->nodesIterator();
     if ( !nIt->more() ) return error("Empty mesh");
 
     const SMDS_MeshNode* nCorner = 0;
@@ -405,7 +349,7 @@ namespace
     // Find all block sides starting from mesh faces sharing the corner node
     // --------------------------------------------------------------------
 
-    int nbFacesOnSides = 0;
+    smIdType nbFacesOnSides = 0;
     TIDSortedElemSet cornerFaces; // corner faces of found _BlockSide's
     list< const SMDS_MeshNode* > corners( 1, nCorner );
     list< const SMDS_MeshNode* >::iterator corner = corners.begin();
@@ -1256,7 +1200,7 @@ bool StdMeshers_HexaFromSkin_3D::Evaluate(SMESH_Mesh &         aMesh,
   bool secondOrder = aMesh.NbFaces( ORDER_QUADRATIC );
 
   int entity = secondOrder ? SMDSEntity_Quad_Hexa : SMDSEntity_Hexa;
-  vector<int>& nbByType = aResMap[ aMesh.GetSubMesh( aShape )];
+  vector<smIdType>& nbByType = aResMap[ aMesh.GetSubMesh( aShape )];
   if ( entity >= (int) nbByType.size() )
     nbByType.resize( SMDSEntity_Last, 0 );