signed_distance.cpp 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2014 Alec Jacobson <[email protected]>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #include "signed_distance.h"
  9. #include "get_seconds.h"
  10. #include "per_edge_normals.h"
  11. #include "parallel_for.h"
  12. #include "per_face_normals.h"
  13. #include "per_vertex_normals.h"
  14. #include "point_mesh_squared_distance.h"
  15. #include "pseudonormal_test.h"
  16. #include "fast_winding_number.h"
  17. namespace
  18. {
  19. template <
  20. typename DerivedP,
  21. typename DerivedV,
  22. typename DerivedF,
  23. typename DerivedS,
  24. typename DerivedI,
  25. typename DerivedC,
  26. typename DerivedN>
  27. void signed_distance_3(
  28. const Eigen::MatrixBase<DerivedP> & P,
  29. const Eigen::MatrixBase<DerivedV> & V,
  30. const Eigen::MatrixBase<DerivedF> & F,
  31. const igl::SignedDistanceType sign_type,
  32. const typename DerivedV::Scalar lower_bound,
  33. const typename DerivedV::Scalar upper_bound,
  34. Eigen::PlainObjectBase<DerivedS> & S,
  35. Eigen::PlainObjectBase<DerivedI> & I,
  36. Eigen::PlainObjectBase<DerivedC> & C,
  37. Eigen::PlainObjectBase<DerivedN> & N)
  38. {
  39. using namespace igl;
  40. AABB<DerivedV,3> tree;
  41. tree.init(V,F);
  42. Eigen::Matrix<typename DerivedV::Scalar,Eigen::Dynamic,3> FN,VN,EN;
  43. Eigen::Matrix<typename DerivedF::Scalar,Eigen::Dynamic,2> E;
  44. Eigen::Matrix<typename DerivedF::Scalar,Eigen::Dynamic,1> EMAP;
  45. typedef Eigen::Matrix<typename DerivedV::Scalar,1,3> RowVectorS;
  46. using Scalar = typename DerivedV::Scalar;
  47. using Index = typename DerivedF::Scalar;
  48. WindingNumberAABB<Scalar,Index> hier3;
  49. igl::FastWindingNumberBVH fwn_bvh;
  50. Eigen::VectorXf W;
  51. switch(sign_type)
  52. {
  53. default:
  54. assert(false && "Unknown SignedDistanceType");
  55. case SIGNED_DISTANCE_TYPE_UNSIGNED:
  56. // do nothing
  57. break;
  58. case SIGNED_DISTANCE_TYPE_DEFAULT:
  59. case SIGNED_DISTANCE_TYPE_WINDING_NUMBER:
  60. hier3.set_mesh(V,F);
  61. hier3.grow();
  62. break;
  63. case SIGNED_DISTANCE_TYPE_FAST_WINDING_NUMBER:
  64. igl::fast_winding_number(V.template cast<float>().eval(), F, 2, fwn_bvh);
  65. break;
  66. case SIGNED_DISTANCE_TYPE_PSEUDONORMAL:
  67. // "Signed Distance Computation Using the Angle Weighted Pseudonormal"
  68. // [Bærentzen & Aanæs 2005]
  69. igl::per_face_normals(V,F,FN);
  70. igl::per_vertex_normals(V,F,PER_VERTEX_NORMALS_WEIGHTING_TYPE_ANGLE,FN,VN);
  71. igl::per_edge_normals(
  72. V,F,PER_EDGE_NORMALS_WEIGHTING_TYPE_UNIFORM,FN,EN,E,EMAP);
  73. N.resize(P.rows(),3);
  74. break;
  75. }
  76. // convert to bounds on (unsiged) squared distances
  77. typedef typename DerivedV::Scalar Scalar;
  78. const Scalar max_abs = std::max(std::abs(lower_bound),std::abs(upper_bound));
  79. const Scalar up_sqr_d = std::pow(max_abs,2.0);
  80. const Scalar low_sqr_d =
  81. std::pow(std::max(max_abs-(upper_bound-lower_bound),(Scalar)0.0),2.0);
  82. S.resize(P.rows(),1);
  83. I.resize(P.rows(),1);
  84. C.resize(P.rows(),3);
  85. igl::parallel_for(P.rows(),[&](const int p)
  86. //for(int p = 0;p<P.rows();p++)
  87. {
  88. RowVectorS q = P.row(p);
  89. typename DerivedV::Scalar s=1,sqrd=0;
  90. RowVectorS c;
  91. int i=-1;
  92. // in all cases compute squared unsiged distances
  93. sqrd = tree.squared_distance(V,F,q,low_sqr_d,up_sqr_d,i,c);
  94. if(sqrd >= up_sqr_d || sqrd < low_sqr_d)
  95. {
  96. // Out of bounds gets a nan (nans on grids can be flood filled later using
  97. // igl::flood_fill)
  98. S(p) = std::numeric_limits<double>::quiet_NaN();
  99. I(p) = F.rows()+1;
  100. C.row(p).setConstant(0);
  101. }else
  102. {
  103. // Determine sign
  104. switch(sign_type)
  105. {
  106. default:
  107. assert(false && "Unknown SignedDistanceType");
  108. case SIGNED_DISTANCE_TYPE_UNSIGNED:
  109. break;
  110. case SIGNED_DISTANCE_TYPE_DEFAULT:
  111. case SIGNED_DISTANCE_TYPE_WINDING_NUMBER:
  112. s = 1.-2.*hier3.winding_number(q.transpose());
  113. break;
  114. case SIGNED_DISTANCE_TYPE_FAST_WINDING_NUMBER:
  115. {
  116. Scalar w = fast_winding_number(fwn_bvh, 2, q.template cast<float>().eval());
  117. s = 1.-2.*std::abs(w);
  118. break;
  119. }
  120. case SIGNED_DISTANCE_TYPE_PSEUDONORMAL:
  121. {
  122. RowVectorS n;
  123. pseudonormal_test(V,F,FN,VN,EN,EMAP,q,i,c,s,n);
  124. N.row(p) = n.template cast<typename DerivedN::Scalar>();
  125. break;
  126. }
  127. }
  128. I(p) = i;
  129. S(p) = s*sqrt(sqrd);
  130. C.row(p) = c.template cast<typename DerivedC::Scalar>();
  131. }
  132. }
  133. ,10000);
  134. }
  135. template <
  136. typename DerivedP,
  137. typename DerivedV,
  138. typename DerivedF,
  139. typename DerivedS,
  140. typename DerivedI,
  141. typename DerivedC,
  142. typename DerivedN>
  143. void signed_distance_2(
  144. const Eigen::MatrixBase<DerivedP> & P,
  145. const Eigen::MatrixBase<DerivedV> & V,
  146. const Eigen::MatrixBase<DerivedF> & F,
  147. const igl::SignedDistanceType sign_type,
  148. const typename DerivedV::Scalar lower_bound,
  149. const typename DerivedV::Scalar upper_bound,
  150. Eigen::PlainObjectBase<DerivedS> & S,
  151. Eigen::PlainObjectBase<DerivedI> & I,
  152. Eigen::PlainObjectBase<DerivedC> & C,
  153. Eigen::PlainObjectBase<DerivedN> & N)
  154. {
  155. using namespace igl;
  156. AABB<DerivedV,2> tree;
  157. tree.init(V,F);
  158. Eigen::Matrix<typename DerivedV::Scalar,Eigen::Dynamic,2> FN,VN,EN;
  159. Eigen::Matrix<typename DerivedF::Scalar,Eigen::Dynamic,2> E;
  160. Eigen::Matrix<typename DerivedF::Scalar,Eigen::Dynamic,1> EMAP;
  161. switch(sign_type)
  162. {
  163. default:
  164. assert(false && "Unknown or unsupported SignedDistanceType for 2D");
  165. case SIGNED_DISTANCE_TYPE_DEFAULT:
  166. case SIGNED_DISTANCE_TYPE_WINDING_NUMBER:
  167. case SIGNED_DISTANCE_TYPE_UNSIGNED:
  168. // no precomp for 2D
  169. break;
  170. case SIGNED_DISTANCE_TYPE_PSEUDONORMAL:
  171. // "Signed Distance Computation Using the Angle Weighted Pseudonormal"
  172. // [Bærentzen & Aanæs 2005]
  173. FN.resize(F.rows(),2);
  174. VN = DerivedV::Zero(V.rows(),2);
  175. for(int e = 0;e<F.rows();e++)
  176. {
  177. // rotate edge vector
  178. FN(e,0) = (V(F(e,1),1)-V(F(e,0),1));
  179. FN(e,1) = -(V(F(e,1),0)-V(F(e,0),0));
  180. FN.row(e).normalize();
  181. // add to vertex normal
  182. VN.row(F(e,1)) += FN.row(e);
  183. VN.row(F(e,0)) += FN.row(e);
  184. }
  185. // normalize to average
  186. VN.rowwise().normalize();
  187. N.resize(P.rows(),2);
  188. break;
  189. }
  190. // convert to bounds on (unsiged) squared distances
  191. typedef typename DerivedV::Scalar Scalar;
  192. const Scalar max_abs = std::max(std::abs(lower_bound),std::abs(upper_bound));
  193. const Scalar up_sqr_d = std::pow(max_abs,2.0);
  194. const Scalar low_sqr_d =
  195. std::pow(std::max(max_abs-(upper_bound-lower_bound),(Scalar)0.0),2.0);
  196. S.resize(P.rows(),1);
  197. I.resize(P.rows(),1);
  198. C.resize(P.rows(),2);
  199. typedef Eigen::Matrix<typename DerivedV::Scalar,1,2> RowVectorS;
  200. igl::parallel_for(P.rows(),[&](const int p)
  201. //for(int p = 0;p<P.rows();p++)
  202. {
  203. RowVectorS q = P.row(p);
  204. typename DerivedV::Scalar s=1,sqrd=0;
  205. RowVectorS c;
  206. int i=-1;
  207. // in all cases compute squared unsiged distances
  208. sqrd = tree.squared_distance(V,F,q,low_sqr_d,up_sqr_d,i,c);
  209. if(sqrd >= up_sqr_d || sqrd < low_sqr_d)
  210. {
  211. // Out of bounds gets a nan (nans on grids can be flood filled later using
  212. // igl::flood_fill)
  213. S(p) = std::numeric_limits<double>::quiet_NaN();
  214. I(p) = F.rows()+1;
  215. C.row(p).setConstant(0);
  216. }else
  217. {
  218. // Determine sign
  219. switch(sign_type)
  220. {
  221. default:
  222. assert(false && "Unknown SignedDistanceType");
  223. case SIGNED_DISTANCE_TYPE_UNSIGNED:
  224. break;
  225. case SIGNED_DISTANCE_TYPE_DEFAULT:
  226. case SIGNED_DISTANCE_TYPE_WINDING_NUMBER:
  227. assert(!V.derived().IsRowMajor);
  228. assert(!F.derived().IsRowMajor);
  229. s = 1.-2.*winding_number(V,F,q);
  230. break;
  231. case SIGNED_DISTANCE_TYPE_PSEUDONORMAL:
  232. {
  233. RowVectorS n;
  234. pseudonormal_test(V,F,FN,VN,q,i,c,s,n);
  235. N.row(p) = n.template cast<typename DerivedN::Scalar>();
  236. break;
  237. }
  238. }
  239. I(p) = i;
  240. S(p) = s*sqrt(sqrd);
  241. C.row(p) = c.template cast<typename DerivedC::Scalar>();
  242. }
  243. }
  244. ,10000);
  245. }
  246. // Class whose templates can be specialized on whether all inputs have dynamic
  247. // columns or not.
  248. template <
  249. typename DerivedP,
  250. typename DerivedV,
  251. typename DerivedF,
  252. typename DerivedS,
  253. typename DerivedI,
  254. typename DerivedC,
  255. typename DerivedN,
  256. int ColsAtCompileTime>
  257. struct signed_distance_DIM_Handler;
  258. // All inputs have dynamic number of columns
  259. template <
  260. typename DerivedP,
  261. typename DerivedV,
  262. typename DerivedF,
  263. typename DerivedS,
  264. typename DerivedI,
  265. typename DerivedC,
  266. typename DerivedN>
  267. struct signed_distance_DIM_Handler<
  268. DerivedP, DerivedV, DerivedF, DerivedS, DerivedI, DerivedC, DerivedN,
  269. Eigen::Dynamic>
  270. {
  271. static void compute(
  272. const Eigen::MatrixBase<DerivedP> & P,
  273. const Eigen::MatrixBase<DerivedV> & V,
  274. const Eigen::MatrixBase<DerivedF> & F,
  275. const igl::SignedDistanceType sign_type,
  276. const typename DerivedV::Scalar lower_bound,
  277. const typename DerivedV::Scalar upper_bound,
  278. Eigen::PlainObjectBase<DerivedS> & S,
  279. Eigen::PlainObjectBase<DerivedI> & I,
  280. Eigen::PlainObjectBase<DerivedC> & C,
  281. Eigen::PlainObjectBase<DerivedN> & N)
  282. {
  283. // Just need to check P as V and F are checked in signed_distance
  284. if(P.cols() == 3)
  285. {
  286. signed_distance_3(P,V,F,sign_type,lower_bound,upper_bound,S,I,C,N);
  287. }else if(P.cols() == 2)
  288. {
  289. signed_distance_2(P,V,F,sign_type,lower_bound,upper_bound,S,I,C,N);
  290. }else
  291. {
  292. assert(false && "P should have 3d or 2d positions");
  293. }
  294. }
  295. };
  296. // Some input is 3D
  297. template <
  298. typename DerivedP,
  299. typename DerivedV,
  300. typename DerivedF,
  301. typename DerivedS,
  302. typename DerivedI,
  303. typename DerivedC,
  304. typename DerivedN>
  305. struct signed_distance_DIM_Handler<
  306. DerivedP, DerivedV, DerivedF, DerivedS, DerivedI, DerivedC, DerivedN,
  307. 3>
  308. {
  309. static void compute(
  310. const Eigen::MatrixBase<DerivedP> & P,
  311. const Eigen::MatrixBase<DerivedV> & V,
  312. const Eigen::MatrixBase<DerivedF> & F,
  313. const igl::SignedDistanceType sign_type,
  314. const typename DerivedV::Scalar lower_bound,
  315. const typename DerivedV::Scalar upper_bound,
  316. Eigen::PlainObjectBase<DerivedS> & S,
  317. Eigen::PlainObjectBase<DerivedI> & I,
  318. Eigen::PlainObjectBase<DerivedC> & C,
  319. Eigen::PlainObjectBase<DerivedN> & N)
  320. {
  321. signed_distance_3(P,V,F,sign_type,lower_bound,upper_bound,S,I,C,N);
  322. }
  323. };
  324. // Some input is 2D
  325. template <
  326. typename DerivedP,
  327. typename DerivedV,
  328. typename DerivedF,
  329. typename DerivedS,
  330. typename DerivedI,
  331. typename DerivedC,
  332. typename DerivedN>
  333. struct signed_distance_DIM_Handler<
  334. DerivedP, DerivedV, DerivedF, DerivedS, DerivedI, DerivedC, DerivedN,
  335. 2>
  336. {
  337. static void compute(
  338. const Eigen::MatrixBase<DerivedP> & P,
  339. const Eigen::MatrixBase<DerivedV> & V,
  340. const Eigen::MatrixBase<DerivedF> & F,
  341. const igl::SignedDistanceType sign_type,
  342. const typename DerivedV::Scalar lower_bound,
  343. const typename DerivedV::Scalar upper_bound,
  344. Eigen::PlainObjectBase<DerivedS> & S,
  345. Eigen::PlainObjectBase<DerivedI> & I,
  346. Eigen::PlainObjectBase<DerivedC> & C,
  347. Eigen::PlainObjectBase<DerivedN> & N)
  348. {
  349. signed_distance_2(P,V,F,sign_type,lower_bound,upper_bound,S,I,C,N);
  350. }
  351. };
  352. }
  353. template <
  354. typename DerivedP,
  355. typename DerivedV,
  356. typename DerivedF,
  357. typename DerivedS,
  358. typename DerivedI,
  359. typename DerivedC,
  360. typename DerivedN>
  361. IGL_INLINE void igl::signed_distance(
  362. const Eigen::MatrixBase<DerivedP> & P,
  363. const Eigen::MatrixBase<DerivedV> & V,
  364. const Eigen::MatrixBase<DerivedF> & F,
  365. const SignedDistanceType sign_type,
  366. const typename DerivedV::Scalar lower_bound,
  367. const typename DerivedV::Scalar upper_bound,
  368. Eigen::PlainObjectBase<DerivedS> & S,
  369. Eigen::PlainObjectBase<DerivedI> & I,
  370. Eigen::PlainObjectBase<DerivedC> & C,
  371. Eigen::PlainObjectBase<DerivedN> & N)
  372. {
  373. constexpr int DIM =
  374. DerivedP::ColsAtCompileTime != Eigen::Dynamic ? DerivedP::ColsAtCompileTime :
  375. DerivedV::ColsAtCompileTime != Eigen::Dynamic ? DerivedV::ColsAtCompileTime :
  376. DerivedF::ColsAtCompileTime != Eigen::Dynamic ? DerivedF::ColsAtCompileTime :
  377. DerivedN::ColsAtCompileTime != Eigen::Dynamic ? DerivedN::ColsAtCompileTime :
  378. DerivedC::ColsAtCompileTime != Eigen::Dynamic ? DerivedC::ColsAtCompileTime :
  379. Eigen::Dynamic;
  380. static_assert(DIM == 3 || DIM == 2 || DIM == Eigen::Dynamic,"DIM should be 2 or 3 or Dynamic");
  381. assert(V.cols() == P.cols() && "V should have same dimension as P");
  382. assert(V.cols() == F.cols() || sign_type == SIGNED_DISTANCE_TYPE_UNSIGNED && "V and F should have same number of columns");
  383. if (sign_type == SIGNED_DISTANCE_TYPE_FAST_WINDING_NUMBER){
  384. assert(V.cols() == 3 && "V should be 3D for fast winding number");
  385. }
  386. if(F.rows() == 0)
  387. {
  388. S.setConstant(P.rows(),1,std::numeric_limits<typename DerivedS::Scalar>::quiet_NaN());
  389. I.setConstant(P.rows(),1,-1);
  390. C.setConstant(P.rows(),P.cols(),std::numeric_limits<typename DerivedC::Scalar>::quiet_NaN());
  391. N.setConstant(P.rows(),P.cols(),std::numeric_limits<typename DerivedC::Scalar>::quiet_NaN());
  392. return;
  393. }
  394. signed_distance_DIM_Handler<
  395. DerivedP,
  396. DerivedV,
  397. DerivedF,
  398. DerivedS,
  399. DerivedI,
  400. DerivedC,
  401. DerivedN,
  402. DIM>::compute(P,V,F,sign_type,lower_bound,upper_bound,S,I,C,N);
  403. }
  404. template <
  405. typename DerivedP,
  406. typename DerivedV,
  407. typename DerivedF,
  408. typename DerivedS,
  409. typename DerivedI,
  410. typename DerivedC,
  411. typename DerivedN>
  412. IGL_INLINE void igl::signed_distance(
  413. const Eigen::MatrixBase<DerivedP> & P,
  414. const Eigen::MatrixBase<DerivedV> & V,
  415. const Eigen::MatrixBase<DerivedF> & F,
  416. const SignedDistanceType sign_type,
  417. Eigen::PlainObjectBase<DerivedS> & S,
  418. Eigen::PlainObjectBase<DerivedI> & I,
  419. Eigen::PlainObjectBase<DerivedC> & C,
  420. Eigen::PlainObjectBase<DerivedN> & N)
  421. {
  422. typedef typename DerivedV::Scalar Scalar;
  423. Scalar lower = std::numeric_limits<Scalar>::min();
  424. Scalar upper = std::numeric_limits<Scalar>::max();
  425. return signed_distance(P,V,F,sign_type,lower,upper,S,I,C,N);
  426. }
  427. template <
  428. typename DerivedV,
  429. typename DerivedF,
  430. typename DerivedFN,
  431. typename DerivedVN,
  432. typename DerivedEN,
  433. typename DerivedEMAP,
  434. typename Derivedq>
  435. IGL_INLINE typename DerivedV::Scalar igl::signed_distance_pseudonormal(
  436. const AABB<DerivedV,3> & tree,
  437. const Eigen::MatrixBase<DerivedV> & V,
  438. const Eigen::MatrixBase<DerivedF> & F,
  439. const Eigen::MatrixBase<DerivedFN> & FN,
  440. const Eigen::MatrixBase<DerivedVN> & VN,
  441. const Eigen::MatrixBase<DerivedEN> & EN,
  442. const Eigen::MatrixBase<DerivedEMAP> & EMAP,
  443. const Eigen::MatrixBase<Derivedq> & q)
  444. {
  445. typename DerivedV::Scalar s,sqrd;
  446. Eigen::Matrix<typename DerivedV::Scalar,1,3> n,c;
  447. int i = -1;
  448. signed_distance_pseudonormal(tree,V,F,FN,VN,EN,EMAP,q,s,sqrd,i,c,n);
  449. return s*sqrt(sqrd);
  450. }
  451. template <
  452. typename DerivedP,
  453. typename DerivedV,
  454. typename DerivedF,
  455. typename DerivedFN,
  456. typename DerivedVN,
  457. typename DerivedEN,
  458. typename DerivedEMAP,
  459. typename DerivedS,
  460. typename DerivedI,
  461. typename DerivedC,
  462. typename DerivedN>
  463. IGL_INLINE void igl::signed_distance_pseudonormal(
  464. const Eigen::MatrixBase<DerivedP> & P,
  465. const Eigen::MatrixBase<DerivedV> & V,
  466. const Eigen::MatrixBase<DerivedF> & F,
  467. const AABB<DerivedV,3> & tree,
  468. const Eigen::MatrixBase<DerivedFN> & FN,
  469. const Eigen::MatrixBase<DerivedVN> & VN,
  470. const Eigen::MatrixBase<DerivedEN> & EN,
  471. const Eigen::MatrixBase<DerivedEMAP> & EMAP,
  472. Eigen::PlainObjectBase<DerivedS> & S,
  473. Eigen::PlainObjectBase<DerivedI> & I,
  474. Eigen::PlainObjectBase<DerivedC> & C,
  475. Eigen::PlainObjectBase<DerivedN> & N)
  476. {
  477. const size_t np = P.rows();
  478. S.resize(np,1);
  479. I.resize(np,1);
  480. N.resize(np,3);
  481. C.resize(np,3);
  482. typedef typename AABB<DerivedV,3>::RowVectorDIMS RowVector3S;
  483. parallel_for(np,[&](const int p)
  484. {
  485. typename DerivedV::Scalar s,sqrd;
  486. RowVector3S n,c;
  487. int i = -1;
  488. RowVector3S q = P.row(p);
  489. signed_distance_pseudonormal(tree,V,F,FN,VN,EN,EMAP,q,s,sqrd,i,c,n);
  490. S(p) = s*sqrt(sqrd);
  491. I(p) = i;
  492. N.row(p) = n;
  493. C.row(p) = c;
  494. },1000);
  495. }
  496. template <
  497. typename DerivedV,
  498. typename DerivedF,
  499. typename DerivedFN,
  500. typename DerivedVN,
  501. typename DerivedEN,
  502. typename DerivedEMAP,
  503. typename Derivedq,
  504. typename Scalar,
  505. typename Derivedc,
  506. typename Derivedn>
  507. IGL_INLINE void igl::signed_distance_pseudonormal(
  508. const AABB<DerivedV,3> & tree,
  509. const Eigen::MatrixBase<DerivedV> & V,
  510. const Eigen::MatrixBase<DerivedF> & F,
  511. const Eigen::MatrixBase<DerivedFN> & FN,
  512. const Eigen::MatrixBase<DerivedVN> & VN,
  513. const Eigen::MatrixBase<DerivedEN> & EN,
  514. const Eigen::MatrixBase<DerivedEMAP> & EMAP,
  515. const Eigen::MatrixBase<Derivedq> & q,
  516. Scalar & s,
  517. Scalar & sqrd,
  518. int & i,
  519. Eigen::PlainObjectBase<Derivedc> & c,
  520. Eigen::PlainObjectBase<Derivedn> & n)
  521. {
  522. static_assert(
  523. DerivedV::ColsAtCompileTime == 3 || DerivedV::ColsAtCompileTime == Eigen::Dynamic,
  524. "V should have 3 or Dynamic columns");
  525. //typedef Eigen::Matrix<typename DerivedV::Scalar,1,3> RowVector3S;
  526. // Alec: Why was this constructor around q necessary?
  527. //sqrd = tree.squared_distance(V,F,RowVector3S(q),i,(RowVector3S&)c);
  528. // Alec: Why was this constructor around c necessary?
  529. //sqrd = tree.squared_distance(V,F,q,i,(RowVector3S&)c);
  530. sqrd = tree.squared_distance(V,F,q,i,c);
  531. pseudonormal_test(V,F,FN,VN,EN,EMAP,q,i,c,s,n);
  532. }
  533. template <
  534. typename DerivedV,
  535. typename DerivedE,
  536. typename DerivedEN,
  537. typename DerivedVN,
  538. typename Derivedq,
  539. typename Scalar,
  540. typename Derivedc,
  541. typename Derivedn>
  542. IGL_INLINE void igl::signed_distance_pseudonormal(
  543. const AABB<DerivedV,2> & tree,
  544. const Eigen::MatrixBase<DerivedV> & V,
  545. const Eigen::MatrixBase<DerivedE> & E,
  546. const Eigen::MatrixBase<DerivedEN> & EN,
  547. const Eigen::MatrixBase<DerivedVN> & VN,
  548. const Eigen::MatrixBase<Derivedq> & q,
  549. Scalar & s,
  550. Scalar & sqrd,
  551. int & i,
  552. Eigen::PlainObjectBase<Derivedc> & c,
  553. Eigen::PlainObjectBase<Derivedn> & n)
  554. {
  555. static_assert(
  556. DerivedV::ColsAtCompileTime == 2 || DerivedV::ColsAtCompileTime == Eigen::Dynamic,
  557. "V should have 2 or Dynamic columns");
  558. typedef Eigen::Matrix<typename DerivedV::Scalar,1,2> RowVector2S;
  559. sqrd = tree.squared_distance(V,E,RowVector2S(q),i,(RowVector2S&)c);
  560. pseudonormal_test(V,E,EN,VN,q,i,c,s,n);
  561. }
  562. template <
  563. typename DerivedV,
  564. typename DerivedF,
  565. typename Derivedq>
  566. IGL_INLINE typename DerivedV::Scalar igl::signed_distance_winding_number(
  567. const AABB<DerivedV,3> & tree,
  568. const Eigen::MatrixBase<DerivedV> & V,
  569. const Eigen::MatrixBase<DerivedF> & F,
  570. const igl::WindingNumberAABB<typename DerivedV::Scalar,typename DerivedF::Scalar> & hier,
  571. const Eigen::MatrixBase<Derivedq> & q)
  572. {
  573. static_assert(
  574. DerivedV::ColsAtCompileTime == 3 || DerivedV::ColsAtCompileTime == Eigen::Dynamic,
  575. "V should have 3 or Dynamic columns");
  576. typedef typename DerivedV::Scalar Scalar;
  577. Scalar s,sqrd;
  578. Eigen::Matrix<Scalar,1,3> c;
  579. int i=-1;
  580. signed_distance_winding_number(tree,V,F,hier,q,s,sqrd,i,c);
  581. return s*sqrt(sqrd);
  582. }
  583. template <
  584. typename DerivedV,
  585. typename DerivedF,
  586. typename Derivedq,
  587. typename Scalar,
  588. typename Derivedc>
  589. IGL_INLINE void igl::signed_distance_winding_number(
  590. const AABB<DerivedV,3> & tree,
  591. const Eigen::MatrixBase<DerivedV> & V,
  592. const Eigen::MatrixBase<DerivedF> & F,
  593. const igl::WindingNumberAABB<typename DerivedV::Scalar, typename DerivedF::Scalar> & hier,
  594. const Eigen::MatrixBase<Derivedq> & q,
  595. Scalar & s,
  596. Scalar & sqrd,
  597. int & i,
  598. Eigen::PlainObjectBase<Derivedc> & c)
  599. {
  600. static_assert(
  601. DerivedV::ColsAtCompileTime == 3 || DerivedV::ColsAtCompileTime == Eigen::Dynamic,
  602. "V should have 3 or Dynamic columns");
  603. typedef Eigen::Matrix<typename DerivedV::Scalar,1,3> RowVector3S;
  604. sqrd = tree.squared_distance(V,F,RowVector3S(q),i,(RowVector3S&)c);
  605. const Scalar w = hier.winding_number(q.transpose());
  606. s = 1.-2.*w;
  607. }
  608. template <
  609. typename DerivedV,
  610. typename DerivedF,
  611. typename Derivedq,
  612. typename Scalar,
  613. typename Derivedc>
  614. IGL_INLINE void igl::signed_distance_winding_number(
  615. const AABB<DerivedV,2> & tree,
  616. const Eigen::MatrixBase<DerivedV> & V,
  617. const Eigen::MatrixBase<DerivedF> & F,
  618. const Eigen::MatrixBase<Derivedq> & q,
  619. Scalar & s,
  620. Scalar & sqrd,
  621. int & i,
  622. Eigen::PlainObjectBase<Derivedc> & c)
  623. {
  624. static_assert(
  625. DerivedV::ColsAtCompileTime == 2 || DerivedV::ColsAtCompileTime == Eigen::Dynamic,
  626. "V should have 2 or Dynamic columns");
  627. typedef Eigen::Matrix<typename DerivedV::Scalar,1,2> RowVector2S;
  628. sqrd = tree.squared_distance(V,F,RowVector2S(q),i,(RowVector2S&)c);
  629. // TODO: using .data() like this is very dangerous... This is assuming
  630. // colmajor order
  631. assert(!V.derived().IsRowMajor);
  632. assert(!F.derived().IsRowMajor);
  633. s = 1.-2.*winding_number(V,F,q);
  634. }
  635. //Multi point by parrallel for on single point
  636. template <
  637. typename DerivedP,
  638. typename DerivedV,
  639. typename DerivedF,
  640. typename DerivedS>
  641. IGL_INLINE void igl::signed_distance_fast_winding_number(
  642. const Eigen::MatrixBase<DerivedP> & P,
  643. const Eigen::MatrixBase<DerivedV> & V,
  644. const Eigen::MatrixBase<DerivedF> & F,
  645. const AABB<DerivedV,3> & tree,
  646. const igl::FastWindingNumberBVH & fwn_bvh,
  647. Eigen::PlainObjectBase<DerivedS> & S)
  648. {
  649. static_assert(
  650. DerivedP::ColsAtCompileTime == 3 || DerivedP::ColsAtCompileTime == Eigen::Dynamic,
  651. "P should have 3 or Dynamic columns");
  652. typedef Eigen::Matrix<typename DerivedV::Scalar,1,3> RowVector3S;
  653. S.resize(P.rows(),1);
  654. int min_parallel = 10000;
  655. parallel_for(P.rows(), [&](const int p)
  656. {
  657. RowVector3S q;
  658. q.head(P.row(p).size()) = P.row(p);
  659. // get sdf for single point, update result matrix
  660. S(p) = signed_distance_fast_winding_number(q, V, F, tree,fwn_bvh);
  661. }
  662. ,min_parallel);
  663. }
  664. //Single Point
  665. template <
  666. typename Derivedq,
  667. typename DerivedV,
  668. typename DerivedF>
  669. IGL_INLINE typename DerivedV::Scalar igl::signed_distance_fast_winding_number(
  670. const Eigen::MatrixBase<Derivedq> & q,
  671. const Eigen::MatrixBase<DerivedV> & V,
  672. const Eigen::MatrixBase<DerivedF> & F,
  673. const AABB<DerivedV,3> & tree,
  674. const igl::FastWindingNumberBVH & fwn_bvh)
  675. {
  676. static_assert(
  677. DerivedV::ColsAtCompileTime == 3 || DerivedV::ColsAtCompileTime == Eigen::Dynamic,
  678. "V should have 3 or Dynamic columns");
  679. typedef typename DerivedV::Scalar Scalar;
  680. Scalar sqrd;
  681. Eigen::Matrix<Scalar,1,3> c;
  682. int i = -1;
  683. sqrd = tree.squared_distance(V,F,q,i,c);
  684. Scalar w = fast_winding_number(fwn_bvh,2,q.template cast<float>());
  685. //0.5 is on surface
  686. return sqrt(sqrd)*(1.-2.*std::abs(w));
  687. }
  688. #ifdef IGL_STATIC_LIBRARY
  689. // Explicit template instantiation
  690. template void igl::signed_distance<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, igl::SignedDistanceType, Eigen::Matrix<double, -1, -1, 0, -1, -1>::Scalar, Eigen::Matrix<double, -1, -1, 0, -1, -1>::Scalar, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
  691. // generated by autoexplicit.sh
  692. template void igl::signed_distance<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, igl::SignedDistanceType, Eigen::Matrix<double, -1, 3, 0, -1, 3>::Scalar, Eigen::Matrix<double, -1, 3, 0, -1, 3>::Scalar, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&);
  693. // generated by autoexplicit.sh
  694. template void igl::signed_distance<Eigen::Matrix<double, -1, 2, 0, -1, 2>, Eigen::Matrix<double, -1, 2, 0, -1, 2>, Eigen::Matrix<int, -1, 2, 0, -1, 2>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 2, 0, -1, 2>, Eigen::Matrix<double, -1, 2, 0, -1, 2> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 2, 0, -1, 2> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 2, 0, -1, 2> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> > const&, igl::SignedDistanceType, Eigen::Matrix<double, -1, 2, 0, -1, 2>::Scalar, Eigen::Matrix<double, -1, 2, 0, -1, 2>::Scalar, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 2, 0, -1, 2> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 2, 0, -1, 2> >&);
  695. // generated by autoexplicit.sh
  696. template void igl::signed_distance<Eigen::Matrix<float, -1, 3, 0, -1, 3>, Eigen::Matrix<float, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<float, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<float, -1, 3, 0, -1, 3>, Eigen::Matrix<float, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, igl::SignedDistanceType, Eigen::Matrix<float, -1, 3, 0, -1, 3>::Scalar, Eigen::Matrix<float, -1, 3, 0, -1, 3>::Scalar, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> >&);
  697. // generated by autoexplicit.sh
  698. template void igl::signed_distance<Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 3, 1, -1, 3>, Eigen::Matrix<float, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<float, -1, 3, 0, -1, 3>, Eigen::Matrix<float, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&, igl::SignedDistanceType, Eigen::Matrix<float, -1, 3, 1, -1, 3>::Scalar, Eigen::Matrix<float, -1, 3, 1, -1, 3>::Scalar, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> >&);
  699. template void igl::signed_distance<Eigen::Matrix<float, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 3, 1, -1, 3>, Eigen::Matrix<float, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<float, -1, 3, 0, -1, 3>, Eigen::Matrix<float, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&, igl::SignedDistanceType, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> >&);
  700. template void igl::signed_distance_pseudonormal<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, 1, 3, 1, 1, 3>, double, Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, 1, 3, 1, 1, 3> >(igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, double&, double&, int&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> >&);
  701. template void igl::signed_distance<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, igl::SignedDistanceType, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&);
  702. template Eigen::Matrix<double, -1, -1, 0, -1, -1>::Scalar igl::signed_distance_pseudonormal<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, 1, 3, 1, 1, 3> >(igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&);
  703. template void igl::signed_distance_pseudonormal<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
  704. template void igl::signed_distance<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, igl::SignedDistanceType, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
  705. template void igl::signed_distance_fast_winding_number<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>>(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1>> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1>> const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1>> const&, igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3> const&, igl::FastWindingNumberBVH const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1>>&);
  706. #endif