Salome HOME
9272cbb96be50ec51b981b7dc66a80dccbd0a5d5
[tools/medcoupling.git] / src / INTERP_KERNEL / PointLocator3DIntersectorP0P0.txx
1 // Copyright (C) 2007-2020  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20 #ifndef __POINTLOCATOR3DINTERSECTORP0P0_TXX__
21 #define __POINTLOCATOR3DINTERSECTORP0P0_TXX__
22
23 #include "PointLocator3DIntersectorP0P0.hxx"
24 #include "Intersector3DP0P0.txx"
25 #include "MeshUtils.hxx"
26
27 #include "SplitterTetra.txx"
28 #include "PointLocatorAlgos.txx"
29
30 namespace INTERP_KERNEL
31 {
32
33   /**
34    * @param targetMesh  mesh containing the target elements
35    * @param srcMesh     mesh containing the source elements
36    */
37   template<class MyMeshType, class MyMatrix>
38   PointLocator3DIntersectorP0P0<MyMeshType,MyMatrix>::PointLocator3DIntersectorP0P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh, double precision):
39     Intersector3DP0P0<MyMeshType,MyMatrix>(targetMesh,srcMesh),_precision(precision)
40   {
41   }
42
43   template<class MyMeshType, class MyMatrix>
44   PointLocator3DIntersectorP0P0<MyMeshType,MyMatrix>::~PointLocator3DIntersectorP0P0()
45   {
46   }
47
48   /**
49    * 
50    * @param targetCell in C mode.
51    * @param srcCells in C mode.
52    *
53    */
54   template<class MyMeshType, class MyMatrix>
55   void PointLocator3DIntersectorP0P0<MyMeshType,MyMatrix>::intersectCells(ConnType targetCell, const std::vector<ConnType>& srcCells, MyMatrix& res)
56   {
57     std::vector<double> CoordsT;
58     Intersector3DP0P0<MyMeshType,MyMatrix>::getRealTargetCoordinates(OTT<ConnType,numPol>::indFC(targetCell),CoordsT);
59     double bary[SPACEDIM];
60     calculateBarycenterDyn2<SPACEDIM>(&CoordsT[0],ToConnType(CoordsT.size())/SPACEDIM,bary);
61     typename MyMatrix::value_type& resRow=res[targetCell];
62     const double *coordsS=Intersector3DP0P0<MyMeshType,MyMatrix>::_src_mesh.getCoordinatesPtr();
63     for(typename std::vector<ConnType>::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++)
64       {
65         NormalizedCellType tS=Intersector3DP0P0<MyMeshType,MyMatrix>::_src_mesh.getTypeOfElement(OTT<ConnType,numPol>::indFC(*iterCellS));
66         const CellModel& cmTypeS=CellModel::GetCellModel(tS);
67         std::vector<ConnType> connOfCurCellS;
68         Intersector3DP0P0<MyMeshType,MyMatrix>::getConnOfSourceCell(OTT<ConnType,numPol>::indFC(*iterCellS),connOfCurCellS);
69         if(PointLocatorAlgos<MyMeshType>::isElementContainsPointAlg3D(bary,&connOfCurCellS[0],ToConnType(connOfCurCellS.size()),coordsS,cmTypeS,_precision))
70           {
71             resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(*iterCellS),1));
72           }
73       }
74   }
75 }
76
77 #endif