1 // Copyright (C) 2007-2024 CEA, EDF
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)
23 #include "CurveIntersectorP1P1PL.hxx"
24 #include "CurveIntersector.txx"
28 namespace INTERP_KERNEL
30 template<class MyMeshType, class MyMatrix>
31 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)
35 template<class MyMeshType, class MyMatrix>
36 typename MyMeshType::MyConnType CurveIntersectorP1P1PL<MyMeshType,MyMatrix>::getNumberOfRowsOfResMatrix() const
38 return this->_meshT.getNumberOfNodes();
41 template<class MyMeshType, class MyMatrix>
42 typename MyMeshType::MyConnType CurveIntersectorP1P1PL<MyMeshType,MyMatrix>::getNumberOfColsOfResMatrix() const
44 return this->_meshS.getNumberOfNodes();
47 template<class MyMeshType, class MyMatrix>
48 void CurveIntersectorP1P1PL<MyMeshType,MyMatrix>::AppendValueInMatrix2(typename MyMatrix::value_type& resRow, ConnType nodeIdS0, double val0)
50 typename MyMatrix::value_type::const_iterator iterRes(resRow.find(OTT<ConnType,numPol>::indFC(nodeIdS0)));
51 if(iterRes==resRow.end())
53 resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(nodeIdS0),val0));
57 double val((*iterRes).second+val0);
58 resRow.erase(OTT<ConnType,numPol>::indFC(nodeIdS0));
59 resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(nodeIdS0),val));
63 template<class MyMeshType, class MyMatrix>
64 void CurveIntersectorP1P1PL<MyMeshType,MyMatrix>::AppendValueInMatrix(MyMatrix& res, ConnType nodeIdT, ConnType nodeIdS0, double val0, ConnType nodeIdS1, double val1)
66 typename MyMatrix::value_type& resRow(res[nodeIdT]);
68 AppendValueInMatrix2(resRow,nodeIdS0,val0);
70 AppendValueInMatrix2(resRow,nodeIdS1,val1);
73 template<class MyMeshType, class MyMatrix>
74 void CurveIntersectorP1P1PL<MyMeshType,MyMatrix>::intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res)
76 std::vector<double> coordsT;
77 if(this->getRealTargetCoordinates(icellT,coordsT))
78 throw INTERP_KERNEL::Exception("Invalid target cell detected for meshdim==1. Only SEG2 supported !");
79 mcIdType nbOfNodesT(ToIdType(coordsT.size()/SPACEDIM));
80 for(typename std::vector<ConnType>::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++)
82 std::vector<double> coordsS;
83 if(this->getRealSourceCoordinates(*iter,coordsS))
84 throw INTERP_KERNEL::Exception("Invalid source cell detected for meshdim==1. Only SEG2 supported !");
85 assert(coordsS.size()/SPACEDIM==2);
86 ConnType nodeIdS0(this->getNodeIdOfSourceCellAt(*iter,0));
87 ConnType nodeIdS1(this->getNodeIdOfSourceCellAt(*iter,1));
88 for(mcIdType nodeIdT = 0 ; nodeIdT<nbOfNodesT ; ++nodeIdT)
90 ConnType nodeIdT0(this->getNodeIdOfTargetCellAt(icellT,nodeIdT));
92 if( this->isPtIncludedInSeg(coordsT.data()+nodeIdT*SPACEDIM,coordsS.data(),xs0,xs1,xt) )
95 this->ComputeBaryCoordsOf(xs0,xs1,xt,a,b);
96 AppendValueInMatrix(res,nodeIdT0,nodeIdS0,a,nodeIdS1,b);