Salome HOME
Bug fix: bounding box for quadratic elements spaceDim=2/meshDim=1 (i.e. SEG3)
[tools/medcoupling.git] / src / INTERP_KERNEL / InterpolationOptions.cxx
index 2e2e7def7193764f69bdde32a9ff52399fafbe4b..ebd37d1a1d533d4b06a2c4faa4bd55e7e9f2cec2 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+// Author : Anthony Geay (CEA/DEN)
 
 #include "InterpolationOptions.hxx"
+#include "InterpKernelException.hxx"
 
 #include <sstream>
 
@@ -57,6 +59,10 @@ const char INTERP_KERNEL::InterpolationOptions::GEOMETRIC_INTERSECT2D_STR[]="Geo
 
 const char INTERP_KERNEL::InterpolationOptions::POINTLOCATOR_INTERSECT_STR[]="PointLocator";
 
+const char INTERP_KERNEL::InterpolationOptions::BARYCENTRIC_INTERSECT_STR[]="Barycentric";
+
+const char INTERP_KERNEL::InterpolationOptions::BARYCENTRICGEO2D_INTERSECT_STR[]="BarycentricGeo2D";
+
 const char INTERP_KERNEL::InterpolationOptions::PLANAR_SPLIT_FACE_5_STR[]="PLANAR_FACE_5";
 
 const char INTERP_KERNEL::InterpolationOptions::PLANAR_SPLIT_FACE_6_STR[]="PLANAR_FACE_6";
@@ -65,6 +71,21 @@ const char INTERP_KERNEL::InterpolationOptions::GENERAL_SPLIT_24_STR[]="GENERAL_
 
 const char INTERP_KERNEL::InterpolationOptions::GENERAL_SPLIT_48_STR[]="GENERAL_48";
 
+void INTERP_KERNEL::InterpolationOptions::init()
+{
+  _print_level=0;
+  _intersection_type=Triangulation;
+  _precision=1e-12;
+  _median_plane=DFT_MEDIAN_PLANE;
+  _do_rotate=true;
+  _bounding_box_adjustment=DFT_SURF3D_ADJ_EPS;
+  _bounding_box_adjustment_abs=0.;
+  _max_distance_for_3Dsurf_intersect=DFT_MAX_DIST_3DSURF_INTERSECT;
+  _orientation=0;
+  _measure_abs=true;
+  _splitting_policy=PLANAR_FACE_5;
+}
+
 std::string INTERP_KERNEL::InterpolationOptions::getIntersectionTypeRepr() const
 {
   if(_intersection_type==INTERP_KERNEL::Triangulation)
@@ -75,6 +96,10 @@ std::string INTERP_KERNEL::InterpolationOptions::getIntersectionTypeRepr() const
     return std::string(GEOMETRIC_INTERSECT2D_STR);
   else if(_intersection_type==INTERP_KERNEL::PointLocator)
     return std::string(POINTLOCATOR_INTERSECT_STR);
+  else if(_intersection_type==INTERP_KERNEL::Barycentric)
+    return std::string(BARYCENTRIC_INTERSECT_STR);
+  else if(_intersection_type==INTERP_KERNEL::BarycentricGeo2D)
+    return std::string(BARYCENTRICGEO2D_INTERSECT_STR);
   else
     return std::string("UNKNOWN_INTERSECT_TYPE");
 }
@@ -161,6 +186,16 @@ bool INTERP_KERNEL::InterpolationOptions::setOptionString(const std::string& key
           setIntersectionType(INTERP_KERNEL::PointLocator);
           return true;
         }
+      else if(value==BARYCENTRIC_INTERSECT_STR)
+        {
+          setIntersectionType(INTERP_KERNEL::Barycentric);
+          return true;
+        }
+      else if(value==BARYCENTRICGEO2D_INTERSECT_STR)
+        {
+          setIntersectionType(INTERP_KERNEL::BarycentricGeo2D);
+          return true;
+        }
     }
   else if(key==SPLITTING_POLICY_STR) 
     {
@@ -206,9 +241,7 @@ std::string INTERP_KERNEL::InterpolationOptions::getSplittingPolicyRepr() const
 
 std::string INTERP_KERNEL::InterpolationOptions::filterInterpolationMethod(const std::string& meth) const
 {
-  if ( _P1P0_bary_method && meth == "P1P0" )
-    return "P1P0Bary";
-  return meth;
+  return std::string(meth);
 }
 
 bool INTERP_KERNEL::InterpolationOptions::setInterpolationOptions(long print_level,
@@ -221,8 +254,7 @@ bool INTERP_KERNEL::InterpolationOptions::setInterpolationOptions(long print_lev
                                                                   double max_distance_for_3Dsurf_intersect,
                                                                   long orientation,
                                                                   bool measure_abs,
-                                                                  std::string splitting_policy,
-                                                                  bool P1P0_bary_method )
+                                                                  std::string splitting_policy)
 {
   _print_level=print_level;
   _precision=precision;
@@ -233,7 +265,6 @@ bool INTERP_KERNEL::InterpolationOptions::setInterpolationOptions(long print_lev
   _max_distance_for_3Dsurf_intersect=max_distance_for_3Dsurf_intersect;
   _orientation=orientation;
   _measure_abs=measure_abs;
-  _P1P0_bary_method=P1P0_bary_method;
   return(setOptionString(INTERSEC_TYPE_STR,intersection_type) && setOptionString(SPLITTING_POLICY_STR,splitting_policy));
 }
 
@@ -251,7 +282,22 @@ std::string INTERP_KERNEL::InterpolationOptions::printOptions() const
   oss << "Orientation : " << _orientation << std::endl;
   oss << "Measure abs : " << _measure_abs << std::endl;
   oss << "Splitting policy : " << getSplittingPolicyRepr() << std::endl;
-  oss << "P1P0 Barycentric method : " << _P1P0_bary_method << std::endl;
   oss << "****************************" << std::endl;
   return oss.str();
 }
+
+void INTERP_KERNEL::InterpolationOptions::CheckAndSplitInterpolationMethod(const std::string& method, std::string& srcMeth, std::string& trgMeth)
+{
+  const int NB_OF_METH_MANAGED=4;
+  const char *METH_MANAGED[NB_OF_METH_MANAGED]={"P0P0","P0P1","P1P0","P1P1"};
+  bool found=false;
+  for(int i=0;i<NB_OF_METH_MANAGED && !found;i++)
+    found=(method==METH_MANAGED[i]);
+  if(!found)
+    {
+      std::string msg("The interpolation method : \'"); msg+=method; msg+="\' not managed by INTERP_KERNEL interpolators ! Supported are \"P0P0\", \"P0P1\", \"P1P0\" and \"P1P1\".";
+      throw INTERP_KERNEL::Exception(msg.c_str());
+    }
+  srcMeth=method.substr(0,2);
+  trgMeth=method.substr(2);
+}