MCPcopy Create free account
hub / github.com/FreeFem/FreeFem-sources / plot_P1_isoline_body

Function plot_P1_isoline_body

plugin/seq/plotPDF.cpp:1360–1419  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1358 }
1359
1360 return;
1361}
1362
1363void plot_P1_isoline_body( std::stringstream &Content, const Fem2D::Mesh &Th, const KN<double> &f_P1,
1364 const std::vector<double> &isoline_val, const double cmin, const double cmax,
1365 const KNM<double> &palette, const double scale, const double ar,
1366 const double x0, const double y0,
1367 const int marginl, const int marginb,
1368 const bool monochrome, const bool logscale,
1369 const int NISOLINES, const double linewidth )
1370{
1371 std::stringstream &st = Content;
1372
1373 st << "q\n";
1374 st << linewidth << " w\n"; // setlinewidth
1375 st << "1 0 0 1 " << PLOTPDFVAR::PADDING+marginl << " " << PLOTPDFVAR::PADDING+marginb << " cm\n";
1376
1377 const int &nTriangles = Th.nt;
1378 for(int k = 0; k < nTriangles; k++){
1379
1380 const int &v0 = Th(k,0);
1381 const int &v1 = Th(k,1);
1382 const int &v2 = Th(k,2);
1383
1384 const double vx[] = { Th(v0).x, Th(v1).x, Th(v2).x };
1385 const double vy[] = { Th(v0).y, Th(v1).y, Th(v2).y };
1386 const double vf[] = { f_P1[3*k+0], f_P1[3*k+1], f_P1[3*k+2] };
1387
1388 for(size_t m = 0; m < isoline_val.size(); m++){
1389
1390 const double &value = isoline_val[m];
1391
1392 std::vector<double> px, py;
1393 trackP1isoline( px, py, vx, vy, value, vf );
1394
1395 assert( px.size() == py.size() );
1396
1397 if( px.size() == 0 ) continue; // goto next isoline_val
1398
1399 setrgbcolor(st, value, palette, cmin, cmax, monochrome, logscale);
1400
1401 if( px.size() > 3 ){
1402
1403 // f(x,y)==value on all vertices, i.e. f(x,y) \equiv value on the triangle
1404 st << "rg\n";
1405 st << scale*ar*(vx[0] - x0) << ' ' << scale*(vy[0] - y0) << " m "
1406 << scale*ar*(vx[1] - x0) << ' ' << scale*(vy[1] - y0) << " l "
1407 << scale*ar*(vx[2] - x0) << ' ' << scale*(vy[2] - y0) << " l f\n";
1408
1409 } else {
1410
1411 // assert( (px.size() == 2) || (px.size() == 3) );
1412 st << "RG\n";
1413 st << scale*ar*(px[0] - x0) << ' ' << scale*(py[0] - y0) << " m "
1414 << scale*ar*(px[1] - x0) << ' ' << scale*(py[1] - y0) << " l\n";
1415 st << "S\n";
1416 }
1417 }

Callers 2

plot_P1_isolineFunction · 0.85
plot_vector2flowFunction · 0.85

Calls 3

trackP1isolineFunction · 0.85
setrgbcolorFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected