Salome HOME
Merge from V6_main 13/12/2012
[tools/medcoupling.git] / src / INTERP_KERNEL / InterpolationOptions.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 // Author : Anthony Geay (CEA/DEN)
20
21 #ifndef __INTERPOLATIONOPTIONS_HXX__
22 #define __INTERPOLATIONOPTIONS_HXX__
23
24 #include "INTERPKERNELDefines.hxx"
25
26 #include <string>
27
28 namespace INTERP_KERNEL
29 {
30   typedef enum { Triangulation, Convex, Geometric2D, PointLocator } IntersectionType;
31   /// Type describing the different ways in which the hexahedron can be split into tetrahedra.
32   /// The PLANAR_* policies persume that each face is to be considered planar, while the general
33   /// policies make no such hypothesis. The integer at the end gives the number of tetrahedra
34   /// that result from the split.
35   typedef enum  { PLANAR_FACE_5 = 5, PLANAR_FACE_6 = 6, GENERAL_24 = 24, GENERAL_48 = 48 } SplittingPolicy;
36   
37   /*!
38    * \class InterpolationOptions
39    * Class defining the options for all interpolation algorithms.
40    * 
41    * List of options, possible values and default values can be found on this page:
42    * \ref InterpKerIntersectors
43    */
44   class INTERPKERNEL_EXPORT InterpolationOptions
45   {
46   private:
47     int _print_level ;
48     IntersectionType _intersection_type;
49     double _precision;
50     double _median_plane ;
51     bool _do_rotate ;
52     //! this measure is relative to the caracteristic dimension
53     double _bounding_box_adjustment ;
54     //! this measure is absolute \b not relative to the cell size
55     double _bounding_box_adjustment_abs ;
56     double _max_distance_for_3Dsurf_intersect;
57     int _orientation ;
58     bool _measure_abs;
59     SplittingPolicy _splitting_policy ;
60     bool _P1P0_bary_method; // issue 0020440
61
62   public:
63     InterpolationOptions() { init(); }
64     int getPrintLevel() const { return _print_level; }
65     void setPrintLevel(int pl) { _print_level=pl; }
66
67     IntersectionType getIntersectionType() const { return _intersection_type; }
68     void setIntersectionType(IntersectionType it) { _intersection_type=it; }
69     std::string getIntersectionTypeRepr() const;
70
71     double getPrecision() const { return _precision; }
72     void setPrecision(double p) { _precision=p; }
73
74     double getMedianPlane() const { return _median_plane; }
75     void setMedianPlane(double mp) { _median_plane=mp; }
76     
77     bool getDoRotate() const { return _do_rotate; }
78     void setDoRotate( bool dr) { _do_rotate = dr; }
79     
80     double getBoundingBoxAdjustment() const { return _bounding_box_adjustment; }
81     void setBoundingBoxAdjustment(double bba) { _bounding_box_adjustment=bba; }
82
83     double getBoundingBoxAdjustmentAbs() const { return _bounding_box_adjustment_abs; }
84     void setBoundingBoxAdjustmentAbs(double bba) { _bounding_box_adjustment_abs=bba; }
85     
86     double getMaxDistance3DSurfIntersect() const { return _max_distance_for_3Dsurf_intersect; }
87     void setMaxDistance3DSurfIntersect(double bba) { _max_distance_for_3Dsurf_intersect=bba; }
88
89     int getOrientation() const { return _orientation; }
90     void setOrientation(int o) { _orientation=o; }
91
92     bool getMeasureAbsStatus() const { return _measure_abs; }
93     void setMeasureAbsStatus(bool newStatus) { _measure_abs=newStatus; }
94     
95     SplittingPolicy getSplittingPolicy() const { return _splitting_policy; }
96     void setSplittingPolicy(SplittingPolicy sp) { _splitting_policy=sp; }
97     std::string getSplittingPolicyRepr() const;
98
99     void setP1P0BaryMethod(bool isP1P0) { _P1P0_bary_method=isP1P0; }
100     bool getP1P0BaryMethod() const { return _P1P0_bary_method; }
101
102     std::string filterInterpolationMethod(const std::string& meth) const;
103
104     void init()
105     {  
106       _print_level=0;
107       _intersection_type=Triangulation;
108       _precision=1e-12;
109       _median_plane=DFT_MEDIAN_PLANE;
110       _do_rotate=true;
111       _bounding_box_adjustment=DFT_SURF3D_ADJ_EPS;
112       _bounding_box_adjustment_abs=0.;
113       _max_distance_for_3Dsurf_intersect=DFT_MAX_DIST_3DSURF_INTERSECT;
114       _orientation=0;
115       _measure_abs=true;
116       _splitting_policy=GENERAL_48;
117       _P1P0_bary_method=false;
118     }
119     bool setInterpolationOptions(long print_level,
120                                  std::string intersection_type,
121                                  double precision,
122                                  double median_plane,
123                                  bool do_rotate,
124                                  double bounding_box_adjustment,
125                                  double bounding_box_adjustment_abs,
126                                  double max_distance_for_3Dsurf_intersect,
127                                  long orientation,
128                                  bool measure_abs,
129                                  std::string splitting_policy,
130                                  bool P1P0_bary_method );
131     void copyOptions(const InterpolationOptions & other) { *this = other; }
132     bool setOptionDouble(const std::string& key, double value);
133     bool setOptionInt(const std::string& key, int value);
134     bool setOptionString(const std::string& key, const std::string& value);
135     std::string printOptions() const;
136   private:
137     static const double DFT_MEDIAN_PLANE;
138     static const double DFT_SURF3D_ADJ_EPS;
139     static const double DFT_MAX_DIST_3DSURF_INTERSECT;
140   public:
141     static const char PRECISION_STR[];
142     static const char MEDIANE_PLANE_STR[];
143     static const char BOUNDING_BOX_ADJ_STR[];
144     static const char BOUNDING_BOX_ADJ_ABS_STR[];
145     static const char MAX_DISTANCE_3DSURF_INSECT_STR[];
146     static const char PRINT_LEV_STR[];
147     static const char DO_ROTATE_STR[];
148     static const char ORIENTATION_STR[];
149     static const char MEASURE_ABS_STR[];
150     static const char INTERSEC_TYPE_STR[];
151     static const char SPLITTING_POLICY_STR[];
152     static const char TRIANGULATION_INTERSECT2D_STR[];
153     static const char CONVEX_INTERSECT2D_STR[];
154     static const char GEOMETRIC_INTERSECT2D_STR[];
155     static const char POINTLOCATOR_INTERSECT_STR[];
156     static const char PLANAR_SPLIT_FACE_5_STR[];
157     static const char PLANAR_SPLIT_FACE_6_STR[];
158     static const char GENERAL_SPLIT_24_STR[];
159     static const char GENERAL_SPLIT_48_STR[];
160   };
161
162 }
163 #endif