Back to index

salome-med  6.5.0
InterpolationOptions.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "InterpolationOptions.hxx"
00021 
00022 #include <sstream>
00023 
00024 const double INTERP_KERNEL::InterpolationOptions::DFT_MEDIAN_PLANE=0.5;
00025 
00026 const double INTERP_KERNEL::InterpolationOptions::DFT_SURF3D_ADJ_EPS=1.e-4;
00027 
00028 const double INTERP_KERNEL::InterpolationOptions::DFT_MAX_DIST_3DSURF_INTERSECT=-1.;
00029 
00030 const char INTERP_KERNEL::InterpolationOptions::PRECISION_STR[]="Precision";
00031 
00032 const char INTERP_KERNEL::InterpolationOptions::MEDIANE_PLANE_STR[]="MedianPlane";
00033 
00034 const char INTERP_KERNEL::InterpolationOptions::BOUNDING_BOX_ADJ_STR[]="BoundingBoxAdjustment";
00035 
00036 const char INTERP_KERNEL::InterpolationOptions::BOUNDING_BOX_ADJ_ABS_STR[]="BoundingBoxAdjustmentAbs";
00037 
00038 const char INTERP_KERNEL::InterpolationOptions::MAX_DISTANCE_3DSURF_INSECT_STR[]="MaxDistance3DSurfIntersect";
00039 
00040 const char INTERP_KERNEL::InterpolationOptions::PRINT_LEV_STR[]="PrintLevel";
00041 
00042 const char INTERP_KERNEL::InterpolationOptions::DO_ROTATE_STR[]="DoRotate";
00043 
00044 const char INTERP_KERNEL::InterpolationOptions::ORIENTATION_STR[]="Orientation";
00045 
00046 const char INTERP_KERNEL::InterpolationOptions::MEASURE_ABS_STR[]="MeasureAbs";
00047 
00048 const char INTERP_KERNEL::InterpolationOptions::INTERSEC_TYPE_STR[]="IntersectionType";
00049 
00050 const char INTERP_KERNEL::InterpolationOptions::SPLITTING_POLICY_STR[]="SplittingPolicy";
00051 
00052 const char INTERP_KERNEL::InterpolationOptions::TRIANGULATION_INTERSECT2D_STR[]="Triangulation";
00053 
00054 const char INTERP_KERNEL::InterpolationOptions::CONVEX_INTERSECT2D_STR[]="Convex";
00055 
00056 const char INTERP_KERNEL::InterpolationOptions::GEOMETRIC_INTERSECT2D_STR[]="Geometric2D";
00057 
00058 const char INTERP_KERNEL::InterpolationOptions::POINTLOCATOR_INTERSECT_STR[]="PointLocator";
00059 
00060 const char INTERP_KERNEL::InterpolationOptions::PLANAR_SPLIT_FACE_5_STR[]="PLANAR_FACE_5";
00061 
00062 const char INTERP_KERNEL::InterpolationOptions::PLANAR_SPLIT_FACE_6_STR[]="PLANAR_FACE_6";
00063 
00064 const char INTERP_KERNEL::InterpolationOptions::GENERAL_SPLIT_24_STR[]="GENERAL_24";
00065 
00066 const char INTERP_KERNEL::InterpolationOptions::GENERAL_SPLIT_48_STR[]="GENERAL_48";
00067 
00068 std::string INTERP_KERNEL::InterpolationOptions::getIntersectionTypeRepr() const
00069 {
00070   if(_intersection_type==INTERP_KERNEL::Triangulation)
00071     return std::string(TRIANGULATION_INTERSECT2D_STR);
00072   else if(_intersection_type==INTERP_KERNEL::Convex)
00073     return std::string(CONVEX_INTERSECT2D_STR);
00074   else if(_intersection_type==INTERP_KERNEL::Geometric2D)
00075     return std::string(GEOMETRIC_INTERSECT2D_STR);
00076   else if(_intersection_type==INTERP_KERNEL::PointLocator)
00077     return std::string(POINTLOCATOR_INTERSECT_STR);
00078   else
00079     return std::string("UNKNOWN_INTERSECT_TYPE");
00080 }
00081 
00082 bool INTERP_KERNEL::InterpolationOptions::setOptionDouble(const std::string& key, double value)
00083 {
00084   if(key==PRECISION_STR) 
00085     {
00086       setPrecision(value);
00087       return true;
00088     }
00089   else if(key==MEDIANE_PLANE_STR) 
00090     {
00091       setMedianPlane(value);
00092       return true;
00093     }
00094   else if(key==BOUNDING_BOX_ADJ_STR) 
00095     {
00096       setBoundingBoxAdjustment(value);
00097       return true;
00098     }
00099   else if(key==BOUNDING_BOX_ADJ_ABS_STR) 
00100     {
00101       setBoundingBoxAdjustmentAbs(value);
00102       return true;
00103     }
00104   else if(key==MAX_DISTANCE_3DSURF_INSECT_STR) 
00105     {
00106       setMaxDistance3DSurfIntersect(value);
00107       return true;
00108     }
00109   else
00110     return false;
00111 }
00112 
00113 bool INTERP_KERNEL::InterpolationOptions::setOptionInt(const std::string& key, int value)
00114 {
00115   if(key==PRINT_LEV_STR) 
00116     {
00117       setPrintLevel(value);
00118       return true;
00119     }
00120     else if(key==DO_ROTATE_STR) 
00121       {
00122         setDoRotate(value != 0);
00123         return true;
00124       }
00125     else if(key==ORIENTATION_STR) 
00126       {
00127         setOrientation(value);
00128         return true;
00129       }
00130     else if(key==MEASURE_ABS_STR)
00131       {
00132         bool valBool=(value!=0);
00133         setMeasureAbsStatus(valBool);
00134         return true;
00135       }
00136     else
00137       return false;
00138 }
00139 
00140 bool INTERP_KERNEL::InterpolationOptions::setOptionString(const std::string& key, const std::string& value)
00141 {
00142   if(key==INTERSEC_TYPE_STR) 
00143     {
00144       if(value==TRIANGULATION_INTERSECT2D_STR)
00145         {
00146           setIntersectionType(INTERP_KERNEL::Triangulation);
00147           return true;
00148         }
00149       else if(value==CONVEX_INTERSECT2D_STR)
00150         {
00151           setIntersectionType(INTERP_KERNEL::Convex);
00152           return true;
00153         }
00154       else if(value==GEOMETRIC_INTERSECT2D_STR)
00155         {
00156           setIntersectionType(INTERP_KERNEL::Geometric2D);
00157           return true;
00158         }
00159       else if(value==POINTLOCATOR_INTERSECT_STR)
00160         {
00161           setIntersectionType(INTERP_KERNEL::PointLocator);
00162           return true;
00163         }
00164     }
00165   else if(key==SPLITTING_POLICY_STR) 
00166     {
00167       if(value==PLANAR_SPLIT_FACE_5_STR)
00168         {
00169           setSplittingPolicy(INTERP_KERNEL::PLANAR_FACE_5);
00170           return true;
00171         }
00172       else if(value==PLANAR_SPLIT_FACE_6_STR)
00173         {
00174           setSplittingPolicy(INTERP_KERNEL::PLANAR_FACE_6);
00175           return true;
00176         }
00177       else if(value==GENERAL_SPLIT_24_STR)
00178         {
00179           setSplittingPolicy(INTERP_KERNEL::GENERAL_24);
00180           return true;
00181         }
00182       else if(value==GENERAL_SPLIT_48_STR)
00183         {
00184           setSplittingPolicy(INTERP_KERNEL::GENERAL_48);
00185           return true;
00186         }
00187       else
00188         return false;
00189     }
00190   return false;
00191 }
00192 
00193 std::string INTERP_KERNEL::InterpolationOptions::getSplittingPolicyRepr() const
00194 {
00195   if(_splitting_policy==INTERP_KERNEL::PLANAR_FACE_5)
00196     return std::string(PLANAR_SPLIT_FACE_5_STR);
00197   else if(_splitting_policy==INTERP_KERNEL::PLANAR_FACE_6)
00198     return std::string(PLANAR_SPLIT_FACE_6_STR);
00199   else if(_splitting_policy==INTERP_KERNEL::GENERAL_24)
00200     return std::string(GENERAL_SPLIT_24_STR);
00201   else if(_splitting_policy==INTERP_KERNEL::GENERAL_48)
00202     return std::string(GENERAL_SPLIT_48_STR);
00203   else
00204     return std::string("UNKNOWN_SPLITTING_POLICY");
00205 }
00206 
00207 std::string INTERP_KERNEL::InterpolationOptions::filterInterpolationMethod(const std::string& meth) const
00208 {
00209   if ( _P1P0_bary_method && meth == "P1P0" )
00210     return "P1P0Bary";
00211   return meth;
00212 }
00213 
00214 bool INTERP_KERNEL::InterpolationOptions::setInterpolationOptions(long print_level,
00215                                                                   std::string intersection_type,
00216                                                                   double precision,
00217                                                                   double median_plane,
00218                                                                   bool do_rotate,
00219                                                                   double bounding_box_adjustment,
00220                                                                   double bounding_box_adjustment_abs,
00221                                                                   double max_distance_for_3Dsurf_intersect,
00222                                                                   long orientation,
00223                                                                   bool measure_abs,
00224                                                                   std::string splitting_policy,
00225                                                                   bool P1P0_bary_method )
00226 {
00227   _print_level=print_level;
00228   _precision=precision;
00229   _median_plane=median_plane;
00230   _do_rotate=do_rotate;
00231   _bounding_box_adjustment=bounding_box_adjustment;
00232   _bounding_box_adjustment_abs=bounding_box_adjustment_abs;
00233   _max_distance_for_3Dsurf_intersect=max_distance_for_3Dsurf_intersect;
00234   _orientation=orientation;
00235   _measure_abs=measure_abs;
00236   _P1P0_bary_method=P1P0_bary_method;
00237   return(setOptionString(INTERSEC_TYPE_STR,intersection_type) && setOptionString(SPLITTING_POLICY_STR,splitting_policy));
00238 }
00239 
00240 std::string INTERP_KERNEL::InterpolationOptions::printOptions() const
00241 {
00242   std::ostringstream oss; oss.precision(15); oss << "Interpolation Options ******" << std::endl;
00243   oss << "Print level : " << _print_level << std::endl;
00244   oss << "Intersection type : " << getIntersectionTypeRepr() << std::endl;
00245   oss << "Precision : " << _precision << std::endl;
00246   oss << "Median plane : " << _median_plane << std::endl;
00247   oss << "Do Rotate status : " << std::boolalpha << _do_rotate << std::endl;
00248   oss << "Bounding box adj : " << _bounding_box_adjustment << std::endl;
00249   oss << "Bounding box adj abs : " << _bounding_box_adjustment_abs << std::endl;
00250   oss << "Max distance for 3DSurf intersect : " << _max_distance_for_3Dsurf_intersect << std::endl;
00251   oss << "Orientation : " << _orientation << std::endl;
00252   oss << "Measure abs : " << _measure_abs << std::endl;
00253   oss << "Splitting policy : " << getSplittingPolicyRepr() << std::endl;
00254   oss << "P1P0 Barycentric method : " << _P1P0_bary_method << std::endl;
00255   oss << "****************************" << std::endl;
00256   return oss.str();
00257 }