frame_field.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
  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 "frame_field.h"
  9. #include <igl/triangle_triangle_adjacency.h>
  10. #include <igl/edge_topology.h>
  11. #include <igl/per_face_normals.h>
  12. #include <igl/comiso/nrosy.h>
  13. #include <iostream>
  14. namespace igl
  15. {
  16. class FrameInterpolator
  17. {
  18. public:
  19. // Init
  20. IGL_INLINE FrameInterpolator(const Eigen::MatrixXd& _V, const Eigen::MatrixXi& _F);
  21. IGL_INLINE ~FrameInterpolator();
  22. // Reset constraints (at least one constraint must be present or solve will fail)
  23. IGL_INLINE void resetConstraints();
  24. IGL_INLINE void setConstraint(const int fid, const Eigen::VectorXd& v);
  25. IGL_INLINE void interpolateSymmetric();
  26. // Generate the frame field
  27. IGL_INLINE void solve();
  28. // Convert the frame field in the canonical representation
  29. IGL_INLINE void frame2canonical(const Eigen::MatrixXd& TP, const Eigen::RowVectorXd& v, double& theta, Eigen::VectorXd& S);
  30. // Convert the canonical representation in a frame field
  31. IGL_INLINE void canonical2frame(const Eigen::MatrixXd& TP, const double theta, const Eigen::VectorXd& S, Eigen::RowVectorXd& v);
  32. IGL_INLINE Eigen::MatrixXd getFieldPerFace();
  33. IGL_INLINE void PolarDecomposition(Eigen::MatrixXd V, Eigen::MatrixXd& U, Eigen::MatrixXd& P);
  34. // Symmetric
  35. Eigen::MatrixXd S;
  36. std::vector<bool> S_c;
  37. // -------------------------------------------------
  38. // Face Topology
  39. Eigen::MatrixXi TT, TTi;
  40. // Two faces are consistent if their representative vector are taken modulo PI
  41. std::vector<bool> edge_consistency;
  42. Eigen::MatrixXi edge_consistency_TT;
  43. private:
  44. IGL_INLINE double mod2pi(double d);
  45. IGL_INLINE double modpi2(double d);
  46. IGL_INLINE double modpi(double d);
  47. // Convert a direction on the tangent space into an angle
  48. IGL_INLINE double vector2theta(const Eigen::MatrixXd& TP, const Eigen::RowVectorXd& v);
  49. // Convert an angle in a vector in the tangent space
  50. IGL_INLINE Eigen::RowVectorXd theta2vector(const Eigen::MatrixXd& TP, const double theta);
  51. // Interpolate the cross field (theta)
  52. IGL_INLINE void interpolateCross();
  53. // Compute difference between reference frames
  54. IGL_INLINE void computek();
  55. // Compute edge consistency
  56. IGL_INLINE void compute_edge_consistency();
  57. // Cross field direction
  58. Eigen::VectorXd thetas;
  59. std::vector<bool> thetas_c;
  60. // Edge Topology
  61. Eigen::MatrixXi EV, FE, EF;
  62. std::vector<bool> isBorderEdge;
  63. // Angle between two reference frames
  64. // R(k) * t0 = t1
  65. Eigen::VectorXd k;
  66. // Mesh
  67. Eigen::MatrixXd V;
  68. Eigen::MatrixXi F;
  69. // Normals per face
  70. Eigen::MatrixXd N;
  71. // Reference frame per triangle
  72. std::vector<Eigen::MatrixXd> TPs;
  73. };
  74. FrameInterpolator::FrameInterpolator(const Eigen::MatrixXd& _V, const Eigen::MatrixXi& _F)
  75. {
  76. using namespace std;
  77. using namespace Eigen;
  78. V = _V;
  79. F = _F;
  80. assert(V.rows() > 0);
  81. assert(F.rows() > 0);
  82. // Generate topological relations
  83. igl::triangle_triangle_adjacency(V,F,TT,TTi);
  84. igl::edge_topology(V,F, EV, FE, EF);
  85. // Flag border edges
  86. isBorderEdge.resize(EV.rows());
  87. for(unsigned i=0; i<EV.rows(); ++i)
  88. isBorderEdge[i] = (EF(i,0) == -1) || ((EF(i,1) == -1));
  89. // Generate normals per face
  90. igl::per_face_normals(V, F, N);
  91. // Generate reference frames
  92. for(unsigned fid=0; fid<F.rows(); ++fid)
  93. {
  94. // First edge
  95. Vector3d e1 = V.row(F(fid,1)) - V.row(F(fid,0));
  96. e1.normalize();
  97. Vector3d e2 = N.row(fid);
  98. e2 = e2.cross(e1);
  99. e2.normalize();
  100. MatrixXd TP(2,3);
  101. TP << e1.transpose(), e2.transpose();
  102. TPs.push_back(TP);
  103. }
  104. // Reset the constraints
  105. resetConstraints();
  106. // Compute k, differences between reference frames
  107. computek();
  108. // Alloc internal variables
  109. thetas = VectorXd::Zero(F.rows());
  110. S = MatrixXd::Zero(F.rows(),3);
  111. compute_edge_consistency();
  112. }
  113. FrameInterpolator::~FrameInterpolator()
  114. {
  115. }
  116. double FrameInterpolator::mod2pi(double d)
  117. {
  118. while(d<0)
  119. d = d + (2.0*M_PI);
  120. return fmod(d, (2.0*M_PI));
  121. }
  122. double FrameInterpolator::modpi2(double d)
  123. {
  124. while(d<0)
  125. d = d + (M_PI/2.0);
  126. return fmod(d, (M_PI/2.0));
  127. }
  128. double FrameInterpolator::modpi(double d)
  129. {
  130. while(d<0)
  131. d = d + (M_PI);
  132. return fmod(d, (M_PI));
  133. }
  134. double FrameInterpolator::vector2theta(const Eigen::MatrixXd& TP, const Eigen::RowVectorXd& v)
  135. {
  136. // Project onto the tangent plane
  137. Eigen::Vector2d vp = TP * v.transpose();
  138. // Convert to angle
  139. double theta = atan2(vp(1),vp(0));
  140. return theta;
  141. }
  142. Eigen::RowVectorXd FrameInterpolator::theta2vector(const Eigen::MatrixXd& TP, const double theta)
  143. {
  144. Eigen::Vector2d vp(cos(theta),sin(theta));
  145. return vp.transpose() * TP;
  146. }
  147. void FrameInterpolator::interpolateCross()
  148. {
  149. using namespace std;
  150. using namespace Eigen;
  151. //olga: was
  152. // NRosyField nrosy(V,F);
  153. // for (unsigned i=0; i<F.rows(); ++i)
  154. // if(thetas_c[i])
  155. // nrosy.setConstraintHard(i,theta2vector(TPs[i],thetas(i)));
  156. // nrosy.solve(4);
  157. // MatrixXd R = nrosy.getFieldPerFace();
  158. //olga: is
  159. Eigen::MatrixXd R;
  160. Eigen::VectorXd S;
  161. Eigen::VectorXi b; b.resize(F.rows(),1);
  162. Eigen::MatrixXd bc; bc.resize(F.rows(),3);
  163. int num = 0;
  164. for (unsigned i=0; i<F.rows(); ++i)
  165. if(thetas_c[i])
  166. {
  167. b[num] = i;
  168. bc.row(num) = theta2vector(TPs[i],thetas(i));
  169. num++;
  170. }
  171. b.conservativeResize(num,Eigen::NoChange);
  172. bc.conservativeResize(num,Eigen::NoChange);
  173. igl::nrosy(V, F, b, bc, 4, R, S);
  174. //olga:end
  175. assert(R.rows() == F.rows());
  176. for (unsigned i=0; i<F.rows(); ++i)
  177. thetas(i) = vector2theta(TPs[i],R.row(i));
  178. }
  179. void FrameInterpolator::resetConstraints()
  180. {
  181. thetas_c.resize(F.rows());
  182. S_c.resize(F.rows());
  183. for(unsigned i=0; i<F.rows(); ++i)
  184. {
  185. thetas_c[i] = false;
  186. S_c[i] = false;
  187. }
  188. }
  189. void FrameInterpolator::compute_edge_consistency()
  190. {
  191. using namespace std;
  192. using namespace Eigen;
  193. // Compute per-edge consistency
  194. edge_consistency.resize(EF.rows());
  195. edge_consistency_TT = MatrixXi::Constant(TT.rows(),3,-1);
  196. // For every non-border edge
  197. for (unsigned eid=0; eid<EF.rows(); ++eid)
  198. {
  199. if (!isBorderEdge[eid])
  200. {
  201. int fid0 = EF(eid,0);
  202. int fid1 = EF(eid,1);
  203. double theta0 = thetas(fid0);
  204. double theta1 = thetas(fid1);
  205. theta0 = theta0 + k(eid);
  206. double r = modpi(theta0-theta1);
  207. edge_consistency[eid] = r < M_PI/4.0 || r > 3*(M_PI/4.0);
  208. // Copy it into edge_consistency_TT
  209. int i1 = -1;
  210. int i2 = -1;
  211. for (unsigned i=0; i<3; ++i)
  212. {
  213. if (TT(fid0,i) == fid1)
  214. i1 = i;
  215. if (TT(fid1,i) == fid0)
  216. i2 = i;
  217. }
  218. assert(i1 != -1);
  219. assert(i2 != -1);
  220. edge_consistency_TT(fid0,i1) = edge_consistency[eid];
  221. edge_consistency_TT(fid1,i2) = edge_consistency[eid];
  222. }
  223. }
  224. }
  225. void FrameInterpolator::computek()
  226. {
  227. using namespace std;
  228. using namespace Eigen;
  229. k.resize(EF.rows());
  230. // For every non-border edge
  231. for (unsigned eid=0; eid<EF.rows(); ++eid)
  232. {
  233. if (!isBorderEdge[eid])
  234. {
  235. int fid0 = EF(eid,0);
  236. int fid1 = EF(eid,1);
  237. Vector3d N0 = N.row(fid0);
  238. //Vector3d N1 = N.row(fid1);
  239. // find common edge on triangle 0 and 1
  240. int fid0_vc = -1;
  241. int fid1_vc = -1;
  242. for (unsigned i=0;i<3;++i)
  243. {
  244. if (EV(eid,0) == F(fid0,i))
  245. fid0_vc = i;
  246. if (EV(eid,1) == F(fid1,i))
  247. fid1_vc = i;
  248. }
  249. assert(fid0_vc != -1);
  250. assert(fid1_vc != -1);
  251. Vector3d common_edge = V.row(F(fid0,(fid0_vc+1)%3)) - V.row(F(fid0,fid0_vc));
  252. common_edge.normalize();
  253. // Map the two triangles in a new space where the common edge is the x axis and the N0 the z axis
  254. MatrixXd P(3,3);
  255. VectorXd o = V.row(F(fid0,fid0_vc));
  256. VectorXd tmp = -N0.cross(common_edge);
  257. P << common_edge, tmp, N0;
  258. P.transposeInPlace();
  259. MatrixXd V0(3,3);
  260. V0.row(0) = V.row(F(fid0,0)).transpose() -o;
  261. V0.row(1) = V.row(F(fid0,1)).transpose() -o;
  262. V0.row(2) = V.row(F(fid0,2)).transpose() -o;
  263. V0 = (P*V0.transpose()).transpose();
  264. assert(V0(0,2) < 10e-10);
  265. assert(V0(1,2) < 10e-10);
  266. assert(V0(2,2) < 10e-10);
  267. MatrixXd V1(3,3);
  268. V1.row(0) = V.row(F(fid1,0)).transpose() -o;
  269. V1.row(1) = V.row(F(fid1,1)).transpose() -o;
  270. V1.row(2) = V.row(F(fid1,2)).transpose() -o;
  271. V1 = (P*V1.transpose()).transpose();
  272. assert(V1(fid1_vc,2) < 10e-10);
  273. assert(V1((fid1_vc+1)%3,2) < 10e-10);
  274. // compute rotation R such that R * N1 = N0
  275. // i.e. map both triangles to the same plane
  276. double alpha = -atan2(V1((fid1_vc+2)%3,2),V1((fid1_vc+2)%3,1));
  277. MatrixXd R(3,3);
  278. R << 1, 0, 0,
  279. 0, cos(alpha), -sin(alpha) ,
  280. 0, sin(alpha), cos(alpha);
  281. V1 = (R*V1.transpose()).transpose();
  282. assert(V1(0,2) < 10e-10);
  283. assert(V1(1,2) < 10e-10);
  284. assert(V1(2,2) < 10e-10);
  285. // measure the angle between the reference frames
  286. // k_ij is the angle between the triangle on the left and the one on the right
  287. VectorXd ref0 = V0.row(1) - V0.row(0);
  288. VectorXd ref1 = V1.row(1) - V1.row(0);
  289. ref0.normalize();
  290. ref1.normalize();
  291. double ktemp = atan2(ref1(1),ref1(0)) - atan2(ref0(1),ref0(0));
  292. // just to be sure, rotate ref0 using angle ktemp...
  293. MatrixXd R2(2,2);
  294. R2 << cos(ktemp), -sin(ktemp), sin(ktemp), cos(ktemp);
  295. tmp = R2*ref0.head<2>();
  296. assert(tmp(0) - ref1(0) < (0.000001));
  297. assert(tmp(1) - ref1(1) < (0.000001));
  298. k[eid] = ktemp;
  299. }
  300. }
  301. }
  302. void FrameInterpolator::frame2canonical(const Eigen::MatrixXd& TP, const Eigen::RowVectorXd& v, double& theta, Eigen::VectorXd& S_v)
  303. {
  304. using namespace std;
  305. using namespace Eigen;
  306. RowVectorXd v0 = v.segment<3>(0);
  307. RowVectorXd v1 = v.segment<3>(3);
  308. // Project onto the tangent plane
  309. Vector2d vp0 = TP * v0.transpose();
  310. Vector2d vp1 = TP * v1.transpose();
  311. // Assemble matrix
  312. MatrixXd M(2,2);
  313. M << vp0, vp1;
  314. if (M.determinant() < 0)
  315. M.col(1) = -M.col(1);
  316. assert(M.determinant() > 0);
  317. // cerr << "M: " << M << endl;
  318. MatrixXd R,S;
  319. PolarDecomposition(M,R,S);
  320. // Finally, express the cross field as an angle
  321. theta = atan2(R(1,0),R(0,0));
  322. MatrixXd R2(2,2);
  323. R2 << cos(theta), -sin(theta), sin(theta), cos(theta);
  324. assert((R2-R).norm() < 10e-8);
  325. // Convert into rotation invariant form
  326. S = R * S * R.inverse();
  327. // Copy in vector form
  328. S_v = VectorXd(3);
  329. S_v << S(0,0), S(0,1), S(1,1);
  330. }
  331. void FrameInterpolator::canonical2frame(const Eigen::MatrixXd& TP, const double theta, const Eigen::VectorXd& S_v, Eigen::RowVectorXd& v)
  332. {
  333. using namespace std;
  334. using namespace Eigen;
  335. assert(S_v.size() == 3);
  336. MatrixXd S_temp(2,2);
  337. S_temp << S_v(0), S_v(1), S_v(1), S_v(2);
  338. // Convert angle in vector in the tangent plane
  339. // Vector2d vp(cos(theta),sin(theta));
  340. // First reconstruct R
  341. MatrixXd R(2,2);
  342. R << cos(theta), -sin(theta), sin(theta), cos(theta);
  343. // Rotation invariant reconstruction
  344. MatrixXd M = S_temp * R;
  345. Vector2d vp0(M(0,0),M(1,0));
  346. Vector2d vp1(M(0,1),M(1,1));
  347. // Unproject the vectors
  348. RowVectorXd v0 = vp0.transpose() * TP;
  349. RowVectorXd v1 = vp1.transpose() * TP;
  350. v.resize(6);
  351. v << v0, v1;
  352. }
  353. void FrameInterpolator::solve()
  354. {
  355. interpolateCross();
  356. interpolateSymmetric();
  357. }
  358. void FrameInterpolator::interpolateSymmetric()
  359. {
  360. using namespace std;
  361. using namespace Eigen;
  362. // Generate uniform Laplacian matrix
  363. typedef Eigen::Triplet<double> triplet;
  364. std::vector<triplet> triplets;
  365. // Variables are stacked as x1,y1,z1,x2,y2,z2
  366. triplets.reserve(3*4*F.rows());
  367. MatrixXd b = MatrixXd::Zero(3*F.rows(),1);
  368. // Build L and b
  369. for (unsigned eid=0; eid<EF.rows(); ++eid)
  370. {
  371. if (!isBorderEdge[eid])
  372. {
  373. for (int z=0;z<2;++z)
  374. {
  375. // W = [w_a, w_b
  376. // w_b, w_c]
  377. //
  378. // It is not symmetric
  379. int i = EF(eid,z==0?0:1);
  380. int j = EF(eid,z==0?1:0);
  381. int w_a_0 = (i*3)+0;
  382. int w_b_0 = (i*3)+1;
  383. int w_c_0 = (i*3)+2;
  384. int w_a_1 = (j*3)+0;
  385. int w_b_1 = (j*3)+1;
  386. int w_c_1 = (j*3)+2;
  387. // Rotation to change frame
  388. double r_a = cos(z==1?k(eid):-k(eid));
  389. double r_b = -sin(z==1?k(eid):-k(eid));
  390. double r_c = sin(z==1?k(eid):-k(eid));
  391. double r_d = cos(z==1?k(eid):-k(eid));
  392. // First term
  393. // w_a_0 = r_a^2 w_a_1 + 2 r_a r_b w_b_1 + r_b^2 w_c_1 = 0
  394. triplets.push_back(triplet(w_a_0,w_a_0, -1 ));
  395. triplets.push_back(triplet(w_a_0,w_a_1, r_a*r_a ));
  396. triplets.push_back(triplet(w_a_0,w_b_1, 2 * r_a*r_b ));
  397. triplets.push_back(triplet(w_a_0,w_c_1, r_b*r_b ));
  398. // Second term
  399. // w_b_0 = r_a r_c w_a + (r_b r_c + r_a r_d) w_b + r_b r_d w_c
  400. triplets.push_back(triplet(w_b_0,w_b_0, -1 ));
  401. triplets.push_back(triplet(w_b_0,w_a_1, r_a*r_c ));
  402. triplets.push_back(triplet(w_b_0,w_b_1, r_b*r_c + r_a*r_d ));
  403. triplets.push_back(triplet(w_b_0,w_c_1, r_b*r_d ));
  404. // Third term
  405. // w_c_0 = r_c^2 w_a + 2 r_c r_d w_b + r_d^2 w_c
  406. triplets.push_back(triplet(w_c_0,w_c_0, -1 ));
  407. triplets.push_back(triplet(w_c_0,w_a_1, r_c*r_c ));
  408. triplets.push_back(triplet(w_c_0,w_b_1, 2 * r_c*r_d ));
  409. triplets.push_back(triplet(w_c_0,w_c_1, r_d*r_d ));
  410. }
  411. }
  412. }
  413. SparseMatrix<double> L(3*F.rows(),3*F.rows());
  414. L.setFromTriplets(triplets.begin(), triplets.end());
  415. triplets.clear();
  416. // Add soft constraints
  417. double w = 100000;
  418. for (unsigned fid=0; fid < F.rows(); ++fid)
  419. {
  420. if (S_c[fid])
  421. {
  422. for (unsigned i=0;i<3;++i)
  423. {
  424. triplets.push_back(triplet(3*fid + i,3*fid + i,w));
  425. b(3*fid + i) += w*S(fid,i);
  426. }
  427. }
  428. }
  429. SparseMatrix<double> soft(3*F.rows(),3*F.rows());
  430. soft.setFromTriplets(triplets.begin(), triplets.end());
  431. SparseMatrix<double> M;
  432. M = L + soft;
  433. // Solve Lx = b;
  434. SparseLU<SparseMatrix<double> > solver;
  435. solver.compute(M);
  436. if(solver.info()!=Success)
  437. {
  438. std::cerr << "LU failed - frame_interpolator.cpp" << std::endl;
  439. assert(0);
  440. }
  441. MatrixXd x;
  442. x = solver.solve(b);
  443. if(solver.info()!=Success)
  444. {
  445. std::cerr << "Linear solve failed - frame_interpolator.cpp" << std::endl;
  446. assert(0);
  447. }
  448. S = MatrixXd::Zero(F.rows(),3);
  449. // Copy back the result
  450. for (unsigned i=0;i<F.rows();++i)
  451. S.row(i) << x(i*3+0), x(i*3+1), x(i*3+2);
  452. }
  453. void FrameInterpolator::setConstraint(const int fid, const Eigen::VectorXd& v)
  454. {
  455. using namespace std;
  456. using namespace Eigen;
  457. double t_;
  458. VectorXd S_;
  459. frame2canonical(TPs[fid],v,t_,S_);
  460. Eigen::RowVectorXd v2;
  461. canonical2frame(TPs[fid], t_, S_, v2);
  462. thetas(fid) = t_;
  463. thetas_c[fid] = true;
  464. S.row(fid) = S_;
  465. S_c[fid] = true;
  466. }
  467. Eigen::MatrixXd FrameInterpolator::getFieldPerFace()
  468. {
  469. using namespace std;
  470. using namespace Eigen;
  471. MatrixXd R(F.rows(),6);
  472. for (unsigned i=0; i<F.rows(); ++i)
  473. {
  474. RowVectorXd v;
  475. canonical2frame(TPs[i],thetas(i),S.row(i),v);
  476. R.row(i) = v;
  477. }
  478. return R;
  479. }
  480. void FrameInterpolator::PolarDecomposition(Eigen::MatrixXd V, Eigen::MatrixXd& U, Eigen::MatrixXd& P)
  481. {
  482. using namespace std;
  483. using namespace Eigen;
  484. // Polar Decomposition
  485. JacobiSVD<MatrixXd> svd(V,Eigen::ComputeFullU | Eigen::ComputeFullV);
  486. U = svd.matrixU() * svd.matrixV().transpose();
  487. P = svd.matrixV() * svd.singularValues().asDiagonal() * svd.matrixV().transpose();
  488. }
  489. }
  490. IGL_INLINE void igl::frame_field(
  491. const Eigen::MatrixXd& V,
  492. const Eigen::MatrixXi& F,
  493. const Eigen::VectorXi& b,
  494. const Eigen::MatrixXd& bc1,
  495. const Eigen::MatrixXd& bc2,
  496. Eigen::MatrixXd& FF1,
  497. Eigen::MatrixXd& FF2
  498. )
  499. {
  500. using namespace std;
  501. using namespace Eigen;
  502. assert(b.size() > 0);
  503. // Init Solver
  504. FrameInterpolator field(V,F);
  505. for (unsigned i=0; i<b.size(); ++i)
  506. {
  507. VectorXd t(6); t << bc1.row(i).transpose(), bc2.row(i).transpose();
  508. field.setConstraint(b(i), t);
  509. }
  510. // Solve
  511. field.solve();
  512. // Copy back
  513. MatrixXd R = field.getFieldPerFace();
  514. FF1 = R.block(0, 0, R.rows(), 3);
  515. FF2 = R.block(0, 3, R.rows(), 3);
  516. }