X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FINTERP_KERNEL%2FTetraAffineTransform.cxx;h=a06e5f16facdfb7c9346ce6a03273de2a20935ef;hb=c241ded3d1997e10ee24c08f294c98c14eca956a;hp=87690657c8026de81c94e815d04ac71d2eb054d4;hpb=f1a947b32a36d8dc8e3079b25305bb50e8cb59a0;p=tools%2Fmedcoupling.git diff --git a/src/INTERP_KERNEL/TetraAffineTransform.cxx b/src/INTERP_KERNEL/TetraAffineTransform.cxx index 87690657c..a06e5f16f 100644 --- a/src/INTERP_KERNEL/TetraAffineTransform.cxx +++ b/src/INTERP_KERNEL/TetraAffineTransform.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -38,13 +38,12 @@ namespace INTERP_KERNEL * with corners specified in pts. If the tetrahedron is degenerate or almost degenerate, * construction succeeds, but the determinant of the transform is set to 0. * - * @param pts a 4x3 matrix containing 4 points (pts[0], ..., pts[3]) of 3 coordinates each + * @param pts a 4x3 matrix containing 4 points (P0X,P0Y,P0Z,P1X,P1Y,P1Z,...) of 3 coordinates each */ - TetraAffineTransform::TetraAffineTransform(const double** pts) + TetraAffineTransform::TetraAffineTransform(const double *pts) { LOG(2,"Creating transform from tetraeder : "); - LOG(2, vToStr(pts[0]) << ", " << vToStr(pts[1]) << ", " << vToStr(pts[2]) << ", " << vToStr(pts[3])); // three last points -> linear transform for(int i = 0; i < 3 ; ++i) @@ -52,21 +51,25 @@ namespace INTERP_KERNEL for(int j = 0 ; j < 3 ; ++j) { // NB we insert columns, not rows - _linear_transform[3*j + i] = (pts[i+1])[j] - (pts[0])[j]; + _linear_transform[3*j + i] = pts[(i+1)*3+j] - pts[j]; } } // remember _linear_transform for the reverse transformation memcpy( _back_linear_transform, _linear_transform, 9*sizeof(double)); - memcpy( _back_translation, pts[0], 3*sizeof(double)); + memcpy( _back_translation, pts, 3*sizeof(double)); calculateDeterminant(); LOG(3, "determinant before inverse = " << _determinant); + + double ni(1./INTERP_KERNEL::normInf(_linear_transform)); + ni = ni*ni*ni; // check that tetra is non-planar -> determinant is not zero + // AGY : the check to 0. must integrate the infinite norm of _linear_transform matrix. // otherwise set _determinant to zero to signal caller that transformation did not work - if(epsilonEqual(_determinant, 0.0)) + if(epsilonEqual(ni*_determinant, 0.0)) { _determinant = 0.0; return; @@ -81,7 +84,7 @@ namespace INTERP_KERNEL // and O is the position vector of the point that is mapped onto the origin for(int i = 0 ; i < 3 ; ++i) { - _translation[i] = -(_linear_transform[3*i]*(pts[0])[0] + _linear_transform[3*i+1]*(pts[0])[1] + _linear_transform[3*i+2]*(pts[0])[2]) ; + _translation[i] = -(_linear_transform[3*i]*pts[0] + _linear_transform[3*i+1]*pts[1] + _linear_transform[3*i+2]*pts[2]) ; } // precalculate determinant (again after inversion of transform) @@ -95,7 +98,7 @@ namespace INTERP_KERNEL for(int i = 0; i < 4 ; ++i) { double v[3]; - apply(v, pts[i]); + apply(v, pts+3*i); LOG(4, vToStr(v)) for(int j = 0; j < 3; ++j) {