Salome HOME
Revert "Synchronize adm files"
[modules/med.git] / src / INTERP_KERNEL / IntersectorCU2D.txx
1 // Copyright (C) 2009-2014  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, 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 // File      : IntersectorCU2D.txx
20 // Created   : Thu Dec 17 14:17:49 2009
21 // Author    : Edward AGAPOV (eap)
22
23 #ifndef __IntersectorCU2D_TXX__
24 #define __IntersectorCU2D_TXX__
25
26 #include "IntersectorCU2D.hxx"
27 #include "IntersectorCU.txx"
28
29 #define IntersectorCU2D_TEMPLATE template<class MyCMeshType, class MyUMeshType, class MyMatrix>
30 #define INTERSECTOR_CU2D IntersectorCU2D<MyCMeshType, MyUMeshType, MyMatrix >
31 #define INTER_CU IntersectorCU<MyCMeshType,MyUMeshType,MyMatrix,IntersectorCU2D<MyCMeshType,MyUMeshType,MyMatrix> >
32
33
34 namespace INTERP_KERNEL
35 {
36   IntersectorCU2D_TEMPLATE
37   INTERSECTOR_CU2D::IntersectorCU2D(const MyCMeshType& meshS,
38                                     const MyUMeshType& meshT):
39     IntersectorCU<MyCMeshType, MyUMeshType, MyMatrix, IntersectorCU2D<MyCMeshType,MyUMeshType,MyMatrix> >( meshS, meshT ),
40     _intersector(meshT, meshT, 0,0,0,0,0,0,0 )
41   {
42     if ( MyCMeshType::MY_SPACEDIM != 2 || MyCMeshType::MY_MESHDIM != 2 ||
43          MyUMeshType::MY_SPACEDIM != 2 || MyUMeshType::MY_MESHDIM != 2 )
44       throw Exception("IntersectorCU2D(): Invalid mesh dimension, it must be 2");
45   }
46
47
48   //================================================================================
49   /*!
50    * \brief Calculate area of intersection of an unstructured cell and a cartesian one.
51    * The cartesian cell is given by its [i,j] indices
52    */
53   //================================================================================
54
55   IntersectorCU2D_TEMPLATE
56   double INTERSECTOR_CU2D::intersectGeometry(UConnType                     icellT,
57                                              const std::vector<CConnType>& icellS)
58   {
59     std::vector<double> uCoords;
60     this->getUCoordinates( icellT, uCoords );
61
62     NormalizedCellType tT = INTER_CU::_meshU.getTypeOfElement( _TMIU(icellT));
63     bool is_tgt_quad = CellModel::GetCellModel(tT).isQuadratic();
64
65     double quad[8] = { INTER_CU::_coordsC[0][icellS[0]],   INTER_CU::_coordsC[1][icellS[1]],
66                        INTER_CU::_coordsC[0][icellS[0]+1], INTER_CU::_coordsC[1][icellS[1]], 
67                        INTER_CU::_coordsC[0][icellS[0]+1], INTER_CU::_coordsC[1][icellS[1]+1], 
68                        INTER_CU::_coordsC[0][icellS[0]],   INTER_CU::_coordsC[1][icellS[1]+1] };
69
70     double surf = _intersector.intersectGeometryWithQuadrangle( quad,
71                                                                 uCoords,
72                                                                 is_tgt_quad);
73     return surf;
74   }
75 }
76 #endif