Salome HOME
Update copyrights 2014.
[modules/med.git] / src / INTERP_KERNEL / TetraAffineTransform.hxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef __TETRA_AFFINE_TRANSFORM_HXX__
21 #define __TETRA_AFFINE_TRANSFORM_HXX__
22
23 #include "INTERPKERNELDefines.hxx"
24
25 #undef INVERSION_SELF_CHECK // debugging : check that calculated inverse is correct
26
27 namespace INTERP_KERNEL
28 {
29   /**
30    * \brief Class representing an affine transformation x -> Ax + b that transforms a given tetrahedron
31    * into the unit tetrahedron.
32    *
33    */
34   class INTERPKERNEL_EXPORT TetraAffineTransform
35   {
36
37   public:
38     TetraAffineTransform(const double *pts);
39
40     void apply(double* destPt, const double* srcPt) const;
41
42     void reverseApply(double* destPt, const double* srcPt) const;
43
44     double determinant() const;
45
46     void dump() const;
47
48   private:
49
50     void invertLinearTransform();
51
52     void calculateDeterminant();
53
54     void factorizeLU(double* lu, int* idx) const;
55       
56     void forwardSubstitution(double* x, const double* lu, const double* b, const int* idx) const;
57
58     void backwardSubstitution(double* x, const double* lu, const double* b, const int* idx) const;
59
60     // The affine transformation Ax + b is represented with _linear_transformation containing the elements of
61     // A in row-first ordering and _translation containing the elements of b
62
63     /// 3x3 matrix A in affine transform x -> Ax + b
64     double _linear_transform[9];
65
66     /// 3x1 vector b in affine transform x -> Ax + b
67     double _translation[3];
68
69     /// The determinant of the matrix A is calculated at the construction of the object and cached.
70     double _determinant;
71
72     /// 3x3 matrix AT is transposed A matrix used for y -> ATy - c transformation
73     double _back_linear_transform[9];
74
75     /// 3x1 vector c in affine transform y -> ATy - c
76     double _back_translation[3];
77
78   };
79 }
80
81 #endif