Salome HOME
Copyrights update 2015.
[modules/med.git] / src / INTERP_KERNEL / Intersector3D.txx
1 // Copyright (C) 2007-2015  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 __INTERSECTOR3D_TXX__
21 #define __INTERSECTOR3D_TXX__
22
23 #include "Intersector3D.hxx"
24
25 #include <algorithm>
26
27 namespace INTERP_KERNEL
28 {
29   template<class MyMeshType, class MyMatrix>
30   Intersector3D<MyMeshType,MyMatrix>::Intersector3D(const MyMeshType& targetMesh, const MyMeshType& srcMesh):_target_mesh(targetMesh),_src_mesh(srcMesh)
31   {
32   }
33
34   /*!
35    * @param icellT in format of MyMeshType.
36    */
37   template<class MyMeshType, class MyMatrix>
38   void Intersector3D<MyMeshType,MyMatrix>::getRealTargetCoordinates(ConnType icellT, std::vector<double>& coordsT) const
39   {
40     int nbNodesT=_target_mesh.getNumberOfNodesOfElement(icellT);
41     coordsT.resize(SPACEDIM*nbNodesT);
42     std::vector<double>::iterator iter=coordsT.begin();
43     for (ConnType iT=0; iT<nbNodesT; iT++)
44       {
45         const double *coordsCur=getCoordsOfNode(iT,icellT,_target_mesh);
46         iter=std::copy(coordsCur,coordsCur+SPACEDIM,iter);
47       }
48   }
49
50   /*!
51    * @param icellT in format of MyMeshType.
52    */
53   template<class MyMeshType, class MyMatrix>
54   void Intersector3D<MyMeshType,MyMatrix>::getRealSourceCoordinates(ConnType icellS, std::vector<double>& coordsS) const
55   {
56     int nbNodesS=_src_mesh.getNumberOfNodesOfElement(icellS);
57     coordsS.resize(SPACEDIM*nbNodesS);
58     std::vector<double>::iterator iter=coordsS.begin();
59     for (ConnType iS=0; iS<nbNodesS; iS++)
60       {
61         const double *coordsCur=getCoordsOfNode(iS,icellS,_src_mesh);
62         iter=std::copy(coordsCur,coordsCur+SPACEDIM,iter);
63       }
64   }
65
66   /*!
67    * @param icellT in C format.
68    * @return is in format of MyMeshType
69    */
70   template<class MyMeshType, class MyMatrix>
71   const typename MyMeshType::MyConnType *Intersector3D<MyMeshType,MyMatrix>::getStartConnOfTargetCell(ConnType icellT) const
72   {
73     const ConnType *myConectT=_target_mesh.getConnectivityPtr();
74     const ConnType *myConIndexT=_target_mesh.getConnectivityIndexPtr();
75     return myConectT+OTT<ConnType,numPol>::conn2C(myConIndexT[icellT]);
76   }
77
78   /*!
79    * @param icellT in C format.
80    * @return is in format of MyMeshType
81    */
82   template<class MyMeshType, class MyMatrix>
83   const typename MyMeshType::MyConnType *Intersector3D<MyMeshType,MyMatrix>::getStartConnOfSourceCell(ConnType icellS) const
84   {
85     const ConnType *myConectS=_src_mesh.getConnectivityPtr();
86     const ConnType *myConIndexS=_src_mesh.getConnectivityIndexPtr();
87     return myConectS+OTT<ConnType,numPol>::conn2C(myConIndexS[icellS]);
88   }
89
90   /*!
91    * @param icellS in format of MyMeshType.
92    * @param res ; out param in format of MyMeshType.
93    */
94   template<class MyMeshType, class MyMatrix>
95   void Intersector3D<MyMeshType,MyMatrix>::getConnOfSourceCell(ConnType icellS, typename std::vector<ConnType>& res) const
96   {
97     const ConnType *myConectS=_src_mesh.getConnectivityPtr();
98     const ConnType *myConIndexS=_src_mesh.getConnectivityIndexPtr();
99     ConnType start=myConIndexS[OTT<ConnType,numPol>::ind2C(icellS)];
100     ConnType end=myConIndexS[OTT<ConnType,numPol>::ind2C(icellS)+1];
101     int nbNodesS=end-start;
102     res.resize(nbNodesS);
103     std::copy(myConectS+OTT<ConnType,numPol>::conn2C(start),myConectS+OTT<ConnType,numPol>::conn2C(end),res.begin());
104   }
105 }
106
107 #endif