Salome HOME
Merge from V6_main 01/04/2013
[modules/hexablock.git] / src / HEXABLOCK / HexGlobale.cxx
1 // Copyright (C) 2009-2013  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 // C++ : Initialisation du singleton
21
22 #include "HexGlobale.hxx"
23
24 BEGIN_NAMESPACE_HEXA
25
26 static bool db = false;
27
28 /* -----------------------------------------------------
29
30                 // ---- Numerotation des faces (%x) 
31                    
32        6=bed  +----bd-----+ bdf=7
33              /|          /|
34            be |   B    bf |
35            /  |        /  |
36     4=bce +----bc-----+...|...bcf=5
37           |  de     D |   df
38           | E |       | F |             z
39          ce   | C     cf  |             ^
40   2=ade...|...+----ad-|---+ adf=3       |   y
41           |  /        |  /              |  /
42           | ae    A   | af              | /
43           |/          |/                |/
44     0=ace +----ac-----+ acf=1           +----->  x
45                 
46  * ----------------------------------------------------- */
47
48 Globale* Globale::unique_instance = NULL;
49
50 // ====================================================== Constructeur
51 Globale::Globale  ()
52 {
53    setNames ();
54
55    setCoordVertex ( V_ACE, 0, 0, 0 );
56    setCoordVertex ( V_ACF, 1, 0, 0 );
57    setCoordVertex ( V_ADF, 1, 1, 0 );
58    setCoordVertex ( V_ADE, 0, 1, 0 );
59
60    setCoordVertex ( V_BCE, 0, 0, 1 );
61    setCoordVertex ( V_BCF, 1, 0, 1 );
62    setCoordVertex ( V_BDF, 1, 1, 1 );
63    setCoordVertex ( V_BDE, 0, 1, 1 );
64    
65    setEdgeVertex ( E_AC, V_ACE, V_ACF );
66    setEdgeVertex ( E_AF, V_ACF, V_ADF );
67    setEdgeVertex ( E_AD, V_ADF, V_ADE );
68    setEdgeVertex ( E_AE, V_ADE, V_ACE );
69
70    setEdgeVertex ( E_BC, V_BCE, V_BCF );
71    setEdgeVertex ( E_BF, V_BCF, V_BDF );
72    setEdgeVertex ( E_BD, V_BDF, V_BDE );
73    setEdgeVertex ( E_BE, V_BDE, V_BCE );
74
75    setEdgeVertex ( E_CE, V_ACE, V_BCE );
76    setEdgeVertex ( E_CF, V_ACF, V_BCF );
77    setEdgeVertex ( E_DF, V_ADF, V_BDF );
78    setEdgeVertex ( E_DE, V_ADE, V_BDE );
79
80    setQuadEdge ( Q_A, E_AC, E_AF, E_AD, E_AE );
81    setQuadEdge ( Q_B, E_BC, E_BF, E_BD, E_BE );
82    setQuadEdge ( Q_C, E_AC, E_CF, E_BC, E_CE );
83    setQuadEdge ( Q_D, E_AD, E_DF, E_BD, E_DE );
84    setQuadEdge ( Q_E, E_AE, E_DE, E_BE, E_CE );
85    setQuadEdge ( Q_F, E_AF, E_DF, E_BF, E_CF );
86
87    setOpposedVertex ( V_ACE, V_BDF);
88    setOpposedVertex ( V_ACF, V_BDE);
89    setOpposedVertex ( V_ADF, V_BCE);
90    setOpposedVertex ( V_ADE, V_BCF);
91
92    setOpposedQuad  ( Q_A, Q_B );
93    setOpposedQuad  ( Q_C, Q_D );
94    setOpposedQuad  ( Q_E, Q_F );
95
96    dump_study = DumpActif; 
97 }
98 // ====================================================== getInstance
99 Globale* Globale::getInstance  ()
100 {
101    if (unique_instance==NULL) 
102        unique_instance = new Globale ();
103
104    return unique_instance;
105 }
106 // ====================================================== setCoordVertex
107 void Globale::setCoordVertex (EnumHVertex node, int px, int py, int pz)
108 {
109     coord_vertex [node] [dir_x] = 2*px-1;
110     coord_vertex [node] [dir_y] = 2*py-1;
111     coord_vertex [node] [dir_z] = 2*pz-1;
112 }
113 // ====================================================== setEdgeVertex 
114 void Globale::setEdgeVertex (EnumHEdge edge, EnumHVertex v1, EnumHVertex v2)
115 {
116     edge_vertex [edge] [V_AMONT] = v1;
117     edge_vertex [edge] [V_AVAL ] = v2;
118
119     if (db) 
120        printf (" %s = %2d = [%s, %s] = [%d,%d]\n", h_edge_name[edge], edge, 
121            h_vertex_name[v1], h_vertex_name[v2], v1, v2);
122 }
123 // ====================================================== setQuadEdge
124 void Globale::setQuadEdge (EnumHQuad face, EnumHEdge c1, EnumHEdge c2, 
125                                            EnumHEdge c3, EnumHEdge c4)
126 {
127     quad_edge [face] [E_A] = c1;
128     quad_edge [face] [E_B] = c2;
129     quad_edge [face] [E_C] = c3;
130     quad_edge [face] [E_D] = c4;
131 }
132 // ====================================================== setopposedVertex 
133 void Globale::setOpposedVertex (EnumHVertex lun, EnumHVertex lautre)
134 {
135     h_opposed_vertex [lun]    = lautre;
136     h_opposed_vertex [lautre] = lun;
137 }
138 // ====================================================== setopposedQuad 
139 void Globale::setOpposedQuad (EnumHQuad lun, EnumHQuad lautre)
140 {
141     h_opposed_quad [lun]    = lautre;
142     h_opposed_quad [lautre] = lun;
143 }
144 // ====================================================== setNames
145 void Globale::setNames  ()
146 {
147 #define SetNameHexaVertex(v) h_vertex_name [v] = #v
148 #define SetNameHexaEdge(e)   h_edge_name   [e] = #e
149 #define SetNameHexaQuad(q)   h_quad_name   [q] = #q
150
151    SetNameHexaVertex ( V_ACE );
152    SetNameHexaVertex ( V_ACF );
153    SetNameHexaVertex ( V_ADF );
154    SetNameHexaVertex ( V_ADE );
155    SetNameHexaVertex ( V_BCE );
156    SetNameHexaVertex ( V_BCF );
157    SetNameHexaVertex ( V_BDF );
158    SetNameHexaVertex ( V_BDE );
159    
160    SetNameHexaEdge ( E_AC );
161    SetNameHexaEdge ( E_AF );
162    SetNameHexaEdge ( E_AD );
163    SetNameHexaEdge ( E_AE );
164    SetNameHexaEdge ( E_BC );
165    SetNameHexaEdge ( E_BF );
166    SetNameHexaEdge ( E_BD );
167    SetNameHexaEdge ( E_BE );
168    SetNameHexaEdge ( E_CE );
169    SetNameHexaEdge ( E_CF );
170    SetNameHexaEdge ( E_DF );
171    SetNameHexaEdge ( E_DE );
172
173    SetNameHexaQuad ( Q_A );
174    SetNameHexaQuad ( Q_B );
175    SetNameHexaQuad ( Q_C );
176    SetNameHexaQuad ( Q_D );
177    SetNameHexaQuad ( Q_E );
178    SetNameHexaQuad ( Q_F );
179 }
180
181 END_NAMESPACE_HEXA