isolines.cpp 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. #include <test_common.h>
  2. #include <igl/isolines.h>
  3. #include <igl/matlab_format.h>
  4. #include <iostream>
  5. TEST_CASE("isolines: broken-sphere", "[igl]" )
  6. {
  7. // Test a case with edge-edge, edge-vertex, vertex-vertex, boundary edge, and
  8. // degenerate boundaries
  9. Eigen::MatrixXd V(42,3);
  10. V<<
  11. 0,0.52573111211913359,0.85065080835203999,
  12. 0,-0.52573111211913359,0.85065080835203999,
  13. 0,0.52573111211913359,-0.85065080835203999,
  14. 0,-0.52573111211913359,-0.85065080835203999,
  15. 0.52573111211913359,0.85065080835203999,0,
  16. -0.52573111211913359,0.85065080835203999,0,
  17. 0.52573111211913359,-0.85065080835203999,0,
  18. -0.52573111211913359,-0.85065080835203999,0,
  19. 0.85065080835203999,0,0.52573111211913359,
  20. -0.85065080835203999,0,0.52573111211913359,
  21. 0.85065080835203999,0,-0.52573111211913359,
  22. -0.85065080835203999,0,-0.52573111211913359,
  23. 0,0,1,
  24. 0.3090169943749474,0.80901699437494734,0.5,
  25. -0.3090169943749474,0.80901699437494734,0.5,
  26. 0.5,0.3090169943749474,0.80901699437494734,
  27. -0.5,0.3090169943749474,0.80901699437494734,
  28. 0.3090169943749474,-0.80901699437494734,0.5,
  29. -0.3090169943749474,-0.80901699437494734,0.5,
  30. 0.5,-0.3090169943749474,0.80901699437494734,
  31. -0.5,-0.3090169943749474,0.80901699437494734,
  32. 0,0,-1,
  33. 0.3090169943749474,0.80901699437494734,-0.5,
  34. -0.3090169943749474,0.80901699437494734,-0.5,
  35. 0.5,0.3090169943749474,-0.80901699437494734,
  36. -0.5,0.3090169943749474,-0.80901699437494734,
  37. 0.3090169943749474,-0.80901699437494734,-0.5,
  38. -0.3090169943749474,-0.80901699437494734,-0.5,
  39. 0.5,-0.3090169943749474,-0.80901699437494734,
  40. -0.5,-0.3090169943749474,-0.80901699437494734,
  41. 0,1,0,
  42. 0.80901699437494734,0.5,0.3090169943749474,
  43. 0.80901699437494734,0.5,-0.3090169943749474,
  44. -0.80901699437494734,0.5,0.3090169943749474,
  45. -0.80901699437494734,0.5,-0.3090169943749474,
  46. 0,-1,0,
  47. 0.80901699437494734,-0.5,0.3090169943749474,
  48. 0.80901699437494734,-0.5,-0.3090169943749474,
  49. -0.80901699437494734,-0.5,0.3090169943749474,
  50. -0.80901699437494734,-0.5,-0.3090169943749474,
  51. 1,0,0,
  52. -1,0,0;
  53. Eigen::MatrixXi F(58,3);
  54. F <<
  55. 0,12,15,
  56. 0,15,13,
  57. 0,13,14,
  58. 0,14,16,
  59. 0,16,12,
  60. 8,40,31,
  61. 4,32,22,
  62. 4,22,30,
  63. 5,23,34,
  64. 5,34,33,
  65. 1,18,17,
  66. 3,26,27,
  67. 8,31,15,
  68. 4,30,13,
  69. 5,33,14,
  70. 9,20,16,
  71. 6,36,17,
  72. 6,37,36,
  73. 10,32,40,
  74. 10,24,32,
  75. 2,23,22,
  76. 2,25,23,
  77. 11,41,34,
  78. 7,18,38,
  79. 7,35,18,
  80. 6,35,26,
  81. 7,39,27,
  82. 11,25,29,
  83. 2,24,21,
  84. 8,15,19,
  85. 4,13,31,
  86. 5,14,30,
  87. 9,16,33,
  88. 4,31,32,
  89. 2,22,24,
  90. 5,30,23,
  91. 11,34,25,
  92. 9,33,41,
  93. 7,38,39,
  94. 6,17,35,
  95. 7,27,35,
  96. 2,21,25,
  97. 10,28,24,
  98. 6,26,37,
  99. 19,15,12,
  100. 31,13,15,
  101. 30,14,13,
  102. 33,16,14,
  103. 20,12,16,
  104. 32,31,40,
  105. 24,22,32,
  106. 23,30,22,
  107. 25,34,23,
  108. 41,33,34,
  109. 35,17,18,
  110. 35,27,26,
  111. 25,21,29,
  112. 24,28,21;
  113. Eigen::MatrixXd iV;
  114. Eigen::MatrixXi iE;
  115. Eigen::VectorXi I;
  116. Eigen::VectorXd vals(3);
  117. vals<<-0.5,0,0.5;
  118. igl::isolines(V,F,V.col(1).eval(),vals,iV,iE,I);
  119. Eigen::MatrixXd iV_gt(30,3);
  120. iV_gt<<
  121. 0.809016994374947,-0.5, 0.309016994374947,
  122. 0.809016994374947,-0.5,-0.309016994374947,
  123. -0.809016994374947,-0.5, 0.309016994374947,
  124. -0.809016994374947,-0.5,-0.309016994374947,
  125. 0.5, 0, 0.809016994374947,
  126. -0.5, 0, 0.809016994374947,
  127. 0.5, 0,-0.809016994374947,
  128. -0.5, 0,-0.809016994374947,
  129. 0, 0, 1,
  130. 0.85065080835204, 0, 0.525731112119134,
  131. 1, 0, 0,
  132. -0.85065080835204, 0, 0.525731112119134,
  133. 0.85065080835204, 0,-0.525731112119134,
  134. -0.85065080835204, 0,-0.525731112119134,
  135. -1, 0, 0,
  136. 0, 0, -1,
  137. 0, 0.5, 0.857960478079794,
  138. 0.0593664879495925, 0.5, 0.845707501720507,
  139. -0.0593664879495925, 0.5, 0.845707501720507,
  140. 0, 0.5,-0.857960478079794,
  141. 0.0593664879495925, 0.5,-0.845707501720507,
  142. -0.0593664879495925, 0.5,-0.845707501720507,
  143. 0.427050983124842, 0.5, 0.690983005625053,
  144. -0.427050983124842, 0.5, 0.690983005625052,
  145. 0.427050983124842, 0.5,-0.690983005625053,
  146. -0.427050983124842, 0.5,-0.690983005625053,
  147. 0.809016994374947, 0.5, 0.309016994374947,
  148. 0.809016994374947, 0.5,-0.309016994374947,
  149. -0.809016994374947, 0.5,-0.309016994374947,
  150. -0.809016994374947, 0.5, 0.309016994374947;
  151. Eigen::MatrixXi iE_gt(28,2);
  152. iE_gt<<
  153. 0, 1,
  154. 3, 2,
  155. 9,10,
  156. 11, 5,
  157. 10,12,
  158. 13,14,
  159. 7,13,
  160. 4, 9,
  161. 14,11,
  162. 12, 6,
  163. 8, 4,
  164. 5, 8,
  165. 15, 7,
  166. 6,15,
  167. 16,17,
  168. 17,22,
  169. 23,18,
  170. 18,16,
  171. 28,29,
  172. 21,25,
  173. 20,19,
  174. 26,27,
  175. 24,20,
  176. 19,21,
  177. 22,26,
  178. 29,23,
  179. 27,24,
  180. 25,28;
  181. test_common::assert_near(iV,iV_gt,1e-15);
  182. test_common::assert_eq(iE,iE_gt);
  183. }