gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
CutBox.cpp
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 
6 #include "GmshConfig.h"
7 #include "OctreePost.h"
8 #include "CutBox.h"
9 #include "Context.h"
10 
11 #if defined(HAVE_OPENGL)
12 #include "drawContext.h"
13 #endif
14 
28  {GMSH_FULLRC, "NumPointsU", GMSH_CutBoxPlugin::callbackU, 20},
29  {GMSH_FULLRC, "NumPointsV", GMSH_CutBoxPlugin::callbackV, 20},
30  {GMSH_FULLRC, "NumPointsW", GMSH_CutBoxPlugin::callbackW, 20},
31  {GMSH_FULLRC, "ConnectPoints", GMSH_CutBoxPlugin::callbackConnect, 1},
33  {GMSH_FULLRC, "View", nullptr, -1.}};
34 
35 extern "C" {
37 }
38 
39 void GMSH_CutBoxPlugin::draw(void *context)
40 {
41 #if defined(HAVE_OPENGL)
42  glColor4ubv((GLubyte *)&CTX::instance()->color.fg);
43  double p[3];
44  drawContext *ctx = (drawContext *)context;
45 
46  getPoint(0, 0, 0, p);
47  ctx->drawString("(X0, Y0, Z0)", p[0], p[1], p[2]);
48  if(getNbU() > 1) {
49  getPoint(getNbU() - 1, 0, 0, p);
50  ctx->drawString("(X1, Y1, Z1)", p[0], p[1], p[2]);
51  }
52  if(getNbV() > 1) {
53  getPoint(0, getNbV() - 1, 0, p);
54  ctx->drawString("(X2, Y2, Z2)", p[0], p[1], p[2]);
55  }
56  if(getNbW() > 1) {
57  getPoint(0, 0, getNbW() - 1, p);
58  ctx->drawString("(X3, Y3, Z3)", p[0], p[1], p[2]);
59  }
60 
61  if(CutBoxOptions_Number[15].def) {
62  glBegin(GL_LINES);
63  // UV
64  for(int i = 0; i < getNbU(); ++i) {
65  getPoint(i, 0, 0, p);
66  glVertex3d(p[0], p[1], p[2]);
67  getPoint(i, getNbV() - 1, 0, p);
68  glVertex3d(p[0], p[1], p[2]);
69 
70  getPoint(i, 0, getNbW() - 1, p);
71  glVertex3d(p[0], p[1], p[2]);
72  getPoint(i, getNbV() - 1, getNbW() - 1, p);
73  glVertex3d(p[0], p[1], p[2]);
74  }
75  for(int i = 0; i < getNbV(); ++i) {
76  getPoint(0, i, 0, p);
77  glVertex3d(p[0], p[1], p[2]);
78  getPoint(getNbU() - 1, i, 0, p);
79  glVertex3d(p[0], p[1], p[2]);
80 
81  getPoint(0, i, getNbW() - 1, p);
82  glVertex3d(p[0], p[1], p[2]);
83  getPoint(getNbU() - 1, i, getNbW() - 1, p);
84  glVertex3d(p[0], p[1], p[2]);
85  }
86  // UW
87  for(int i = 0; i < getNbU(); ++i) {
88  getPoint(i, 0, 0, p);
89  glVertex3d(p[0], p[1], p[2]);
90  getPoint(i, 0, getNbW() - 1, p);
91  glVertex3d(p[0], p[1], p[2]);
92 
93  getPoint(i, getNbV() - 1, 0, p);
94  glVertex3d(p[0], p[1], p[2]);
95  getPoint(i, getNbV() - 1, getNbW() - 1, p);
96  glVertex3d(p[0], p[1], p[2]);
97  }
98  for(int i = 0; i < getNbW(); ++i) {
99  getPoint(0, 0, i, p);
100  glVertex3d(p[0], p[1], p[2]);
101  getPoint(getNbU() - 1, 0, i, p);
102  glVertex3d(p[0], p[1], p[2]);
103 
104  getPoint(0, getNbV() - 1, i, p);
105  glVertex3d(p[0], p[1], p[2]);
106  getPoint(getNbU() - 1, getNbV() - 1, i, p);
107  glVertex3d(p[0], p[1], p[2]);
108  }
109  // VW
110  for(int i = 0; i < getNbV(); ++i) {
111  getPoint(0, i, 0, p);
112  glVertex3d(p[0], p[1], p[2]);
113  getPoint(0, i, getNbW() - 1, p);
114  glVertex3d(p[0], p[1], p[2]);
115 
116  getPoint(getNbU() - 1, i, 0, p);
117  glVertex3d(p[0], p[1], p[2]);
118  getPoint(getNbU() - 1, i, getNbW() - 1, p);
119  glVertex3d(p[0], p[1], p[2]);
120  }
121  for(int i = 0; i < getNbW(); ++i) {
122  getPoint(0, 0, i, p);
123  glVertex3d(p[0], p[1], p[2]);
124  getPoint(0, getNbV() - 1, i, p);
125  glVertex3d(p[0], p[1], p[2]);
126 
127  getPoint(getNbU() - 1, 0, i, p);
128  glVertex3d(p[0], p[1], p[2]);
129  getPoint(getNbU() - 1, getNbV() - 1, i, p);
130  glVertex3d(p[0], p[1], p[2]);
131  }
132 
133  glEnd();
134  }
135  else {
136  for(int i = 0; i < getNbU(); ++i) {
137  for(int j = 0; j < getNbV(); ++j) {
138  getPoint(i, j, 0, p);
139  ctx->drawSphere(CTX::instance()->pointSize, p[0], p[1], p[2], 1);
140  getPoint(i, j, getNbW() - 1, p);
141  ctx->drawSphere(CTX::instance()->pointSize, p[0], p[1], p[2], 1);
142  }
143  }
144  for(int i = 0; i < getNbU(); ++i) {
145  for(int j = 0; j < getNbW(); ++j) {
146  getPoint(i, 0, j, p);
147  ctx->drawSphere(CTX::instance()->pointSize, p[0], p[1], p[2], 1);
148  getPoint(i, getNbV() - 1, j, p);
149  ctx->drawSphere(CTX::instance()->pointSize, p[0], p[1], p[2], 1);
150  }
151  }
152  for(int i = 0; i < getNbV(); ++i) {
153  for(int j = 0; j < getNbW(); ++j) {
154  getPoint(0, i, j, p);
155  ctx->drawSphere(CTX::instance()->pointSize, p[0], p[1], p[2], 1);
156  getPoint(getNbU() - 1, i, j, p);
157  ctx->drawSphere(CTX::instance()->pointSize, p[0], p[1], p[2], 1);
158  }
159  }
160  }
161 #endif
162 }
163 
164 double GMSH_CutBoxPlugin::callback(int num, int action, double value,
165  double *opt, double step, double min,
166  double max)
167 {
168  switch(action) { // configure the input field
169  case 1: return step;
170  case 2: return min;
171  case 3: return max;
172  default: break;
173  }
174  *opt = value;
176  return 0.;
177 }
178 
179 double GMSH_CutBoxPlugin::callbackX0(int num, int action, double value)
180 {
181  return callback(num, action, value, &CutBoxOptions_Number[0].def,
182  CTX::instance()->lc / 100., CTX::instance()->min[0],
183  CTX::instance()->max[0]);
184 }
185 
186 double GMSH_CutBoxPlugin::callbackY0(int num, int action, double value)
187 {
188  return callback(num, action, value, &CutBoxOptions_Number[1].def,
189  CTX::instance()->lc / 100., CTX::instance()->min[1],
190  CTX::instance()->max[1]);
191 }
192 
193 double GMSH_CutBoxPlugin::callbackZ0(int num, int action, double value)
194 {
195  return callback(num, action, value, &CutBoxOptions_Number[2].def,
196  CTX::instance()->lc / 100., CTX::instance()->min[2],
197  CTX::instance()->max[2]);
198 }
199 
200 double GMSH_CutBoxPlugin::callbackX1(int num, int action, double value)
201 {
202  return callback(num, action, value, &CutBoxOptions_Number[3].def,
203  CTX::instance()->lc / 100., CTX::instance()->min[0],
204  CTX::instance()->max[0]);
205 }
206 
207 double GMSH_CutBoxPlugin::callbackY1(int num, int action, double value)
208 {
209  return callback(num, action, value, &CutBoxOptions_Number[4].def,
210  CTX::instance()->lc / 100., CTX::instance()->min[1],
211  CTX::instance()->max[1]);
212 }
213 
214 double GMSH_CutBoxPlugin::callbackZ1(int num, int action, double value)
215 {
216  return callback(num, action, value, &CutBoxOptions_Number[5].def,
217  CTX::instance()->lc / 100., CTX::instance()->min[2],
218  CTX::instance()->max[2]);
219 }
220 
221 double GMSH_CutBoxPlugin::callbackX2(int num, int action, double value)
222 {
223  return callback(num, action, value, &CutBoxOptions_Number[6].def,
224  CTX::instance()->lc / 100., CTX::instance()->min[0],
225  CTX::instance()->max[0]);
226 }
227 
228 double GMSH_CutBoxPlugin::callbackY2(int num, int action, double value)
229 {
230  return callback(num, action, value, &CutBoxOptions_Number[7].def,
231  CTX::instance()->lc / 100., CTX::instance()->min[1],
232  CTX::instance()->max[1]);
233 }
234 
235 double GMSH_CutBoxPlugin::callbackZ2(int num, int action, double value)
236 {
237  return callback(num, action, value, &CutBoxOptions_Number[8].def,
238  CTX::instance()->lc / 100., CTX::instance()->min[2],
239  CTX::instance()->max[2]);
240 }
241 
242 double GMSH_CutBoxPlugin::callbackX3(int num, int action, double value)
243 {
244  return callback(num, action, value, &CutBoxOptions_Number[9].def,
245  CTX::instance()->lc / 100., CTX::instance()->min[0],
246  CTX::instance()->max[0]);
247 }
248 
249 double GMSH_CutBoxPlugin::callbackY3(int num, int action, double value)
250 {
251  return callback(num, action, value, &CutBoxOptions_Number[10].def,
252  CTX::instance()->lc / 100., CTX::instance()->min[1],
253  CTX::instance()->max[1]);
254 }
255 
256 double GMSH_CutBoxPlugin::callbackZ3(int num, int action, double value)
257 {
258  return callback(num, action, value, &CutBoxOptions_Number[11].def,
259  CTX::instance()->lc / 100., CTX::instance()->min[2],
260  CTX::instance()->max[2]);
261 }
262 
263 double GMSH_CutBoxPlugin::callbackU(int num, int action, double value)
264 {
265  return callback(num, action, value, &CutBoxOptions_Number[12].def, 1, 1, 200);
266 }
267 
268 double GMSH_CutBoxPlugin::callbackV(int num, int action, double value)
269 {
270  return callback(num, action, value, &CutBoxOptions_Number[13].def, 1, 1, 200);
271 }
272 
273 double GMSH_CutBoxPlugin::callbackW(int num, int action, double value)
274 {
275  return callback(num, action, value, &CutBoxOptions_Number[14].def, 1, 1, 200);
276 }
277 
278 double GMSH_CutBoxPlugin::callbackConnect(int num, int action, double value)
279 {
280  return callback(num, action, value, &CutBoxOptions_Number[15].def, 1, 0, 1);
281 }
282 
283 double GMSH_CutBoxPlugin::callbackBoundary(int num, int action, double value)
284 {
285  return callback(num, action, value, &CutBoxOptions_Number[16].def, 1, 0, 1);
286 }
287 
288 std::string GMSH_CutBoxPlugin::getHelp() const
289 {
290  return "Plugin(CutBox) cuts the view `View' with a "
291  "rectangular box defined by the 4 points "
292  "(`X0',`Y0',`Z0') (origin), (`X1',`Y1',`Z1') (axis of U), "
293  "(`X2',`Y2',`Z2') (axis of V) and (`X3',`Y3',`Z3') (axis of W).\n\n"
294  "The number of points along U, V, W is set with the "
295  "options `NumPointsU', `NumPointsV' and `NumPointsW'.\n\n"
296  "If `ConnectPoints' is zero, the plugin creates points; "
297  "otherwise, the plugin generates hexahedra, quadrangles, lines or "
298  "points depending on the values of `NumPointsU', "
299  "`NumPointsV' and `NumPointsW'.\n\n"
300  "If `Boundary' is zero, the plugin interpolates the view inside "
301  "the box; otherwise the plugin interpolates the view at its "
302  "boundary.\n\n"
303  "If `View' < 0, the plugin is run on the current view.\n\n"
304  "Plugin(CutBox) creates one new list-based view.";
305 }
306 
308 {
309  return sizeof(CutBoxOptions_Number) / sizeof(StringXNumber);
310 }
311 
313 {
314  return &CutBoxOptions_Number[iopt];
315 }
316 
318 
320 
322 
323 void GMSH_CutBoxPlugin::getPoint(int iU, int iV, int iW, double *X)
324 {
325  double u = getNbU() > 1 ? (double)iU / (double)(getNbU() - 1.) : 0.;
326  double v = getNbV() > 1 ? (double)iV / (double)(getNbV() - 1.) : 0.;
327  double w = getNbW() > 1 ? (double)iW / (double)(getNbW() - 1.) : 0.;
328 
329  X[0] = CutBoxOptions_Number[0].def +
331  v * (CutBoxOptions_Number[6].def - CutBoxOptions_Number[0].def) +
333  X[1] = CutBoxOptions_Number[1].def +
335  v * (CutBoxOptions_Number[7].def - CutBoxOptions_Number[1].def) +
337  X[2] = CutBoxOptions_Number[2].def +
339  v * (CutBoxOptions_Number[8].def - CutBoxOptions_Number[2].def) +
341 }
342 
343 void GMSH_CutBoxPlugin::addInView(int connect, int boundary, int numsteps,
344  int nbcomp, double ****pnts, double ****vals,
345  std::vector<double> &P, int *nP,
346  std::vector<double> &L, int *nL,
347  std::vector<double> &Q, int *nQ,
348  std::vector<double> &H, int *nH)
349 {
350  if(!connect ||
351  (getNbU() == 1 && getNbV() == 1 && getNbW() == 1)) { // generate points
352  if(!boundary)
353  for(int i = 0; i < getNbU(); ++i) {
354  for(int j = 0; j < getNbV(); ++j) {
355  for(int m = 0; m < getNbW(); ++m) {
356  P.push_back(pnts[i][j][m][0]);
357  P.push_back(pnts[i][j][m][1]);
358  P.push_back(pnts[i][j][m][2]);
359  (*nP)++;
360  for(int k = 0; k < numsteps; ++k) {
361  for(int l = 0; l < nbcomp; ++l)
362  P.push_back(vals[i][j][m][nbcomp * k + l]);
363  }
364  }
365  }
366  }
367  else {
368  for(int i = 0; i < getNbU(); ++i) {
369  for(int j = 0; j < getNbV(); ++j) {
370  P.push_back(pnts[i][j][0][0]);
371  P.push_back(pnts[i][j][0][1]);
372  P.push_back(pnts[i][j][0][2]);
373  (*nP)++;
374  for(int k = 0; k < numsteps; ++k) {
375  for(int l = 0; l < nbcomp; ++l)
376  P.push_back(vals[i][j][0][nbcomp * k + l]);
377  }
378  P.push_back(pnts[i][j][getNbW() - 1][0]);
379  P.push_back(pnts[i][j][getNbW() - 1][1]);
380  P.push_back(pnts[i][j][getNbW() - 1][2]);
381  (*nP)++;
382  for(int k = 0; k < numsteps; ++k) {
383  for(int l = 0; l < nbcomp; ++l)
384  P.push_back(vals[i][j][getNbW() - 1][nbcomp * k + l]);
385  }
386  }
387  } // end UV planes
388  for(int i = 0; i < getNbU(); ++i) {
389  for(int j = 0; j < getNbW(); ++j) {
390  P.push_back(pnts[i][0][j][0]);
391  P.push_back(pnts[i][0][j][1]);
392  P.push_back(pnts[i][0][j][2]);
393  (*nP)++;
394  for(int k = 0; k < numsteps; ++k) {
395  for(int l = 0; l < nbcomp; ++l)
396  P.push_back(vals[i][0][j][nbcomp * k + l]);
397  }
398  P.push_back(pnts[i][getNbV() - 1][j][0]);
399  P.push_back(pnts[i][getNbV() - 1][j][1]);
400  P.push_back(pnts[i][getNbV() - 1][j][2]);
401  (*nP)++;
402  for(int k = 0; k < numsteps; ++k) {
403  for(int l = 0; l < nbcomp; ++l)
404  P.push_back(vals[i][getNbV() - 1][j][nbcomp * k + l]);
405  }
406  }
407  } // end UW planes
408  for(int i = 0; i < getNbV(); ++i) {
409  for(int j = 0; j < getNbW(); ++j) {
410  P.push_back(pnts[0][i][j][0]);
411  P.push_back(pnts[0][i][j][1]);
412  P.push_back(pnts[0][i][j][2]);
413  (*nP)++;
414  for(int k = 0; k < numsteps; ++k) {
415  for(int l = 0; l < nbcomp; ++l)
416  P.push_back(vals[0][i][j][nbcomp * k + l]);
417  }
418  P.push_back(pnts[getNbU() - 1][i][j][0]);
419  P.push_back(pnts[getNbU() - 1][i][j][1]);
420  P.push_back(pnts[getNbU() - 1][i][j][2]);
421  (*nP)++;
422  for(int k = 0; k < numsteps; ++k) {
423  for(int l = 0; l < nbcomp; ++l)
424  P.push_back(vals[getNbU() - 1][i][j][nbcomp * k + l]);
425  }
426  }
427  } // end VW planes
428  }
429  }
430  else { // generate lines or quads
431  if(getNbU() == 1 && getNbV() == 1) {
432  if(!boundary)
433  for(int i = 0; i < getNbW() - 1; ++i) {
434  L.push_back(pnts[0][0][i][0]);
435  L.push_back(pnts[0][0][i + 1][0]);
436  L.push_back(pnts[0][0][i][1]);
437  L.push_back(pnts[0][0][i + 1][1]);
438  L.push_back(pnts[0][0][i][2]);
439  L.push_back(pnts[0][0][i + 1][2]);
440  (*nL)++;
441  for(int k = 0; k < numsteps; ++k) {
442  for(int l = 0; l < nbcomp; ++l)
443  L.push_back(vals[0][0][i][nbcomp * k + l]);
444  for(int l = 0; l < nbcomp; ++l)
445  L.push_back(vals[0][0][i + 1][nbcomp * k + l]);
446  }
447  }
448  else {
449  P.push_back(pnts[0][0][0][0]);
450  P.push_back(pnts[0][0][0][1]);
451  P.push_back(pnts[0][0][0][2]);
452  (*nP)++;
453  for(int k = 0; k < numsteps; ++k) {
454  for(int l = 0; l < nbcomp; ++l)
455  P.push_back(vals[0][0][0][nbcomp * k + l]);
456  }
457  P.push_back(pnts[0][0][getNbW() - 1][0]);
458  P.push_back(pnts[0][0][getNbW() - 1][1]);
459  P.push_back(pnts[0][0][getNbW() - 1][2]);
460  (*nP)++;
461  for(int k = 0; k < numsteps; ++k) {
462  for(int l = 0; l < nbcomp; ++l)
463  P.push_back(vals[0][0][getNbW() - 1][nbcomp * k + l]);
464  }
465  }
466  }
467  else if(getNbU() == 1 && getNbW() == 1) {
468  if(!boundary)
469  for(int i = 0; i < getNbV() - 1; ++i) {
470  L.push_back(pnts[0][i][0][0]);
471  L.push_back(pnts[0][i + 1][0][0]);
472  L.push_back(pnts[0][i][0][1]);
473  L.push_back(pnts[0][i + 1][0][1]);
474  L.push_back(pnts[0][i][0][2]);
475  L.push_back(pnts[0][i + 1][0][2]);
476  (*nL)++;
477  for(int k = 0; k < numsteps; ++k) {
478  for(int l = 0; l < nbcomp; ++l)
479  L.push_back(vals[0][i][0][nbcomp * k + l]);
480  for(int l = 0; l < nbcomp; ++l)
481  L.push_back(vals[0][i + 1][0][nbcomp * k + l]);
482  }
483  }
484  else {
485  P.push_back(pnts[0][0][0][0]);
486  P.push_back(pnts[0][0][0][1]);
487  P.push_back(pnts[0][0][0][2]);
488  (*nP)++;
489  for(int k = 0; k < numsteps; ++k) {
490  for(int l = 0; l < nbcomp; ++l)
491  P.push_back(vals[0][0][0][nbcomp * k + l]);
492  }
493  P.push_back(pnts[0][getNbV() - 1][0][0]);
494  P.push_back(pnts[0][getNbV() - 1][0][1]);
495  P.push_back(pnts[0][getNbV() - 1][0][2]);
496  (*nP)++;
497  for(int k = 0; k < numsteps; ++k) {
498  for(int l = 0; l < nbcomp; ++l)
499  P.push_back(vals[0][getNbV() - 1][0][nbcomp * k + l]);
500  }
501  }
502  }
503  else if(getNbV() == 1 && getNbW() == 1) {
504  if(!boundary)
505  for(int i = 0; i < getNbU() - 1; ++i) {
506  L.push_back(pnts[i][0][0][0]);
507  L.push_back(pnts[i + 1][0][0][0]);
508  L.push_back(pnts[i][0][0][1]);
509  L.push_back(pnts[i + 1][0][0][1]);
510  L.push_back(pnts[i][0][0][2]);
511  L.push_back(pnts[i + 1][0][0][2]);
512  (*nL)++;
513  for(int k = 0; k < numsteps; ++k) {
514  for(int l = 0; l < nbcomp; ++l)
515  L.push_back(vals[i][0][0][nbcomp * k + l]);
516  for(int l = 0; l < nbcomp; ++l)
517  L.push_back(vals[i + 1][0][0][nbcomp * k + l]);
518  }
519  }
520  else {
521  P.push_back(pnts[0][0][0][0]);
522  P.push_back(pnts[0][0][0][1]);
523  P.push_back(pnts[0][0][0][2]);
524  (*nP)++;
525  for(int k = 0; k < numsteps; ++k) {
526  for(int l = 0; l < nbcomp; ++l)
527  P.push_back(vals[0][0][0][nbcomp * k + l]);
528  }
529  P.push_back(pnts[getNbU() - 1][0][0][0]);
530  P.push_back(pnts[getNbU() - 1][0][0][1]);
531  P.push_back(pnts[getNbU() - 1][0][0][2]);
532  (*nP)++;
533  for(int k = 0; k < numsteps; ++k) {
534  for(int l = 0; l < nbcomp; ++l)
535  P.push_back(vals[getNbU() - 1][0][0][nbcomp * k + l]);
536  }
537  }
538  }
539  else if(getNbU() == 1) {
540  if(!boundary)
541  for(int i = 0; i < getNbV() - 1; ++i) {
542  for(int j = 0; j < getNbW() - 1; ++j) {
543  Q.push_back(pnts[0][i][j][0]);
544  Q.push_back(pnts[0][i + 1][j][0]);
545  Q.push_back(pnts[0][i + 1][j + 1][0]);
546  Q.push_back(pnts[0][i][j + 1][0]);
547  Q.push_back(pnts[0][i][j][1]);
548  Q.push_back(pnts[0][i + 1][j][1]);
549  Q.push_back(pnts[0][i + 1][j + 1][1]);
550  Q.push_back(pnts[0][i][j + 1][1]);
551  Q.push_back(pnts[0][i][j][2]);
552  Q.push_back(pnts[0][i + 1][j][2]);
553  Q.push_back(pnts[0][i + 1][j + 1][2]);
554  Q.push_back(pnts[0][i][j + 1][2]);
555  (*nQ)++;
556  for(int k = 0; k < numsteps; ++k) {
557  for(int l = 0; l < nbcomp; ++l)
558  Q.push_back(vals[0][i][j][nbcomp * k + l]);
559  for(int l = 0; l < nbcomp; ++l)
560  Q.push_back(vals[0][i + 1][j][nbcomp * k + l]);
561  for(int l = 0; l < nbcomp; ++l)
562  Q.push_back(vals[0][i + 1][j + 1][nbcomp * k + l]);
563  for(int l = 0; l < nbcomp; ++l)
564  Q.push_back(vals[0][i][j + 1][nbcomp * k + l]);
565  }
566  }
567  }
568  else {
569  for(int i = 0; i < getNbV() - 1; ++i) {
570  L.push_back(pnts[0][i][0][0]);
571  L.push_back(pnts[0][i + 1][0][0]);
572  L.push_back(pnts[0][i][0][1]);
573  L.push_back(pnts[0][i + 1][0][1]);
574  L.push_back(pnts[0][i][0][2]);
575  L.push_back(pnts[0][i + 1][0][2]);
576  (*nL)++;
577  for(int k = 0; k < numsteps; ++k) {
578  for(int l = 0; l < nbcomp; ++l)
579  L.push_back(vals[0][i][0][nbcomp * k + l]);
580  for(int l = 0; l < nbcomp; ++l)
581  L.push_back(vals[0][i + 1][0][nbcomp * k + l]);
582  }
583  L.push_back(pnts[0][i][getNbW() - 1][0]);
584  L.push_back(pnts[0][i + 1][getNbW() - 1][0]);
585  L.push_back(pnts[0][i][getNbW() - 1][1]);
586  L.push_back(pnts[0][i + 1][getNbW() - 1][1]);
587  L.push_back(pnts[0][i][getNbW() - 1][2]);
588  L.push_back(pnts[0][i + 1][getNbW() - 1][2]);
589  (*nL)++;
590  for(int k = 0; k < numsteps; ++k) {
591  for(int l = 0; l < nbcomp; ++l)
592  L.push_back(vals[0][i][getNbW()][nbcomp * k + l]);
593  for(int l = 0; l < nbcomp; ++l)
594  L.push_back(vals[0][i + 1][getNbW()][nbcomp * k + l]);
595  }
596  }
597  for(int i = 0; i < getNbW() - 1; ++i) {
598  L.push_back(pnts[0][0][i][0]);
599  L.push_back(pnts[0][0][i + 1][0]);
600  L.push_back(pnts[0][0][i][1]);
601  L.push_back(pnts[0][0][i + 1][1]);
602  L.push_back(pnts[0][0][i][2]);
603  L.push_back(pnts[0][0][i + 1][2]);
604  (*nL)++;
605  for(int k = 0; k < numsteps; ++k) {
606  for(int l = 0; l < nbcomp; ++l)
607  L.push_back(vals[0][0][i][nbcomp * k + l]);
608  for(int l = 0; l < nbcomp; ++l)
609  L.push_back(vals[0][0][i + 1][nbcomp * k + l]);
610  }
611  L.push_back(pnts[0][getNbV() - 1][i][0]);
612  L.push_back(pnts[0][getNbV() - 1][i + 1][0]);
613  L.push_back(pnts[0][getNbV() - 1][i][1]);
614  L.push_back(pnts[0][getNbV() - 1][i + 1][1]);
615  L.push_back(pnts[0][getNbV() - 1][i][2]);
616  L.push_back(pnts[0][getNbV() - 1][i + 1][2]);
617  (*nL)++;
618  for(int k = 0; k < numsteps; ++k) {
619  for(int l = 0; l < nbcomp; ++l)
620  L.push_back(vals[0][getNbV() - 1][i][nbcomp * k + l]);
621  for(int l = 0; l < nbcomp; ++l)
622  L.push_back(vals[0][getNbV() - 1][i + 1][nbcomp * k + l]);
623  }
624  }
625  }
626  }
627  else if(getNbV() == 1) {
628  if(!boundary)
629  for(int i = 0; i < getNbU() - 1; ++i) {
630  for(int j = 0; j < getNbW() - 1; ++j) {
631  Q.push_back(pnts[i][0][j][0]);
632  Q.push_back(pnts[i + 1][0][j][0]);
633  Q.push_back(pnts[i + 1][0][j + 1][0]);
634  Q.push_back(pnts[i][0][j + 1][0]);
635  Q.push_back(pnts[i][0][j][1]);
636  Q.push_back(pnts[i + 1][0][j][1]);
637  Q.push_back(pnts[i + 1][0][j + 1][1]);
638  Q.push_back(pnts[i][0][j + 1][1]);
639  Q.push_back(pnts[i][0][j][2]);
640  Q.push_back(pnts[i + 1][0][j][2]);
641  Q.push_back(pnts[i + 1][0][j + 1][2]);
642  Q.push_back(pnts[i][0][j + 1][2]);
643  (*nQ)++;
644  for(int k = 0; k < numsteps; ++k) {
645  for(int l = 0; l < nbcomp; ++l)
646  Q.push_back(vals[i][0][j][nbcomp * k + l]);
647  for(int l = 0; l < nbcomp; ++l)
648  Q.push_back(vals[i + 1][0][j][nbcomp * k + l]);
649  for(int l = 0; l < nbcomp; ++l)
650  Q.push_back(vals[i + 1][0][j + 1][nbcomp * k + l]);
651  for(int l = 0; l < nbcomp; ++l)
652  Q.push_back(vals[i][0][j + 1][nbcomp * k + l]);
653  }
654  }
655  }
656  else {
657  for(int i = 0; i < getNbU() - 1; ++i) {
658  L.push_back(pnts[i][0][0][0]);
659  L.push_back(pnts[i + 1][0][0][0]);
660  L.push_back(pnts[i][0][0][1]);
661  L.push_back(pnts[i + 1][0][0][1]);
662  L.push_back(pnts[i][0][0][2]);
663  L.push_back(pnts[i + 1][0][0][2]);
664  (*nL)++;
665  for(int k = 0; k < numsteps; ++k) {
666  for(int l = 0; l < nbcomp; ++l)
667  L.push_back(vals[i][0][0][nbcomp * k + l]);
668  for(int l = 0; l < nbcomp; ++l)
669  L.push_back(vals[i + 1][0][0][nbcomp * k + l]);
670  }
671  L.push_back(pnts[i][0][getNbW() - 1][0]);
672  L.push_back(pnts[i + 1][0][getNbW() - 1][0]);
673  L.push_back(pnts[i][0][getNbW() - 1][1]);
674  L.push_back(pnts[i + 1][0][getNbW() - 1][1]);
675  L.push_back(pnts[i][0][getNbW() - 1][2]);
676  L.push_back(pnts[i + 1][0][getNbW() - 1][2]);
677  (*nL)++;
678  for(int k = 0; k < numsteps; ++k) {
679  for(int l = 0; l < nbcomp; ++l)
680  L.push_back(vals[i][0][getNbW() - 1][nbcomp * k + l]);
681  for(int l = 0; l < nbcomp; ++l)
682  L.push_back(vals[i + 1][0][getNbW() - 1][nbcomp * k + l]);
683  }
684  }
685  for(int i = 0; i < getNbW() - 1; ++i) {
686  L.push_back(pnts[0][0][i][0]);
687  L.push_back(pnts[0][0][i + 1][0]);
688  L.push_back(pnts[0][0][i][1]);
689  L.push_back(pnts[0][0][i + 1][1]);
690  L.push_back(pnts[0][0][i][2]);
691  L.push_back(pnts[0][0][i + 1][2]);
692  (*nL)++;
693  for(int k = 0; k < numsteps; ++k) {
694  for(int l = 0; l < nbcomp; ++l)
695  L.push_back(vals[0][0][i][nbcomp * k + l]);
696  for(int l = 0; l < nbcomp; ++l)
697  L.push_back(vals[0][0][i + 1][nbcomp * k + l]);
698  }
699  L.push_back(pnts[getNbU() - 1][0][i][0]);
700  L.push_back(pnts[getNbU() - 1][0][i + 1][0]);
701  L.push_back(pnts[getNbU() - 1][0][i][1]);
702  L.push_back(pnts[getNbU() - 1][0][i + 1][1]);
703  L.push_back(pnts[getNbU() - 1][0][i][2]);
704  L.push_back(pnts[getNbU() - 1][0][i + 1][2]);
705  (*nL)++;
706  for(int k = 0; k < numsteps; ++k) {
707  for(int l = 0; l < nbcomp; ++l)
708  L.push_back(vals[getNbU() - 1][0][i][nbcomp * k + l]);
709  for(int l = 0; l < nbcomp; ++l)
710  L.push_back(vals[getNbU() - 1][0][i + 1][nbcomp * k + l]);
711  }
712  }
713  }
714  }
715  else if(getNbW() == 1) {
716  if(!boundary)
717  for(int i = 0; i < getNbU() - 1; ++i) {
718  for(int j = 0; j < getNbV() - 1; ++j) {
719  Q.push_back(pnts[i][j][0][0]);
720  Q.push_back(pnts[i + 1][j][0][0]);
721  Q.push_back(pnts[i + 1][j + 1][0][0]);
722  Q.push_back(pnts[i][j + 1][0][0]);
723  Q.push_back(pnts[i][j][0][1]);
724  Q.push_back(pnts[i + 1][j][0][1]);
725  Q.push_back(pnts[i + 1][j + 1][0][1]);
726  Q.push_back(pnts[i][j + 1][0][1]);
727  Q.push_back(pnts[i][j][0][2]);
728  Q.push_back(pnts[i + 1][j][0][2]);
729  Q.push_back(pnts[i + 1][j + 1][0][2]);
730  Q.push_back(pnts[i][j + 1][0][2]);
731  (*nQ)++;
732  for(int k = 0; k < numsteps; ++k) {
733  for(int l = 0; l < nbcomp; ++l)
734  Q.push_back(vals[i][j][0][nbcomp * k + l]);
735  for(int l = 0; l < nbcomp; ++l)
736  Q.push_back(vals[i + 1][j][0][nbcomp * k + l]);
737  for(int l = 0; l < nbcomp; ++l)
738  Q.push_back(vals[i + 1][j + 1][0][nbcomp * k + l]);
739  for(int l = 0; l < nbcomp; ++l)
740  Q.push_back(vals[i][j + 1][0][nbcomp * k + l]);
741  }
742  }
743  }
744  else {
745  for(int i = 0; i < getNbU() - 1; ++i) {
746  L.push_back(pnts[i][0][0][0]);
747  L.push_back(pnts[i + 1][0][0][0]);
748  L.push_back(pnts[i][0][0][1]);
749  L.push_back(pnts[i + 1][0][0][1]);
750  L.push_back(pnts[i][0][0][2]);
751  L.push_back(pnts[i + 1][0][0][2]);
752  (*nL)++;
753  for(int k = 0; k < numsteps; ++k) {
754  for(int l = 0; l < nbcomp; ++l)
755  L.push_back(vals[i][0][0][nbcomp * k + l]);
756  for(int l = 0; l < nbcomp; ++l)
757  L.push_back(vals[i + 1][0][0][nbcomp * k + l]);
758  }
759  L.push_back(pnts[i][getNbV() - 1][0][0]);
760  L.push_back(pnts[i + 1][getNbV() - 1][0][0]);
761  L.push_back(pnts[i][getNbV() - 1][0][1]);
762  L.push_back(pnts[i + 1][getNbV() - 1][0][1]);
763  L.push_back(pnts[i][getNbV() - 1][0][2]);
764  L.push_back(pnts[i + 1][getNbV() - 1][0][2]);
765  (*nL)++;
766  for(int k = 0; k < numsteps; ++k) {
767  for(int l = 0; l < nbcomp; ++l)
768  L.push_back(vals[i][getNbV() - 1][0][nbcomp * k + l]);
769  for(int l = 0; l < nbcomp; ++l)
770  L.push_back(vals[i + 1][getNbV() - 1][0][nbcomp * k + l]);
771  }
772  }
773  for(int i = 0; i < getNbV() - 1; ++i) {
774  L.push_back(pnts[0][i][0][0]);
775  L.push_back(pnts[0][i + 1][0][0]);
776  L.push_back(pnts[0][i][0][1]);
777  L.push_back(pnts[0][i + 1][0][1]);
778  L.push_back(pnts[0][i][0][2]);
779  L.push_back(pnts[0][i + 1][0][2]);
780  (*nL)++;
781  for(int k = 0; k < numsteps; ++k) {
782  for(int l = 0; l < nbcomp; ++l)
783  L.push_back(vals[0][i][0][nbcomp * k + l]);
784  for(int l = 0; l < nbcomp; ++l)
785  L.push_back(vals[0][i + 1][0][nbcomp * k + l]);
786  }
787  L.push_back(pnts[getNbU() - 1][i][0][0]);
788  L.push_back(pnts[getNbU() - 1][i + 1][0][0]);
789  L.push_back(pnts[getNbU() - 1][i][0][1]);
790  L.push_back(pnts[getNbU() - 1][i + 1][0][1]);
791  L.push_back(pnts[getNbU() - 1][i][0][2]);
792  L.push_back(pnts[getNbU() - 1][i + 1][0][2]);
793  (*nL)++;
794  for(int k = 0; k < numsteps; ++k) {
795  for(int l = 0; l < nbcomp; ++l)
796  L.push_back(vals[getNbU() - 1][i][0][nbcomp * k + l]);
797  for(int l = 0; l < nbcomp; ++l)
798  L.push_back(vals[getNbU() - 1][i + 1][0][nbcomp * k + l]);
799  }
800  }
801  }
802  }
803  // from here, general case
804  else {
805  if(!boundary) { // Hexaedra in the box
806  for(int i = 0; i < getNbU() - 1; ++i) {
807  for(int j = 0; j < getNbV() - 1; ++j) {
808  for(int m = 0; m < getNbW() - 1; ++m) {
809  H.push_back(pnts[i][j][m][0]);
810  H.push_back(pnts[i + 1][j][m][0]);
811  H.push_back(pnts[i + 1][j + 1][m][0]);
812  H.push_back(pnts[i][j + 1][m][0]);
813  H.push_back(pnts[i][j][m + 1][0]);
814  H.push_back(pnts[i + 1][j][m + 1][0]);
815  H.push_back(pnts[i + 1][j + 1][m + 1][0]);
816  H.push_back(pnts[i][j + 1][m + 1][0]);
817 
818  H.push_back(pnts[i][j][m][1]);
819  H.push_back(pnts[i + 1][j][m][1]);
820  H.push_back(pnts[i + 1][j + 1][m][1]);
821  H.push_back(pnts[i][j + 1][m][1]);
822  H.push_back(pnts[i][j][m + 1][1]);
823  H.push_back(pnts[i + 1][j][m + 1][1]);
824  H.push_back(pnts[i + 1][j + 1][m + 1][1]);
825  H.push_back(pnts[i][j + 1][m + 1][1]);
826 
827  H.push_back(pnts[i][j][m][2]);
828  H.push_back(pnts[i + 1][j][m][2]);
829  H.push_back(pnts[i + 1][j + 1][m][2]);
830  H.push_back(pnts[i][j + 1][m][2]);
831  H.push_back(pnts[i][j][m + 1][2]);
832  H.push_back(pnts[i + 1][j][m + 1][2]);
833  H.push_back(pnts[i + 1][j + 1][m + 1][2]);
834  H.push_back(pnts[i][j + 1][m + 1][2]);
835  (*nH)++;
836 
837  for(int k = 0; k < numsteps; ++k) {
838  for(int l = 0; l < nbcomp; ++l)
839  H.push_back(vals[i][j][m][nbcomp * k + l]);
840  for(int l = 0; l < nbcomp; ++l)
841  H.push_back(vals[i + 1][j][m][nbcomp * k + l]);
842  for(int l = 0; l < nbcomp; ++l)
843  H.push_back(vals[i + 1][j + 1][m][nbcomp * k + l]);
844  for(int l = 0; l < nbcomp; ++l)
845  H.push_back(vals[i][j + 1][m][nbcomp * k + l]);
846  for(int l = 0; l < nbcomp; ++l)
847  H.push_back(vals[i][j][m + 1][nbcomp * k + l]);
848  for(int l = 0; l < nbcomp; ++l)
849  H.push_back(vals[i + 1][j][m + 1][nbcomp * k + l]);
850  for(int l = 0; l < nbcomp; ++l)
851  H.push_back(vals[i + 1][j + 1][m + 1][nbcomp * k + l]);
852  for(int l = 0; l < nbcomp; ++l)
853  H.push_back(vals[i][j + 1][m + 1][nbcomp * k + l]);
854  }
855  }
856  }
857  }
858  }
859  else { // Quadrangles at boundary of the box + forcing exterior normals
860  for(int i = 0; i < getNbU() - 1; ++i) {
861  for(int j = 0; j < getNbV() - 1; ++j) {
862  Q.push_back(pnts[i][j][0][0]);
863  Q.push_back(pnts[i][j + 1][0][0]);
864  Q.push_back(pnts[i + 1][j + 1][0][0]);
865  Q.push_back(pnts[i + 1][j][0][0]);
866  Q.push_back(pnts[i][j][0][1]);
867  Q.push_back(pnts[i][j + 1][0][1]);
868  Q.push_back(pnts[i + 1][j + 1][0][1]);
869  Q.push_back(pnts[i + 1][j][0][1]);
870  Q.push_back(pnts[i][j][0][2]);
871  Q.push_back(pnts[i][j + 1][0][2]);
872  Q.push_back(pnts[i + 1][j + 1][0][2]);
873  Q.push_back(pnts[i + 1][j][0][2]);
874  (*nQ)++;
875  for(int k = 0; k < numsteps; ++k) {
876  for(int l = 0; l < nbcomp; ++l)
877  Q.push_back(vals[i][j][0][nbcomp * k + l]);
878  for(int l = 0; l < nbcomp; ++l)
879  Q.push_back(vals[i][j + 1][0][nbcomp * k + l]);
880  for(int l = 0; l < nbcomp; ++l)
881  Q.push_back(vals[i + 1][j + 1][0][nbcomp * k + l]);
882  for(int l = 0; l < nbcomp; ++l)
883  Q.push_back(vals[i + 1][j][0][nbcomp * k + l]);
884  }
885  Q.push_back(pnts[i][j][getNbW() - 1][0]);
886  Q.push_back(pnts[i + 1][j][getNbW() - 1][0]);
887  Q.push_back(pnts[i + 1][j + 1][getNbW() - 1][0]);
888  Q.push_back(pnts[i][j + 1][getNbW() - 1][0]);
889  Q.push_back(pnts[i][j][getNbW() - 1][1]);
890  Q.push_back(pnts[i + 1][j][getNbW() - 1][1]);
891  Q.push_back(pnts[i + 1][j + 1][getNbW() - 1][1]);
892  Q.push_back(pnts[i][j + 1][getNbW() - 1][1]);
893  Q.push_back(pnts[i][j][getNbW() - 1][2]);
894  Q.push_back(pnts[i + 1][j][getNbW() - 1][2]);
895  Q.push_back(pnts[i + 1][j + 1][getNbW() - 1][2]);
896  Q.push_back(pnts[i][j + 1][getNbW() - 1][2]);
897  (*nQ)++;
898  for(int k = 0; k < numsteps; ++k) {
899  for(int l = 0; l < nbcomp; ++l)
900  Q.push_back(vals[i][j][getNbW() - 1][nbcomp * k + l]);
901  for(int l = 0; l < nbcomp; ++l)
902  Q.push_back(vals[i + 1][j][getNbW() - 1][nbcomp * k + l]);
903  for(int l = 0; l < nbcomp; ++l)
904  Q.push_back(vals[i + 1][j + 1][getNbW() - 1][nbcomp * k + l]);
905  for(int l = 0; l < nbcomp; ++l)
906  Q.push_back(vals[i][j + 1][getNbW() - 1][nbcomp * k + l]);
907  }
908  }
909  }
910  for(int i = 0; i < getNbU() - 1; ++i) {
911  for(int j = 0; j < getNbW() - 1; ++j) {
912  Q.push_back(pnts[i][0][j][0]);
913  Q.push_back(pnts[i + 1][0][j][0]);
914  Q.push_back(pnts[i + 1][0][j + 1][0]);
915  Q.push_back(pnts[i][0][j + 1][0]);
916  Q.push_back(pnts[i][0][j][1]);
917  Q.push_back(pnts[i + 1][0][j][1]);
918  Q.push_back(pnts[i + 1][0][j + 1][1]);
919  Q.push_back(pnts[i][0][j + 1][1]);
920  Q.push_back(pnts[i][0][j][2]);
921  Q.push_back(pnts[i + 1][0][j][2]);
922  Q.push_back(pnts[i + 1][0][j + 1][2]);
923  Q.push_back(pnts[i][0][j + 1][2]);
924  (*nQ)++;
925  for(int k = 0; k < numsteps; ++k) {
926  for(int l = 0; l < nbcomp; ++l)
927  Q.push_back(vals[i][0][j][nbcomp * k + l]);
928  for(int l = 0; l < nbcomp; ++l)
929  Q.push_back(vals[i + 1][0][j][nbcomp * k + l]);
930  for(int l = 0; l < nbcomp; ++l)
931  Q.push_back(vals[i + 1][0][j + 1][nbcomp * k + l]);
932  for(int l = 0; l < nbcomp; ++l)
933  Q.push_back(vals[i][0][j + 1][nbcomp * k + l]);
934  }
935  Q.push_back(pnts[i][getNbV() - 1][j][0]);
936  Q.push_back(pnts[i][getNbV() - 1][j + 1][0]);
937  Q.push_back(pnts[i + 1][getNbV() - 1][j + 1][0]);
938  Q.push_back(pnts[i + 1][getNbV() - 1][j][0]);
939  Q.push_back(pnts[i][getNbV() - 1][j][1]);
940  Q.push_back(pnts[i][getNbV() - 1][j + 1][1]);
941  Q.push_back(pnts[i + 1][getNbV() - 1][j + 1][1]);
942  Q.push_back(pnts[i + 1][getNbV() - 1][j][1]);
943  Q.push_back(pnts[i][getNbV() - 1][j][2]);
944  Q.push_back(pnts[i][getNbV() - 1][j + 1][2]);
945  Q.push_back(pnts[i + 1][getNbV() - 1][j + 1][2]);
946  Q.push_back(pnts[i + 1][getNbV() - 1][j][2]);
947  (*nQ)++;
948  for(int k = 0; k < numsteps; ++k) {
949  for(int l = 0; l < nbcomp; ++l)
950  Q.push_back(vals[i][getNbV() - 1][j][nbcomp * k + l]);
951  for(int l = 0; l < nbcomp; ++l)
952  Q.push_back(vals[i][getNbV() - 1][j + 1][nbcomp * k + l]);
953  for(int l = 0; l < nbcomp; ++l)
954  Q.push_back(vals[i + 1][getNbV() - 1][j + 1][nbcomp * k + l]);
955  for(int l = 0; l < nbcomp; ++l)
956  Q.push_back(vals[i + 1][getNbV() - 1][j][nbcomp * k + l]);
957  }
958  }
959  }
960 
961  for(int i = 0; i < getNbV() - 1; ++i) {
962  for(int j = 0; j < getNbW() - 1; ++j) {
963  Q.push_back(pnts[0][i][j][0]);
964  Q.push_back(pnts[0][i][j + 1][0]);
965  Q.push_back(pnts[0][i + 1][j + 1][0]);
966  Q.push_back(pnts[0][i + 1][j][0]);
967  Q.push_back(pnts[0][i][j][1]);
968  Q.push_back(pnts[0][i][j + 1][1]);
969  Q.push_back(pnts[0][i + 1][j + 1][1]);
970  Q.push_back(pnts[0][i + 1][j][1]);
971  Q.push_back(pnts[0][i][j][2]);
972  Q.push_back(pnts[0][i][j + 1][2]);
973  Q.push_back(pnts[0][i + 1][j + 1][2]);
974  Q.push_back(pnts[0][i + 1][j][2]);
975  (*nQ)++;
976  for(int k = 0; k < numsteps; ++k) {
977  for(int l = 0; l < nbcomp; ++l)
978  Q.push_back(vals[0][i][j][nbcomp * k + l]);
979  for(int l = 0; l < nbcomp; ++l)
980  Q.push_back(vals[0][i][j + 1][nbcomp * k + l]);
981  for(int l = 0; l < nbcomp; ++l)
982  Q.push_back(vals[0][i + 1][j + 1][nbcomp * k + l]);
983  for(int l = 0; l < nbcomp; ++l)
984  Q.push_back(vals[0][i + 1][j][nbcomp * k + l]);
985  }
986  Q.push_back(pnts[getNbU() - 1][i][j][0]);
987  Q.push_back(pnts[getNbU() - 1][i + 1][j][0]);
988  Q.push_back(pnts[getNbU() - 1][i + 1][j + 1][0]);
989  Q.push_back(pnts[getNbU() - 1][i][j + 1][0]);
990  Q.push_back(pnts[getNbU() - 1][i][j][1]);
991  Q.push_back(pnts[getNbU() - 1][i + 1][j][1]);
992  Q.push_back(pnts[getNbU() - 1][i + 1][j + 1][1]);
993  Q.push_back(pnts[getNbU() - 1][i][j + 1][1]);
994  Q.push_back(pnts[getNbU() - 1][i][j][2]);
995  Q.push_back(pnts[getNbU() - 1][i + 1][j][2]);
996  Q.push_back(pnts[getNbU() - 1][i + 1][j + 1][2]);
997  Q.push_back(pnts[getNbU() - 1][i][j + 1][2]);
998  (*nQ)++;
999  for(int k = 0; k < numsteps; ++k) {
1000  for(int l = 0; l < nbcomp; ++l)
1001  Q.push_back(vals[getNbU() - 1][i][j][nbcomp * k + l]);
1002  for(int l = 0; l < nbcomp; ++l)
1003  Q.push_back(vals[getNbU() - 1][i + 1][j][nbcomp * k + l]);
1004  for(int l = 0; l < nbcomp; ++l)
1005  Q.push_back(vals[getNbU() - 1][i + 1][j + 1][nbcomp * k + l]);
1006  for(int l = 0; l < nbcomp; ++l)
1007  Q.push_back(vals[getNbU() - 1][i][j + 1][nbcomp * k + l]);
1008  }
1009  }
1010  }
1011  }
1012  }
1013  }
1014 }
1015 
1016 PView *GMSH_CutBoxPlugin::GenerateView(PView *v1, int connect, int boundary)
1017 {
1018  if(getNbU() <= 0 || getNbV() <= 0 || getNbW() <= 0) return v1;
1019 
1020  PViewData *data1 = getPossiblyAdaptiveData(v1);
1021 
1022  PView *v2 = new PView();
1023  PViewDataList *data2 = getDataList(v2);
1024 
1025  OctreePost o(v1);
1026 
1027  int nbs = data1->getNumScalars();
1028  int nbv = data1->getNumVectors();
1029  int nbt = data1->getNumTensors();
1030  int maxcomp = nbt ? 9 : (nbv ? 3 : 1);
1031  int numsteps = data1->getNumTimeSteps();
1032 
1033  double ****pnts = new double ***[getNbU()];
1034  double ****vals = new double ***[getNbU()];
1035  for(int i = 0; i < getNbU(); i++) {
1036  pnts[i] = new double **[getNbV()];
1037  vals[i] = new double **[getNbV()];
1038  for(int j = 0; j < getNbV(); j++) {
1039  pnts[i][j] = new double *[getNbW()];
1040  vals[i][j] = new double *[getNbW()];
1041  for(int k = 0; k < getNbW(); k++) {
1042  pnts[i][j][k] = new double[3];
1043  vals[i][j][k] = new double[maxcomp * numsteps];
1044  getPoint(i, j, k, pnts[i][j][k]);
1045  }
1046  }
1047  }
1048 
1049  if(nbs) {
1050  for(int i = 0; i < getNbU(); i++)
1051  for(int j = 0; j < getNbV(); j++)
1052  for(int k = 0; k < getNbW(); k++)
1053  o.searchScalar(pnts[i][j][k][0], pnts[i][j][k][1], pnts[i][j][k][2],
1054  vals[i][j][k]);
1055  addInView(connect, boundary, numsteps, 1, pnts, vals, data2->SP,
1056  &data2->NbSP, data2->SL, &data2->NbSL, data2->SQ, &data2->NbSQ,
1057  data2->SH, &data2->NbSH);
1058  }
1059 
1060  if(nbv) {
1061  for(int i = 0; i < getNbU(); i++)
1062  for(int j = 0; j < getNbV(); j++)
1063  for(int k = 0; k < getNbW(); k++)
1064  o.searchVector(pnts[i][j][k][0], pnts[i][j][k][1], pnts[i][j][k][2],
1065  vals[i][j][k]);
1066  addInView(connect, boundary, numsteps, 3, pnts, vals, data2->VP,
1067  &data2->NbVP, data2->VL, &data2->NbVL, data2->VQ, &data2->NbVQ,
1068  data2->VH, &data2->NbVH);
1069  }
1070 
1071  if(nbt) {
1072  for(int i = 0; i < getNbU(); i++)
1073  for(int j = 0; j < getNbV(); j++)
1074  for(int k = 0; k < getNbW(); k++)
1075  o.searchTensor(pnts[i][j][k][0], pnts[i][j][k][1], pnts[i][j][k][2],
1076  vals[i][j][k]);
1077  addInView(connect, boundary, numsteps, 9, pnts, vals, data2->TP,
1078  &data2->NbTP, data2->TL, &data2->NbTL, data2->TQ, &data2->NbTQ,
1079  data2->TH, &data2->NbTH);
1080  }
1081 
1082  for(int i = 0; i < getNbU(); i++) {
1083  for(int j = 0; j < getNbV(); j++) {
1084  for(int k = 0; k < getNbW(); k++) {
1085  delete[] pnts[i][j][k];
1086  delete[] vals[i][j][k];
1087  }
1088  delete[] pnts[i][j];
1089  delete[] vals[i][j];
1090  }
1091  delete[] pnts[i];
1092  delete[] vals[i];
1093  }
1094  delete[] pnts;
1095  delete[] vals;
1096 
1097  data2->setName(data1->getName() + "_CutBox");
1098  data2->setFileName(data1->getName() + "_CutBox.pos");
1099  data2->finalize();
1100 
1101  return v2;
1102 }
1103 
1105 {
1106  int connectPoints = (int)CutBoxOptions_Number[15].def;
1107  int boundary = (int)CutBoxOptions_Number[16].def;
1108  int iView = (int)CutBoxOptions_Number[17].def;
1109 
1110  PView *v1 = getView(iView, v);
1111  if(!v1) return v;
1112 
1113  return GenerateView(v1, connectPoints, boundary);
1114 }
GMSH_CutBoxPlugin::callbackW
static double callbackW(int, int, double)
Definition: CutBox.cpp:273
PViewDataList::VQ
std::vector< double > VQ
Definition: PViewDataList.h:33
GMSH_CutBoxPlugin::getNbV
static int getNbV()
Definition: CutBox.cpp:319
GMSH_CutBoxPlugin::callbackU
static double callbackU(int, int, double)
Definition: CutBox.cpp:263
PView
Definition: PView.h:27
PViewDataList::TQ
std::vector< double > TQ
Definition: PViewDataList.h:33
CutBoxOptions_Number
StringXNumber CutBoxOptions_Number[]
Definition: CutBox.cpp:15
GMSH_CutBoxPlugin::GenerateView
PView * GenerateView(PView *v, int connectPoints, int boundary)
Definition: CutBox.cpp:1016
GMSH_CutBoxPlugin::getOption
StringXNumber * getOption(int iopt)
Definition: CutBox.cpp:312
GMSH_CutBoxPlugin::getNbOptions
int getNbOptions() const
Definition: CutBox.cpp:307
OctreePost::searchScalar
bool searchScalar(double x, double y, double z, double *values, int step=-1, double *size=nullptr, int qn=0, double *qx=nullptr, double *qy=nullptr, double *qz=nullptr, bool grad=false, int dim=-1)
Definition: OctreePost.cpp:578
PViewDataList::NbTL
int NbTL
Definition: PViewDataList.h:28
PViewDataList::TL
std::vector< double > TL
Definition: PViewDataList.h:29
GMSH_Plugin
Definition: Plugin.h:26
StringXNumber::def
double def
Definition: Options.h:922
PViewData::getNumTimeSteps
virtual int getNumTimeSteps()=0
PViewDataList::NbTP
int NbTP
Definition: PViewDataList.h:26
OctreePost.h
PViewDataList
Definition: PViewDataList.h:17
GMSH_CutBoxPlugin::callbackX0
static double callbackX0(int, int, double)
Definition: CutBox.cpp:179
GMSH_Plugin::draw
static void(* draw)(void *)
Definition: Plugin.h:77
PViewDataList::NbSP
int NbSP
Definition: PViewDataList.h:26
drawContext::drawString
void drawString(const std::string &s, double x, double y, double z, const std::string &font_name, int font_enum, int font_size, int align, int line_num=0)
Definition: drawGlyph.cpp:16
StringXNumber
Definition: Options.h:918
PViewDataList::NbSQ
int NbSQ
Definition: PViewDataList.h:32
OctreePost
Definition: BoundaryLayers.cpp:23
PViewDataList::NbSH
int NbSH
Definition: PViewDataList.h:38
PViewDataList::VL
std::vector< double > VL
Definition: PViewDataList.h:29
GMSH_CutBoxPlugin::callbackY2
static double callbackY2(int, int, double)
Definition: CutBox.cpp:228
GMSH_CutBoxPlugin::getNbW
static int getNbW()
Definition: CutBox.cpp:321
PViewDataList::NbVH
int NbVH
Definition: PViewDataList.h:38
PViewData::setFileName
virtual void setFileName(const std::string &val)
Definition: PViewData.h:75
PViewDataList::VH
std::vector< double > VH
Definition: PViewDataList.h:39
GMSH_CutBoxPlugin::callbackZ3
static double callbackZ3(int, int, double)
Definition: CutBox.cpp:256
CTX::fg
unsigned int fg
Definition: Context.h:358
CTX::instance
static CTX * instance()
Definition: Context.cpp:122
GMSH_CutBoxPlugin::callbackX3
static double callbackX3(int, int, double)
Definition: CutBox.cpp:242
GMSH_CutBoxPlugin::callbackY3
static double callbackY3(int, int, double)
Definition: CutBox.cpp:249
PViewDataList::TP
std::vector< double > TP
Definition: PViewDataList.h:27
GMSH_CutBoxPlugin::callbackX1
static double callbackX1(int, int, double)
Definition: CutBox.cpp:200
GMSH_CutBoxPlugin::callbackY1
static double callbackY1(int, int, double)
Definition: CutBox.cpp:207
PViewDataList::VP
std::vector< double > VP
Definition: PViewDataList.h:27
PViewDataList::NbTH
int NbTH
Definition: PViewDataList.h:38
GMSH_CutBoxPlugin::callbackZ1
static double callbackZ1(int, int, double)
Definition: CutBox.cpp:214
PViewDataList::SP
std::vector< double > SP
Definition: PViewDataList.h:27
PViewData::getNumScalars
virtual int getNumScalars(int step=-1)
Definition: PViewData.h:111
GMSH_FULLRC
#define GMSH_FULLRC
Definition: Options.h:20
PViewDataList::SL
std::vector< double > SL
Definition: PViewDataList.h:29
GMSH_CutBoxPlugin::getHelp
std::string getHelp() const
Definition: CutBox.cpp:288
GMSH_CutBoxPlugin::callbackBoundary
static double callbackBoundary(int, int, double)
Definition: CutBox.cpp:283
drawContext
Definition: drawContext.h:120
PViewDataList::finalize
bool finalize(bool computeMinMax=true, const std::string &interpolationScheme="")
Definition: PViewDataList.cpp:81
PViewData::setName
virtual void setName(const std::string &val)
Definition: PViewData.h:71
GMSH_CutBoxPlugin
Definition: CutBox.h:15
PViewDataList::NbVP
int NbVP
Definition: PViewDataList.h:26
PViewData::getNumVectors
virtual int getNumVectors(int step=-1)
Definition: PViewData.h:112
PViewData
Definition: PViewData.h:29
GMSH_CutBoxPlugin::addInView
void addInView(int connect, int boundary, int numsteps, int nbcomp, double ****pnts, double ****vals, std::vector< double > &P, int *nP, std::vector< double > &L, int *nL, std::vector< double > &Q, int *nQ, std::vector< double > &H, int *nH)
Definition: CutBox.cpp:343
GMSH_CutBoxPlugin::getPoint
static void getPoint(int iU, int iV, int iW, double *X)
Definition: CutBox.cpp:323
GMSH_CutBoxPlugin::callback
static double callback(int num, int action, double value, double *opt, double step, double min, double max)
Definition: CutBox.cpp:164
PViewDataList::NbSL
int NbSL
Definition: PViewDataList.h:28
PViewDataList::TH
std::vector< double > TH
Definition: PViewDataList.h:39
PViewDataList::SH
std::vector< double > SH
Definition: PViewDataList.h:39
Context.h
OctreePost::searchVector
bool searchVector(double x, double y, double z, double *values, int step=-1, double *size=nullptr, int qn=0, double *qx=nullptr, double *qy=nullptr, double *qz=nullptr, bool grad=false, int dim=-1)
Definition: OctreePost.cpp:634
PViewData::getNumTensors
virtual int getNumTensors(int step=-1)
Definition: PViewData.h:113
PViewDataList::NbVL
int NbVL
Definition: PViewDataList.h:28
GMSH_Plugin::setDrawFunction
static void setDrawFunction(void(*fct)(void *))
Definition: Plugin.cpp:21
GMSH_CutBoxPlugin::callbackX2
static double callbackX2(int, int, double)
Definition: CutBox.cpp:221
GMSH_PostPlugin::getView
virtual PView * getView(int index, PView *view)
Definition: Plugin.cpp:81
GMSH_RegisterCutBoxPlugin
GMSH_Plugin * GMSH_RegisterCutBoxPlugin()
Definition: CutBox.cpp:36
GMSH_PostPlugin::getPossiblyAdaptiveData
virtual PViewData * getPossiblyAdaptiveData(PView *view)
Definition: Plugin.cpp:94
CutBox.h
GMSH_CutBoxPlugin::callbackY0
static double callbackY0(int, int, double)
Definition: CutBox.cpp:186
GMSH_CutBoxPlugin::execute
PView * execute(PView *)
Definition: CutBox.cpp:1104
PViewDataList::NbTQ
int NbTQ
Definition: PViewDataList.h:32
GMSH_CutBoxPlugin::getNbU
static int getNbU()
Definition: CutBox.cpp:317
PViewData::getName
virtual std::string getName()
Definition: PViewData.h:70
PViewDataList::NbVQ
int NbVQ
Definition: PViewDataList.h:32
PViewDataList::SQ
std::vector< double > SQ
Definition: PViewDataList.h:33
GMSH_CutBoxPlugin::callbackConnect
static double callbackConnect(int, int, double)
Definition: CutBox.cpp:278
GMSH_CutBoxPlugin::callbackZ2
static double callbackZ2(int, int, double)
Definition: CutBox.cpp:235
drawContext::drawSphere
void drawSphere(double R, double x, double y, double z, int n1, int n2, int light)
Definition: drawGlyph.cpp:390
GMSH_CutBoxPlugin::callbackV
static double callbackV(int, int, double)
Definition: CutBox.cpp:268
GMSH_CutBoxPlugin::callbackZ0
static double callbackZ0(int, int, double)
Definition: CutBox.cpp:193
GMSH_PostPlugin::getDataList
virtual PViewDataList * getDataList(PView *view, bool showError=true)
Definition: Plugin.cpp:107
OctreePost::searchTensor
bool searchTensor(double x, double y, double z, double *values, int step=-1, double *size=nullptr, int qn=0, double *qx=nullptr, double *qy=nullptr, double *qz=nullptr, bool grad=false, int dim=-1)
Definition: OctreePost.cpp:690
drawContext.h