]> SALOME platform Git repositories - tools/medcoupling.git/blob - src/INTERP_KERNEL/PlanarIntersectorP0P1.txx
Salome HOME
Ensure that ShapeRecognition links against cblas
[tools/medcoupling.git] / src / INTERP_KERNEL / PlanarIntersectorP0P1.txx
1 // Copyright (C) 2007-2024  CEA, EDF
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 __PLANARINTERSECTORP0P1_TXX__
21 #define __PLANARINTERSECTORP0P1_TXX__
22
23 #include "PlanarIntersectorP0P1.hxx"
24 #include "InterpolationUtils.hxx"
25 #include "CellModel.hxx"
26
27 namespace INTERP_KERNEL
28 {
29   template<class MyMeshType, class MyMatrix, class ConcreteP0P1Intersector>
30   PlanarIntersectorP0P1<MyMeshType,MyMatrix,ConcreteP0P1Intersector>::PlanarIntersectorP0P1(const MyMeshType& meshT, const MyMeshType& meshS,
31                                                                                             double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane,
32                                                                                             bool doRotate, int orientation, int printLevel):
33     PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,minDot3DSurf,medianPlane,doRotate,orientation,printLevel)
34   {
35   }
36
37   template<class MyMeshType, class MyMatrix, class ConcreteP0P1Intersector>
38   typename MyMeshType::MyConnType PlanarIntersectorP0P1<MyMeshType,MyMatrix,ConcreteP0P1Intersector>::getNumberOfRowsOfResMatrix() const
39   {
40     return PlanarIntersector<MyMeshType,MyMatrix>::_meshT.getNumberOfNodes();
41   }
42
43   template<class MyMeshType, class MyMatrix, class ConcreteP0P1Intersector>
44   typename MyMeshType::MyConnType PlanarIntersectorP0P1<MyMeshType,MyMatrix,ConcreteP0P1Intersector>::getNumberOfColsOfResMatrix() const
45   {
46     return PlanarIntersector<MyMeshType,MyMatrix>::_meshS.getNumberOfElements();
47   }
48
49   /*!
50    * This methods split on the fly, into triangles in order to compute dual mesh of target cell (with icellT id in target mesh in C mode).
51    */
52   template<class MyMeshType, class MyMatrix, class ConcreteP0P1Intersector>
53   void PlanarIntersectorP0P1<MyMeshType,MyMatrix,ConcreteP0P1Intersector>::intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res)
54   {
55     ConnType nbNodesT=PlanarIntersector<MyMeshType,MyMatrix>::_connIndexT[icellT+1]-PlanarIntersector<MyMeshType,MyMatrix>::_connIndexT[icellT];
56     double triangle[9];
57     double quadrangle[12];
58     std::vector<double> sourceCellCoords;
59     int orientation=1;
60     const ConnType *startOfCellNodeConn=PlanarIntersector<MyMeshType,MyMatrix>::_connectT+OTT<ConnType,numPol>::conn2C(PlanarIntersector<MyMeshType,MyMatrix>::_connIndexT[icellT]);
61     for(ConnType nodeIdT=0;nodeIdT<nbNodesT;nodeIdT++)
62       {
63         ConnType curNodeTInCmode=OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[nodeIdT]);
64         std::copy(PlanarIntersector<MyMeshType,MyMatrix>::_coordsT+curNodeTInCmode*SPACEDIM,
65                   PlanarIntersector<MyMeshType,MyMatrix>::_coordsT+curNodeTInCmode*SPACEDIM+SPACEDIM,triangle);
66         typename MyMatrix::value_type& resRow=res[curNodeTInCmode];
67         for(typename std::vector<ConnType>::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++)
68           {
69             ConnType iS=*iter;
70             PlanarIntersector<MyMeshType,MyMatrix>::getRealSourceCoordinates(OTT<ConnType,numPol>::indFC(iS),sourceCellCoords);
71             for(ConnType subTriT=1;subTriT<=nbNodesT-2;subTriT++)
72               {
73                 std::copy(PlanarIntersector<MyMeshType,MyMatrix>::_coordsT+OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[(nodeIdT+subTriT)%nbNodesT])*SPACEDIM,
74                           PlanarIntersector<MyMeshType,MyMatrix>::_coordsT+OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[(nodeIdT+subTriT)%nbNodesT])*SPACEDIM+SPACEDIM,
75                           triangle+SPACEDIM);
76                 std::copy(PlanarIntersector<MyMeshType,MyMatrix>::_coordsT+OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[(nodeIdT+subTriT+1)%nbNodesT])*SPACEDIM,
77                           PlanarIntersector<MyMeshType,MyMatrix>::_coordsT+OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[(nodeIdT+subTriT+1)%nbNodesT])*SPACEDIM+SPACEDIM,
78                           triangle+2*SPACEDIM);
79                 fillDualCellOfTri<SPACEDIM>(triangle,quadrangle);
80                 std::vector<double> sourceCellCoordsTmp(sourceCellCoords);
81                 if(SPACEDIM==3)
82                   orientation=PlanarIntersector<MyMeshType,MyMatrix>::projectionThis(&sourceCellCoordsTmp[0],quadrangle,ToConnType(sourceCellCoords.size())/SPACEDIM,4);
83                 NormalizedCellType tS=PlanarIntersector<MyMeshType,MyMatrix>::_meshS.getTypeOfElement(OTT<ConnType,numPol>::indFC(iS));
84                 double surf=orientation*intersectGeometryWithQuadrangle(quadrangle,sourceCellCoordsTmp,CellModel::GetCellModel(tS).isQuadratic());
85                 surf=PlanarIntersector<MyMeshType,MyMatrix>::getValueRegardingOption(surf);
86                 if(surf!=0.)
87                   {
88                     typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT<ConnType,numPol>::indFC(iS));
89                     if(iterRes==resRow.end())
90                       resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(iS),surf));
91                     else
92                       {
93                         double val=(*iterRes).second+surf;
94                         resRow.erase(OTT<ConnType,numPol>::indFC(iS));
95                         resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(iS),val));
96                       }
97                   }
98               }
99           }
100       }
101   }
102 }
103
104 #endif