| 1471 | return; |
| 1472 | } |
| 1473 | |
| 1474 | //---------------------------------------------------------------------- |
| 1475 | |
| 1476 | void plot_P1_fill( std::stringstream &Content, const Fem2D::Mesh &Th, const KN<double> &f_P1_, |
| 1477 | const KNM<double> &palette, |
| 1478 | const int sizex, const int sizey, const double scale, const double ar, |
| 1479 | const double x0, const double y0, const double y1, |
| 1480 | const int marginl, const int marginb, |
| 1481 | const double textfontsize, const bool monochrome, |
| 1482 | const bool legend, const int prec, const bool logscale, |
| 1483 | const double withmesh, |
| 1484 | const long nbfill, const KN<double> *const frange ) |
| 1485 | { |
| 1486 | const int &nVertices = Th.nv; |
| 1487 | const int &nTriangles = Th.nt; |
| 1488 | const int &nEdges = Th.neb; |
| 1489 | const double &r = scale; |
| 1490 | |
| 1491 | const double fmax = (frange)? (*frange)[1]: f_P1_.max(); |
| 1492 | const double fmin = (frange)? (*frange)[0]: f_P1_.min(); |
| 1493 | const double df = (logscale)? |
| 1494 | pow( fmax/fmin, static_cast<double>(1)/nbfill ): |
| 1495 | (fmax - fmin)/nbfill; |
| 1496 | |
| 1497 | std::stringstream &st = Content; |
| 1498 | st.str(""); |
| 1499 | |
| 1500 | //------------------------------ |
| 1501 | // element(triangle)-wise process |
| 1502 | //------------------------------ |
| 1503 | st << "q\n"; |
| 1504 | st << "1 0 0 1 " << PLOTPDFVAR::PADDING+marginl << " " << PLOTPDFVAR::PADDING+marginb << " cm\n"; |
| 1505 | |
| 1506 | double *const f_P1 = new double [ Th.nv ]; |
| 1507 | for(int k = 0; k < nTriangles; k++){ |
| 1508 | |
| 1509 | const int &v0 = Th(k,0); const double &f0 = f_P1[v0]; |
| 1510 | const int &v1 = Th(k,1); const double &f1 = f_P1[v1]; |
| 1511 | const int &v2 = Th(k,2); const double &f2 = f_P1[v2]; |
| 1512 | |
| 1513 | f_P1[v0] = f_P1_[3*k+0]; f_P1[v1] = f_P1_[3*k+1]; f_P1[v2] = f_P1_[3*k+2]; |
| 1514 | |
| 1515 | // find minimum |
| 1516 | int v_min = v2; |
| 1517 | int end1 = v0; // destination point |
| 1518 | int end2 = v1; // destination point |
| 1519 | |
| 1520 | if( (f0 <= f1) && (f0 <= f2) ){ |
| 1521 | v_min = v0; |
| 1522 | end1 = v1; |
| 1523 | end2 = v2; |
| 1524 | } else if( (f1 <= f0) && (f1 <= f2) ){ |
| 1525 | v_min = v1; |
| 1526 | end1 = v2; |
| 1527 | end2 = v0; |
| 1528 | } |
| 1529 | |
| 1530 | if( frange && (fmax < f_P1[v_min]) ) |
no test coverage detected