377 gsMatrix<T> uniformPoints = gsPointGrid<T>(0,1,102);
378 int numCols = uniformPoints.cols();
380 gsMatrix<T>storage0(2, numCols),storage1(2,numCols),storage2(2,numCols),storage3(2,numCols);
382 storage0.row(0)=uniformPoints.row(0);
385 storage1.row(0)=uniformPoints.row(0);
388 storage2.row(1)=uniformPoints.row(0);
391 storage3.row(1)=uniformPoints.row(0);
396 for(
int i=1; i<storage0.cols()-1;++i)
403 std::vector< gsCurve<T> *> BoundaryCurves;
404 BoundaryCurves.push_back(boundaryB);
405 BoundaryCurves.push_back(boundaryR);
406 BoundaryCurves.push_back(boundaryU);
407 BoundaryCurves.push_back(boundaryL);
436 tcp << verts(i, 0), verts(i, 1), verts((i + 1) % n, 0), verts((i + 1) % n, 1);
438 loop->insertCurve(tcurve);
441 m_pdomain.insertHole(loop);
449 gsMatrix<T> Tang1i = (verts.row((startIdx + n - 1) % n) - startPoint).normalized();
450 gsMatrix<T> Tang1o = (verts.row((startIdx + 1) % n) - startPoint).normalized();
451 gsMatrix<T> Tang2i = (verts.row((endIdx + n - 1) % n) - endPoint).normalized();
452 gsMatrix<T> Tang2o = (verts.row((endIdx + 1) % n) - endPoint).normalized();
456 normals.col(0) = startNormal.transpose();
457 normals.col(1) = endNormal.transpose();
461 constraints.setZero();
462 constraints.block(0, 0, 2, 2).setIdentity();
463 constraints.block(2, 6, 2, 2).setIdentity();
464 constraints.block(4, 0, 1, 2) = - startNormal;
465 constraints.block(4, 2, 1, 2) = startNormal;
466 constraints.block(5, 4, 1, 2) = - endNormal;
467 constraints.block(5, 6, 1, 2) = endNormal;
470 constraintsRHS.segment(0, 2) = startPoint.transpose();
471 constraintsRHS.segment(2, 2) = endPoint.transpose();
472 constraintsRHS.segment(4, 2).setZero();
478 inequalities.setZero();
482 for(
int idxE = 0; idxE < n; idxE++)
484 gsMatrix<T> edgeDiff = verts.row((idxE + 1) % n) - verts.row(idxE);
485 for(
int idxCP = 0; idxCP < 4; idxCP++)
487 inequalities.block(idxE * 4 + idxCP, 2 * idxCP, 1, 2) << -edgeDiff(0, 1), edgeDiff(0, 0);
488 ineqRHS(idxE * 4 + idxCP) = -edgeDiff(0, 1) * verts(idxE, 0) + edgeDiff(0, 0) * verts(idxE, 1);
494 secondDifference.setZero();
495 for(
size_t i = 0; i < 4; i++)
497 secondDifference(i, i) = 1;
498 secondDifference(i, i + 2) = -2;
499 secondDifference(i, i + 4) = 1;
504 costFromSec.setIdentity();
505 costFromSec(0, 2) = costFromSec(1, 3) = costFromSec(2, 0) = costFromSec(3, 1) = 0.5;
508 gsMatrix<T> totalCost = secondDifference.transpose() * costFromSec * secondDifference;
514 constraints.transposeInPlace();
515 inequalities.transposeInPlace();
517 constraintsRHS *= -1;
520 solve_quadprog(totalCost, zeroCost,
521 constraints , constraintsRHS,
522 inequalities, ineqRHS,
525 for(
size_t i = 0; i < 4; i++)
527 imageCoefs.col(i) = imageCoefsConcat.segment(2 * i, 2);
529 GISMO_ASSERT((imageCoefs.col(0) - startPoint.transpose()).norm() < 0.0001 &&
530 (imageCoefs.col(imageCoefs.cols() - 1) - endPoint.transpose()).norm() < 0.0001,
531 "Quadratic optimization failed to satisfy constraints");
536 g << 1,-3,3,-1,0,3,-6,3,0,0,3,-3,0,0,0,1;
538 T k0 = (T(1) - curveProportion) / 2;
539 T k1 = curveProportion;
547 k(i, j) = k0 * k(i - 1, j);
548 if(j > 0) k(i, j) += k1 * k(i - 1, j - 1);
552 gsMatrix<T> transformedCoefs = imageCoefs * g * k * g.inverse();
558 transformedCoefs.transposeInPlace();