FreeFem 3.5.x
List of all members
fem::femGraphicDeviceIndependent Class Reference

device independat graphic class More...

#include <femGraphicDeviceIndependent.hpp>

Public Types

Typedefs
typedef femMesh::femPoint femPoint
 
typedef femMesh::femTriangle femTriangle
 

Public Member Functions

Constructors, destructor and methods
 femGraphicDeviceIndependent (femMesh *=0)
 
Mutators
void setTriangulation (femMesh *)
 

Methods

void graph3d (float *f, int waitm)
 
void showtriangulation (int waitm)
 
void equpot (int *ng, float *f, int nl, int waitm)
 
void equpotd (int *ng, float *f, int nl, int waitm)
 
void showbdy (long nbs, float *cr, long nba, long *arete, float *hh, int waitm)
 

Detailed Description

device independat graphic class

Author
Christophe Prud'homme prudh.nosp@m.omm@.nosp@m.users.nosp@m..sou.nosp@m.rcefo.nosp@m.rge..nosp@m.net
See also
Version
Id
femGraphicDeviceIndependent.hpp,v 1.2 2001/07/12 15:15:39 delpinux Exp

Constructor & Destructor Documentation

◆ femGraphicDeviceIndependent()

fem::femGraphicDeviceIndependent::femGraphicDeviceIndependent ( femMesh = 0)
47 :
48 __t( t )
49{
50}

◆ ~femGraphicDeviceIndependent()

fem::femGraphicDeviceIndependent::~femGraphicDeviceIndependent ( )
52{
53}

Member Function Documentation

◆ equpot()

void fem::femGraphicDeviceIndependent::equpot ( int *  ng,
float *  f,
int  nl,
int  waitm 
)
301{
302 float qp[2][5];
303 int ns = __t->getNumberOfPoints(), nt = __t->getNumberOfCells();
304 femTriangle *tr = __t->tr;
305 femPoint *rp = __t->rp;
306 float xln, fm, xf, xfm, fi, fj, xlam;
307 int im, i, j, k, l, ik, jk;
308
309 Init (rp, ns, "o");
310 contour (ng, 11);
311 couleur (2);
312
313 fm = f[0]; /* search fmin and fmax */
314 xfm = fm;
315 for (i = 1; i <= ns; i++)
316 {
317 if (f[i - 1] > fm)
318 fm = f[i - 1];
319 if (f[i - 1] < xfm)
320 xfm = f[i - 1];
321 }
322 if ((float) fabs (fm - xfm) < 1.0e-15)
323 nl = 1;
324 for (l = 1; l <= nl; l++) /* loop on the level curves */
325 {
326 if (nl == 1)
327 xln = 0.5F;
328 else
329 xln = (l - 1.0F) / (nl - 1.0F);
330 xf = xfm + (fm - xfm) * xln;
331 for (k = 1; k <= nt; k++) /* loop on each femTriangle */
332 {
333 im = 0;
334 for (i = 0; i <= 2; i++)
335 {
336 j = ((i + 1) == 3 ? 0 : i + 1);
337 ik = tr[k - 1][i];
338 jk = tr[k - 1][j];
339 fi = realpart (f[ik]);
340 fj = realpart (f[jk]);
341 if (((fi <= xf) && (fj >= xf)) || ((fi >= xf) && (fj <= xf)))
342 {
343 if ((float) fabs (fi - fj) <= 0.1e-10) /* one side must be drawn */
344 {
345 rmoveto (rp[ik][0], rp[ik][1]);
346 rlineto (rp[jk][0], rp[jk][1]);
347 }
348 else
349 {
350 xlam = (fi - xf) / (fi - fj);
351 im = im + 1;
352 qp[0][im] = rp[ik][0] * (1.0F - xlam) + rp[jk][0] * xlam;
353 qp[1][im] = rp[ik][1] * (1.0F - xlam) + rp[jk][1] * xlam;
354 }
355 }
356 }
357 if (im >= 2) /* draw one segment */
358 {
359 rmoveto (qp[0][1], qp[1][1]);
360 rlineto (qp[0][2], qp[1][2]);
361 }
362 }
363 }
364 xfmin = xfm; /* solution min */
365 xfmax = fm; /* solution max */
366 //std::cout << xfmin << " " << xfmax << "\n";
367 contour (ng, 11);
368 rattente (waitm, xfmin, xfmax);
369}

◆ equpotd()

void fem::femGraphicDeviceIndependent::equpotd ( int *  ng,
float *  f,
int  nl,
int  waitm 
)
373{
374 float qp[2][5];
375 int ns = __t->getNumberOfPoints();
376 int nt = __t->getNumberOfCells();
377 femTriangle* tr = __t->tr;
378 femPoint* rp = __t->rp;
379 float xln, fm, xf, xfm, fi, fj, xlam;
380 int im, i, j, k, l, ik, jk;
381
382 Init (rp, ns, "o");
383 contour (ng, 11);
384 couleur (2);
385
386 fm = f[0]; /* search fmin and fmax */
387 xfm = fm;
388 for (i = 1; i <= 3 * nt; i++)
389 {
390 if (f[i - 1] > fm)
391 fm = f[i - 1];
392 if (f[i - 1] < xfm)
393 xfm = f[i - 1];
394 }
395 if ((float) fabs (fm - xfm) < 1.0e-15)
396 nl = 1;
397 for (k = 1; k <= nt; k++) /* loop on each femTriangle */
398 {
399 for (l = 1; l <= nl; l++) /* loop on the level curves */
400 {
401 if (nl == 1)
402 xln = 0.5F;
403 else
404 xln = (l - 1.0F) / (nl - 1.0F);
405 xf = xfm + (fm - xfm) * xln;
406 im = 0;
407 for (i = 0; i <= 2; i++)
408 {
409 j = ((i + 1) == 3 ? 0 : i + 1);
410 ik = tr[k - 1][i];
411 jk = tr[k - 1][j];
412 fi = realpart (f[3 * (k - 1) + i]);
413 fj = realpart (f[3 * (k - 1) + j]);
414 if (((fi <= xf) && (fj >= xf)) || ((fi >= xf) && (fj <= xf)))
415 {
416 if ((float) fabs (fi - fj) <= 0.1e-10) /* one side must be drawn */
417 {
418 rmoveto (rp[ik][0], rp[ik][1]);
419 rlineto (rp[jk][0], rp[jk][1]);
420 }
421 else
422 {
423 xlam = (fi - xf) / (fi - fj);
424 im = im + 1;
425 qp[0][im] = rp[ik][0] * (1.0F - xlam) + rp[jk][0] * xlam;
426 qp[1][im] = rp[ik][1] * (1.0F - xlam) + rp[jk][1] * xlam;
427 }
428 }
429 }
430 if (im >= 2) /* draw one segment */
431 {
432 rmoveto (qp[0][1], qp[1][1]);
433 rlineto (qp[0][2], qp[1][2]);
434 }
435 }
436 }
437 contour (ng, 11);
438 rattente (waitm);
439}

◆ graph3d()

void fem::femGraphicDeviceIndependent::graph3d ( float *  f,
int  waitm 
)
170{
171
172 int i, j, coul;
173 int coul1 = 11, coul2 = 3;
174 int p1, p2, p3;
175 float test;
176 femTriangle *tt = __t->tr;
177 femPoint *pp = __t->rp;
178
179 initt ();
180 quicksort (table, ordre, __t->getNumberOfCells());
181 delete[]table;
182 table = NULL;
183 projection (fct);
184 Init (proj, __t->getNumberOfPoints(), "n");
185 for (i = 0; i < __t->getNumberOfCells(); i++)
186 {
187 float poly[6];
188 int ii = ordre[i];
189
190 for (j = 0; j < 3; j++)
191 {
192 poly[2 * j] = proj[tt[ii][j]][0];
193 poly[2 * j + 1] = proj[tt[ii][j]][1];
194 }
195 if (pp[tt[ii][0]][1] < pp[tt[ii][1]][1])
196 {
197 p1 = tt[ii][0];
198 p2 = tt[ii][1];
199 }
200 else
201 {
202 p2 = tt[ii][0];
203 p1 = tt[ii][1];
204 }
205 if (pp[tt[ii][2]][1] < pp[p2][1])
206 if (pp[tt[ii][2]][1] < pp[p1][1])
207 {
208 p3 = p2;
209 p2 = p1;
210 p1 = tt[ii][2];
211 }
212 else
213 {
214 p3 = p2;
215 p2 = tt[ii][2];
216 }
217 else
218 p3 = tt[ii][2];
219 test = proj[p3][1] * (proj[p1][0] - proj[p2][0]) +
220 proj[p3][0] * (proj[p2][1] - proj[p1][1]) +
221 proj[p2][0] * proj[p1][1] - proj[p1][0] * proj[p2][1];
222 if (test <= 0)
223 if (proj[p2][0] < proj[p1][0])
224 coul = coul2;
225 else
226 coul = coul1;
227 else if (proj[p2][0] > proj[p1][0])
228 coul = coul2;
229 else
230 coul = coul1;
231 if (i == 0 && coul == coul2)
232 {
233 int exchg;
234
235 exchg = coul2;
236 coul = coul2 = coul1;
237 coul1 = exchg;
238 }
239/* couleurint(coul); */
240 /* raffpoly(3,poly); */
241/* couleur(4); */
242 rmoveto (proj[tt[ii][2]][0], proj[tt[ii][2]][1]);
243 for (j = 0; j < 3; j++)
244 {
245 rlineto (proj[tt[ii][j]][0], proj[tt[ii][j]][1]);
246 }
247 }
248 rattente (waitm);
249 delete[]proj;
250 proj = NULL;
251 delete[]ordre;
252 ordre = NULL;
253}

◆ setTriangulation()

void fem::femGraphicDeviceIndependent::setTriangulation ( femMesh )
57{
58 __t = t;
59}

◆ showbdy()

void fem::femGraphicDeviceIndependent::showbdy ( long  nbs,
float *  cr,
long  nba,
long *  arete,
float *  hh,
int  waitm 
)
443{
444 long i;
445 float d, x, y, xmx = -(float)1e10, xmn = (float)1e10, ymx = -(float)1e10, ymn = (float)1e10;
446 float xctr, yctr, ray;
447
448 for (i = 0; i < nbs; i++)
449 {
450 x = cr[2 * i];
451 y = cr[2 * i + 1];
452 xmx = x > xmx ? x : xmx;
453 xmn = xmn > x ? x : xmn;
454 ymx = y > ymx ? y : ymx;
455 ymn = ymn > y ? y : ymn;
456 }
457 xctr = (xmx + xmn) / 2;
458 yctr = (ymx + ymn) / 2;
459 ray = (xmx - xctr) > (ymx - yctr) ? xmx - xctr : ymx - yctr;
460 reffecran ();
461 cadreortho (xctr, yctr, ray);
462 for (i = 0; i < nbs; i++)
463 {
464 d = 0.1F * hh[i];
465 rmoveto (cr[2 * i], cr[2 * i + 1]);
466 rlineto (d + cr[2 * i], cr[2 * i + 1]);
467 rlineto (d + cr[2 * i], d + cr[2 * i + 1]);
468 rlineto (cr[2 * i], d + cr[2 * i + 1]);
469 rlineto (cr[2 * i], cr[2 * i + 1]);
470 }
471 for (i = 0; i < nba; i++)
472 {
473 rmoveto (cr[2 * arete[2 * i]], cr[2 * arete[2 * i] + 1]);
474 rlineto (cr[2 * arete[2 * i + 1]], cr[2 * arete[2 * i + 1] + 1]);
475 }
476 rattente(waitm);
477}

◆ showtriangulation()

void fem::femGraphicDeviceIndependent::showtriangulation ( int  waitm)
258{
259 int i, j;
260 femTriangle *tt = __t->tr;
261 femPoint *pp = __t->rp;
262
263 Init (pp, __t->getNumberOfPoints(), "o");
264 couleur (6);
265 for (i = 0; i < __t->getNumberOfCells(); i++)
266 {
267 rmoveto (pp[tt[i][2]][0], pp[tt[i][2]][1]);
268 for (j = 0; j < 3; j++)
269 rlineto (pp[tt[i][j]][0], pp[tt[i][j]][1]);
270 }
271 rattente (waitm);
272}

The documentation for this class was generated from the following files:

This is the FreeFEM reference manual
Provided by The KFEM project