AABB.cpp 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 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 "AABB.h"
  9. #include "EPS.h"
  10. #include "barycenter.h"
  11. #include "colon.h"
  12. #include "doublearea.h"
  13. #include "point_simplex_squared_distance.h"
  14. #include "project_to_line_segment.h"
  15. #include "sort.h"
  16. #include "volume.h"
  17. #include "ray_box_intersect.h"
  18. #include "parallel_for.h"
  19. #include "ray_mesh_intersect.h"
  20. #include <iostream>
  21. #include <iomanip>
  22. #include <limits>
  23. #include <list>
  24. #include <queue>
  25. #include <stack>
  26. template <typename DerivedV, int DIM>
  27. template <typename DerivedEle, typename Derivedbb_mins, typename Derivedbb_maxs, typename Derivedelements>
  28. IGL_INLINE void igl::AABB<DerivedV,DIM>::init(
  29. const Eigen::MatrixBase<DerivedV> & V,
  30. const Eigen::MatrixBase<DerivedEle> & Ele,
  31. const Eigen::MatrixBase<Derivedbb_mins> & bb_mins,
  32. const Eigen::MatrixBase<Derivedbb_maxs> & bb_maxs,
  33. const Eigen::MatrixBase<Derivedelements> & elements,
  34. const int i)
  35. {
  36. using namespace std;
  37. using namespace Eigen;
  38. deinit();
  39. if(bb_mins.size() > 0)
  40. {
  41. assert(bb_mins.rows() == bb_maxs.rows() && "Serial tree arrays must match");
  42. assert(bb_mins.cols() == V.cols() && "Serial tree array dim must match V");
  43. assert(bb_mins.cols() == bb_maxs.cols() && "Serial tree arrays must match");
  44. assert(bb_mins.rows() == elements.rows() &&
  45. "Serial tree arrays must match");
  46. // construct from serialization
  47. m_box.extend(bb_mins.row(i).transpose());
  48. m_box.extend(bb_maxs.row(i).transpose());
  49. m_primitive = elements(i);
  50. // Not leaf then recurse
  51. if(m_primitive == -1)
  52. {
  53. m_left = new AABB();
  54. m_left->init( V,Ele,bb_mins,bb_maxs,elements,2*i+1);
  55. m_right = new AABB();
  56. m_right->init( V,Ele,bb_mins,bb_maxs,elements,2*i+2);
  57. //m_depth = std::max( m_left->m_depth, m_right->m_depth)+1;
  58. }
  59. }else
  60. {
  61. VectorXi allI = colon<int>(0,Ele.rows()-1);
  62. MatrixXDIMS BC;
  63. if(Ele.cols() == 1)
  64. {
  65. // points
  66. BC = V;
  67. }else
  68. {
  69. // Simplices
  70. barycenter(V,Ele,BC);
  71. }
  72. MatrixXi SI(BC.rows(),BC.cols());
  73. {
  74. MatrixXDIMS _;
  75. MatrixXi IS;
  76. igl::sort(BC,1,true,_,IS);
  77. // Need SI(i) to tell which place i would be sorted into
  78. const int dim = IS.cols();
  79. for(int i = 0;i<IS.rows();i++)
  80. {
  81. for(int d = 0;d<dim;d++)
  82. {
  83. SI(IS(i,d),d) = i;
  84. }
  85. }
  86. }
  87. init(V,Ele,SI,allI);
  88. }
  89. }
  90. template <typename DerivedV, int DIM>
  91. template <typename DerivedEle>
  92. void igl::AABB<DerivedV,DIM>::init(
  93. const Eigen::MatrixBase<DerivedV> & V,
  94. const Eigen::MatrixBase<DerivedEle> & Ele)
  95. {
  96. using namespace Eigen;
  97. // deinit will be immediately called...
  98. return init(V,Ele,MatrixXDIMS(),MatrixXDIMS(),VectorXi(),0);
  99. }
  100. template <typename DerivedV, int DIM>
  101. template <
  102. typename DerivedEle,
  103. typename DerivedSI,
  104. typename DerivedI>
  105. IGL_INLINE void igl::AABB<DerivedV,DIM>::init(
  106. const Eigen::MatrixBase<DerivedV> & V,
  107. const Eigen::MatrixBase<DerivedEle> & Ele,
  108. const Eigen::MatrixBase<DerivedSI> & SI,
  109. const Eigen::MatrixBase<DerivedI> & I)
  110. {
  111. using namespace Eigen;
  112. using namespace std;
  113. deinit();
  114. if(V.size() == 0 || Ele.size() == 0 || I.size() == 0)
  115. {
  116. return;
  117. }
  118. assert(DIM == V.cols() && "V.cols() should matched declared dimension");
  119. //const Scalar inf = numeric_limits<Scalar>::infinity();
  120. m_box = AlignedBox<Scalar,DIM>();
  121. // Compute bounding box
  122. for(int i = 0;i<I.rows();i++)
  123. {
  124. for(int c = 0;c<Ele.cols();c++)
  125. {
  126. m_box.extend(V.row(Ele(I(i),c)).transpose());
  127. m_box.extend(V.row(Ele(I(i),c)).transpose());
  128. }
  129. }
  130. switch(I.size())
  131. {
  132. case 0:
  133. {
  134. assert(false);
  135. }
  136. case 1:
  137. {
  138. m_primitive = I(0);
  139. break;
  140. }
  141. default:
  142. {
  143. // Compute longest direction
  144. int max_d = -1;
  145. m_box.diagonal().maxCoeff(&max_d);
  146. // Can't use median on BC directly because many may have same value,
  147. // but can use median on sorted BC indices
  148. VectorXi SIdI(I.rows());
  149. for(int i = 0;i<I.rows();i++)
  150. {
  151. SIdI(i) = SI(I(i),max_d);
  152. }
  153. // Pass by copy to avoid changing input
  154. const auto median = [](VectorXi A)->int
  155. {
  156. size_t n = (A.size()-1)/2;
  157. nth_element(A.data(),A.data()+n,A.data()+A.size());
  158. return A(n);
  159. };
  160. const int med = median(SIdI);
  161. VectorXi LI((I.rows()+1)/2),RI(I.rows()/2);
  162. assert(LI.rows()+RI.rows() == I.rows());
  163. // Distribute left and right
  164. {
  165. int li = 0;
  166. int ri = 0;
  167. for(int i = 0;i<I.rows();i++)
  168. {
  169. if(SIdI(i)<=med)
  170. {
  171. LI(li++) = I(i);
  172. }else
  173. {
  174. RI(ri++) = I(i);
  175. }
  176. }
  177. }
  178. //m_depth = 0;
  179. if(LI.rows()>0)
  180. {
  181. m_left = new AABB();
  182. m_left->init(V,Ele,SI,LI);
  183. //m_depth = std::max(m_depth, m_left->m_depth+1);
  184. }
  185. if(RI.rows()>0)
  186. {
  187. m_right = new AABB();
  188. m_right->init(V,Ele,SI,RI);
  189. //m_depth = std::max(m_depth, m_right->m_depth+1);
  190. }
  191. }
  192. }
  193. }
  194. template <typename DerivedV, int DIM>
  195. IGL_INLINE bool igl::AABB<DerivedV,DIM>::is_leaf() const
  196. {
  197. return m_primitive != -1;
  198. }
  199. template <typename DerivedV, int DIM>
  200. template <typename DerivedEle, typename Derivedq>
  201. IGL_INLINE std::vector<int> igl::AABB<DerivedV,DIM>::find(
  202. const Eigen::MatrixBase<DerivedV> & V,
  203. const Eigen::MatrixBase<DerivedEle> & Ele,
  204. const Eigen::MatrixBase<Derivedq> & q,
  205. const bool first) const
  206. {
  207. using namespace std;
  208. using namespace Eigen;
  209. assert(q.size() == DIM &&
  210. "Query dimension should match aabb dimension");
  211. assert(Ele.cols() == V.cols()+1 &&
  212. "AABB::find only makes sense for (d+1)-simplices");
  213. const Scalar epsilon = igl::EPS<Scalar>();
  214. // Check if outside bounding box
  215. bool inside = m_box.contains(q.transpose());
  216. if(!inside)
  217. {
  218. return std::vector<int>();
  219. }
  220. assert(m_primitive==-1 || (m_left == NULL && m_right == NULL));
  221. if(is_leaf())
  222. {
  223. // Initialize to some value > -epsilon
  224. Scalar a1=0,a2=0,a3=0,a4=0;
  225. switch(DIM)
  226. {
  227. case 3:
  228. {
  229. // Barycentric coordinates
  230. typedef Eigen::Matrix<Scalar,1,3> RowVector3S;
  231. const RowVector3S V1 = V.row(Ele(m_primitive,0));
  232. const RowVector3S V2 = V.row(Ele(m_primitive,1));
  233. const RowVector3S V3 = V.row(Ele(m_primitive,2));
  234. const RowVector3S V4 = V.row(Ele(m_primitive,3));
  235. a1 = volume_single(V2,V4,V3,(RowVector3S)q);
  236. a2 = volume_single(V1,V3,V4,(RowVector3S)q);
  237. a3 = volume_single(V1,V4,V2,(RowVector3S)q);
  238. a4 = volume_single(V1,V2,V3,(RowVector3S)q);
  239. break;
  240. }
  241. case 2:
  242. {
  243. // Barycentric coordinates
  244. typedef Eigen::Matrix<Scalar,2,1> Vector2S;
  245. const Vector2S V1 = V.row(Ele(m_primitive,0));
  246. const Vector2S V2 = V.row(Ele(m_primitive,1));
  247. const Vector2S V3 = V.row(Ele(m_primitive,2));
  248. // Hack for now to keep templates simple. If becomes bottleneck
  249. // consider using std::enable_if_t
  250. const Vector2S q2 = q.head(2);
  251. a1 = doublearea_single(V1,V2,q2);
  252. a2 = doublearea_single(V2,V3,q2);
  253. a3 = doublearea_single(V3,V1,q2);
  254. break;
  255. }
  256. default:assert(false);
  257. }
  258. // Normalization is important for correcting sign
  259. Scalar sum = a1+a2+a3+a4;
  260. a1 /= sum;
  261. a2 /= sum;
  262. a3 /= sum;
  263. a4 /= sum;
  264. if(
  265. a1>=-epsilon &&
  266. a2>=-epsilon &&
  267. a3>=-epsilon &&
  268. a4>=-epsilon)
  269. {
  270. return std::vector<int>(1,m_primitive);
  271. }else
  272. {
  273. return std::vector<int>();
  274. }
  275. }
  276. std::vector<int> left = m_left->find(V,Ele,q,first);
  277. if(first && !left.empty())
  278. {
  279. return left;
  280. }
  281. std::vector<int> right = m_right->find(V,Ele,q,first);
  282. if(first)
  283. {
  284. return right;
  285. }
  286. left.insert(left.end(),right.begin(),right.end());
  287. return left;
  288. }
  289. template <typename DerivedV, int DIM>
  290. IGL_INLINE int igl::AABB<DerivedV,DIM>::subtree_size() const
  291. {
  292. // 1 for self
  293. int n = 1;
  294. int n_left = 0,n_right = 0;
  295. if(m_left != NULL)
  296. {
  297. n_left = m_left->subtree_size();
  298. }
  299. if(m_right != NULL)
  300. {
  301. n_right = m_right->subtree_size();
  302. }
  303. n += 2*std::max(n_left,n_right);
  304. return n;
  305. }
  306. template <typename DerivedV, int DIM>
  307. template <typename Derivedbb_mins, typename Derivedbb_maxs, typename Derivedelements>
  308. IGL_INLINE void igl::AABB<DerivedV,DIM>::serialize(
  309. Eigen::PlainObjectBase<Derivedbb_mins> & bb_mins,
  310. Eigen::PlainObjectBase<Derivedbb_maxs> & bb_maxs,
  311. Eigen::PlainObjectBase<Derivedelements> & elements,
  312. const int i) const
  313. {
  314. using namespace std;
  315. using namespace Eigen;
  316. // Calling for root then resize output
  317. if(i==0)
  318. {
  319. const int m = subtree_size();
  320. //cout<<"m: "<<m<<endl;
  321. bb_mins.resize(m,DIM);
  322. bb_maxs.resize(m,DIM);
  323. elements.resize(m,1);
  324. }
  325. //cout<<i<<" ";
  326. bb_mins.row(i) = m_box.min();
  327. bb_maxs.row(i) = m_box.max();
  328. elements(i) = m_primitive;
  329. if(m_left != NULL)
  330. {
  331. m_left->serialize(bb_mins,bb_maxs,elements,2*i+1);
  332. }
  333. if(m_right != NULL)
  334. {
  335. m_right->serialize(bb_mins,bb_maxs,elements,2*i+2);
  336. }
  337. }
  338. template <typename DerivedV, int DIM>
  339. template <typename DerivedEle>
  340. IGL_INLINE typename igl::AABB<DerivedV,DIM>::Scalar
  341. igl::AABB<DerivedV,DIM>::squared_distance(
  342. const Eigen::MatrixBase<DerivedV> & V,
  343. const Eigen::MatrixBase<DerivedEle> & Ele,
  344. const RowVectorDIMS & p,
  345. int & i,
  346. Eigen::PlainObjectBase<RowVectorDIMS> & c) const
  347. {
  348. return squared_distance(V,Ele,p,std::numeric_limits<Scalar>::infinity(),i,c);
  349. }
  350. template <typename DerivedV, int DIM>
  351. template <typename DerivedEle>
  352. IGL_INLINE typename igl::AABB<DerivedV,DIM>::Scalar
  353. igl::AABB<DerivedV,DIM>::squared_distance(
  354. const Eigen::MatrixBase<DerivedV> & V,
  355. const Eigen::MatrixBase<DerivedEle> & Ele,
  356. const RowVectorDIMS & p,
  357. Scalar low_sqr_d,
  358. Scalar up_sqr_d,
  359. int & i,
  360. Eigen::PlainObjectBase<RowVectorDIMS> & c) const
  361. {
  362. using namespace Eigen;
  363. using namespace std;
  364. //assert(low_sqr_d <= up_sqr_d);
  365. if(low_sqr_d > up_sqr_d)
  366. {
  367. return low_sqr_d;
  368. }
  369. Scalar sqr_d = up_sqr_d;
  370. //assert(DIM == 3 && "Code has only been tested for DIM == 3");
  371. assert((Ele.cols() == 3 || Ele.cols() == 2 || Ele.cols() == 1)
  372. && "Code has only been tested for simplex sizes 3,2,1");
  373. assert(m_primitive==-1 || (m_left == NULL && m_right == NULL));
  374. if(is_leaf())
  375. {
  376. leaf_squared_distance(V,Ele,p,low_sqr_d,sqr_d,i,c);
  377. }else
  378. {
  379. bool looked_left = false;
  380. bool looked_right = false;
  381. const auto & look_left = [&]()
  382. {
  383. int i_left;
  384. RowVectorDIMS c_left = c;
  385. Scalar sqr_d_left =
  386. m_left->squared_distance(V,Ele,p,low_sqr_d,sqr_d,i_left,c_left);
  387. this->set_min(p,sqr_d_left,i_left,c_left,sqr_d,i,c);
  388. looked_left = true;
  389. };
  390. const auto & look_right = [&]()
  391. {
  392. int i_right;
  393. RowVectorDIMS c_right = c;
  394. Scalar sqr_d_right =
  395. m_right->squared_distance(V,Ele,p,low_sqr_d,sqr_d,i_right,c_right);
  396. this->set_min(p,sqr_d_right,i_right,c_right,sqr_d,i,c);
  397. looked_right = true;
  398. };
  399. // must look left or right if in box
  400. if(m_left->m_box.contains(p.transpose()))
  401. {
  402. look_left();
  403. }
  404. if(m_right->m_box.contains(p.transpose()))
  405. {
  406. look_right();
  407. }
  408. // if haven't looked left and could be less than current min, then look
  409. Scalar left_up_sqr_d =
  410. m_left->m_box.squaredExteriorDistance(p.transpose());
  411. Scalar right_up_sqr_d =
  412. m_right->m_box.squaredExteriorDistance(p.transpose());
  413. if(left_up_sqr_d < right_up_sqr_d)
  414. {
  415. if(!looked_left && left_up_sqr_d<sqr_d)
  416. {
  417. look_left();
  418. }
  419. if( !looked_right && right_up_sqr_d<sqr_d)
  420. {
  421. look_right();
  422. }
  423. }else
  424. {
  425. if( !looked_right && right_up_sqr_d<sqr_d)
  426. {
  427. look_right();
  428. }
  429. if(!looked_left && left_up_sqr_d<sqr_d)
  430. {
  431. look_left();
  432. }
  433. }
  434. }
  435. return sqr_d;
  436. }
  437. template <typename DerivedV, int DIM>
  438. template <typename DerivedEle>
  439. IGL_INLINE typename igl::AABB<DerivedV,DIM>::Scalar
  440. igl::AABB<DerivedV,DIM>::squared_distance(
  441. const Eigen::MatrixBase<DerivedV> & V,
  442. const Eigen::MatrixBase<DerivedEle> & Ele,
  443. const RowVectorDIMS & p,
  444. Scalar up_sqr_d,
  445. int & i,
  446. Eigen::PlainObjectBase<RowVectorDIMS> & c) const
  447. {
  448. return squared_distance(V,Ele,p,0.0,up_sqr_d,i,c);
  449. }
  450. template <typename DerivedV, int DIM>
  451. template <
  452. typename DerivedEle,
  453. typename DerivedP,
  454. typename DerivedsqrD,
  455. typename DerivedI,
  456. typename DerivedC>
  457. IGL_INLINE void igl::AABB<DerivedV,DIM>::squared_distance(
  458. const Eigen::MatrixBase<DerivedV> & V,
  459. const Eigen::MatrixBase<DerivedEle> & Ele,
  460. const Eigen::MatrixBase<DerivedP> & P,
  461. Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
  462. Eigen::PlainObjectBase<DerivedI> & I,
  463. Eigen::PlainObjectBase<DerivedC> & C) const
  464. {
  465. assert(P.cols() == V.cols() && "cols in P should match dim of cols in V");
  466. sqrD.resize(P.rows(),1);
  467. I.resize(P.rows(),1);
  468. C.resizeLike(P);
  469. // O( #P * log #Ele ), where log #Ele is really the depth of this AABB
  470. // hierarchy
  471. //for(int p = 0;p<P.rows();p++)
  472. igl::parallel_for(P.rows(),[&](int p)
  473. {
  474. RowVectorDIMS Pp = P.row(p), c;
  475. int Ip;
  476. sqrD(p) = squared_distance(V,Ele,Pp,Ip,c);
  477. I(p) = Ip;
  478. C.row(p).head(DIM) = c;
  479. },
  480. 10000);
  481. }
  482. template <typename DerivedV, int DIM>
  483. template <
  484. typename DerivedEle,
  485. typename Derivedother_V,
  486. typename Derivedother_Ele,
  487. typename DerivedsqrD,
  488. typename DerivedI,
  489. typename DerivedC>
  490. IGL_INLINE void igl::AABB<DerivedV,DIM>::squared_distance(
  491. const Eigen::MatrixBase<DerivedV> & V,
  492. const Eigen::MatrixBase<DerivedEle> & Ele,
  493. const AABB<Derivedother_V,DIM> & other,
  494. const Eigen::MatrixBase<Derivedother_V> & other_V,
  495. const Eigen::MatrixBase<Derivedother_Ele> & other_Ele,
  496. Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
  497. Eigen::PlainObjectBase<DerivedI> & I,
  498. Eigen::PlainObjectBase<DerivedC> & C) const
  499. {
  500. assert(other_Ele.cols() == 1 &&
  501. "Only implemented for other as list of points");
  502. assert(other_V.cols() == V.cols() && "other must match this dimension");
  503. sqrD.setConstant(other_Ele.rows(),1,std::numeric_limits<double>::infinity());
  504. I.resize(other_Ele.rows(),1);
  505. C.resize(other_Ele.rows(),other_V.cols());
  506. // All points in other_V currently think they need to check against root of
  507. // this. The point of using another AABB is to quickly prune chunks of
  508. // other_V so that most points just check some subtree of this.
  509. // This holds a conservative estimate of max(sqr_D) where sqr_D is the
  510. // current best minimum squared distance for all points in this subtree
  511. double up_sqr_d = std::numeric_limits<double>::infinity();
  512. squared_distance_helper(
  513. V,Ele,&other,other_V,other_Ele,0,up_sqr_d,sqrD,I,C);
  514. }
  515. template <typename DerivedV, int DIM>
  516. template <
  517. typename DerivedEle,
  518. typename Derivedother_V,
  519. typename Derivedother_Ele,
  520. typename DerivedsqrD,
  521. typename DerivedI,
  522. typename DerivedC>
  523. IGL_INLINE typename igl::AABB<DerivedV,DIM>::Scalar
  524. igl::AABB<DerivedV,DIM>::squared_distance_helper(
  525. const Eigen::MatrixBase<DerivedV> & V,
  526. const Eigen::MatrixBase<DerivedEle> & Ele,
  527. const AABB<Derivedother_V,DIM> * other,
  528. const Eigen::MatrixBase<Derivedother_V> & other_V,
  529. const Eigen::MatrixBase<Derivedother_Ele> & other_Ele,
  530. const Scalar /*up_sqr_d*/,
  531. Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
  532. Eigen::PlainObjectBase<DerivedI> & I,
  533. Eigen::PlainObjectBase<DerivedC> & C) const
  534. {
  535. using namespace std;
  536. using namespace Eigen;
  537. // This implementation is a bit disappointing. There's no major speed up. Any
  538. // performance gains seem to come from accidental cache coherency and
  539. // diminish for larger "other" (the opposite of what was intended).
  540. // Base case
  541. if(other->is_leaf() && this->is_leaf())
  542. {
  543. Scalar sqr_d = sqrD(other->m_primitive);
  544. int i = I(other->m_primitive);
  545. RowVectorDIMS c = C.row( other->m_primitive);
  546. RowVectorDIMS p = other_V.row(other->m_primitive);
  547. leaf_squared_distance(V,Ele,p,sqr_d,i,c);
  548. sqrD( other->m_primitive) = sqr_d;
  549. I( other->m_primitive) = i;
  550. C.row(other->m_primitive) = c;
  551. //cout<<"leaf: "<<sqr_d<<endl;
  552. //other->m_low_sqr_d = sqr_d;
  553. return sqr_d;
  554. }
  555. if(other->is_leaf())
  556. {
  557. Scalar sqr_d = sqrD(other->m_primitive);
  558. int i = I(other->m_primitive);
  559. RowVectorDIMS c = C.row( other->m_primitive);
  560. RowVectorDIMS p = other_V.row(other->m_primitive);
  561. sqr_d = squared_distance(V,Ele,p,sqr_d,i,c);
  562. sqrD( other->m_primitive) = sqr_d;
  563. I( other->m_primitive) = i;
  564. C.row(other->m_primitive) = c;
  565. //other->m_low_sqr_d = sqr_d;
  566. return sqr_d;
  567. }
  568. //// Exact minimum squared distance between arbitrary primitives inside this and
  569. //// othre's bounding boxes
  570. //const auto & min_squared_distance = [&](
  571. // const AABB<DerivedV,DIM> * A,
  572. // const AABB<Derivedother_V,DIM> * B)->Scalar
  573. //{
  574. // return A->m_box.squaredExteriorDistance(B->m_box);
  575. //};
  576. if(this->is_leaf())
  577. {
  578. //if(min_squared_distance(this,other) < other->m_low_sqr_d)
  579. if(true)
  580. {
  581. this->squared_distance_helper(
  582. V,Ele,other->m_left,other_V,other_Ele,0,sqrD,I,C);
  583. this->squared_distance_helper(
  584. V,Ele,other->m_right,other_V,other_Ele,0,sqrD,I,C);
  585. }else
  586. {
  587. // This is never reached...
  588. }
  589. //// we know other is not a leaf
  590. //other->m_low_sqr_d = std::max(other->m_left->m_low_sqr_d,other->m_right->m_low_sqr_d);
  591. return 0;
  592. }
  593. // FORCE DOWN TO OTHER LEAF EVAL
  594. //if(min_squared_distance(this,other) < other->m_low_sqr_d)
  595. if(true)
  596. {
  597. if(true)
  598. {
  599. this->squared_distance_helper(
  600. V,Ele,other->m_left,other_V,other_Ele,0,sqrD,I,C);
  601. this->squared_distance_helper(
  602. V,Ele,other->m_right,other_V,other_Ele,0,sqrD,I,C);
  603. }else // this direction never seems to be faster
  604. {
  605. this->m_left->squared_distance_helper(
  606. V,Ele,other,other_V,other_Ele,0,sqrD,I,C);
  607. this->m_right->squared_distance_helper(
  608. V,Ele,other,other_V,other_Ele,0,sqrD,I,C);
  609. }
  610. }else
  611. {
  612. // this is never reached ... :-(
  613. }
  614. //// we know other is not a leaf
  615. //other->m_low_sqr_d = std::max(other->m_left->m_low_sqr_d,other->m_right->m_low_sqr_d);
  616. return 0;
  617. #if 0 // False
  618. // _Very_ conservative approximation of maximum squared distance between
  619. // primitives inside this and other's bounding boxes
  620. const auto & max_squared_distance = [](
  621. const AABB<DerivedV,DIM> * A,
  622. const AABB<Derivedother_V,DIM> * B)->Scalar
  623. {
  624. AlignedBox<Scalar,DIM> combo = A->m_box;
  625. combo.extend(B->m_box);
  626. return combo.diagonal().squaredNorm();
  627. };
  628. //// other base-case
  629. //if(other->is_leaf())
  630. //{
  631. // double sqr_d = sqrD(other->m_primitive);
  632. // int i = I(other->m_primitive);
  633. // RowVectorDIMS c = C.row(m_primitive);
  634. // RowVectorDIMS p = other_V.row(m_primitive);
  635. // leaf_squared_distance(V,Ele,p,sqr_d,i,c);
  636. // sqrD(other->m_primitive) = sqr_d;
  637. // I(other->m_primitive) = i;
  638. // C.row(m_primitive) = c;
  639. // return;
  640. //}
  641. std::vector<const AABB<DerivedV,DIM> * > this_list;
  642. if(this->is_leaf())
  643. {
  644. this_list.push_back(this);
  645. }else
  646. {
  647. assert(this->m_left);
  648. this_list.push_back(this->m_left);
  649. assert(this->m_right);
  650. this_list.push_back(this->m_right);
  651. }
  652. std::vector<AABB<Derivedother_V,DIM> *> other_list;
  653. if(other->is_leaf())
  654. {
  655. other_list.push_back(other);
  656. }else
  657. {
  658. assert(other->m_left);
  659. other_list.push_back(other->m_left);
  660. assert(other->m_right);
  661. other_list.push_back(other->m_right);
  662. }
  663. //const std::function<Scalar(
  664. // const AABB<Derivedother_V,DIM> * other)
  665. // > low_sqr_d = [&sqrD,&low_sqr_d](const AABB<Derivedother_V,DIM> * other)->Scalar
  666. // {
  667. // if(other->is_leaf())
  668. // {
  669. // return sqrD(other->m_primitive);
  670. // }else
  671. // {
  672. // return std::max(low_sqr_d(other->m_left),low_sqr_d(other->m_right));
  673. // }
  674. // };
  675. //// Potentially recurse on all pairs, if minimum distance is less than running
  676. //// bound
  677. //Eigen::Matrix<Scalar,Eigen::Dynamic,1> other_low_sqr_d =
  678. // Eigen::Matrix<Scalar,Eigen::Dynamic,1>::Constant(other_list.size(),1,up_sqr_d);
  679. for(size_t child = 0;child<other_list.size();child++)
  680. {
  681. auto other_tree = other_list[child];
  682. Eigen::Matrix<Scalar,Eigen::Dynamic,1> this_low_sqr_d(this_list.size(),1);
  683. for(size_t t = 0;t<this_list.size();t++)
  684. {
  685. const auto this_tree = this_list[t];
  686. this_low_sqr_d(t) = max_squared_distance(this_tree,other_tree);
  687. }
  688. if(this_list.size() ==2 &&
  689. ( this_low_sqr_d(0) > this_low_sqr_d(1))
  690. )
  691. {
  692. std::swap(this_list[0],this_list[1]);
  693. //std::swap(this_low_sqr_d(0),this_low_sqr_d(1));
  694. }
  695. const Scalar sqr_d = this_low_sqr_d.minCoeff();
  696. for(size_t t = 0;t<this_list.size();t++)
  697. {
  698. const auto this_tree = this_list[t];
  699. //const auto mm = low_sqr_d(other_tree);
  700. //const Scalar mc = other_low_sqr_d(child);
  701. //assert(mc == mm);
  702. // Only look left/right in this_list if can possible decrease somebody's
  703. // distance in this_tree.
  704. const Scalar min_this_other = min_squared_distance(this_tree,other_tree);
  705. if(
  706. min_this_other < sqr_d &&
  707. min_this_other < other_tree->m_low_sqr_d)
  708. {
  709. //cout<<"before: "<<other_low_sqr_d(child)<<endl;
  710. //other_low_sqr_d(child) = std::min(
  711. // other_low_sqr_d(child),
  712. // this_tree->squared_distance_helper(
  713. // V,Ele,other_tree,other_V,other_Ele,other_low_sqr_d(child),sqrD,I,C));
  714. //cout<<"after: "<<other_low_sqr_d(child)<<endl;
  715. this_tree->squared_distance_helper(
  716. V,Ele,other_tree,other_V,other_Ele,0,sqrD,I,C);
  717. }
  718. }
  719. }
  720. //const Scalar ret = other_low_sqr_d.maxCoeff();
  721. //const auto mm = low_sqr_d(other);
  722. //assert(mm == ret);
  723. //cout<<"non-leaf: "<<ret<<endl;
  724. //return ret;
  725. if(!other->is_leaf())
  726. {
  727. other->m_low_sqr_d = std::max(other->m_left->m_low_sqr_d,other->m_right->m_low_sqr_d);
  728. }
  729. return 0;
  730. #endif
  731. }
  732. template <typename DerivedV, int DIM>
  733. template <typename DerivedEle>
  734. IGL_INLINE void igl::AABB<DerivedV,DIM>::leaf_squared_distance(
  735. const Eigen::MatrixBase<DerivedV> & V,
  736. const Eigen::MatrixBase<DerivedEle> & Ele,
  737. const RowVectorDIMS & p,
  738. const Scalar low_sqr_d,
  739. Scalar & sqr_d,
  740. int & i,
  741. Eigen::PlainObjectBase<RowVectorDIMS> & c) const
  742. {
  743. using namespace Eigen;
  744. using namespace std;
  745. if(low_sqr_d > sqr_d)
  746. {
  747. sqr_d = low_sqr_d;
  748. return;
  749. }
  750. RowVectorDIMS c_candidate;
  751. Scalar sqr_d_candidate;
  752. igl::point_simplex_squared_distance<DIM>(
  753. p,V,Ele,m_primitive,sqr_d_candidate,c_candidate);
  754. set_min(p,sqr_d_candidate,m_primitive,c_candidate,sqr_d,i,c);
  755. }
  756. template <typename DerivedV, int DIM>
  757. template <typename DerivedEle>
  758. IGL_INLINE void igl::AABB<DerivedV,DIM>::leaf_squared_distance(
  759. const Eigen::MatrixBase<DerivedV> & V,
  760. const Eigen::MatrixBase<DerivedEle> & Ele,
  761. const RowVectorDIMS & p,
  762. Scalar & sqr_d,
  763. int & i,
  764. Eigen::PlainObjectBase<RowVectorDIMS> & c) const
  765. {
  766. return leaf_squared_distance(V,Ele,p,0,sqr_d,i,c);
  767. }
  768. template <typename DerivedV, int DIM>
  769. IGL_INLINE void igl::AABB<DerivedV,DIM>::set_min(
  770. const RowVectorDIMS & /* p */,
  771. const Scalar sqr_d_candidate,
  772. const int i_candidate,
  773. const RowVectorDIMS & c_candidate,
  774. Scalar & sqr_d,
  775. int & i,
  776. Eigen::PlainObjectBase<RowVectorDIMS> & c) const
  777. {
  778. if(sqr_d_candidate < sqr_d)
  779. {
  780. i = i_candidate;
  781. c = c_candidate;
  782. sqr_d = sqr_d_candidate;
  783. }
  784. }
  785. template <typename DerivedV, int DIM>
  786. template <typename DerivedEle>
  787. IGL_INLINE bool
  788. igl::AABB<DerivedV,DIM>::intersect_ray(
  789. const Eigen::MatrixBase<DerivedV> & V,
  790. const Eigen::MatrixBase<DerivedEle> & Ele,
  791. const RowVectorDIMS & origin,
  792. const RowVectorDIMS & dir,
  793. std::vector<igl::Hit> & hits) const
  794. {
  795. hits.clear();
  796. const Scalar t0 = 0;
  797. const Scalar t1 = std::numeric_limits<Scalar>::infinity();
  798. {
  799. Scalar _1,_2;
  800. if(!ray_box_intersect(origin,dir,m_box,t0,t1,_1,_2))
  801. {
  802. return false;
  803. }
  804. }
  805. if(this->is_leaf())
  806. {
  807. // Actually process elements
  808. assert((Ele.size() == 0 || Ele.cols() == 3) && "Elements should be triangles");
  809. // Cheesecake way of hitting element
  810. bool ret = ray_mesh_intersect(origin,dir,V,Ele.row(m_primitive),hits);
  811. // Since we only gave ray_mesh_intersect a single face, it will have set
  812. // any hits to id=0. Set these to this primitive's id
  813. for(auto & hit : hits)
  814. {
  815. hit.id = m_primitive;
  816. }
  817. return ret;
  818. }
  819. std::vector<igl::Hit> left_hits;
  820. std::vector<igl::Hit> right_hits;
  821. const bool left_ret = m_left->intersect_ray(V,Ele,origin,dir,left_hits);
  822. const bool right_ret = m_right->intersect_ray(V,Ele,origin,dir,right_hits);
  823. hits.insert(hits.end(),left_hits.begin(),left_hits.end());
  824. hits.insert(hits.end(),right_hits.begin(),right_hits.end());
  825. return left_ret || right_ret;
  826. }
  827. template <typename DerivedV, int DIM>
  828. template <typename DerivedEle>
  829. IGL_INLINE bool
  830. igl::AABB<DerivedV,DIM>::intersect_ray(
  831. const Eigen::MatrixBase<DerivedV> & V,
  832. const Eigen::MatrixBase<DerivedEle> & Ele,
  833. const RowVectorDIMS & origin,
  834. const RowVectorDIMS & dir,
  835. igl::Hit & hit) const
  836. {
  837. #if false
  838. // BFS
  839. std::queue<const AABB *> Q;
  840. // Or DFS
  841. //std::stack<const AABB *> Q;
  842. Q.push(this);
  843. bool any_hit = false;
  844. hit.t = std::numeric_limits<Scalar>::infinity();
  845. while(!Q.empty())
  846. {
  847. const AABB * tree = Q.front();
  848. //const AABB * tree = Q.top();
  849. Q.pop();
  850. {
  851. Scalar _1,_2;
  852. if(!ray_box_intersect(
  853. origin,dir,tree->m_box,Scalar(0),Scalar(hit.t),_1,_2))
  854. {
  855. continue;
  856. }
  857. }
  858. if(tree->is_leaf())
  859. {
  860. // Actually process elements
  861. assert((Ele.size() == 0 || Ele.cols() == 3) && "Elements should be triangles");
  862. igl::Hit leaf_hit;
  863. if(
  864. ray_mesh_intersect(origin,dir,V,Ele.row(tree->m_primitive),leaf_hit)&&
  865. leaf_hit.t < hit.t)
  866. {
  867. // correct the id
  868. leaf_hit.id = tree->m_primitive;
  869. hit = leaf_hit;
  870. }
  871. continue;
  872. }
  873. // Add children to queue
  874. Q.push(tree->m_left);
  875. Q.push(tree->m_right);
  876. }
  877. return any_hit;
  878. #else
  879. // DFS
  880. return intersect_ray(
  881. V,Ele,origin,dir,std::numeric_limits<Scalar>::infinity(),hit);
  882. #endif
  883. }
  884. template <typename DerivedV, int DIM>
  885. template <typename DerivedEle>
  886. IGL_INLINE bool
  887. igl::AABB<DerivedV,DIM>::intersect_ray(
  888. const Eigen::MatrixBase<DerivedV> & V,
  889. const Eigen::MatrixBase<DerivedEle> & Ele,
  890. const RowVectorDIMS & origin,
  891. const RowVectorDIMS & dir,
  892. const Scalar _min_t,
  893. igl::Hit & hit) const
  894. {
  895. //// Naive, slow
  896. //std::vector<igl::Hit> hits;
  897. //intersect_ray(V,Ele,origin,dir,hits);
  898. //if(hits.size() > 0)
  899. //{
  900. // hit = hits.front();
  901. // return true;
  902. //}else
  903. //{
  904. // return false;
  905. //}
  906. Scalar min_t = _min_t;
  907. const Scalar t0 = 0;
  908. {
  909. Scalar _1,_2;
  910. if(!ray_box_intersect(origin,dir,m_box,t0,min_t,_1,_2))
  911. {
  912. return false;
  913. }
  914. }
  915. if(this->is_leaf())
  916. {
  917. // Actually process elements
  918. assert((Ele.size() == 0 || Ele.cols() == 3) && "Elements should be triangles");
  919. // Cheesecake way of hitting element
  920. bool ret = ray_mesh_intersect(origin,dir,V,Ele.row(m_primitive),hit);
  921. hit.id = m_primitive;
  922. return ret;
  923. }
  924. // Doesn't seem like smartly choosing left before/after right makes a
  925. // differnce
  926. igl::Hit left_hit;
  927. igl::Hit right_hit;
  928. bool left_ret = m_left->intersect_ray(V,Ele,origin,dir,min_t,left_hit);
  929. if(left_ret && left_hit.t<min_t)
  930. {
  931. // It's scary that this line doesn't seem to matter....
  932. min_t = left_hit.t;
  933. hit = left_hit;
  934. left_ret = true;
  935. }else
  936. {
  937. left_ret = false;
  938. }
  939. bool right_ret = m_right->intersect_ray(V,Ele,origin,dir,min_t,right_hit);
  940. if(right_ret && right_hit.t<min_t)
  941. {
  942. min_t = right_hit.t;
  943. hit = right_hit;
  944. right_ret = true;
  945. }else
  946. {
  947. right_ret = false;
  948. }
  949. return left_ret || right_ret;
  950. }
  951. // This is a bullshit template because AABB annoyingly needs templates for bad
  952. // combinations of 3D V with DIM=2 AABB
  953. //
  954. // _Define_ as a no-op rather than monkeying around with the proper code above
  955. //
  956. // Meanwhile, GCC seems to have a bug. Let's see if GCC likes using explicit
  957. // namespace block instead. https://stackoverflow.com/a/25594681/148668
  958. namespace igl
  959. {
  960. template<> template<> IGL_INLINE float AABB<Eigen::Matrix<float, -1, 3, 1, -1, 3>, 2>::squared_distance( Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&, Eigen::Matrix<float, 1, 2, 1, 1, 2> const&, int&, Eigen::PlainObjectBase<Eigen::Matrix<float, 1, 2, 1, 1, 2> >&) const { assert(false);return -1;};
  961. template<> template<> IGL_INLINE float igl::AABB<Eigen::Matrix<float, -1, 3, 1, -1, 3>, 2>::squared_distance( Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&, Eigen::Matrix<float, 1, 2, 1, 1, 2> const&, float, float, int&, Eigen::PlainObjectBase<Eigen::Matrix<float, 1, 2, 1, 1, 2> >&) const { assert(false);return -1;};
  962. template<> template<> IGL_INLINE void igl::AABB<Eigen::Matrix<float, -1, 3, 1, -1, 3>, 2>::init (Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&) { assert(false);};
  963. template<> template<> IGL_INLINE double AABB<Eigen::Matrix<double, -1, 3, 1, -1, 3>, 2>::squared_distance( Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&, Eigen::Matrix<double, 1, 2, 1, 1, 2> const&, int&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 2, 1, 1, 2> >&) const { assert(false);return -1;};
  964. template<> template<> IGL_INLINE double igl::AABB<Eigen::Matrix<double, -1, 3, 1, -1, 3>, 2>::squared_distance( Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&, Eigen::Matrix<double, 1, 2, 1, 1, 2> const&, double, double, int&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 2, 1, 1, 2> >&) const { assert(false);return -1;};
  965. template<> template<> IGL_INLINE void igl::AABB<Eigen::Matrix<double, -1, 3, 1, -1, 3>, 2>::init (Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&) { assert(false);};
  966. template<> template<> IGL_INLINE void igl::AABB<Eigen::Matrix<float, -1, 3, 0, -1, 3>, 2>::init(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&) {assert(false);};
  967. template<> template<> IGL_INLINE float igl::AABB<Eigen::Matrix<float, -1, 3, 0, -1, 3>, 2>::squared_distance(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::Matrix<float, 1, 2, 1, 1, 2> const&, float, float, int&, Eigen::PlainObjectBase<Eigen::Matrix<float, 1, 2, 1, 1, 2> >&) const { assert(false);return -1;};
  968. }
  969. #ifdef IGL_STATIC_LIBRARY
  970. // Explicit template instantiation
  971. // generated by autoexplicit.sh
  972. template bool igl::AABB<Eigen::Matrix<float, -1, -1, 0, -1, -1>, 3>::intersect_ray<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<float, 1, 3, 1, 1, 3> const&, Eigen::Matrix<float, 1, 3, 1, 1, 3> const&, std::vector<igl::Hit, std::allocator<igl::Hit> >&) const;
  973. // generated by autoexplicit.sh
  974. template void igl::AABB<Eigen::Matrix<float, -1, -1, 0, -1, -1>, 3>::init<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
  975. // generated by autoexplicit.sh
  976. template void igl::AABB<Eigen::Matrix<double, -1, 3, 1, -1, 3>, 3>::squared_distance<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 3, 1, -1, 3>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 3, 1, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> > 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, 3, 1, -1, 3> >&) const;
  977. // generated by autoexplicit.sh
  978. template void igl::AABB<Eigen::Matrix<double, -1, 3, 1, -1, 3>, 3>::init<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
  979. template bool igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::intersect_ray<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<double, 1, 3, 1, 1, 3> const&, Eigen::Matrix<double, 1, 3, 1, 1, 3> const&, igl::Hit&) const;
  980. template double igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::squared_distance<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<double, 1, 2, 1, 1, 2> const&, int&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 2, 1, 1, 2> >&) const;
  981. template double igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<double, 1, 3, 1, 1, 3> const&, double, int&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> >&) const;
  982. template double igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<double, 1, 3, 1, 1, 3> const&, int&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> >&) const;
  983. template double igl::AABB<Eigen::Matrix<double, -1, 3, 1, -1, 3>, 3>::squared_distance<Eigen::Matrix<int, -1, 3, 1, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&, Eigen::Matrix<double, 1, 3, 1, 1, 3> const&, double, double, int&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> >&) const;
  984. template float igl::AABB<Eigen::Matrix<float, -1, 3, 0, -1, 3>, 3>::squared_distance<Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::Matrix<float, 1, 3, 1, 1, 3> const&, float, float, int&, Eigen::PlainObjectBase<Eigen::Matrix<float, 1, 3, 1, 1, 3> >&) const;
  985. template float igl::AABB<Eigen::Matrix<float, -1, 3, 1, -1, 3>, 3>::squared_distance<Eigen::Matrix<int, -1, 3, 1, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&, Eigen::Matrix<float, 1, 3, 1, 1, 3> const&, int&, Eigen::PlainObjectBase<Eigen::Matrix<float, 1, 3, 1, 1, 3> >&) const;
  986. template std::vector<int, std::allocator<int> > igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::find<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, 1, -1, 1, 1, -1> >(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, 1, 1, -1> > const&, bool) const;
  987. template std::vector<int, std::allocator<int> > igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::find<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1> const, 1, -1, false> >(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::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1> const, 1, -1, false> > const&, bool) const;
  988. template std::vector<int, std::allocator<int> > igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::find<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, 1, -1, 1, 1, -1> >(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, 1, 1, -1> > const&, bool) const;
  989. template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::init<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
  990. template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::init<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<int, -1, 1, 0, -1, 1> >(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<int, -1, 1, 0, -1, 1> > const&, int);
  991. template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::init<Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&);
  992. template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::serialize<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::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, int) const;
  993. template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::squared_distance<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<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<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -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> >&) const;
  994. template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::squared_distance<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<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<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -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> >&) const;
  995. template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::squared_distance<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<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<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -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> >&) const;
  996. template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::squared_distance<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<long, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 3, 0, -1, 3> >(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::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&) const;
  997. template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::squared_distance<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<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<int, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -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> >&) const;
  998. template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::init<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
  999. template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::init<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<int, -1, 1, 0, -1, 1> >(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<int, -1, 1, 0, -1, 1> > const&, int);
  1000. template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::init<Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&);
  1001. template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::serialize<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::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, int) const;
  1002. template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance<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<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<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -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> >&) const;
  1003. template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance<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<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<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -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> >&) const;
  1004. template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance<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<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<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -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> >&) const;
  1005. template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance<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<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<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -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> >&) const;
  1006. template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance<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<long, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 3, 0, -1, 3> >(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::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&) const;
  1007. template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, 2, 3, 0, 2, 3>, Eigen::Matrix<double, 2, 1, 0, 2, 1>, Eigen::Matrix<int, 2, 1, 0, 2, 1>, Eigen::Matrix<double, 2, 3, 0, 2, 3> >(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, 2, 3, 0, 2, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 2, 1, 0, 2, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, 2, 1, 0, 2, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, 2, 3, 0, 2, 3> >&) const;
  1008. template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance<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<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<int, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -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> >&) const;
  1009. template void igl::AABB<Eigen::Matrix<double, -1, 3, 1, -1, 3>, 3>::init<Eigen::Matrix<int, -1, 3, 1, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&);
  1010. template void igl::AABB<Eigen::Matrix<float, -1, 3, 0, -1, 3>, 3>::init<Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&);
  1011. template void igl::AABB<Eigen::Matrix<float, -1, 3, 1, -1, 3>, 3>::init<Eigen::Matrix<int, -1, 3, 1, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&);
  1012. template double igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance<Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::Matrix<double, 1, 3, 1, 1, 3> const&, int&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> >&) const;
  1013. template double igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::squared_distance<Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::Matrix<double, 1, 2, 1, 1, 2> const&, int&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 2, 1, 1, 2> >&) const;
  1014. #ifdef WIN32
  1015. template void igl::AABB<class Eigen::Matrix<double,-1,-1,0,-1,-1>,2>::squared_distance<class Eigen::Matrix<int,-1,-1,0,-1,-1>,class Eigen::Matrix<double,-1,-1,0,-1,-1>,class Eigen::Matrix<double,-1,1,0,-1,1>,class Eigen::Matrix<__int64,-1,1,0,-1,1>,class Eigen::Matrix<double,-1,3,0,-1,3> >(class Eigen::MatrixBase<class Eigen::Matrix<double,-1,-1,0,-1,-1> > const &,class Eigen::MatrixBase<class Eigen::Matrix<int,-1,-1,0,-1,-1> > const &,class Eigen::MatrixBase<class Eigen::Matrix<double,-1,-1,0,-1,-1> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<double,-1,1,0,-1,1> > &,class Eigen::PlainObjectBase<class Eigen::Matrix<__int64,-1,1,0,-1,1> > &,class Eigen::PlainObjectBase<class Eigen::Matrix<double,-1,3,0,-1,3> > &)const;
  1016. template void igl::AABB<class Eigen::Matrix<double,-1,-1,0,-1,-1>,3>::squared_distance<class Eigen::Matrix<int,-1,-1,0,-1,-1>,class Eigen::Matrix<double,-1,-1,0,-1,-1>,class Eigen::Matrix<double,-1,1,0,-1,1>,class Eigen::Matrix<__int64,-1,1,0,-1,1>,class Eigen::Matrix<double,-1,3,0,-1,3> >(class Eigen::MatrixBase<class Eigen::Matrix<double,-1,-1,0,-1,-1> > const &,class Eigen::MatrixBase<class Eigen::Matrix<int,-1,-1,0,-1,-1> > const &,class Eigen::MatrixBase<class Eigen::Matrix<double,-1,-1,0,-1,-1> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<double,-1,1,0,-1,1> > &,class Eigen::PlainObjectBase<class Eigen::Matrix<__int64,-1,1,0,-1,1> > &,class Eigen::PlainObjectBase<class Eigen::Matrix<double,-1,3,0,-1,3> > &)const;
  1017. #endif
  1018. #endif