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

Function P2_fill_linear

plugin/seq/plotPDF.cpp:2941–3100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2939 sum += (a*mx*mx + b*mx*my + c*my*my + d*mx + e*my + f);
2940 npoints++;
2941 }
2942 }
2943
2944 return sum / npoints;
2945}
2946
2947void P2_fill_linear( std::stringstream &Content,
2948 const Fem2D::Mesh &Th, const int triangle_id,
2949 const double *const vf,
2950 const KNM<double> &palette,
2951 const double fmax, const double fmin, const double df,
2952 const int nbfill, const KN<double> *const frange,
2953 const double scale, const double ar, const double x0, const double y0,
2954 const bool monochrome, const bool logscale )
2955{
2956 std::stringstream &st = Content;
2957
2958 const int &v0 = Th(triangle_id,0);
2959 const int &v1 = Th(triangle_id,1);
2960 const int &v2 = Th(triangle_id,2);
2961 const double x[] = { Th(v0).x, Th(v1).x, Th(v2).x };
2962 const double y[] = { Th(v0).y, Th(v1).y, Th(v2).y };
2963 // phi(x,y) = a*x + b*y + c
2964 const double *const &phi = vf;
2965
2966 // find minimum
2967 int v_min = 2;
2968 int end1 = 0; // destination point
2969 int end2 = 1; // destination point
2970
2971 if( (phi[0] <= phi[1]) && (phi[0] <= phi[2]) ){
2972 v_min = 0;
2973 end1 = 1;
2974 end2 = 2;
2975 } else if( (phi[1] <= phi[0]) && (phi[1] <= phi[2]) ){
2976 v_min = 1;
2977 end1 = 2;
2978 end2 = 0;
2979 }
2980
2981 if( frange && (fmax < phi[v_min]) )
2982 return;
2983
2984 if( frange && (phi[end1] < fmin) && (phi[end2] < fmin) )
2985 return;
2986
2987 int beg1 = v_min; // current point
2988 int beg2 = v_min; // current point
2989 double t1 = 0; // secting parameters on edge beg1--end1
2990 double t2 = 0; // secting parameters on edge beg2--end2
2991
2992 int level = (logscale)?
2993 static_cast<int>( log(phi[v_min]/fmin) / log(df) ):
2994 static_cast<int>( (phi[v_min]-fmin) / df );
2995
2996 double f = (logscale)? (pow(df,level) * fmin) : (level*df + fmin);
2997
2998 if( frange && (phi[v_min] < fmin) ){

Callers 1

plot_P2_fillFunction · 0.85

Calls 3

setrgbcolorFunction · 0.85
logFunction · 0.50
powFunction · 0.50

Tested by

no test coverage detected