2 // Incl : Common definitions for HEXA-BLOCK
4 // Copyright (C) 2009-2012 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/ or email : webmaster.salome@opencascade.com
29 // Conventions C Ansi compatibles
31 typedef const char* cpchar;
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]
39 // Pour rendre les operateurs plus visibles
47 #define DeuxPuissance(n) (1 << (n))
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
57 // Calculs reels en 3D
63 // enum EnumCoord { dir_x, dir_y, dir_z, DIM3 };
64 // typedef double Real;
65 // typedef double Real3 [DIM3];
68 #define PI 3.1415926535898
73 // Impressions de mise au point
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
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 ; }
87 // ---------------------------------- Definitions propres a HEXA
89 #define BEGIN_NAMESPACE_HEXA namespace Hex {
90 #define END_NAMESPACE_HEXA }
92 /* -----------------------------------------------------
94 // ---- Numerotation des faces (%x)
96 6=bed +----bd-----+ bdf=7
100 4=bce +----bc-----+...|...bcf=5
104 2=ade...|...+----ad-|---+ adf=3 | y
108 0=ace +----ac-----+ acf=1 +-----> x
110 * ----------------------------------------------------- */
112 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
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_GRID, EL_CYLINDER, EL_PIPE, EL_REMOVED, EL_MAXI };
119 enum EnumGroup { HexaCell, QuadCell, EdgeCell,
120 HexaNode, QuadNode, EdgeNode, VertexNode};
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
129 enum EnumVCyl { S_E, S_NE, S_N, S_NW, S_W, S_SW, S_S, S_SE, S_MAXI };
131 enum KindLaw { Uniform, Arithmetic, Geometric };
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};
137 enum EnumVertex { V_AMONT, V_AVAL, V_TWO };
138 enum EnumQuad { E_A, E_B, E_C, E_D, QUAD4 };
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};
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 };
147 enum EnumHVertex {V_ACE, V_ACF, V_ADE, V_ADF, V_BCE, V_BCF, V_BDE, V_BDF,
150 enum EnumQDirection {Q_INSIDE, Q_DIRECT, Q_INVERSE, Q_UNDEFINED, Q_WAITING };
152 enum { CylSmall=0, CylBig=1, NxInt=1, NxExt=2 };
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;
194 typedef double Real3 [DIM3];
196 // Quelques fonctions :
198 pchar get_temp_name (cpchar format, pchar nomfic);
199 void fatal_error (cpchar format, cpchar info1=NULL, cpchar info2=NULL);
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[]);
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[]);
211 double carre (double val);
212 bool same_coords (double* pa, double* pb, double epsilon=1e-6);
217 void set_minus (string& chaine);
219 bool special_option ();
220 void set_special_option (bool opt);
222 const double Epsil = 1e-6;
223 const double UnEpsil = 0.999999;
224 const double Epsil2 = 1e-12;