Salome HOME
6f0646305d39c56ea51b41b73b89661002beb795
[tools/medcoupling.git] / src / INTERP_KERNEL / Planar2D1DIntersectorP0P0.txx
1 // Copyright (C) 2007-2016  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 __PLANAR2D1DINTERSECTORP0P0_TXX__
21 #define __PLANAR2D1DINTERSECTORP0P0_TXX__
22
23 #include "Planar2D1DIntersectorP0P0.hxx"
24
25 namespace INTERP_KERNEL
26 {
27   template<class MyMeshType, class MyMatrix, class ConcreteP0P0Intersector>
28   Planar2D1DIntersectorP0P0<MyMeshType,MyMatrix,ConcreteP0P0Intersector>::Planar2D1DIntersectorP0P0(const MyMeshType& meshT, const MyMeshType& meshS,
29                                                                                                     double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane,
30                                                                                                     bool doRotate, int orientation, int printLevel):
31     PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,minDot3DSurf,medianPlane,doRotate,orientation,printLevel)
32   {
33   }
34
35   template<class MyMeshType, class MyMatrix, class ConcreteP0P0Intersector>
36   int Planar2D1DIntersectorP0P0<MyMeshType,MyMatrix,ConcreteP0P0Intersector>::getNumberOfRowsOfResMatrix() const
37   {
38     return PlanarIntersector<MyMeshType,MyMatrix>::_meshT.getNumberOfElements();
39   }
40
41   template<class MyMeshType, class MyMatrix, class ConcreteP0P0Intersector>
42   int Planar2D1DIntersectorP0P0<MyMeshType,MyMatrix,ConcreteP0P0Intersector>::getNumberOfColsOfResMatrix() const
43   {
44     return PlanarIntersector<MyMeshType,MyMatrix>::_meshS.getNumberOfElements();
45   }
46
47   template<class MyMeshType, class MyMatrix, class ConcreteP0P0Intersector>
48   void Planar2D1DIntersectorP0P0<MyMeshType,MyMatrix,ConcreteP0P0Intersector>::intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res)
49   {
50     int nbNodesT=PlanarIntersector<MyMeshType,MyMatrix>::_connIndexT[icellT+1]-PlanarIntersector<MyMeshType,MyMatrix>::_connIndexT[icellT];
51     typename MyMatrix::value_type& resRow=res[icellT];
52     for(typename std::vector<ConnType>::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++)
53       {
54         int iS=*iter;
55         int nbNodesS=PlanarIntersector<MyMeshType,MyMatrix>::_connIndexS[iS+1]-PlanarIntersector<MyMeshType,MyMatrix>::_connIndexS[iS];
56         bool isColinear = false;
57         double surf=intersectGeometry1D(OTT<ConnType,numPol>::indFC(icellT),OTT<ConnType,numPol>::indFC(iS),
58                                         nbNodesT,nbNodesS, isColinear);
59         surf=PlanarIntersector<MyMeshType,MyMatrix>::getValueRegardingOption(surf);
60         if(surf!=0.)
61           resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(iS),surf));
62
63         if (isColinear)
64           {
65           typename PlanarIntersector<MyMeshType,MyMatrix>::DuplicateFacesType::iterator intersectFacesIter = _intersect_faces.find(iS);
66           if (intersectFacesIter != _intersect_faces.end())
67             {
68               intersectFacesIter->second.insert(icellT);
69             }
70           else
71             {
72               std::set<int> targetCellSet;
73               targetCellSet.insert(icellT);
74               _intersect_faces.insert(std::make_pair(iS, targetCellSet));
75             }
76           }
77       }
78   }
79 }
80
81 #endif