Documentation


SFVec3fCellConstrained.h

Go to the documentation of this file.
00001 
00002 #ifndef _CELL_CONSTRAINED_VERTEX_H
00003 #define _CELL_CONSTRAINED_VERTEX_H
00004 
00005 #include <X3DTK/private/SFVec3f.h>
00006 
00007 #include "HermiteFunction.h"
00008 #include "octree_instanciation.h"
00009 
00010 #include <map>
00011 
00012 
00013 namespace animal
00014 {
00015 namespace octree
00016 {
00017 
00018 // Return alpha for points 0,2,4,6 and 1-alpha for the other one
00019 #define LINEARFACTORALPHA(VID,alpha) (((VID%2)==0)?alpha:(1.0-alpha))
00020 #define LINEARFACTORBETA(VID,beta) (((VID%4)<=1)?beta:(1.0-beta))
00021 #define LINEARFACTORGAMMA(VID,gamma) ((VID<=3)?gamma:(1.0-gamma))
00022 
00023 
00024 typedef int PositionMethod;
00025 enum { LINEAR, GLOBAL_LINEAR, LOCAL_SKINNING };
00026 
00027 class SFVec3fCellConstrained
00028 {
00029 public:
00030 
00031     SFVec3fCellConstrained( X3DTK::SFVec3f *q, Cell* cell, int vertexID, X3DTK::SFVec3f normal );
00032     SFVec3fCellConstrained( X3DTK::SFVec3f *q, Cell* cell, Vec3d params, int vertexID, Vec3d normal );
00033     
00034     ~SFVec3fCellConstrained( );
00035 
00036         
00037     
00038     FloatingPointType getAlpha() const { return _alpha; }
00039     FloatingPointType getBeta() const { return _beta; }
00040     FloatingPointType getGamma() const { return _gamma; }
00041     Vec3d getLocalParams() const { return Vec3d(_alpha,_beta,_gamma); }
00042     
00047     void setParams( const Vec3d params );
00048     
00049     
00050     
00051     /*
00052     * update the SFVec3f coordinates by recalcuting it's position with _alpha, .. and the cell
00053     */
00054     void updatePosition( PositionMethod method );
00055     
00059     Vec3d computePosition( PositionMethod method ) const;
00060     
00061     std::vector<Vec3d> computeDerivative( ) const;
00062     
00063     
00067     inline X3DTK::SFVec3f * getSFVec3f() const { return _vec; }
00068     
00072     inline Cell * getCell( ) const {return _cell;}
00073     
00074     
00081     Vec3d getParameters( unsigned short vId ) const;
00082     
00083     
00084     
00088     void clearRelativeWeights() { _relativeWeights.clear(); }
00094     void setRelativeWeight( ConstrainedVertex*cv, FloatingPointType w ) { _relativeWeights[cv] = w; }
00101     const FloatingPointType getRelativeWeight( ConstrainedVertex*cv ) const { Require(_relativeWeights.find(cv) != _relativeWeights.end()); return _relativeWeights.find(cv)->second; }
00102     
00103     
00104     void clearRelativePositions() { _relativePositions.clear(); }
00105     void setRelativePosition( ConstrainedVertex*cv, Vec3d Q ) { _relativePositions[cv] = Q; }
00106 //  const Vec3d getRelativePosition( ConstrainedVertex*cv ) const { Require(_relativePositions.find(cv) != _relativePositions.end()); return _relativePositions[cv]; }
00107     const Vec3d getRelativePosition( ConstrainedVertex*cv ) const { Require(_relativePositions.find(cv) != _relativePositions.end()); return _relativePositions.find(cv)->second; }
00108     
00109     
00113     void updateSkinningInformations( CellInfluenceData & influence );
00114     
00115     
00119      static FloatingPointType computeWeight( Vec3d w, PositionMethod method );
00120 
00121      
00125     static void globalLinearUpdatePositions( Cell *cStart );
00126 
00127     
00128     
00129 
00137     static Vec3d translateParameters( Cell *cStart, Vec3d params, Cell *cDest, unsigned short vId );    
00138             
00139     
00140     Vec3d getInitNormal() const { return _normal; };
00141     Vec3d getInitNormalParameters( unsigned short vId ) const;
00142     void clearInitNormalRelativeWeights() { _initNormalRelativeWeights.clear(); }
00143     void setInitNormalRelativeWeight( ConstrainedVertex*cv, FloatingPointType w ) { _initNormalRelativeWeights[cv] = w; }   
00144     const FloatingPointType getInitNormalRelativeWeight( ConstrainedVertex*cv ) const { Require(_initNormalRelativeWeights.find(cv) != _initNormalRelativeWeights.end()); return _initNormalRelativeWeights.find(cv)->second; }
00145 
00146     
00147     
00148     int getVertexID() const { return _vertexID; };
00149     void setVertexID( int id ) { _vertexID = id; };
00150     
00151 private:
00152     FloatingPointType _alpha, _beta, _gamma;
00153     X3DTK::SFVec3f *_vec;
00154     Cell *_cell;
00155 
00156         
00157     std::map<ConstrainedVertex*,Vec3d> _relativePositions;
00158     std::map<ConstrainedVertex*,FloatingPointType> _relativeWeights;
00159 
00160     
00161     // Normal stuff
00162     Vec3d _normal;      
00163     FloatingPointType _alphaNormal, _betaNormal, _gammaNormal;
00164     std::map<ConstrainedVertex*,FloatingPointType> _initNormalRelativeWeights;
00165     
00166     
00167     int _vertexID;
00168     
00169     
00174     void computeParameters();
00175     
00176 };
00177 
00178 }
00179 }
00180 
00181 
00182 
00183 #endif

Generated on Thu Dec 23 13:52:27 2004 by doxygen 1.3.6