7 #include "GmshConfig.h"
13 #if defined(HAVE_OPENGL)
29 "2 * Cos(u) * Sin(v)"},
31 "4 * Sin(u) * Sin(v)"},
33 "0.1 + 0.5 * Cos(v)"}};
51 return minU + (double)(i) / (double)(nbU - 1) * (maxU - minU);
63 return minV + (double)(i) / (double)(nbV - 1) * (maxV - minV);
73 std::vector<std::string> expressions(3), variables(2);
74 for(
int i = 0; i < 3; i++)
79 if(expressions.empty())
return 0;
86 std::vector<double> val(2), res(3);
87 for(
int i = 0; i < nbU; ++i) {
89 for(
int j = 0; j < nbV; ++j) {
91 if(
f.eval(val, res)) {
92 x[i * nbV + j] = res[0];
93 y[i * nbV + j] = res[1];
94 z[i * nbV + j] = res[2];
103 #if defined(HAVE_OPENGL)
112 if(nbU == 1 || nbV == 1) {
114 for(std::size_t i = 1; i <
x.size(); ++i) {
115 glVertex3d(
x[i - 1],
y[i - 1],
z[i - 1]);
116 glVertex3d(
x[i],
y[i],
z[i]);
121 glBegin(GL_TRIANGLES);
122 for(
int i = 0; i < nbU - 1; ++i) {
123 for(
int j = 0; j < nbV - 1; ++j) {
125 glVertex3d(
x[v],
y[v],
z[v]);
126 glVertex3d(
x[v + 1],
y[v + 1],
z[v + 1]);
127 glVertex3d(
x[v + 1 + nbV],
y[v + 1 + nbV],
z[v + 1 + nbV]);
129 glVertex3d(
x[v],
y[v],
z[v]);
130 glVertex3d(
x[v + nbV],
y[v + nbV],
z[v + nbV]);
131 glVertex3d(
x[v + 1 + nbV],
y[v + 1 + nbV],
z[v + 1 + nbV]);
139 for(std::size_t i = 0; i <
x.size(); ++i)
146 double *opt,
double step,
double min,
162 const std::string &value,
215 const std::string &value)
221 const std::string &value)
227 const std::string &value)
234 return "Plugin(CutParametric) cuts the view `View' with "
235 "the parametric function (`X'(u,v), `Y'(u,v), `Z'(u,v)), "
236 "using `NumPointsU' values of the parameter u in "
237 "[`MinU', `MaxU'] and `NumPointsV' values of the parameter v in "
238 "[`MinV', `MaxV'].\n\n"
239 "If `ConnectPoints' is set, the plugin creates surface or line "
240 "elements; otherwise, the plugin generates points.\n\n"
241 "If `View' < 0, the plugin is run on the current view.\n\n"
242 "Plugin(CutParametric) creates one new list-based view.";
265 static void addInView(
int connect,
int i,
int nbcomp,
int nbtime,
double x0,
266 double y0,
double z0,
double *res0,
double x,
double y,
267 double z,
double *res, std::vector<double> &P,
int *nP,
268 std::vector<double> &L,
int *nL)
278 for(
int k = 0; k < nbtime; ++k) {
279 for(
int l = 0; l < nbcomp; ++l) L.push_back(res0[nbcomp * k + l]);
280 for(
int l = 0; l < nbcomp; ++l) L.push_back(res[nbcomp * k + l]);
289 for(
int k = 0; k < nbtime; ++k)
290 for(
int l = 0; l < nbcomp; ++l) P.push_back(res[nbcomp * k + l]);
295 static void addInView(
int nbcomp,
int nbtime,
double x0,
double y0,
double z0,
296 double *res0,
double x1,
double y1,
double z1,
297 double *res1,
double x2,
double y2,
double z2,
298 double *res2,
double x3,
double y3,
double z3,
299 double *res3, std::vector<double> &Q,
int *nQ)
313 for(
int k = 0; k < nbtime; ++k) {
314 for(
int l = 0; l < nbcomp; ++l) Q.push_back(res0[nbcomp * k + l]);
315 for(
int l = 0; l < nbcomp; ++l) Q.push_back(res1[nbcomp * k + l]);
316 for(
int l = 0; l < nbcomp; ++l) Q.push_back(res2[nbcomp * k + l]);
317 for(
int l = 0; l < nbcomp; ++l) Q.push_back(res3[nbcomp * k + l]);
337 if(nbU < 2 && nbV < 2) connect = 0;
344 double *res0 =
new double[9 * numSteps];
345 double *res1 =
new double[9 * numSteps];
346 double *res2 =
new double[9 * numSteps];
347 double *res3 =
new double[9 * numSteps];
348 double x0 = 0., y0 = 0., z0 = 0., x1 = 0., y1 = 0., z1 = 0.;
349 double x2 = 0., y2 = 0., z2 = 0., x3 = 0., y3 = 0., z3 = 0.;
351 for(
int k = 0; k < 9 * numSteps; ++k) res0[k] = res1[k] = 0.;
353 if(nbU == 1 || nbV == 1 || !connect) {
354 for(std::size_t i = 0; i <
x.size(); ++i) {
359 for(
int k = 0; k < 9 * numSteps; ++k) res0[k] = res1[k];
368 addInView(connect, i, 1, numSteps, x0, y0, z0, res0, x1, y1, z1, res1,
373 addInView(connect, i, 3, numSteps, x0, y0, z0, res0, x1, y1, z1, res1,
378 addInView(connect, i, 9, numSteps, x0, y0, z0, res0, x1, y1, z1, res1,
384 for(
int i = 0; i < nbU - 1; ++i) {
385 for(
int j = 0; j < nbV - 1; ++j) {
405 addInView(1, numSteps, x0, y0, z0, res0, x1, y1, z1, res1, x2, y2, z2,
406 res2, x3, y3, z3, res3, data2->
SQ, &data2->
NbSQ);
413 addInView(3, numSteps, x0, y0, z0, res0, x1, y1, z1, res1, x2, y2, z2,
414 res2, x3, y3, z3, res3, data2->
VQ, &data2->
NbVQ);
421 addInView(9, numSteps, x0, y0, z0, res0, x1, y1, z1, res1, x2, y2, z2,
422 res2, x3, y3, z3, res3, data2->
TQ, &data2->
NbTQ);