X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FINTERP_KERNEL%2FTetraAffineTransform.cxx;h=a71ec134233c63107e60e6ba185ec267f665822c;hb=1a9af3cb21941312cdda3f0466677b61beba7ade;hp=21a42d0df444f276e67b020c4e7c3c77b9f8972d;hpb=48782c06022ca2caa36f849cb5a29ea4fe2aaa83;p=tools%2Fmedcoupling.git diff --git a/src/INTERP_KERNEL/TetraAffineTransform.cxx b/src/INTERP_KERNEL/TetraAffineTransform.cxx index 21a42d0df..a71ec1342 100644 --- a/src/INTERP_KERNEL/TetraAffineTransform.cxx +++ b/src/INTERP_KERNEL/TetraAffineTransform.cxx @@ -1,25 +1,27 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// 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. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + #include "TetraAffineTransform.hxx" #include "VectorUtils.hxx" #include +#include #include #include "Log.hxx" @@ -36,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) @@ -50,13 +51,13 @@ 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(); @@ -79,7 +80,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) @@ -93,7 +94,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) { @@ -209,17 +210,15 @@ namespace INTERP_KERNEL */ void TetraAffineTransform::dump() const { - using namespace std; - std::cout << "A = " << std::endl << "["; for(int i = 0; i < 3; ++i) { std::cout << _linear_transform[3*i] << ", " << _linear_transform[3*i + 1] << ", " << _linear_transform[3*i + 2]; - if(i != 2 ) std::cout << endl; + if(i != 2 ) std::cout << std::endl; } - std::cout << "]" << endl; + std::cout << "]" << std::endl; - std::cout << "b = " << "[" << _translation[0] << ", " << _translation[1] << ", " << _translation[2] << "]" << endl; + std::cout << "b = " << "[" << _translation[0] << ", " << _translation[1] << ", " << _translation[2] << "]" << std::endl; } ///////////////////////////////////////////////////////////////////////////////////////// @@ -253,9 +252,9 @@ namespace INTERP_KERNEL // form standard base vector i const double b[3] = { - int(i == 0), - int(i == 1), - int(i == 2) + double ( int(i == 0) ), + double ( int(i == 1) ), + double ( int(i == 2) ), }; LOG(6, "b = [" << b[0] << ", " << b[1] << ", " << b[2] << "]");