Salome HOME
Mise a jour M.Barry
[modules/hexablock.git] / src / HEXABLOCK / hexa_base.hxx
1
2 // Incl : Common definitions for HEXA-BLOCK
3
4 // Copyright (C) 2009-2013  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/
21 // or email : webmaster.salome@opencascade.com
22 //
23
24 #define DumpActif true
25
26 #ifndef _HEXA_BASE_H_
27 #define _HEXA_BASE_H_
28
29 #include "Hex_defines.hxx"
30
31 #include <cstdio>
32 #include <cstring>
33
34                     // Conventions C Ansi compatibles
35 typedef char*       pchar;
36 typedef const char* cpchar;
37 typedef FILE*       pfile;
38
39 #define Cestegal(c1,c2)      !strcmp(c1,c2)
40 #define Cestdifferent(c1,c2)  strcmp(c1,c2)
41 #define Cestvide(c1)    !c1[0]
42 #define Cestnonvide(c1)  c1[0]
43
44                      // Pour rendre les operateurs plus visibles
45                      // ... mais ne passe pas avec ce @#! de swig
46 #ifndef SWIG
47 #define NOT    !
48 #define XOR    ^
49 #define MODULO %
50 #define INOT   `
51 // #define IOR    |
52 #define IAND   &
53 #endif    // Swig
54                     // Chaines de bits
55 #define DeuxPuissance(n) (1 << (n))
56
57                      // Codes retour d'une fonction
58 #define HOK  0       // Code retour=0 :  deroulement correct
59 #define HERR 1       // Code retour>0 = numero d'erreur, 1 par defaut
60 #define NOTHING -1   // Code retour fonction de recherche d'un index
61
62 #define EOL '\n'
63 #define EOS 0
64 #define CHVIDE ""
65                       // Calculs reels en 3D
66 #define ZEROR 0.0
67 #define UNR   1.0
68 #define DEMI  0.5
69 #define DIM2  2
70
71 // enum EnumCoord { dir_x, dir_y, dir_z, DIM3 };
72 // typedef double Real;
73 // typedef double Real3 [DIM3];
74
75 #ifndef M_PI
76 #define M_PI  3.14159265358979323846
77 #endif
78 #define Degre2Radian M_PI/180
79
80                        // Conventions C++
81 #include <string>
82 #include <vector>
83
84 typedef const std::string& rcstring;
85                        // Impressions de mise au point
86 #include <iostream>
87 using namespace std;
88
89 #define HexDisplay(x)   cout << " ... " #x " = " << x << endl
90 #define PutData(x)      cout << " ... " #x " = " << x << endl
91 #define PutCoord(x)     cout << " ... " #x " = (" << x[0] << ", " \
92                               << x[1] << ", " << x[2] << ")"  << endl
93 #define Echo(m)         cout << " _______________ " << m << endl
94
95 //  #define Libere(obj)     { if (obj!=NULL) free (obj)      ;  obj=NULL; }
96 //  #define Destroy(obj)    { delete obj       ;  obj=NULL   ;            }
97 //  #define Deltable(table) { delete [] table  ;  table=NULL ;            }
98
99 // ---------------------------------- Definitions propres a HEXA
100 #define HEXA_NS Hex
101 #define BEGIN_NAMESPACE_HEXA namespace Hex {
102 #define END_NAMESPACE_HEXA   }
103
104 /* -----------------------------------------------------
105
106                 // ---- Numerotation des faces (%x)
107
108        6=bed  +----bd-----+ bdf=7
109              /|          /|
110            be |   B    bf |
111            /  |        /  |
112     4=bce +----bc-----+...|...bcf=5
113           |  de     D |   df
114           | E |       | F |             z
115          ce   | C     cf  |             ^
116   2=ade...|...+----ad-|---+ adf=3       |   y
117           |  /        |  /              |  /
118           | ae    A   | af              | /
119           |/          |/                |/
120     0=ace +----ac-----+ acf=1           +----->  x
121
122  * ----------------------------------------------------- */
123
124 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
125
126 class  TopoDS_Shape;
127 class  BRepAdaptor_Curve;
128
129 BEGIN_NAMESPACE_HEXA
130
131 enum EnumCoord  { dir_x, dir_y, dir_z, DIM3 };
132 enum EnumElt    { EL_NONE, EL_VERTEX, EL_EDGE, EL_QUAD, EL_HEXA, EL_VECTOR,
133                   EL_GRID, EL_CYLINDER, EL_PIPE, EL_GROUP, EL_LAW,
134                   EL_SHAPE, EL_SUBSHAPE, EL_PROPAGATION,
135                   EL_DOCU,  EL_REMOVED, EL_MAXI };
136
137 const cpchar ABR_TYPES = "xveqhwtcpglsupdz???";
138
139 enum EnumGroup  { HexaCell, QuadCell, EdgeCell,
140                   HexaNode, QuadNode, EdgeNode, VertexNode};
141
142                   // Origine des shapes
143 enum EnumShape { SH_NONE,  SH_IMPORT, SH_CYLINDER, SH_INTER, SH_SPHERE,
144                  SH_CLOUD, SH_EXTRUD };
145
146                 //  Modes de remplissage des grilles cylindriques
147 enum EnumCyl   { CYL_NOFILL, CYL_CL4, CYL_CL6, CYL_CLOSED, CYL_PEER, CYL_ODD};
148 enum EnumGrid   { GR_NONE, GR_CARTESIAN, GR_CYLINDRIC, GR_SPHERIC, GR_JOINT,
149                   GR_BICYL, GR_BIPIPE, GR_REPLACE,
150                   GR_HEMISPHERIC, GR_RIND, GR_PART_SPHERIC, GR_PART_RIND };
151                 //  Sommets de la decomposition canonique du bicylindre
152                 // 0    1     2    3     4    5     6    7     8
153 enum EnumVCyl   { S_E, S_NE, S_N, S_NW, S_W, S_SW, S_S, S_SE, S_MAXI };
154
155 enum KindLaw    { Uniform, Arithmetic, Geometric };
156
157 enum EnumOrient { OR_FRONT, OR_LEFT, OR_RIGHT, OR_BACK }; // respecter l'ordre
158 enum EnumMark   { IS_NONE=-1,  IS_MARRIED=-2 };
159 enum EnumCount  { NO_COUNTED=-3, NO_USED=-2, IS_USED=-1};
160
161 enum EnumVertex { V_AMONT, V_AVAL, V_TWO };
162 enum EnumQuad   { E_A, E_B, E_C, E_D, QUAD4 };
163
164           //      z=0   z=1   y=0   y=1   x=0  x=1
165 enum EnumHQuad   {Q_A,  Q_B,  Q_C,  Q_D,  Q_E, Q_F,  HQ_MAXI};
166
167 enum EnumHEdge   {E_AC, E_AD, E_BC, E_BD,
168                   E_AE, E_AF, E_BE, E_BF,
169                   E_CE, E_CF, E_DE, E_DF,  HE_MAXI };
170
171 enum EnumHVertex {V_ACE, V_ACF, V_ADE, V_ADF, V_BCE, V_BCF, V_BDE, V_BDF,
172                   HV_MAXI };
173
174 enum EnumQDirection {Q_INSIDE, Q_DIRECT, Q_INVERSE, Q_UNDEFINED, Q_WAITING };
175
176 enum EnumKindOfShape {KS_Line, KS_Circle, KS_Ellipse, KS_Hyperbola,
177                       KS_Parabola, KS_BezierCurve, KS_BSplineCurve,
178                       KS_OtherCurve, KS_None=-1 };
179
180 enum { CylSmall=0, CylBig=1, NxInt=1, NxExt=2 };
181
182 class Hex;
183 class Document;
184 class EltBase;
185
186 class Hexa;
187 class Quad;
188 class Edge;
189 class Vertex;
190
191 class Cylinder;
192 class Pipe;
193 class Prism;
194
195 class Vector;
196 class Matrix;
197 class Cloner;
198 class XmlWriter;
199 class XmlTree;
200
201 class  Elements;
202 class  BiCylinder;
203
204 struct  StrOrient;
205 class   Globale;
206 class   Propagation;
207 class   Law;
208 class   Group;
209
210 class   AnaQuads;
211 class   Pattern;
212
213 class   Shape;
214 class   SubShape;
215 class   VertexShape;
216 class   BiCylinderShape;
217 class   EdgeShape;
218 class   FaceShape;
219 class   AssoEdge;
220 class   NewShape;  // 1) Shape -> OldShape, 2) NewShape->Shape
221 typedef Shape OldShape;
222
223 typedef std::vector <Hexa*>  Hexas;
224 typedef std::vector <Quad*>  Quads;
225 typedef std::vector <Edge*>  Edges;
226 typedef std::vector <Shape*> Shapes;
227 typedef std::vector <Vertex*> Vertices;
228
229 typedef std::vector <NewShape*>  NewShapes;
230 typedef std::vector <SubShape*>  SubShapes;
231 typedef std::vector <AssoEdge*>  AssoEdges;
232 typedef std::vector <FaceShape*> FaceShapes;
233 typedef std::vector <EdgeShape*> EdgeShapes;
234
235 typedef std::vector <EltBase*>    TabElts;
236 typedef std::vector <double>      RealVector;
237 typedef std::vector <int>         IntVector;
238 typedef std::vector <std::string> TabText;
239
240 typedef double Real;
241 typedef double Real3 [DIM3];
242
243                                   // a cause de Swig
244 #ifndef HEXABLOCKENGINE_EXPORT 
245 #define HEXABLOCKENGINE_EXPORT 
246 #endif 
247
248 #ifndef HexaExport 
249 #define HexaExport 
250 #endif 
251
252                         // Quelques fonctions :
253
254 HexaExport pchar   get_temp_name (cpchar format, pchar nomfic);
255 HexaExport void    fatal_error   (cpchar format, cpchar info1=NULL, cpchar info2=NULL);
256
257 HexaExport double  prod_scalaire  (double v1[], double v2[]);
258 HexaExport double* prod_vectoriel (double v1[], double v2[], double v3[]);
259 HexaExport double  prod_mixte     (double vi[], double vj[], double vk[]);
260
261 HexaExport inline  double deg2radians (double angle) {  return (angle*M_PI/180.0); }
262 HexaExport inline  double rad2degres  (double angle) {  return (angle*180.0/M_PI); }
263
264 HexaExport double  calc_norme     (double v1[]);
265 HexaExport double  calc_distance  (double v1[],  double v2[]);
266 HexaExport double  calc_d2        (double v1[],  double v2[]);
267 HexaExport double  calc_d2        (double v1[], double v2[]);
268 HexaExport void    calc_vecteur   (double pta[], double ptb[], double vab[]);
269 HexaExport void    copy_vecteur   (double va [], double vb []);
270 HexaExport void    calc_milieu    (double pta[], double ptb[], double milieu[]);
271 HexaExport int     normer_vecteur (double v1[]);
272
273 HexaExport double  carre       (double val);
274 HexaExport bool    same_coords (double* pa, double* pb, double epsilon=1e-6);
275
276 HexaExport bool requals (const double  v1, const double  v2);
277 HexaExport bool requals (const double* v1, const double* v2);
278
279 HexaExport bool   on_debug();     // == getenv ("HEXA_DB") > 0
280 HexaExport bool   in_test ();     // == getenv ("HEXA_TEST") > 0
281 HexaExport int    niv_debug();    // Implemente prochainement
282
283 HexaExport void   set_minus (string& chaine);
284
285 HexaExport bool   special_option ();
286 HexaExport void   set_special_option (bool opt);
287
288 HexaExport int    sizeof_file (cpchar filename);
289 HexaExport char*  read_file   (cpchar filename, int& size);
290 HexaExport cpchar get_time   (string& buffer);
291 HexaExport int make_basename (cpchar filename, string& base);
292
293 const double Epsil   = 1e-6;
294 const double UnEpsil = 0.999999;
295 const double Epsil2  = 1e-12;
296
297 END_NAMESPACE_HEXA
298
299 #endif