BVHJoint.h

Go to the documentation of this file.
00001 /******************************************************************************
00002 *       SOFA, Simulation Open-Framework Architecture, version 1.0 beta 3      *
00003 *                (c) 2006-2008 MGH, INRIA, USTL, UJF, CNRS                    *
00004 *                                                                             *
00005 * This library is free software; you can redistribute it and/or modify it     *
00006 * under the terms of the GNU Lesser General Public License as published by    *
00007 * the Free Software Foundation; either version 2.1 of the License, or (at     *
00008 * your option) any later version.                                             *
00009 *                                                                             *
00010 * This library is distributed in the hope that it will be useful, but WITHOUT *
00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       *
00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
00013 * for more details.                                                           *
00014 *                                                                             *
00015 * You should have received a copy of the GNU Lesser General Public License    *
00016 * along with this library; if not, write to the Free Software Foundation,     *
00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.          *
00018 *******************************************************************************
00019 *                              SOFA :: Framework                              *
00020 *                                                                             *
00021 * Authors: M. Adam, J. Allard, B. Andre, P-J. Bensoussan, S. Cotin, C. Duriez,*
00022 * H. Delingette, F. Falipou, F. Faure, S. Fonteneau, L. Heigeas, C. Mendoza,  *
00023 * M. Nesme, P. Neumann, J-P. de la Plata Alcade, F. Poyer and F. Roy          *
00024 *                                                                             *
00025 * Contact information: contact@sofa-framework.org                             *
00026 ******************************************************************************/
00027 #ifndef SOFA_HELPER_IO_BVH_BVHJOINT_H
00028 #define SOFA_HELPER_IO_BVH_BVHJOINT_H
00029 
00030 #include <sofa/helper/io/bvh/BVHChannels.h>
00031 #include <sofa/helper/io/bvh/BVHOffset.h>
00032 #include <sofa/helper/io/bvh/BVHMotion.h>
00033 #include <cstdio>
00034 #include <string.h>
00035 
00036 namespace sofa
00037 {
00038 
00039 namespace helper
00040 {
00041 
00042 namespace io
00043 {
00044 
00045 namespace bvh
00046 {
00047 
00055 class BVHJoint
00056 {
00057 public:
00058     BVHJoint(const char *_name, bool _endSite=false, BVHJoint *_parent=NULL);
00059     virtual ~BVHJoint();
00060     
00061     void addChild(BVHJoint *j){children.push_back(j);}
00062     std::vector<BVHJoint *> &getChildren(void){return children;}
00063 
00064     void setOffset(BVHOffset *o){offset = o;}
00065     BVHOffset *setOffset(void){return offset;}
00066 
00067     void setChannels(BVHChannels *c){channels = c;}
00068     BVHChannels *getChannels(void){return channels;}
00069 
00070     bool isEndSite(void){return endSite;}
00071     void setEndSite(bool isEndSite){endSite = isEndSite;}
00072 
00073     void setMotion(BVHMotion *m){motion = m;}
00074     BVHMotion *getMotion(void)
00075     {   
00076         if (motion == NULL)
00077             motion = new BVHMotion();
00078         return motion;
00079     }
00080     void initMotion(double fTime, unsigned int fCount);
00081 
00082     // Debug Text display
00083     void debug(int tab=0);
00084 
00085     void display(int);
00086     void displayInGlobalFrame(void);
00087 
00088     // .dat File creation for each frame
00089     // Christian Duriez PHD Articulated Rigids File Format
00090     void dump(char *fName, char *rootJointName=NULL);
00091     void dumpPosition(FILE *f, char *s=NULL);
00092     void dumpSegment(FILE *f, char *s=NULL);
00093     void dumpRotation(FILE *f, char *s=NULL);
00094     void dumpRotationLimit(FILE *f, char *s=NULL);
00095     void dumpRotationStiffness(FILE *f, char *s=NULL);
00096     void dumpPosition(FILE *f, int beginIndex);
00097     void dumpSegment(FILE *f, int &cpt, int beginIndex);
00098     void dumpRotation(FILE *f, int &cpt, int beginIndex);
00099     void dumpRotationLimit(FILE *f, int &cpt);
00100     void dumpRotationStiffness(FILE *f, int &cpt);
00101 
00102     int getNumJoints(char *s=NULL);
00103     int accumulateNumJoints(void);
00104     int getNumSegments(char *s=NULL);
00105     int getId();
00106     char* getName();
00107     BVHOffset* getOffset();
00108 
00109 
00110 private:
00111     BVHOffset *offset;
00112     BVHChannels* channels;
00113     BVHMotion* motion;
00114 
00115     BVHJoint* parent;
00116     std::vector<BVHJoint *> children;
00117 
00118     char name[128];
00119     bool endSite;
00120     int id;
00121     static int lastId;
00122     
00123     // Transformation matrix in the global frame
00124     double matrix[16];
00125 };
00126 
00127 } // namespace bvh
00128 
00129 } // namespace io
00130 
00131 } // namespace helper
00132 
00133 } // namespace sofa
00134 
00135 #endif

Generated on Sun Nov 23 02:29:30 2008 for Sofa by  doxygen 1.5.7.1