libmove3d  3.13.0
/home/slemaign/softs-local/BioMove3D-git/collision/Kcd/include/kcd.h
00001 #ifndef KCD_H
00002 #define KCD_H
00003 
00004 typedef int kcd_index;
00005 typedef kcd_index *kcd_index_p;
00006 typedef double kcd_vector3[3];
00007 typedef kcd_vector3 *pkcd_vector3;
00008 typedef double kcd_matrix3[3][3];
00009 typedef double kcd_matrix4[4][4];
00010 
00011 
00012 /*--------------------------------------------------------------------------
00013  * Activation / deactivation of collision test.
00014  *
00015  * Modif: Fabien Gravot
00016  */
00017 
00025 typedef unsigned char mo_act_type;
00026 
00032 typedef short grp_act_type;
00033 
00037 #define KCD_TABLE_COL_ACT        ((mo_act_type)0x01)
00038 
00041 #define KCD_TABLE_DIST_ACT       ((mo_act_type)0x02)
00042 
00045 #define KCD_TABLE_COL_DIST_ACT   ((mo_act_type)0x03)
00046 
00049 #define KCD_TABLE_COL_DIST_DEACT ((mo_act_type)0x00)
00050 
00056 typedef struct kcd_col_handle
00057 {
00059   int nof_mos;
00060 
00065   mo_act_type **act_mo_pair_arr;
00066   
00070   mo_act_type *act_mo_env_arr;  
00071 
00073   int nof_grps;
00074 
00080   grp_act_type **act_grp_pair_arr;
00081   
00085   grp_act_type *act_grp_env_arr;  
00086 } kcd_col_handle, *kcd_col_handle_p;
00087 
00088 
00089 typedef struct kcd_bb
00090 {
00091   int bb_id_in_all_bbs;         /* unique id, place in array all_bbs[] */
00092   /* what is the best box represented here */
00093   int best_box_type;                 /* UNSET: 0, AABB_BOXTYPE: 1, OBB_BOXTYPE: 2 */
00094 
00095   /* AABB: */
00096   double x1,x2,y1,y2,z1,z2;    /* x1 <= x2, y1 <= y2, z1 <= z2, values of box vertices */
00097   int is_aabb_tree_leaf;       /* TRUE or FALSE */
00098   int current_status_aabb;     /* UNSET, UNCHANGED, MOVED_FORWARD, MOVED_BACKWARD, MOVED */
00099   int hier_level;              /* in case of non-leaf, the indices */
00100   int place_at_level;          /*  that allow access to position in AABB-tree */
00101 
00102   /* B Kineo Carl 27.02.2002 */
00103   int ext_obj_id;   /* external identifier of object to which belong the polyhedrons and solids
00104                        inside this box, if this object is the same for all; -1 otherwise */
00105   /* E Kineo Carl 27.02.2002 */
00106 
00107   /* OBB: */
00108   int is_obb_root;       /* true if OBB is root of OBB-tree or if OBB around solid */
00109   int type_of_obb;       /* NEW: OBB_FLAT,OBB_SPHERICAL or OBB_TALL */
00110   double d[3];                 /* half box size in three "eigen" directions */
00111   double volume;               /* volume of box = 8.0 * d[0] * d[1] * d[2]    */
00112   double center[3];            /* the center of the box w.r.t. frame specified below */
00113   kcd_vector3 eigenv[3];       /* the eigen vectors (unit vectors!) ordered in decending importance, 
00114                                    w.r.t. frame specified below */
00115   int reference_frame;         /* WORK, LOCAL */
00116   int current_status_obb;      /* UNSET, UNCHANGED, MOVED */
00117   struct kcd_bb *parent_bb;    /* parent box in an OBB-TREE, for complex things */
00118   struct kcd_bb **children_bb;    /* child boxes in an OBB-TREE, for complex things */
00119   int nof_children_bb;            /* number of child boxes in array above */
00120   /* TO BE ADDED: pointer to low level object for which the box is a BV */
00121   int what_is_inside;           /* POLYHEDRON, SOLID, BBs,... */
00122   int entity_type;        /* SPHERE, CONVEX_POLYHEDRON,...,KCD_SMALL_VOLUME_BOX */ 
00123   void *pol;          /* in case what_is_inside is POLYHEDRON or SOLID */
00124   int ext_pol_id;   /* external identifier of pol, whenever it is a POLYHEDRON or SOLID (25.02.2002) */
00125   int nof_facet_vertices; /* in case what_is_inside is POLYHEDRON, we have a facet... */
00126   int *facet_vertices;    /* ... of the *pol with these vertices */
00127   int interesting_seed;   /* KCD GJK: interation starts here in list facet_vertices */
00128   int is_robot_prim; /* only TRUE if *pol belongs to a moving object */
00129   int nof_bbs;                    /* in case what_is_inside is BBs */
00130   struct kcd_bb **array_of_bbs;    /* in case what_is_inside is BBs 
00131                                      pointer to nof_bbs BBs */
00132 
00133   /* attributes for min_max filtering Pepijn */
00134   double min_estimated_distance;
00135   double max_estimated_distance;
00136 
00137   /* connecting them */
00138   struct kcd_bb *prev;
00139   struct kcd_bb *next;
00140 }kcd_bb, *kcd_bb_p;
00141 
00142 
00143 typedef struct id_bb
00144 {
00145   int       p3d_poly_id;
00146   int       obb_type;
00147   int       obb_ref_num_by_type;
00148 }id_bb;
00149 
00150 typedef struct prim_obj_table
00151 {
00152   int is_movable;
00153   int ext_obj_id;
00154   int ext_prim_id;
00155   int kcd_obj_id;
00156   int kcd_prim_bb_id;
00157 }prim_obj_table, *prim_obj_table_p;
00158 
00159 typedef struct obj_prim_interval_table
00160 {
00161   int ext_obj_id;
00162   int m_or_s_id;
00163   int is_movable;
00164   int is_active;    /* TRUE if (movable) object must be taken into account for collision testing */
00165   int is_moved;     /* if FALSE, collision detector can re-use previous result for this movable object (flag only useful for movable objects) */
00166   int sml_index;
00167   int big_index;
00168 }obj_prim_interval_table, *obj_prim_interval_table_p;
00169 
00170 typedef struct poly_bb_table
00171 {
00172   int p3d_poly_id;
00173   int bb_id;
00174 }poly_bb_table, *poly_bb_table_p;
00175 
00176 typedef struct link_bb_table
00177 {
00178   int mo_id;
00179   int kcd_mo_id;
00180   int bb_id;
00181 }link_bb_table, *link_bb_table_p;
00182 
00183 typedef struct mov_obj_bb_table
00184 {
00185   int ext_o_id;  /* the external obj_id of mo */
00186   int obj_id;  /* the obj_id of mo */
00187   int bb_id;   /* for each mo, the bb around it */
00188   int grp_id;  /* if mo belongs to group (robot), or -1 if not */
00189   int ith_mo;  /* mo is the ith_mo-th group element (the ith_mo-th body) */
00190 }mov_obj_bb_table, *mov_obj_bb_table_p;
00191 
00192 typedef struct group_bb_table
00193 {
00194   int group_id;
00195   int hierheight;
00196   int bb_id;
00197 }group_bb_table;
00198 
00199 
00200 
00201 
00202 #endif
00203 
00204 
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines