| 1136 | } |
| 1137 | |
| 1138 | //---------------------------------------------------------------------- |
| 1139 | |
| 1140 | void plot_mesh( std::stringstream &Content, const Fem2D::Mesh &Th, |
| 1141 | const double scale, const double ar, const double x0, const double y0, |
| 1142 | const int marginl, const int marginb, |
| 1143 | const double textfontsize, const bool monochrome, |
| 1144 | const double withmesh, const double linewidth, |
| 1145 | const bool idcell, const bool idvert, const int idedge, |
| 1146 | const int mode = 0) |
| 1147 | { |
| 1148 | // mode == 0 (default) : without index |
| 1149 | // mode == 1 : FreeFEM index |
| 1150 | // mode == 2 : Boundary Label |
| 1151 | enum { MODE_NOLABEL = 0, MODE_INDEX = 1, MODE_BELABEL = 2 }; |
| 1152 | |
| 1153 | const int nVertices = Th.nv; |
| 1154 | const int nElements = Th.nt; |
| 1155 | const int nEdges = Th.neb; |
| 1156 | const double &r = scale; |
| 1157 | |
| 1158 | std::stringstream &st = Content; |
| 1159 | st.str(""); |
| 1160 | |
| 1161 | st << "q\n"; |
| 1162 | st << "1 0 0 1 " << PLOTPDFVAR::PADDING+marginl << " " << PLOTPDFVAR::PADDING+marginb << " cm\n"; |
| 1163 | st << linewidth << " w\n"; // setlinewidth |
| 1164 | |
| 1165 | //------------------------------ |
| 1166 | // vertices |
| 1167 | //------------------------------ |
| 1168 | if( (mode == MODE_INDEX) && idvert ){ |
| 1169 | |
| 1170 | if(monochrome) |
| 1171 | st << PLOTPDFVAR::DEFAULT_IDVERT_MONO[0] << ' ' << PLOTPDFVAR::DEFAULT_IDVERT_MONO[1] << ' ' |
| 1172 | << PLOTPDFVAR::DEFAULT_IDVERT_MONO[2] << " rg\n" << std::endl; |
| 1173 | else |
| 1174 | st << PLOTPDFVAR::DEFAULT_IDVERT_RGB[0] << ' ' << PLOTPDFVAR::DEFAULT_IDVERT_RGB[1] << ' ' |
| 1175 | << PLOTPDFVAR::DEFAULT_IDVERT_RGB[2] << " rg\n" << std::endl; |
| 1176 | |
| 1177 | int id = mode; |
| 1178 | |
| 1179 | st << "BT\n"; |
| 1180 | st << "/F1 " << textfontsize << " Tf\n"; |
| 1181 | for(int n = 0; n < nVertices; n++){ |
| 1182 | |
| 1183 | st << "1 0 0 1 " << r*ar*(Th(n).x-x0) << ' ' << r*(Th(n).y-y0) << " Tm " |
| 1184 | << "(" << id << ") Tj\n"; |
| 1185 | id++; |
| 1186 | } |
| 1187 | st << "ET\n"; |
| 1188 | } |
| 1189 | |
| 1190 | //------------------------------ |
| 1191 | // element (triangle) |
| 1192 | //------------------------------ |
| 1193 | if( mode == MODE_BELABEL ){ |
| 1194 | |
| 1195 | const double grayscale0 = (withmesh < 0)? 0: withmesh; |