Salome HOME
Implementation of MEDCoupling1SGTUMesh.computeTriangleHeight and DataArrayDouble...
[tools/medcoupling.git] / src / INTERP_KERNEL / Polyhedron3D2DIntersectorP0P0.txx
index 92418804d093d86ae2b47267eee5660f4aa0975f..96909f3ae5e489bde442956c9959baed8ce160b7 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -81,14 +81,13 @@ namespace INTERP_KERNEL
    * 
    * @param targetCell in C mode.
    * @param srcCells in C mode.
-   *
    */
   template<class MyMeshType, class MyMatrixType>
   void Polyhedron3D2DIntersectorP0P0<MyMeshType,MyMatrixType>::intersectCells(ConnType targetCell,
                                                                               const std::vector<ConnType>& srcCells,
                                                                               MyMatrixType& matrix)
   {
-    int nbOfNodesT=Intersector3D<MyMeshType,MyMatrixType>::_target_mesh.getNumberOfNodesOfElement(OTT<ConnType,numPol>::indFC(targetCell));
+    ConnType nbOfNodesT=Intersector3D<MyMeshType,MyMatrixType>::_target_mesh.getNumberOfNodesOfElement(OTT<ConnType,numPol>::indFC(targetCell));
     releaseArrays();
     _split.splitTargetCell(targetCell,nbOfNodesT,_tetra);
 
@@ -100,18 +99,18 @@ namespace INTERP_KERNEL
 
         // calculate the coordinates of the nodes
         typename MyMeshType::MyConnType cellSrc = *iterCellS;
-        int cellSrcIdx = OTT<ConnType,numPol>::indFC(cellSrc);
+        ConnType cellSrcIdx = OTT<ConnType,numPol>::indFC(cellSrc);
         NormalizedCellType normCellType=Intersector3D<MyMeshType,MyMatrixType>::_src_mesh.getTypeOfElement(cellSrcIdx);
         const CellModel& cellModelCell=CellModel::GetCellModel(normCellType);
         const MyMeshType& src_mesh = Intersector3D<MyMeshType,MyMatrixType>::_src_mesh;
-        unsigned nbOfNodes4Type=cellModelCell.isDynamic() ? src_mesh.getNumberOfNodesOfElement(cellSrcIdx) : cellModelCell.getNumberOfNodes();
-        int *polyNodes=new int[nbOfNodes4Type];
+        ConnType nbOfNodes4Type=cellModelCell.isDynamic() ? src_mesh.getNumberOfNodesOfElement(cellSrcIdx) : cellModelCell.getNumberOfNodes();
+        mcIdType *polyNodes=new mcIdType[nbOfNodes4Type];
         double **polyCoords = new double*[nbOfNodes4Type];
         for(int i = 0;i<(int)nbOfNodes4Type;++i)
           {
             // we could store mapping local -> global numbers too, but not sure it is worth it
-            const int globalNodeNum = getGlobalNumberOfNode(i, OTT<ConnType,numPol>::indFC(*iterCellS), src_mesh);
-            polyNodes[i]=globalNodeNum;
+            const ConnType globalNodeNum = getGlobalNumberOfNode(i, OTT<ConnType,numPol>::indFC(*iterCellS), src_mesh);
+            polyNodes[i] = ToIdType( globalNodeNum );
             polyCoords[i] = const_cast<double*>(src_mesh.getCoordinatesPtr()+MyMeshType::MY_SPACEDIM*globalNodeNum);
           }
 
@@ -125,46 +124,43 @@ namespace INTERP_KERNEL
                                                     listOfTetraFacesTreated,
                                                     listOfTetraFacesColinear);
 
-        if(surface!=0.) {
-
-          matrix[targetCell].insert(std::make_pair(cellSrcIdx, surface));
-
-          bool isSrcFaceColinearWithFaceOfTetraTargetCell = false;
-          std::set<TriangleFaceKey>::iterator iter;
-          for (iter = listOfTetraFacesColinear.begin(); iter != listOfTetraFacesColinear.end(); ++iter)
-            {
-              if (listOfTetraFacesTreated.count(*iter) != 1)
-                {
-                  isSrcFaceColinearWithFaceOfTetraTargetCell = false;
-                  break;
-                }
-              else
-                {
-                  isSrcFaceColinearWithFaceOfTetraTargetCell = true;
-                }
-            }
-
-          if (isSrcFaceColinearWithFaceOfTetraTargetCell)
-            {
-              DuplicateFacesType::iterator intersectFacesIter = _intersect_faces.find(cellSrcIdx);
-              if (intersectFacesIter != _intersect_faces.end())
-                {
-                  intersectFacesIter->second.insert(targetCell);
-                }
-              else
-                {
-                  std::set<int> targetCellSet;
-                  targetCellSet.insert(targetCell);
-                  _intersect_faces.insert(std::make_pair(cellSrcIdx, targetCellSet));
-                }
-
-            }
-
-        }
-
-        delete[] polyNodes;
-        delete[] polyCoords;
-
+        if(surface!=0.)
+          {
+            
+            matrix[targetCell].insert(std::make_pair(cellSrcIdx, surface));
+            
+            bool isSrcFaceColinearWithFaceOfTetraTargetCell = false;
+            std::set<TriangleFaceKey>::iterator iter;
+            for (iter = listOfTetraFacesColinear.begin(); iter != listOfTetraFacesColinear.end(); ++iter)
+              {
+                if (listOfTetraFacesTreated.count(*iter) != 1)
+                  {
+                    isSrcFaceColinearWithFaceOfTetraTargetCell = false;
+                    break;
+                  }
+                else
+                  {
+                    isSrcFaceColinearWithFaceOfTetraTargetCell = true;
+                  }
+              }
+            
+            if (isSrcFaceColinearWithFaceOfTetraTargetCell)
+              {
+                DuplicateFacesType::iterator intersectFacesIter = _intersect_faces.find(cellSrcIdx);
+                if (intersectFacesIter != _intersect_faces.end())
+                  {
+                    intersectFacesIter->second.insert(targetCell);
+                  }
+                else
+                  {
+                    std::set<ConnType> targetCellSet;
+                    targetCellSet.insert(targetCell);
+                    _intersect_faces.insert(std::make_pair(cellSrcIdx, targetCellSet));
+                  }
+              }
+          }
+        delete [] polyNodes;
+        delete [] polyCoords;
       }
     _split.releaseArrays();
   }