Blender V2.61 - r43446

LOD_NdQuadric.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00033 #ifndef NAN_INCLUDED_LOD_NdQuardic_h
00034 #define NAN_INCLUDED_LOD_NdQuardic_h
00035 
00036 // An N dimensional quadric form.
00038 
00039 #include "TNT/cmat.h"
00040 #include "TNT/vec.h"
00041 #include "MT_Matrix3x3.h"
00042 #include "LOD_Quadric.h"
00043 
00044 
00045 class LOD_NdQuadric {
00046 
00047 private :
00048 
00049     LOD_Quadric m_q;
00050 
00051     // For space efficiency we should not use
00052     // TNT matrices to hold variables in. Use
00053     // fixed sized arrays based on template size
00054     // and load them into the quadric only when
00055     // needed for computation.
00056 
00057     TNT::Vector<MT_Scalar> m_prop_grad1;
00058     TNT::Vector<MT_Scalar> m_prop_grad2;
00059     TNT::Vector<MT_Scalar> m_prop_grad3;
00060     TNT::Vector<MT_Scalar> m_bbottom;
00061 
00062     // Not essential but makes it easier to debug if keep an
00063     // explicit version of the diagonal.
00064 #if 1
00065     TNT::Vector<MT_Scalar> m_diag;
00066 #else
00067     MT_Scalar m_diag;
00068 #endif
00069 public :
00070 
00071     // The general idea of these 2 constructors
00072     // is that first you build a quadric Qg from the
00073     // geometric properties of a vertex v. Then for
00074     // each of the properties i construct a property
00075     // quadric Qpi. Then sum them altogether to get
00076     // the final combined geomeetry and property quadric
00077     // Qv = Qg + Qpi
00078 
00079     // Initialize a quadric with a default geometric plane
00080 
00081     LOD_NdQuadric(
00082         const MT_Vector3 & vec,
00083         const MT_Scalar & offset
00084     ); 
00085 
00086     // Initialize a quadric from a linear functional describing
00087     // the property gradient.pos is the position where this
00088     // functional is placed in the array.
00089 
00090     LOD_NdQuadric(
00091         const MT_Vector3 & vec,
00092         const MT_Scalar & offset,
00093         int pos
00094     );
00095 
00096     // Make sure the internal vectors are of the correct size.
00097 
00098     LOD_NdQuadric(
00099     );
00100 
00101     // This class also has the default copy constructors
00102     // available.
00103 
00104     ~LOD_NdQuadric(
00105     ){
00106         //nothing to do
00107     };
00108 
00109         void
00110     Tensor(
00111         TNT::Matrix<MT_Scalar> &        
00112     ) const; 
00113 
00114         void
00115     Vector(
00116         TNT::Vector<MT_Scalar> &
00117     ) const; 
00118 
00119         void 
00120     Clear(
00121         MT_Scalar val=0.0
00122     );
00123 
00124         LOD_NdQuadric & 
00125     operator=(
00126         const LOD_NdQuadric& Q
00127     ); 
00128         
00129         LOD_NdQuadric& 
00130     operator+=(
00131         const LOD_NdQuadric& Q
00132     );
00133 
00134     // You can increase or decrease the relative importance
00135     // of a quadric prior the summation by multiplying it
00136     // with a scalar value s.
00137 
00138         LOD_NdQuadric& 
00139     operator*=(
00140         const MT_Scalar & s
00141     ); 
00142 
00143         MT_Scalar 
00144     Evaluate(
00145         const TNT::Vector<MT_Scalar> & vec
00146     ) const;
00147  
00148         bool 
00149     Optimize(
00150         TNT::Vector<MT_Scalar> & vec
00151     ) const ;
00152 
00153     
00154 };
00155 
00156 #endif
00157