Salome HOME
30fb35f1e72ef573e800576acfb22326eef4460d
[modules/med.git] / src / INTERP_KERNEL / IntersectorCU1D.txx
1 // Copyright (C) 2009-2013  OPEN CASCADE
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.
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 // File      : IntersectorCU1D.txx
20 // Created   : Thu Dec 17 14:17:49 2009
21 // Author    : Edward AGAPOV (eap)
22
23 #ifndef __IntersectorCU1D_TXX__
24 #define __IntersectorCU1D_TXX__
25
26 #include "IntersectorCU1D.hxx"
27 #include "IntersectorCU.txx"
28
29 #define  IntersectorCU1D_TEMPLATE template<class MyCMeshType, class MyUMeshType, class MyMatrix>
30 #define  INTERSECTOR_CU1D IntersectorCU1D<MyCMeshType,MyUMeshType,MyMatrix >
31 #define _INTER_CU         IntersectorCU  <MyCMeshType,MyUMeshType,MyMatrix,IntersectorCU1D<MyCMeshType,MyUMeshType,MyMatrix> >
32
33 namespace INTERP_KERNEL
34 {
35   //================================================================================
36   /*!
37    * \brief intersector of the unstructured mesh and the cartesian mesh in 1D
38    */
39   //================================================================================
40
41   IntersectorCU1D_TEMPLATE
42   INTERSECTOR_CU1D::IntersectorCU1D(const MyCMeshType& meshS,
43                                     const MyUMeshType& meshT):
44     _INTER_CU( meshS, meshT )
45   {
46     if ( MyCMeshType::MY_SPACEDIM != 1 || MyCMeshType::MY_MESHDIM != 1 ||
47          MyUMeshType::MY_SPACEDIM != 1 || MyUMeshType::MY_MESHDIM != 1 )
48       throw Exception("IntersectorCU1D(): Invalid mesh dimension, it must be 1");
49   }
50
51   //================================================================================
52   /*!
53    * \brief destructor
54    */
55   //================================================================================
56
57   IntersectorCU1D_TEMPLATE
58   INTERSECTOR_CU1D::~IntersectorCU1D()
59   {
60   }
61
62   //================================================================================
63   /*!
64    * \brief Calculate length of intersection of an unstructured cell and a cartesian one.
65    * The cartesian cell is given by its [i,j,k] indices
66    */
67   //================================================================================
68
69   IntersectorCU1D_TEMPLATE
70   double INTERSECTOR_CU1D::intersectGeometry(UConnType                     icellT,
71                                              const std::vector<CConnType>& icellS)
72   {
73     std::vector<double> coordsU;
74     _INTER_CU::getUCoordinates(icellT, coordsU);
75
76     const double* coordsC = & _INTER_CU::_coordsC[0][ _FMIC(icellS[0]) ];
77
78     double res = std::min( coordsU[1], coordsC[1] ) - std::max( coordsU[0], coordsC[0] );
79     return res;
80   }
81 }
82 #endif