face.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*************************************/
  2. /* Auteur : Rémi Synave */
  3. /* Date de création : 01/03/07 */
  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 "face.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. Affichage d'une face
  31. @param f face à afficher
  32. @return aucun
  33. */
  34. void
  35. vf_face_display (
  36. const vf_face * const f)
  37. {
  38. printf ("Face --> [vertex %d , edge %d , edge %d]\n", f->ve1, f->ve2, f->ve3);
  39. }
  40. /**
  41. Inversion de l'orientation de la face
  42. @param f pointeur sur la face à inverser
  43. @return aucun
  44. */
  45. void
  46. vf_face_reverse (
  47. vf_face * f)
  48. {
  49. int temp = f->ve1;
  50. f->ve1 = f->ve2;
  51. f->ve2 = temp;
  52. }
  53. /**
  54. Test de l'appartenance d'un sommet à une face
  55. @param f pointeur sur la face
  56. @param numvertex numero du sommet
  57. @return 1 si le sommet appartient à la face, 0 sinon
  58. */
  59. int
  60. vf_face_contains (
  61. const vf_face * const f,
  62. int numvertex)
  63. {
  64. return (f->ve1 == numvertex || f->ve2 == numvertex || f->ve3 == numvertex);
  65. }
  66. /**
  67. Affichage d'une face
  68. @param f face à afficher
  69. @return aucun
  70. */
  71. void
  72. vef_face_display (
  73. const vef_face * const f)
  74. {
  75. printf ("Face --> [vertex %d , edge %d , edge %d]\n", f->ed1, f->ed2, f->ed3);
  76. }
  77. /**
  78. Inversion de l'orientation de la face
  79. @param f pointeur sur la face à inverser
  80. @return aucun
  81. */
  82. void
  83. vef_face_reverse (
  84. vef_face * f)
  85. {
  86. int temp = f->ed1;
  87. f->ed1 = f->ed2;
  88. f->ed2 = temp;
  89. }
  90. /**
  91. Donne les trois points formant la face
  92. @param f la face dont on veut les trois sommets
  93. @param list list des aretes
  94. @param ve1 index du premier sommet
  95. @param ve2 index du second sommet
  96. @param ve3 index du troisième sommet
  97. @return aucun
  98. */
  99. void
  100. vef_face_get_vertices (
  101. const vef_face * const f,
  102. const vef_edge * const list,
  103. int * ve1,
  104. int * ve2,
  105. int * ve3)
  106. {
  107. if (list[f->ed1].ve1 == list[f->ed2].ve1
  108. || list[f->ed1].ve1 == list[f->ed2].ve2)
  109. {
  110. *ve1 = list[f->ed1].ve1;
  111. *ve3 = list[f->ed1].ve2;
  112. }
  113. else
  114. {
  115. *ve1 = list[f->ed1].ve2;
  116. *ve3 = list[f->ed1].ve1;
  117. }
  118. if (list[f->ed2].ve1 == list[f->ed3].ve1
  119. || list[f->ed2].ve1 == list[f->ed3].ve2)
  120. *ve2 = list[f->ed2].ve1;
  121. else
  122. *ve2 = list[f->ed2].ve2;
  123. }
  124. /**
  125. Test de l'appartenance d'une arete à une face
  126. @param f pointeur sur la face
  127. @param numvertex numero de l'arete
  128. @return 1 si l'arete appartient à la face, 0 sinon
  129. */
  130. int
  131. vef_face_contains (
  132. const vef_face * const f,
  133. int numedge)
  134. {
  135. return (f->ed1 == numedge || f->ed2 == numedge || f->ed3 == numedge);
  136. }