Salome HOME
Porting HEXABLOCK module on WIN32 platform.
[modules/hexablock.git] / src / HEXABLOCK / HexElements_ter.cxx
1 // C++ : Table d'hexaedres (Evol Versions 3)
2
3 // Copyright (C) 2009-2013  CEA/DEN, EDF R&D
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 //
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 //
21
22 #include "HexElements.hxx"
23
24 #include "HexDocument.hxx"
25 #include "HexVector.hxx"
26 #include "HexVertex.hxx"
27 #include "HexEdge.hxx"
28 #include "HexHexa.hxx"
29 #include "HexMatrix.hxx"
30 #include "HexGlobale.hxx"
31
32 #include "HexNewShape.hxx"
33 #include "HexEdgeShape.hxx"
34 #include "HexAssoEdge.hxx"
35
36 #include <cmath>
37
38 BEGIN_NAMESPACE_HEXA
39
40 // static bool db=false;
41
42 // ====================================================== makeRind
43 int Elements::makeRind (EnumGrid type, Vertex* center, Vector* vx, Vector* vz,
44                         double radext, double radint, double radhole,
45                         Vertex* plorig, double angle, int nr, int na, int nl)
46 {
47    double phi1;
48    int ier = controlRind (type, center, vx, vz, radext, radint, radhole,
49                           plorig, angle, nr, na, nl, cyl_phi0, phi1);
50    if (ier!=HOK)
51       return ier;
52
53    resize (type, nr, na, nl);
54
55    cyl_radext  = radext;
56    cyl_radint  = radint;
57    cyl_radhole = radhole;
58    cyl_closed  = type==GR_HEMISPHERIC || type==GR_RIND;
59
60    double theta  = cyl_closed ? 2*M_PI : M_PI*angle/180;
61    cyl_dphi      = (phi1-cyl_phi0)/ size_hz;
62    cyl_dtheta    = theta / size_hy;
63
64    int nb_secteurs = cyl_closed ? size_vy-1 : size_vy;
65
66    for (int ny=0 ; ny<nb_secteurs ; ny++)
67        for (int nx=0 ; nx<size_vx ; nx++)
68            for (int nz=0 ; nz<size_vz ; nz++)
69                {
70                double px, py, pz;
71                getCylPoint (nx, ny, nz, px, py, pz);
72                Vertex* node = el_root->addVertex (px, py, pz);
73                setVertex (node, nx, ny, nz);
74                }
75    if (cyl_closed)
76       for (int nx=0 ; nx<size_vx ; nx++)
77           for (int nz=0 ; nz<size_vz ; nz++)
78               {
79               Vertex* node = getVertexIJK (nx, 0, nz);
80               setVertex (node, nx, size_vy-1, nz);
81               }
82
83    transfoVertices (center, vx, vz);
84    fillGrid ();
85    assoCylinder (center, vz, angle);
86    return HOK;
87 }
88 // ====================================================== getCylPoint
89 int Elements::getCylPoint (int nr, int na, int nh, double& px, double& py,
90                            double& pz)
91 {
92    if (grid_type == GR_CYLINDRIC)
93       {
94       px = cyl_radext * cos (na*cyl_dtheta);
95       py = cyl_radext * sin (na*cyl_dtheta);
96       pz = cyl_length * nh;
97       return HOK;
98       }
99
100    bool   rind   = (grid_type == GR_RIND || grid_type == GR_PART_RIND);
101    double sinphi = sin (cyl_phi0 + nh*cyl_dphi);
102    double cosphi = cos (cyl_phi0 + nh*cyl_dphi);
103
104    double rayon = 0;
105    if (rind)
106       {
107       rayon = cyl_radint + nr*(cyl_radext-cyl_radint)/size_hx;
108       pz    = rayon*sinphi;
109       rayon = rayon*cosphi;
110       }
111    else
112       {
113       pz    = cyl_radext*sinphi;
114       rayon = cyl_radhole + nr*(cyl_radext*cosphi - cyl_radhole)/size_hx;
115       rayon = std::max (cyl_radhole, rayon);
116       }
117
118    px = rayon * cos (na*cyl_dtheta);
119    py = rayon * sin (na*cyl_dtheta);
120
121    return HOK;
122 }
123 // ====================================================== controlRind
124 int Elements::controlRind (EnumGrid type, Vertex* cx, Vector* vx, Vector* vz,
125                            double rext, double rint, double rhole,
126                            Vertex* px, double angle,
127                            int nrad, int nang, int nhaut,
128                            double &phi0, double &phi1)
129 {
130    const double Epsil1 = 1e-6;
131    phi0  = phi1 = 0;
132
133    if (cx == NULL || vx == NULL || vz == NULL)
134       return HERR;
135
136    if (nrad<=0 || nang<=0 || nhaut<=0)
137       return HERR;
138
139    if (rext <= 0.0)
140       return HERR;
141
142    if (rint >= rext)
143       return HERR;
144
145    if (rhole > rint)
146       return HERR;
147
148    double nvx = vx->getNorm();
149    double nvz = vz->getNorm();
150
151    if (nvx < Epsil1 || nvz <  Epsil1)
152       return HERR;
153
154    double alpha = asin (rhole/rext);
155    double beta  = -M_PI*DEMI;
156    if (type==GR_HEMISPHERIC || type==GR_PART_SPHERIC)
157        alpha = 2*alpha;
158
159    if (px!=NULL)
160       {
161           // oh = oa.n/|n|
162       double oh = ((px->getX() - cx->getX()) * vz->getDx()
163                 +  (px->getY() - cx->getY()) * vz->getDy()
164                 +  (px->getZ() - cx->getZ()) * vz->getDz()) / nvz;
165       if (oh > rext)
166          return HERR;
167       else if (oh > -rext)
168          beta  = asin (oh/rext);
169       }
170
171    phi0 = std::max (alpha - M_PI*DEMI, beta);
172    phi1 = M_PI*DEMI - alpha;
173    return HOK;
174 }
175 // ====================================================== getHexas
176 int Elements::getHexas (Hexas& liste)
177 {
178    liste.clear ();
179    for (int nro = 0 ; nro<nbr_hexas ; nro++)
180        {
181        Hexa* cell = tab_hexa [nro];
182        if (cell!=NULL && cell->isValid())
183           liste.push_back (cell);
184        }
185    return HOK;
186 }
187 // ====================================================== assoCylinder
188 void Elements::assoCylinder (Vertex* ori, Vector* normal, double angle)
189 {
190    if (normal==NULL || ori==NULL)
191        return;
192
193    RealVector tangles;
194    Real3      vz, center;
195    normal->getCoord (vz);
196    ori   ->getPoint (center);
197    assoCylinders (center, vz, angle, tangles);
198 }
199 // ====================================================== assoCylinders
200 void Elements::assoCylinders (Vertex* ori, Vector* normal, double angle,
201                               RealVector& t_angles)
202 {
203    if (normal==NULL || ori==NULL)
204        return;
205
206    Real3 vz, center;
207    normal->getCoord (vz);
208    ori   ->getPoint (center);
209    assoCylinders (center, vz, angle, t_angles);
210 }
211 // ====================================================== assoCylinders
212 void Elements::assoCylinders (double* ori, double* vk, double angle,
213                               RealVector& t_angles)
214 {
215    char     name [12];
216    sprintf (name, "grid_%02d", el_id);
217    NewShape* geom = el_root->addShape (name, SH_CYLINDER);
218    geom -> openShape();
219
220    string brep;
221    // Real3 vk = { normal->getDx(), normal->getDy(), normal->getDz() };
222    // normer_vecteur (vk);
223
224    for (int nz=0 ; nz<size_vz ; nz++)
225        {
226        for (int nx=0 ; nx<size_vx ; nx++)
227            {
228            Vertex* pm = getVertexIJK (nx, 0, nz);
229            Real3   om = { pm->getX() - ori[dir_x], 
230                           pm->getY() - ori[dir_y], 
231                           pm->getZ() - ori[dir_z] };
232
233            double oh     = prod_scalaire (om, vk);
234            double rayon  = 0;
235            Real3  ph, hm;
236            for (int dd=dir_x; dd<=dir_z ; dd++)
237                {
238                ph [dd] = ori[dd] + oh*vk[dd];
239                hm [dd] = pm ->getCoord(dd) - ph[dd];
240                rayon  += hm[dd] * hm[dd];
241                }
242
243            rayon = sqrt (rayon);
244            int subid = geom->addCircle (ph, rayon, vk, hm);
245
246            for (int ny=0 ; ny<size_hy ; ny++)
247                {
248                double pmin = t_angles [ny]/360;
249                double pmax = t_angles [ny+1]/360;
250                Edge*  edge = getEdgeJ (nx, ny, nz);
251                geom->addAssociation (edge, subid, pmin, pmax);
252                cout << " assoCylinders : ny= " << ny << ", nz= " << nz 
253                     << " param = (" << pmin << ", " << pmax  << ")\n";
254                }
255            }
256        }
257    // Association automatique des vertex non associes -> bph
258    // Traitement des faces spheriques
259
260    Real3 vi = { -vk[dir_x],  -vk[dir_y],  -vk[dir_z] };
261
262    switch (grid_type)
263       {
264       case GR_HEMISPHERIC  :    // Pour l'exterieur
265       case GR_PART_SPHERIC :
266            assoRind (ori, vi, size_vx-1, geom);
267            break;
268       case GR_PART_RIND    :    // Exterieur + interieur
269       case GR_RIND         :
270            assoRind (ori, vi, 0, geom);
271            assoRind (ori, vi, size_vx-1, geom);
272            break;
273       default :
274            break;
275       }
276    geom->closeShape ();
277 }
278 // ====================================================== calcul_param
279 double calcul_param (double* ori, double* vi, Vertex* vert)
280 {
281    Real3  pnt, vj;
282    vert->getPoint (pnt);
283    calc_vecteur (ori, pnt, vj);
284    normer_vecteur  (vj);
285    double kos = prod_scalaire (vi, vj);
286    double alpha = acos (kos) / (2*M_PI);
287    return alpha;
288 }
289 // ====================================================== assoRind
290 // Association des meridiennes
291 // Creation sphere geometrique + association faces
292 void Elements::assoRind (double* ori, double* vi, int nx, NewShape* geom)
293 {
294    Real3  vk;
295    double radius  = nx==0 ? cyl_radint : cyl_radext;
296    int    sphid   = geom->addSphere (ori, radius);
297
298    int nz1 = size_vz/2;
299    int nb_secteurs = cyl_closed ? size_vy-1 : size_vy;
300
301    for (int ny=0 ; ny<nb_secteurs ; ny++)
302        {
303        Vertex* pm = getVertexIJK (nx, ny, nz1);
304        Real3   vj = { pm->getX(), pm->getY(), pm->getZ() };
305        prod_vectoriel (vi, vj, vk);
306        double rayon = cyl_radint + nx*(cyl_radext-cyl_radint)/size_hx;
307        int    subid = geom->addCircle (ori, rayon, vk, vi);
308
309        for (int nz=0 ; nz<size_hz ; nz++)
310            {
311            Quad* quad  = getQuadJK (nx, ny, nz);
312            Edge* edge  = getEdgeK  (nx, ny, nz);
313            Vertex* nd1 = edge->getVertex (V_AMONT);
314            Vertex* nd2 = edge->getVertex (V_AVAL);
315            double pmin = calcul_param (ori, vi, nd1);
316            double pmax = calcul_param (ori, vi, nd2);
317            cout << " assoRind : ny= " << ny << ", nz= " << nz 
318                 << " param = (" << pmin << ", " << pmax  << ")\n";
319
320            geom->addAssociation (edge, subid, pmin, pmax);
321            geom->addAssociation (quad, sphid);
322            }
323        }
324 }
325 // ====================================================== assoCircle
326 // ==== utilise pour les spheres carrees
327 void Elements::assoCircle (double* center, Edge* ed1, Edge* ed2, NewShape* geom)
328 {
329    Real3 oa,  ob, normal;
330    Real3 pta, ptb, ptc, ptd;
331    string brep;
332
333 //  Les 2 edges dont les petits cotes d'un rectangle de rapport L/l=sqrt(2)
334 //  Soit le cercle circonscrit a ce rectangle.
335 //    * la largeur est balayee par l'angle alpha
336 //    * la longueur par l'angle beta = pi -alpha
337
338    ed1->getVertex(V_AMONT)->getPoint (pta);
339    ed1->getVertex(V_AVAL )->getPoint (ptb);
340    ed2->getVertex(V_AMONT)->getPoint (ptc);
341    ed2->getVertex(V_AVAL )->getPoint (ptd);
342
343    double d1 = calc_distance (pta, ptc);
344    double d2 = calc_distance (pta, ptd);
345
346    if (d1 < d2)
347       {
348       ed2->getVertex(V_AMONT)->getPoint (ptd);
349       ed2->getVertex(V_AVAL )->getPoint (ptc);
350       }
351
352    calc_vecteur   (center, pta, oa);
353    calc_vecteur   (center, ptb, ob);
354    prod_vectoriel (oa, ob, normal);
355
356    double rayon = calc_norme (oa);
357    int    subid = geom->addCircle (center, rayon, normal, oa);
358
359    const double alpha = atan (sqrt(2.)/2)/M_PI; //  angle proche de 70.528 degres
360    // asso1->setBounds (0,   alpha);
361    // asso2->setBounds (0.5, alpha + 0.5);
362
363    geom->addAssociation (ed1, subid, 0.0, alpha);
364    geom->addAssociation (ed2, subid, 0.5, alpha+0.5);
365 }
366 // ====================================================== assoSphere
367 void Elements::assoSphere (double* center, Edge* t_edge[], Quad* t_quad[])
368 {
369    char     name [12];
370    sprintf (name, "grid_%02d", el_id);
371    NewShape* geom = el_root->addShape (name, SH_SPHERE);
372    geom -> openShape ();
373
374    Real3 sommet;
375
376    assoCircle (center, t_edge [E_AC], t_edge [E_BD], geom);
377    assoCircle (center, t_edge [E_AD], t_edge [E_BC], geom);
378    assoCircle (center, t_edge [E_AE], t_edge [E_BF], geom);
379    assoCircle (center, t_edge [E_AF], t_edge [E_BE], geom);
380    assoCircle (center, t_edge [E_CE], t_edge [E_DF], geom);
381    assoCircle (center, t_edge [E_CF], t_edge [E_DE], geom);
382
383    t_edge[E_AC]->getVertex(V_AMONT)->getPoint (sommet);
384    double radius = calc_distance (center, sommet);
385
386    int sphid = geom -> addSphere (center, radius);
387    geom->closeShape();
388
389    for (int nf=0 ; nf < HQ_MAXI ; nf++)
390        t_quad[nf]->addAssociation (geom, sphid);
391 }
392 // ==================================================== propagateAssociation
393 int Elements::propagateAssociation (Edge* orig, Edge* dest, Edge* dir)
394 {
395     return HERR;
396 #if 0
397    if (revo_lution || orig==NULL || dest==NULL || dir==NULL)
398       return HERR;
399
400    const Shapes& tab_shapes = orig->getAssociations ();
401    const Shapes& tab_dest   = dest->getAssociations ();
402    int   nbdest             = tab_dest.size();
403    int   nbshapes           = tab_shapes.size();
404    bool  on_edge            = nbshapes!=0 && nbdest==0;
405
406    Vertex* vo1 = orig->commonVertex  (dir);
407    Vertex* vd1 = dest->commonVertex  (dir);
408    Vertex* vo2 = orig->opposedVertex (vo1);
409    Vertex* vd2 = dest->opposedVertex (vd1);
410
411    if (vo1==NULL || vd1==NULL)
412       return HERR;
413
414    string  trep;
415    Real3   pa, pb, vdir1, vdir2;
416    calc_vecteur (vo1->getPoint (pa), vd1->getPoint (pb), vdir1);
417    calc_vecteur (vo2->getPoint (pa), vd2->getPoint (pb), vdir2);
418
419    double dd = calc_distance (vdir1, vdir2);
420    bool para = dd < 1.0e-3;
421
422    if (para && on_edge)
423       {
424       for (int nro=0 ; nro<nbshapes ; nro++)
425           {
426           Shape* shape  = tab_shapes[nro];
427           if (shape!=NULL)
428              {
429              string brep   = shape->getBrep();
430              translate_brep (brep, vdir1, trep);
431              // Shape* tshape = new Shape (trep);
432              // tshape->setBounds (shape->getStart(), shape->getEnd());
433              // dest->addAssociation (tshape);
434              }
435           }
436       }
437
438    double* vdir = vdir1;
439    for (int nro=V_AMONT ; nro<=V_AVAL ; nro++)
440        {
441        Shape* shape = vo1->getAssociation ();
442        if (shape!=NULL && vd1->getAssociation ()==NULL)
443           {
444           string brep   = shape->getBrep();
445           translate_brep (brep, vdir, trep);
446           // Shape* tshape = new Shape (trep);
447           // vd1->setAssociation (tshape);
448           }
449        vo1  = vo2;
450        vd1  = vd2;
451        vdir = vdir2;
452        }
453    return HOK;
454 #endif
455 }
456 // ==================================================== prismAssociation
457 int Elements::prismAssociation (Edge* lorig, Edge* ldest, int nh)
458 {
459    if (lorig==NULL || ldest==NULL)
460       return HERR;
461
462    updateMatrix (nh);
463    int nbshapes = lorig->countAssociation ();
464    if (nbshapes==0)
465        return HOK;
466
467    NewShape* new_shape = getShape ();
468    for (int nro=0 ; nro<nbshapes ; nro++)
469        {
470        AssoEdge*  asso  = lorig->getAssociation (nro);
471        EdgeShape* shape = asso ->getEdgeShape();
472        double     p1    = asso ->getStart();
473        double     p2    = asso ->getEnd  ();
474        int        subid = 0;
475        char       name [24];
476
477        sprintf (name, "0x%lx#%d", (unsigned long) shape, nh);
478        map<string,int>::iterator iter = map_shape.find (name);
479        if (iter != map_shape.end())
480           subid = iter->second;
481        else
482           subid = map_shape[name] = new_shape->transfoShape (cum_matrix, shape);
483
484        new_shape->addAssociation (ldest, subid, p1, p2);
485        printf (" prismAsso : %s -> %s(%d)  = %s [ %g , %g]\n",
486                  lorig->getName(), ldest->getName(), nh, name, p1, p2);
487        }
488    return HOK;
489 }
490 // ====================================================== assoResiduelle
491 void Elements::assoResiduelle ()
492 {
493    // int nbre = tab_vertex.size();
494    // for (int nv=0 ; nv<nbre ; nv++)
495        // {
496        // geom_asso_point (tab_vertex [nv]);
497        // }
498 }
499 // ====================================================== moveDisco
500 void Elements::moveDisco (Hexa* hexa)
501 {
502    Real3  center;
503    Matrix matrix;
504    hexa->getCenter (center);
505    matrix.defScale (center, 0.55);
506
507    int nbre = tab_vertex.size();
508    for (int nv=0 ; nv<nbre ; nv++)
509        {
510        matrix.perform (tab_vertex [nv]);
511        }
512 }
513 // =================================================== getStrate
514 Hexa* Elements::getStrate (int couche, EnumHQuad nroface)
515 {
516    Hexa* cell = NULL;
517    int   nro  = couche <= 0 ? 0 : (couche-1)*HQ_MAXI + nroface + 1;
518
519    if (nbr_hexas==0 || nro >= nbr_hexas)
520       cell = NULL;
521    else
522       cell = tab_hexa [nro];
523
524    return cell;
525 }
526 // ============================================================  setHexa
527 void Elements::setHexa (Hexa* elt, int nro)
528 {
529    if (nro >=0 && nro < nbr_hexas)
530        tab_hexa [nro] = elt;
531 }
532 // ============================================================  setQuad
533 void Elements::setQuad (Quad* elt, int nro)
534 {
535    if (nro >=0 && nro < nbr_quads)
536        tab_quad [nro] = elt;
537 }
538 // ============================================================  setEdge
539 void Elements::setEdge (Edge* elt, int nro)
540 {
541    if (nro >=0 && nro < nbr_edges)
542        tab_edge [nro] = elt;
543 }
544 // ============================================================  setVertex
545 void Elements::setVertex (Vertex* elt, int nro)
546 {
547    if (nro >=0 && nro < nbr_vertex)
548        tab_vertex [nro] = elt;
549 }
550 // -----------------------------------------------------------------------
551 // -----------------------------------------------------------------------
552 // ============================================================  getHexa
553 Hexa* Elements::getHexa (int nro)
554 {
555    DumpStart ("getHexa", nro);
556
557    Hexa* elt = NULL;
558    int  nombre=tab_hexa.size();
559    // if (nro >=0 && nro < nbr_hexas && el_status == HOK Abu 2010/05/06
560    if (nro >=0 && nro < nombre && el_status == HOK
561                && tab_hexa [nro] != NULL && tab_hexa [nro]->isValid())
562       elt = tab_hexa [nro];
563
564    DumpReturn (elt);
565    return elt;
566 }
567 // ============================================================  getQuad
568 Quad* Elements::getQuad (int nro)
569 {
570    DumpStart ("getQuad", nro);
571
572    Quad* elt = NULL;
573    if (nro >=0 && nro < nbr_quads && el_status == HOK
574                && tab_quad [nro] != NULL && tab_quad [nro]->isValid())
575       elt = tab_quad [nro];
576
577    DumpReturn (elt);
578    return elt;
579 }
580 // ============================================================  getEdge
581 Edge* Elements::getEdge (int nro)
582 {
583    DumpStart ("getEdge", nro);
584
585    Edge* elt = NULL;
586    if (nro >=0 && nro < nbr_edges && el_status == HOK
587                && tab_edge [nro] != NULL && tab_edge [nro]->isValid())
588       elt = tab_edge [nro];
589
590    DumpReturn (elt);
591    return elt;
592 }
593 // ============================================================  getVertex
594 Vertex* Elements::getVertex (int nro)
595 {
596    DumpStart ("getVertex", nro);
597
598    Vertex* elt = NULL;
599    if (nro >=0 && nro <  nbr_vertex && el_status == HOK
600                && tab_vertex [nro] != NULL && tab_vertex [nro]->isValid())
601       elt = tab_vertex [nro];
602
603    DumpReturn (elt);
604    return elt;
605 }
606 // ============================================================  indVertex
607 int Elements::indVertex (int nquad, int nsommet, int nh)
608 {
609    int nro = nsommet  + QUAD4*nquad + nbr_orig*QUAD4*(nh+1);
610    return nro;
611 }
612 // ============================================================  nroVertex
613 int Elements::nroVertex (int nquad, int nsommet, int nh)
614 {
615    int nro = nsommet  + QUAD4*nquad + nbr_orig*QUAD4*nh;
616    return nro;
617 }
618 // ============================================================  indVertex
619 int Elements::indVertex (int ref_edge, int nh)
620 {
621    int    nro = ref_edge + nbr_orig*QUAD4*nh;
622    return nro;
623 }
624 // ============================================================  nroEdgeH
625 int Elements::nroEdgeH (int nvertex)
626 {
627    return QUAD4*nbr_orig*gr_hauteur + nvertex;
628 }
629 // ============================================================  nroEdgeH
630 int Elements::nroEdgeH (int nquad, int nsommet, int nh)
631 {
632    return QUAD4*nbr_orig*gr_hauteur + indVertex (nquad, nsommet, nh);
633 }
634 // ============================================================  nroHexa
635 int Elements::nroHexa (int nquad, int nh)
636 {
637    int nro = gr_hauteur*nquad + nh;
638    return nro;
639 }
640
641 // ============================================================  addHexa
642 void Elements::addHexa (Hexa* element)
643 {
644    tab_hexa.push_back (element);
645    nbr_hexas ++;
646 }
647 // ============================================================  addQuad
648 void Elements::addQuad (Quad* element)
649 {
650    tab_quad.push_back (element);
651    nbr_quads ++;
652 }
653 // ============================================================  addEdge
654 void Elements::addEdge (Edge* element)
655 {
656    tab_edge.push_back (element);
657    nbr_edges ++;
658 }
659 // ============================================================  addVertex
660 void Elements::addVertex (Vertex* element)
661 {
662    tab_vertex.push_back (element);
663    nbr_vertex ++;
664 }
665 // ============================================================  findHexa
666 int Elements::findHexa (Hexa* element)
667 {
668    int nbre = tab_hexa.size();
669    for (int nro=0 ; nro<nbre ; nro++)
670        if (tab_hexa [nro] == element)
671           return nro;
672    return NOTHING;
673 }
674 // ============================================================  findQuad
675 int Elements::findQuad (Quad* element)
676 {
677    int nbre = tab_quad.size();
678    for (int nro=0 ; nro<nbre ; nro++)
679        if (tab_quad [nro] == element)
680           return nro;
681    return NOTHING;
682 }
683 // ============================================================  findEdge
684 int Elements::findEdge (Edge* element)
685 {
686    int nbre = tab_edge.size();
687    for (int nro=0 ; nro<nbre ; nro++)
688        if (tab_edge [nro] == element)
689           return nro;
690    return NOTHING;
691 }
692 // ============================================================  findVertex
693 int Elements::findVertex (Vertex* element)
694 {
695    int nbre = tab_vertex.size();
696    for (int nro=0 ; nro<nbre ; nro++)
697        if (tab_vertex [nro] == element)
698           return nro;
699    return NOTHING;
700 }
701 // ========================================================= saveVtk (avec nro)
702 int Elements::saveVtk  (cpchar radical, int &nro)
703 {
704    char num[8];
705    sprintf (num, "%d", nro);
706    nro ++;
707
708    string filename = radical;
709    filename += num;
710    filename += ".vtk";
711    int ier = saveVtk (filename.c_str());
712    return ier;
713 }
714
715 END_NAMESPACE_HEXA