Salome HOME
28195109c5611d068f26332077f630b4c9a56b1c
[modules/hexablock.git] / src / HEXABLOCK / HexAnaQuads.hxx
1
2 // class : Analyse des quadrangles avant construction
3
4 // Copyright (C) 2009-2023  CEA, EDF
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 #ifndef __ANA_QUADS_H
23 #define __ANA_QUADS_H
24
25 #include "HexQuad.hxx"
26 // #include "HexEdge.hxx"
27
28 BEGIN_NAMESPACE_HEXA
29
30 class HexaExport AnaQuads
31 {
32 public:
33     AnaQuads (Quad* q1, Quad* q2, Quad* q3=NULL, Quad* q4=NULL, Quad* q5=NULL);
34
35 public:
36     enum {MaxQuads=5};
37     int    status;
38     int    nbr_quads;
39     int    nbr_aretes;
40     Quad*  tab_quads  [MaxQuads];
41     int    inter_nbre [MaxQuads];
42     int    inter_edge [MaxQuads][MaxQuads]; // L'arete commune des 2 quads
43     int    inter_quad [MaxQuads][QUAD4];    // Le quad touchant la ieme arete
44 };
45 // ----------------------------------------------- Inlining
46 // ========================================================== Constructeur
47 inline AnaQuads::AnaQuads (Quad* q0, Quad* q1, Quad* q2, Quad* q3, Quad* q4)
48 {
49    nbr_quads  = 2;
50    nbr_aretes = 0;
51    status     = HOK;
52
53    for (int nquad=0 ; nquad < MaxQuads ; nquad++)
54        {
55        tab_quads  [nquad] = NULL;
56        inter_nbre [nquad] = 0;
57        for (int nro=0 ; nro < QUAD4 ; nro++)
58            inter_quad [nquad][nro] = NOTHING;
59        for (int nro=0 ; nro < MaxQuads ; nro++)
60            inter_edge [nquad][nro] = NOTHING;
61        }
62
63    tab_quads [0] = q0;
64    tab_quads [1] = q1;
65    tab_quads [2] = q2;
66    tab_quads [3] = q3;
67    tab_quads [4] = q4;
68
69    if      (q4 != NULL) nbr_quads = 5;
70    else if (q3 != NULL) nbr_quads = 4;
71    else if (q2 != NULL) nbr_quads = 3;
72    else                 nbr_quads = 2;
73
74    for (int nquad1=0 ; nquad1 < nbr_quads ; nquad1++)
75        {
76        if (tab_quads[nquad1]==NULL || tab_quads[nquad1]->isDeleted())
77           {
78           status = HERR;
79           return;
80           }
81        for (int nquad2=0 ; nquad2 < nquad1 ; nquad2++)
82            {
83            if (tab_quads[nquad1]==tab_quads[nquad2]) 
84               {
85               status = HERR;
86               return;
87               }
88            int nedge2 = 0;
89            int nedge1 = tab_quads[nquad1]->inter (tab_quads[nquad2], nedge2) ;
90            if (nedge1 != NOTHING)
91               {
92               inter_edge [nquad1] [nquad2] = nedge1;
93               inter_quad [nquad1] [nedge1] = nquad2;
94
95               inter_edge [nquad2] [nquad1] = nedge2;
96               inter_quad [nquad2] [nedge2] = nquad1;
97
98               inter_nbre [nquad1]++;
99               inter_nbre [nquad2]++;
100               nbr_aretes++;
101               }
102            }
103        }
104 }
105 // ============================================================== distance
106 inline double distance (Vertex* v1, Vertex* v2)
107 {
108    double vx   = v1->getX () - v2->getX ();
109    double vy   = v1->getY () - v2->getY ();
110    double vz   = v1->getZ () - v2->getZ ();
111    double dist = sqrt (vx*vx + vy*vy + vz*vz);
112    return dist;
113 }
114 END_NAMESPACE_HEXA
115 #endif