Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/hexablock.git] / src / HEXABLOCK / HexGlobale.hxx
1 // Copyright (C) 2009-2012  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // Singleton : Var globales : Disposition sommets/aretes/faces d'un hexaedre
21
22 #ifndef _HEX_GLOBALE_H
23 #define _HEX_GLOBALE_H
24
25 #include "hexa_base.hxx"
26
27 /* -----------------------------------------------------
28
29                 // ---- Numerotation des faces (%x) 
30                    
31        6=bed  +----bd-----+ bdf=7
32              /|          /|
33            be |   B    bf |
34            /  |        /  |
35     4=bce +----bc-----+...|...bcf=5
36           |  de     D |   df
37           | E |       | F |             z
38          ce   | C     cf  |             ^
39   2=ade...|...+----ad-|---+ adf=3       |   y
40           |  /        |  /              |  /
41           | ae    A   | af              | /
42           |/          |/                |/
43     0=ace +----ac-----+ acf=1           +----->  x
44                 
45  * ----------------------------------------------------- */
46
47
48 BEGIN_NAMESPACE_HEXA
49
50 class Globale
51 {
52 public :
53    static Globale* getInstance ();
54
55    int CoordVertex (int edge, EnumCoord dim)
56        { return coord_vertex [edge] [dim] ; }
57
58    EnumHVertex EdgeVertex (int edge, EnumVertex sens)
59        { return edge_vertex [edge] [sens] ; }
60
61    EnumHEdge QuadEdge (int face, EnumQuad cote)
62        { return quad_edge [face] [cote] ; }
63
64    cpchar namofHexaEdge   (int arete)   { return h_edge_name   [arete] ; }
65    cpchar namofHexaVertex (int sommet)  { return h_vertex_name [sommet]; }
66    cpchar namofHexaQuad   (int face)    { return h_quad_name   [face];   }
67
68    EnumHQuad getOpposedQuad (int face)  { return h_opposed_quad [face]; }
69
70    void setArgs  (int nbargs, cpchar tabargs[]);
71    int  findArg  (cpchar opt);
72    bool isinArgs (cpchar opt)  { return findArg (opt) >= 0; }
73    cpchar getArg  (int nro)    { return nro>=nbr_args ? NULL : tab_args[nro]; }
74
75 private :
76    Globale ();         // Constructeur prive
77
78    void setCoordVertex (EnumHVertex node, int px, int py, int pz);
79    void setEdgeVertex  (EnumHEdge edge, EnumHVertex amont, EnumHVertex aval);
80    void setQuadEdge    (EnumHQuad face, EnumHEdge c1, EnumHEdge c2, 
81                                         EnumHEdge c3, EnumHEdge c4);
82    void setOpposedVertex (EnumHVertex lun, EnumHVertex lautre);
83    void setOpposedQuad   (EnumHQuad   lun, EnumHQuad   lautre);
84
85    void setNames ();
86
87 private :
88    int     nbr_args;
89    cpchar* tab_args;
90
91    int         coord_vertex [HV_MAXI] [DIM3];
92    EnumHVertex edge_vertex  [HE_MAXI] [V_TWO];
93    EnumHEdge   quad_edge    [HQ_MAXI] [QUAD4];
94
95    cpchar h_edge_name   [HE_MAXI]; 
96    cpchar h_vertex_name [HV_MAXI];
97    cpchar h_quad_name   [HQ_MAXI]; 
98
99    EnumHVertex  h_opposed_vertex [HV_MAXI];
100    EnumHQuad    h_opposed_quad   [HQ_MAXI];
101
102    static Globale* unique_instance;
103 };
104 // ===================================================== setArgs
105 inline void Globale::setArgs (int nbargs, cpchar tabargs[])
106 {
107    nbr_args = nbargs;
108    tab_args = tabargs;
109 }
110 // ===================================================== findArg
111 inline int Globale::findArg (cpchar option)
112 {
113    for (int nro=1 ; nro<nbr_args ; nro++)
114        if (Cestegal (option, tab_args[nro]))
115           return nro;
116
117    return NOTHING;
118 }
119 END_NAMESPACE_HEXA
120
121 #endif