shapematching.c 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*************************************/
  2. /* Auteur : Rémi Synave */
  3. /* Date de création : 01/10/08 */
  4. /* Date de modification : 15/03/15 */
  5. /* Version : 0.4 */
  6. /*************************************/
  7. /***************************************************************************/
  8. /* This file is part of a2ri. */
  9. /* */
  10. /* a2ri is free software: you can redistribute it and/or modify it */
  11. /* under the terms of the GNU Lesser General Public License as published */
  12. /* by the Free Software Foundation, either version 3 of the License, or */
  13. /* (at your option) any later version. */
  14. /* */
  15. /* a2ri is distributed in the hope that it will be useful, */
  16. /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
  17. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
  18. /* GNU Lesser General Public License for more details. */
  19. /* */
  20. /* You should have received a copy of the GNU Lesser General Public */
  21. /* License along with a2ri. */
  22. /* If not, see <http://www.gnu.org/licenses/>. */
  23. /***************************************************************************/
  24. #include "shapematching.h"
  25. /********** INTERMEDIATE TYPES AND FUNCTIONS **********/
  26. /* Les fonctions intermédiaires sont préfixées de IF */
  27. /* et les types intermédiaires de IT */
  28. /********** MAIN FUNCTIONS **********/
  29. /**
  30. Calcul de l'empreinte d'un modèle
  31. @param m le modèle
  32. @param nb_tranche nombre de tranche de l'empreinte
  33. @param list liste de retour de l'empreinte
  34. @return aucun
  35. **/
  36. void
  37. a2ri_vf_empreinte (
  38. const vf_model * const m,
  39. int nb_tranche,
  40. double **list)
  41. {
  42. int size = 0;
  43. int index;
  44. point3d ptmin,
  45. ptmax,
  46. centre,
  47. p;
  48. point3d_init (&ptmin, m->xmin, m->ymin, m->zmin);
  49. point3d_init (&ptmax, m->xmax, m->ymax, m->zmax);
  50. double longdiag = point3d_length (&ptmin, &ptmax);
  51. double longueur;
  52. longdiag /= 2.0;
  53. point3d_init (&centre, (ptmin.x + ptmax.x) / 2.0, (ptmin.y + ptmax.y) / 2.0,
  54. (ptmin.z + ptmax.z) / 2.0);
  55. *list = NULL;
  56. for (int i = 0; i < nb_tranche; i++)
  57. list_double_add (list, &size, 0.0, WITH_REDUNDANCE);
  58. for (int i = 0; i < m->nbvertex; i++)
  59. {
  60. point3d_init (&p, m->ve[i].x, m->ve[i].y, m->ve[i].z);
  61. longueur = point3d_length (&p, &centre);
  62. index = (int) (longueur / longdiag * nb_tranche);
  63. (*list)[index] = (*list)[index] + 1;
  64. }
  65. for (int i = 0; i < nb_tranche; i++)
  66. (*list)[i] = ((*list)[i] / m->nbvertex);
  67. }