1 // Copyright (C) 2007-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (EDF R&D)
21 #ifndef __CURVEINTERSECTORP1P1PL_TXX__
22 #define __CURVEINTERSECTORP1P1PL_TXX__
24 #include "CurveIntersectorP1P1PL.hxx"
25 #include "CurveIntersector.txx"
29 namespace INTERP_KERNEL
31 template<class MyMeshType, class MyMatrix>
32 CurveIntersectorP1P1PL<MyMeshType,MyMatrix>::CurveIntersectorP1P1PL(const MyMeshType& meshT, const MyMeshType& meshS, double precision, double tolerance, double medianLine, int printLevel):CurveIntersector<MyMeshType,MyMatrix>(meshT, meshS, precision, tolerance, medianLine, printLevel)
36 template<class MyMeshType, class MyMatrix>
37 typename MyMeshType::MyConnType CurveIntersectorP1P1PL<MyMeshType,MyMatrix>::getNumberOfRowsOfResMatrix() const
39 return CurveIntersector<MyMeshType,MyMatrix>::_meshT.getNumberOfNodes();
42 template<class MyMeshType, class MyMatrix>
43 typename MyMeshType::MyConnType CurveIntersectorP1P1PL<MyMeshType,MyMatrix>::getNumberOfColsOfResMatrix() const
45 return CurveIntersector<MyMeshType,MyMatrix>::_meshS.getNumberOfNodes();
48 template<class MyMeshType, class MyMatrix>
49 void CurveIntersectorP1P1PL<MyMeshType,MyMatrix>::AppendValueInMatrix2(typename MyMatrix::value_type& resRow, ConnType nodeIdS0, double val0)
51 typename MyMatrix::value_type::const_iterator iterRes(resRow.find(OTT<ConnType,numPol>::indFC(nodeIdS0)));
52 if(iterRes==resRow.end())
54 resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(nodeIdS0),val0));
58 double val((*iterRes).second+val0);
59 resRow.erase(OTT<ConnType,numPol>::indFC(nodeIdS0));
60 resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(nodeIdS0),val));
64 template<class MyMeshType, class MyMatrix>
65 void CurveIntersectorP1P1PL<MyMeshType,MyMatrix>::AppendValueInMatrix(MyMatrix& res, ConnType nodeIdT, ConnType nodeIdS0, double val0, ConnType nodeIdS1, double val1)
67 typename MyMatrix::value_type& resRow(res[nodeIdT]);
68 AppendValueInMatrix2(resRow,nodeIdS0,val0);
69 AppendValueInMatrix2(resRow,nodeIdS1,val1);
72 template<class MyMeshType, class MyMatrix>
73 void CurveIntersectorP1P1PL<MyMeshType,MyMatrix>::intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res)
75 std::vector<double> coordsT;
76 if(CurveIntersector<MyMeshType,MyMatrix>::getRealTargetCoordinates(icellT,coordsT))
77 throw INTERP_KERNEL::Exception("Invalid target cell detected for meshdim==1. Only SEG2 supported !");
78 assert(coordsT.size()/SPACEDIM==2);
79 for(typename std::vector<ConnType>::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++)
81 std::vector<double> coordsS;
82 if(CurveIntersector<MyMeshType,MyMatrix>::getRealSourceCoordinates(*iter,coordsS))
83 throw INTERP_KERNEL::Exception("Invalid source cell detected for meshdim==1. Only SEG2 supported !");
84 assert(coordsS.size()/SPACEDIM==2);
85 double xs0,xs1,xt0,xt1;
86 double lgth(CurveIntersector<MyMeshType,MyMatrix>::intersectSegmentsInternal(&coordsT[0],&coordsS[0],xs0,xs1,xt0,xt1));
87 ConnType nodeIdS0(CurveIntersector<MyMeshType,MyMatrix>::getNodeIdOfSourceCellAt(*iter,0));
88 ConnType nodeIdS1(CurveIntersector<MyMeshType,MyMatrix>::getNodeIdOfSourceCellAt(*iter,1));
93 ConnType nodeIdT0(CurveIntersector<MyMeshType,MyMatrix>::getNodeIdOfTargetCellAt(icellT,0));
94 if(CurveIntersector<MyMeshType,MyMatrix>::ComputeBaryCoordsOf(xs0,xs1,xt0,a,b))
97 AppendValueInMatrix(res,nodeIdT0,nodeIdS0,a,nodeIdS1,b);
100 ConnType nodeIdT1(CurveIntersector<MyMeshType,MyMatrix>::getNodeIdOfTargetCellAt(icellT,1));
101 typename MyMatrix::value_type& resRow1=res[nodeIdT1];
102 if(CurveIntersector<MyMeshType,MyMatrix>::ComputeBaryCoordsOf(xs0,xs1,xt1,a,b))
105 AppendValueInMatrix(res,nodeIdT1,nodeIdS0,a,nodeIdS1,b);