outer_hull.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. #include "outer_hull.h"
  2. #include "outer_facet.h"
  3. #include "sortrows.h"
  4. #include "facet_components.h"
  5. #include "winding_number.h"
  6. #include "triangle_triangle_adjacency.h"
  7. #include "unique_edge_map.h"
  8. #include "barycenter.h"
  9. #include "per_face_normals.h"
  10. #include <Eigen/Geometry>
  11. #include <vector>
  12. #include <map>
  13. #include <queue>
  14. #include <iostream>
  15. //#define IGL_OUTER_HULL_DEBUG
  16. template <
  17. typename DerivedV,
  18. typename DerivedF,
  19. typename DerivedN,
  20. typename DerivedG,
  21. typename DerivedJ,
  22. typename Derivedflip>
  23. IGL_INLINE void igl::outer_hull(
  24. const Eigen::PlainObjectBase<DerivedV> & V,
  25. const Eigen::PlainObjectBase<DerivedF> & F,
  26. const Eigen::PlainObjectBase<DerivedN> & N,
  27. Eigen::PlainObjectBase<DerivedG> & G,
  28. Eigen::PlainObjectBase<DerivedJ> & J,
  29. Eigen::PlainObjectBase<Derivedflip> & flip)
  30. {
  31. using namespace Eigen;
  32. using namespace std;
  33. typedef typename DerivedF::Index Index;
  34. Matrix<Index,DerivedF::RowsAtCompileTime,1> C;
  35. typedef Matrix<typename DerivedV::Scalar,Dynamic,DerivedV::ColsAtCompileTime> MatrixXV;
  36. typedef Matrix<typename DerivedF::Scalar,Dynamic,DerivedF::ColsAtCompileTime> MatrixXF;
  37. typedef Matrix<typename DerivedG::Scalar,Dynamic,DerivedG::ColsAtCompileTime> MatrixXG;
  38. typedef Matrix<typename DerivedJ::Scalar,Dynamic,DerivedJ::ColsAtCompileTime> MatrixXJ;
  39. typedef Matrix<typename DerivedN::Scalar,1,3> RowVector3N;
  40. const Index m = F.rows();
  41. const auto & duplicate_simplex = [&F](const int f, const int g)->bool
  42. {
  43. return
  44. (F(f,0) == F(g,0) && F(f,1) == F(g,1) && F(f,2) == F(g,2)) ||
  45. (F(f,1) == F(g,0) && F(f,2) == F(g,1) && F(f,0) == F(g,2)) ||
  46. (F(f,2) == F(g,0) && F(f,0) == F(g,1) && F(f,1) == F(g,2)) ||
  47. (F(f,0) == F(g,2) && F(f,1) == F(g,1) && F(f,2) == F(g,0)) ||
  48. (F(f,1) == F(g,2) && F(f,2) == F(g,1) && F(f,0) == F(g,0)) ||
  49. (F(f,2) == F(g,2) && F(f,0) == F(g,1) && F(f,1) == F(g,0));
  50. };
  51. #ifdef IGL_OUTER_HULL_DEBUG
  52. cout<<"outer hull..."<<endl;
  53. #endif
  54. #ifdef IGL_OUTER_HULL_DEBUG
  55. cout<<"edge map..."<<endl;
  56. #endif
  57. typedef Matrix<typename DerivedF::Scalar,Dynamic,2> MatrixX2I;
  58. typedef Matrix<typename DerivedF::Index,Dynamic,1> VectorXI;
  59. MatrixX2I E,uE;
  60. VectorXI EMAP;
  61. vector<vector<typename DerivedF::Index> > uE2E;
  62. unique_edge_map(F,E,uE,EMAP,uE2E);
  63. // TODO:
  64. // uE --> face-edge index, sorted CCW around edge according to normal
  65. // uE --> sorted order index
  66. // uE --> bool, whether needed to flip face to make "consistent" with unique
  67. // edge
  68. // Place order of each half-edge in its corresponding sorted list around edge
  69. VectorXI diIM(3*m);
  70. // Whether face's edge used for sorting is consistent with unique edge
  71. VectorXI dicons(3*m);
  72. // dihedral angles of faces around edge with face of edge in dicons
  73. vector<vector<typename DerivedV::Scalar> > di(uE2E.size());
  74. // For each list of face-edges incide on a unique edge
  75. for(size_t ui = 0;ui<(size_t)uE.rows();ui++)
  76. {
  77. // Base normal vector to orient against
  78. const auto fe0 = uE2E[ui][0];
  79. const RowVector3N & eVp = N.row(fe0%m);
  80. MatrixXd di_I(uE2E[ui].size(),2);
  81. const typename DerivedF::Scalar d = F(fe0%m,((fe0/m)+2)%3);
  82. const typename DerivedF::Scalar s = F(fe0%m,((fe0/m)+1)%3);
  83. // Edge vector
  84. const auto & eV = (V.row(d)-V.row(s)).normalized();
  85. vector<bool> cons(uE2E[ui].size());
  86. // Loop over incident face edges
  87. for(size_t fei = 0;fei<uE2E[ui].size();fei++)
  88. {
  89. const auto & fe = uE2E[ui][fei];
  90. const auto f = fe % m;
  91. const auto c = fe / m;
  92. // source should match destination to be consistent
  93. cons[fei] = (d == F(f,(c+1)%3));
  94. assert( cons[fei] || (d == F(f,(c+2)%3)));
  95. assert(!cons[fei] || (s == F(f,(c+2)%3)));
  96. assert(!cons[fei] || (d == F(f,(c+1)%3)));
  97. // Angle between n and f
  98. const RowVector3N & n = N.row(f);
  99. di_I(fei,0) = M_PI - atan2( eVp.cross(n).dot(eV), eVp.dot(n));
  100. #ifdef IGL_OUTER_HULL_DEBUG
  101. if(di_I(fei,0) != di_I(fei,0) )
  102. {
  103. cout<<"NaN from face: "<<(f+1)<<endl;
  104. cout<<" n: "<<n<<endl;
  105. cout<<" eVp: "<<eVp<<endl;
  106. cout<<" eV: "<<eV<<endl;
  107. cout<<" eVp x n . eV: "<<(eVp.cross(n).dot(eV))<<endl;
  108. cout<<" eVp . n: "<<(eVp.dot(n))<<endl;
  109. }
  110. #endif
  111. assert(di_I(fei,0) == di_I(fei,0) && "NaN Alert!");
  112. if(!cons[fei])
  113. {
  114. di_I(fei,0) = di_I(fei,0) + M_PI;
  115. if(di_I(fei,0)>=2.*M_PI)
  116. {
  117. di_I(fei,0) = di_I(fei,0) - 2.*M_PI;
  118. }
  119. }
  120. // This signing is very important to make sure different edges sort
  121. // duplicate faces the same way, regardless of their orientations
  122. di_I(fei,1) = (cons[fei]?1.:-1.)*f;
  123. }
  124. // Despite the effort to get stable normals the atan2 up doesn't
  125. // compute (exactly) -θ for -n if it computes θ for n. So just
  126. // explicitly check if there's a duplicate face
  127. // Shitty O(val^2) implementation
  128. for(size_t fei = 0;fei<uE2E[ui].size();fei++)
  129. {
  130. const auto & fe = uE2E[ui][fei];
  131. const auto f = fe % m;
  132. for(size_t gei = fei+1;gei<uE2E[ui].size();gei++)
  133. {
  134. const auto & ge = uE2E[ui][gei];
  135. const auto g = ge % m;
  136. if(duplicate_simplex(f,g))
  137. {
  138. #ifdef IGL_OUTER_HULL_DEBUG
  139. cout<<"Forcing duplicate: "<<(f+1)<<","<<(g+1)<<endl;
  140. #endif
  141. di_I(gei,0) = di_I(fei,0);
  142. }
  143. }
  144. }
  145. VectorXi IM;
  146. //igl::sort(di[ui],true,di[ui],IM);
  147. // Sort, but break ties using "signed index" to ensure that duplicates
  148. // always show up in same order.
  149. MatrixXd s_di_I;
  150. igl::sortrows(di_I,true,s_di_I,IM);
  151. di[ui].resize(uE2E[ui].size());
  152. for(size_t i = 0;i<di[ui].size();i++)
  153. {
  154. di[ui][i] = s_di_I(i,0);
  155. }
  156. // copy old list
  157. vector<typename DerivedF::Index> temp = uE2E[ui];
  158. for(size_t fei = 0;fei<uE2E[ui].size();fei++)
  159. {
  160. uE2E[ui][fei] = temp[IM(fei)];
  161. const auto & fe = uE2E[ui][fei];
  162. diIM(fe) = fei;
  163. dicons(fe) = cons[IM(fei)];
  164. }
  165. }
  166. vector<vector<vector<Index > > > TT,_1;
  167. triangle_triangle_adjacency(E,EMAP,uE2E,false,TT,_1);
  168. VectorXI counts;
  169. #ifdef IGL_OUTER_HULL_DEBUG
  170. cout<<"facet components..."<<endl;
  171. #endif
  172. facet_components(TT,C,counts);
  173. assert(C.maxCoeff()+1 == counts.rows());
  174. const size_t ncc = counts.rows();
  175. G.resize(0,F.cols());
  176. J.resize(0,1);
  177. flip.setConstant(m,1,false);
  178. #ifdef IGL_OUTER_HULL_DEBUG
  179. cout<<"reindex..."<<endl;
  180. #endif
  181. // H contains list of faces on outer hull;
  182. vector<bool> FH(m,false);
  183. vector<bool> EH(3*m,false);
  184. vector<MatrixXG> vG(ncc);
  185. vector<MatrixXJ> vJ(ncc);
  186. vector<MatrixXJ> vIM(ncc);
  187. for(size_t id = 0;id<ncc;id++)
  188. {
  189. vIM[id].resize(counts[id],1);
  190. }
  191. // current index into each IM
  192. vector<size_t> g(ncc,0);
  193. // place order of each face in its respective component
  194. for(Index f = 0;f<m;f++)
  195. {
  196. vIM[C(f)](g[C(f)]++) = f;
  197. }
  198. #ifdef IGL_OUTER_HULL_DEBUG
  199. cout<<"barycenters..."<<endl;
  200. #endif
  201. // assumes that "resolve" has handled any coplanar cases correctly and nearly
  202. // coplanar cases can be sorted based on barycenter.
  203. MatrixXV BC;
  204. barycenter(V,F,BC);
  205. #ifdef IGL_OUTER_HULL_DEBUG
  206. cout<<"loop over CCs (="<<ncc<<")..."<<endl;
  207. #endif
  208. for(Index id = 0;id<(Index)ncc;id++)
  209. {
  210. auto & IM = vIM[id];
  211. // starting face that's guaranteed to be on the outer hull and in this
  212. // component
  213. int f;
  214. bool f_flip;
  215. #ifdef IGL_OUTER_HULL_DEBUG
  216. cout<<"outer facet..."<<endl;
  217. #endif
  218. outer_facet(V,F,N,IM,f,f_flip);
  219. #ifdef IGL_OUTER_HULL_DEBUG
  220. cout<<"outer facet: "<<f<<endl;
  221. #endif
  222. int FHcount = 1;
  223. FH[f] = true;
  224. // Q contains list of face edges to continue traversing upong
  225. queue<int> Q;
  226. Q.push(f+0*m);
  227. Q.push(f+1*m);
  228. Q.push(f+2*m);
  229. flip(f) = f_flip;
  230. //cout<<"flip("<<f<<") = "<<(flip(f)?"true":"false")<<endl;
  231. #ifdef IGL_OUTER_HULL_DEBUG
  232. cout<<"BFS..."<<endl;
  233. #endif
  234. while(!Q.empty())
  235. {
  236. // face-edge
  237. const int e = Q.front();
  238. Q.pop();
  239. // face
  240. const int f = e%m;
  241. // corner
  242. const int c = e/m;
  243. // Should never see edge again...
  244. if(EH[e] == true)
  245. {
  246. continue;
  247. }
  248. EH[e] = true;
  249. // source of edge according to f
  250. const int fs = flip(f)?F(f,(c+2)%3):F(f,(c+1)%3);
  251. // destination of edge according to f
  252. const int fd = flip(f)?F(f,(c+1)%3):F(f,(c+2)%3);
  253. // edge valence
  254. const size_t val = uE2E[EMAP(e)].size();
  255. //// find overlapping face-edges
  256. //const auto & neighbors = uE2E[EMAP(e)];
  257. //// normal after possible flipping
  258. //const auto & fN = (flip(f)?-1.:1.)*N.row(f);
  259. //// Edge vector according to f's (flipped) orientation.
  260. ////const auto & eV = (V.row(fd)-V.row(fs)).normalized();
  261. //#warning "EXPERIMENTAL, DO NOT USE"
  262. //// THIS IS WRONG! The first face is---after sorting---no longer the face
  263. //// used for orienting the sort.
  264. //const auto ui = EMAP(e);
  265. //const auto fe0 = uE2E[ui][0];
  266. //const auto es = F(fe0%m,((fe0/m)+1)%3);
  267. // is edge consistent with edge of face used for sorting
  268. const int e_cons = (dicons(e) ? 1: -1);
  269. int nfei = -1;
  270. // Loop once around trying to find suitable next face
  271. for(size_t step = 1; step<val+2;step++)
  272. {
  273. const int nfei_new = (diIM(e) + 2*val + e_cons*step*(flip(f)?-1:1))%val;
  274. const int nf = uE2E[EMAP(e)][nfei_new] % m;
  275. // Don't consider faces with identical dihedral angles
  276. if((di[EMAP(e)][diIM(e)] != di[EMAP(e)][nfei_new]))
  277. //#warning "THIS IS HACK, FIX ME"
  278. // if( abs(di[EMAP(e)][diIM(e)] - di[EMAP(e)][nfei_new]) < 1e-16 )
  279. {
  280. #ifdef IGL_OUTER_HULL_DEBUG
  281. cout<<"Next facet: "<<(f+1)<<" --> "<<(nf+1)<<", |"<<
  282. di[EMAP(e)][diIM(e)]<<" - "<<di[EMAP(e)][nfei_new]<<"| = "<<
  283. abs(di[EMAP(e)][diIM(e)] - di[EMAP(e)][nfei_new])
  284. <<endl;
  285. #endif
  286. // Only use this face if not already seen
  287. if(!FH[nf])
  288. {
  289. nfei = nfei_new;
  290. }
  291. break;
  292. }
  293. //#ifdef IGL_OUTER_HULL_DEBUG
  294. // cout<<"Skipping co-planar facet: "<<(f+1)<<" --> "<<(nf+1)<<endl;
  295. //#endif
  296. }
  297. int max_ne = -1;
  298. //// Loop over and find max dihedral angle
  299. //typename DerivedV::Scalar max_di = -1;
  300. //for(const auto & ne : neighbors)
  301. //{
  302. // const int nf = ne%m;
  303. // if(nf == f)
  304. // {
  305. // continue;
  306. // }
  307. // // Corner of neighbor
  308. // const int nc = ne/m;
  309. // // Is neighbor oriented consistently with (flipped) f?
  310. // //const int ns = F(nf,(nc+1)%3);
  311. // const int nd = F(nf,(nc+2)%3);
  312. // const bool cons = (flip(f)?fd:fs) == nd;
  313. // // Normal after possibly flipping to match flip or orientation of f
  314. // const auto & nN = (cons? (flip(f)?-1:1.) : (flip(f)?1.:-1.) )*N.row(nf);
  315. // // Angle between n and f
  316. // const auto & ndi = M_PI - atan2( fN.cross(nN).dot(eV), fN.dot(nN));
  317. // if(ndi>=max_di)
  318. // {
  319. // max_ne = ne;
  320. // max_di = ndi;
  321. // }
  322. //}
  323. ////cout<<(max_ne != max_ne_2)<<" =?= "<<e_cons<<endl;
  324. //if(max_ne != max_ne_2)
  325. //{
  326. // cout<<(f+1)<<" ---> "<<(max_ne%m)+1<<" != "<<(max_ne_2%m)+1<<" ... "<<e_cons<<" "<<flip(f)<<endl;
  327. // typename DerivedV::Scalar max_di = -1;
  328. // for(size_t nei = 0;nei<neighbors.size();nei++)
  329. // {
  330. // const auto & ne = neighbors[nei];
  331. // const int nf = ne%m;
  332. // if(nf == f)
  333. // {
  334. // cout<<" "<<(ne%m)+1<<":\t"<<0<<"\t"<<di[EMAP[e]][nei]<<" "<<diIM(ne)<<endl;
  335. // continue;
  336. // }
  337. // // Corner of neighbor
  338. // const int nc = ne/m;
  339. // // Is neighbor oriented consistently with (flipped) f?
  340. // //const int ns = F(nf,(nc+1)%3);
  341. // const int nd = F(nf,(nc+2)%3);
  342. // const bool cons = (flip(f)?fd:fs) == nd;
  343. // // Normal after possibly flipping to match flip or orientation of f
  344. // const auto & nN = (cons? (flip(f)?-1:1.) : (flip(f)?1.:-1.) )*N.row(nf);
  345. // // Angle between n and f
  346. // const auto & ndi = M_PI - atan2( fN.cross(nN).dot(eV), fN.dot(nN));
  347. // cout<<" "<<(ne%m)+1<<":\t"<<ndi<<"\t"<<di[EMAP[e]][nei]<<" "<<diIM(ne)<<endl;
  348. // if(ndi>=max_di)
  349. // {
  350. // max_ne = ne;
  351. // max_di = ndi;
  352. // }
  353. // }
  354. //}
  355. if(nfei >= 0)
  356. {
  357. max_ne = uE2E[EMAP(e)][nfei];
  358. }
  359. if(max_ne>=0)
  360. {
  361. // face of neighbor
  362. const int nf = max_ne%m;
  363. #ifdef IGL_OUTER_HULL_DEBUG
  364. if(!FH[nf])
  365. {
  366. // first time seeing face
  367. cout<<(f+1)<<" --> "<<(nf+1)<<endl;
  368. }
  369. #endif
  370. FH[nf] = true;
  371. FHcount++;
  372. // corner of neighbor
  373. const int nc = max_ne/m;
  374. const int nd = F(nf,(nc+2)%3);
  375. const bool cons = (flip(f)?fd:fs) == nd;
  376. flip(nf) = (cons ? flip(f) : !flip(f));
  377. //cout<<"flip("<<nf<<") = "<<(flip(nf)?"true":"false")<<endl;
  378. const int ne1 = nf+((nc+1)%3)*m;
  379. const int ne2 = nf+((nc+2)%3)*m;
  380. if(!EH[ne1])
  381. {
  382. Q.push(ne1);
  383. }
  384. if(!EH[ne2])
  385. {
  386. Q.push(ne2);
  387. }
  388. }
  389. }
  390. {
  391. vG[id].resize(FHcount,3);
  392. vJ[id].resize(FHcount,1);
  393. //nG += FHcount;
  394. size_t h = 0;
  395. assert(counts(id) == IM.rows());
  396. for(int i = 0;i<counts(id);i++)
  397. {
  398. const size_t f = IM(i);
  399. //if(f_flip)
  400. //{
  401. // flip(f) = !flip(f);
  402. //}
  403. if(FH[f])
  404. {
  405. vG[id].row(h) = (flip(f)?F.row(f).reverse().eval():F.row(f));
  406. vJ[id](h,0) = f;
  407. h++;
  408. }
  409. }
  410. assert((int)h == FHcount);
  411. }
  412. }
  413. // Is A inside B? Assuming A and B are consistently oriented but closed and
  414. // non-intersecting.
  415. const auto & is_component_inside_other = [](
  416. const Eigen::PlainObjectBase<DerivedV> & V,
  417. const MatrixXV & BC,
  418. const MatrixXG & A,
  419. const MatrixXJ & AJ,
  420. const MatrixXG & B)->bool
  421. {
  422. const auto & bounding_box = [](
  423. const Eigen::PlainObjectBase<DerivedV> & V,
  424. const MatrixXG & F)->
  425. MatrixXV
  426. {
  427. MatrixXV BB(2,3);
  428. BB<<
  429. 1e26,1e26,1e26,
  430. -1e26,-1e26,-1e26;
  431. const size_t m = F.rows();
  432. for(size_t f = 0;f<m;f++)
  433. {
  434. for(size_t c = 0;c<3;c++)
  435. {
  436. const auto & vfc = V.row(F(f,c));
  437. BB.row(0) = BB.row(0).array().min(vfc.array()).eval();
  438. BB.row(1) = BB.row(1).array().max(vfc.array()).eval();
  439. }
  440. }
  441. return BB;
  442. };
  443. // A lot of the time we're dealing with unrelated, distant components: cull
  444. // them.
  445. MatrixXV ABB = bounding_box(V,A);
  446. MatrixXV BBB = bounding_box(V,B);
  447. if( (BBB.row(0)-ABB.row(1)).maxCoeff()>0 ||
  448. (ABB.row(0)-BBB.row(1)).maxCoeff()>0 )
  449. {
  450. // bounding boxes do not overlap
  451. return false;
  452. }
  453. ////////////////////////////////////////////////////////////////////////
  454. // POTENTIAL ROBUSTNESS WEAK AREA
  455. ////////////////////////////////////////////////////////////////////////
  456. //
  457. // q could be so close (<~1e-16) to B that the winding number is not a robust way to
  458. // determine inside/outsideness. We could try to find a _better_ q which is
  459. // farther away, but couldn't they all be bad?
  460. MatrixXV q = BC.row(AJ(0));
  461. // In a perfect world, it's enough to test a single point.
  462. double w;
  463. // winding_number_3 expects colmajor
  464. const typename DerivedV::Scalar * Vdata;
  465. Vdata = V.data();
  466. Matrix<
  467. typename DerivedV::Scalar,
  468. DerivedV::RowsAtCompileTime,
  469. DerivedV::ColsAtCompileTime,
  470. ColMajor> Vcol;
  471. if(DerivedV::IsRowMajor)
  472. {
  473. // copy to convert to colmajor
  474. Vcol = V;
  475. Vdata = Vcol.data();
  476. }
  477. winding_number_3(
  478. Vdata,V.rows(),
  479. B.data(),B.rows(),
  480. q.data(),1,&w);
  481. return fabs(w)>0.5;
  482. };
  483. // Reject components which are completely inside other components
  484. vector<bool> keep(ncc,true);
  485. size_t nG = 0;
  486. // This is O( ncc * ncc * m)
  487. for(size_t id = 0;id<ncc;id++)
  488. {
  489. for(size_t oid = 0;oid<ncc;oid++)
  490. {
  491. if(id == oid)
  492. {
  493. continue;
  494. }
  495. const bool inside = is_component_inside_other(V,BC,vG[id],vJ[id],vG[oid]);
  496. #ifdef IGL_OUTER_HULL_DEBUG
  497. cout<<id<<" is inside "<<oid<<" ? "<<inside<<endl;
  498. #endif
  499. keep[id] = keep[id] && !inside;
  500. }
  501. if(keep[id])
  502. {
  503. nG += vJ[id].rows();
  504. }
  505. }
  506. // collect G and J across components
  507. G.resize(nG,3);
  508. J.resize(nG,1);
  509. {
  510. size_t off = 0;
  511. for(Index id = 0;id<(Index)ncc;id++)
  512. {
  513. if(keep[id])
  514. {
  515. assert(vG[id].rows() == vJ[id].rows());
  516. G.block(off,0,vG[id].rows(),vG[id].cols()) = vG[id];
  517. J.block(off,0,vJ[id].rows(),vJ[id].cols()) = vJ[id];
  518. off += vG[id].rows();
  519. }
  520. }
  521. }
  522. }
  523. template <
  524. typename DerivedV,
  525. typename DerivedF,
  526. typename DerivedG,
  527. typename DerivedJ,
  528. typename Derivedflip>
  529. IGL_INLINE void igl::outer_hull(
  530. const Eigen::PlainObjectBase<DerivedV> & V,
  531. const Eigen::PlainObjectBase<DerivedF> & F,
  532. Eigen::PlainObjectBase<DerivedG> & G,
  533. Eigen::PlainObjectBase<DerivedJ> & J,
  534. Eigen::PlainObjectBase<Derivedflip> & flip)
  535. {
  536. Eigen::Matrix<typename DerivedV::Scalar,DerivedF::RowsAtCompileTime,3> N;
  537. per_face_normals_stable(V,F,N);
  538. return outer_hull(V,F,N,G,J,flip);
  539. }
  540. #ifdef IGL_STATIC_LIBRARY
  541. // Explicit template specialization
  542. template void igl::outer_hull<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<long, -1, 1, 0, -1, 1>, Eigen::Matrix<bool, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&);
  543. template void igl::outer_hull<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
  544. template void igl::outer_hull<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<int, -1, 1, 0, -1, 1>, Eigen::Matrix<bool, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&);
  545. #endif