Salome HOME
Update copyrights 2014.
[modules/med.git] / src / INTERP_KERNEL / PlanarIntersectorP0P1PL.txx
1 // Copyright (C) 2007-2014  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 __PLANARINTERSECTORP0P1PL_TXX__
21 #define __PLANARINTERSECTORP0P1PL_TXX__
22
23 #include "PlanarIntersectorP0P1PL.hxx"
24 #include "PlanarIntersector.txx"
25 #include "CellModel.hxx"
26
27 #include "PointLocatorAlgos.txx"
28
29 namespace INTERP_KERNEL
30 {
31   template<class MyMeshType, class MyMatrix>
32   PlanarIntersectorP0P1PL<MyMeshType,MyMatrix>::PlanarIntersectorP0P1PL(const MyMeshType& meshT, const MyMeshType& meshS,
33                                                                         double dimCaracteristic, double md3DSurf,
34                                                                         double medianPlane, double precision, int orientation):
35     PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,medianPlane,true,orientation,0)
36   {
37   }
38
39   template<class MyMeshType, class MyMatrix>
40   void PlanarIntersectorP0P1PL<MyMeshType,MyMatrix>::intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res)
41   {
42     std::vector< std::vector<double> > coordsOfSources(icellsS.size());
43     int ii=0;
44     for(typename std::vector<ConnType>::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++,ii++)
45       PlanarIntersector<MyMeshType,MyMatrix>::getRealSourceCoordinates(OTT<ConnType,numPol>::indFC(*iter),coordsOfSources[ii]);
46     const ConnType *startOfCellNodeConnT=PlanarIntersector<MyMeshType,MyMatrix>::_connectT+OTT<ConnType,numPol>::conn2C(PlanarIntersector<MyMeshType,MyMatrix>::_connIndexT[icellT]);
47     std::vector<double> coordsTarget;
48     PlanarIntersector<MyMeshType,MyMatrix>::getRealTargetCoordinates(OTT<ConnType,numPol>::indFC(icellT),coordsTarget);
49     int nbNodesT=coordsTarget.size()/SPACEDIM;
50     ii=0;
51     for(typename std::vector<ConnType>::const_iterator iter2=icellsS.begin();iter2!=icellsS.end();iter2++,ii++)
52       {
53         std::vector<double> tmpSource(coordsOfSources[ii]);
54         std::vector<double> tmpTarget(coordsTarget);
55         if(SPACEDIM==3)
56           PlanarIntersector<MyMeshType,MyMatrix>::projectionThis(&tmpSource[0],&tmpTarget[0],tmpSource.size()/SPACEDIM,nbNodesT);
57         for(int nodeIdT=0;nodeIdT<nbNodesT;nodeIdT++)
58           {
59             if(PointLocatorAlgos<MyMeshType>::isElementContainsPointAlg2D(&tmpTarget[0]+nodeIdT*SPACEDIM,&tmpSource[0],tmpSource.size()/SPACEDIM,PlanarIntersector<MyMeshType,MyMatrix>::_precision))
60               {
61                 ConnType curNodeTInCmode=OTT<ConnType,numPol>::coo2C(startOfCellNodeConnT[nodeIdT]);
62                 typename MyMatrix::value_type& resRow=res[curNodeTInCmode];
63                 typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT<ConnType,numPol>::indFC(*iter2));
64                 if(iterRes==resRow.end())
65                   resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(*iter2),1.));
66               }
67           }
68       }
69   }
70
71   template<class MyMeshType, class MyMatrix>
72   int PlanarIntersectorP0P1PL<MyMeshType,MyMatrix>::getNumberOfRowsOfResMatrix() const
73   {
74     return PlanarIntersector<MyMeshType,MyMatrix>::_meshT.getNumberOfNodes();
75   }
76   
77   template<class MyMeshType, class MyMatrix>
78   int PlanarIntersectorP0P1PL<MyMeshType,MyMatrix>::getNumberOfColsOfResMatrix() const
79   {
80     return PlanarIntersector<MyMeshType,MyMatrix>::_meshS.getNumberOfElements();
81   }
82 }
83
84 #endif