1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "InterpolationOptions.hxx"
25 const double INTERP_KERNEL::InterpolationOptions::DFT_MEDIAN_PLANE=0.5;
27 const double INTERP_KERNEL::InterpolationOptions::DFT_SURF3D_ADJ_EPS=1.e-4;
29 const double INTERP_KERNEL::InterpolationOptions::DFT_MAX_DIST_3DSURF_INTERSECT=-1.;
31 const char INTERP_KERNEL::InterpolationOptions::PRECISION_STR[]="Precision";
33 const char INTERP_KERNEL::InterpolationOptions::MEDIANE_PLANE_STR[]="MedianPlane";
35 const char INTERP_KERNEL::InterpolationOptions::BOUNDING_BOX_ADJ_STR[]="BoundingBoxAdjustment";
37 const char INTERP_KERNEL::InterpolationOptions::BOUNDING_BOX_ADJ_ABS_STR[]="BoundingBoxAdjustmentAbs";
39 const char INTERP_KERNEL::InterpolationOptions::MAX_DISTANCE_3DSURF_INSECT_STR[]="MaxDistance3DSurfIntersect";
41 const char INTERP_KERNEL::InterpolationOptions::PRINT_LEV_STR[]="PrintLevel";
43 const char INTERP_KERNEL::InterpolationOptions::DO_ROTATE_STR[]="DoRotate";
45 const char INTERP_KERNEL::InterpolationOptions::ORIENTATION_STR[]="Orientation";
47 const char INTERP_KERNEL::InterpolationOptions::MEASURE_ABS_STR[]="MeasureAbs";
49 const char INTERP_KERNEL::InterpolationOptions::INTERSEC_TYPE_STR[]="IntersectionType";
51 const char INTERP_KERNEL::InterpolationOptions::SPLITTING_POLICY_STR[]="SplittingPolicy";
53 const char INTERP_KERNEL::InterpolationOptions::TRIANGULATION_INTERSECT2D_STR[]="Triangulation";
55 const char INTERP_KERNEL::InterpolationOptions::CONVEX_INTERSECT2D_STR[]="Convex";
57 const char INTERP_KERNEL::InterpolationOptions::GEOMETRIC_INTERSECT2D_STR[]="Geometric2D";
59 const char INTERP_KERNEL::InterpolationOptions::POINTLOCATOR_INTERSECT_STR[]="PointLocator";
61 const char INTERP_KERNEL::InterpolationOptions::PLANAR_SPLIT_FACE_5_STR[]="PLANAR_FACE_5";
63 const char INTERP_KERNEL::InterpolationOptions::PLANAR_SPLIT_FACE_6_STR[]="PLANAR_FACE_6";
65 const char INTERP_KERNEL::InterpolationOptions::GENERAL_SPLIT_24_STR[]="GENERAL_24";
67 const char INTERP_KERNEL::InterpolationOptions::GENERAL_SPLIT_48_STR[]="GENERAL_48";
69 void INTERP_KERNEL::InterpolationOptions::init()
72 _intersection_type=Triangulation;
74 _median_plane=DFT_MEDIAN_PLANE;
76 _bounding_box_adjustment=DFT_SURF3D_ADJ_EPS;
77 _bounding_box_adjustment_abs=0.;
78 _max_distance_for_3Dsurf_intersect=DFT_MAX_DIST_3DSURF_INTERSECT;
81 _splitting_policy=PLANAR_FACE_5;
82 _P1P0_bary_method=false;
85 std::string INTERP_KERNEL::InterpolationOptions::getIntersectionTypeRepr() const
87 if(_intersection_type==INTERP_KERNEL::Triangulation)
88 return std::string(TRIANGULATION_INTERSECT2D_STR);
89 else if(_intersection_type==INTERP_KERNEL::Convex)
90 return std::string(CONVEX_INTERSECT2D_STR);
91 else if(_intersection_type==INTERP_KERNEL::Geometric2D)
92 return std::string(GEOMETRIC_INTERSECT2D_STR);
93 else if(_intersection_type==INTERP_KERNEL::PointLocator)
94 return std::string(POINTLOCATOR_INTERSECT_STR);
96 return std::string("UNKNOWN_INTERSECT_TYPE");
99 bool INTERP_KERNEL::InterpolationOptions::setOptionDouble(const std::string& key, double value)
101 if(key==PRECISION_STR)
106 else if(key==MEDIANE_PLANE_STR)
108 setMedianPlane(value);
111 else if(key==BOUNDING_BOX_ADJ_STR)
113 setBoundingBoxAdjustment(value);
116 else if(key==BOUNDING_BOX_ADJ_ABS_STR)
118 setBoundingBoxAdjustmentAbs(value);
121 else if(key==MAX_DISTANCE_3DSURF_INSECT_STR)
123 setMaxDistance3DSurfIntersect(value);
130 bool INTERP_KERNEL::InterpolationOptions::setOptionInt(const std::string& key, int value)
132 if(key==PRINT_LEV_STR)
134 setPrintLevel(value);
137 else if(key==DO_ROTATE_STR)
139 setDoRotate(value != 0);
142 else if(key==ORIENTATION_STR)
144 setOrientation(value);
147 else if(key==MEASURE_ABS_STR)
149 bool valBool=(value!=0);
150 setMeasureAbsStatus(valBool);
157 bool INTERP_KERNEL::InterpolationOptions::setOptionString(const std::string& key, const std::string& value)
159 if(key==INTERSEC_TYPE_STR)
161 if(value==TRIANGULATION_INTERSECT2D_STR)
163 setIntersectionType(INTERP_KERNEL::Triangulation);
166 else if(value==CONVEX_INTERSECT2D_STR)
168 setIntersectionType(INTERP_KERNEL::Convex);
171 else if(value==GEOMETRIC_INTERSECT2D_STR)
173 setIntersectionType(INTERP_KERNEL::Geometric2D);
176 else if(value==POINTLOCATOR_INTERSECT_STR)
178 setIntersectionType(INTERP_KERNEL::PointLocator);
182 else if(key==SPLITTING_POLICY_STR)
184 if(value==PLANAR_SPLIT_FACE_5_STR)
186 setSplittingPolicy(INTERP_KERNEL::PLANAR_FACE_5);
189 else if(value==PLANAR_SPLIT_FACE_6_STR)
191 setSplittingPolicy(INTERP_KERNEL::PLANAR_FACE_6);
194 else if(value==GENERAL_SPLIT_24_STR)
196 setSplittingPolicy(INTERP_KERNEL::GENERAL_24);
199 else if(value==GENERAL_SPLIT_48_STR)
201 setSplittingPolicy(INTERP_KERNEL::GENERAL_48);
210 std::string INTERP_KERNEL::InterpolationOptions::getSplittingPolicyRepr() const
212 if(_splitting_policy==INTERP_KERNEL::PLANAR_FACE_5)
213 return std::string(PLANAR_SPLIT_FACE_5_STR);
214 else if(_splitting_policy==INTERP_KERNEL::PLANAR_FACE_6)
215 return std::string(PLANAR_SPLIT_FACE_6_STR);
216 else if(_splitting_policy==INTERP_KERNEL::GENERAL_24)
217 return std::string(GENERAL_SPLIT_24_STR);
218 else if(_splitting_policy==INTERP_KERNEL::GENERAL_48)
219 return std::string(GENERAL_SPLIT_48_STR);
221 return std::string("UNKNOWN_SPLITTING_POLICY");
224 std::string INTERP_KERNEL::InterpolationOptions::filterInterpolationMethod(const std::string& meth) const
226 if ( _P1P0_bary_method && meth == "P1P0" )
231 bool INTERP_KERNEL::InterpolationOptions::setInterpolationOptions(long print_level,
232 std::string intersection_type,
236 double bounding_box_adjustment,
237 double bounding_box_adjustment_abs,
238 double max_distance_for_3Dsurf_intersect,
241 std::string splitting_policy,
242 bool P1P0_bary_method )
244 _print_level=print_level;
245 _precision=precision;
246 _median_plane=median_plane;
247 _do_rotate=do_rotate;
248 _bounding_box_adjustment=bounding_box_adjustment;
249 _bounding_box_adjustment_abs=bounding_box_adjustment_abs;
250 _max_distance_for_3Dsurf_intersect=max_distance_for_3Dsurf_intersect;
251 _orientation=orientation;
252 _measure_abs=measure_abs;
253 _P1P0_bary_method=P1P0_bary_method;
254 return(setOptionString(INTERSEC_TYPE_STR,intersection_type) && setOptionString(SPLITTING_POLICY_STR,splitting_policy));
257 std::string INTERP_KERNEL::InterpolationOptions::printOptions() const
259 std::ostringstream oss; oss.precision(15); oss << "Interpolation Options ******" << std::endl;
260 oss << "Print level : " << _print_level << std::endl;
261 oss << "Intersection type : " << getIntersectionTypeRepr() << std::endl;
262 oss << "Precision : " << _precision << std::endl;
263 oss << "Median plane : " << _median_plane << std::endl;
264 oss << "Do Rotate status : " << std::boolalpha << _do_rotate << std::endl;
265 oss << "Bounding box adj : " << _bounding_box_adjustment << std::endl;
266 oss << "Bounding box adj abs : " << _bounding_box_adjustment_abs << std::endl;
267 oss << "Max distance for 3DSurf intersect : " << _max_distance_for_3Dsurf_intersect << std::endl;
268 oss << "Orientation : " << _orientation << std::endl;
269 oss << "Measure abs : " << _measure_abs << std::endl;
270 oss << "Splitting policy : " << getSplittingPolicyRepr() << std::endl;
271 oss << "P1P0 Barycentric method : " << _P1P0_bary_method << std::endl;
272 oss << "****************************" << std::endl;