Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/med.git] / src / INTERP_KERNEL / PointLocator3DIntersectorP0P1.txx
1 // Copyright (C) 2007-2012  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.
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 #ifndef __POINTLOCATOR3DINTERSECTORP0P1_TXX__
20 #define __POINTLOCATOR3DINTERSECTORP0P1_TXX__
21
22 #include "PointLocator3DIntersectorP0P1.hxx"
23 #include "Intersector3DP0P1.txx"
24 #include "MeshUtils.hxx"
25
26 namespace INTERP_KERNEL
27 {
28
29   /** 
30    * @param targetMesh  mesh containing the target elements
31    * @param srcMesh     mesh containing the source elements
32    * @param policy      splitting policy to be used
33    */
34   template<class MyMeshType, class MyMatrix>
35   PointLocator3DIntersectorP0P1<MyMeshType,MyMatrix>::PointLocator3DIntersectorP0P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, double precision):
36     Intersector3DP0P1<MyMeshType,MyMatrix>(targetMesh,srcMesh),_precision(precision)
37   {
38   }
39
40   template<class MyMeshType, class MyMatrix>
41   PointLocator3DIntersectorP0P1<MyMeshType,MyMatrix>::~PointLocator3DIntersectorP0P1()
42   {
43   }
44
45   /**
46    * 
47    * @param targetCell in C mode.
48    * @param srcCells in C mode.
49    *
50    */
51   template<class MyMeshType, class MyMatrix>
52   void PointLocator3DIntersectorP0P1<MyMeshType,MyMatrix>::intersectCells(ConnType targetCell, const std::vector<ConnType>& srcCells, MyMatrix& res)
53   {
54     std::vector<double> coordsTarget;
55     Intersector3DP0P1<MyMeshType,MyMatrix>::getRealTargetCoordinates(OTT<ConnType,numPol>::indFC(targetCell),coordsTarget);
56     int nbNodesT=coordsTarget.size()/SPACEDIM;
57     const double *coordsS=Intersector3DP0P1<MyMeshType,MyMatrix>::_src_mesh.getCoordinatesPtr();
58     const ConnType *startOfCellNodeConnT=Intersector3DP0P1<MyMeshType,MyMatrix>::getStartConnOfTargetCell(targetCell);
59     for(typename std::vector<ConnType>::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++)
60       {
61         NormalizedCellType tS=Intersector3DP0P1<MyMeshType,MyMatrix>::_src_mesh.getTypeOfElement(OTT<ConnType,numPol>::indFC(*iterCellS));
62         const CellModel& cmTypeS=CellModel::GetCellModel(tS);
63         std::vector<ConnType> connOfCurCellS;
64         Intersector3DP0P1<MyMeshType,MyMatrix>::getConnOfSourceCell(OTT<ConnType,numPol>::indFC(*iterCellS),connOfCurCellS);
65         for(int nodeIdT=0;nodeIdT<nbNodesT;nodeIdT++)
66           {
67             if(PointLocatorAlgos<MyMeshType>::isElementContainsPointAlg3D(&coordsTarget[nodeIdT*SPACEDIM],&connOfCurCellS[0],connOfCurCellS.size(),coordsS,cmTypeS,_precision))
68               {
69                 ConnType curNodeTInCmode=OTT<ConnType,numPol>::coo2C(startOfCellNodeConnT[nodeIdT]);
70                 typename MyMatrix::value_type& resRow=res[curNodeTInCmode];
71                 typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT<ConnType,numPol>::indFC(*iterCellS));
72                 if(iterRes==resRow.end())
73                   resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(*iterCellS),1.));
74               }
75           }
76       }
77   }
78 }
79
80 #endif