]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
API modif : suppression of P1P0Bary policy. Now it is included in the intersection...
authorageay <ageay>
Mon, 19 Aug 2013 08:49:20 +0000 (08:49 +0000)
committerageay <ageay>
Mon, 19 Aug 2013 08:49:20 +0000 (08:49 +0000)
src/INTERP_KERNEL/Interpolation3D.txx
src/INTERP_KERNEL/InterpolationOptions.cxx
src/INTERP_KERNEL/InterpolationOptions.hxx
src/INTERP_KERNEL/InterpolationPlanar.txx
src/MEDCoupling/Test/MEDCouplingBasicsTestInterp.cxx
src/MEDCoupling_Swig/MEDCouplingRemapperTest.py

index 87ab6b14c43a6771c0ff92cbbb50fea4e23daf01..9edf10b4579e2fcef6b01ec712733de4de18b803 100644 (file)
@@ -132,17 +132,13 @@ namespace INTERP_KERNEL
           case PointLocator:
             intersector=new PointLocator3DIntersectorP1P0<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
             break;
+          case Barycentric:
+            intersector=new PolyhedronIntersectorP1P0Bary<MyMeshType,MatrixType>(targetMesh, srcMesh, getSplittingPolicy());
+            break;
           default:
-            throw INTERP_KERNEL::Exception("Invalid 3D intersection type for P1P0 interp specified : must be Triangle or PointLocator.");
+            throw INTERP_KERNEL::Exception("Invalid 3D intersection type for P1P0 interp specified : must be Triangle, PointLocator or Barycentric.");
           }
       }
-    else if(methC=="P1P0Bary")
-      {
-        if(InterpolationOptions::getIntersectionType()==Triangulation)
-          intersector=new PolyhedronIntersectorP1P0Bary<MyMeshType,MatrixType>(targetMesh, srcMesh, getSplittingPolicy());
-        else
-          throw INTERP_KERNEL::Exception("Invalid 3D intersection type specified : must be Triangle.");
-      }
     else if(methC=="P1P1")
       {
         switch(InterpolationOptions::getIntersectionType())
index cdfef798c11c2ff44f3f2f0ac866e12093917b67..c3551054a9ad987a33c486817c9c218a49ec196a 100644 (file)
@@ -58,6 +58,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";
@@ -79,7 +83,6 @@ void INTERP_KERNEL::InterpolationOptions::init()
   _orientation=0;
   _measure_abs=true;
   _splitting_policy=PLANAR_FACE_5;
-  _P1P0_bary_method=false;
 }
 
 std::string INTERP_KERNEL::InterpolationOptions::getIntersectionTypeRepr() const
@@ -92,6 +95,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");
 }
@@ -178,6 +185,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) 
     {
@@ -223,9 +240,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,
@@ -238,8 +253,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;
@@ -250,7 +264,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));
 }
 
@@ -268,7 +281,6 @@ 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();
 }
index b97d3db171198fe9e3bbe2753dc8eaf72fe6921d..53655259df6db2bba97e0f7084825731d93d9ff0 100644 (file)
@@ -28,7 +28,7 @@
 
 namespace INTERP_KERNEL
 {
-  typedef enum { Triangulation, Convex, Geometric2D, PointLocator } IntersectionType;
+  typedef enum { Triangulation, Convex, Geometric2D, PointLocator, Barycentric, BarycentricGeo2D } IntersectionType;
   
   /*!
    * \class InterpolationOptions
@@ -53,8 +53,6 @@ namespace INTERP_KERNEL
     int _orientation ;
     bool _measure_abs;
     SplittingPolicy _splitting_policy ;
-    bool _P1P0_bary_method; // issue 0020440
-
   public:
     InterpolationOptions() { init(); }
     int getPrintLevel() const { return _print_level; }
@@ -92,9 +90,6 @@ namespace INTERP_KERNEL
     void setSplittingPolicy(SplittingPolicy sp) { _splitting_policy=sp; }
     std::string getSplittingPolicyRepr() const;
 
-    void setP1P0BaryMethod(bool isP1P0) { _P1P0_bary_method=isP1P0; }
-    bool getP1P0BaryMethod() const { return _P1P0_bary_method; }
-
     std::string filterInterpolationMethod(const std::string& meth) const;
 
     void init();
@@ -109,8 +104,7 @@ namespace INTERP_KERNEL
                                  double max_distance_for_3Dsurf_intersect,
                                  long orientation,
                                  bool measure_abs,
-                                 std::string splitting_policy,
-                                 bool P1P0_bary_method );
+                                 std::string splitting_policy);
     void copyOptions(const InterpolationOptions & other) { *this = other; }
     bool setOptionDouble(const std::string& key, double value);
     bool setOptionInt(const std::string& key, int value);
@@ -136,6 +130,8 @@ namespace INTERP_KERNEL
     static const char CONVEX_INTERSECT2D_STR[];
     static const char GEOMETRIC_INTERSECT2D_STR[];
     static const char POINTLOCATOR_INTERSECT_STR[];
+    static const char BARYCENTRIC_INTERSECT_STR[];
+    static const char BARYCENTRICGEO2D_INTERSECT_STR[];
     static const char PLANAR_SPLIT_FACE_5_STR[];
     static const char PLANAR_SPLIT_FACE_6_STR[];
     static const char GENERAL_SPLIT_24_STR[];
index 110ff9d56813f55ca02b131602fdf20f69424294..92aa07407cd52af807f247c8eee5512ad596eb21 100644 (file)
@@ -264,41 +264,23 @@ namespace INTERP_KERNEL
                                                                        InterpolationOptions::getPrecision(),
                                                                        InterpolationOptions::getOrientation());
             break;
+          case Barycentric:
+             intersector=new TriangulationIntersector<MyMeshType,MatrixType,PlanarIntersectorP1P0Bary>(myMeshT,myMeshS,_dim_caracteristic,
+                                                                                                       InterpolationOptions::getPrecision(),
+                                                                                                       InterpolationOptions::getMaxDistance3DSurfIntersect(),
+                                                                                                       InterpolationOptions::getMedianPlane(),
+                                                                                                       InterpolationOptions::getOrientation(),
+                                                                                                       InterpolationOptions::getPrintLevel());
+             break;
+          case BarycentricGeo2D:
+            intersector=new Geometric2DIntersector<MyMeshType,MatrixType,PlanarIntersectorP1P0Bary>(myMeshT, myMeshS, _dim_caracteristic,
+                                                                                                    InterpolationOptions::getMaxDistance3DSurfIntersect(),
+                                                                                                    InterpolationOptions::getMedianPlane(),
+                                                                                                    InterpolationOptions::getPrecision(),
+                                                                                                    InterpolationOptions::getOrientation());
+            break;
           }
       }
-    else if(meth=="P1P0Bary")
-    {
-      switch (InterpolationOptions::getIntersectionType())
-      {
-      case Triangulation:
-        intersector=new TriangulationIntersector<MyMeshType,MatrixType,PlanarIntersectorP1P0Bary>(myMeshT,myMeshS,_dim_caracteristic,
-                                                                                                  InterpolationOptions::getPrecision(),
-                                                                                                  InterpolationOptions::getMaxDistance3DSurfIntersect(),
-                                                                                                  InterpolationOptions::getMedianPlane(),
-                                                                                                  InterpolationOptions::getOrientation(),
-                                                                                                  InterpolationOptions::getPrintLevel());
-        break;
-      case Convex:
-        intersector=new ConvexIntersector<MyMeshType,MatrixType,PlanarIntersectorP1P0Bary>(myMeshT,myMeshS,_dim_caracteristic,
-                                                                                           InterpolationOptions::getPrecision(),
-                                                                                           InterpolationOptions::getMaxDistance3DSurfIntersect(),
-                                                                                           InterpolationOptions::getMedianPlane(),
-                                                                                           InterpolationOptions::getDoRotate(),
-                                                                                           InterpolationOptions::getOrientation(),
-                                                                                           InterpolationOptions::getPrintLevel());
-        break;
-      case Geometric2D:
-        intersector=new Geometric2DIntersector<MyMeshType,MatrixType,PlanarIntersectorP1P0Bary>(myMeshT, myMeshS, _dim_caracteristic,
-                                                                                                InterpolationOptions::getMaxDistance3DSurfIntersect(),
-                                                                                                InterpolationOptions::getMedianPlane(),
-                                                                                                InterpolationOptions::getPrecision(),
-                                                                                                InterpolationOptions::getOrientation());
-        break;
-      case PointLocator:
-        throw INTERP_KERNEL::Exception("Invalid intersector (PointLocator) for P1P0Bary !");
-        break;
-      }
-    }
     else if(meth=="P1P1")
       {
         switch (InterpolationOptions::getIntersectionType())
index 27822158527ecd700dc41a540163c73d3d501822..cb0e0e8eb213e93d2ba6a89180de0fe86ffc8449 100644 (file)
@@ -1932,9 +1932,8 @@ void MEDCouplingBasicsTestInterp::test2DInterpP1P0Bary_1()
   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
   INTERP_KERNEL::Interpolation2D myInterpolator;
-  myInterpolator.setP1P0BaryMethod(true);
   std::vector<std::map<int,double> > res;
-  INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
+  INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Barycentric,INTERP_KERNEL::BarycentricGeo2D};
   for(int i=0;i<2;i++)
     {
       myInterpolator.setPrecision(1e-12);
@@ -1974,9 +1973,8 @@ void MEDCouplingBasicsTestInterp::test3DSurfInterpP1P0Bary_1()
   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
-  myInterpolator.setP1P0BaryMethod(true);
   std::vector<std::map<int,double> > res;
-  INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
+  INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Barycentric,INTERP_KERNEL::BarycentricGeo2D};
   for(int i=0;i<2;i++)
     {
       myInterpolator.setPrecision(1e-12);
@@ -2017,9 +2015,9 @@ void MEDCouplingBasicsTestInterp::test3DInterpP1P0Bary_1()
   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
   INTERP_KERNEL::Interpolation3D myInterpolator;
-  myInterpolator.setP1P0BaryMethod(true);
   std::vector<std::map<int,double> > res;
   myInterpolator.setPrecision(1e-12);
+  myInterpolator.setIntersectionType(INTERP_KERNEL::Barycentric);
   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
 
index 56b562278ed1d943edeea3633303e24a6170a4bf..795e66e61cbc30f2c6b16204d9f6f9952d6a2b12 100644 (file)
@@ -342,7 +342,7 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         f.setTime(5.6,7,8)
         f.setName("toto") ; f.setDescription("aDescription")
         p=MEDCouplingRemapper()
-        p.setP1P0BaryMethod(True)
+        p.setIntersectionType(Barycentric)
         p.prepare(um,um,"P1P0")
         fNode=p.reverseTransferField(f,1e300)
         self.assertEqual("toto",fNode.getName())