Salome HOME
Merge from V6_main_20120808 08Aug12
[tools/medcoupling.git] / src / INTERP_KERNEL / PlanarIntersector.hxx
1 // Copyright (C) 2007-2012  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.
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
20 #ifndef __PLANARINTERSECTOR_HXX__
21 #define __PLANARINTERSECTOR_HXX__
22
23 #include "TargetIntersector.hxx"
24 #include "NormalizedUnstructuredMesh.hxx"
25
26 #include <map>
27 #include <set>
28
29 namespace INTERP_KERNEL
30 {
31   class TranslationRotationMatrix;
32   
33   template<class MyMeshType, class MyMatrix>
34   class PlanarIntersector : public TargetIntersector<MyMeshType,MyMatrix>
35   {
36   public:
37     static const int SPACEDIM=MyMeshType::MY_SPACEDIM;
38     static const int MESHDIM=MyMeshType::MY_MESHDIM;
39     typedef typename MyMeshType::MyConnType ConnType;
40     static const NumberingPolicy numPol=MyMeshType::My_numPol;
41     typedef typename std::map<int,std::set<int> > DuplicateFacesType;
42   public:
43     //! \addtogroup InterpKerGrpIntPlan @{
44     PlanarIntersector(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel);
45     //! @}
46     virtual ~PlanarIntersector();
47     void createBoundingBoxes(const MyMeshType& mesh, std::vector<double>& bbox);
48     void adjustBoundingBoxes(std::vector<double>& bbox, double surf3DAdjustmentEps, double surf3DAdjustmentEpsAbs);
49     inline void getElemBB(double* bb, const MyMeshType& mesh, ConnType iP, ConnType nb_nodes);
50     static int projection(double *Coords_A, double *Coords_B,
51                           int nb_NodesA, int nb_NodesB, double epsilon, double md3DSurf, double median_plane, bool do_rotate);
52     virtual const DuplicateFacesType* getIntersectFaces() const
53     {
54       return NULL;
55     }
56   protected :
57     int projectionThis(double *Coords_A, double *Coords_B, int nb_NodesA, int nb_NodesB);
58     void getRealTargetCoordinates(ConnType icellT, std::vector<double>& coordsT);
59     void getRealSourceCoordinates(ConnType icellS, std::vector<double>& coordsS);
60     void getRealTargetCoordinatesPermute(ConnType icellT, int offset, std::vector<double>& coordsT);
61     void getRealSourceCoordinatesPermute(ConnType icellS, int offset, std::vector<double>& coordsS);
62     void getRealCoordinates(ConnType icellT, ConnType icellS, ConnType nbNodesT, ConnType nbNodesS, std::vector<double>& coordsT, std::vector<double>& coordsS, int& orientation);
63     double getValueRegardingOption(double val) const;
64     static void rotate3DTriangle( double* PP1, double*PP2, double*PP3,
65                                   TranslationRotationMatrix& rotation_matrix);
66   protected:
67     const ConnType *_connectT;
68     const ConnType *_connectS;
69     const double *_coordsT;
70     const double *_coordsS;
71     const ConnType *_connIndexT;
72     const ConnType *_connIndexS;
73     const MyMeshType& _meshT;
74     const MyMeshType& _meshS;
75     double _dim_caracteristic;
76     double _max_distance_3Dsurf_intersect;
77     double _precision;
78     double _median_plane;
79     bool _do_rotate;
80     int _orientation;
81     int _print_level;
82   };
83 }
84
85 #endif