Salome HOME
topo2vol: use CEA repository
[tools/sat_salome.git] / products / patches / medcoupling_abn780.patch
1 diff -rupN MEDCOUPLING_orig/doc/user/doxygen/doxfiles/reference/interpolation/intersectors.dox MEDCOUPLING_new/doc/user/doxygen/doxfiles/reference/interpolation/intersectors.dox
2 --- MEDCOUPLING_orig/doc/user/doxygen/doxfiles/reference/interpolation/intersectors.dox 2017-01-23 09:08:42.640092940 +0100
3 +++ MEDCOUPLING_new/doc/user/doxygen/doxfiles/reference/interpolation/intersectors.dox  2017-01-23 09:10:56.995732061 +0100
4 @@ -11,7 +11,8 @@ Before reading on, remember the definiti
5  
6  - \subpage intersec-specifics
7  - \subpage interpkernelGeo2D
8 -- \subpage barycoords (used in some P1 intersectors/locators) 
9 +- \subpage barycoords (used in some P1 intersectors/locators)
10 +- \subpage mapped_bary (used in some P1P1 intersectors) 
11  
12  Some implementation details of the C++ code can also be found here: \ref interpkernel 
13  
14 diff -rupN MEDCOUPLING_orig/doc/user/doxygen/doxfiles/reference/interpolation/mapped_bary.dox MEDCOUPLING_new/doc/user/doxygen/doxfiles/reference/interpolation/mapped_bary.dox
15 --- MEDCOUPLING_orig/doc/user/doxygen/doxfiles/reference/interpolation/mapped_bary.dox  1970-01-01 01:00:00.000000000 +0100
16 +++ MEDCOUPLING_new/doc/user/doxygen/doxfiles/reference/interpolation/mapped_bary.dox   2017-01-23 09:10:56.995732061 +0100
17 @@ -0,0 +1,61 @@
18 +/*!
19 +\page mapped_bary Mapped barycentric coordinates algorithm
20 +
21 +Mapped barycentric intersection type ('MappedBarycentric') can be selected in space dim 2 (resp. 3) when
22 +working with quadrangle only (resp. hexaedrons only).
23 +
24 +It can only be used for P1P1 projection: for any point P within the quadrangle or the hexaedron, the 
25 +set of reduced coordinates is computed (x, y, z all comprised between 0 and 1).
26 +Then the field value at P is computed using the usual form functions of finite element method 
27 +((1-x)*(1-y), x*(1-y), (1-x)*y and x*y in 2D for example). 
28 +
29 +The algorithm used to compute the reduced coordinates differs in dim 2 and dim 3.
30 +
31 +\section mapped_bary2d Dimension 2
32 +
33 +Let O, A, B, C the four points of the quadrangle, clockwise. Without loss of generality 
34 +O is assumed to be the origin.
35 +A point P within the quadrangle is identified with vector OP and simply denoted P.
36 +
37 +A suitable mapping is such that, if (x,y) is the couple of reduced coordinates (with x and y both in [0,1])
38 + of a point P, then:
39 +\f[   \mathbf{P} = x\mathbf{C} + y\mathbf{A} + xy(\mathbf{B}- \mathbf{A}-\mathbf{C}) \f]
40 +
41 +This forms is the simplest one having a gradient which x component is constant in x, and similarly in y. 
42 +Furthermore the reduced coordinates 
43 +(0,0) (resp. (0,1), (1,0), and (1,1)) map to point O (resp. A, B, and C).
44 +
45 +Calling \f$\mathbf{N} = \mathbf{B}-\mathbf{A}-\mathbf{C}\f$ and developping for the 2 compos:
46 +
47 +\f[   p_x = C_x x + A_x y + N_x xy \f]
48 +\f[   p_y = C_y x + A_y y + N_y xy \f]
49 +
50 +Solving the first eq for x:
51 +\f[ x = \frac{p_x - y A_x }{C_x+yN_x}  \f]
52 +
53 +and injecting in second eq:
54 +\f[   (A_yN_x -N_yA_x)y^2 + (-p_yN_x -A_xC_y +A_yC_x+N_yp_x)y + (p_x C_y-p_yC_x)=0   \f] 
55 +solved in:
56 +\f[  y = \frac{-b \pm \sqrt{b^2 - 4 a c}}{2a} \f]
57 +where a, b and c are the coeffs of the 2nd order eq.
58 +
59 +This gives two possible couples of solution among which only one is in \f$[0,1]^2\f$.
60 +
61 +In case where \f$A_yN_x -N_yA_x = 0 \f$ we have a degenerated unique solution for $y$
62 +\f[ y = \frac{c}{b} \f]
63 +
64 +\subsection{Rectangle}
65 +
66 +Finally it is worth puting aside the case \f$\mathbf{N} = 0\f$ (rectangle), which boils down to solving an ordinary
67 +2-unknows system:
68 +\f[ x = \frac{p_x A_y - p_y A_x}{C_x A_y - C_y A_x}, y = \frac{C_x p_y-C_y p_x}{C_x A_y - C_y A_x} \f]
69 +
70 +
71 +\section mapped_bary3d Dimension 3  
72 +
73 +In three dimensions, adopting the same approach as above would lead to a 4th order equation to solve.
74 +A simpler approach has been chosen: the distance to each pair of parallel faces in the hexaedron is computed.   
75 +The ratios to the sum of the two distances is computed giving again a number between 0 and 1 for each of 
76 +the 3 directions.
77 +
78 +*/
79 diff -rupN MEDCOUPLING_orig/src/INTERP_KERNEL/CMakeLists.txt MEDCOUPLING_new/src/INTERP_KERNEL/CMakeLists.txt
80 --- MEDCOUPLING_orig/src/INTERP_KERNEL/CMakeLists.txt   2017-01-23 09:08:42.644093048 +0100
81 +++ MEDCOUPLING_new/src/INTERP_KERNEL/CMakeLists.txt    2017-01-23 09:10:57.060733806 +0100
82 @@ -35,6 +35,7 @@ SET(interpkernel_SOURCES
83    Interpolation3DSurf.cxx
84    Interpolation3D.cxx
85    Interpolation2D3D.cxx
86 +  Interpolation3D1D.cxx
87    MeshElement.cxx
88    InterpKernelMeshQuality.cxx
89    InterpKernelCellSimplify.cxx
90 diff -rupN MEDCOUPLING_orig/src/INTERP_KERNEL/Interpolation3D1D.cxx MEDCOUPLING_new/src/INTERP_KERNEL/Interpolation3D1D.cxx
91 --- MEDCOUPLING_orig/src/INTERP_KERNEL/Interpolation3D1D.cxx    1970-01-01 01:00:00.000000000 +0100
92 +++ MEDCOUPLING_new/src/INTERP_KERNEL/Interpolation3D1D.cxx     2017-01-23 09:10:57.069734048 +0100
93 @@ -0,0 +1,64 @@
94 +// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
95 +//
96 +// This library is free software; you can redistribute it and/or
97 +// modify it under the terms of the GNU Lesser General Public
98 +// License as published by the Free Software Foundation; either
99 +// version 2.1 of the License, or (at your option) any later version.
100 +//
101 +// This library is distributed in the hope that it will be useful,
102 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
103 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
104 +// Lesser General Public License for more details.
105 +//
106 +// You should have received a copy of the GNU Lesser General Public
107 +// License along with this library; if not, write to the Free Software
108 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
109 +//
110 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
111 +//
112 +// Author : Adrien Bruneton (CEA/DEN)
113 +
114 +#include "Interpolation3D1D.hxx"
115 +#include "Interpolation3D1D.txx"
116 +
117 +namespace INTERP_KERNEL
118 +{
119 +  /**
120 +   * \class Interpolation3D1D
121 +   * \brief Class used to calculate the interpolation between a 3D mesh and 1D mesh (in 3D space)
122 +   * Can be seen as a specialization of Interpolation3D, and allows notably the adjustment of bounind boxes.
123 +   * 
124 +   */
125 +
126 +  Interpolation3D1D::Interpolation3D1D()
127 +  {}
128 +
129 +  Interpolation3D1D::Interpolation3D1D(const InterpolationOptions& io):Interpolation<Interpolation3D1D>(io)
130 +  {}
131 +
132 +  /**
133 +   * Inspired from PlanarIntersector<MyMeshType,MyMatrix>::adjustBoundingBoxes
134 +   */
135 +  void Interpolation3D1D::adjustBoundingBoxes(std::vector<double>& bbox)
136 +  {
137 +    const int SPACE_DIM = 3;
138 +    const double adj = getBoundingBoxAdjustmentAbs();
139 +    const double adjRel = getBoundingBoxAdjustment();
140 +
141 +    long size = bbox.size()/(2*SPACE_DIM);
142 +    for (int i=0; i<size; i++)
143 +      {
144 +        double max=- std::numeric_limits<double>::max();
145 +        for(int idim=0; idim<SPACE_DIM; idim++)
146 +          {
147 +            double Dx=bbox[i*2*SPACE_DIM+1+2*idim]-bbox[i*2*SPACE_DIM+2*idim];
148 +            max=(max<Dx)?Dx:max;
149 +          }
150 +        for(int idim=0; idim<SPACE_DIM; idim++)
151 +          {
152 +            bbox[i*2*SPACE_DIM+2*idim  ] -= adjRel*max+adj;
153 +            bbox[i*2*SPACE_DIM+2*idim+1] += adjRel*max+adj;
154 +          }
155 +      }
156 +  }
157 +}
158 diff -rupN MEDCOUPLING_orig/src/INTERP_KERNEL/Interpolation3D1D.hxx MEDCOUPLING_new/src/INTERP_KERNEL/Interpolation3D1D.hxx
159 --- MEDCOUPLING_orig/src/INTERP_KERNEL/Interpolation3D1D.hxx    1970-01-01 01:00:00.000000000 +0100
160 +++ MEDCOUPLING_new/src/INTERP_KERNEL/Interpolation3D1D.hxx     2017-01-23 09:10:57.069734048 +0100
161 @@ -0,0 +1,45 @@
162 +// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
163 +//
164 +// This library is free software; you can redistribute it and/or
165 +// modify it under the terms of the GNU Lesser General Public
166 +// License as published by the Free Software Foundation; either
167 +// version 2.1 of the License, or (at your option) any later version.
168 +//
169 +// This library is distributed in the hope that it will be useful,
170 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
171 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
172 +// Lesser General Public License for more details.
173 +//
174 +// You should have received a copy of the GNU Lesser General Public
175 +// License along with this library; if not, write to the Free Software
176 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
177 +//
178 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
179 +//
180 +// Author : A Bruneton (CEA/DEN)
181 +
182 +#ifndef __INTERPOLATION3D1D_HXX__
183 +#define __INTERPOLATION3D1D_HXX__
184 +
185 +#include "INTERPKERNELDefines.hxx"
186 +#include "Interpolation.hxx"
187 +#include "NormalizedUnstructuredMesh.hxx"
188 +#include "InterpolationOptions.hxx"
189 +
190 +#include <vector>
191 +
192 +namespace INTERP_KERNEL
193 +{
194 +  class INTERPKERNEL_EXPORT Interpolation3D1D : public Interpolation<Interpolation3D1D>
195 +  {
196 +  public:
197 +    Interpolation3D1D();
198 +    Interpolation3D1D(const InterpolationOptions& io);
199 +    template<class MyMeshType, class MatrixType>
200 +    int interpolateMeshes(const MyMeshType& srcMesh, const MyMeshType& targetMesh, MatrixType& result, const std::string& method);
201 +  private:
202 +    void adjustBoundingBoxes(std::vector<double>& bbox);
203 +  };
204 +}
205 +
206 +#endif
207 diff -rupN MEDCOUPLING_orig/src/INTERP_KERNEL/Interpolation3D1D.txx MEDCOUPLING_new/src/INTERP_KERNEL/Interpolation3D1D.txx
208 --- MEDCOUPLING_orig/src/INTERP_KERNEL/Interpolation3D1D.txx    1970-01-01 01:00:00.000000000 +0100
209 +++ MEDCOUPLING_new/src/INTERP_KERNEL/Interpolation3D1D.txx     2017-01-23 09:10:57.343741406 +0100
210 @@ -0,0 +1,152 @@
211 +// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
212 +//
213 +// This library is free software; you can redistribute it and/or
214 +// modify it under the terms of the GNU Lesser General Public
215 +// License as published by the Free Software Foundation; either
216 +// version 2.1 of the License, or (at your option) any later version.
217 +//
218 +// This library is distributed in the hope that it will be useful,
219 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
220 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
221 +// Lesser General Public License for more details.
222 +//
223 +// You should have received a copy of the GNU Lesser General Public
224 +// License along with this library; if not, write to the Free Software
225 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
226 +//
227 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
228 +//
229 +// Author : Anthony Geay (CEA/DEN)
230 +
231 +#ifndef __INTERPOLATION3D1D_TXX__
232 +#define __INTERPOLATION3D1D_TXX__
233 +
234 +#include "Interpolation3D1D.hxx"
235 +#include "Interpolation.txx"
236 +#include "MeshElement.txx"
237 +#include "PointLocator3DIntersectorP0P0.txx"
238 +#include "PointLocator3DIntersectorP0P1.txx"
239 +#include "PointLocator3DIntersectorP1P0.txx"
240 +#include "PointLocator3DIntersectorP1P1.txx"
241 +#include "Log.hxx"
242 +
243 +#include "BBTree.txx"
244 +
245 +namespace INTERP_KERNEL
246 +{
247 +  /**
248 +   *  Very similar to Interpolation3D::interpolateMeshes, except for the bounding boxes that can be
249 +   *  adjusted in a similar fashion as in InterpolationPlanar::performAdjustmentOfBB()
250 +   **/
251 +  template<class MyMeshType, class MatrixType>
252 +  int Interpolation3D1D::interpolateMeshes(const MyMeshType& srcMesh, const MyMeshType& targetMesh, MatrixType& result, const std::string& method)
253 +  {
254 +    if(InterpolationOptions::getIntersectionType() != PointLocator)
255 +      INTERP_KERNEL::Exception("Invalid 3D/1D intersection type specified : must be PointLocator.");
256 +
257 +    typedef typename MyMeshType::MyConnType ConnType;
258 +    // create MeshElement objects corresponding to each element of the two meshes
259 +    const unsigned long numSrcElems = srcMesh.getNumberOfElements();
260 +    const unsigned long numTargetElems = targetMesh.getNumberOfElements();
261 +
262 +    LOG(2, "Source mesh has " << numSrcElems << " elements and target mesh has " << numTargetElems << " elements ");
263 +
264 +    std::vector<MeshElement<ConnType>*> srcElems(numSrcElems);
265 +    std::vector<MeshElement<ConnType>*> targetElems(numTargetElems);
266 +
267 +    std::map<MeshElement<ConnType>*, int> indices;
268 +
269 +    for(unsigned long i = 0 ; i < numSrcElems ; ++i)
270 +      srcElems[i] = new MeshElement<ConnType>(i, srcMesh);       
271 +
272 +    for(unsigned long i = 0 ; i < numTargetElems ; ++i)
273 +      targetElems[i] = new MeshElement<ConnType>(i, targetMesh);
274 +
275 +    Intersector3D<MyMeshType,MatrixType>* intersector=0;
276 +    std::string methC = InterpolationOptions::filterInterpolationMethod(method);
277 +    if(methC=="P0P0")
278 +      { intersector=new PointLocator3DIntersectorP0P0<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
279 +      }
280 +    else if(methC=="P0P1")
281 +      {  intersector=new PointLocator3DIntersectorP0P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
282 +      }
283 +    else if(methC=="P1P0")
284 +      {  intersector=new PointLocator3DIntersectorP1P0<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
285 +      }
286 +    else if(methC=="P1P1")
287 +      {  intersector=new PointLocator3DIntersectorP1P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
288 +      }
289 +    else
290 +      throw Exception("Invalid method choosed must be in \"P0P0\", \"P0P1\", \"P1P0\" or \"P1P1\".");
291 +    // create empty maps for all source elements
292 +    result.resize(intersector->getNumberOfRowsOfResMatrix());
293 +
294 +    // create BBTree structure
295 +    // - get bounding boxes
296 +    std::vector<double> bboxes(6*numSrcElems);
297 +    int* srcElemIdx = new int[numSrcElems];
298 +    for(unsigned long i = 0; i < numSrcElems ; ++i)
299 +      {
300 +        // get source bboxes in right order
301 +        const BoundingBox* box = srcElems[i]->getBoundingBox();
302 +        bboxes[6*i+0] = box->getCoordinate(BoundingBox::XMIN);
303 +        bboxes[6*i+1] = box->getCoordinate(BoundingBox::XMAX);
304 +        bboxes[6*i+2] = box->getCoordinate(BoundingBox::YMIN);
305 +        bboxes[6*i+3] = box->getCoordinate(BoundingBox::YMAX);
306 +        bboxes[6*i+4] = box->getCoordinate(BoundingBox::ZMIN);
307 +        bboxes[6*i+5] = box->getCoordinate(BoundingBox::ZMAX);
308 +
309 +        srcElemIdx[i] = srcElems[i]->getIndex();
310 +      }
311 +
312 +    adjustBoundingBoxes(bboxes);
313 +    const double *bboxPtr=0;
314 +    if(numSrcElems>0)
315 +      bboxPtr=&bboxes[0];
316 +    BBTree<3,ConnType> tree(bboxPtr, srcElemIdx, 0, numSrcElems);
317 +
318 +    // for each target element, get source elements with which to calculate intersection
319 +    // - calculate intersection by calling intersectCells
320 +    for(unsigned long i = 0; i < numTargetElems; ++i)
321 +      {
322 +        const BoundingBox* box = targetElems[i]->getBoundingBox();
323 +        const int targetIdx = targetElems[i]->getIndex();
324 +
325 +        // get target bbox in right order
326 +        double targetBox[6];
327 +        targetBox[0] = box->getCoordinate(BoundingBox::XMIN);
328 +        targetBox[1] = box->getCoordinate(BoundingBox::XMAX);
329 +        targetBox[2] = box->getCoordinate(BoundingBox::YMIN);
330 +        targetBox[3] = box->getCoordinate(BoundingBox::YMAX);
331 +        targetBox[4] = box->getCoordinate(BoundingBox::ZMIN);
332 +        targetBox[5] = box->getCoordinate(BoundingBox::ZMAX);
333 +
334 +        std::vector<ConnType> intersectElems;
335 +
336 +        tree.getIntersectingElems(targetBox, intersectElems);
337 +
338 +        if ( !intersectElems.empty() )
339 +          intersector->intersectCells(targetIdx,intersectElems,result);
340 +      }
341 +
342 +    // free allocated memory
343 +    delete [] srcElemIdx;
344 +
345 +    int ret=intersector->getNumberOfColsOfResMatrix();
346 +
347 +    delete intersector;
348 +
349 +    for(unsigned long i = 0 ; i < numSrcElems ; ++i)
350 +      {
351 +        delete srcElems[i];
352 +      }
353 +    for(unsigned long i = 0 ; i < numTargetElems ; ++i)
354 +      {
355 +        delete targetElems[i];
356 +      }
357 +    return ret;
358 +
359 +  }
360 +}
361 +
362 +#endif
363 diff -rupN MEDCOUPLING_orig/src/INTERP_KERNEL/Interpolation3D.txx MEDCOUPLING_new/src/INTERP_KERNEL/Interpolation3D.txx
364 --- MEDCOUPLING_orig/src/INTERP_KERNEL/Interpolation3D.txx      2017-01-23 09:08:42.646093103 +0100
365 +++ MEDCOUPLING_new/src/INTERP_KERNEL/Interpolation3D.txx       2017-01-23 09:10:57.343741406 +0100
366 @@ -35,6 +35,7 @@
367  #include "PolyhedronIntersectorP1P1.txx"
368  #include "PointLocator3DIntersectorP1P1.txx"
369  #include "Barycentric3DIntersectorP1P1.txx"
370 +#include "MappedBarycentric3DIntersectorP1P1.txx"
371  #include "Log.hxx"
372  // If defined, use recursion to traverse the binary search tree, else use the BBTree class
373  //#define USE_RECURSIVE_BBOX_FILTER
374 @@ -154,8 +155,11 @@ namespace INTERP_KERNEL
375            case Barycentric:
376              intersector=new Barycentric3DIntersectorP1P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
377              break;
378 +          case MappedBarycentric:
379 +            intersector=new MappedBarycentric3DIntersectorP1P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
380 +            break;
381            default:
382 -            throw INTERP_KERNEL::Exception("Invalid 3D intersection type for P1P1 interp specified : must be Triangle or PointLocator.");
383 +            throw INTERP_KERNEL::Exception("Invalid 3D intersection type for P1P1 interp specified : must be Triangle, PointLocator, Barycentric or MappedBarycentric.");
384            }
385        }
386      else
387 diff -rupN MEDCOUPLING_orig/src/INTERP_KERNEL/InterpolationOptions.hxx MEDCOUPLING_new/src/INTERP_KERNEL/InterpolationOptions.hxx
388 --- MEDCOUPLING_orig/src/INTERP_KERNEL/InterpolationOptions.hxx 2017-01-23 09:08:42.646093103 +0100
389 +++ MEDCOUPLING_new/src/INTERP_KERNEL/InterpolationOptions.hxx  2017-01-23 09:10:57.069734048 +0100
390 @@ -28,7 +28,7 @@
391  
392  namespace INTERP_KERNEL
393  {
394 -  typedef enum { Triangulation, Convex, Geometric2D, PointLocator, Barycentric, BarycentricGeo2D } IntersectionType;
395 +  typedef enum { Triangulation, Convex, Geometric2D, PointLocator, Barycentric, BarycentricGeo2D, MappedBarycentric } IntersectionType;
396    
397    /*!
398     * Class defining the options for all interpolation algorithms used in the \ref remapper "remapper" and
399 diff -rupN MEDCOUPLING_orig/src/INTERP_KERNEL/InterpolationPlanar.txx MEDCOUPLING_new/src/INTERP_KERNEL/InterpolationPlanar.txx
400 --- MEDCOUPLING_orig/src/INTERP_KERNEL/InterpolationPlanar.txx  2017-01-23 09:08:42.646093103 +0100
401 +++ MEDCOUPLING_new/src/INTERP_KERNEL/InterpolationPlanar.txx   2017-01-23 09:10:57.069734048 +0100
402 @@ -40,6 +40,8 @@
403  #include "PlanarIntersectorP1P0PL.txx"
404  #include "PlanarIntersectorP1P1PL.hxx"
405  #include "PlanarIntersectorP1P1PL.txx"
406 +#include "MappedBarycentric2DIntersectorP1P1.hxx"
407 +#include "MappedBarycentric2DIntersectorP1P1.txx"
408  #include "VectorUtils.hxx"
409  #include "BBTree.txx"
410  
411 @@ -358,8 +360,16 @@ namespace INTERP_KERNEL
412                                                                             InterpolationOptions::getPrecision(),
413                                                                             InterpolationOptions::getOrientation());
414              break;
415 +          case MappedBarycentric:
416 +            intersector=new MappedBarycentric2DIntersectorP1P1<MyMeshType,MatrixType>(myMeshT, myMeshS, _dim_caracteristic,
417 +                                                                                     InterpolationOptions::getMaxDistance3DSurfIntersect(),
418 +                                                                                     InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
419 +                                                                                     InterpolationOptions::getMedianPlane(),
420 +                                                                                     InterpolationOptions::getPrecision(),
421 +                                                                                     InterpolationOptions::getOrientation());
422 +            break;
423            default:
424 -            throw INTERP_KERNEL::Exception("For P1P1 planar interpolation possibities are : Triangulation, Convex, Geometric2D, PointLocator !");
425 +            throw INTERP_KERNEL::Exception("For P1P1 planar interpolation possibities are : Triangulation, Convex, Geometric2D, PointLocator, MappedBarycentric !");
426            }
427        }
428      else
429 diff -rupN MEDCOUPLING_orig/src/INTERP_KERNEL/InterpolationUtils.hxx MEDCOUPLING_new/src/INTERP_KERNEL/InterpolationUtils.hxx
430 --- MEDCOUPLING_orig/src/INTERP_KERNEL/InterpolationUtils.hxx   2017-01-23 09:08:42.646093103 +0100
431 +++ MEDCOUPLING_new/src/INTERP_KERNEL/InterpolationUtils.hxx    2017-01-23 09:10:57.343741406 +0100
432 @@ -23,6 +23,7 @@
433  
434  #include "INTERPKERNELDefines.hxx"
435  #include "InterpKernelException.hxx"
436 +#include "VolSurfUser.hxx"
437  
438  #include "NormalizedUnstructuredMesh.hxx"
439  
440 @@ -413,7 +414,7 @@ namespace INTERP_KERNEL
441    }
442  
443    /*!
444 -   * Calculate barycentric coordinates of a point p with respect to triangle or tetra verices.
445 +   * Calculate barycentric coordinates of a point p with respect to triangle or tetra vertices.
446     * This method makes 2 assumptions :
447     *    - this is a simplex
448     *    - spacedim == meshdim. For TRI3 and TRI6 spaceDim is expected to be equal to 2 and for TETRA4 spaceDim is expected to be equal to 3.
449 @@ -535,6 +536,136 @@ namespace INTERP_KERNEL
450        }
451    }
452  
453 +  /*!
454 +   * Calculate pseudo barycentric coordinates of a point p with respect to the quadrangle vertices.
455 +   * This method makes the assumption that:
456 +   *  - spacedim == meshdim (2 here).
457 +   *  - the point is within the quad
458 +   *  Quadratic elements are not supported yet.
459 +   *
460 +   *  A quadrangle can be described as 3 vectors, one point being taken as the origin.
461 +   *  Denoting A, B, C the three other points, any point P within the quad is written as
462 +   *    P = xA+ yC + xy(B-A-C)
463 +   *  This method solve those 2 equations (one per component) for x and y.
464 +   *
465 +
466 +          A------B
467 +          |      |
468 +          |      |
469 +          0------C
470 +   */
471 +  inline void quad_mapped_coords(const std::vector<const double*>& n, const double *p, double *bc)
472 +  {
473 +    double prec = 1.0e-14;
474 +    enum { _XX=0, _YY, _ZZ };
475 +
476 +    if(n.size() != 4)
477 +      throw INTERP_KERNEL::Exception("INTERP_KERNEL::quad_mapped_coords : unrecognized geometric type! Only QUAD4 supported.");
478 +
479 +    double A[2] = {n[1][_XX] - n[0][_XX],  n[1][_YY] - n[0][_YY]};
480 +    double B[2] = {n[2][_XX] - n[0][_XX],  n[2][_YY] - n[0][_YY]};
481 +    double C[2] = {n[3][_XX] - n[0][_XX],  n[3][_YY] - n[0][_YY]};
482 +    double N[2] = {B[_XX] - A[_XX] - C[_XX], B[_YY] - A[_YY] - C[_YY]};
483 +    double P[2] = {p[_XX] - n[0][_XX], p[_YY] - n[0][_YY]};
484 +
485 +    // degenerated case: a rectangle:
486 +    if (fabs(N[0]) < prec && fabs(N[1]) < prec)
487 +      {
488 +        double det = C[0]*A[1] -C[1]*A[0];
489 +        if (fabs(det) < prec)
490 +          throw INTERP_KERNEL::Exception("MappedBarycentric intersection type: quad_mapped_coords() has a degenerated 2x2 system!");
491 +        bc[0] = (P[0]*A[1]-P[1]*A[0])/det;
492 +        bc[1] = (P[1]*C[0]-P[0]*C[1])/det;
493 +        return;
494 +      }
495 +    double b,c ,a = A[1]*N[0]-A[0]*N[1];
496 +    bool cas1;
497 +    if (fabs(a) > 1.0e-14)
498 +      {
499 +        b = A[1]*C[0]+N[1]*P[0]-N[0]*P[1]-A[0]*C[1];
500 +        c = P[0]*C[1] - P[1]*C[0];
501 +        cas1 = true;
502 +      }
503 +    else
504 +      {
505 +        a = -C[1]*N[0]+C[0]*N[1];
506 +        b = A[1]*C[0]-N[1]*P[0]+N[0]*P[1]-A[0]*C[1];
507 +        c = -P[0]*A[1] + P[1]*A[0];
508 +        cas1 = false;
509 +      }
510 +    double delta = b*b - 4.0*a*c;
511 +    if (delta < 0.0)
512 +      throw INTERP_KERNEL::Exception("MappedBarycentric intersection type: quad_mapped_coords(): imaginary solutions!");
513 +    bc[1] = 0.5*(-b+sqrt(delta))/a;
514 +    if (bc[1] < -prec || bc[1] > (1.0+prec))
515 +      bc[1] = 0.5*(-b-sqrt(delta))/a;
516 +    if (bc[1] < -prec || bc[1] > (1.0+prec))
517 +      throw INTERP_KERNEL::Exception("MappedBarycentric intersection type: quad_mapped_coords(): point doesn't seem to be in quad4!");
518 +    if (cas1)
519 +      {
520 +        double denom = C[0]+bc[1]*N[0];
521 +        if (fabs(denom) < prec)
522 +          throw INTERP_KERNEL::Exception("MappedBarycentric intersection type: quad_mapped_coords(): point doesn't seem to be in quad4!");
523 +        bc[0] = (P[0]-bc[1]*A[0])/denom;
524 +        if (bc[0] < -prec || bc[0] > (1.0+prec))
525 +          throw INTERP_KERNEL::Exception("MappedBarycentric intersection type: quad_mapped_coords(): point doesn't seem to be in quad4!");
526 +      }
527 +    else
528 +      {
529 +        bc[0] = bc[1];
530 +        double denom = A[1]+bc[0]*N[1];
531 +        if (fabs(denom) < prec)
532 +          throw INTERP_KERNEL::Exception("MappedBarycentric intersection type: cuboid_mapped_coord(): point doesn't seem to be in quad4!");
533 +        bc[1] = (P[1]-bc[0]*C[1])/denom;
534 +        if (bc[1] < -prec || bc[1] > (1.0+prec))
535 +          throw INTERP_KERNEL::Exception("MappedBarycentric intersection type: cuboid_mapped_coord(): point doesn't seem to be in quad4!");
536 +      }
537 +  }
538 +
539 +  /*!
540 +   * Doing as in quad_mapped_coords() would lead to a 4th order equation ... So go simpler here:
541 +   * orthogonal distance to each pair of parallel faces is computed. The ratio gives a number in [0,1]
542 +   *
543 +   * Conventions:
544 +   *   - for HEXA8, point F (5) is taken to be the origin (see med file ref connec):
545 +   *          0 ------ 3
546 +             /|       /|
547 +            / |      / |
548 +           1 ------ 2  |
549 +           |  |     |  |
550 +           |  |     |  |
551 +           |  4-----|- 7
552 +           | /      | /
553 +           5 ------ 6
554 +
555 +   *
556 +   */
557 +
558 +  inline void cuboid_mapped_coords(const std::vector<const double*>& n, const double *p, double *bc)
559 +  {
560 +    double prec = 1.0e-14;
561 +    enum { _XX=0, _YY };
562 +    if (n.size() != 8)
563 +      throw INTERP_KERNEL::Exception("INTERP_KERNEL::cuboid_mapped_coords: unrecognized geometric type! Only HEXA8 supported.");
564 +
565 +    double dx1, dx2, dy1, dy2, dz1, dz2;
566 +    dx1 = OrthoDistanceFromPtToPlaneInSpaceDim3(p, n[4],n[5],n[1]);
567 +    dx2 = OrthoDistanceFromPtToPlaneInSpaceDim3(p, n[7],n[3],n[2]);
568 +
569 +    dy1 = OrthoDistanceFromPtToPlaneInSpaceDim3(p, n[5],n[6],n[2]);
570 +    dy2 = OrthoDistanceFromPtToPlaneInSpaceDim3(p, n[4],n[0],n[3]);
571 +
572 +    dz1 = OrthoDistanceFromPtToPlaneInSpaceDim3(p, n[5],n[4],n[7]);
573 +    dz2 = OrthoDistanceFromPtToPlaneInSpaceDim3(p, n[1],n[2],n[3]);
574 +
575 +    if (dx1 < -prec || dx2 < -prec || dy1 < -prec || dy2 < -prec || dz1 < -prec || dz2 < -prec)
576 +      throw INTERP_KERNEL::Exception("INTERP_KERNEL::cuboid_mapped_coords: point outside HEXA8");
577 +
578 +    bc[0] = dx1+dx2 < prec ? 0.5 : dx1/(dx1+dx2);
579 +    bc[1] = dy1+dy2 < prec ? 0.5 : dy1/(dy1+dy2);
580 +    bc[2] = dz1+dz2 < prec ? 0.5 : dz1/(dz1+dz2);
581 +  }
582 +
583    /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
584    /*         calcul la surface d'un polygone.                 */
585    /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
586 diff -rupN MEDCOUPLING_orig/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.hxx MEDCOUPLING_new/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.hxx
587 --- MEDCOUPLING_orig/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.hxx   1970-01-01 01:00:00.000000000 +0100
588 +++ MEDCOUPLING_new/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.hxx    2017-01-23 09:10:57.071734102 +0100
589 @@ -0,0 +1,44 @@
590 +// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
591 +//
592 +// This library is free software; you can redistribute it and/or
593 +// modify it under the terms of the GNU Lesser General Public
594 +// License as published by the Free Software Foundation; either
595 +// version 2.1 of the License, or (at your option) any later version.
596 +//
597 +// This library is distributed in the hope that it will be useful,
598 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
599 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
600 +// Lesser General Public License for more details.
601 +//
602 +// You should have received a copy of the GNU Lesser General Public
603 +// License along with this library; if not, write to the Free Software
604 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
605 +//
606 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
607 +//
608 +// Author : Adrien Bruneton (CEA/DEN)
609 +
610 +#ifndef __MappedBarycenter2DIntersectorP1P1_HXX__
611 +#define __MappedBarycenter2DIntersectorP1P1_HXX__
612 +
613 +#include "PlanarIntersector.hxx"
614 +
615 +namespace INTERP_KERNEL
616 +{
617 +  template<class MyMeshType, class MyMatrix>
618 +  class MappedBarycentric2DIntersectorP1P1 : public PlanarIntersector<MyMeshType,MyMatrix>
619 +  {
620 +   public:
621 +    static const int SPACEDIM=MyMeshType::MY_SPACEDIM;
622 +    static const int MESHDIM=MyMeshType::MY_MESHDIM;
623 +    typedef typename MyMeshType::MyConnType ConnType;
624 +    static const NumberingPolicy numPol=MyMeshType::My_numPol;
625 +  public:
626 +    MappedBarycentric2DIntersectorP1P1(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double md3DSurf, double minDot3DSurf, double medianPlane, double precision, int orientation);
627 +    void intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res);
628 +    int getNumberOfRowsOfResMatrix() const;
629 +    int getNumberOfColsOfResMatrix() const;
630 +  };
631 +}
632 +
633 +#endif
634 diff -rupN MEDCOUPLING_orig/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.txx MEDCOUPLING_new/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.txx
635 --- MEDCOUPLING_orig/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.txx   1970-01-01 01:00:00.000000000 +0100
636 +++ MEDCOUPLING_new/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.txx    2017-01-23 09:10:57.071734102 +0100
637 @@ -0,0 +1,111 @@
638 +// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
639 +//
640 +// This library is free software; you can redistribute it and/or
641 +// modify it under the terms of the GNU Lesser General Public
642 +// License as published by the Free Software Foundation; either
643 +// version 2.1 of the License, or (at your option) any later version.
644 +//
645 +// This library is distributed in the hope that it will be useful,
646 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
647 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
648 +// Lesser General Public License for more details.
649 +//
650 +// You should have received a copy of the GNU Lesser General Public
651 +// License along with this library; if not, write to the Free Software
652 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
653 +//
654 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
655 +//
656 +// Author : Adrien Bruneton (CEA/DEN)
657 +
658 +#ifndef __MappedBarycentric2DIntersectorP1P1_TXX__
659 +#define __MappedBarycentric2DIntersectorP1P1_TXX__
660 +
661 +#include "MappedBarycentric2DIntersectorP1P1.hxx"
662 +#include "PlanarIntersector.txx"
663 +#include "CellModel.hxx"
664 +
665 +#include "PointLocatorAlgos.txx"
666 +#include "MeshUtils.hxx"
667 +
668 +namespace INTERP_KERNEL
669 +{
670 +  template<class MyMeshType, class MyMatrix>
671 +  MappedBarycentric2DIntersectorP1P1<MyMeshType,MyMatrix>::MappedBarycentric2DIntersectorP1P1(const MyMeshType& meshT, const MyMeshType& meshS,
672 +                                                                        double dimCaracteristic, double md3DSurf, double minDot3DSurf,
673 +                                                                        double medianPlane, double precision, int orientation):
674 +    PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,minDot3DSurf,medianPlane,true,orientation,0)
675 +  {
676 +  }
677 +
678 +  template<class MyMeshType, class MyMatrix>
679 +  void MappedBarycentric2DIntersectorP1P1<MyMeshType,MyMatrix>::intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res)
680 +  {
681 +    std::vector<double> CoordsT;
682 +    PlanarIntersector<MyMeshType,MyMatrix>::getRealTargetCoordinates(OTT<ConnType,numPol>::indFC(icellT),CoordsT);
683 +    int nbOfNodesT=CoordsT.size()/SPACEDIM;
684 +    for(typename std::vector<ConnType>::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++)
685 +      {
686 +        NormalizedCellType tS=PlanarIntersector<MyMeshType,MyMatrix>::_meshS.getTypeOfElement(OTT<ConnType,numPol>::indFC(*iter));
687 +        if(tS!=NORM_QUAD4)
688 +          throw INTERP_KERNEL::Exception("Invalid source cell detected for meshdim==2. Only QUAD4 supported !");
689 +        std::vector<double> CoordsS;
690 +        PlanarIntersector<MyMeshType,MyMatrix>::getRealSourceCoordinates(OTT<ConnType,numPol>::indFC(*iter),CoordsS);
691 +        std::vector<double> CoordsTTmp(CoordsT);
692 +        if(SPACEDIM==3)
693 +          PlanarIntersector<MyMeshType,MyMatrix>::projectionThis(&CoordsS[0],&CoordsTTmp[0],CoordsS.size()/SPACEDIM,nbOfNodesT);
694 +        const ConnType *startOfCellNodeConnT=PlanarIntersector<MyMeshType,MyMatrix>::_connectT+OTT<ConnType,numPol>::conn2C(PlanarIntersector<MyMeshType,MyMatrix>::_connIndexT[icellT]);
695 +        for(int nodeIdT=0;nodeIdT<nbOfNodesT;nodeIdT++)
696 +          {
697 +            typename MyMatrix::value_type& resRow=res[OTT<ConnType,numPol>::ind2C(startOfCellNodeConnT[nodeIdT])];
698 +            if( PointLocatorAlgos<MyMeshType>::isElementContainsPointAlg2D(&CoordsTTmp[nodeIdT*SPACEDIM],&CoordsS[0],4,PlanarIntersector<MyMeshType,MyMatrix>::_precision) )
699 +              {
700 +                double mco[2];  // mapped coordinates in the quad4
701 +                std::vector<const double*> coo(4);
702 +                coo[0]=&CoordsS[0]; coo[1]=&CoordsS[SPACEDIM]; coo[2]=&CoordsS[2*SPACEDIM]; coo[3]=&CoordsS[3*SPACEDIM];
703 +                quad_mapped_coords(coo,&CoordsTTmp[nodeIdT*SPACEDIM],mco);
704 +
705 +                // Now use the form function of the QUAD4 to map the field values
706 +                double resLoc[4];
707 +                // See QUAD4 standard connectivity and cuboid_mapped_coords() convention:
708 +                resLoc[0] = (1.-mco[0]) * (1.-mco[1]);
709 +                resLoc[1] = (1.-mco[0]) *   mco[1]   ;
710 +                resLoc[2] =  mco[0]     *   mco[1]   ;
711 +                resLoc[3] =  mco[0]     * (1.-mco[1]);
712 +
713 +                const ConnType *startOfCellNodeConnS=PlanarIntersector<MyMeshType,MyMatrix>::_connectS+OTT<ConnType,numPol>::conn2C(PlanarIntersector<MyMeshType,MyMatrix>::_connIndexS[*iter]);
714 +                for(int nodeIdS=0;nodeIdS<4;nodeIdS++)
715 +                  {
716 +                    if(fabs(resLoc[nodeIdS])>PlanarIntersector<MyMeshType,MyMatrix>::_precision)
717 +                      {
718 +                        ConnType curNodeSInCmode=OTT<ConnType,numPol>::coo2C(startOfCellNodeConnS[nodeIdS]);
719 +                        typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT<ConnType,numPol>::indFC(curNodeSInCmode));
720 +                        if(iterRes==resRow.end())
721 +                          resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(curNodeSInCmode),resLoc[nodeIdS]));
722 +                        else
723 +                          {
724 +                            double val=(*iterRes).second+resLoc[nodeIdS];
725 +                            resRow.erase(OTT<ConnType,numPol>::indFC(curNodeSInCmode));
726 +                            resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(curNodeSInCmode),val));
727 +                          }
728 +                      }
729 +                  }
730 +              }
731 +          }
732 +      }
733 +  }
734 +
735 +  template<class MyMeshType, class MyMatrix>
736 +  int MappedBarycentric2DIntersectorP1P1<MyMeshType,MyMatrix>::getNumberOfRowsOfResMatrix() const
737 +  {
738 +    return PlanarIntersector<MyMeshType,MyMatrix>::_meshT.getNumberOfNodes();
739 +  }
740 +
741 +  template<class MyMeshType, class MyMatrix>
742 +  int MappedBarycentric2DIntersectorP1P1<MyMeshType,MyMatrix>::getNumberOfColsOfResMatrix() const
743 +  {
744 +    return PlanarIntersector<MyMeshType,MyMatrix>::_meshS.getNumberOfNodes();
745 +  }
746 +}
747 +
748 +#endif
749 diff -rupN MEDCOUPLING_orig/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.hxx MEDCOUPLING_new/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.hxx
750 --- MEDCOUPLING_orig/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.hxx   1970-01-01 01:00:00.000000000 +0100
751 +++ MEDCOUPLING_new/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.hxx    2017-01-23 09:10:57.071734102 +0100
752 @@ -0,0 +1,46 @@
753 +// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
754 +//
755 +// This library is free software; you can redistribute it and/or
756 +// modify it under the terms of the GNU Lesser General Public
757 +// License as published by the Free Software Foundation; either
758 +// version 2.1 of the License, or (at your option) any later version.
759 +//
760 +// This library is distributed in the hope that it will be useful,
761 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
762 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
763 +// Lesser General Public License for more details.
764 +//
765 +// You should have received a copy of the GNU Lesser General Public
766 +// License along with this library; if not, write to the Free Software
767 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
768 +//
769 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
770 +//
771 +// Author : Adrien Bruneton (CEA/DEN)
772 +
773 +#ifndef __MappedBarycentric3DIntersectorP1P1_HXX__
774 +#define __MappedBarycentric3DIntersectorP1P1_HXX__
775 +
776 +#include "Intersector3DP1P1.hxx"
777 +#include "NormalizedUnstructuredMesh.hxx"
778 +
779 +namespace INTERP_KERNEL
780 +{
781 +  template<class MyMeshType, class MyMatrix>
782 +  class MappedBarycentric3DIntersectorP1P1 : public Intersector3DP1P1<MyMeshType,MyMatrix>
783 +  { 
784 +  public:
785 +    static const int SPACEDIM=MyMeshType::MY_SPACEDIM;
786 +    static const int MESHDIM=MyMeshType::MY_MESHDIM;
787 +    typedef typename MyMeshType::MyConnType ConnType;
788 +    static const NumberingPolicy numPol=MyMeshType::My_numPol;
789 +  public:
790 +    MappedBarycentric3DIntersectorP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, double precision);
791 +    ~MappedBarycentric3DIntersectorP1P1();
792 +    void intersectCells(ConnType targetCell, const std::vector<ConnType>& srcCells, MyMatrix& res);
793 +  protected:
794 +    double _precision;
795 +  };
796 +}
797 +
798 +#endif
799 diff -rupN MEDCOUPLING_orig/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.txx MEDCOUPLING_new/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.txx
800 --- MEDCOUPLING_orig/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.txx   1970-01-01 01:00:00.000000000 +0100
801 +++ MEDCOUPLING_new/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.txx    2017-01-23 09:10:57.071734102 +0100
802 @@ -0,0 +1,113 @@
803 +// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
804 +//
805 +// This library is free software; you can redistribute it and/or
806 +// modify it under the terms of the GNU Lesser General Public
807 +// License as published by the Free Software Foundation; either
808 +// version 2.1 of the License, or (at your option) any later version.
809 +//
810 +// This library is distributed in the hope that it will be useful,
811 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
812 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
813 +// Lesser General Public License for more details.
814 +//
815 +// You should have received a copy of the GNU Lesser General Public
816 +// License along with this library; if not, write to the Free Software
817 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
818 +//
819 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
820 +//
821 +// Author : Adrien Bruneton (CEA/DEN)
822 +
823 +#ifndef __MAPPEDBARYCENTRIC3DINTERSECTORP1P1_TXX__
824 +#define __MAPPEDBARYCENTRIC3DINTERSECTORP1P1_TXX__
825 +
826 +#include "MappedBarycentric3DIntersectorP1P1.hxx"
827 +#include "Intersector3DP1P1.txx"
828 +#include "MeshUtils.hxx"
829 +
830 +namespace INTERP_KERNEL
831 +{
832 +
833 +  /**
834 +   * Constructor creating object from target cell global number 
835 +   * 
836 +   * @param targetMesh  mesh containing the target elements
837 +   * @param srcMesh     mesh containing the source elements
838 +   * @param policy      splitting policy to be used
839 +   */
840 +  template<class MyMeshType, class MyMatrix>
841 +  MappedBarycentric3DIntersectorP1P1<MyMeshType,MyMatrix>::MappedBarycentric3DIntersectorP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, double precision):
842 +    Intersector3DP1P1<MyMeshType,MyMatrix>(targetMesh,srcMesh),_precision(precision)
843 +  {
844 +  }
845 +
846 +  template<class MyMeshType, class MyMatrix>
847 +  MappedBarycentric3DIntersectorP1P1<MyMeshType,MyMatrix>::~MappedBarycentric3DIntersectorP1P1()
848 +  {
849 +  }
850 +
851 +  /**
852 +   * @param targetCell in C mode.
853 +   * @param srcCells in C mode.
854 +   */
855 +  template<class MyMeshType, class MyMatrix>
856 +  void MappedBarycentric3DIntersectorP1P1<MyMeshType,MyMatrix>::intersectCells(ConnType targetCell, const std::vector<ConnType>& srcCells, MyMatrix& res)
857 +  {
858 +    std::vector<double> CoordsT;
859 +    const ConnType *startOfCellNodeConnT=Intersector3DP1P1<MyMeshType,MyMatrix>::getStartConnOfTargetCell(targetCell);
860 +    Intersector3DP1P1<MyMeshType,MyMatrix>::getRealTargetCoordinates(OTT<ConnType,numPol>::indFC(targetCell),CoordsT);
861 +    int nbOfNodesT=CoordsT.size()/SPACEDIM;
862 +    const double *coordsS=Intersector3DP1P1<MyMeshType,MyMatrix>::_src_mesh.getCoordinatesPtr();
863 +    for(int nodeIdT=0;nodeIdT<nbOfNodesT;nodeIdT++)
864 +      {
865 +        typename MyMatrix::value_type& resRow=res[OTT<ConnType,numPol>::ind2C(startOfCellNodeConnT[nodeIdT])];
866 +        if(!resRow.empty())
867 +          continue;
868 +        for(typename std::vector<ConnType>::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++)
869 +          {
870 +            NormalizedCellType tS=Intersector3DP1P1<MyMeshType,MyMatrix>::_src_mesh.getTypeOfElement(OTT<ConnType,numPol>::indFC(*iterCellS));
871 +            if(tS!=NORM_HEXA8)
872 +              throw INTERP_KERNEL::Exception("Invalid source cell detected for meshdim==3. Only HEXA8 supported !");
873 +            const CellModel& cmTypeS=CellModel::GetCellModel(tS);
874 +            //
875 +            std::vector<ConnType> connOfCurCellS;
876 +            Intersector3DP1P1<MyMeshType,MyMatrix>::getConnOfSourceCell(OTT<ConnType,numPol>::indFC(*iterCellS),connOfCurCellS);
877 +            if( PointLocatorAlgos<MyMeshType>::isElementContainsPointAlg3D(&CoordsT[nodeIdT*SPACEDIM],&connOfCurCellS[0],connOfCurCellS.size(),coordsS,cmTypeS,_precision) )
878 +              {
879 +                double mco[3];  // mapped coordinates in the hexa8
880 +                std::vector<double> localCoordsS;
881 +                Intersector3DP1P1<MyMeshType,MyMatrix>::getRealSourceCoordinates(OTT<ConnType,numPol>::indFC(*iterCellS),localCoordsS);
882 +                std::vector<const double*> coo(8);
883 +                coo[0]=&localCoordsS[0]; coo[1]=&localCoordsS[3]; coo[2]=&localCoordsS[6]; coo[3]=&localCoordsS[9];
884 +                coo[4]=&localCoordsS[12]; coo[5]=&localCoordsS[15]; coo[6]=&localCoordsS[18]; coo[7]=&localCoordsS[21];
885 +                cuboid_mapped_coords(coo,&CoordsT[nodeIdT*SPACEDIM],mco);
886 +
887 +                // Now use the form function of the HEXA8 to map the field values
888 +                double resLoc[8];
889 +                // See HEXA8 standard connectivity and cuboid_mapped_coords() convention:
890 +                resLoc[5] = (1.-mco[0]) * (1.-mco[1]) * (1.-mco[2]);
891 +                resLoc[6] =  mco[0]     * (1.-mco[1]) * (1.-mco[2]);
892 +                resLoc[7] =  mco[0]     *   mco[1]    * (1.-mco[2]);
893 +                resLoc[4] = (1.-mco[0]) *   mco[1]    * (1.-mco[2]);
894 +
895 +                resLoc[1] = (1.-mco[0]) * (1.-mco[1]) * mco[2];
896 +                resLoc[2] =  mco[0]     * (1.-mco[1]) * mco[2];
897 +                resLoc[3] =  mco[0]     *   mco[1]    * mco[2];
898 +                resLoc[0] = (1.-mco[0]) *   mco[1]    * mco[2];
899 +
900 +                const ConnType *startOfCellNodeConnS=Intersector3DP1P1<MyMeshType,MyMatrix>::getStartConnOfSourceCell(*iterCellS);
901 +                for(int nodeIdS=0;nodeIdS<8;nodeIdS++)
902 +                  {
903 +                    if(fabs(resLoc[nodeIdS])>_precision)
904 +                      {
905 +                        ConnType curNodeSInCmode=OTT<ConnType,numPol>::coo2C(startOfCellNodeConnS[nodeIdS]);
906 +                        resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(curNodeSInCmode),resLoc[nodeIdS]));
907 +                      }
908 +                  }
909 +              }
910 +          }
911 +      }
912 +  }
913 +}
914 +
915 +#endif
916 diff -rupN MEDCOUPLING_orig/src/INTERP_KERNEL/VolSurfUser.cxx MEDCOUPLING_new/src/INTERP_KERNEL/VolSurfUser.cxx
917 --- MEDCOUPLING_orig/src/INTERP_KERNEL/VolSurfUser.cxx  2017-01-23 09:08:42.647093130 +0100
918 +++ MEDCOUPLING_new/src/INTERP_KERNEL/VolSurfUser.cxx   2017-01-23 09:10:57.078734290 +0100
919 @@ -28,6 +28,25 @@
920  
921  namespace INTERP_KERNEL
922  {
923 +  /* Orthogonal distance from a point to a plane defined by three points p1, p2, p3.
924 +   * Returns a signed distance, the normal of the plane being defined by (p1-p2)x(p3-p2)
925 +   */
926 +  double OrthoDistanceFromPtToPlaneInSpaceDim3(const double *p, const double *p1, const double *p2, const double *p3)
927 +  {
928 +    double prec = 1.0e-14;
929 +    double T[2][3] = {{p1[0] - p2[0], p1[1] - p2[1], p1[2] - p2[2]},
930 +                      {p3[0] - p2[0], p3[1] - p2[1], p3[2] - p2[2]}};
931 +    double N[3] = {T[0][1]*T[1][2]-T[0][2]*T[1][1],
932 +                   T[0][2]*T[1][0]-T[0][0]*T[1][2],
933 +                   T[0][0]*T[1][1]-T[0][1]*T[1][0]};
934 +
935 +    double norm2 = N[0]*N[0] + N[1]*N[1] + N[2]*N[2];
936 +    if (norm2 < prec)
937 +      throw INTERP_KERNEL::Exception("OrthoDistanceFromPtToPlaneInSpaceDim3: degenerated normal vector!");
938 +    double num = N[0]*(p[0]-p1[0]) + N[1]*(p[1]-p1[1]) + N[2]*(p[2]-p1[2]);
939 +    return num/sqrt(norm2);
940 +  }
941 +
942    double SquareDistanceFromPtToSegInSpaceDim2(const double *pt, const double *pt0Seg2, const double *pt1Seg2, std::size_t &nbOfHint)
943    {
944      double dx=pt1Seg2[0]-pt0Seg2[0],dy=pt1Seg2[1]-pt0Seg2[1];
945 diff -rupN MEDCOUPLING_orig/src/INTERP_KERNEL/VolSurfUser.hxx MEDCOUPLING_new/src/INTERP_KERNEL/VolSurfUser.hxx
946 --- MEDCOUPLING_orig/src/INTERP_KERNEL/VolSurfUser.hxx  2017-01-23 09:08:42.647093130 +0100
947 +++ MEDCOUPLING_new/src/INTERP_KERNEL/VolSurfUser.hxx   2017-01-23 09:10:57.078734290 +0100
948 @@ -39,6 +39,8 @@ namespace INTERP_KERNEL
949    template<class ConnType, NumberingPolicy numPolConn>
950    void computeBarycenter2(NormalizedCellType type, const ConnType *connec, int lgth, const double *coords, int spaceDim, double *res);
951  
952 +  double INTERPKERNEL_EXPORT OrthoDistanceFromPtToPlaneInSpaceDim3(const double *p, const double *p1, const double *p2, const double *p3);
953 +
954    double INTERPKERNEL_EXPORT SquareDistanceFromPtToSegInSpaceDim2(const double *pt, const double *pt0Seg2, const double *pt1Seg2, std::size_t &nbOfHint);
955  
956    double INTERPKERNEL_EXPORT DistanceFromPtToTriInSpaceDim3(const double *pt, const double *pt0Tri3, const double *pt1Tri3, const double *pt2Tri3);
957 diff -rupN MEDCOUPLING_orig/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx MEDCOUPLING_new/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx
958 --- MEDCOUPLING_orig/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx    2017-01-23 09:08:42.648093157 +0100
959 +++ MEDCOUPLING_new/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx     2017-01-23 09:10:57.083734424 +0100
960 @@ -342,5 +342,148 @@ namespace INTERP_TEST
961      CPPUNIT_ASSERT_DOUBLES_EQUAL( p[0], p2[0], 1e-12);
962      CPPUNIT_ASSERT_DOUBLES_EQUAL( p[1], p2[1], 1e-12);
963      CPPUNIT_ASSERT_DOUBLES_EQUAL( p[2], p2[2], 1e-12);
964 -  }  
965 +  }
966 +
967 +  /* Conventions:
968 +  *   - for HEXA8, point 5 is taken to be the origin (see med file ref connec):
969 +  *          0 ------ 3
970 +            /|       /|
971 +           / |      / |
972 +          1 ------ 2  |
973 +          |  |     |  |
974 +          |  |     |  |
975 +          |  4-----|- 7
976 +          | /      | /
977 +          5 ------ 6
978 +   */
979 +  void UnitTetraIntersectionBaryTest::test_cuboid_mapped_coords_3D()
980 +  {
981 +    double nodes[8][3] = { { 0.0, 2.0, 4.0 }, //0
982 +                           { 0.0, 0.0, 4.0 },
983 +                           { 1.0, 0.0, 4.0 },
984 +                           { 1.0, 2.0, 4.0 },
985 +                           { 0.0, 2.0, 0.0 }, // 4
986 +                           { 0.0, 0.0, 0.0 },
987 +                           { 1.0, 0.0, 0.0 },
988 +                           { 1.0, 2.0, 0.0 }
989 +    };
990 +    // Translate cube:
991 +    for (int i=0; i < 8; ++i)
992 +      for (int j=0; j < 3; ++j)
993 +        nodes[i][j] += 15.0;
994 +
995 +    std::vector<const double*> n (8);
996 +    for (int i=0; i<8; i++)
997 +      n[i] = &nodes[i][0];
998 +
999 +    {
1000 +        // middle point
1001 +        double p[3] = { 15.5, 16.0, 17.0 }, bc[3];
1002 +        cuboid_mapped_coords(n, p, bc);
1003 +        CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, bc[0], 1e-12);
1004 +        CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, bc[1], 1e-12);
1005 +        CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, bc[2], 1e-12);
1006 +    }
1007 +    {
1008 +      // point 1
1009 +      double p[3] = { 15.0, 15.0, 19.0 }, bc[3];
1010 +      cuboid_mapped_coords(n, p, bc);
1011 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, bc[0], 1e-12);
1012 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, bc[1], 1e-12);
1013 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[2], 1e-12);
1014 +    }
1015 +    {
1016 +      // point 7
1017 +      double p[3] = { 16.0, 17.0, 15.0 }, bc[3];
1018 +      cuboid_mapped_coords(n, p, bc);
1019 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[0], 1e-12);
1020 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[1], 1e-12);
1021 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, bc[2], 1e-12);
1022 +    }
1023 +    {
1024 +      // point 3
1025 +      double p[3] = { 16.0, 17.0, 19.0 }, bc[3];
1026 +      cuboid_mapped_coords(n, p, bc);
1027 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[0], 1e-12);
1028 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[1], 1e-12);
1029 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[2], 1e-12);
1030 +    }
1031 +    {
1032 +      // point outside
1033 +      double p[3] = { 2.0, 16.0, 18.0 }, bc[3];
1034 +      CPPUNIT_ASSERT_THROW(cuboid_mapped_coords(n, p, bc), INTERP_KERNEL::Exception);
1035 +    }
1036 +
1037 +  }
1038 +
1039 +  /* Convention
1040 +      - for QUAD4, point 0 is taken to be the origin (again see med file ref connec):
1041 +
1042 +         1------2
1043 +         |      |
1044 +         |      |
1045 +         0------3
1046 +  */
1047 +  void UnitTetraIntersectionBaryTest::test_quad_mapped_coords_2D()
1048 +  {
1049 +
1050 +    double nodes[4][2] = { { 0.0, 0.0 },
1051 +                           { 0.0, 1.0 },
1052 +                           { 2.0, 3.0 },
1053 +                           { 1.0, 0.0 } };
1054 +
1055 +    // Translate quad4:
1056 +    for (int i=0; i < 4; ++i)
1057 +      for (int j=0; j < 2; ++j)
1058 +        nodes[i][j] += 15.0;
1059 +
1060 +    std::vector<const double*> n (4);
1061 +    for (int i=0; i<4; i++)
1062 +      n[i] = &nodes[i][0];
1063 +
1064 +    {
1065 +      // middle point
1066 +      double p[2] = { 15.75, 16.0 }, bc[2];
1067 +      quad_mapped_coords(n, p, bc);
1068 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, bc[0], 1e-12);
1069 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, bc[1], 1e-12);
1070 +    }
1071 +
1072 +    {
1073 +      // middle point of seg
1074 +      double p[2] = { 15.5, 15.0 }, bc[2];
1075 +      quad_mapped_coords(n, p, bc);
1076 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, bc[0], 1e-12);
1077 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, bc[1], 1e-12);
1078 +    }
1079 +
1080 +    {
1081 +      // point 1
1082 +      double p[2] = { 15.0, 16.0 }, bc[2];
1083 +      quad_mapped_coords(n, p, bc);
1084 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, bc[0], 1e-12);
1085 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[1], 1e-12);
1086 +    }
1087 +    {
1088 +      // point 2
1089 +      double p[2] = { 17.0, 18.0 }, bc[2];
1090 +      quad_mapped_coords(n, p, bc);
1091 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[0], 1e-12);
1092 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[1], 1e-12);
1093 +    }
1094 +    {
1095 +      // point 3
1096 +      double p[2] = { 16.0, 15.0 }, bc[2];
1097 +      quad_mapped_coords(n, p, bc);
1098 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[0], 1e-12);
1099 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, bc[1], 1e-12);
1100 +    }
1101 +    {
1102 +      // point outside
1103 +      double p[2] = { 18.0, 18.0 }, bc[2];
1104 +      CPPUNIT_ASSERT_THROW(quad_mapped_coords(n, p, bc), INTERP_KERNEL::Exception);
1105 +    }
1106 +  }
1107 +
1108 +
1109  }
1110 diff -rupN MEDCOUPLING_orig/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.hxx MEDCOUPLING_new/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.hxx
1111 --- MEDCOUPLING_orig/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.hxx    2017-01-23 09:08:42.648093157 +0100
1112 +++ MEDCOUPLING_new/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.hxx     2017-01-23 09:10:57.083734424 +0100
1113 @@ -52,6 +52,8 @@ namespace INTERP_TEST
1114      CPPUNIT_TEST( test_UnitTetraIntersectionBary_11 );
1115      CPPUNIT_TEST( test_TetraAffineTransform_reverseApply );
1116      CPPUNIT_TEST( test_barycentric_coords );
1117 +    CPPUNIT_TEST( test_cuboid_mapped_coords_3D );
1118 +    CPPUNIT_TEST( test_quad_mapped_coords_2D );
1119      CPPUNIT_TEST_SUITE_END();
1120    public:
1121      void test_UnitTetraIntersectionBary_1();
1122 @@ -69,6 +71,8 @@ namespace INTERP_TEST
1123      void test_UnitTetraIntersectionBary_13();
1124      void test_TetraAffineTransform_reverseApply();
1125      void test_barycentric_coords();
1126 +    void test_cuboid_mapped_coords_3D();
1127 +    void test_quad_mapped_coords_2D();
1128    };
1129  }
1130  
1131 diff -rupN MEDCOUPLING_orig/src/MEDCoupling/MEDCouplingRemapper.cxx MEDCOUPLING_new/src/MEDCoupling/MEDCouplingRemapper.cxx
1132 --- MEDCOUPLING_orig/src/MEDCoupling/MEDCouplingRemapper.cxx    2017-01-23 09:08:42.666093645 +0100
1133 +++ MEDCOUPLING_new/src/MEDCoupling/MEDCouplingRemapper.cxx     2017-01-23 09:10:57.368742077 +0100
1134 @@ -35,6 +35,7 @@
1135  #include "Interpolation3DSurf.hxx"
1136  #include "Interpolation2D1D.txx"
1137  #include "Interpolation2D3D.txx"
1138 +#include "Interpolation3D1D.txx"
1139  #include "InterpolationCU.txx"
1140  #include "InterpolationCC.txx"
1141  
1142 @@ -436,7 +437,7 @@ int MEDCouplingRemapper::prepareInterpKe
1143          throw INTERP_KERNEL::Exception("Invalid interpolation requested between 3D and 1D ! Select PointLocator as intersection type !");
1144        MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh);
1145        MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
1146 -      INTERP_KERNEL::Interpolation3D interpolation(*this);
1147 +      INTERP_KERNEL::Interpolation3D1D interpolation(*this);
1148        nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
1149      }
1150    else if(srcMeshDim==1 && trgMeshDim==3 && srcSpaceDim==3)
1151 @@ -445,7 +446,7 @@ int MEDCouplingRemapper::prepareInterpKe
1152          throw INTERP_KERNEL::Exception("Invalid interpolation requested between 3D and 1D ! Select PointLocator as intersection type !");
1153        MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh);
1154        MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
1155 -      INTERP_KERNEL::Interpolation3D interpolation(*this);
1156 +      INTERP_KERNEL::Interpolation3D1D interpolation(*this);
1157        std::vector<std::map<int,double> > matrixTmp;
1158        std::string revMethod(BuildMethodFrom(trgMeth,srcMeth));
1159        nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,revMethod);
1160 diff -rupN MEDCOUPLING_orig/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py MEDCOUPLING_new/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py
1161 --- MEDCOUPLING_orig/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py    2017-01-23 09:08:42.691094322 +0100
1162 +++ MEDCOUPLING_new/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py     2017-01-23 09:10:57.400742936 +0100
1163 @@ -555,7 +555,7 @@ class MEDCouplingBasicsTest(unittest.Tes
1164      def testSwig2BarycentricP1P13D_1(self):
1165          sCoo=DataArrayDouble([0.313,0.00218,6.90489,0.313,0.10692667,6.90489,0.313,0.10692667,6.96790167,0.313,0.00218,6.9773125,0.313,0.21167333,6.90489,0.313,0.21167333,6.95849083,0.313,0.31642,6.90489,0.313,0.31642,6.94908,0.313,0.09383333,7.04891667,0.313,0.00218,7.049735,0.313,0.18548667,7.04809833,0.313,0.27714,7.04728,0.313,0.05782667,7.133205,0.313,0.00218,7.1221575,0.313,0.11347333,7.1442525,0.313,0.16912,7.1553,0.313,0.02509333,7.19458,0.313,0.00218,7.19458,0.313,0.04800667,7.19458,0.313,0.07092,7.19458,0.31005609,0.00218,6.90460005,0.31005609,0.10692667,6.90460005,0.29776312,0.10692667,6.96640097,0.29592716,0.00218,6.97563097,0.31005609,0.21167333,6.90460005,0.29959908,0.21167333,6.95717096,0.31005609,0.31642,6.90460005,0.30143505,0.31642,6.94794095,0.28195788,0.09383333,7.04585928,0.28179823,0.00218,7.04666189,0.28211753,0.18548667,7.04505668,0.28227718,0.27714,7.04425407,0.26551404,0.05782667,7.12852804,0.2676693,0.00218,7.11769282,0.26335878,0.11347333,7.13936327,0.26120352,0.16912,7.15019849,0.25354037,0.02509333,7.18872374,0.25354037,0.00218,7.18872374,0.25354037,0.04800667,7.18872374,0.25354037,0.07092,7.18872374,0.30722531,0.00218,6.90374134,0.30722531,0.10692667,6.90374134,0.28311179,0.10692667,6.96195653,0.27951042,0.00218,6.97065101,0.30722531,0.21167333,6.90374134,0.28671316,0.21167333,6.95326205,0.30722531,0.31642,6.90374134,0.29031453,0.31642,6.94456758,0.25210869,0.09383333,7.03680463,0.25179553,0.00218,7.03756067,0.25242185,0.18548667,7.03604859,0.25273501,0.27714,7.03529255,0.21985294,0.05782667,7.1146769,0.22408063,0.00218,7.10447034,0.21562524,0.11347333,7.12488346,0.21139755,0.16912,7.13509002,0.19636574,0.02509333,7.17138,0.19636574,0.00218,7.17138,0.19636574,0.04800667,7.17138,0.19636574,0.07092,7.17138,0.30461645,0.00218,6.90234688,0.30461645,0.10692667,6.90234688,0.26960904,0.10692667,6.95473916,0.26438066,0.00218,6.96256398,0.30461645,0.21167333,6.90234688,0.27483742,0.21167333,6.94691434,0.30461645,0.31642,6.90234688,0.2800658,0.31642,6.93908952,0.22459952,0.09383333,7.02210067,0.22414487,0.00218,7.02278109,0.22505416,0.18548667,7.02142025,0.2255088,0.27714,7.02073983,0.17777143,0.05782667,7.09218386,0.18390909,0.00218,7.0829982,0.17163377,0.11347333,7.10136952,0.1654961,0.16912,7.11055518,0.1436733,0.02509333,7.14321531,0.1436733,0.00218,7.14321531,0.1436733,0.04800667,7.14321531,0.1436733,0.07092,7.14321531,0.30232976,0.00218,6.90047024,0.30232976,0.10692667,6.90047024,0.25777378,0.10692667,6.94502622,0.25111932,0.00218,6.95168068,0.30232976,0.21167333,6.90047024,0.26442825,0.21167333,6.93837175,0.30232976,0.31642,6.90047024,0.27108271,0.31642,6.93171729,0.20048753,0.09383333,7.00231247,0.19990888,0.00218,7.00289112,0.20106618,0.18548667,7.00173382,0.20164482,0.27714,7.00115518,0.14088667,0.05782667,7.06191333,0.14869844,0.00218,7.05410156,0.13307491,0.11347333,7.06972509,0.12526315,0.16912,7.07753685,0.097488,0.02509333,7.105312,0.097488,0.00218,7.105312,0.097488,0.04800667,7.105312,0.097488,0.07092,7.105312,0.30045312,0.00218,6.89818355,0.30045312,0.10692667,6.89818355,0.24806084,0.10692667,6.93319096,0.24023602,0.00218,6.93841934,0.30045312,0.21167333,6.89818355,0.25588566,0.21167333,6.92796258,0.30045312,0.31642,6.89818355,0.26371048,0.31642,6.9227342,0.18069933,0.09383333,6.97820048,0.18001891,0.00218,6.97865513,0.18137975,0.18548667,6.97774584,0.18206017,0.27714,6.9772912,0.11061614,0.05782667,7.02502857,0.1198018,0.00218,7.01889091,0.10143048,0.11347333,7.03116623,0.09224482,0.16912,7.0373039,0.05958469,0.02509333,7.0591267,0.05958469,0.00218,7.0591267,0.05958469,0.04800667,7.0591267,0.05958469,0.07092,7.0591267,0.29905866,0.00218,6.89557469,0.29905866,0.10692667,6.89557469,0.24084347,0.10692667,6.91968821,0.23214899,0.00218,6.92328958,0.29905866,0.21167333,6.89557469,0.24953795,0.21167333,6.91608684,0.29905866,0.31642,6.89557469,0.25823242,0.31642,6.91248547,0.16599537,0.09383333,6.95069131,0.16523933,0.00218,6.95100447,0.16675141,0.18548667,6.95037815,0.16750745,0.27714,6.95006499,0.0881231,0.05782667,6.98294706,0.09832966,0.00218,6.97871937,0.07791654,0.11347333,6.98717476,0.06770998,0.16912,6.99140245,0.03142,0.02509333,7.00643426,0.03142,0.00218,7.00643426,0.03142,0.04800667,7.00643426,0.03142,0.07092,7.00643426,0.29819995,0.00218,6.89274391,0.29819995,0.10692667,6.89274391,0.23639903,0.10692667,6.90503688,0.22716903,0.00218,6.90687284,0.29819995,0.21167333,6.89274391,0.24562904,0.21167333,6.90320092,0.29819995,0.31642,6.89274391,0.25485905,0.31642,6.90136495,0.15694072,0.09383333,6.92084212,0.15613811,0.00218,6.92100177,0.15774332,0.18548667,6.92068247,0.15854593,0.27714,6.92052282,0.07427196,0.05782667,6.93728596,0.08510718,0.00218,6.9351307,0.06343673,0.11347333,6.93944122,0.05260151,0.16912,6.94159648,0.01407626,0.02509333,6.94925963,0.01407626,0.00218,6.94925963,0.01407626,0.04800667,6.94925963,0.01407626,0.07092,6.94925963,0.29792818,0.00218,6.89054043,0.29792818,0.10692667,6.89054043,0.23499241,0.10692667,6.89363227,0.22559291,0.00218,6.89409403,0.29792818,0.21167333,6.89054043,0.24439191,0.21167333,6.8931705,0.29792818,0.31642,6.89054043,0.25379141,0.31642,6.89270873,0.154075,0.09383333,6.89760748,0.15325765,0.00218,6.89764764,0.15489234,0.18548667,6.89756733,0.15570969,0.27714,6.89752718,0.06988819,0.05782667,6.90174332,0.08092238,0.00218,6.90120124,0.058854,0.11347333,6.90228539,0.04781981,0.16912,6.90282747,0.00858712,0.02509333,6.90475485,0.00858712,0.00218,6.90475485,0.00858712,0.04800667,6.90475485,0.00858712,0.07092,6.90475485,0.29791,0.00218,6.820902,0.29791,0.10692667,6.820902,0.23489833,0.10692667,6.820902,0.2254875,0.00218,6.820902,0.29791,0.21167333,6.820902,0.24430917,0.21167333,6.820902,0.29791,0.31642,6.820902,0.25372,0.31642,6.820902,0.15388333,0.09383333,6.820902,0.153065,0.00218,6.820902,0.15470167,0.18548667,6.820902,0.15552,0.27714,6.820902,0.069595,0.05782667,6.820902,0.0806425,0.00218,6.820902,0.0585475,0.11347333,6.820902,0.0475,0.16912,6.820902,0.00822,0.02509333,6.820902,0.00822,0.00218,6.820902,0.00822,0.04800667,6.820902,0.00822,0.07092,6.820902],200,3)
1166          sConn=DataArrayInt([0,1,2,3,20,21,22,23,1,4,5,2,21,24,25,22,4,6,7,5,24,26,27,25,3,2,8,9,23,22,28,29,2,5,10,8,22,25,30,28,5,7,11,10,25,27,31,30,9,8,12,13,29,28,32,33,8,10,14,12,28,30,34,32,10,11,15,14,30,31,35,34,13,12,16,17,33,32,36,37,12,14,18,16,32,34,38,36,14,15,19,18,34,35,39,38,20,21,22,23,40,41,42,43,21,24,25,22,41,44,45,42,24,26,27,25,44,46,47,45,23,22,28,29,43,42,48,49,22,25,30,28,42,45,50,48,25,27,31,30,45,47,51,50,29,28,32,33,49,48,52,53,28,30,34,32,48,50,54,52,30,31,35,34,50,51,55,54,33,32,36,37,53,52,56,57,32,34,38,36,52,54,58,56,34,35,39,38,54,55,59,58,40,41,42,43,60,61,62,63,41,44,45,42,61,64,65,62,44,46,47,45,64,66,67,65,43,42,48,49,63,62,68,69,42,45,50,48,62,65,70,68,45,47,51,50,65,67,71,70,49,48,52,53,69,68,72,73,48,50,54,52,68,70,74,72,50,51,55,54,70,71,75,74,53,52,56,57,73,72,76,77,52,54,58,56,72,74,78,76,54,55,59,58,74,75,79,78,60,61,62,63,80,81,82,83,61,64,65,62,81,84,85,82,64,66,67,65,84,86,87,85,63,62,68,69,83,82,88,89,62,65,70,68,82,85,90,88,65,67,71,70,85,87,91,90,69,68,72,73,89,88,92,93,68,70,74,72,88,90,94,92,70,71,75,74,90,91,95,94,73,72,76,77,93,92,96,97,72,74,78,76,92,94,98,96,74,75,79,78,94,95,99,98,80,81,82,83,100,101,102,103,81,84,85,82,101,104,105,102,84,86,87,85,104,106,107,105,83,82,88,89,103,102,108,109,82,85,90,88,102,105,110,108,85,87,91,90,105,107,111,110,89,88,92,93,109,108,112,113,88,90,94,92,108,110,114,112,90,91,95,94,110,111,115,114,93,92,96,97,113,112,116,117,92,94,98,96,112,114,118,116,94,95,99,98,114,115,119,118,100,101,102,103,120,121,122,123,101,104,105,102,121,124,125,122,104,106,107,105,124,126,127,125,103,102,108,109,123,122,128,129,102,105,110,108,122,125,130,128,105,107,111,110,125,127,131,130,109,108,112,113,129,128,132,133,108,110,114,112,128,130,134,132,110,111,115,114,130,131,135,134,113,112,116,117,133,132,136,137,112,114,118,116,132,134,138,136,114,115,119,118,134,135,139,138,120,121,122,123,140,141,142,143,121,124,125,122,141,144,145,142,124,126,127,125,144,146,147,145,123,122,128,129,143,142,148,149,122,125,130,128,142,145,150,148,125,127,131,130,145,147,151,150,129,128,132,133,149,148,152,153,128,130,134,132,148,150,154,152,130,131,135,134,150,151,155,154,133,132,136,137,153,152,156,157,132,134,138,136,152,154,158,156,134,135,139,138,154,155,159,158,140,141,142,143,160,161,162,163,141,144,145,142,161,164,165,162,144,146,147,145,164,166,167,165,143,142,148,149,163,162,168,169,142,145,150,148,162,165,170,168,145,147,151,150,165,167,171,170,149,148,152,153,169,168,172,173,148,150,154,152,168,170,174,172,150,151,155,154,170,171,175,174,153,152,156,157,173,172,176,177,152,154,158,156,172,174,178,176,154,155,159,158,174,175,179,178,160,161,162,163,180,181,182,183,161,164,165,162,181,184,185,182,164,166,167,165,184,186,187,185,163,162,168,169,183,182,188,189,162,165,170,168,182,185,190,188,165,167,171,170,185,187,191,190,169,168,172,173,189,188,192,193,168,170,174,172,188,190,194,192,170,171,175,174,190,191,195,194,173,172,176,177,193,192,196,197,172,174,178,176,192,194,198,196,174,175,179,178,194,195,199,198])
1167 -        s=MEDCoupling1SGTUMesh("target",NORM_HEXA8) ; s.setCoords(sCoo)
1168 +        s=MEDCoupling1SGTUMesh("source",NORM_HEXA8) ; s.setCoords(sCoo)
1169          s.setNodalConnectivity(sConn)
1170          #
1171          tCoo=DataArrayDouble([0.328,0.012,6.8598,0.328,0.168320184237353,6.8598,0.328,0.324640368474706,6.8598,0.328,0.0,6.8598,0.298,0.012,6.8598,0.1565,0.012,6.8598,0.180205346493166,0.144794653506834,6.8598,0.298,0.168320184237353,6.8598,0.0,0.012,6.8598,0.0916755774886107,0.233324422511389,6.8598,0.298,0.324640368474706,6.8598,0.298,0.0,6.8598,0.1565,0.0,6.8598,0.0,0.0,6.8598,0.328,0.012,7.2298,0.328,0.168320184237353,7.2298,0.328,0.324640368474706,7.2298,0.328,0.0,7.2298,0.298,0.012,7.2298,0.1565,0.012,7.2298,0.180205346493166,0.144794653506834,7.2298,0.298,0.168320184237353,7.2298,0.0,0.012,7.2298,0.0916755774886107,0.233324422511389,7.2298,0.298,0.324640368474706,7.2298,0.298,0.0,7.2298,0.1565,0.0,7.2298,0.0,0.0,7.2298],28,3)
1172 @@ -587,6 +587,130 @@ class MEDCouplingBasicsTest(unittest.Tes
1173          self.assertAlmostEqual(0.3521445110626687 ,m[6][170],12)
1174          pass
1175  
1176 +    def testSwig2MappedBarycentricP1P12D_1(self):
1177 +        """ Testing mapped barycentric P1P1 projection
1178 +        (uses analytical mapping from square to arbitrary convex quadrangle)
1179 +        """
1180 +        n = 5
1181 +        sCoo = DataArrayDouble(n,1)
1182 +        sCoo.iota(0.0);     sCoo /= float(n-1)
1183 +        m = MEDCouplingCMesh("target")
1184 +        m.setCoordsAt(0, sCoo)
1185 +        m.setCoordsAt(1, sCoo)
1186 +        tgt = m.buildUnstructured()
1187 +        coo = tgt.getCoords()
1188 +        orig = coo.deepCpy();   orig[:,0] = 10.0; orig[:,1] = 15.0
1189 +        pt_a = coo.deepCpy();   pt_a[:,0] = -0.3; pt_a[:,1] = 1.0
1190 +        pt_b = coo.deepCpy();   pt_b[:,0] = 2.0;  pt_b[:,1] = 3.0
1191 +        pt_c = coo.deepCpy();   pt_c[:,0] = 1.0;  pt_c[:,1] = 0.0
1192 +        # P = x*C+y*A + xy(B-A-C) + ORIGIN
1193 +        coo2 = coo[:,0]*pt_c + coo[:, 1]*pt_a + coo[:, 0]*coo[:, 1]*(pt_b - pt_a - pt_c) + orig
1194 +
1195 +        tgt.setCoords(coo2)
1196 +
1197 +        sCoo = DataArrayDouble([0.0,0.0,  -0.3,1.0,  2.0,3.0,  1.0,0.0],4,2)
1198 +        sCoo[:,0] += 10.0;  sCoo[:,1] += 15.0;
1199 +        sConn = DataArrayInt([0,1,2,3])
1200 +        s = MEDCoupling1SGTUMesh("source",NORM_QUAD4) ; s.setCoords(sCoo)
1201 +        s.setNodalConnectivity(sConn)
1202 +        #
1203 +        aRemapper=MEDCouplingRemapper()
1204 +        aRemapper.setPrecision(1e-12)
1205 +        aRemapper.setIntersectionType(MappedBarycentric)
1206 +        self.assertEqual(aRemapper.prepare(s,tgt,'P1P1'),1)
1207 +        srcField = MEDCouplingFieldDouble(ON_NODES, ONE_TIME)
1208 +        srcField.setNature(ConservativeVolumic)
1209 +        srcField.setMesh(s); srcField.setName("field")
1210 +        srcField.setArray(DataArrayDouble([1.0,2.0,3.0,4.0]))
1211 +        tgtF = aRemapper.transferField(srcField, 1e+300)
1212 +        ref = [1.0, 1.75, 2.5, 3.25, 4.0, 1.25, 1.875, 2.5, 3.125, 3.75, 1.5, 2.0, 2.5, 3.0, 3.5, 1.75,
1213 +         2.125, 2.5, 2.875, 3.25, 2.0, 2.25, 2.5, 2.75, 3.0]
1214 +        val = tgtF.getArray().getValues()
1215 +        for i, ref_v in enumerate(ref):
1216 +            self.assertAlmostEqual(ref_v, val[i])
1217 +        pass
1218 +
1219 +    def testSwig2MappedBarycentricP1P13_1(self):
1220 +        """ Testing mapped barycentric P1P1 projection in 3D (uses orthogonal distances to 
1221 +        HEXA8 faces).
1222 +        Convention:
1223 +              0 ------ 3
1224 +             /|       /|
1225 +            / |      / |
1226 +           1 ------ 2  |
1227 +           |  |     |  |
1228 +           |  |     |  |
1229 +           |  4-----|- 7
1230 +           | /      | /
1231 +           5 ------ 6
1232 +        """
1233 +        n = 5
1234 +        sCoo = DataArrayDouble(n,1)
1235 +        sCoo.iota(0.0)
1236 +        sCoo /= float(n-1)
1237 +        m = MEDCouplingCMesh("target")
1238 +        m.setCoordsAt(0, sCoo)
1239 +        m.setCoordsAt(1, sCoo)
1240 +        m.setCoordsAt(2, sCoo)
1241 +        tgt = m.buildUnstructured()
1242 +        coo = tgt.getCoords()
1243 +        pt_0 = coo.deepCpy(); pt_0[:,0] = -0.3; pt_0[:,1] = 1.0; pt_0[:,2] = 1.0
1244 +        pt_1 = coo.deepCpy(); pt_1[:,0] = 0.0; pt_1[:,1] = 0.0; pt_1[:,2] = 1.0
1245 +        pt_2 = coo.deepCpy(); pt_2[:,0] = 1.0; pt_2[:,1] = 0.0; pt_2[:,2] = 1.0
1246 +        pt_3 = coo.deepCpy(); pt_3[:,0] = 2.0; pt_3[:,1] = 3.0; pt_3[:,2] = 1.0
1247 +        
1248 +        pt_4 = coo.deepCpy(); pt_4[:,0] = -0.3; pt_4[:,1] = 1.0; pt_4[:,2] = 0.0
1249 +        orig = coo.deepCpy(); orig[:,0] = 10.0; orig[:,1] = 15.0; orig[:,2] = 20.0
1250 +        pt_6 = coo.deepCpy(); pt_6[:,0] = 1.0; pt_6[:,1] = 0.0; pt_6[:,2] = 0.0 
1251 +        pt_7 = coo.deepCpy(); pt_7[:,0] = 2.0; pt_7[:,1] = 3.0; pt_7[:,2] = 0.0
1252 +        # P = x*p6 + y*p4 + z*p1 + xy*(p7-p6-p4) + xz*(p2-p1-p6) + yz*(p0-p4-p1) + xyz(p3-p7-p2-p0+p1+p6+p4)
1253 +        x,y,z = coo[:,0],coo[:,1],coo[:,2]
1254 +        coo2 = x*pt_6 + y*pt_4 + z*pt_1 + \
1255 +               x*y*(pt_7 - pt_6 - pt_4) + x*z*(pt_2 - pt_1 - pt_6) + y*z*(pt_0 - pt_4 - pt_1) + \
1256 +               x*y*z*(pt_3 - pt_7 - pt_2 - pt_0 + pt_6 + pt_1 + pt_4) + orig
1257 +        tgt.setCoords(coo2)
1258 +
1259 +        sCoo = DataArrayDouble([-0.3,1.0,1.0,  0.0,0.0,1.0,  1.0,0.0,1.0,  2.0,3.0,1.0,
1260 +                                -0.3,1.0,0.0,  0.0,0.0,0.0,  1.0,0.0,0.0,  2.0,3.0,0.0,],8,3)
1261 +        sCoo[:, 0] += 10.0; sCoo[:, 1] += 15.0; sCoo[:, 2] += 20.0;
1262 +        sConn = DataArrayInt([0,1,2,3,4, 5,6,7])
1263 +        s = MEDCoupling1SGTUMesh("source",NORM_HEXA8) ; s.setCoords(sCoo)
1264 +        s.setNodalConnectivity(sConn)
1265 +        #
1266 +        aRemapper=MEDCouplingRemapper()
1267 +        aRemapper.setPrecision(1e-12)
1268 +        aRemapper.setIntersectionType(MappedBarycentric)
1269 +        self.assertEqual(aRemapper.prepare(s,tgt,'P1P1'),1)
1270 +        srcField = MEDCouplingFieldDouble(ON_NODES, ONE_TIME)
1271 +        srcField.setNature(ConservativeVolumic)
1272 +        srcField.setMesh(s); srcField.setName("field")
1273 +        srcField.setArray(DataArrayDouble([1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0]))
1274 +        tgtF = aRemapper.transferField(srcField, 1e+300)
1275 +#        print tgtF.getArray().getValues()
1276 +        ref = [6.0, 6.251802698104413, 6.502397834044702, 6.7517940736426665, 7.0, 5.740554726834594,
1277 +               6.1761835575796935, 6.6052985689637564, 7.009392769824465, 7.383488834310164,
1278 +               5.487562931129931, 6.140664596972973, 6.720290674177548, 7.220534970454015, 7.651092836860121,
1279 +               5.2407867837524345, 6.125759809889516, 6.82853486793175, 7.390880823876876, 7.848445254819061,
1280 +               5.0, 6.12211344611157, 6.925740671133115, 7.529623182840827, 8.0, 5.0, 5.251802698104413,
1281 +               5.502397834044702, 5.751794073642667, 6.0, 4.740554726834594, 5.1761835575796935,
1282 +               5.6052985689637564, 6.009392769824465, 6.383488834310163, 4.487562931129931, 5.140664596972973,
1283 +                5.720290674177548, 6.220534970454015, 6.651092836860121, 4.2407867837524345, 5.125759809889516,
1284 +                5.828534867931749, 6.390880823876876, 6.848445254819061, 4.0, 5.122113446111569, 5.925740671133115,
1285 +                6.529623182840827, 7.0, 4.0, 4.251802698104413, 4.502397834044702, 4.751794073642667, 5.0, 3.740554726834594,
1286 +                4.176183557579693, 4.6052985689637564, 5.009392769824464, 5.383488834310164, 3.487562931129931,
1287 +                4.140664596972973, 4.720290674177548, 5.220534970454015, 5.651092836860121, 3.240786783752434, 4.125759809889516, 4.82853486793175,
1288 +                5.390880823876876, 5.848445254819061, 3.0, 4.122113446111569, 4.925740671133115, 5.529623182840827, 6.0, 3.0,
1289 +                3.2518026981044135, 3.502397834044702, 3.7517940736426674, 4.0, 2.7405547268345933, 3.176183557579693,
1290 +                3.6052985689637564, 4.009392769824465, 4.383488834310164, 2.487562931129931, 3.140664596972973, 3.7202906741775474, 4.220534970454015, 4.65109283686012, 2.2407867837524345, 3.1257598098895154, 3.828534867931749,
1291 +                4.390880823876876, 4.848445254819061, 2.0, 3.1221134461115687, 3.9257406711331146, 4.529623182840826, 5.0, 2.0, 2.2518026981044135, 2.502397834044702, 2.7517940736426674, 3.0, 1.7405547268345936, 2.176183557579693, 2.6052985689637564,
1292 +                3.0093927698244642, 3.3834888343101635, 1.4875629311299305, 2.1406645969729734, 2.720290674177548,
1293 +                3.2205349704540143, 3.6510928368601205, 1.2407867837524345, 2.125759809889516, 2.8285348679317495, 3.390880823876876, 3.848445254819061, 1.0, 2.1221134461115687, 2.9257406711331146, 3.529623182840827, 4.0]
1294 +
1295 +        val = tgtF.getArray().getValues()
1296 +        for i, ref_v in enumerate(ref):
1297 +            self.assertAlmostEqual(ref_v, val[i])
1298 +        pass
1299 +
1300      @unittest.skipUnless(MEDCouplingHasNumPyBindings() and MEDCouplingHasSciPyBindings(),"requires numpy AND scipy")
1301      def testGetCrudeCSRMatrix1(self):
1302          """ testing CSR matrix output using numpy/scipy.
1303 @@ -645,7 +769,7 @@ class MEDCouplingBasicsTest(unittest.Tes
1304          self.assertAlmostEqual(m_1[2,3],0.3,12)
1305          self.assertEqual(m_1.getnnz(),7)
1306          pass
1307 -    
1308 +
1309      @unittest.skipUnless(MEDCouplingHasNumPyBindings() and MEDCouplingHasSciPyBindings(),"requires numpy AND scipy")
1310      def testP0P1Bary_1(self):
1311          a=MEDCouplingUMesh("a",2)
1312 @@ -712,7 +836,7 @@ class MEDCouplingBasicsTest(unittest.Tes
1313          #
1314          rem=MEDCouplingRemapper()
1315          rem.setMaxDistance3DSurfIntersect(1e-12)
1316 -        rem.setMinDotBtwPlane3DSurfIntersect(0.99)# this line is important it is to tell to remapper to select only cells with very close orientation 
1317 +        rem.setMinDotBtwPlane3DSurfIntersect(0.99)# this line is important it is to tell to remapper to select only cells with very close orientation
1318          rem.prepare(skinAndNonConformCells,skinAndNonConformCells,"P0P0")
1319          mat=rem.getCrudeCSRMatrix()
1320          indptr=DataArrayInt(mat.indptr)
1321 @@ -785,7 +909,7 @@ class MEDCouplingBasicsTest(unittest.Tes
1322          #
1323          self.assertTrue(coarse.isEqual(trgField.getArray(),1e-12))
1324          pass
1325 -    
1326 +
1327      @unittest.skipUnless(MEDCouplingHasNumPyBindings() and MEDCouplingHasSciPyBindings(),"requires numpy AND scipy")
1328      def test1DPointLocator1(self):
1329          """This test focuses on PointLocator for P1P1 in 1D and 2DCurve."""
1330 @@ -853,7 +977,7 @@ class MEDCouplingBasicsTest(unittest.Tes
1331          diff=abs(m-mExp0)
1332          self.assertAlmostEqual(diff.sum(),0.,14)
1333          pass
1334 -    
1335 +
1336      def test3D2Dand2D3DPointLocator1(self):
1337          """ Non regression test solving SIGSEGV when using 3D<->3Dsurf pointlocator."""
1338          arrX=DataArrayDouble([0,1,2])
1339 @@ -894,7 +1018,37 @@ class MEDCouplingBasicsTest(unittest.Tes
1340          rem.prepare(mt,ms,"P0P0")
1341          self.assertEqual(rem.getCrudeMatrix(),[{0:1.},{1:1.}])
1342          pass
1343 -    
1344 +
1345 +    def test3D1DPointLocatorBBoxAdjusted(self):
1346 +        """ In case a 1D segment lies exactly on the interface between two 2D (or 3D) faces, the default
1347 +        bounding box logic will make it non-intersecting with the surrounding 2D (or 3D) faces.
1348 +        Test bounding box adjustment allowing to widen the BB to capture this.
1349 +        """
1350 +        m = MEDCouplingCMesh("source")
1351 +        di, dd = DataArrayInt, DataArrayDouble
1352 +        m.setCoordsAt(0, dd([0.0, 1.0, 2.0]))
1353 +        m.setCoordsAt(1, dd([0.0, 1.0]))
1354 +        m.setCoordsAt(2, dd([0.0, 1.0]))
1355 +        m3d = m.buildUnstructured()
1356 +        m1d = MEDCouplingUMesh("target", 1)
1357 +        m1d.setCoords(dd([1.0,0.5,0.2  ,  1.0,0.5,0.8], 2,3))
1358 +        m1d.setConnectivity(di([NORM_SEG2, 0, 1]), di([0,3]))
1359 +
1360 +        rem = MEDCouplingRemapper()
1361 +        rem.setPrecision(1e-12)
1362 +        rem.setIntersectionType(PointLocator)
1363 +        rem.prepare(m3d, m1d,"P0P1")
1364 +        self.assertEqual(rem.getCrudeMatrix(), [{0: 1.0, 1: 1.0}, {0: 1.0, 1: 1.0}])
1365 +
1366 +        rem = MEDCouplingRemapper()
1367 +        rem.setPrecision(1e-12)
1368 +        rem.setIntersectionType(PointLocator)
1369 +        rem.setBoundingBoxAdjustment(0.0)
1370 +        rem.setBoundingBoxAdjustmentAbs(0.0)
1371 +        rem.prepare(m3d, m1d,"P0P1")
1372 +        self.assertEqual(rem.getCrudeMatrix(), [{}, {}])
1373 +        pass
1374 +
1375      def build2DSourceMesh_1(self):
1376          sourceCoords=[-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7]
1377          sourceConn=[0,3,1,0,2,3]
1378 @@ -907,7 +1061,7 @@ class MEDCouplingBasicsTest(unittest.Tes
1379          myCoords.setValues(sourceCoords,4,2);
1380          sourceMesh.setCoords(myCoords);
1381          return sourceMesh;
1382 -    
1383 +
1384      def build2DTargetMesh_1(self):
1385          targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ]
1386          targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4]
1387 @@ -940,9 +1094,10 @@ class MEDCouplingBasicsTest(unittest.Tes
1388          targetMesh.setCoords(myCoords);
1389          return targetMesh;
1390          pass
1391 -    
1392 +
1393      def setUp(self):
1394          pass
1395      pass
1396  
1397 -unittest.main()
1398 +if __name__ == "__main__":
1399 +  unittest.main()
1400 diff -rupN MEDCOUPLING_orig/src/MEDLoader/MEDFileField.cxx MEDCOUPLING_new/src/MEDLoader/MEDFileField.cxx
1401 --- MEDCOUPLING_orig/src/MEDLoader/MEDFileField.cxx     2017-01-23 09:08:42.696094458 +0100
1402 +++ MEDCOUPLING_new/src/MEDLoader/MEDFileField.cxx      2017-01-23 09:10:57.406743098 +0100
1403 @@ -7357,9 +7357,8 @@ void MEDFileAnyTypeFieldMultiTSWithoutSD
1404      {
1405        std::vector< std::pair<int,int> > ts;
1406        med_int numdt=0,numo=0;
1407 -      med_int meshIt=0,meshOrder=0;
1408        med_float dt=0.0;
1409 -      MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder));
1410 +      MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
1411        switch(fieldTyp)
1412        {
1413          case MED_FLOAT64: