2 // Incl : Common definitions for HEXA-BLOCK
4 // Copyright (C) 2009-2013 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.
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/
21 // or email : webmaster.salome@opencascade.com
24 #define DumpActif true
29 #include "Hex_defines.hxx"
34 // Conventions C Ansi compatibles
36 typedef const char* cpchar;
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]
44 // Pour rendre les operateurs plus visibles
45 // ... mais ne passe pas avec ce @#! de swig
55 #define DeuxPuissance(n) (1 << (n))
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
65 // Calculs reels en 3D
71 // enum EnumCoord { dir_x, dir_y, dir_z, DIM3 };
72 // typedef double Real;
73 // typedef double Real3 [DIM3];
76 #define M_PI 3.14159265358979323846
78 #define Degre2Radian M_PI/180
84 typedef const std::string& rcstring;
85 // Impressions de mise au point
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
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 ; }
99 // ---------------------------------- Definitions propres a HEXA
101 #define BEGIN_NAMESPACE_HEXA namespace Hex {
102 #define END_NAMESPACE_HEXA }
104 /* -----------------------------------------------------
106 // ---- Numerotation des faces (%x)
108 6=bed +----bd-----+ bdf=7
112 4=bce +----bc-----+...|...bcf=5
116 2=ade...|...+----ad-|---+ adf=3 | y
120 0=ace +----ac-----+ acf=1 +-----> x
122 * ----------------------------------------------------- */
124 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
127 class BRepAdaptor_Curve;
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 };
137 const cpchar ABR_TYPES = "xveqhwtcpglsupdz???";
139 enum EnumGroup { HexaCell, QuadCell, EdgeCell,
140 HexaNode, QuadNode, EdgeNode, VertexNode};
142 // Origine des shapes
143 enum EnumShape { SH_NONE, SH_IMPORT, SH_CYLINDER, SH_INTER, SH_SPHERE,
144 SH_CLOUD, SH_EXTRUD };
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
153 enum EnumVCyl { S_E, S_NE, S_N, S_NW, S_W, S_SW, S_S, S_SE, S_MAXI };
155 enum KindLaw { Uniform, Arithmetic, Geometric };
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};
161 enum EnumVertex { V_AMONT, V_AVAL, V_TWO };
162 enum EnumQuad { E_A, E_B, E_C, E_D, QUAD4 };
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};
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 };
171 enum EnumHVertex {V_ACE, V_ACF, V_ADE, V_ADF, V_BCE, V_BCF, V_BDE, V_BDF,
174 enum EnumQDirection {Q_INSIDE, Q_DIRECT, Q_INVERSE, Q_UNDEFINED, Q_WAITING };
176 enum { CylSmall=0, CylBig=1, NxInt=1, NxExt=2 };
215 class BiCylinderShape;
219 class NewShape; // 1) Shape -> OldShape, 2) NewShape->Shape
220 typedef Shape OldShape;
222 typedef std::vector <Hexa*> Hexas;
223 typedef std::vector <Quad*> Quads;
224 typedef std::vector <Edge*> Edges;
225 typedef std::vector <Shape*> Shapes;
226 typedef std::vector <Vertex*> Vertices;
228 typedef std::vector <NewShape*> NewShapes;
229 typedef std::vector <SubShape*> SubShapes;
230 typedef std::vector <AssoEdge*> AssoEdges;
231 typedef std::vector <FaceShape*> FaceShapes;
232 typedef std::vector <EdgeShape*> EdgeShapes;
234 typedef std::vector <EltBase*> TabElts;
235 typedef std::vector <double> RealVector;
236 typedef std::vector <int> IntVector;
237 typedef std::vector <std::string> TabText;
240 typedef double Real3 [DIM3];
242 // Quelques fonctions :
244 HEXABLOCKENGINE_EXPORT pchar get_temp_name (cpchar format, pchar nomfic);
245 HEXABLOCKENGINE_EXPORT void fatal_error (cpchar format, cpchar info1=NULL, cpchar info2=NULL);
247 HEXABLOCKENGINE_EXPORT double prod_scalaire (double v1[], double v2[]);
248 HEXABLOCKENGINE_EXPORT double* prod_vectoriel (double v1[], double v2[], double v3[]);
249 HEXABLOCKENGINE_EXPORT double prod_mixte (double vi[], double vj[], double vk[]);
251 HEXABLOCKENGINE_EXPORT inline double deg2radians (double angle) { return (angle*M_PI/180.0); }
252 HEXABLOCKENGINE_EXPORT inline double rad2degres (double angle) { return (angle*180.0/M_PI); }
254 HEXABLOCKENGINE_EXPORT double calc_norme (double v1[]);
255 HEXABLOCKENGINE_EXPORT double calc_distance (double v1[], double v2[]);
256 HEXABLOCKENGINE_EXPORT void calc_vecteur (double pta[], double ptb[], double vab[]);
257 HEXABLOCKENGINE_EXPORT void copy_vecteur (double va [], double vb []);
258 HEXABLOCKENGINE_EXPORT void calc_milieu (double pta[], double ptb[], double milieu[]);
259 HEXABLOCKENGINE_EXPORT int normer_vecteur (double v1[]);
261 HEXABLOCKENGINE_EXPORT double carre (double val);
262 HEXABLOCKENGINE_EXPORT bool same_coords (double* pa, double* pb, double epsilon=1e-6);
264 HEXABLOCKENGINE_EXPORT bool requals (const double v1, const double v2);
265 HEXABLOCKENGINE_EXPORT bool requals (const double* v1, const double* v2);
267 HEXABLOCKENGINE_EXPORT bool on_debug(); // == getenv ("HEXA_DB") > 0
268 HEXABLOCKENGINE_EXPORT bool in_test (); // == getenv ("HEXA_TEST") > 0
269 HEXABLOCKENGINE_EXPORT int niv_debug(); // Implemente prochainement
271 HEXABLOCKENGINE_EXPORT void set_minus (string& chaine);
273 HEXABLOCKENGINE_EXPORT bool special_option ();
274 HEXABLOCKENGINE_EXPORT void set_special_option (bool opt);
276 HEXABLOCKENGINE_EXPORT int sizeof_file (cpchar filename);
277 HEXABLOCKENGINE_EXPORT char* read_file (cpchar filename, int& size);
278 HEXABLOCKENGINE_EXPORT cpchar get_time (string& buffer);
280 const double Epsil = 1e-6;
281 const double UnEpsil = 0.999999;
282 const double Epsil2 = 1e-12;