2 // Incl : Common definitions for HEXA-BLOCK
4 // Copyright (C) 2009-2022 CEA/DEN, EDF R&D
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #define DumpActif true
28 #include "Hex_defines.hxx"
33 // Conventions C Ansi compatibles
35 typedef const char* cpchar;
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]
43 // Pour rendre les operateurs plus visibles
44 // ... mais ne passe pas avec ce @#! de swig
54 #define DeuxPuissance(n) (1 << (n))
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
64 // Calculs reels en 3D
70 // enum EnumCoord { dir_x, dir_y, dir_z, DIM3 };
71 // typedef double Real;
72 // typedef double Real3 [DIM3];
75 #define M_PI 3.14159265358979323846
77 #define Degre2Radian M_PI/180
83 typedef const std::string& rcstring;
84 // Impressions de mise au point
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
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 ; }
97 // ---------------------------------- Definitions propres a HEXA
99 #define BEGIN_NAMESPACE_HEXA namespace Hex {
100 #define END_NAMESPACE_HEXA }
102 /* -----------------------------------------------------
104 // ---- Numerotation des faces (%x)
106 6=bed +----bd-----+ bdf=7
110 4=bce +----bc-----+...|...bcf=5
114 2=ade...|...+----ad-|---+ adf=3 | y
118 0=ace +----ac-----+ acf=1 +-----> x
120 * ----------------------------------------------------- */
122 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
125 class BRepAdaptor_Curve;
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 };
135 const cpchar ABR_TYPES = "xveqhwtcpglsupdz???";
137 enum EnumGroup { HexaCell, QuadCell, EdgeCell,
138 HexaNode, QuadNode, EdgeNode, VertexNode};
140 // Origine des shapes
141 enum EnumShape { SH_NONE, SH_IMPORT, SH_CYLINDER, SH_INTER, SH_SPHERE,
142 SH_CLOUD, SH_EXTRUD };
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
151 enum EnumVCyl { S_E, S_NE, S_N, S_NW, S_W, S_SW, S_S, S_SE, S_MAXI };
153 enum KindLaw { Uniform, Arithmetic, Geometric };
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};
159 enum EnumVertex { V_AMONT, V_AVAL, V_TWO };
160 enum EnumQuad { E_A, E_B, E_C, E_D, QUAD4 };
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};
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 };
169 enum EnumHVertex {V_ACE, V_ACF, V_ADE, V_ADF, V_BCE, V_BCF, V_BDE, V_BDF,
172 enum EnumQDirection {Q_INSIDE, Q_DIRECT, Q_INVERSE, Q_UNDEFINED, Q_WAITING };
174 enum EnumKindOfShape {KS_Line, KS_Circle, KS_Ellipse, KS_Hyperbola,
175 KS_Parabola, KS_BezierCurve, KS_BSplineCurve,
176 KS_OtherCurve, KS_None=-1 };
178 enum { CylSmall=0, CylBig=1, NxInt=1, NxExt=2 };
214 class BiCylinderShape;
218 class NewShape; // 1) Shape -> OldShape, 2) NewShape->Shape
219 typedef Shape OldShape;
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;
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;
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;
239 typedef double Real3 [DIM3];
242 #ifndef HEXABLOCKENGINE_EXPORT
243 #define HEXABLOCKENGINE_EXPORT
250 // Quelques fonctions :
252 HexaExport pchar get_temp_name (cpchar format, pchar nomfic);
253 HexaExport void fatal_error (cpchar format, cpchar info1=NULL, cpchar info2=NULL);
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[]);
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); }
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[]);
271 HexaExport double carre (double val);
272 HexaExport bool same_coords (double* pa, double* pb, double epsilon=1e-6);
274 HexaExport bool requals (const double v1, const double v2);
275 HexaExport bool requals (const double* v1, const double* v2);
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
281 HexaExport void set_minus (std::string& chaine);
283 HexaExport bool special_option ();
284 HexaExport void set_special_option (bool opt);
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);
291 const double Epsil = 1e-6;
292 const double UnEpsil = 0.999999;
293 const double Epsil2 = 1e-12;