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