Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/hexablock.git] / src / HEXABLOCK / hexa_base.hxx
1
2 // Incl : Common definitions for HEXA-BLOCK
3
4 // Copyright (C) 2009-2012  CEA/DEN, EDF R&D
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.
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
23 #ifndef _HEXA_BASE_H_
24 #define _HEXA_BASE_H_
25
26 #include <cstdio>
27 #include <cstring>
28
29                     // Conventions C Ansi compatibles
30 typedef char*       pchar;
31 typedef const char* cpchar;
32 typedef FILE*       pfile;
33
34 #define Cestegal(c1,c2)      !strcmp(c1,c2)
35 #define Cestdifferent(c1,c2)  strcmp(c1,c2)
36 #define Cestvide(c1)    !c1[0]
37 #define Cestnonvide(c1)  c1[0]
38
39                      // Pour rendre les operateurs plus visibles
40 #define NOT    !  
41 #define XOR    ^
42 #define MODULO %
43 #define INOT   `
44 // #define IOR    |
45 #define IAND   &
46                     // Chaines de bits 
47 #define DeuxPuissance(n) (1 << (n))
48
49                      // Codes retour d'une fonction 
50 #define HOK  0       // Code retour=0 :  deroulement correct
51 #define HERR 1       // Code retour>0 = numero d'erreur, 1 par defaut
52 #define NOTHING -1   // Code retour fonction de recherche d'un index
53
54 #define EOL '\n'
55 #define EOS 0
56 #define CHVIDE ""
57                       // Calculs reels en 3D
58 #define ZEROR 0.0
59 #define UNR   1.0
60 #define DEMI  0.5
61 #define DIM2  2
62
63 // enum EnumCoord { dir_x, dir_y, dir_z, DIM3 };
64 // typedef double Real;
65 // typedef double Real3 [DIM3];
66
67 #ifndef PI
68 #define PI    3.1415926535898
69 #endif
70                        // Conventions C++
71 #include <string>
72 #include <vector>
73                        // Impressions de mise au point
74 #include <iostream>
75 using namespace std;
76
77 #define HexDisplay(x)      cout << " ... " #x " = " << x << endl
78 #define PutData(x)      cout << " ... " #x " = " << x << endl
79 #define PutCoord(x)      cout << " ... " #x " = (" << x[0] << ", " \
80                               << x[1] << ", " << x[2] << ")"  << endl
81 #define Echo(m)         cout << " _______________ " << m << endl
82
83 //  #define Libere(obj)     { if (obj!=NULL) free (obj)      ;  obj=NULL; }
84 //  #define Destroy(obj)    { delete obj       ;  obj=NULL   ;            }
85 //  #define Deltable(table) { delete [] table  ;  table=NULL ;            }
86
87 // ---------------------------------- Definitions propres a HEXA 
88 #define HEXA_NS Hex
89 #define BEGIN_NAMESPACE_HEXA namespace Hex {
90 #define END_NAMESPACE_HEXA   }
91
92 /* -----------------------------------------------------
93
94                 // ---- Numerotation des faces (%x) 
95                    
96        6=bed  +----bd-----+ bdf=7
97              /|          /|
98            be |   B    bf |
99            /  |        /  |
100     4=bce +----bc-----+...|...bcf=5
101           |  de     D |   df
102           | E |       | F |             z
103          ce   | C     cf  |             ^
104   2=ade...|...+----ad-|---+ adf=3       |   y
105           |  /        |  /              |  /
106           | ae    A   | af              | /
107           |/          |/                |/
108     0=ace +----ac-----+ acf=1           +----->  x
109                 
110  * ----------------------------------------------------- */
111
112 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
113 BEGIN_NAMESPACE_HEXA
114
115 enum EnumCoord  { dir_x, dir_y, dir_z, DIM3 };
116 enum EnumElt    { EL_NONE, EL_VERTEX, EL_EDGE, EL_QUAD, EL_HEXA, EL_VECTOR, 
117                   EL_REMOVED, EL_MAXI };
118
119 enum EnumGroup  { HexaCell, QuadCell, EdgeCell, 
120                   HexaNode, QuadNode, EdgeNode, VertexNode};
121
122                 //  Modes de remplissage des grilles cylindriques
123 enum EnumCyl   { CYL_NOFILL, CYL_CL4, CYL_CL6, CYL_CLOSED, CYL_PEER, CYL_ODD};
124 enum EnumGrid   { GR_NONE, GR_CARTESIAN, GR_CYLINDRIC, GR_SPHERIC, GR_JOINT, 
125                   GR_BICYL, GR_BIPIPE, GR_REPLACE, 
126                   GR_HEMISPHERIC, GR_RIND, GR_PART_SPHERIC, GR_PART_RIND };
127                 //  Sommets de la decomposition canonique du bicylindre
128                 // 0    1     2    3     4    5     6    7     8
129 enum EnumVCyl   { S_E, S_NE, S_N, S_NW, S_W, S_SW, S_S, S_SE, S_MAXI };
130
131 enum KindLaw    { Uniform, Arithmetic, Geometric };
132
133 enum EnumOrient { OR_FRONT, OR_LEFT, OR_RIGHT, OR_BACK }; // respecter l'ordre
134 enum EnumMark   { IS_NONE=-1,  IS_MARRIED=-2 };
135 enum EnumCount  { NO_COUNTED=-3, NO_USED=-2, IS_USED=-1};
136
137 enum EnumVertex { V_AMONT, V_AVAL, V_TWO };
138 enum EnumQuad   { E_A, E_B, E_C, E_D, QUAD4 };
139
140           //      z=0   z=1   y=0   y=1   x=0  x=1
141 enum EnumHQuad   {Q_A,  Q_B,  Q_C,  Q_D,  Q_E, Q_F,  HQ_MAXI};
142
143 enum EnumHEdge   {E_AC, E_AD, E_BC, E_BD, 
144                   E_AE, E_AF, E_BE, E_BF,
145                   E_CE, E_CF, E_DE, E_DF,  HE_MAXI };
146
147 enum EnumHVertex {V_ACE, V_ACF, V_ADE, V_ADF, V_BCE, V_BCF, V_BDE, V_BDF, 
148                   HV_MAXI };
149
150 enum EnumQDirection {Q_INSIDE, Q_DIRECT, Q_INVERSE, Q_UNDEFINED, Q_WAITING };
151
152 enum { CylSmall=0, CylBig=1, NxInt=1, NxExt=2 };
153
154 class Document;
155 class EltBase;
156
157 class Hexa;
158 class Quad;
159 class Edge;
160 class Vertex;
161
162 class Cylinder;
163 class Pipe;
164 class Prism;
165
166 class Vector;
167 class Matrix;
168 class Cloner;
169 class XmlWriter;
170 class XmlTree;
171
172 class  Elements;
173 class  GridElements;
174 class  SphericalGrid;
175 class  CrossElements;
176
177 struct  StrOrient;
178 class   Shape;
179 class   Globale;
180 class   Propagation;
181 class   Law;
182 class   Group;
183
184 class   AnaQuads;
185 class   Pattern;
186
187 typedef std::vector <Hexa*>  Hexas;
188 typedef std::vector <Quad*>  Quads;
189 typedef std::vector <Edge*>  Edges;
190 typedef std::vector <Shape*> Shapes;
191 typedef std::vector <double> RealVector;
192
193 typedef double Real;
194 typedef double Real3 [DIM3];
195
196                         // Quelques fonctions :
197
198 pchar   get_temp_name (cpchar format, pchar nomfic);
199 void    fatal_error   (cpchar format, cpchar info1=NULL, cpchar info2=NULL);
200
201 double  prod_scalaire  (double v1[], double v2[]);
202 double* prod_vectoriel (double v1[], double v2[], double v3[]);
203 double  prod_mixte     (double vi[], double vj[], double vk[]);
204
205 double  calc_norme     (double v1[]);
206 double  calc_distance  (double v1[], double v2[]);
207 void    calc_vecteur   (double pta[], double ptb[], double vab[]);
208 void    calc_milieu    (double pta[], double ptb[], double milieu[]);
209 int     normer_vecteur (double v1[]);
210
211 double carre       (double val);
212 bool   same_coords (double* pa, double* pb, double epsilon=1e-6);
213
214 bool   on_debug();
215 int    niv_debug();
216
217 void   set_minus (string& chaine);
218
219 bool   special_option ();
220 void   set_special_option (bool opt);
221
222 const double Epsil   = 1e-6;
223 const double UnEpsil = 0.999999;
224 const double Epsil2  = 1e-12;
225
226
227 END_NAMESPACE_HEXA
228
229 #endif