libmove3d  3.13.0
/home/slemaign/softs-local/BioMove3D-git/include/polyhedre.h
00001 #ifndef _POLYHEDRE_H
00002 #define _POLYHEDRE_H
00003 
00004 /******************************************************************************************
00005    
00006   FICHIER: polyhedre.h
00007 
00008   USAGE: module gerant des objets a facettes, creation par sommet 
00009          puis definition des faces
00010          le calcul des plans des faces est effectuee et reste memorisee uniquement 
00011          a la demande. De meme pour les arretes
00012 
00013 ******************************************************************************************/
00014 #include <math.h>
00015 #include <stdlib.h>
00016 #include <locale.h>
00017 #include <vector>
00018 
00019 #include "p3d_matrix.h"
00020 
00021 #ifdef _p3d_MATRIX_H
00022 
00023 #define  poly_type_de_base p3d_matrix_type
00024 #define poly_vector3 p3d_vector3
00025 #define poly_matrix4 p3d_matrix4
00026 
00027 #else
00028 typedef double  poly_type_de_base;
00029 
00030 typedef poly_type_de_base  poly_vector3[3];
00031 
00032 typedef poly_type_de_base poly_matrix4[4][4];
00033 #endif
00034 
00035 #ifndef FALSE
00036 #define FALSE 0
00037 #endif
00038 
00039 #ifndef TRUE
00040 #define TRUE 1
00041 #endif
00042 
00043 #ifndef UNKNOWN
00044 #define UNKNOWN 2
00045 #endif
00046 
00047 
00048 #define poly_error_null_pointer             1
00049 #define poly_error_malloc_failled           2
00050 #define poly_error_unknown_point            3
00051 #define poly_error_impossible_edge          4
00052 #define poly_error_impossible_index         5
00053 #define poly_error_edge_needs_2_points      6
00054 #define poly_error_normal_nulle             7
00055 #define poly_error_plane_needs_3_points     8
00056 #define poly_error_impossible_list_edges    9
00057 #define poly_error_impossible_polyhedre     10
00058 
00059 
00060 /*************************************************
00061  cet valeur est nulle quand il n y a pas d erreur
00062   et les valeurs M3d_error????? sinon
00063 *************************************************/
00064 extern unsigned int poly_error_value;
00065 
00066 
00067 typedef unsigned int poly_index;
00068 typedef poly_index *poly_index_p ;
00069 
00070 typedef unsigned int poly_triangle[3];
00071 #define p3d_triangle poly_triangle
00072 
00073 typedef struct  poly_plane
00074   { poly_vector3      normale;
00075     poly_type_de_base  d;
00076   } poly_plane;
00077 
00078 typedef struct poly_edge
00079   { poly_index     point1,point2; 
00080     poly_index     face1,face2; 
00081 
00082     poly_vector3  u;
00083 
00087     double angle;
00088 
00089     poly_vector3 normal; 
00090     poly_vector3 midpoint; 
00092   } poly_edge;
00093 
00094 typedef struct poly_face
00095   { poly_plane     *plane;
00096     unsigned  int  nb_points;
00097     poly_index     *the_indexs_points; 
00098     unsigned int face_is_convex;
00099 
00101     p3d_vector3 centroid; 
00102     double area; 
00103   
00109     int neighbours[3];
00110 
00115     int edges[3];
00116 
00117 #ifdef GRASP_PLANNING
00118 
00119     unsigned int part;
00120     double curvature;
00121 #endif
00122 
00123   } poly_face;  
00124 
00125 
00126 typedef struct poly_polyhedre
00127   { char *name;
00128     unsigned int  nb_points;
00129     unsigned int  nb_faces;
00130     unsigned int  nb_edges;
00131     poly_vector3  *the_points;
00132     poly_face      *the_faces;
00133     poly_edge      *the_edges;
00134     poly_matrix4   pos;
00135     double *curvatures; 
00136 
00138     p3d_vector3  *vertex_normals; 
00139  
00140     p3d_vector3 centroid; 
00141 
00143     int areEdgesAndNeighboursUpToDate;
00144 
00145      poly_vector3  *originalPoints;
00146 
00147     #ifdef GRASP_PLANNING 
00148 
00149 
00150 
00151      p3d_vector3 cmass;
00152 
00154      p3d_matrix3 inertia_axes;
00155  
00157      double volume;
00158     #endif
00159   } poly_polyhedre;
00160 
00161 /*
00162 void poly_f_2_v3(float x, float y, float z, poly_vector3 *vector);
00163 void poly_d_2_v3(double x, double y, double z, poly_vector3 *vector);
00164 void poly_v3_2_f( poly_vector3 *vector, float *x, float *y, float *z);
00165 void poly_v3_2_d(poly_vector3 *vector, double *x, double *y, double *z);
00166 void poly_plane_2_d(poly_plane *plane, double *a, double *b, double *c, double *d);
00167 void poly_show_error_on_shell(int value);
00168 int poly_get_error_value();
00169 int poly_error();
00170 void poly_init_poly(poly_polyhedre *polyhedre,char *name);
00171 poly_polyhedre *poly_create_poly(char *name);
00172 void poly_destroy_poly(poly_polyhedre *polyhedre);
00173 void poly_destroy_edges(poly_polyhedre *polyhedre);
00174 void poly_destroy_planes(poly_polyhedre *polyhedre);
00175 char *poly_get_name(poly_polyhedre *polyhedre);
00176 unsigned int poly_get_nb_points(poly_polyhedre *polyhedre);
00177 unsigned int poly_get_nb_points_in_face(poly_polyhedre *polyhedre, poly_index face);
00178 unsigned int poly_get_nb_faces(poly_polyhedre *polyhedre);
00179 unsigned int poly_get_nb_edges_in_face(poly_polyhedre *polyhedre, poly_index face);
00180 unsigned int poly_get_nb_edges(poly_polyhedre *polyhedre);
00181 int poly_get_index_point_in_face(poly_polyhedre *polyhedre,poly_index face, poly_index index);
00182 int poly_get_edge_points(poly_polyhedre *polyhedre, poly_index edge, poly_index *p1, poly_index *p2);
00183 int poly_get_edge_faces(poly_polyhedre *polyhedre, poly_index edge, poly_index *f1, poly_index *f2);
00184 int poly_add_point(poly_vector3 point, poly_polyhedre *polyhedre);
00185 int poly_find_point(poly_vector3 point, poly_polyhedre *polyhedre);
00186 int poly_get_point_2_v3(poly_polyhedre *polyhedre, poly_index index, poly_vector3 *vector);
00187 int poly_get_point_2_d(poly_polyhedre *polyhedre, poly_index index, double *x,double *y,double *z);
00188 void poly_get_poly_pos(poly_polyhedre *polyhedre, poly_matrix4 mat);
00189 poly_matrix4 *poly_get_poly_mat(poly_polyhedre *polyhedre);
00190 void poly_set_poly_pos(poly_polyhedre *polyhedre, poly_matrix4 mat);
00191 int poly_find_pos_in_face(poly_polyhedre *polyhedre, poly_index index, poly_index point);
00192 int poly_get_point_in_pos_in_face(poly_polyhedre *polyhedre, poly_index face, poly_index point, double *x, double *y, double *z);
00193 int poly_get_point_in_edge(poly_polyhedre *polyhedre, poly_index edge, poly_index point, double *x, double *y, double *z);
00194 int poly_find_edge(poly_polyhedre *polyhedre, poly_index p1, poly_index p2);
00195 int poly_build_edges(poly_polyhedre *polyhedre);
00196 int poly_build_plane_face(poly_polyhedre *polyhedre, poly_index numero);
00197 int poly_get_plane(poly_polyhedre *polyhedre, poly_index index, poly_plane *plane);
00198 int poly_get_plane_2_d(poly_polyhedre *polyhedre, poly_index index, double *a,double *b,double *c, double *d);
00199 int poly_build_planes(poly_polyhedre *polyhedre);
00200 int poly_build_face(poly_index *the_indexs, unsigned int nombre, poly_polyhedre *polyhedre);
00201 */
00202 
00203 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines