Salome HOME
OCCT: use git repository since back online
[tools/sat_salome.git] / products / patches / medcoupling_abn780b.patch
1 diff -rupN -x git 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:49:37.458001480 +0100
3 +++ MEDCOUPLING_new/doc/user/doxygen/doxfiles/reference/interpolation/intersectors.dox  2017-01-23 09:50:14.164001480 +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 -x git 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:50:14.164001480 +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 -x git MEDCOUPLING_orig/.git/config MEDCOUPLING_new/.git/config
80 --- MEDCOUPLING_orig/.git/config        2017-01-23 09:49:36.981001479 +0100
81 +++ MEDCOUPLING_new/.git/config 2017-01-23 09:50:14.725001479 +0100
82 @@ -9,3 +9,6 @@
83  [branch "master"]
84         remote = origin
85         merge = refs/heads/master
86 +[branch "abn/backport"]
87 +       remote = origin
88 +       merge = refs/heads/abn/backport
89 diff -rupN -x git MEDCOUPLING_orig/.git/HEAD MEDCOUPLING_new/.git/HEAD
90 --- MEDCOUPLING_orig/.git/HEAD  2017-01-23 09:49:37.574001479 +0100
91 +++ MEDCOUPLING_new/.git/HEAD   2017-01-23 09:50:14.726001479 +0100
92 @@ -1 +1 @@
93 -f93666474947a2dce6782eddcd24fe1ba624c246
94 +ref: refs/heads/abn/backport
95 Les fichiers binaires MEDCOUPLING_orig/.git/index et MEDCOUPLING_new/.git/index sont diffĂ©rents.
96 diff -rupN -x git MEDCOUPLING_orig/.git/logs/HEAD MEDCOUPLING_new/.git/logs/HEAD
97 --- MEDCOUPLING_orig/.git/logs/HEAD     2017-01-23 09:49:37.574001479 +0100
98 +++ MEDCOUPLING_new/.git/logs/HEAD      2017-01-23 09:50:14.726001479 +0100
99 @@ -1,2 +1,2 @@
100 -0000000000000000000000000000000000000000 6bf54bb729d4c6bcc4b0f635d6b6f9466ef80b21 S. Pomarede <support-salome@cea.fr> 1485161376 +0100 clone: from http://git.salome-platform.org/gitpub/tools/medcoupling.git
101 -6bf54bb729d4c6bcc4b0f635d6b6f9466ef80b21 f93666474947a2dce6782eddcd24fe1ba624c246 S. Pomarede <support-salome@cea.fr> 1485161377 +0100 checkout: moving from master to V7_8_0
102 +0000000000000000000000000000000000000000 6bf54bb729d4c6bcc4b0f635d6b6f9466ef80b21 S. Pomarede <support-salome@cea.fr> 1485161414 +0100 clone: from http://git.salome-platform.org/gitpub/tools/medcoupling.git
103 +6bf54bb729d4c6bcc4b0f635d6b6f9466ef80b21 9f0e9109c8c30b224e9869e2a52b1f84dd5a73cb S. Pomarede <support-salome@cea.fr> 1485161414 +0100 checkout: moving from master to abn/backport
104 diff -rupN -x git MEDCOUPLING_orig/.git/logs/refs/heads/abn/backport MEDCOUPLING_new/.git/logs/refs/heads/abn/backport
105 --- MEDCOUPLING_orig/.git/logs/refs/heads/abn/backport  1970-01-01 01:00:00.000000000 +0100
106 +++ MEDCOUPLING_new/.git/logs/refs/heads/abn/backport   2017-01-23 09:50:14.726001479 +0100
107 @@ -0,0 +1 @@
108 +0000000000000000000000000000000000000000 9f0e9109c8c30b224e9869e2a52b1f84dd5a73cb S. Pomarede <support-salome@cea.fr> 1485161414 +0100 branch: Created from refs/remotes/origin/abn/backport
109 diff -rupN -x git MEDCOUPLING_orig/.git/logs/refs/heads/master MEDCOUPLING_new/.git/logs/refs/heads/master
110 --- MEDCOUPLING_orig/.git/logs/refs/heads/master        2017-01-23 09:49:36.981001479 +0100
111 +++ MEDCOUPLING_new/.git/logs/refs/heads/master 2017-01-23 09:50:14.087001491 +0100
112 @@ -1 +1 @@
113 -0000000000000000000000000000000000000000 6bf54bb729d4c6bcc4b0f635d6b6f9466ef80b21 S. Pomarede <support-salome@cea.fr> 1485161376 +0100 clone: from http://git.salome-platform.org/gitpub/tools/medcoupling.git
114 +0000000000000000000000000000000000000000 6bf54bb729d4c6bcc4b0f635d6b6f9466ef80b21 S. Pomarede <support-salome@cea.fr> 1485161414 +0100 clone: from http://git.salome-platform.org/gitpub/tools/medcoupling.git
115 diff -rupN -x git MEDCOUPLING_orig/.git/refs/heads/abn/backport MEDCOUPLING_new/.git/refs/heads/abn/backport
116 --- MEDCOUPLING_orig/.git/refs/heads/abn/backport       1970-01-01 01:00:00.000000000 +0100
117 +++ MEDCOUPLING_new/.git/refs/heads/abn/backport        2017-01-23 09:50:14.726001479 +0100
118 @@ -0,0 +1 @@
119 +9f0e9109c8c30b224e9869e2a52b1f84dd5a73cb
120 diff -rupN -x git MEDCOUPLING_orig/src/INTERP_KERNEL/CMakeLists.txt MEDCOUPLING_new/src/INTERP_KERNEL/CMakeLists.txt
121 --- MEDCOUPLING_orig/src/INTERP_KERNEL/CMakeLists.txt   2017-01-23 09:49:37.463001480 +0100
122 +++ MEDCOUPLING_new/src/INTERP_KERNEL/CMakeLists.txt    2017-01-23 09:50:14.259001480 +0100
123 @@ -35,6 +35,7 @@ SET(interpkernel_SOURCES
124    Interpolation3DSurf.cxx
125    Interpolation3D.cxx
126    Interpolation2D3D.cxx
127 +  Interpolation3D1D.cxx
128    MeshElement.cxx
129    InterpKernelMeshQuality.cxx
130    InterpKernelCellSimplify.cxx
131 diff -rupN -x git MEDCOUPLING_orig/src/INTERP_KERNEL/Interpolation3D1D.cxx MEDCOUPLING_new/src/INTERP_KERNEL/Interpolation3D1D.cxx
132 --- MEDCOUPLING_orig/src/INTERP_KERNEL/Interpolation3D1D.cxx    1970-01-01 01:00:00.000000000 +0100
133 +++ MEDCOUPLING_new/src/INTERP_KERNEL/Interpolation3D1D.cxx     2017-01-23 09:50:14.278001479 +0100
134 @@ -0,0 +1,64 @@
135 +// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
136 +//
137 +// This library is free software; you can redistribute it and/or
138 +// modify it under the terms of the GNU Lesser General Public
139 +// License as published by the Free Software Foundation; either
140 +// version 2.1 of the License, or (at your option) any later version.
141 +//
142 +// This library is distributed in the hope that it will be useful,
143 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
144 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
145 +// Lesser General Public License for more details.
146 +//
147 +// You should have received a copy of the GNU Lesser General Public
148 +// License along with this library; if not, write to the Free Software
149 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
150 +//
151 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
152 +//
153 +// Author : Adrien Bruneton (CEA/DEN)
154 +
155 +#include "Interpolation3D1D.hxx"
156 +#include "Interpolation3D1D.txx"
157 +
158 +namespace INTERP_KERNEL
159 +{
160 +  /**
161 +   * \class Interpolation3D1D
162 +   * \brief Class used to calculate the interpolation between a 3D mesh and 1D mesh (in 3D space)
163 +   * Can be seen as a specialization of Interpolation3D, and allows notably the adjustment of bounind boxes.
164 +   * 
165 +   */
166 +
167 +  Interpolation3D1D::Interpolation3D1D()
168 +  {}
169 +
170 +  Interpolation3D1D::Interpolation3D1D(const InterpolationOptions& io):Interpolation<Interpolation3D1D>(io)
171 +  {}
172 +
173 +  /**
174 +   * Inspired from PlanarIntersector<MyMeshType,MyMatrix>::adjustBoundingBoxes
175 +   */
176 +  void Interpolation3D1D::adjustBoundingBoxes(std::vector<double>& bbox)
177 +  {
178 +    const int SPACE_DIM = 3;
179 +    const double adj = getBoundingBoxAdjustmentAbs();
180 +    const double adjRel = getBoundingBoxAdjustment();
181 +
182 +    long size = bbox.size()/(2*SPACE_DIM);
183 +    for (int i=0; i<size; i++)
184 +      {
185 +        double max=- std::numeric_limits<double>::max();
186 +        for(int idim=0; idim<SPACE_DIM; idim++)
187 +          {
188 +            double Dx=bbox[i*2*SPACE_DIM+1+2*idim]-bbox[i*2*SPACE_DIM+2*idim];
189 +            max=(max<Dx)?Dx:max;
190 +          }
191 +        for(int idim=0; idim<SPACE_DIM; idim++)
192 +          {
193 +            bbox[i*2*SPACE_DIM+2*idim  ] -= adjRel*max+adj;
194 +            bbox[i*2*SPACE_DIM+2*idim+1] += adjRel*max+adj;
195 +          }
196 +      }
197 +  }
198 +}
199 diff -rupN -x git MEDCOUPLING_orig/src/INTERP_KERNEL/Interpolation3D1D.hxx MEDCOUPLING_new/src/INTERP_KERNEL/Interpolation3D1D.hxx
200 --- MEDCOUPLING_orig/src/INTERP_KERNEL/Interpolation3D1D.hxx    1970-01-01 01:00:00.000000000 +0100
201 +++ MEDCOUPLING_new/src/INTERP_KERNEL/Interpolation3D1D.hxx     2017-01-23 09:50:14.278001479 +0100
202 @@ -0,0 +1,45 @@
203 +// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
204 +//
205 +// This library is free software; you can redistribute it and/or
206 +// modify it under the terms of the GNU Lesser General Public
207 +// License as published by the Free Software Foundation; either
208 +// version 2.1 of the License, or (at your option) any later version.
209 +//
210 +// This library is distributed in the hope that it will be useful,
211 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
212 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
213 +// Lesser General Public License for more details.
214 +//
215 +// You should have received a copy of the GNU Lesser General Public
216 +// License along with this library; if not, write to the Free Software
217 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
218 +//
219 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
220 +//
221 +// Author : A Bruneton (CEA/DEN)
222 +
223 +#ifndef __INTERPOLATION3D1D_HXX__
224 +#define __INTERPOLATION3D1D_HXX__
225 +
226 +#include "INTERPKERNELDefines.hxx"
227 +#include "Interpolation.hxx"
228 +#include "NormalizedUnstructuredMesh.hxx"
229 +#include "InterpolationOptions.hxx"
230 +
231 +#include <vector>
232 +
233 +namespace INTERP_KERNEL
234 +{
235 +  class INTERPKERNEL_EXPORT Interpolation3D1D : public Interpolation<Interpolation3D1D>
236 +  {
237 +  public:
238 +    Interpolation3D1D();
239 +    Interpolation3D1D(const InterpolationOptions& io);
240 +    template<class MyMeshType, class MatrixType>
241 +    int interpolateMeshes(const MyMeshType& srcMesh, const MyMeshType& targetMesh, MatrixType& result, const std::string& method);
242 +  private:
243 +    void adjustBoundingBoxes(std::vector<double>& bbox);
244 +  };
245 +}
246 +
247 +#endif
248 diff -rupN -x git MEDCOUPLING_orig/src/INTERP_KERNEL/Interpolation3D1D.txx MEDCOUPLING_new/src/INTERP_KERNEL/Interpolation3D1D.txx
249 --- MEDCOUPLING_orig/src/INTERP_KERNEL/Interpolation3D1D.txx    1970-01-01 01:00:00.000000000 +0100
250 +++ MEDCOUPLING_new/src/INTERP_KERNEL/Interpolation3D1D.txx     2017-01-23 09:50:14.595001480 +0100
251 @@ -0,0 +1,152 @@
252 +// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
253 +//
254 +// This library is free software; you can redistribute it and/or
255 +// modify it under the terms of the GNU Lesser General Public
256 +// License as published by the Free Software Foundation; either
257 +// version 2.1 of the License, or (at your option) any later version.
258 +//
259 +// This library is distributed in the hope that it will be useful,
260 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
261 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
262 +// Lesser General Public License for more details.
263 +//
264 +// You should have received a copy of the GNU Lesser General Public
265 +// License along with this library; if not, write to the Free Software
266 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
267 +//
268 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
269 +//
270 +// Author : Anthony Geay (CEA/DEN)
271 +
272 +#ifndef __INTERPOLATION3D1D_TXX__
273 +#define __INTERPOLATION3D1D_TXX__
274 +
275 +#include "Interpolation3D1D.hxx"
276 +#include "Interpolation.txx"
277 +#include "MeshElement.txx"
278 +#include "PointLocator3DIntersectorP0P0.txx"
279 +#include "PointLocator3DIntersectorP0P1.txx"
280 +#include "PointLocator3DIntersectorP1P0.txx"
281 +#include "PointLocator3DIntersectorP1P1.txx"
282 +#include "Log.hxx"
283 +
284 +#include "BBTree.txx"
285 +
286 +namespace INTERP_KERNEL
287 +{
288 +  /**
289 +   *  Very similar to Interpolation3D::interpolateMeshes, except for the bounding boxes that can be
290 +   *  adjusted in a similar fashion as in InterpolationPlanar::performAdjustmentOfBB()
291 +   **/
292 +  template<class MyMeshType, class MatrixType>
293 +  int Interpolation3D1D::interpolateMeshes(const MyMeshType& srcMesh, const MyMeshType& targetMesh, MatrixType& result, const std::string& method)
294 +  {
295 +    if(InterpolationOptions::getIntersectionType() != PointLocator)
296 +      INTERP_KERNEL::Exception("Invalid 3D/1D intersection type specified : must be PointLocator.");
297 +
298 +    typedef typename MyMeshType::MyConnType ConnType;
299 +    // create MeshElement objects corresponding to each element of the two meshes
300 +    const unsigned long numSrcElems = srcMesh.getNumberOfElements();
301 +    const unsigned long numTargetElems = targetMesh.getNumberOfElements();
302 +
303 +    LOG(2, "Source mesh has " << numSrcElems << " elements and target mesh has " << numTargetElems << " elements ");
304 +
305 +    std::vector<MeshElement<ConnType>*> srcElems(numSrcElems);
306 +    std::vector<MeshElement<ConnType>*> targetElems(numTargetElems);
307 +
308 +    std::map<MeshElement<ConnType>*, int> indices;
309 +
310 +    for(unsigned long i = 0 ; i < numSrcElems ; ++i)
311 +      srcElems[i] = new MeshElement<ConnType>(i, srcMesh);       
312 +
313 +    for(unsigned long i = 0 ; i < numTargetElems ; ++i)
314 +      targetElems[i] = new MeshElement<ConnType>(i, targetMesh);
315 +
316 +    Intersector3D<MyMeshType,MatrixType>* intersector=0;
317 +    std::string methC = InterpolationOptions::filterInterpolationMethod(method);
318 +    if(methC=="P0P0")
319 +      { intersector=new PointLocator3DIntersectorP0P0<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
320 +      }
321 +    else if(methC=="P0P1")
322 +      {  intersector=new PointLocator3DIntersectorP0P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
323 +      }
324 +    else if(methC=="P1P0")
325 +      {  intersector=new PointLocator3DIntersectorP1P0<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
326 +      }
327 +    else if(methC=="P1P1")
328 +      {  intersector=new PointLocator3DIntersectorP1P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
329 +      }
330 +    else
331 +      throw Exception("Invalid method choosed must be in \"P0P0\", \"P0P1\", \"P1P0\" or \"P1P1\".");
332 +    // create empty maps for all source elements
333 +    result.resize(intersector->getNumberOfRowsOfResMatrix());
334 +
335 +    // create BBTree structure
336 +    // - get bounding boxes
337 +    std::vector<double> bboxes(6*numSrcElems);
338 +    int* srcElemIdx = new int[numSrcElems];
339 +    for(unsigned long i = 0; i < numSrcElems ; ++i)
340 +      {
341 +        // get source bboxes in right order
342 +        const BoundingBox* box = srcElems[i]->getBoundingBox();
343 +        bboxes[6*i+0] = box->getCoordinate(BoundingBox::XMIN);
344 +        bboxes[6*i+1] = box->getCoordinate(BoundingBox::XMAX);
345 +        bboxes[6*i+2] = box->getCoordinate(BoundingBox::YMIN);
346 +        bboxes[6*i+3] = box->getCoordinate(BoundingBox::YMAX);
347 +        bboxes[6*i+4] = box->getCoordinate(BoundingBox::ZMIN);
348 +        bboxes[6*i+5] = box->getCoordinate(BoundingBox::ZMAX);
349 +
350 +        srcElemIdx[i] = srcElems[i]->getIndex();
351 +      }
352 +
353 +    adjustBoundingBoxes(bboxes);
354 +    const double *bboxPtr=0;
355 +    if(numSrcElems>0)
356 +      bboxPtr=&bboxes[0];
357 +    BBTree<3,ConnType> tree(bboxPtr, srcElemIdx, 0, numSrcElems);
358 +
359 +    // for each target element, get source elements with which to calculate intersection
360 +    // - calculate intersection by calling intersectCells
361 +    for(unsigned long i = 0; i < numTargetElems; ++i)
362 +      {
363 +        const BoundingBox* box = targetElems[i]->getBoundingBox();
364 +        const int targetIdx = targetElems[i]->getIndex();
365 +
366 +        // get target bbox in right order
367 +        double targetBox[6];
368 +        targetBox[0] = box->getCoordinate(BoundingBox::XMIN);
369 +        targetBox[1] = box->getCoordinate(BoundingBox::XMAX);
370 +        targetBox[2] = box->getCoordinate(BoundingBox::YMIN);
371 +        targetBox[3] = box->getCoordinate(BoundingBox::YMAX);
372 +        targetBox[4] = box->getCoordinate(BoundingBox::ZMIN);
373 +        targetBox[5] = box->getCoordinate(BoundingBox::ZMAX);
374 +
375 +        std::vector<ConnType> intersectElems;
376 +
377 +        tree.getIntersectingElems(targetBox, intersectElems);
378 +
379 +        if ( !intersectElems.empty() )
380 +          intersector->intersectCells(targetIdx,intersectElems,result);
381 +      }
382 +
383 +    // free allocated memory
384 +    delete [] srcElemIdx;
385 +
386 +    int ret=intersector->getNumberOfColsOfResMatrix();
387 +
388 +    delete intersector;
389 +
390 +    for(unsigned long i = 0 ; i < numSrcElems ; ++i)
391 +      {
392 +        delete srcElems[i];
393 +      }
394 +    for(unsigned long i = 0 ; i < numTargetElems ; ++i)
395 +      {
396 +        delete targetElems[i];
397 +      }
398 +    return ret;
399 +
400 +  }
401 +}
402 +
403 +#endif
404 diff -rupN -x git MEDCOUPLING_orig/src/INTERP_KERNEL/Interpolation3D.txx MEDCOUPLING_new/src/INTERP_KERNEL/Interpolation3D.txx
405 --- MEDCOUPLING_orig/src/INTERP_KERNEL/Interpolation3D.txx      2017-01-23 09:49:37.465001480 +0100
406 +++ MEDCOUPLING_new/src/INTERP_KERNEL/Interpolation3D.txx       2017-01-23 09:50:14.595001480 +0100
407 @@ -35,6 +35,7 @@
408  #include "PolyhedronIntersectorP1P1.txx"
409  #include "PointLocator3DIntersectorP1P1.txx"
410  #include "Barycentric3DIntersectorP1P1.txx"
411 +#include "MappedBarycentric3DIntersectorP1P1.txx"
412  #include "Log.hxx"
413  // If defined, use recursion to traverse the binary search tree, else use the BBTree class
414  //#define USE_RECURSIVE_BBOX_FILTER
415 @@ -154,8 +155,11 @@ namespace INTERP_KERNEL
416            case Barycentric:
417              intersector=new Barycentric3DIntersectorP1P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
418              break;
419 +          case MappedBarycentric:
420 +            intersector=new MappedBarycentric3DIntersectorP1P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
421 +            break;
422            default:
423 -            throw INTERP_KERNEL::Exception("Invalid 3D intersection type for P1P1 interp specified : must be Triangle or PointLocator.");
424 +            throw INTERP_KERNEL::Exception("Invalid 3D intersection type for P1P1 interp specified : must be Triangle, PointLocator, Barycentric or MappedBarycentric.");
425            }
426        }
427      else
428 diff -rupN -x git MEDCOUPLING_orig/src/INTERP_KERNEL/InterpolationOptions.hxx MEDCOUPLING_new/src/INTERP_KERNEL/InterpolationOptions.hxx
429 --- MEDCOUPLING_orig/src/INTERP_KERNEL/InterpolationOptions.hxx 2017-01-23 09:49:37.465001480 +0100
430 +++ MEDCOUPLING_new/src/INTERP_KERNEL/InterpolationOptions.hxx  2017-01-23 09:50:14.280001479 +0100
431 @@ -28,7 +28,7 @@
432  
433  namespace INTERP_KERNEL
434  {
435 -  typedef enum { Triangulation, Convex, Geometric2D, PointLocator, Barycentric, BarycentricGeo2D } IntersectionType;
436 +  typedef enum { Triangulation, Convex, Geometric2D, PointLocator, Barycentric, BarycentricGeo2D, MappedBarycentric } IntersectionType;
437    
438    /*!
439     * Class defining the options for all interpolation algorithms used in the \ref remapper "remapper" and
440 diff -rupN -x git MEDCOUPLING_orig/src/INTERP_KERNEL/InterpolationPlanar.txx MEDCOUPLING_new/src/INTERP_KERNEL/InterpolationPlanar.txx
441 --- MEDCOUPLING_orig/src/INTERP_KERNEL/InterpolationPlanar.txx  2017-01-23 09:49:37.466001480 +0100
442 +++ MEDCOUPLING_new/src/INTERP_KERNEL/InterpolationPlanar.txx   2017-01-23 09:50:14.280001479 +0100
443 @@ -40,6 +40,8 @@
444  #include "PlanarIntersectorP1P0PL.txx"
445  #include "PlanarIntersectorP1P1PL.hxx"
446  #include "PlanarIntersectorP1P1PL.txx"
447 +#include "MappedBarycentric2DIntersectorP1P1.hxx"
448 +#include "MappedBarycentric2DIntersectorP1P1.txx"
449  #include "VectorUtils.hxx"
450  #include "BBTree.txx"
451  
452 @@ -358,8 +360,16 @@ namespace INTERP_KERNEL
453                                                                             InterpolationOptions::getPrecision(),
454                                                                             InterpolationOptions::getOrientation());
455              break;
456 +          case MappedBarycentric:
457 +            intersector=new MappedBarycentric2DIntersectorP1P1<MyMeshType,MatrixType>(myMeshT, myMeshS, _dim_caracteristic,
458 +                                                                                     InterpolationOptions::getMaxDistance3DSurfIntersect(),
459 +                                                                                     InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
460 +                                                                                     InterpolationOptions::getMedianPlane(),
461 +                                                                                     InterpolationOptions::getPrecision(),
462 +                                                                                     InterpolationOptions::getOrientation());
463 +            break;
464            default:
465 -            throw INTERP_KERNEL::Exception("For P1P1 planar interpolation possibities are : Triangulation, Convex, Geometric2D, PointLocator !");
466 +            throw INTERP_KERNEL::Exception("For P1P1 planar interpolation possibities are : Triangulation, Convex, Geometric2D, PointLocator, MappedBarycentric !");
467            }
468        }
469      else
470 diff -rupN -x git MEDCOUPLING_orig/src/INTERP_KERNEL/InterpolationUtils.hxx MEDCOUPLING_new/src/INTERP_KERNEL/InterpolationUtils.hxx
471 --- MEDCOUPLING_orig/src/INTERP_KERNEL/InterpolationUtils.hxx   2017-01-23 09:49:37.466001480 +0100
472 +++ MEDCOUPLING_new/src/INTERP_KERNEL/InterpolationUtils.hxx    2017-01-23 09:50:14.596001480 +0100
473 @@ -23,6 +23,7 @@
474  
475  #include "INTERPKERNELDefines.hxx"
476  #include "InterpKernelException.hxx"
477 +#include "VolSurfUser.hxx"
478  
479  #include "NormalizedUnstructuredMesh.hxx"
480  
481 @@ -413,7 +414,7 @@ namespace INTERP_KERNEL
482    }
483  
484    /*!
485 -   * Calculate barycentric coordinates of a point p with respect to triangle or tetra verices.
486 +   * Calculate barycentric coordinates of a point p with respect to triangle or tetra vertices.
487     * This method makes 2 assumptions :
488     *    - this is a simplex
489     *    - 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.
490 @@ -535,6 +536,136 @@ namespace INTERP_KERNEL
491        }
492    }
493  
494 +  /*!
495 +   * Calculate pseudo barycentric coordinates of a point p with respect to the quadrangle vertices.
496 +   * This method makes the assumption that:
497 +   *  - spacedim == meshdim (2 here).
498 +   *  - the point is within the quad
499 +   *  Quadratic elements are not supported yet.
500 +   *
501 +   *  A quadrangle can be described as 3 vectors, one point being taken as the origin.
502 +   *  Denoting A, B, C the three other points, any point P within the quad is written as
503 +   *    P = xA+ yC + xy(B-A-C)
504 +   *  This method solve those 2 equations (one per component) for x and y.
505 +   *
506 +
507 +          A------B
508 +          |      |
509 +          |      |
510 +          0------C
511 +   */
512 +  inline void quad_mapped_coords(const std::vector<const double*>& n, const double *p, double *bc)
513 +  {
514 +    double prec = 1.0e-14;
515 +    enum { _XX=0, _YY, _ZZ };
516 +
517 +    if(n.size() != 4)
518 +      throw INTERP_KERNEL::Exception("INTERP_KERNEL::quad_mapped_coords : unrecognized geometric type! Only QUAD4 supported.");
519 +
520 +    double A[2] = {n[1][_XX] - n[0][_XX],  n[1][_YY] - n[0][_YY]};
521 +    double B[2] = {n[2][_XX] - n[0][_XX],  n[2][_YY] - n[0][_YY]};
522 +    double C[2] = {n[3][_XX] - n[0][_XX],  n[3][_YY] - n[0][_YY]};
523 +    double N[2] = {B[_XX] - A[_XX] - C[_XX], B[_YY] - A[_YY] - C[_YY]};
524 +    double P[2] = {p[_XX] - n[0][_XX], p[_YY] - n[0][_YY]};
525 +
526 +    // degenerated case: a rectangle:
527 +    if (fabs(N[0]) < prec && fabs(N[1]) < prec)
528 +      {
529 +        double det = C[0]*A[1] -C[1]*A[0];
530 +        if (fabs(det) < prec)
531 +          throw INTERP_KERNEL::Exception("MappedBarycentric intersection type: quad_mapped_coords() has a degenerated 2x2 system!");
532 +        bc[0] = (P[0]*A[1]-P[1]*A[0])/det;
533 +        bc[1] = (P[1]*C[0]-P[0]*C[1])/det;
534 +        return;
535 +      }
536 +    double b,c ,a = A[1]*N[0]-A[0]*N[1];
537 +    bool cas1;
538 +    if (fabs(a) > 1.0e-14)
539 +      {
540 +        b = A[1]*C[0]+N[1]*P[0]-N[0]*P[1]-A[0]*C[1];
541 +        c = P[0]*C[1] - P[1]*C[0];
542 +        cas1 = true;
543 +      }
544 +    else
545 +      {
546 +        a = -C[1]*N[0]+C[0]*N[1];
547 +        b = A[1]*C[0]-N[1]*P[0]+N[0]*P[1]-A[0]*C[1];
548 +        c = -P[0]*A[1] + P[1]*A[0];
549 +        cas1 = false;
550 +      }
551 +    double delta = b*b - 4.0*a*c;
552 +    if (delta < 0.0)
553 +      throw INTERP_KERNEL::Exception("MappedBarycentric intersection type: quad_mapped_coords(): imaginary solutions!");
554 +    bc[1] = 0.5*(-b+sqrt(delta))/a;
555 +    if (bc[1] < -prec || bc[1] > (1.0+prec))
556 +      bc[1] = 0.5*(-b-sqrt(delta))/a;
557 +    if (bc[1] < -prec || bc[1] > (1.0+prec))
558 +      throw INTERP_KERNEL::Exception("MappedBarycentric intersection type: quad_mapped_coords(): point doesn't seem to be in quad4!");
559 +    if (cas1)
560 +      {
561 +        double denom = C[0]+bc[1]*N[0];
562 +        if (fabs(denom) < prec)
563 +          throw INTERP_KERNEL::Exception("MappedBarycentric intersection type: quad_mapped_coords(): point doesn't seem to be in quad4!");
564 +        bc[0] = (P[0]-bc[1]*A[0])/denom;
565 +        if (bc[0] < -prec || bc[0] > (1.0+prec))
566 +          throw INTERP_KERNEL::Exception("MappedBarycentric intersection type: quad_mapped_coords(): point doesn't seem to be in quad4!");
567 +      }
568 +    else
569 +      {
570 +        bc[0] = bc[1];
571 +        double denom = A[1]+bc[0]*N[1];
572 +        if (fabs(denom) < prec)
573 +          throw INTERP_KERNEL::Exception("MappedBarycentric intersection type: cuboid_mapped_coord(): point doesn't seem to be in quad4!");
574 +        bc[1] = (P[1]-bc[0]*C[1])/denom;
575 +        if (bc[1] < -prec || bc[1] > (1.0+prec))
576 +          throw INTERP_KERNEL::Exception("MappedBarycentric intersection type: cuboid_mapped_coord(): point doesn't seem to be in quad4!");
577 +      }
578 +  }
579 +
580 +  /*!
581 +   * Doing as in quad_mapped_coords() would lead to a 4th order equation ... So go simpler here:
582 +   * orthogonal distance to each pair of parallel faces is computed. The ratio gives a number in [0,1]
583 +   *
584 +   * Conventions:
585 +   *   - for HEXA8, point F (5) is taken to be the origin (see med file ref connec):
586 +   *          0 ------ 3
587 +             /|       /|
588 +            / |      / |
589 +           1 ------ 2  |
590 +           |  |     |  |
591 +           |  |     |  |
592 +           |  4-----|- 7
593 +           | /      | /
594 +           5 ------ 6
595 +
596 +   *
597 +   */
598 +
599 +  inline void cuboid_mapped_coords(const std::vector<const double*>& n, const double *p, double *bc)
600 +  {
601 +    double prec = 1.0e-14;
602 +    enum { _XX=0, _YY };
603 +    if (n.size() != 8)
604 +      throw INTERP_KERNEL::Exception("INTERP_KERNEL::cuboid_mapped_coords: unrecognized geometric type! Only HEXA8 supported.");
605 +
606 +    double dx1, dx2, dy1, dy2, dz1, dz2;
607 +    dx1 = OrthoDistanceFromPtToPlaneInSpaceDim3(p, n[4],n[5],n[1]);
608 +    dx2 = OrthoDistanceFromPtToPlaneInSpaceDim3(p, n[7],n[3],n[2]);
609 +
610 +    dy1 = OrthoDistanceFromPtToPlaneInSpaceDim3(p, n[5],n[6],n[2]);
611 +    dy2 = OrthoDistanceFromPtToPlaneInSpaceDim3(p, n[4],n[0],n[3]);
612 +
613 +    dz1 = OrthoDistanceFromPtToPlaneInSpaceDim3(p, n[5],n[4],n[7]);
614 +    dz2 = OrthoDistanceFromPtToPlaneInSpaceDim3(p, n[1],n[2],n[3]);
615 +
616 +    if (dx1 < -prec || dx2 < -prec || dy1 < -prec || dy2 < -prec || dz1 < -prec || dz2 < -prec)
617 +      throw INTERP_KERNEL::Exception("INTERP_KERNEL::cuboid_mapped_coords: point outside HEXA8");
618 +
619 +    bc[0] = dx1+dx2 < prec ? 0.5 : dx1/(dx1+dx2);
620 +    bc[1] = dy1+dy2 < prec ? 0.5 : dy1/(dy1+dy2);
621 +    bc[2] = dz1+dz2 < prec ? 0.5 : dz1/(dz1+dz2);
622 +  }
623 +
624    /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
625    /*         calcul la surface d'un polygone.                 */
626    /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
627 diff -rupN -x git MEDCOUPLING_orig/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.hxx MEDCOUPLING_new/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.hxx
628 --- MEDCOUPLING_orig/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.hxx   1970-01-01 01:00:00.000000000 +0100
629 +++ MEDCOUPLING_new/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.hxx    2017-01-23 09:50:14.283001479 +0100
630 @@ -0,0 +1,44 @@
631 +// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
632 +//
633 +// This library is free software; you can redistribute it and/or
634 +// modify it under the terms of the GNU Lesser General Public
635 +// License as published by the Free Software Foundation; either
636 +// version 2.1 of the License, or (at your option) any later version.
637 +//
638 +// This library is distributed in the hope that it will be useful,
639 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
640 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
641 +// Lesser General Public License for more details.
642 +//
643 +// You should have received a copy of the GNU Lesser General Public
644 +// License along with this library; if not, write to the Free Software
645 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
646 +//
647 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
648 +//
649 +// Author : Adrien Bruneton (CEA/DEN)
650 +
651 +#ifndef __MappedBarycenter2DIntersectorP1P1_HXX__
652 +#define __MappedBarycenter2DIntersectorP1P1_HXX__
653 +
654 +#include "PlanarIntersector.hxx"
655 +
656 +namespace INTERP_KERNEL
657 +{
658 +  template<class MyMeshType, class MyMatrix>
659 +  class MappedBarycentric2DIntersectorP1P1 : public PlanarIntersector<MyMeshType,MyMatrix>
660 +  {
661 +   public:
662 +    static const int SPACEDIM=MyMeshType::MY_SPACEDIM;
663 +    static const int MESHDIM=MyMeshType::MY_MESHDIM;
664 +    typedef typename MyMeshType::MyConnType ConnType;
665 +    static const NumberingPolicy numPol=MyMeshType::My_numPol;
666 +  public:
667 +    MappedBarycentric2DIntersectorP1P1(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double md3DSurf, double minDot3DSurf, double medianPlane, double precision, int orientation);
668 +    void intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res);
669 +    int getNumberOfRowsOfResMatrix() const;
670 +    int getNumberOfColsOfResMatrix() const;
671 +  };
672 +}
673 +
674 +#endif
675 diff -rupN -x git MEDCOUPLING_orig/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.txx MEDCOUPLING_new/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.txx
676 --- MEDCOUPLING_orig/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.txx   1970-01-01 01:00:00.000000000 +0100
677 +++ MEDCOUPLING_new/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.txx    2017-01-23 09:50:14.283001479 +0100
678 @@ -0,0 +1,111 @@
679 +// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
680 +//
681 +// This library is free software; you can redistribute it and/or
682 +// modify it under the terms of the GNU Lesser General Public
683 +// License as published by the Free Software Foundation; either
684 +// version 2.1 of the License, or (at your option) any later version.
685 +//
686 +// This library is distributed in the hope that it will be useful,
687 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
688 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
689 +// Lesser General Public License for more details.
690 +//
691 +// You should have received a copy of the GNU Lesser General Public
692 +// License along with this library; if not, write to the Free Software
693 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
694 +//
695 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
696 +//
697 +// Author : Adrien Bruneton (CEA/DEN)
698 +
699 +#ifndef __MappedBarycentric2DIntersectorP1P1_TXX__
700 +#define __MappedBarycentric2DIntersectorP1P1_TXX__
701 +
702 +#include "MappedBarycentric2DIntersectorP1P1.hxx"
703 +#include "PlanarIntersector.txx"
704 +#include "CellModel.hxx"
705 +
706 +#include "PointLocatorAlgos.txx"
707 +#include "MeshUtils.hxx"
708 +
709 +namespace INTERP_KERNEL
710 +{
711 +  template<class MyMeshType, class MyMatrix>
712 +  MappedBarycentric2DIntersectorP1P1<MyMeshType,MyMatrix>::MappedBarycentric2DIntersectorP1P1(const MyMeshType& meshT, const MyMeshType& meshS,
713 +                                                                        double dimCaracteristic, double md3DSurf, double minDot3DSurf,
714 +                                                                        double medianPlane, double precision, int orientation):
715 +    PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,minDot3DSurf,medianPlane,true,orientation,0)
716 +  {
717 +  }
718 +
719 +  template<class MyMeshType, class MyMatrix>
720 +  void MappedBarycentric2DIntersectorP1P1<MyMeshType,MyMatrix>::intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res)
721 +  {
722 +    std::vector<double> CoordsT;
723 +    PlanarIntersector<MyMeshType,MyMatrix>::getRealTargetCoordinates(OTT<ConnType,numPol>::indFC(icellT),CoordsT);
724 +    int nbOfNodesT=CoordsT.size()/SPACEDIM;
725 +    for(typename std::vector<ConnType>::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++)
726 +      {
727 +        NormalizedCellType tS=PlanarIntersector<MyMeshType,MyMatrix>::_meshS.getTypeOfElement(OTT<ConnType,numPol>::indFC(*iter));
728 +        if(tS!=NORM_QUAD4)
729 +          throw INTERP_KERNEL::Exception("Invalid source cell detected for meshdim==2. Only QUAD4 supported !");
730 +        std::vector<double> CoordsS;
731 +        PlanarIntersector<MyMeshType,MyMatrix>::getRealSourceCoordinates(OTT<ConnType,numPol>::indFC(*iter),CoordsS);
732 +        std::vector<double> CoordsTTmp(CoordsT);
733 +        if(SPACEDIM==3)
734 +          PlanarIntersector<MyMeshType,MyMatrix>::projectionThis(&CoordsS[0],&CoordsTTmp[0],CoordsS.size()/SPACEDIM,nbOfNodesT);
735 +        const ConnType *startOfCellNodeConnT=PlanarIntersector<MyMeshType,MyMatrix>::_connectT+OTT<ConnType,numPol>::conn2C(PlanarIntersector<MyMeshType,MyMatrix>::_connIndexT[icellT]);
736 +        for(int nodeIdT=0;nodeIdT<nbOfNodesT;nodeIdT++)
737 +          {
738 +            typename MyMatrix::value_type& resRow=res[OTT<ConnType,numPol>::ind2C(startOfCellNodeConnT[nodeIdT])];
739 +            if( PointLocatorAlgos<MyMeshType>::isElementContainsPointAlg2D(&CoordsTTmp[nodeIdT*SPACEDIM],&CoordsS[0],4,PlanarIntersector<MyMeshType,MyMatrix>::_precision) )
740 +              {
741 +                double mco[2];  // mapped coordinates in the quad4
742 +                std::vector<const double*> coo(4);
743 +                coo[0]=&CoordsS[0]; coo[1]=&CoordsS[SPACEDIM]; coo[2]=&CoordsS[2*SPACEDIM]; coo[3]=&CoordsS[3*SPACEDIM];
744 +                quad_mapped_coords(coo,&CoordsTTmp[nodeIdT*SPACEDIM],mco);
745 +
746 +                // Now use the form function of the QUAD4 to map the field values
747 +                double resLoc[4];
748 +                // See QUAD4 standard connectivity and cuboid_mapped_coords() convention:
749 +                resLoc[0] = (1.-mco[0]) * (1.-mco[1]);
750 +                resLoc[1] = (1.-mco[0]) *   mco[1]   ;
751 +                resLoc[2] =  mco[0]     *   mco[1]   ;
752 +                resLoc[3] =  mco[0]     * (1.-mco[1]);
753 +
754 +                const ConnType *startOfCellNodeConnS=PlanarIntersector<MyMeshType,MyMatrix>::_connectS+OTT<ConnType,numPol>::conn2C(PlanarIntersector<MyMeshType,MyMatrix>::_connIndexS[*iter]);
755 +                for(int nodeIdS=0;nodeIdS<4;nodeIdS++)
756 +                  {
757 +                    if(fabs(resLoc[nodeIdS])>PlanarIntersector<MyMeshType,MyMatrix>::_precision)
758 +                      {
759 +                        ConnType curNodeSInCmode=OTT<ConnType,numPol>::coo2C(startOfCellNodeConnS[nodeIdS]);
760 +                        typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT<ConnType,numPol>::indFC(curNodeSInCmode));
761 +                        if(iterRes==resRow.end())
762 +                          resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(curNodeSInCmode),resLoc[nodeIdS]));
763 +                        else
764 +                          {
765 +                            double val=(*iterRes).second+resLoc[nodeIdS];
766 +                            resRow.erase(OTT<ConnType,numPol>::indFC(curNodeSInCmode));
767 +                            resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(curNodeSInCmode),val));
768 +                          }
769 +                      }
770 +                  }
771 +              }
772 +          }
773 +      }
774 +  }
775 +
776 +  template<class MyMeshType, class MyMatrix>
777 +  int MappedBarycentric2DIntersectorP1P1<MyMeshType,MyMatrix>::getNumberOfRowsOfResMatrix() const
778 +  {
779 +    return PlanarIntersector<MyMeshType,MyMatrix>::_meshT.getNumberOfNodes();
780 +  }
781 +
782 +  template<class MyMeshType, class MyMatrix>
783 +  int MappedBarycentric2DIntersectorP1P1<MyMeshType,MyMatrix>::getNumberOfColsOfResMatrix() const
784 +  {
785 +    return PlanarIntersector<MyMeshType,MyMatrix>::_meshS.getNumberOfNodes();
786 +  }
787 +}
788 +
789 +#endif
790 diff -rupN -x git MEDCOUPLING_orig/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.hxx MEDCOUPLING_new/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.hxx
791 --- MEDCOUPLING_orig/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.hxx   1970-01-01 01:00:00.000000000 +0100
792 +++ MEDCOUPLING_new/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.hxx    2017-01-23 09:50:14.283001479 +0100
793 @@ -0,0 +1,46 @@
794 +// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
795 +//
796 +// This library is free software; you can redistribute it and/or
797 +// modify it under the terms of the GNU Lesser General Public
798 +// License as published by the Free Software Foundation; either
799 +// version 2.1 of the License, or (at your option) any later version.
800 +//
801 +// This library is distributed in the hope that it will be useful,
802 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
803 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
804 +// Lesser General Public License for more details.
805 +//
806 +// You should have received a copy of the GNU Lesser General Public
807 +// License along with this library; if not, write to the Free Software
808 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
809 +//
810 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
811 +//
812 +// Author : Adrien Bruneton (CEA/DEN)
813 +
814 +#ifndef __MappedBarycentric3DIntersectorP1P1_HXX__
815 +#define __MappedBarycentric3DIntersectorP1P1_HXX__
816 +
817 +#include "Intersector3DP1P1.hxx"
818 +#include "NormalizedUnstructuredMesh.hxx"
819 +
820 +namespace INTERP_KERNEL
821 +{
822 +  template<class MyMeshType, class MyMatrix>
823 +  class MappedBarycentric3DIntersectorP1P1 : public Intersector3DP1P1<MyMeshType,MyMatrix>
824 +  { 
825 +  public:
826 +    static const int SPACEDIM=MyMeshType::MY_SPACEDIM;
827 +    static const int MESHDIM=MyMeshType::MY_MESHDIM;
828 +    typedef typename MyMeshType::MyConnType ConnType;
829 +    static const NumberingPolicy numPol=MyMeshType::My_numPol;
830 +  public:
831 +    MappedBarycentric3DIntersectorP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, double precision);
832 +    ~MappedBarycentric3DIntersectorP1P1();
833 +    void intersectCells(ConnType targetCell, const std::vector<ConnType>& srcCells, MyMatrix& res);
834 +  protected:
835 +    double _precision;
836 +  };
837 +}
838 +
839 +#endif
840 diff -rupN -x git MEDCOUPLING_orig/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.txx MEDCOUPLING_new/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.txx
841 --- MEDCOUPLING_orig/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.txx   1970-01-01 01:00:00.000000000 +0100
842 +++ MEDCOUPLING_new/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.txx    2017-01-23 09:50:14.283001479 +0100
843 @@ -0,0 +1,113 @@
844 +// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
845 +//
846 +// This library is free software; you can redistribute it and/or
847 +// modify it under the terms of the GNU Lesser General Public
848 +// License as published by the Free Software Foundation; either
849 +// version 2.1 of the License, or (at your option) any later version.
850 +//
851 +// This library is distributed in the hope that it will be useful,
852 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
853 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
854 +// Lesser General Public License for more details.
855 +//
856 +// You should have received a copy of the GNU Lesser General Public
857 +// License along with this library; if not, write to the Free Software
858 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
859 +//
860 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
861 +//
862 +// Author : Adrien Bruneton (CEA/DEN)
863 +
864 +#ifndef __MAPPEDBARYCENTRIC3DINTERSECTORP1P1_TXX__
865 +#define __MAPPEDBARYCENTRIC3DINTERSECTORP1P1_TXX__
866 +
867 +#include "MappedBarycentric3DIntersectorP1P1.hxx"
868 +#include "Intersector3DP1P1.txx"
869 +#include "MeshUtils.hxx"
870 +
871 +namespace INTERP_KERNEL
872 +{
873 +
874 +  /**
875 +   * Constructor creating object from target cell global number 
876 +   * 
877 +   * @param targetMesh  mesh containing the target elements
878 +   * @param srcMesh     mesh containing the source elements
879 +   * @param policy      splitting policy to be used
880 +   */
881 +  template<class MyMeshType, class MyMatrix>
882 +  MappedBarycentric3DIntersectorP1P1<MyMeshType,MyMatrix>::MappedBarycentric3DIntersectorP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, double precision):
883 +    Intersector3DP1P1<MyMeshType,MyMatrix>(targetMesh,srcMesh),_precision(precision)
884 +  {
885 +  }
886 +
887 +  template<class MyMeshType, class MyMatrix>
888 +  MappedBarycentric3DIntersectorP1P1<MyMeshType,MyMatrix>::~MappedBarycentric3DIntersectorP1P1()
889 +  {
890 +  }
891 +
892 +  /**
893 +   * @param targetCell in C mode.
894 +   * @param srcCells in C mode.
895 +   */
896 +  template<class MyMeshType, class MyMatrix>
897 +  void MappedBarycentric3DIntersectorP1P1<MyMeshType,MyMatrix>::intersectCells(ConnType targetCell, const std::vector<ConnType>& srcCells, MyMatrix& res)
898 +  {
899 +    std::vector<double> CoordsT;
900 +    const ConnType *startOfCellNodeConnT=Intersector3DP1P1<MyMeshType,MyMatrix>::getStartConnOfTargetCell(targetCell);
901 +    Intersector3DP1P1<MyMeshType,MyMatrix>::getRealTargetCoordinates(OTT<ConnType,numPol>::indFC(targetCell),CoordsT);
902 +    int nbOfNodesT=CoordsT.size()/SPACEDIM;
903 +    const double *coordsS=Intersector3DP1P1<MyMeshType,MyMatrix>::_src_mesh.getCoordinatesPtr();
904 +    for(int nodeIdT=0;nodeIdT<nbOfNodesT;nodeIdT++)
905 +      {
906 +        typename MyMatrix::value_type& resRow=res[OTT<ConnType,numPol>::ind2C(startOfCellNodeConnT[nodeIdT])];
907 +        if(!resRow.empty())
908 +          continue;
909 +        for(typename std::vector<ConnType>::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++)
910 +          {
911 +            NormalizedCellType tS=Intersector3DP1P1<MyMeshType,MyMatrix>::_src_mesh.getTypeOfElement(OTT<ConnType,numPol>::indFC(*iterCellS));
912 +            if(tS!=NORM_HEXA8)
913 +              throw INTERP_KERNEL::Exception("Invalid source cell detected for meshdim==3. Only HEXA8 supported !");
914 +            const CellModel& cmTypeS=CellModel::GetCellModel(tS);
915 +            //
916 +            std::vector<ConnType> connOfCurCellS;
917 +            Intersector3DP1P1<MyMeshType,MyMatrix>::getConnOfSourceCell(OTT<ConnType,numPol>::indFC(*iterCellS),connOfCurCellS);
918 +            if( PointLocatorAlgos<MyMeshType>::isElementContainsPointAlg3D(&CoordsT[nodeIdT*SPACEDIM],&connOfCurCellS[0],connOfCurCellS.size(),coordsS,cmTypeS,_precision) )
919 +              {
920 +                double mco[3];  // mapped coordinates in the hexa8
921 +                std::vector<double> localCoordsS;
922 +                Intersector3DP1P1<MyMeshType,MyMatrix>::getRealSourceCoordinates(OTT<ConnType,numPol>::indFC(*iterCellS),localCoordsS);
923 +                std::vector<const double*> coo(8);
924 +                coo[0]=&localCoordsS[0]; coo[1]=&localCoordsS[3]; coo[2]=&localCoordsS[6]; coo[3]=&localCoordsS[9];
925 +                coo[4]=&localCoordsS[12]; coo[5]=&localCoordsS[15]; coo[6]=&localCoordsS[18]; coo[7]=&localCoordsS[21];
926 +                cuboid_mapped_coords(coo,&CoordsT[nodeIdT*SPACEDIM],mco);
927 +
928 +                // Now use the form function of the HEXA8 to map the field values
929 +                double resLoc[8];
930 +                // See HEXA8 standard connectivity and cuboid_mapped_coords() convention:
931 +                resLoc[5] = (1.-mco[0]) * (1.-mco[1]) * (1.-mco[2]);
932 +                resLoc[6] =  mco[0]     * (1.-mco[1]) * (1.-mco[2]);
933 +                resLoc[7] =  mco[0]     *   mco[1]    * (1.-mco[2]);
934 +                resLoc[4] = (1.-mco[0]) *   mco[1]    * (1.-mco[2]);
935 +
936 +                resLoc[1] = (1.-mco[0]) * (1.-mco[1]) * mco[2];
937 +                resLoc[2] =  mco[0]     * (1.-mco[1]) * mco[2];
938 +                resLoc[3] =  mco[0]     *   mco[1]    * mco[2];
939 +                resLoc[0] = (1.-mco[0]) *   mco[1]    * mco[2];
940 +
941 +                const ConnType *startOfCellNodeConnS=Intersector3DP1P1<MyMeshType,MyMatrix>::getStartConnOfSourceCell(*iterCellS);
942 +                for(int nodeIdS=0;nodeIdS<8;nodeIdS++)
943 +                  {
944 +                    if(fabs(resLoc[nodeIdS])>_precision)
945 +                      {
946 +                        ConnType curNodeSInCmode=OTT<ConnType,numPol>::coo2C(startOfCellNodeConnS[nodeIdS]);
947 +                        resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(curNodeSInCmode),resLoc[nodeIdS]));
948 +                      }
949 +                  }
950 +              }
951 +          }
952 +      }
953 +  }
954 +}
955 +
956 +#endif
957 diff -rupN -x git MEDCOUPLING_orig/src/INTERP_KERNEL/VolSurfUser.cxx MEDCOUPLING_new/src/INTERP_KERNEL/VolSurfUser.cxx
958 --- MEDCOUPLING_orig/src/INTERP_KERNEL/VolSurfUser.cxx  2017-01-23 09:49:37.466001480 +0100
959 +++ MEDCOUPLING_new/src/INTERP_KERNEL/VolSurfUser.cxx   2017-01-23 09:50:14.296001479 +0100
960 @@ -28,6 +28,25 @@
961  
962  namespace INTERP_KERNEL
963  {
964 +  /* Orthogonal distance from a point to a plane defined by three points p1, p2, p3.
965 +   * Returns a signed distance, the normal of the plane being defined by (p1-p2)x(p3-p2)
966 +   */
967 +  double OrthoDistanceFromPtToPlaneInSpaceDim3(const double *p, const double *p1, const double *p2, const double *p3)
968 +  {
969 +    double prec = 1.0e-14;
970 +    double T[2][3] = {{p1[0] - p2[0], p1[1] - p2[1], p1[2] - p2[2]},
971 +                      {p3[0] - p2[0], p3[1] - p2[1], p3[2] - p2[2]}};
972 +    double N[3] = {T[0][1]*T[1][2]-T[0][2]*T[1][1],
973 +                   T[0][2]*T[1][0]-T[0][0]*T[1][2],
974 +                   T[0][0]*T[1][1]-T[0][1]*T[1][0]};
975 +
976 +    double norm2 = N[0]*N[0] + N[1]*N[1] + N[2]*N[2];
977 +    if (norm2 < prec)
978 +      throw INTERP_KERNEL::Exception("OrthoDistanceFromPtToPlaneInSpaceDim3: degenerated normal vector!");
979 +    double num = N[0]*(p[0]-p1[0]) + N[1]*(p[1]-p1[1]) + N[2]*(p[2]-p1[2]);
980 +    return num/sqrt(norm2);
981 +  }
982 +
983    double SquareDistanceFromPtToSegInSpaceDim2(const double *pt, const double *pt0Seg2, const double *pt1Seg2, std::size_t &nbOfHint)
984    {
985      double dx=pt1Seg2[0]-pt0Seg2[0],dy=pt1Seg2[1]-pt0Seg2[1];
986 diff -rupN -x git MEDCOUPLING_orig/src/INTERP_KERNEL/VolSurfUser.hxx MEDCOUPLING_new/src/INTERP_KERNEL/VolSurfUser.hxx
987 --- MEDCOUPLING_orig/src/INTERP_KERNEL/VolSurfUser.hxx  2017-01-23 09:49:37.466001480 +0100
988 +++ MEDCOUPLING_new/src/INTERP_KERNEL/VolSurfUser.hxx   2017-01-23 09:50:14.296001479 +0100
989 @@ -39,6 +39,8 @@ namespace INTERP_KERNEL
990    template<class ConnType, NumberingPolicy numPolConn>
991    void computeBarycenter2(NormalizedCellType type, const ConnType *connec, int lgth, const double *coords, int spaceDim, double *res);
992  
993 +  double INTERPKERNEL_EXPORT OrthoDistanceFromPtToPlaneInSpaceDim3(const double *p, const double *p1, const double *p2, const double *p3);
994 +
995    double INTERPKERNEL_EXPORT SquareDistanceFromPtToSegInSpaceDim2(const double *pt, const double *pt0Seg2, const double *pt1Seg2, std::size_t &nbOfHint);
996  
997    double INTERPKERNEL_EXPORT DistanceFromPtToTriInSpaceDim3(const double *pt, const double *pt0Tri3, const double *pt1Tri3, const double *pt2Tri3);
998 diff -rupN -x git MEDCOUPLING_orig/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx MEDCOUPLING_new/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx
999 --- MEDCOUPLING_orig/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx    2017-01-23 09:49:37.468001480 +0100
1000 +++ MEDCOUPLING_new/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx     2017-01-23 09:50:14.305001479 +0100
1001 @@ -342,5 +342,148 @@ namespace INTERP_TEST
1002      CPPUNIT_ASSERT_DOUBLES_EQUAL( p[0], p2[0], 1e-12);
1003      CPPUNIT_ASSERT_DOUBLES_EQUAL( p[1], p2[1], 1e-12);
1004      CPPUNIT_ASSERT_DOUBLES_EQUAL( p[2], p2[2], 1e-12);
1005 -  }  
1006 +  }
1007 +
1008 +  /* Conventions:
1009 +  *   - for HEXA8, point 5 is taken to be the origin (see med file ref connec):
1010 +  *          0 ------ 3
1011 +            /|       /|
1012 +           / |      / |
1013 +          1 ------ 2  |
1014 +          |  |     |  |
1015 +          |  |     |  |
1016 +          |  4-----|- 7
1017 +          | /      | /
1018 +          5 ------ 6
1019 +   */
1020 +  void UnitTetraIntersectionBaryTest::test_cuboid_mapped_coords_3D()
1021 +  {
1022 +    double nodes[8][3] = { { 0.0, 2.0, 4.0 }, //0
1023 +                           { 0.0, 0.0, 4.0 },
1024 +                           { 1.0, 0.0, 4.0 },
1025 +                           { 1.0, 2.0, 4.0 },
1026 +                           { 0.0, 2.0, 0.0 }, // 4
1027 +                           { 0.0, 0.0, 0.0 },
1028 +                           { 1.0, 0.0, 0.0 },
1029 +                           { 1.0, 2.0, 0.0 }
1030 +    };
1031 +    // Translate cube:
1032 +    for (int i=0; i < 8; ++i)
1033 +      for (int j=0; j < 3; ++j)
1034 +        nodes[i][j] += 15.0;
1035 +
1036 +    std::vector<const double*> n (8);
1037 +    for (int i=0; i<8; i++)
1038 +      n[i] = &nodes[i][0];
1039 +
1040 +    {
1041 +        // middle point
1042 +        double p[3] = { 15.5, 16.0, 17.0 }, bc[3];
1043 +        cuboid_mapped_coords(n, p, bc);
1044 +        CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, bc[0], 1e-12);
1045 +        CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, bc[1], 1e-12);
1046 +        CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, bc[2], 1e-12);
1047 +    }
1048 +    {
1049 +      // point 1
1050 +      double p[3] = { 15.0, 15.0, 19.0 }, bc[3];
1051 +      cuboid_mapped_coords(n, p, bc);
1052 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, bc[0], 1e-12);
1053 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, bc[1], 1e-12);
1054 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[2], 1e-12);
1055 +    }
1056 +    {
1057 +      // point 7
1058 +      double p[3] = { 16.0, 17.0, 15.0 }, bc[3];
1059 +      cuboid_mapped_coords(n, p, bc);
1060 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[0], 1e-12);
1061 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[1], 1e-12);
1062 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, bc[2], 1e-12);
1063 +    }
1064 +    {
1065 +      // point 3
1066 +      double p[3] = { 16.0, 17.0, 19.0 }, bc[3];
1067 +      cuboid_mapped_coords(n, p, bc);
1068 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[0], 1e-12);
1069 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[1], 1e-12);
1070 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[2], 1e-12);
1071 +    }
1072 +    {
1073 +      // point outside
1074 +      double p[3] = { 2.0, 16.0, 18.0 }, bc[3];
1075 +      CPPUNIT_ASSERT_THROW(cuboid_mapped_coords(n, p, bc), INTERP_KERNEL::Exception);
1076 +    }
1077 +
1078 +  }
1079 +
1080 +  /* Convention
1081 +      - for QUAD4, point 0 is taken to be the origin (again see med file ref connec):
1082 +
1083 +         1------2
1084 +         |      |
1085 +         |      |
1086 +         0------3
1087 +  */
1088 +  void UnitTetraIntersectionBaryTest::test_quad_mapped_coords_2D()
1089 +  {
1090 +
1091 +    double nodes[4][2] = { { 0.0, 0.0 },
1092 +                           { 0.0, 1.0 },
1093 +                           { 2.0, 3.0 },
1094 +                           { 1.0, 0.0 } };
1095 +
1096 +    // Translate quad4:
1097 +    for (int i=0; i < 4; ++i)
1098 +      for (int j=0; j < 2; ++j)
1099 +        nodes[i][j] += 15.0;
1100 +
1101 +    std::vector<const double*> n (4);
1102 +    for (int i=0; i<4; i++)
1103 +      n[i] = &nodes[i][0];
1104 +
1105 +    {
1106 +      // middle point
1107 +      double p[2] = { 15.75, 16.0 }, bc[2];
1108 +      quad_mapped_coords(n, p, bc);
1109 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, bc[0], 1e-12);
1110 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, bc[1], 1e-12);
1111 +    }
1112 +
1113 +    {
1114 +      // middle point of seg
1115 +      double p[2] = { 15.5, 15.0 }, bc[2];
1116 +      quad_mapped_coords(n, p, bc);
1117 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, bc[0], 1e-12);
1118 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, bc[1], 1e-12);
1119 +    }
1120 +
1121 +    {
1122 +      // point 1
1123 +      double p[2] = { 15.0, 16.0 }, bc[2];
1124 +      quad_mapped_coords(n, p, bc);
1125 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, bc[0], 1e-12);
1126 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[1], 1e-12);
1127 +    }
1128 +    {
1129 +      // point 2
1130 +      double p[2] = { 17.0, 18.0 }, bc[2];
1131 +      quad_mapped_coords(n, p, bc);
1132 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[0], 1e-12);
1133 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[1], 1e-12);
1134 +    }
1135 +    {
1136 +      // point 3
1137 +      double p[2] = { 16.0, 15.0 }, bc[2];
1138 +      quad_mapped_coords(n, p, bc);
1139 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[0], 1e-12);
1140 +      CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, bc[1], 1e-12);
1141 +    }
1142 +    {
1143 +      // point outside
1144 +      double p[2] = { 18.0, 18.0 }, bc[2];
1145 +      CPPUNIT_ASSERT_THROW(quad_mapped_coords(n, p, bc), INTERP_KERNEL::Exception);
1146 +    }
1147 +  }
1148 +
1149 +
1150  }
1151 diff -rupN -x git MEDCOUPLING_orig/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.hxx MEDCOUPLING_new/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.hxx
1152 --- MEDCOUPLING_orig/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.hxx    2017-01-23 09:49:37.468001480 +0100
1153 +++ MEDCOUPLING_new/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.hxx     2017-01-23 09:50:14.305001479 +0100
1154 @@ -52,6 +52,8 @@ namespace INTERP_TEST
1155      CPPUNIT_TEST( test_UnitTetraIntersectionBary_11 );
1156      CPPUNIT_TEST( test_TetraAffineTransform_reverseApply );
1157      CPPUNIT_TEST( test_barycentric_coords );
1158 +    CPPUNIT_TEST( test_cuboid_mapped_coords_3D );
1159 +    CPPUNIT_TEST( test_quad_mapped_coords_2D );
1160      CPPUNIT_TEST_SUITE_END();
1161    public:
1162      void test_UnitTetraIntersectionBary_1();
1163 @@ -69,6 +71,8 @@ namespace INTERP_TEST
1164      void test_UnitTetraIntersectionBary_13();
1165      void test_TetraAffineTransform_reverseApply();
1166      void test_barycentric_coords();
1167 +    void test_cuboid_mapped_coords_3D();
1168 +    void test_quad_mapped_coords_2D();
1169    };
1170  }
1171  
1172 diff -rupN -x git MEDCOUPLING_orig/src/MEDCoupling/MEDCouplingRemapper.cxx MEDCOUPLING_new/src/MEDCoupling/MEDCouplingRemapper.cxx
1173 --- MEDCOUPLING_orig/src/MEDCoupling/MEDCouplingRemapper.cxx    2017-01-23 09:49:37.490001480 +0100
1174 +++ MEDCOUPLING_new/src/MEDCoupling/MEDCouplingRemapper.cxx     2017-01-23 09:50:14.629001480 +0100
1175 @@ -35,6 +35,7 @@
1176  #include "Interpolation3DSurf.hxx"
1177  #include "Interpolation2D1D.txx"
1178  #include "Interpolation2D3D.txx"
1179 +#include "Interpolation3D1D.txx"
1180  #include "InterpolationCU.txx"
1181  #include "InterpolationCC.txx"
1182  
1183 @@ -436,7 +437,7 @@ int MEDCouplingRemapper::prepareInterpKe
1184          throw INTERP_KERNEL::Exception("Invalid interpolation requested between 3D and 1D ! Select PointLocator as intersection type !");
1185        MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh);
1186        MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
1187 -      INTERP_KERNEL::Interpolation3D interpolation(*this);
1188 +      INTERP_KERNEL::Interpolation3D1D interpolation(*this);
1189        nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
1190      }
1191    else if(srcMeshDim==1 && trgMeshDim==3 && srcSpaceDim==3)
1192 @@ -445,7 +446,7 @@ int MEDCouplingRemapper::prepareInterpKe
1193          throw INTERP_KERNEL::Exception("Invalid interpolation requested between 3D and 1D ! Select PointLocator as intersection type !");
1194        MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh);
1195        MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
1196 -      INTERP_KERNEL::Interpolation3D interpolation(*this);
1197 +      INTERP_KERNEL::Interpolation3D1D interpolation(*this);
1198        std::vector<std::map<int,double> > matrixTmp;
1199        std::string revMethod(BuildMethodFrom(trgMeth,srcMeth));
1200        nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,revMethod);
1201 diff -rupN -x git MEDCOUPLING_orig/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py MEDCOUPLING_new/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py
1202 --- MEDCOUPLING_orig/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py    2017-01-23 09:49:37.520001480 +0100
1203 +++ MEDCOUPLING_new/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py     2017-01-23 09:50:14.666001480 +0100
1204 @@ -555,7 +555,7 @@ class MEDCouplingBasicsTest(unittest.Tes
1205      def testSwig2BarycentricP1P13D_1(self):
1206          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)
1207          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])
1208 -        s=MEDCoupling1SGTUMesh("target",NORM_HEXA8) ; s.setCoords(sCoo)
1209 +        s=MEDCoupling1SGTUMesh("source",NORM_HEXA8) ; s.setCoords(sCoo)
1210          s.setNodalConnectivity(sConn)
1211          #
1212          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)
1213 @@ -587,6 +587,130 @@ class MEDCouplingBasicsTest(unittest.Tes
1214          self.assertAlmostEqual(0.3521445110626687 ,m[6][170],12)
1215          pass
1216  
1217 +    def testSwig2MappedBarycentricP1P12D_1(self):
1218 +        """ Testing mapped barycentric P1P1 projection
1219 +        (uses analytical mapping from square to arbitrary convex quadrangle)
1220 +        """
1221 +        n = 5
1222 +        sCoo = DataArrayDouble(n,1)
1223 +        sCoo.iota(0.0);     sCoo /= float(n-1)
1224 +        m = MEDCouplingCMesh("target")
1225 +        m.setCoordsAt(0, sCoo)
1226 +        m.setCoordsAt(1, sCoo)
1227 +        tgt = m.buildUnstructured()
1228 +        coo = tgt.getCoords()
1229 +        orig = coo.deepCpy();   orig[:,0] = 10.0; orig[:,1] = 15.0
1230 +        pt_a = coo.deepCpy();   pt_a[:,0] = -0.3; pt_a[:,1] = 1.0
1231 +        pt_b = coo.deepCpy();   pt_b[:,0] = 2.0;  pt_b[:,1] = 3.0
1232 +        pt_c = coo.deepCpy();   pt_c[:,0] = 1.0;  pt_c[:,1] = 0.0
1233 +        # P = x*C+y*A + xy(B-A-C) + ORIGIN
1234 +        coo2 = coo[:,0]*pt_c + coo[:, 1]*pt_a + coo[:, 0]*coo[:, 1]*(pt_b - pt_a - pt_c) + orig
1235 +
1236 +        tgt.setCoords(coo2)
1237 +
1238 +        sCoo = DataArrayDouble([0.0,0.0,  -0.3,1.0,  2.0,3.0,  1.0,0.0],4,2)
1239 +        sCoo[:,0] += 10.0;  sCoo[:,1] += 15.0;
1240 +        sConn = DataArrayInt([0,1,2,3])
1241 +        s = MEDCoupling1SGTUMesh("source",NORM_QUAD4) ; s.setCoords(sCoo)
1242 +        s.setNodalConnectivity(sConn)
1243 +        #
1244 +        aRemapper=MEDCouplingRemapper()
1245 +        aRemapper.setPrecision(1e-12)
1246 +        aRemapper.setIntersectionType(MappedBarycentric)
1247 +        self.assertEqual(aRemapper.prepare(s,tgt,'P1P1'),1)
1248 +        srcField = MEDCouplingFieldDouble(ON_NODES, ONE_TIME)
1249 +        srcField.setNature(ConservativeVolumic)
1250 +        srcField.setMesh(s); srcField.setName("field")
1251 +        srcField.setArray(DataArrayDouble([1.0,2.0,3.0,4.0]))
1252 +        tgtF = aRemapper.transferField(srcField, 1e+300)
1253 +        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,
1254 +         2.125, 2.5, 2.875, 3.25, 2.0, 2.25, 2.5, 2.75, 3.0]
1255 +        val = tgtF.getArray().getValues()
1256 +        for i, ref_v in enumerate(ref):
1257 +            self.assertAlmostEqual(ref_v, val[i])
1258 +        pass
1259 +
1260 +    def testSwig2MappedBarycentricP1P13_1(self):
1261 +        """ Testing mapped barycentric P1P1 projection in 3D (uses orthogonal distances to 
1262 +        HEXA8 faces).
1263 +        Convention:
1264 +              0 ------ 3
1265 +             /|       /|
1266 +            / |      / |
1267 +           1 ------ 2  |
1268 +           |  |     |  |
1269 +           |  |     |  |
1270 +           |  4-----|- 7
1271 +           | /      | /
1272 +           5 ------ 6
1273 +        """
1274 +        n = 5
1275 +        sCoo = DataArrayDouble(n,1)
1276 +        sCoo.iota(0.0)
1277 +        sCoo /= float(n-1)
1278 +        m = MEDCouplingCMesh("target")
1279 +        m.setCoordsAt(0, sCoo)
1280 +        m.setCoordsAt(1, sCoo)
1281 +        m.setCoordsAt(2, sCoo)
1282 +        tgt = m.buildUnstructured()
1283 +        coo = tgt.getCoords()
1284 +        pt_0 = coo.deepCpy(); pt_0[:,0] = -0.3; pt_0[:,1] = 1.0; pt_0[:,2] = 1.0
1285 +        pt_1 = coo.deepCpy(); pt_1[:,0] = 0.0; pt_1[:,1] = 0.0; pt_1[:,2] = 1.0
1286 +        pt_2 = coo.deepCpy(); pt_2[:,0] = 1.0; pt_2[:,1] = 0.0; pt_2[:,2] = 1.0
1287 +        pt_3 = coo.deepCpy(); pt_3[:,0] = 2.0; pt_3[:,1] = 3.0; pt_3[:,2] = 1.0
1288 +        
1289 +        pt_4 = coo.deepCpy(); pt_4[:,0] = -0.3; pt_4[:,1] = 1.0; pt_4[:,2] = 0.0
1290 +        orig = coo.deepCpy(); orig[:,0] = 10.0; orig[:,1] = 15.0; orig[:,2] = 20.0
1291 +        pt_6 = coo.deepCpy(); pt_6[:,0] = 1.0; pt_6[:,1] = 0.0; pt_6[:,2] = 0.0 
1292 +        pt_7 = coo.deepCpy(); pt_7[:,0] = 2.0; pt_7[:,1] = 3.0; pt_7[:,2] = 0.0
1293 +        # 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)
1294 +        x,y,z = coo[:,0],coo[:,1],coo[:,2]
1295 +        coo2 = x*pt_6 + y*pt_4 + z*pt_1 + \
1296 +               x*y*(pt_7 - pt_6 - pt_4) + x*z*(pt_2 - pt_1 - pt_6) + y*z*(pt_0 - pt_4 - pt_1) + \
1297 +               x*y*z*(pt_3 - pt_7 - pt_2 - pt_0 + pt_6 + pt_1 + pt_4) + orig
1298 +        tgt.setCoords(coo2)
1299 +
1300 +        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,
1301 +                                -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)
1302 +        sCoo[:, 0] += 10.0; sCoo[:, 1] += 15.0; sCoo[:, 2] += 20.0;
1303 +        sConn = DataArrayInt([0,1,2,3,4, 5,6,7])
1304 +        s = MEDCoupling1SGTUMesh("source",NORM_HEXA8) ; s.setCoords(sCoo)
1305 +        s.setNodalConnectivity(sConn)
1306 +        #
1307 +        aRemapper=MEDCouplingRemapper()
1308 +        aRemapper.setPrecision(1e-12)
1309 +        aRemapper.setIntersectionType(MappedBarycentric)
1310 +        self.assertEqual(aRemapper.prepare(s,tgt,'P1P1'),1)
1311 +        srcField = MEDCouplingFieldDouble(ON_NODES, ONE_TIME)
1312 +        srcField.setNature(ConservativeVolumic)
1313 +        srcField.setMesh(s); srcField.setName("field")
1314 +        srcField.setArray(DataArrayDouble([1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0]))
1315 +        tgtF = aRemapper.transferField(srcField, 1e+300)
1316 +#        print tgtF.getArray().getValues()
1317 +        ref = [6.0, 6.251802698104413, 6.502397834044702, 6.7517940736426665, 7.0, 5.740554726834594,
1318 +               6.1761835575796935, 6.6052985689637564, 7.009392769824465, 7.383488834310164,
1319 +               5.487562931129931, 6.140664596972973, 6.720290674177548, 7.220534970454015, 7.651092836860121,
1320 +               5.2407867837524345, 6.125759809889516, 6.82853486793175, 7.390880823876876, 7.848445254819061,
1321 +               5.0, 6.12211344611157, 6.925740671133115, 7.529623182840827, 8.0, 5.0, 5.251802698104413,
1322 +               5.502397834044702, 5.751794073642667, 6.0, 4.740554726834594, 5.1761835575796935,
1323 +               5.6052985689637564, 6.009392769824465, 6.383488834310163, 4.487562931129931, 5.140664596972973,
1324 +                5.720290674177548, 6.220534970454015, 6.651092836860121, 4.2407867837524345, 5.125759809889516,
1325 +                5.828534867931749, 6.390880823876876, 6.848445254819061, 4.0, 5.122113446111569, 5.925740671133115,
1326 +                6.529623182840827, 7.0, 4.0, 4.251802698104413, 4.502397834044702, 4.751794073642667, 5.0, 3.740554726834594,
1327 +                4.176183557579693, 4.6052985689637564, 5.009392769824464, 5.383488834310164, 3.487562931129931,
1328 +                4.140664596972973, 4.720290674177548, 5.220534970454015, 5.651092836860121, 3.240786783752434, 4.125759809889516, 4.82853486793175,
1329 +                5.390880823876876, 5.848445254819061, 3.0, 4.122113446111569, 4.925740671133115, 5.529623182840827, 6.0, 3.0,
1330 +                3.2518026981044135, 3.502397834044702, 3.7517940736426674, 4.0, 2.7405547268345933, 3.176183557579693,
1331 +                3.6052985689637564, 4.009392769824465, 4.383488834310164, 2.487562931129931, 3.140664596972973, 3.7202906741775474, 4.220534970454015, 4.65109283686012, 2.2407867837524345, 3.1257598098895154, 3.828534867931749,
1332 +                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,
1333 +                3.0093927698244642, 3.3834888343101635, 1.4875629311299305, 2.1406645969729734, 2.720290674177548,
1334 +                3.2205349704540143, 3.6510928368601205, 1.2407867837524345, 2.125759809889516, 2.8285348679317495, 3.390880823876876, 3.848445254819061, 1.0, 2.1221134461115687, 2.9257406711331146, 3.529623182840827, 4.0]
1335 +
1336 +        val = tgtF.getArray().getValues()
1337 +        for i, ref_v in enumerate(ref):
1338 +            self.assertAlmostEqual(ref_v, val[i])
1339 +        pass
1340 +
1341      @unittest.skipUnless(MEDCouplingHasNumPyBindings() and MEDCouplingHasSciPyBindings(),"requires numpy AND scipy")
1342      def testGetCrudeCSRMatrix1(self):
1343          """ testing CSR matrix output using numpy/scipy.
1344 @@ -645,7 +769,7 @@ class MEDCouplingBasicsTest(unittest.Tes
1345          self.assertAlmostEqual(m_1[2,3],0.3,12)
1346          self.assertEqual(m_1.getnnz(),7)
1347          pass
1348 -    
1349 +
1350      @unittest.skipUnless(MEDCouplingHasNumPyBindings() and MEDCouplingHasSciPyBindings(),"requires numpy AND scipy")
1351      def testP0P1Bary_1(self):
1352          a=MEDCouplingUMesh("a",2)
1353 @@ -712,7 +836,7 @@ class MEDCouplingBasicsTest(unittest.Tes
1354          #
1355          rem=MEDCouplingRemapper()
1356          rem.setMaxDistance3DSurfIntersect(1e-12)
1357 -        rem.setMinDotBtwPlane3DSurfIntersect(0.99)# this line is important it is to tell to remapper to select only cells with very close orientation 
1358 +        rem.setMinDotBtwPlane3DSurfIntersect(0.99)# this line is important it is to tell to remapper to select only cells with very close orientation
1359          rem.prepare(skinAndNonConformCells,skinAndNonConformCells,"P0P0")
1360          mat=rem.getCrudeCSRMatrix()
1361          indptr=DataArrayInt(mat.indptr)
1362 @@ -785,7 +909,7 @@ class MEDCouplingBasicsTest(unittest.Tes
1363          #
1364          self.assertTrue(coarse.isEqual(trgField.getArray(),1e-12))
1365          pass
1366 -    
1367 +
1368      @unittest.skipUnless(MEDCouplingHasNumPyBindings() and MEDCouplingHasSciPyBindings(),"requires numpy AND scipy")
1369      def test1DPointLocator1(self):
1370          """This test focuses on PointLocator for P1P1 in 1D and 2DCurve."""
1371 @@ -853,7 +977,7 @@ class MEDCouplingBasicsTest(unittest.Tes
1372          diff=abs(m-mExp0)
1373          self.assertAlmostEqual(diff.sum(),0.,14)
1374          pass
1375 -    
1376 +
1377      def test3D2Dand2D3DPointLocator1(self):
1378          """ Non regression test solving SIGSEGV when using 3D<->3Dsurf pointlocator."""
1379          arrX=DataArrayDouble([0,1,2])
1380 @@ -894,7 +1018,37 @@ class MEDCouplingBasicsTest(unittest.Tes
1381          rem.prepare(mt,ms,"P0P0")
1382          self.assertEqual(rem.getCrudeMatrix(),[{0:1.},{1:1.}])
1383          pass
1384 -    
1385 +
1386 +    def test3D1DPointLocatorBBoxAdjusted(self):
1387 +        """ In case a 1D segment lies exactly on the interface between two 2D (or 3D) faces, the default
1388 +        bounding box logic will make it non-intersecting with the surrounding 2D (or 3D) faces.
1389 +        Test bounding box adjustment allowing to widen the BB to capture this.
1390 +        """
1391 +        m = MEDCouplingCMesh("source")
1392 +        di, dd = DataArrayInt, DataArrayDouble
1393 +        m.setCoordsAt(0, dd([0.0, 1.0, 2.0]))
1394 +        m.setCoordsAt(1, dd([0.0, 1.0]))
1395 +        m.setCoordsAt(2, dd([0.0, 1.0]))
1396 +        m3d = m.buildUnstructured()
1397 +        m1d = MEDCouplingUMesh("target", 1)
1398 +        m1d.setCoords(dd([1.0,0.5,0.2  ,  1.0,0.5,0.8], 2,3))
1399 +        m1d.setConnectivity(di([NORM_SEG2, 0, 1]), di([0,3]))
1400 +
1401 +        rem = MEDCouplingRemapper()
1402 +        rem.setPrecision(1e-12)
1403 +        rem.setIntersectionType(PointLocator)
1404 +        rem.prepare(m3d, m1d,"P0P1")
1405 +        self.assertEqual(rem.getCrudeMatrix(), [{0: 1.0, 1: 1.0}, {0: 1.0, 1: 1.0}])
1406 +
1407 +        rem = MEDCouplingRemapper()
1408 +        rem.setPrecision(1e-12)
1409 +        rem.setIntersectionType(PointLocator)
1410 +        rem.setBoundingBoxAdjustment(0.0)
1411 +        rem.setBoundingBoxAdjustmentAbs(0.0)
1412 +        rem.prepare(m3d, m1d,"P0P1")
1413 +        self.assertEqual(rem.getCrudeMatrix(), [{}, {}])
1414 +        pass
1415 +
1416      def build2DSourceMesh_1(self):
1417          sourceCoords=[-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7]
1418          sourceConn=[0,3,1,0,2,3]
1419 @@ -907,7 +1061,7 @@ class MEDCouplingBasicsTest(unittest.Tes
1420          myCoords.setValues(sourceCoords,4,2);
1421          sourceMesh.setCoords(myCoords);
1422          return sourceMesh;
1423 -    
1424 +
1425      def build2DTargetMesh_1(self):
1426          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 ]
1427          targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4]
1428 @@ -940,9 +1094,10 @@ class MEDCouplingBasicsTest(unittest.Tes
1429          targetMesh.setCoords(myCoords);
1430          return targetMesh;
1431          pass
1432 -    
1433 +
1434      def setUp(self):
1435          pass
1436      pass
1437  
1438 -unittest.main()
1439 +if __name__ == "__main__":
1440 +  unittest.main()
1441 diff -rupN -x git MEDCOUPLING_orig/src/MEDLoader/MEDFileField.cxx MEDCOUPLING_new/src/MEDLoader/MEDFileField.cxx
1442 --- MEDCOUPLING_orig/src/MEDLoader/MEDFileField.cxx     2017-01-23 09:49:37.525001480 +0100
1443 +++ MEDCOUPLING_new/src/MEDLoader/MEDFileField.cxx      2017-01-23 09:50:14.672001480 +0100
1444 @@ -7357,9 +7357,8 @@ void MEDFileAnyTypeFieldMultiTSWithoutSD
1445      {
1446        std::vector< std::pair<int,int> > ts;
1447        med_int numdt=0,numo=0;
1448 -      med_int meshIt=0,meshOrder=0;
1449        med_float dt=0.0;
1450 -      MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder));
1451 +      MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
1452        switch(fieldTyp)
1453        {
1454          case MED_FLOAT64: