Biomechanical Joint Model
 Author: Anderson Maciel

comemesh.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2002 by Anderson Maciel                                 *
00003  *   andi.maciel@gmail.com                                                 *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  **************************************************************************/
00020 
00035 
00036 #ifndef __COMEMESH_H    
00037 #define __COMEMESH_H    
00038 
00039 #include <general/come.h>
00040 #include <algebra/comevertex3d.h>
00041 #include <algebra/comeface.h>
00042 
00043 #ifndef __COME_MOLECULESTISSUE_H
00044 class COME_MoleculesTissue;
00045 #endif
00046 
00047 class COME_BioStructure;
00048 
00049 /* Image type - contains height, width, and data */
00050 struct Image {
00051     unsigned long sizeX;
00052     unsigned long sizeY;
00053     char *data;
00054 };
00055 typedef struct Image Image;
00056 
00057 class COME_Mesh : public COME {
00058 
00059 protected:
00060         vector<COME_Vertex3D>   vertices;               //list of vertices 
00061         vector<COME_Vertex3D>   verticesGlobal; //list of vertices in the global CS
00062         vector<COME_Face>               faces;                  //list of faces (each face uses the indices of the vertices array)
00063         Image *texture;
00064         unsigned int textureID;
00065         static int textureCount;
00066         string  meshFile;
00067 
00068         void    edgeCollapse( int v1, int v2 );
00069         void    reverse(char* data,int size);
00070 
00071 public:
00072         COME_Mesh();
00073         COME_Mesh( const vector<COME_Vertex3D> verticesN, const vector<COME_Face> facesN, COME_BioStructure* parentN );
00074         ~COME_Mesh();
00075         
00076         int                     loadImage(string filename );
00077         void                    addFaceAsIndices( vector<int> indicesN );
00078         void                    addVertex( COME_Vertex3D vertexN );
00079         void                    setAVertex( COME_Vertex3D vertN, int iPosN );
00080         void                    setCollisionDetectableFaces();
00081 
00082         vector<COME_Vertex3D>&  getVertices();
00083         vector<COME_Vertex3D>*  getVerticesPt();
00084         vector<COME_Vertex3D>   getVerticesGlobal();
00085         vector<COME_Face>       getFaces() const;
00086         vector<COME_Vertex3D>   getVerticesFace( int iNumberFace ) const;
00087         vector<COME_Vertex3D>   getVerticesFaceGlobalPosition( int iNumberFace ) const;
00088         COME_Vertex3D           getAVertex( int iPosN ) const;
00089         COME_Vertex3D           getClosestVertex( COME_Point3D givenPoint ) const;
00090         int                     getClosestVertexIndex( COME_Point3D givenPoint ) const;
00091         int                     getClosestFaceIndex( COME_Point3D givenPoint );
00092         COME_Face               getAFace( int iNumberFace ) const;
00093         int                     getNumberFaces() const;
00094         Image *                 getTexture();
00095         unsigned int            *getTextureID();
00096         string                  getFileName();
00097 
00098         void                    setFileName( string newName );
00099         void                    getEnvelop( COME_Point3D& mins, COME_Point3D& maxs );
00100         COME_Point3D            medialPoint();
00101         void                    updateVerticesNormals();
00102         bool                    isInside( COME_Point3D currentPoint ); 
00103         void                    findIntersections( COME_Point3D pi, COME_Point3D pf, vector<COME_Point3D> *allIntersections );
00104         bool                    loadFile( string fileName, double scaleFactor, COME_Point3D originTranslation  );
00105         void                    resetMesh();
00106         void                    update();
00107         void                    estabilishLinkVerticesFaces();
00108         int                     simplify( double minDistance );
00109         void                    scaleOnNormals( double factor );
00110         void                    scale( double factor );
00111         void                    scale( double factorx, double factory, double factorz );
00112         void                    translate( double dx, double dy, double dz );
00113         void                    rotate( double rx, double ry, double rz );
00114         void                    transform( COME_Matrix M );
00115         void                    anchorToMolecules( COME_MoleculesTissue* substract, int anchorNumber );
00116         void                    resetCollisionDisps();
00117         int                     getClosestFaceIndex( COME_Point3D givenPoint ) const;
00118         
00119         //Added by Jean
00120         void                    changeAnchorIfNear( COME_Molecule* molecule, int anchorNumber, int vert );
00121         int                     findDistantAnchor(int indVertex, int anchorNumber);
00122         void                    initClosestNeighbour();
00123         COME_Vertex3D           calcGravityPoint(vector<COME_Vertex3D> vertices);
00124         double                  calcVolume();
00125         double                  calcAreaOfFace(vector<COME_Vertex3D> verticesFace);
00126         double                  distanceVertexFace( COME_Vertex3D vertex, vector<COME_Vertex3D> verticesFace);
00127         COME_Vertex3D           getAVertexGlobalPosition( int iPosN );
00128         COME_Matrix             getGIM();
00129         void                    updateFacesNormalsGlobalPosition();
00130         void                    updateVerticesNormalsGlobalPosition();
00131         void                    updateGlobalPositions();
00132         void                    initVerticesNeighbours();
00133         void                    initFacesNeighbours();
00134         COME_Face*              getAFacePt( int iNumberFace );
00135         vector<COME_Face*>      getPtFaces();
00136         vector<COME_Face>*      getFacesPt();
00137         vector<COME_Vertex3D>   updateMesh();
00138         void                    updateSkin();
00139         vector<COME_Vertex3D>*  getVerticesGlobalPt();
00140         COME_Vertex3D*          getAVertexGlobalPositionPt( int iPosN );
00141         COME_Vertex3D*          getAVertexPt( int iPosN );
00142 
00143 };
00144 
00145 #endif // __COMEMESH_H
00146 

Generated on Thu Dec 1 10:13:34 2005 for COME - Biomechanical Joint Model by  doxygen 1.4.5