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