Documentation


GeoLink.h

Go to the documentation of this file.
00001 
00002 #ifndef _GEOLINK_H
00003 #define _GEOLINK_H
00004 
00005 #include <vector>
00006 
00007 class GeoLink;
00008 
00009 
00010 #include "ConstrainedVertex.h"
00011 
00012 
00013 namespace animal
00014 {
00015 namespace octree 
00016 {
00017 
00018 /*
00019  * NB:
00020  * A free vertex can see it's parameters changed
00021  * A vertex is constrained by those types of link :
00022  *      - soft Link : the vertex is free to be changed, but for MR purposes,
00023  *          it's defined by 8 parents and 3 associated parameters. There are 4 types of parents' strains :
00024  *              * //0 parents, it's really free (only used for the 8 root's vertices)
00025  *              * 2 parents, when we move one of the 6 other vertices, we should FIRST updateParameters before
00026  *                  accessing the vertex position
00027  *              * 4 parents
00028  *              * 8 parents : so any change in a parent should NEVER updateParameters() !
00029  *      - hard link : the vertex is constrained only by it's geoparents, it will allways
00030  *          be defined by it's geoparents. There are only 2 cases :
00031  *              * 2 parents : the point is on a line, //use only  _alpha parameter
00032  *              * 4 parents : the point is on the "plane", //use only _alpha and _beta parameters
00033  *
00034  * The link also ensure that we are registred in our parents' children list
00035  * The destructor also unregister the vertex
00036  */
00037 class GeoLink
00038 {
00039 
00040 public:
00041     
00042     /*
00043      * Give us the 8 pointers to our parents
00044      * Plus the number of geo linked parents and their corresponding IDs in the "allParents" array
00045      * Also give the fact that it's a hard link (for example, that the vertex IS NOT FREE)
00046      * or soft link (free, but from multiresolution edition, it can be moved)
00047      *
00048      * If the geolink is a hard link, then the parameters should never be updated !
00049      *
00050      * The parameters are updated
00051      */
00052     GeoLink( vector< ConstrainedVertex* > allParents, vector<unsigned short> geoParentsIds,
00053     bool isSoftLink, ConstrainedVertex *vertex );
00054     
00055     ~GeoLink();
00056     
00057     /*
00058      * Return true IFF vertex is in geoParents
00059      * For example, your should use this to see if we need to call updateParameters() or not
00060      * It the moved "vertex" is geolink parent then you should NOT update parameters
00061      * In the other case, you MUST update parameters
00062      * Require : isParent(vertex)
00063      */
00064     bool isGeoLinkParent( ConstrainedVertex *vertex );
00065     
00066     /*
00067      * Get the Vec3d position of the current vertex, by computing with the parameters
00068      */
00069     Vec3d getPosition()  const;
00070 
00071     
00072     void addVector( Vec3d v );
00073     unsigned short getNGeoParents() const;
00074     unsigned short getGeoParentId( unsigned short id )
00075     {
00076         Require( id < getNGeoParents() );
00077         return _geoParentsIds[id];
00078     }
00079     
00083     ConstrainedVertex * getGeoParent( unsigned short i )
00084     {
00085         Require( isGeoLinkParent(_parents[i]) );
00086         return _parents[i];
00087     };
00088 
00089     /*
00090      * This is used to change the cell we're in, for example when simplification occurs
00091      * We must change our geoparents and our geoparents ids so that we get the same vertices
00092      * which constrain the vertex
00093      */
00094     void changeCell( Cell *cell );
00095     
00096     
00097     /*
00098      * Update the parameters by recomputing it's barycentrical coordinates (if needed)
00099      * Require : isFree()
00100      */
00101      void updateParameters();
00102      
00103      /*
00104       * Return true if it's a soft link, and false if it's a hard link
00105         */
00106      bool isFree()  const;
00107     
00108      
00109      /*
00110       * Free it : make it a soft link and no more a hard link
00111         * Require : !isFree()
00112         * Ensure : isFree()
00113         */
00114         void freeIt();
00115         
00116         /*
00117          * Make it a hard link : project the point on the line
00118          * Require : isFree()
00119          * Require : vertices are parents
00120          */
00121         void hardLinkIt( ConstrainedVertex *v1, ConstrainedVertex *v2  );
00122         
00123         /*
00124          * Make it a hard link : project the point on the plane
00125          * Require : isFree()
00126          * Require : vertices are parents
00127          */
00128         void hardLinkIt( ConstrainedVertex *v1, ConstrainedVertex *v2, ConstrainedVertex *v3, ConstrainedVertex *v4  );
00129 
00130         void softLinkIt( ConstrainedVertex *v1, ConstrainedVertex *v2 );
00131         void softLinkIt( ConstrainedVertex *v1, ConstrainedVertex *v2, ConstrainedVertex *v3, ConstrainedVertex *v4 ); 
00132         void softLinkIt( ConstrainedVertex *v1, ConstrainedVertex *v2, ConstrainedVertex *v3, ConstrainedVertex *v4, ConstrainedVertex *v5, ConstrainedVertex *v6, ConstrainedVertex *v7, ConstrainedVertex *v8  );
00133         
00134         
00135         void print();
00136 
00137     /*
00138      * Return true IFF vertex is in parents list
00139      * Used only for debug
00140      */
00141      bool isParent( const ConstrainedVertex *vertex );
00142             
00143 private:
00144 
00145      
00146      vector<ConstrainedVertex*> _parents;
00147      vector<unsigned short> _geoParentsIds;
00148      bool _isSoftLink;
00149      
00150      ConstrainedVertex * _vertex;
00151      
00152      /*
00153       * The parameters associated to each of the 8 parents
00154         */
00155      FloatingPointType _alpha, _beta, _gamma;
00156      FloatingPointType _alpha2, _beta2, _gamma2;
00157 
00158 };
00159 
00160 }
00161 }
00162 
00163 #endif
00164 
00165 

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