G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsPatchReparameterized.h
Go to the documentation of this file.
1 
13 #pragma once
14 
15 #include <gismo.h>
17 
18 namespace gismo
19 {
20 
21 template<short_t d, class T>
22 class gsPatchReparameterized
23 {
24 public:
25 
26  gsPatchReparameterized()
27  {}
28 
29  gsPatchReparameterized(const gsGeometry<T> & patch, gsBasis<T> & singlePatch)
30  : m_patchRotated(patch), m_basisRotated(singlePatch)
31  {
32  rotationNum = 0;
33  axisOrientation = 0;
34 
35  mapIndex.setZero(4);
36  mapIndex[0] = 1;
37  mapIndex[1] = 2;
38  mapIndex[2] = 3;
39  mapIndex[3] = 4;
40  };
41 
42  void swapAxis()
43  {
44 /*
45  gsTensorBSplineBasis<d, T> & temp_L = dynamic_cast<gsTensorBSplineBasis<d, T> &>(m_patchRotated.basis(0));
46  gsBSplineBasis<T> temp_basisLU = dynamic_cast<gsBSplineBasis<T> &>(temp_L.component(0));
47  gsBSplineBasis<T> temp_basisLV = dynamic_cast<gsBSplineBasis<T> &>(temp_L.component(1));
48  index_t dimU = temp_L.size(0);
49  index_t dimV = temp_L.size(1);
50 
51  // The number of cols has to match the dimension of the space
52  gsMatrix<T> mpar(dimU * dimV, m_patchRotated.targetDim());
53  for (index_t j = 0; j < dimU; j++)
54  { // Loop over the rows
55  for (index_t i = 0; i < dimV; i++)
56  {
57  mpar.row(i + j * dimV) = m_patchRotated.patch(0).coefs().row(j + dimU * i);
58  }
59  }
60  // Create a new geometry starting from kntot vectors and the matrix of the coefficients reparametrized
61  gsTensorBSpline<d, T> newgeom1(temp_basisLV.knots(), temp_basisLU.knots(), mpar);
62 
63  // Create a new single-patch object
64  gsMultiPatch<T> newpatch;
65  newpatch.addPatch(newgeom1);
66  m_patchRotated.swap(newpatch);
67 */
68  gsBasis<T> & temp_L_basis = m_patchRotated.basis(0);
69  index_t dimU = temp_L_basis.component(0).size();
70  index_t dimV = temp_L_basis.component(1).size();
71 
72  // The number of cols has to match the dimension of the space
73  gsMatrix<T> mpar(dimU * dimV, m_patchRotated.targetDim());
75  dynamic_cast<gsTensorBSplineBasis<d, T> *>(&m_patchRotated.basis(0)) )
76  {
77  for (index_t j = 0; j < dimU; j++)
78  for (index_t i = 0; i < dimV; i++)
79  mpar.row(i + j * dimV) = m_patchRotated.patch(0).coefs().row(j + dimU * i);
80 
81 
82  gsTensorBSplineBasis<d, T> & temp_L = dynamic_cast<gsTensorBSplineBasis<d, T> &>(m_patchRotated.basis(0));
83 
84  // Create a new geometry starting from kntot vectors and the matrix of the coefficients reparametrized
85  gsTensorBSpline<d, T> newgeom1(temp_L.knots(1), temp_L.knots(0), mpar);
86 
87  // Create a new single-patch object
88  gsMultiPatch<T> newpatch(newgeom1);
89  m_patchRotated.swap(newpatch);
90  }
91  else if (gsTensorNurbsBasis<d, T> * mb =
92  dynamic_cast<gsTensorNurbsBasis<d, T> *>(&m_patchRotated.basis(0)) )
93  {
94  gsMatrix<T> weight_rep(dimU * dimV, 1);
95  for (index_t j = 0; j < dimU; j++)
96  { // Loop over the rows
97  for (index_t i = 0; i < dimV; i++)
98  {
99  mpar.row(i + j * dimV) = m_patchRotated.patch(0).coefs().row(j + dimU * i);
100  weight_rep.row(i + j * dimV) = mb->weights().row(j + dimU * i);
101  }
102  }
103 
104  gsTensorNurbsBasis<d, T> & temp_L = dynamic_cast<gsTensorNurbsBasis<d, T> &>(m_patchRotated.basis(0));
105 
106  // Create a new geometry starting from kntot vectors and the matrix of the coefficients reparametrized
107  gsTensorNurbs<d, T> newgeom1(temp_L.knots(1), temp_L.knots(0), mpar, weight_rep);
108 
109  // Create a new single-patch object
110  gsMultiPatch<T> newpatch(newgeom1);
111  m_patchRotated.swap(newpatch);
112  }
113  else
114  gsInfo << "Only gsTensorBSplineBasis<d, T> and gsTensorNurbsBasis<d, T> are implemented \n";
115 
116 
117  // BASES
118  //m_basisRotated.swapAxis();
119  m_basisRotated.basis(0).reverse();
120 
121  // Map Index
122  mapIndex[0] = 3;
123  mapIndex[1] = 4;
124  mapIndex[2] = 1;
125  mapIndex[3] = 2;
126 
127  axisOrientation = 1;
128  }
129 
130 
131  void rotateParamAntiClock(){
132 /*
133  gsTensorBSplineBasis<d, T> & temp_L = dynamic_cast<gsTensorBSplineBasis<d, T> &>(m_patchRotated.basis(0));
134  gsBSplineBasis<T> temp_basisLU = dynamic_cast<gsBSplineBasis<T> &>(temp_L.component(0));
135  gsBSplineBasis<T> temp_basisLV = dynamic_cast<gsBSplineBasis<T> &>(temp_L.component(1));
136  index_t dimU = temp_L.size(0);
137  index_t dimV = temp_L.size(1);
138 
139  // The number of cols has to match the dimension of the space
140  gsMatrix<T> mpar(dimU * dimV, m_patchRotated.targetDim());
141 
142  // Loop over the cols
143  for (index_t j = 0; j < dimU; j++)
144  { // Loop over the rows
145  for (index_t i = 0; i < dimV; i++)
146  {
147  mpar.row(i + j * dimV) = m_patchRotated.patch(0).coefs().row((dimU - 1 - j) + dimU * i);
148  }
149  }
150  temp_basisLU.knots().reverse(); // For different regularity
151  // Create a new geometry starting from kntot vectors and the matrix of the coefficients reparametrized
152  gsTensorBSpline<d, T> newgeom1(temp_basisLV.knots(), temp_basisLU.knots(), mpar);
153 
154  // Create a new single-patch object
155  gsMultiPatch<T> newpatch(newgeom1);
156  m_patchRotated.swap(newpatch);
157 */
158  gsBasis<T> & temp_L_basis = m_patchRotated.basis(0);
159  index_t dimU = temp_L_basis.component(0).size();
160  index_t dimV = temp_L_basis.component(1).size();
161 
162  // The number of cols has to match the dimension of the space
163  gsMatrix<T> mpar(dimU * dimV, m_patchRotated.targetDim());
164  if (gsTensorBSplineBasis<d, T> * mb =
165  dynamic_cast<gsTensorBSplineBasis<d, T> *>(&m_patchRotated.basis(0)) )
166  {
167  for (index_t j = 0; j < dimU; j++)
168  for (index_t i = 0; i < dimV; i++)
169  mpar.row(i + j * dimV) = m_patchRotated.patch(0).coefs().row((dimU - 1 - j) + dimU * i);
170 
171  gsTensorBSplineBasis<d, T> & temp_L = dynamic_cast<gsTensorBSplineBasis<d, T> &>(m_patchRotated.basis(0));
172  temp_L.knots(0).reverse(); // For different regularity
173 
174  // Create a new geometry starting from kntot vectors and the matrix of the coefficients reparametrized
175  gsTensorBSpline<d, T> newgeom1(temp_L.knots(1), temp_L.knots(0), mpar);
176 
177  // Create a new single-patch object
178  gsMultiPatch<T> newpatch(newgeom1);
179  m_patchRotated.swap(newpatch);
180  }
181  else if (gsTensorNurbsBasis<d, T> * mb =
182  dynamic_cast<gsTensorNurbsBasis<d, T> *>(&m_patchRotated.basis(0)) )
183  {
184  gsMatrix<T> weight_rep(dimU * dimV, 1);
185  for (index_t j = (dimU - 1 ) ; j >= 0; j--)
186  { // Loop over the rows
187  for (index_t i = 0; i < dimV; i++)
188  {
189  mpar.row(i + j * dimV) = m_patchRotated.patch(0).coefs().row((dimU - 1 - j) + dimU * i);
190  weight_rep.row(i + j * dimV) = mb->weights().row((dimU - 1 - j) + dimU * i);
191  }
192  }
193 
194  gsTensorNurbsBasis<d, T> & temp_L = dynamic_cast<gsTensorNurbsBasis<d, T> &>(m_patchRotated.basis(0));
195  temp_L.knots(0).reverse(); // For different regularity
196 
197  // Create a new geometry starting from kntot vectors and the matrix of the coefficients reparametrized
198  gsTensorNurbs<d, T> newgeom1(temp_L.knots(1), temp_L.knots(0), mpar, weight_rep);
199 
200  // Create a new single-patch object
201  gsMultiPatch<T> newpatch(newgeom1);
202  m_patchRotated.swap(newpatch);
203  }
204  else
205  gsInfo << "Only gsTensorBSplineBasis<d, T> and gsTensorNurbsBasis<d, T> are implemented \n";
206 
207 
208 
209  // BASES
210  //m_basisRotated.swapAxis();
211  m_basisRotated.basis(0).reverse();
212 
213  // Map Index
214  if (getOrient() == 0)
215  {
216  mapIndex[0] = 4;
217  mapIndex[1] = 3;
218  mapIndex[2] = 1;
219  mapIndex[3] = 2;
220  }
221  else
222  {
223  mapIndex[0] = 1;
224  mapIndex[1] = 2;
225  mapIndex[2] = 4;
226  mapIndex[3] = 3;
227  }
228 
229 
230  // Update the number of rotation of the axis
231  rotationNum++;
232  }
233 
234  void rotateParamClock()
235  {
236 /*
237  gsTensorBSplineBasis<d, T> & temp_L = dynamic_cast<gsTensorBSplineBasis<d, T> &>(m_patchRotated.basis(0));
238  gsBSplineBasis<T> temp_basisLU = dynamic_cast<gsBSplineBasis<T> &>(temp_L.component(0));
239  gsBSplineBasis<T> temp_basisLV = dynamic_cast<gsBSplineBasis<T> &>(temp_L.component(1));
240  index_t dimU = temp_L.size(0);
241  index_t dimV = temp_L.size(1);
242 */
243 
244  gsBasis<T> & temp_L_basis = m_patchRotated.basis(0);
245  index_t dimU = temp_L_basis.component(0).size();
246  index_t dimV = temp_L_basis.component(1).size();
247 
248  // The number of cols has to match the dimension of the space
249  gsMatrix<T> mpar(dimU * dimV, m_patchRotated.targetDim());
250  if (gsTensorBSplineBasis<d, T> * mb =
251  dynamic_cast<gsTensorBSplineBasis<d, T> *>(&m_patchRotated.basis(0)) )
252  {
253  for (index_t j = (dimU - 1 ) ; j >= 0; j--)
254  for (index_t i = 0; i < dimV; i++)
255  mpar.row(i + (dimU - j - 1) * dimV) = m_patchRotated.patch(0).coefs().row((dimV * dimU -1 - j) - dimU * i);
256 
257 
258  gsTensorBSplineBasis<d, T> & temp_L = dynamic_cast<gsTensorBSplineBasis<d, T> &>(m_patchRotated.basis(0));
259  temp_L.knots(1).reverse(); // For different regularity
260 
261  // Create a new geometry starting from kntot vectors and the matrix of the coefficients reparametrized
262  gsTensorBSpline<d, T> newgeom1(temp_L.knots(1), temp_L.knots(0), mpar);
263 
264  // Create a new single-patch object
265  gsMultiPatch<T> newpatch(newgeom1);
266  m_patchRotated.swap(newpatch);
267  }
268  else if (gsTensorNurbsBasis<d, T> * mb =
269  dynamic_cast<gsTensorNurbsBasis<d, T> *>(&m_patchRotated.basis(0)) )
270  {
271  gsMatrix<T> weight_rep(dimU * dimV, 1);
272  for (index_t j = (dimU - 1 ) ; j >= 0; j--)
273  { // Loop over the rows
274  for (index_t i = 0; i < dimV; i++)
275  {
276  mpar.row(i + (dimU - j - 1) * dimV) = m_patchRotated.patch(0).coefs().row((dimV * dimU -1 - j) - dimU * i);
277  weight_rep.row(i + (dimU - j - 1) * dimV) = mb->weights().row((dimV * dimU -1 - j) - dimU * i);
278  }
279  }
280 
281  gsTensorNurbsBasis<d, T> & temp_L = dynamic_cast<gsTensorNurbsBasis<d, T> &>(m_patchRotated.basis(0));
282  temp_L.knots(1).reverse(); // For different regularity
283 
284  // Create a new geometry starting from kntot vectors and the matrix of the coefficients reparametrized
285  gsTensorNurbs<d, T> newgeom1(temp_L.knots(1), temp_L.knots(0), mpar, weight_rep);
286 
287  // Create a new single-patch object
288  gsMultiPatch<T> newpatch(newgeom1);
289  m_patchRotated.swap(newpatch);
290  }
291  else
292  gsInfo << "Only gsTensorBSplineBasis<d, T> and gsTensorNurbsBasis<d, T> are implemented \n";
293 
294 
295  // BASES
296  //m_basisRotated.swapAxis();
297  m_basisRotated.basis(0).reverse();
298 
299  // Map Index
300  if (getOrient() == 0)
301  {
302  mapIndex[0] = 3;
303  mapIndex[1] = 4;
304  mapIndex[2] = 2;
305  mapIndex[3] = 1;
306  }
307  else
308  {
309  mapIndex[0] = 2;
310  mapIndex[1] = 1;
311  mapIndex[2] = 3;
312  mapIndex[3] = 4;
313  }
314 
315  // Update the number of rotation of the axis
316  rotationNum--;
317  checkRotation();
318  }
319 
320  void rotateParamAntiClockTwice()
321  {
322 /*
323  gsTensorBSplineBasis<d, T> & temp_L = dynamic_cast<gsTensorBSplineBasis<d, T> &>(m_patchRotated.basis(0));
324  gsBSplineBasis<T> temp_basisLU = dynamic_cast<gsBSplineBasis<T> &>(temp_L.component(0));
325  gsBSplineBasis<T> temp_basisLV = dynamic_cast<gsBSplineBasis<T> &>(temp_L.component(1));
326  index_t dimU = temp_L.size(0);
327  index_t dimV = temp_L.size(1);
328 
329  // The number of cols has to match the dimension of the space
330  gsMatrix<T> mpar(dimU * dimV, m_patchRotated.targetDim());
331 
332  for (index_t i = 0; i < ( dimU * dimV ); i++)
333  {
334  mpar.row(i) = m_patchRotated.patch(0).coefs().row((dimU * dimV - 1) - i);
335  }
336  temp_basisLU.knots().reverse(); // For different regularity
337  temp_basisLV.knots().reverse(); // For different regularity
338 
339  // Create a new geometry starting from kntot vectors and the matrix of the coefficients reparametrized
340  gsTensorBSpline<d, T> newgeom1(temp_basisLU.knots(), temp_basisLV.knots(), mpar);
341 
342  // Create a new single-patch object
343  gsMultiPatch<T> newpatch(newgeom1);
344  m_patchRotated.swap(newpatch);
345 */
346  gsBasis<T> & temp_L_basis = m_patchRotated.basis(0);
347  index_t dimU = temp_L_basis.component(0).size();
348  index_t dimV = temp_L_basis.component(1).size();
349 
350  // The number of cols has to match the dimension of the space
351  gsMatrix<T> mpar(dimU * dimV, m_patchRotated.targetDim());
352  if (gsTensorBSplineBasis<d, T> * mb =
353  dynamic_cast<gsTensorBSplineBasis<d, T> *>(&m_patchRotated.basis(0)) )
354  {
355  for (index_t i = 0; i < ( dimU * dimV ); i++)
356  mpar.row(i) = m_patchRotated.patch(0).coefs().row((dimU * dimV - 1) - i);
357 
358  gsTensorBSplineBasis<d, T> & temp_L = dynamic_cast<gsTensorBSplineBasis<d, T> &>(m_patchRotated.basis(0));
359  temp_L.knots(0).reverse(); // For different regularity
360  temp_L.knots(1).reverse(); // For different regularity
361 
362  // Create a new geometry starting from kntot vectors and the matrix of the coefficients reparametrized
363  gsTensorBSpline<d, T> newgeom1(temp_L.knots(0), temp_L.knots(1), mpar);
364 
365  // Create a new single-patch object
366  gsMultiPatch<T> newpatch(newgeom1);
367  m_patchRotated.swap(newpatch);
368  }
369  else if (gsTensorNurbsBasis<d, T> * mb =
370  dynamic_cast<gsTensorNurbsBasis<d, T> *>(&m_patchRotated.basis(0)) )
371  {
372  gsMatrix<T> weight_rep(dimU * dimV, 1);
373  for (index_t i = 0; i < ( dimU * dimV ); i++)
374  {
375  mpar.row(i) = m_patchRotated.patch(0).coefs().row((dimU * dimV - 1) - i);
376  weight_rep.row(i) = mb->weights().row((dimU * dimV - 1) - i);
377  }
378 
379  gsTensorNurbsBasis<d, T> & temp_L = dynamic_cast<gsTensorNurbsBasis<d, T> &>(m_patchRotated.basis(0));
380  temp_L.knots(0).reverse(); // For different regularity
381  temp_L.knots(1).reverse(); // For different regularity
382 
383  // Create a new geometry starting from kntot vectors and the matrix of the coefficients reparametrized
384  gsTensorNurbs<d, T> newgeom1(temp_L.knots(0), temp_L.knots(1), mpar, weight_rep);
385 
386  // Create a new single-patch object
387  gsMultiPatch<T> newpatch(newgeom1);
388  m_patchRotated.swap(newpatch);
389  }
390  else
391  gsInfo << "Only gsTensorBSplineBasis<d, T> and gsTensorNurbsBasis<d, T> are implemented \n";
392 
393 
394  // Map Index
395  if (getOrient() == 0)
396  {
397  mapIndex[0] = 2;
398  mapIndex[1] = 1;
399  mapIndex[2] = 4;
400  mapIndex[3] = 3;
401  }
402  else
403  {
404  mapIndex[0] = 4;
405  mapIndex[1] = 3;
406  mapIndex[2] = 2;
407  mapIndex[3] = 1;
408  }
409 
410  // Update the number of rotation of the axis (anti-clockwise)
411  rotationNum+=2;
412  checkRotation();
413  }
414 
415  void parametrizeBasisBack(gsMultiPatch<T> & g1Basis)
416  {
417  switch (rotationNum)
418  {
419  case 2:
420  //gsInfo << "Patch Basis rotated twice anticlockwise\n";
421  rotateBasisAntiClockTwice(g1Basis);
422  break;
423  case -1:
424  //gsInfo << "Patch Basis rotated anticlockwise\n";
425  rotateBasisAntiClock(g1Basis);
426  break;
427  case 1:
428  //gsInfo << "Patch Basis rotated clockwise\n";
429  rotateBasisClock(g1Basis);
430  break;
431  case 0:
432  //gsInfo << "Patch Basis not rotated\n";
433  break;
434  default:
435  break;
436  }
437 
438  if(axisOrientation)
439  swapBasisAxis(g1Basis);
440 
441  }
442 
443  void rotateBasisAntiClockTwice(gsMultiPatch<T> & g1Basis)
444  {
445  gsMultiPatch<T> newpatch;
446  for(size_t np = 0; np < g1Basis.nPatches(); np++)
447  {
448  gsMultiBasis<T> auxBase(g1Basis.patch(np));
450  & temp_L = dynamic_cast<gsTensorBSplineBasis<d, T> &>(auxBase.basis(0));
451  gsBSplineBasis<T> temp_basisLU = dynamic_cast<gsBSplineBasis<T> &>(temp_L.component(0));
452  gsBSplineBasis<T> temp_basisLV = dynamic_cast<gsBSplineBasis<T> &>(temp_L.component(1));
453  index_t dimU = temp_L.size(0);
454  index_t dimV = temp_L.size(1);
455 
456  // The number of cols has to match the dimension of the space
457  gsMatrix<T> mpar(dimU * dimV, g1Basis.patch(np).targetDim());
458 
459  for (index_t i = 0; i < (dimU * dimV); i++)
460  {
461  mpar.row(i) = g1Basis.patch(np).coefs().row((dimU * dimV - 1) - i);
462  }
463  // Create a new geometry starting from kntot vectors and the matrix of the coefficients reparametrized
464  gsTensorBSpline<d, T> newgeom1(temp_basisLU.knots(), temp_basisLV.knots(), mpar);
465 
466  newpatch.addPatch(newgeom1);
467  }
468  g1Basis.swap(newpatch);
469  }
470 
471  void rotateBasisAntiClock(gsMultiPatch<T> & g1Basis)
472  {
473  gsMultiPatch<T> newpatch;
474  for(size_t np = 0; np < g1Basis.nPatches(); np++)
475  {
476  gsMultiBasis<T> auxBase(g1Basis.patch(np));
478  & temp_L = dynamic_cast<gsTensorBSplineBasis<d, T> &>(auxBase.basis(0));
479  gsBSplineBasis<T> temp_basisLU = dynamic_cast<gsBSplineBasis<T> &>(temp_L.component(0));
480  gsBSplineBasis<T> temp_basisLV = dynamic_cast<gsBSplineBasis<T> &>(temp_L.component(1));
481  index_t dimU = temp_L.size(0);
482  index_t dimV = temp_L.size(1);
483 
484  // The number of cols has to match the dimension of the space
485  gsMatrix<T> mpar(dimU * dimV, g1Basis.patch(np).targetDim());
486 
487  // Loop over the cols
488  for (index_t j = 0; j < dimU; j++)
489  { // Loop over the rows
490  for (index_t i = 0; i < dimV; i++)
491  {
492  mpar.row(i + j * dimV) = g1Basis.patch(np).coefs().row((dimU - 1 - j) + dimU * i);
493  }
494  }
495 
496  // Create a new geometry starting from kntot vectors and the matrix of the coefficients reparametrized
497  gsTensorBSpline<d, T> newgeom1(temp_basisLV.knots(), temp_basisLU.knots(), mpar);
498 
499  newpatch.addPatch(newgeom1);
500  }
501  g1Basis.swap(newpatch);
502  }
503 
504  void rotateBasisClock(gsMultiPatch<T> & g1Basis)
505  {
506  gsMultiPatch<T> newpatch;
507  for(size_t np = 0; np < g1Basis.nPatches(); np++)
508  {
509  gsMultiBasis<T> auxBase(g1Basis.patch(np));
511  & temp_L = dynamic_cast<gsTensorBSplineBasis<d, T> &>(auxBase.basis(0));
512  gsBSplineBasis<T> temp_basisLU = dynamic_cast<gsBSplineBasis<T> &>(temp_L.component(0));
513  gsBSplineBasis<T> temp_basisLV = dynamic_cast<gsBSplineBasis<T> &>(temp_L.component(1));
514  index_t dimU = temp_L.size(0);
515  index_t dimV = temp_L.size(1);
516 
517  // The number of cols has to match the dimension of the space
518  gsMatrix<T> mpar(dimU * dimV, g1Basis.patch(np).targetDim());
519 
520  for (index_t j = (dimU - 1); j >= 0; j--)
521  { // Loop over the rows
522  for (index_t i = 0; i < dimV; i++)
523  {
524  mpar.row(i + (dimU - j - 1) * dimV) =
525  g1Basis.patch(np).coefs().row((dimV * dimU - 1 - j) - dimU * i);
526  }
527  }
528 
529  // Create a new geometry starting from kntot vectors and the matrix of the coefficients reparametrized
530  gsTensorBSpline<d, T> newgeom1(temp_basisLV.knots(), temp_basisLU.knots(), mpar);
531 
532  newpatch.addPatch(newgeom1);
533  }
534  g1Basis.swap(newpatch);
535  }
536 
537  void swapBasisAxis(gsMultiPatch<T> & g1Basis)
538  {
539  gsMultiPatch<T> newpatch;
540  for(size_t np = 0; np < g1Basis.nPatches(); np++)
541  {
542  gsMultiBasis<T> auxBase(g1Basis.patch(np));
543  gsTensorBSplineBasis<d, T> & temp_L = dynamic_cast<gsTensorBSplineBasis<d, T> &>(auxBase.basis(0));
544  gsBSplineBasis<T> temp_basisLU = dynamic_cast<gsBSplineBasis<T> &>(temp_L.component(0));
545  gsBSplineBasis<T> temp_basisLV = dynamic_cast<gsBSplineBasis<T> &>(temp_L.component(1));
546  index_t dimU = temp_L.size(0);
547  index_t dimV = temp_L.size(1);
548 
549  // The number of cols has to match the dimension of the space
550  gsMatrix<T> mpar(dimU * dimV, g1Basis.patch(np).targetDim());
551 
552  for (index_t j = 0; j < dimU; j++)
553  { // Loop over the rows
554  for (index_t i = 0; i < dimV; i++)
555  {
556  mpar.row(i + j * dimV) = g1Basis.patch(np).coefs().row(j + dimU * i);
557  }
558  }
559 
560  // Create a new geometry starting from kntot vectors and the matrix of the coefficients reparametrized
561  gsTensorBSpline<d, T> newgeom1(temp_basisLV.knots(), temp_basisLU.knots(), mpar);
562 
563  newpatch.addPatch(newgeom1);
564  }
565  g1Basis.swap(newpatch);
566  }
567 
568 
569  const index_t getOrient(){
570  return axisOrientation;
571  }
572 
573  void checkRotation()
574  {
575  if(rotationNum == 4)
576  rotationNum = 0;
577  }
578 
579  void setNumberOfRotation(index_t numRot)
580  {
581  rotationNum = numRot;
582  }
583 
584  const index_t getNumberOfRotation(){
585  return rotationNum;
586  }
587 
588  gsGeometry<T> & getPatchRotated() { return m_patchRotated.patch(0); }
589  gsBasis<T> & getBasisRotated() { return m_basisRotated.basis(0); }
590 
591  index_t getMapIndex(index_t glSide) const { return mapIndex[glSide-1]; }
592 
593 protected:
594 
595  gsMultiPatch<T> m_patchRotated;
596 
597  gsMultiBasis<T> m_basisRotated;
598 
599  // Referenz to initial geometry
600  gsVector<index_t> mapIndex;
601 
602  // Stores the changing of the axis
603  // 0 -> axis not changed
604  // 1 -> axis swapped (x, y --> y, x)
605  bool axisOrientation;
606 
607  // How many rotation of the axis has been executed
608  // Positive -> anticlockwise Negative -> clockwise
609  index_t rotationNum;
610 
611 };
612 
613 }
index_t addPatch(typename gsGeometry< T >::uPtr g)
Add a patch from a gsGeometry&lt;T&gt;::uPtr.
Definition: gsMultiPatch.hpp:210
Abstract base class representing a geometry map.
Definition: gsGeometry.h:92
Main header to be included by clients using the G+Smo library.
A tensor product of d B-spline functions, with arbitrary target dimension.
Definition: gsTensorBSpline.h:44
int size(size_t i) const
The number of basis functions in basis i.
Definition: gsMultiBasis.h:232
A tensor product Non-Uniform Rational B-spline function (NURBS) of parametric dimension d...
Definition: gsTensorNurbs.h:40
#define index_t
Definition: gsConfig.h:32
virtual const gsBasis< T > & component(short_t i) const
For a tensor product basis, return the (const) 1-d basis for the i-th parameter component.
Definition: gsBasis.hpp:514
A tensor product B-spline basis.
Definition: gsTensorBSplineBasis.h:36
A univariate B-spline basis.
Definition: gsBSplineBasis.h:694
Holds a set of patch-wise bases and their topology information.
Definition: gsMultiBasis.h:36
const KnotVectorType & knots(int i=0) const
Returns the knot vector of the basis.
Definition: gsBSplineBasis.h:369
void swap(gsMultiPatch &other)
Swap with another gsMultiPatch.
Definition: gsMultiPatch.h:170
gsGeometry< T > & patch(size_t i) const
Return the i-th patch.
Definition: gsMultiPatch.h:226
const gsBasis< T > & basis(const index_t k) const
Helper which casts and returns the k-th piece of this function set as a gsBasis.
Definition: gsFunctionSet.hpp:33
size_t nPatches() const
Number of patches.
Definition: gsMultiPatch.h:208
Provides declaration of Basis abstract interface. Similar to gsMultiBasis, but without topology...
#define gsInfo
Definition: gsDebug.h:43
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition: gsMultiPatch.h:33
A tensor product Non-Uniform Rational B-spline (NURBS) basis.
Definition: gsTensorNurbsBasis.h:38
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78