Salome HOME
2475eccec0a498787fd9d55587647e38148fc11e
[tools/medcoupling.git] / src / INTERP_KERNEL / IntersectorCU.hxx
1 // Copyright (C) 2009-2016  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      : IntersectorCU.hxx
20 // Created   : Thu Dec 17 12:30:17 2009
21 // Author    : Edward AGAPOV (eap)
22 //
23
24 #ifndef __IntersectorCU_HXX__
25 #define __IntersectorCU_HXX__
26
27 #include "TargetIntersector.hxx"
28 #include "NormalizedUnstructuredMesh.hxx"
29
30 namespace INTERP_KERNEL
31 {
32   template<class MyCMeshType, class MyUMeshType, class MyMatrix> class _StabIntersector;
33
34   template<class MyCMeshType, class MyUMeshType, class MyMatrix, class ConcreteIntersector=_StabIntersector<MyCMeshType,MyUMeshType,MyMatrix> >
35   class IntersectorCU : public TargetIntersector<MyCMeshType,MyMatrix>
36   {
37   public:
38     static const int SPACEDIM=MyCMeshType::MY_SPACEDIM;
39     static const int MESHDIM=MyCMeshType::MY_MESHDIM;
40     typedef typename MyUMeshType::MyConnType UConnType;
41     typedef typename MyCMeshType::MyConnType CConnType;
42   public:
43     //! \addtogroup InterpKerGrpIntCU @{
44     IntersectorCU(const MyCMeshType& meshS, const MyUMeshType& meshT);
45     //! @}
46     virtual ~IntersectorCU();
47     void getUElemBB(double* bb, UConnType iP);
48     void getUCoordinates(UConnType icell, std::vector<double>& coords);
49
50     int getNumberOfRowsOfResMatrix() const;
51     int getNumberOfColsOfResMatrix() const;
52     void intersectCells(CConnType icellU, const std::vector<CConnType>& icellC, MyMatrix& res);
53     double intersectGeometry(CConnType icellT, const std::vector<CConnType>& icellC) { return asLeaf().intersectGeometry(icellT,icellC); }
54   protected:
55     ConcreteIntersector& asLeaf() { return static_cast<ConcreteIntersector&>(*this); }
56
57   protected:
58     const UConnType *_connectU;
59     const UConnType *_connIndexU;
60     const double *  _coordsU;
61     const MyUMeshType& _meshU;
62
63     const double *     _coordsC[SPACEDIM];
64     int                _nbCellsC[SPACEDIM];
65     const MyCMeshType& _meshC;
66   };
67
68   // class to enable usage of IntersectorCU not for intersection but for access to data it encapsulates
69   template<class MyCMeshType, class MyUMeshType, class MyMatrix>
70   class _StabIntersector: public IntersectorCU<MyCMeshType, MyUMeshType, MyMatrix, _StabIntersector<MyCMeshType, MyUMeshType, MyMatrix> >
71   {
72   public:
73     _StabIntersector(const MyCMeshType& meshS, const MyUMeshType& meshT) : IntersectorCU<MyCMeshType, MyUMeshType, MyMatrix, _StabIntersector<MyCMeshType, MyUMeshType, MyMatrix> >(meshS, meshT) {}
74     double intersectGeometry(typename MyUMeshType::MyConnType icellT, const std::vector<typename MyCMeshType::MyConnType>& icellC) { throw Exception("You must provide an intersector as the 4-th template argument of IntersectorCU"); return 0; }
75   };
76 }
77
78 #endif