31template<
class T>
typename gsNurbsCreator<T>::TensorBSpline2Ptr
32gsNurbsCreator<T>::rotate2D(gsTensorBSpline<2,T>
const & geo,
const T turndeg,
const T Tx,
const T Ty)
34 GISMO_ASSERT(geo.geoDim() >= 2,
"Geometry must be 2D or higher");
36 const T pi = 3.1415926535897932384626433832795;
37 T r = turndeg / 180 * pi;
40 gsMatrix<T> newcoefs = geo.coefs();
43 for(
index_t i =0; i < geo.coefs().rows(); i++)
47 newcoefs(i,0) = math::cos(r) * (tx-Tx) - math::sin(r) * (ty-Ty) + Tx;
48 newcoefs(i,1) = math::sin(r) * (tx-Tx) + math::cos(r) * (ty-Ty) + Ty;
51 return TensorBSpline2Ptr(
new gsTensorBSpline<2,T>(geo.basis().knots(0),geo.basis().knots(1),
give(newcoefs) ));
55void gsNurbsCreator<T>::rotate2D(gsGeometry<T> & geo,
const T turndeg,
const T Tx,
const T Ty)
57 const T pi = 3.1415926535897932384626433832795;
58 T r = turndeg / 180 * pi;
61 for(
index_t i =0; i < geo.coefs().rows(); i++)
63 tx = geo.coefs()(i,0);
64 ty = geo.coefs()(i,1);
65 geo.coefs()(i,0) = math::cos(r) * (tx-Tx) - math::sin(r) * (ty-Ty) + Tx;
66 geo.coefs()(i,1) = math::sin(r) * (tx-Tx) + math::cos(r) * (ty-Ty) + Ty;
70template<
class T>
typename gsNurbsCreator<T>::TensorBSpline2Ptr
71gsNurbsCreator<T>::shift2D(gsTensorBSpline<2,T>
const & geo,
const T dx,
const T dy,
const T dz)
73 GISMO_ASSERT(geo.geoDim() >= 2,
"Geometry must be 2D or higher");
74 gsMatrix<T> newcoefs = geo.coefs();
76 newcoefs.col(0) += gsVector<T>::Ones(newcoefs.rows())*dx;
77 newcoefs.col(1) += gsVector<T>::Ones(newcoefs.rows())*dy;
78 if (newcoefs.cols()==3)
79 newcoefs.col(2) += gsVector<T>::Ones(newcoefs.rows())*dz;
81 return TensorBSpline2Ptr(
new gsTensorBSpline<2,T>(geo.basis().knots(0),geo.basis().knots(1),
give(newcoefs) ));
85void gsNurbsCreator<T>::shift2D(gsGeometry<T> & geo,
const T dx,
const T dy,
const T dz)
87 geo.coefs().col(0) += gsVector<T>::Ones(geo.coefs().rows())*dx;
88 geo.coefs().col(1) += gsVector<T>::Ones(geo.coefs().rows())*dy;
89 if (geo.coefs().cols()==3)
90 geo.coefs().col(2) += gsVector<T>::Ones(geo.coefs().rows())*dz;
94void gsNurbsCreator<T>::shift2D(gsMultiPatch<T> & mp,
const T dx,
const T dy,
const T dz)
96 for (
size_t k = 0; k!=mp.nPatches(); k++)
97 shift2D(mp.patch(k),dx,dy,dz);
100template <
class T>
typename gsNurbsCreator<T>::TensorBSpline2Ptr
101gsNurbsCreator<T>::mirror2D(gsTensorBSpline<2,T> & geo,
bool axis)
103 gsMatrix<T> newcoefs = geo.coefs();
105 T mid = newcoefs.col(!axis).maxCoeff() - newcoefs.col(!axis).minCoeff();
106 newcoefs.col(!axis) -= gsVector<T>::Ones(newcoefs.rows())*mid;
107 newcoefs.col(!axis) *= -1;
109 return TensorBSpline2Ptr(
new gsTensorBSpline<2,T>(geo.basis().knots(0),geo.basis().knots(1),
give(newcoefs) ));
113void gsNurbsCreator<T>::mirror2D(gsGeometry<T> & geo,
bool axis)
115 T mid = geo.coefs().col(!axis).maxCoeff() - geo.coefs().col(!axis).minCoeff();
116 geo.coefs().col(!axis) -= gsVector<T>::Ones(geo.coefs().rows())*mid;
117 geo.coefs().col(!axis) *= -1;
122void gsNurbsCreator<T>::mirror2D(gsMultiPatch<T> & mp,
bool axis)
125 mp.boundingBox(bbox);
127 T mid = (bbox(!axis,1)+bbox(!axis,0))/2;
128 for (
size_t p = 0; p!=mp.nPatches(); p++)
130 mp.patch(p).coefs().col(!axis) -= gsVector<T>::Ones(mp.patch(p).coefs().rows())*mid;
131 mp.patch(p).coefs().col(!axis) *= -1;
135template <
class T>
typename gsNurbsCreator<T>::TensorBSpline2Ptr
136gsNurbsCreator<T>::scale2D(gsTensorBSpline<2,T>
const & geo, T factor)
138 gsMatrix<T> newcoefs = geo.coefs();
139 for (
index_t k = 0; k!= newcoefs.cols(); k++)
141 newcoefs.col(k) *= factor;
143 return TensorBSpline2Ptr(
new gsTensorBSpline<2,T>(geo.basis().knots(0),geo.basis().knots(1),
give(newcoefs) ));
146template <
class T>
typename gsNurbsCreator<T>::TensorBSpline2Ptr
147gsNurbsCreator<T>::scale2D(gsTensorBSpline<2,T>
const & geo, std::vector<T> factors)
149 gsMatrix<T> newcoefs = geo.coefs();
150 GISMO_ENSURE(factors.size()==
static_cast<size_t>(newcoefs.cols()),
"Number of scaling factors must be the same as the number of dimensions");
151 for (
index_t k = 0; k!= newcoefs.cols(); k++)
153 newcoefs.col(k) *= factors.at(k);
155 return TensorBSpline2Ptr(
new gsTensorBSpline<2,T>(geo.basis().knots(0),geo.basis().knots(1),
give(newcoefs) ));
159void gsNurbsCreator<T>::scale2D(gsGeometry<T> & geo, T factor)
161 for (
index_t k = 0; k!= geo.coefs().cols(); k++)
163 geo.coefs().col(k) *= factor;
168void gsNurbsCreator<T>::scale2D(gsGeometry<T> & geo, std::vector<T> factors)
170 GISMO_ENSURE(factors.size()==
static_cast<size_t>(geo.coefs().cols()),
"Number of scaling factors must be the same as the number of dimensions");
171 for (
index_t k = 0; k!= geo.coefs().cols(); k++)
173 geo.coefs().col(k) *= factors.at(k);
178void gsNurbsCreator<T>::scale2D(gsMultiPatch<T> & mp, T factor)
180 for (
size_t p = 0; p!=mp.nPatches(); p++)
181 scale2D(mp.patch(p),factor);
185void gsNurbsCreator<T>::scale2D(gsMultiPatch<T> & mp, std::vector<T> factors)
187 for (
size_t p = 0; p!=mp.nPatches(); p++)
188 scale2D(mp.patch(p),factors);
192void gsNurbsCreator<T>::makeGrid(gsMultiPatch<T> & mp,
const index_t M,
const index_t N)
194 gsMultiPatch<T> mp_ori(mp);
196 mp.boundingBox(bbox);
198 T L = bbox(0,1)-bbox(0,0);
199 T H = bbox(1,1)-bbox(1,0);
205 gsMultiPatch<T> mp_tmp(mp_ori);
206 shift2D(mp_tmp,(m)*L,(n)*H);
207 for (
size_t k=0; k!=mp_tmp.nPatches(); k++)
208 mp.addPatch(mp_tmp.patch(k));
210 mp.computeTopology();
214gsMultiPatch<T> gsNurbsCreator<T>::makeGrid(std::vector<gsMultiPatch<T>> & mps,
const index_t M,
const index_t N)
218 std::vector<gsMultiPatch<T>> mps_ori(mps);
219 std::vector<T> Hs,Ls;
220 Hs.reserve(mps.size());
221 Ls.reserve(mps.size());
223 for (
typename std::vector<gsMultiPatch<T>>::iterator it = mps.begin(); it!=mps.end(); it++)
225 it->boundingBox(bbox);
226 Ls.push_back(bbox(0,1)-bbox(0,0));
227 Hs.push_back(bbox(1,1)-bbox(1,0));
230 typename std::vector<gsMultiPatch<T>>::iterator mp_it = mps.begin();
231 typename std::vector<T>::iterator L_it = Ls.begin();
232 typename std::vector<T>::iterator H_it = Hs.begin();
237 gsMultiPatch<T> mp_tmp(*mp_it);
238 shift2D(mp_tmp,(m)*(*L_it),(n)*(*H_it));
239 for (
size_t k=0; k!=mp_tmp.nPatches(); k++)
240 mp.addPatch(mp_tmp.patch(k));
242 mp_it==mps.end()-1 ? mp_it = mps.begin() : mp_it++;
243 L_it==Ls.end()-1 ? L_it = Ls.begin() : L_it++;
244 H_it==Hs.end()-1 ? H_it = Hs.begin() : H_it++;
248 if (mps.size() % 2 == 0 && N % 2 == 0)
250 mp_it==mps.end()-1 ? mp_it = mps.begin() : mp_it++;
251 L_it==Ls.end()-1 ? L_it = Ls.begin() : L_it++;
252 H_it==Hs.end()-1 ? H_it = Hs.begin() : H_it++;
255 mp.computeTopology();
259template<
class T>
typename gsNurbsCreator<T>::TensorBSpline3Ptr
260gsNurbsCreator<T>::lift3D( gsTensorBSpline<2,T>
const & geo, T z)
262 gsKnotVector<T> KV(0, 1, 0, 2);
263 const int sz = geo.basis().size();
265 gsMatrix<T> newcoefs( 2*sz, geo.geoDim() ) ;
268 newcoefs.topRows(sz) =
269 newcoefs.bottomRows(sz) = geo.coefs();
272 if (newcoefs.cols() == 2 )
274 newcoefs.conservativeResize( gsEigen::NoChange, 3);
275 newcoefs.col(2).setZero();
279 newcoefs.col(2).bottomRows(sz).array() += z;
281 return TensorBSpline3Ptr(
new gsTensorBSpline<3,T>(geo.basis().knots(0),
282 geo.basis().knots(1),
283 KV,
give(newcoefs) ));
287template<
class T>
typename gsNurbsCreator<T>::TensorBSpline4Ptr
288gsNurbsCreator<T>::lift4D( gsTensorBSpline<3,T>
const & geo, T z)
290 gsKnotVector<T> KV(0, 1, 0, 2);
291 const int sz = geo.basis().size();
293 gsMatrix<T> newcoefs( 2*sz, geo.geoDim() ) ;
296 newcoefs.topRows(sz) =
297 newcoefs.bottomRows(sz) = geo.coefs();
300 if (newcoefs.cols() == 3 )
302 newcoefs.conservativeResize( gsEigen::NoChange, 4);
303 newcoefs.col(3).setZero();
307 newcoefs.col(3).bottomRows(sz).array() += z;
309 return TensorBSpline4Ptr(
new gsTensorBSpline<4,T>(geo.basis().knots(0),
310 geo.basis().knots(1),
311 geo.basis().knots(2),
312 KV,
give(newcoefs) ));
316template<
class T>
typename gsNurbsCreator<T>::TensorNurbs3Ptr
317gsNurbsCreator<T>::lift3D( gsTensorNurbs<2,T>
const & geo, T z)
319 gsKnotVector<T> KV(0, 1, 0, 2);
320 const int sz = geo.basis().size();
322 gsMatrix<T> newweights(2*sz, 1), newcoefs( 2*sz, geo.geoDim() ) ;
325 newcoefs.topRows(sz) =
326 newcoefs.bottomRows(sz) = geo.coefs();
329 newweights.topRows(sz) =
330 newweights.bottomRows(sz) = geo.basis().weights();
333 if (newcoefs.cols() == 2 )
335 newcoefs.conservativeResize( gsEigen::NoChange, 3);
336 newcoefs.col(2).setZero();
340 newcoefs.col(2).bottomRows(sz).array() += z;
342 return TensorNurbs3Ptr(
new gsTensorNurbs<3,T>(geo.basis().knots(0),
343 geo.basis().knots(1),
344 KV,
give(newcoefs),
give(newweights) ));
348template<
class T>
typename gsNurbsCreator<T>::TensorNurbs4Ptr
349gsNurbsCreator<T>::lift4D( gsTensorNurbs<3,T>
const & geo, T z)
351 gsKnotVector<T> KV(0, 1, 0, 2);
352 const int sz = geo.basis().size();
354 gsMatrix<T> newweights(2*sz, 1), newcoefs(2*sz, geo.geoDim());
357 newcoefs.topRows(sz) =
358 newcoefs.bottomRows(sz) = geo.coefs();
361 newweights.topRows(sz) =
362 newweights.bottomRows(sz) = geo.basis().weights();
365 if (newcoefs.cols() == 3 )
367 newcoefs.conservativeResize( gsEigen::NoChange, 4);
368 newcoefs.col(3).setZero();
372 newcoefs.col(3).bottomRows(sz).array() += z;
374 return TensorNurbs4Ptr(
new gsTensorNurbs<4,T>(geo.basis().knots(0),
375 geo.basis().knots(1),
376 geo.basis().knots(2),
377 KV,
give(newcoefs),
give(newweights) ));
437template<
class T>
typename gsNurbsCreator<T>::BSplinePtr
438gsNurbsCreator<T>::BSplineUnitInterval(
short_t deg)
440 gsKnotVector<T> KV(0,1, 0,deg+1);
441 gsMatrix<T> C(deg+1, 1);
442 for (
short_t i = 0; i <= deg; ++i)
443 C(i) =
static_cast<T
>(i) /
static_cast<T
>(deg);
444 return BSplinePtr(
new gsBSpline<T>(KV,
give(C)));
448template<
class T>
typename gsNurbsCreator<T>::TensorBSpline2Ptr
452 T
const & upp_y, T
const & turndeg)
458 const T pi = 3.1415926535897932384626433832795;
460 T r = turndeg / (T)(180) * pi;
469 for(
int i =0; i < 4; i++)
471 tx = C(i,0); ty = C(i,1);
472 C(i,0) = math::cos(r) * tx - math::sin(r) * ty;
473 C(i,1) = math::sin(r) * tx + math::cos(r) * ty;
478 D(0,0) = C(0,0); D(0,1) = C(0,1);
479 D(2,0) = C(1,0); D(2,1) = C(1,1);
480 D(6,0) = C(2,0); D(6,1) = C(2,1);
481 D(8,0) = C(3,0); D(8,1) = C(3,1);
483 D(1,0) = (C(0,0)+C(1,0))/(T)(2); D(1,1) = (C(0,1)+C(1,1))/(T)(2);
484 D(3,0) = (C(0,0)+C(2,0))/(T)(2); D(3,1) = (C(0,1)+C(2,1))/(T)(2);
485 D(5,0) = (C(3,0)+C(1,0))/(T)(2); D(5,1) = (C(3,1)+C(1,1))/(T)(2);
486 D(7,0) = (C(2,0)+C(3,0))/(T)(2); D(7,1) = (C(2,1)+C(3,1))/(T)(2);
487 D(4,0) = (C(0,0)+C(3,0))/(T)(2); D(4,1) = (C(0,1)+C(3,1))/(T)(2);
505template<
class T>
typename gsNurbsCreator<T>::TensorBSpline2Ptr
507 T
const & Bx, T
const & By,
508 T
const & Cx, T
const & Cy,
509 T
const & Dx, T
const & Dy,
516 const T pi = 3.1415926535897932384626433832795;
518 T r = turndeg / 180. * pi;
527 for(
int i =0; i < 4; i++)
529 tx = C(i,0); ty = C(i,1);
530 C(i,0) = math::cos(r) * tx - math::sin(r) * ty;
531 C(i,1) = math::sin(r) * tx + math::cos(r) * ty;
538template<
class T>
typename gsNurbsCreator<T>::TensorBSpline2Ptr
542 T
const & d, T
const & turndeg)
544 T Ax,Ay,Bx,By,Cx,Cy,Dx,Dy;
551 return BSplineTrapezium(Ax,Ay,Bx,By,Cx,Cy,Dx,Dy,turndeg);
555template<
class T>
typename gsNurbsCreator<T>::TensorBSpline2Ptr
586template<
class T>
typename gsNurbsCreator<T>::TensorNurbs2Ptr
588 T
const & Bx, T
const & By,
589 T
const & Cx, T
const & Cy,
590 T
const & Dx, T
const & Dy,
598 const T pi = 3.1415926535897932384626433832795;
600 T r = turndeg / 180 * pi;
612 D(0,0) = C(0,0); D(0,1) = C(0,1);
613 D(1,0) = C(1,0); D(1,1) = C(1,1);
614 D(4,0) = C(2,0); D(4,1) = C(2,1);
615 D(5,0) = C(3,0); D(5,1) = C(3,1);
617 D(2,0) = (C(0,0)+C(2,0))/2; D(2,1) = (C(0,1)+C(2,1))/2;
618 D(3,0) = C(3,0); D(3,1) = C(0,0);
624 for(
int i =0; i < 6; i++)
626 tx = D(i,0); ty = D(i,1);
627 D(i,0) = math::cos(r) * tx - math::sin(r) * ty;
628 D(i,1) = math::sin(r) * tx + math::cos(r) * ty;
632 newweights.setOnes();
633 newweights(3,0) = 0.7071;
639template<
class T>
typename gsNurbsCreator<T>::TensorNurbs2Ptr
643 T
const & d, T
const & turndeg)
645 T Ax,Ay,Bx,By,Cx,Cy,Dx,Dy;
652 return NurbsArcTrapezium(Ax,Ay,Bx,By,Cx,Cy,Dx,Dy,turndeg);
657template<
class T>
typename gsNurbsCreator<T>::TensorBSpline2Ptr
671 C.col(0).array() += x;
672 C.col(1).array() += y;
698 for(
int i = 0; i < n; i++)
699 for(
int j = 0; j < m; j++)
701 mp.addPatch(BSplineSquare(r,lx + r*(T)(i) ,ly + r*(T)(j))) ;
703 mp.computeTopology();
708template<
class T>
typename gsNurbsCreator<T>::TensorBSpline2Ptr
713 C << Box(0,0) , Box(1,0), Box(0,1),Box(1,0),
714 Box(0,0) , Box(1,1), Box(0,1),Box(1,1) ;
720template<
class T>
typename gsNurbsCreator<T>::TensorBSpline2Ptr
724 TensorBSpline2Ptr res = BSplineSquare(scale, 0.0, 0.0);
725 res->degreeElevate(deg-1);
730template<
class T>
typename gsNurbsCreator<T>::TensorBSpline3Ptr
732 T
const & y, T
const & z)
736 C << -0.5 , -0.5 , -0.5, 0.5 , -0.5 , -0.5
737 , -0.5 , 0.5 , -0.5, 0.5 , 0.5 , -0.5
738 , -0.5 , -0.5 , 0.5, 0.5 , -0.5 , 0.5
739 , -0.5 , 0.5 , 0.5, 0.5 , 0.5 , 0.5 ;
741 C.col(0).array() += x + 0.5;
742 C.col(1).array() += y + 0.5;
743 C.col(2).array() += z + 0.5;
752template<
class T>
typename gsNurbsCreator<T>::TensorBSpline3Ptr
755 const int n = (deg + 1) * (deg + 1) * (deg + 1);
761 for (
int k = 0; k <= deg; ++k)
762 for (
int j = 0; j <= deg; ++j)
763 for (
int i = 0; i <= deg; ++i)
765 C(r, 0) = ((T) i) / (T)(deg);
766 C(r, 1) = ((T) j) / (T)(deg);
767 C(r, 2) = ((T) k) / (T)(deg);
784 for(
int i = 0; i < n; i++)
785 for(
int j = 0; j < m; j++)
786 for(
int k = 0; k < p; k++)
788 mp.addPatch(BSplineCube(r, r*(T)(0.5) + lx + r*(T)(i), r*(T)(0.5) + ly + r*(T)(j), r*(T)(0.5) + lz+r*(T)(k))) ;
790 mp.computeTopology();
795template<
class T>
typename gsNurbsCreator<T>::TensorBSpline3Ptr
796gsNurbsCreator<T>::BSplineHalfCube( T
const & r, T
const & x,
797 T
const & y, T
const & z)
799 gsKnotVector<T> KV (0,1,0,2) ;
801 C << -0.5 , -0.5 , -0.5, 0.5 , -0.5 , -0.5
802 , -0.5 , 0.5 , -0.5, 0 , 0 , -0.5
803 , -0.5 , -0.5 , 0.5, 0.5 , -0.5 , 0.5
804 , -0.5 , 0.5 , 0.5, 0 , 0 , 0.5 ;
806 C.col(0).array() += x;
807 C.col(1).array() += y;
808 C.col(2).array() += z;
810 return TensorBSpline3Ptr(
new gsTensorBSpline<3,T>(KV,KV,KV,
give(C)));
813template<
class T>
typename gsNurbsCreator<T>::TensorNurbs3Ptr
815 T
const & y, T
const & z)
819 C << 0 , 0 , 0, r , 0 , 0
820 , 0 , r , 0, r , r , 0
821 , 0 , 0 , r, r , 0 , r
822 , 0 , r , r, r , r , r ;
824 C.col(0).array() += x;
825 C.col(1).array() += y;
826 C.col(2).array() += z;
831template<
class T>
typename gsNurbsCreator<T>::TensorNurbs2Ptr
844 ww.
at(2)= 0.707106781186548 ;
845 ww.
at(3)= 0.707106781186548 ;
850template<
class T>
typename gsNurbsCreator<T>::TensorNurbs2Ptr
881 ww<< 1, 0.707106781186548, 1, 0.707106781186548,1, 0.707106781186548,1, 0.707106781186548, 1, 1, 0.707106781186548, 1, 0.707106781186548,1, 0.707106781186548,1, 0.707106781186548, 1 ;
887template<
class T>
typename gsNurbsCreator<T>::GeometryPtr
900template<
class T>
typename gsNurbsCreator<T>::TensorNurbs3Ptr
903 return TensorNurbs3Ptr();
935template<class T> typename gsNurbsCreator<T>::GeometryPtr
936gsNurbsCreator<T>::BSplineQuarterAnnulusMixedWithLShape(int const & deg) {
937 GeometryPtr quann = gsNurbsCreator<T>::NurbsQuarterAnnulusMixedWithLShape();
939 gsKnotVector<T> KV1(0, 1, 0, 2);
940 gsKnotVector<T> KV2(0, 1, deg - 2, deg + 1);
942 gsTensorBSplineBasis<2, T> tbsp(new gsBSplineBasis<T>(KV1), new gsBSplineBasis<T>(KV2));
943 const gsMatrix<T> pts = tbsp.anchors();
944 return GeometryPtr(tbsp.interpolateData(quann->eval(pts), pts));
948template<
class T>
typename gsNurbsCreator<T>::TensorBSpline2Ptr
969template<
class T>
typename gsNurbsCreator<T>::TensorNurbs2Ptr
971 T
const & y, T
const & z)
977 2, 0, 0, 2, 2, 0, 0, 2, 0,-2, 2, 0,-2, 0, 0,
978 2, 0, 2, 2, 2, 2, 0, 2, 2,-2, 2, 2,-2, 0, 2,
979 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2,
980 2, 0, 2, 2,-2, 2, 0,-2, 2,-2,-2, 2,-2, 0, 2,
981 2, 0, 0, 2,-2, 0, 0,-2, 0,-2,-2, 0,-2, 0, 0,
982 2, 0,-2, 2,-2,-2, 0,-2,-2,-2,-2,-2,-2, 0,-2,
983 0, 0,-2, 0, 0,-2, 0, 0,-2, 0, 0,-2, 0, 0,-2,
984 2, 0,-2, 2, 2,-2, 0, 2,-2,-2, 2,-2,-2, 0,-2,
985 2, 0, 0, 2, 2, 0, 0, 2, 0,-2, 2, 0,-2, 0, 0;
990 W << 1, 0.707106781186548, 1, 0.707106781186548, 1,
991 0.707106781186548, 0.5, 0.707106781186548, 0.5, 0.707106781186548,
992 1, 0.707106781186548, 1, 0.707106781186548, 1,
993 0.707106781186548, 0.5, 0.707106781186548, 0.5, 0.707106781186548,
994 1, 0.707106781186548, 1, 0.707106781186548, 1,
995 0.707106781186548, 0.5, 0.707106781186548, 0.5, 0.707106781186548,
996 1, 0.707106781186548, 1, 0.707106781186548, 1,
997 0.707106781186548, 0.5, 0.707106781186548, 0.5, 0.707106781186548,
998 1, 0.707106781186548, 1, 0.707106781186548, 1;
1000 C.col(0).array() += x;
1001 C.col(1).array() += y;
1002 C.col(2).array() += z;
1008template<
class T>
typename gsNurbsCreator<T>::NurbsPtr
1024 C.col(0).array() += x;
1025 C.col(1).array() += y;
1028 ww<< 1, 0.707106781186548, 1, 0.707106781186548,1, 0.707106781186548,1, 0.707106781186548, 1 ;
1033template<
class T>
typename gsNurbsCreator<T>::BSplinePtr
1049 C.col(0).array() += x;
1050 C.col(1).array() += y;
1055template<
class T>
typename gsNurbsCreator<T>::TensorBSpline2Ptr
1060 C << 0, -r , r,-r , r, 0
1061 ,-r, -r , 0, 0 , r ,r
1062 ,-r , 0 , -r, r , 0 ,r ;
1064 C.col(0).array() += x;
1065 C.col(1).array() += y;
1070template<
class T>
typename gsNurbsCreator<T>::NurbsPtr
1074 KV2.uniformRefine();
1091 C.col(0).array() += x;
1092 C.col(1).array() += y;
1095 ww<< 1, 0.853553, 0.853553, 1, 0.853553, 0.853553, 1, 0.853553,
1096 0.853553, 1, 0.853553, 0.853553, 1;
1105 return NurbsPtr(nn);
1109template<
class T>
typename gsNurbsCreator<T>::NurbsPtr
1110gsNurbsCreator<T>::NurbsCurve2 (T
const & r, T
const & x, T
const & y)
1112 gsKnotVector<T> kv(0,4,3,3,2);
1114 C << 0, -2 , 0.5,-0.5 , 2, 0
1115 ,-2, -2 , 0, 0 , 0.5 ,0.5
1116 ,-2 , 0 , -0.5, 0.5 , 0 ,-2 ;
1120 C.col(0).array() += x;
1121 C.col(1).array() += y;
1123 gsMatrix<T> ww( 9, 1 ) ;
1127 ww(3)= 0.707106781186548 ;
1131 ww(7)= 0.707106781186548 ;
1134 return NurbsPtr(
new gsNurbs<T>(kv,
give(C),
give(ww)));
1138template<
class T>
typename gsNurbsCreator<T>::NurbsPtr
1139gsNurbsCreator<T>::NurbsBean(T
const &, T
const & x, T
const & y)
1141 gsKnotVector<T> kv(0,1,12,3,1,2);
1142 gsMatrix<T> C(15,2);
1159 C.col(0).array() += x;
1160 C.col(1).array() += y;
1162 gsMatrix<T> ww( 15, 1 ) ;
1164 return NurbsPtr(
new gsNurbs<T>(kv,
give(C),
give(ww)));
1168template<
class T>
typename gsNurbsCreator<T>::BSplinePtr
1169gsNurbsCreator<T>::BSplineE (T
const &, T
const & x, T
const & y)
1171 gsKnotVector<T> kv(0,1,22,4,1,3);
1172 gsMatrix<T> C(26,2);
1199 C.col(0).array() += x;
1200 C.col(1).array() += y;
1202 return BSplinePtr(
new gsBSpline<T>(kv,
give(C)));
1205template<
class T>
typename gsNurbsCreator<T>::NurbsPtr
1206gsNurbsCreator<T>::NurbsAmoebaFull(T
const &, T
const & x, T
const & y)
1208 gsKnotVector<T> kv(0,1,19,3,1,2);
1209 gsMatrix<T> C(22,2);
1233 C.col(0).array() += x;
1234 C.col(1).array() += y;
1236 gsMatrix<T> ww(22, 1 ) ;
1238 return NurbsPtr(
new gsNurbs<T>(kv,
give(ww),
give(C)));
1241template<
class T>
typename gsNurbsCreator<T>::BSplinePtr
1242gsNurbsCreator<T>::BSplineLineSegment(gsMatrix<T>
const & p0, gsMatrix<T>
const & p1 )
1244 gsKnotVector<T> kv(0,1,0,2,1,1);
1247 C.row(0).noalias() = p0.transpose();
1248 C.row(1).noalias() = p1.transpose();
1249 return BSplinePtr(
new gsBSpline<T>(kv,
give(C)));
1252template<
class T>
typename gsNurbsCreator<T>::BSplinePtr
1253gsNurbsCreator<T>::BSplineSegment(T
const u0, T
const u1)
1255 gsKnotVector<T> kv(u0, u1, 0, 2);
1256 gsBSplineBasis<T> bsb(kv);
1257 return BSplinePtr(
new gsBSpline<T>(bsb, bsb.anchors().transpose()) );
1261template<
class T>
typename gsNurbsCreator<T>::TensorBSpline2Ptr
1286template<
class T>
typename gsNurbsCreator<T>::TensorBSpline2Ptr
1318template<
class T>
typename gsNurbsCreator<T>::TensorBSpline2Ptr
1361 TensorBSpline2Ptr patch1 = BSplineSquare(0.5, 0.0, 0.0);
1362 patch1->degreeElevate();
1363 mp.addPatch(
give(patch1) ) ;
1365 TensorBSpline2Ptr patch2 = BSplineSquare(0.5, 0, 0.5);
1366 patch2->degreeElevate();
1367 mp.addPatch(
give(patch2) ) ;
1369 TensorBSpline2Ptr patch3 = BSplineSquare(0.5, 0.5, 0);
1370 patch3->degreeElevate();
1371 mp.addPatch(
give(patch3) ) ;
1373 mp.computeTopology();
1377template<
class T>
typename gsNurbsCreator<T>::BSplinePtr
1408 C.col(0).array() += x;
1409 C.col(1).array() += y;
1413 return BSplinePtr(B);
1416template<
class T>
typename gsNurbsCreator<T>::BSplinePtr
1417gsNurbsCreator<T>::BSplineAmoebaBig(T
const &, T
const & x, T
const & y)
1419 gsKnotVector<T> kv(0,1,19,3,1,2);
1420 gsMatrix<T> C(22,2);
1445 C.col(0).array() += x;
1446 C.col(1).array() += y;
1448 gsBSpline<T> *B =
new gsBSpline<T>(kv,
give(C));
1450 return BSplinePtr(B);
1453template<
class T>
typename gsNurbsCreator<T>::BSplinePtr
1454gsNurbsCreator<T>::BSplineAustria(T
const &, T
const & x, T
const & y)
1456 gsKnotVector<T> kv(0,1,31,3,1,2);
1457 gsMatrix<T> C(34,2);
1494 C.col(0).array() += x;
1495 C.col(1).array() += y;
1497 gsBSpline<T> *B =
new gsBSpline<T>(kv,
give(C));
1499 return BSplinePtr(B);
1503template<
class T>
typename gsNurbsCreator<T>::BSplinePtr
1504gsNurbsCreator<T>::BSplineFish(T
const &, T
const & x, T
const & y)
1506 gsKnotVector<T> kv(0,1,13,3,1,2);
1507 gsMatrix<T> C(16,2);
1525 C.col(0).array() += x;
1526 C.col(1).array() += y;
1528 gsBSpline<T> *B =
new gsBSpline<T>(kv,
give(C));
1529 return BSplinePtr(B);
1532template<
class T>
typename gsNurbsCreator<T>::BSplinePtr
1533gsNurbsCreator<T>::BSplineAmoeba3degree(T
const &, T
const & x, T
const & y)
1535 gsKnotVector<T> kv(0,1,18,4,1,3);
1536 gsMatrix<T> C(22,2);
1562 C.col(0).array() += x;
1563 C.col(1).array() += y;
1565 gsBSpline<T> *B =
new gsBSpline<T>(kv,
give(C));
1567 return BSplinePtr(B);
1571template<
class T>
typename gsNurbsCreator<T>::TensorNurbs2Ptr
1572gsNurbsCreator<T>::NurbsDisk(T
const & r, T
const & x, T
const & y)
1574 gsKnotVector<T> kv(0,1,0,3);
1577 C << 0, -1 , 1,-1 , 1, 0
1578 ,-1, -1 , 0, 0 , 1 ,1
1579 ,-1 , 0 , -1, 1 , 0 ,1 ;
1583 C.col(0).array() += x;
1584 C.col(1).array() += y;
1586 gsMatrix<T> ww(9, 1 ) ;
1588 ww(1)= 0.707106781186548 ;
1590 ww(3)= 0.707106781186548 ;
1592 ww(5)= 0.707106781186548 ;
1594 ww(7)= 0.707106781186548 ;
1597 return TensorNurbs2Ptr(
new gsTensorNurbs<2,T>(kv,kv,
give(C),
give(ww)));
1601template<
class T>
typename gsNurbsCreator<T>::TensorBSpline2Ptr
1602gsNurbsCreator<T>::NurbsQrtPlateWHoleC0()
1609 gsKnotVector<T> kv1(0,1,1,3,2);
1610 gsKnotVector<T> kv2(0,1,0,3);
1611 gsMatrix<T> C(15,2);
1615 -1/sqrt(2.0), 1/sqrt(2.0),
1630 return TensorBSpline2Ptr(
new gsTensorBSpline<2,T>(kv1,kv2,
give(C)));
1635template<
class T>
typename gsNurbsCreator<T>::TensorBSpline2Ptr
1642 C.col(0) << 0 , 0 , 0.5*W, W;
1643 C.col(1) << H , 0 , 0.5*H, 0 ;
1656 const T pi = 3.1415926535897932384626433832795;
1657 const T theta = 2*pi/N;
1661 R1*math::cos(pi/2-theta/2), R1*math::sin(pi/2-theta/2),
1662 -R1*math::cos(pi/2-theta/2), R1*math::sin(pi/2-theta/2),
1670 bspline = *(rotate2D(bspline,theta*360/(2*pi)));
A univariate B-spline basis.
Definition gsBSplineBasis.h:700
A B-spline function of one argument, with arbitrary target dimension.
Definition gsBSpline.h:51
memory::unique_ptr< gsGeometry< T > > interpolateData(gsMatrix< T > const &vals, gsMatrix< T > const &pts) const
Applies interpolation given the parameter values pts and values vals.
Definition gsBasis.hpp:240
gsMatrix< T > anchors() const
Returns the anchor points that represent the members of the basis. There is exactly one anchor point ...
Definition gsBasis.h:437
Class for representing a knot vector.
Definition gsKnotVector.h:80
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
T at(index_t i) const
Returns the i-th element of the vectorization of the matrix.
Definition gsMatrix.h:211
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition gsMultiPatch.h:100
index_t addPatch(typename gsGeometry< T >::uPtr g)
Add a patch from a gsGeometry<T>::uPtr.
Definition gsMultiPatch.hpp:211
A NURBS function of one argument, with arbitrary target dimension.
Definition gsNurbs.h:40
A tensor product B-spline basis.
Definition gsTensorBSplineBasis.h:37
A tensor product of d B-spline functions, with arbitrary target dimension.
Definition gsTensorBSpline.h:45
A tensor product Non-Uniform Rational B-spline function (NURBS) of parametric dimension d,...
Definition gsTensorNurbs.h:41
Represents a B-spline curve/function with one parameter.
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
#define GISMO_ENSURE(cond, message)
Definition gsDebug.h:102
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Provides declaration of the MultiPatch class.
Represents a NURBS curve/function with one parameter.
Represents a tensor-product B-spline patch.
Represents a tensor-product NURBS patch.
The G+Smo namespace, containing all definitions for the library.
S give(S &x)
Definition gsMemory.h:266
Class gsNurbsCreator provides some simple examples of Nurbs Geometries.
Definition gsNurbsCreator.h:37
static TensorBSpline2Ptr BSplineLShape_p1(T r=(T)(1))
L-Shaped domain represented as a tensor B-spline of degree 1.
Definition gsNurbsCreator.hpp:1262
static TensorBSpline2Ptr BSplineFatDisk(T const &r=1, T const &x=0, T const &y=0)
Inexact disk using B-splines.
Definition gsNurbsCreator.hpp:1056
static TensorBSpline2Ptr BSplineTrapezium(T const &Lbot=1, T const &Ltop=0.5, T const &H=1, T const &d=0, T const &turndeg=0)
Rectangle described by the identity mapping over the given parameter domain, using tensor product B-s...
Definition gsNurbsCreator.hpp:539
static TensorBSpline2Ptr BSplineTriangle(T const &H=1, T const &W=1)
Makes a Isosceles triangle with height H and width W.
Definition gsNurbsCreator.hpp:1636
static TensorNurbs2Ptr NurbsSphere(T const &r=1, T const &x=0, T const &y=0, T const &z=0)
Sphere using NURBS.
Definition gsNurbsCreator.hpp:970
static BSplinePtr BSplineFatCircle(T const &r=(T)(1), T const &x=0, T const &y=0)
Inexact circle using B-splines.
Definition gsNurbsCreator.hpp:1034
static TensorNurbs2Ptr NurbsArcTrapezium(T const &Lbot=1, T const &Ltop=0.5, T const &H=1, T const &d=0, T const &turndeg=0)
2d-trapezium
Definition gsNurbsCreator.hpp:640
static gsMultiPatch< T > BSplineSquareGrid(int n, int m, T const &r=1, T const &lx=0, T const &ly=0)
Definition gsNurbsCreator.hpp:691
static TensorBSpline2Ptr BSplineRectangle(T const &low_x=0, T const &low_y=0, T const &upp_x=1, T const &upp_y=1, T const &turndeg=0)
2d-rectange [low_x,upp_x] x [low_y,upp_y], rotated by turndeg degrees.
Definition gsNurbsCreator.hpp:449
static TensorNurbs3Ptr NurbsCube(T const &r=1, T const &x=0, T const &y=0, T const &z=0)
Cube of side r, with lower left corner at (x,y,z) using NURBS.
Definition gsNurbsCreator.hpp:814
static TensorNurbs2Ptr NurbsAnnulus(T const &r0=1, T const &r1=2)
Exact full annulus using NURBS with inner radius r0 and outer radius r1.
Definition gsNurbsCreator.hpp:851
static TensorBSpline2Ptr BSplineLShape_p2C0()
Definition gsNurbsCreator.hpp:1287
static gsMultiPatch< T > BSplineLShapeMultiPatch_p2()
Definition gsNurbsCreator.hpp:1357
static TensorBSpline2Ptr BSplineLShape_p2C1()
Definition gsNurbsCreator.hpp:1319
static GeometryPtr BSplineQuarterAnnulus(const short_t °=2)
Inexact annulus using B-splines.
Definition gsNurbsCreator.hpp:888
static TensorBSpline2Ptr BSplineSquareDeg(short_t deg, T scale=(T)(1))
The unit square represented as a tensor B-spline of degree deg.
Definition gsNurbsCreator.hpp:721
static NurbsPtr NurbsCircle(T const &r=(T)(1), T const &x=0, T const &y=0)
Circle using NURBS.
Definition gsNurbsCreator.hpp:1009
static TensorBSpline3Ptr BSplineCube(T const &r=1, T const &x=0, T const &y=0, T const &z=0)
Cube of side r, with lower left corner at (x,y,z)
Definition gsNurbsCreator.hpp:731
static TensorNurbs2Ptr NurbsQuarterAnnulus(T const &r0=1, T const &r1=2)
Exact annulus using NURBS with inner radius r0 and outer radius r1.
Definition gsNurbsCreator.hpp:832
static TensorBSpline2Ptr BSplineFatQuarterAnnulus(T const &r0=1, T const &r1=2)
Definition gsNurbsCreator.hpp:949
static gsMultiPatch< T > BSplineStar(index_t const &N=3, T const &R0=1, T const &R1=0.5)
Makes a star with N patches, outer radius R0 and inner radius R1.
Definition gsNurbsCreator.hpp:1650