// Copyright (C) 2007-2019 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // Author : Anthony Geay (EDF R&D) #ifndef __CURVEINTERSECTORP1P1PL_TXX__ #define __CURVEINTERSECTORP1P1PL_TXX__ #include "CurveIntersectorP1P1PL.hxx" #include "CurveIntersector.txx" #include namespace INTERP_KERNEL { template CurveIntersectorP1P1PL::CurveIntersectorP1P1PL(const MyMeshType& meshT, const MyMeshType& meshS, double precision, double tolerance, double medianLine, int printLevel):CurveIntersector(meshT, meshS, precision, tolerance, medianLine, printLevel) { } template int CurveIntersectorP1P1PL::getNumberOfRowsOfResMatrix() const { return CurveIntersector::_meshT.getNumberOfNodes(); } template int CurveIntersectorP1P1PL::getNumberOfColsOfResMatrix() const { return CurveIntersector::_meshS.getNumberOfNodes(); } template void CurveIntersectorP1P1PL::AppendValueInMatrix2(typename MyMatrix::value_type& resRow, ConnType nodeIdS0, double val0) { typename MyMatrix::value_type::const_iterator iterRes(resRow.find(OTT::indFC(nodeIdS0))); if(iterRes==resRow.end()) { resRow.insert(std::make_pair(OTT::indFC(nodeIdS0),val0)); } else { double val((*iterRes).second+val0); resRow.erase(OTT::indFC(nodeIdS0)); resRow.insert(std::make_pair(OTT::indFC(nodeIdS0),val)); } } template void CurveIntersectorP1P1PL::AppendValueInMatrix(MyMatrix& res, ConnType nodeIdT, ConnType nodeIdS0, double val0, ConnType nodeIdS1, double val1) { typename MyMatrix::value_type& resRow(res[nodeIdT]); AppendValueInMatrix2(resRow,nodeIdS0,val0); AppendValueInMatrix2(resRow,nodeIdS1,val1); } template void CurveIntersectorP1P1PL::intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res) { std::vector coordsT; if(CurveIntersector::getRealTargetCoordinates(icellT,coordsT)) throw INTERP_KERNEL::Exception("Invalid target cell detected for meshdim==1. Only SEG2 supported !"); assert(coordsT.size()/SPACEDIM==2); for(typename std::vector::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++) { std::vector coordsS; if(CurveIntersector::getRealSourceCoordinates(*iter,coordsS)) throw INTERP_KERNEL::Exception("Invalid source cell detected for meshdim==1. Only SEG2 supported !"); assert(coordsS.size()/SPACEDIM==2); double xs0,xs1,xt0,xt1; double lgth(CurveIntersector::intersectSegmentsInternal(&coordsT[0],&coordsS[0],xs0,xs1,xt0,xt1)); ConnType nodeIdS0(CurveIntersector::getNodeIdOfSourceCellAt(*iter,0)); ConnType nodeIdS1(CurveIntersector::getNodeIdOfSourceCellAt(*iter,1)); if(lgth>0.) { double a,b; // for first ConnType nodeIdT0(CurveIntersector::getNodeIdOfTargetCellAt(icellT,0)); if(CurveIntersector::ComputeBaryCoordsOf(xs0,xs1,xt0,a,b)) { a*=lgth; b*=lgth; AppendValueInMatrix(res,nodeIdT0,nodeIdS0,a,nodeIdS1,b); } // ConnType nodeIdT1(CurveIntersector::getNodeIdOfTargetCellAt(icellT,1)); typename MyMatrix::value_type& resRow1=res[nodeIdT1]; if(CurveIntersector::ComputeBaryCoordsOf(xs0,xs1,xt1,a,b)) { a*=lgth; b*=lgth; AppendValueInMatrix(res,nodeIdT1,nodeIdS0,a,nodeIdS1,b); } } } } } #endif