Salome HOME
Porting HEXABLOCK module on WIN32 platform.
[modules/hexablock.git] / src / HEXABLOCK / HexBiCylinder.hxx
1
2 // Class : Gestion des tutaux en T (like castles in scotland)
3
4 //  Copyright (C) 2009-2011  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 #ifndef __BI_CYLINDER_H_
24 #define __BI_CYLINDER_H_
25
26 #include "Hex_defines.hxx"
27
28 #include "HexElements.hxx"
29 #include <map>
30
31 BEGIN_NAMESPACE_HEXA
32
33 class HEXABLOCKENGINE_EXPORT BiCylinder : public Elements
34 {
35 public:
36    BiCylinder (Document* doc);
37
38    Hexa*   getHexaIJK   (int part, int nx, int ny, int nz);
39    Quad*   getQuadIJ    (int part, int nx, int ny, int nz);
40    Quad*   getQuadJK    (int part, int nx, int ny, int nz);
41    Quad*   getQuadIK    (int part, int nx, int ny, int nz);
42    Edge*   getEdgeI     (int part, int nx, int ny, int nz);
43    Edge*   getEdgeJ     (int part, int nx, int ny, int nz);
44    Edge*   getEdgeK     (int part, int nx, int ny, int nz);
45    Vertex* getVertexIJK (int part, int nx, int ny, int nz);
46
47 #ifndef SWIG
48 public :
49    virtual ~BiCylinder () {}
50                      // Tutaux en T (like castles in scotland)
51    int makeCylinders (Vertex* ori1, double* vz1, double ray1, double h1, 
52                       Vertex* ori2, double* vz2, double ray2, double h2);
53
54    int makePipes (Vertex* ori1, double* z1, double ri1, double rx1, double h1, 
55                   Vertex* ori2, double* z2, double ri2, double rx2, double h2, 
56                   bool fill=false);
57
58    virtual int countHexa   () { return nbr_hexas ; }
59    virtual int countQuad   () { return nbr_quads ; }
60    virtual int countEdge   () { return nbr_edges ; }
61    virtual int countVertex () { return nbr_vertex ; }
62
63    // int  crossCylinders (Cylinder* cyl1, Cylinder* cyl2); // perime
64
65 private :
66
67    enum { NbrSlices=5, NbrVslices=NbrSlices+1, NbrCotes=4 };
68
69    void createLittlePipe ();
70    void createBigPipe    ();
71    void adjustLittleSlice  (int nx, int nzs);
72    void adjustLittleSquare (int nk);
73
74    Vertex* addVertex (double px, double py, double pz,
75                       int cyl, int ni, int nj, int nk);
76    Edge* addEdge (Vertex* v1, Vertex* v2,
77                   int cyl, int dir, int nx, int ny, int nz);
78    Quad* addQuad (Edge* e1, Edge* e2, Edge* e3, Edge* e4,
79                   int cyl, int dir, int nx, int ny, int nz);
80    Hexa* addHexa (Quad* qa, Quad* qb, Quad* qc, Quad* qd, Quad* qe, Quad* qf,
81                   int cyl, int nx, int ny, int nz);
82
83    Vertex* findVertex (double px, double py, double pz, int ni, int nj, int nk);
84    Edge*   findEdge (Vertex* v1, Vertex* v2, int dir, int nx, int ny, int nz);
85    Quad*   findQuad (Vertex* v1, Vertex* v2, int dir, int nx, int ny, int nz);
86    Quad*   findQuad (Edge* e1, Edge* e2, int dir, int nx, int ny, int nz);
87    Hexa*   findHexa (Quad* qa, Quad* qb, int nx, int ny, int nz);
88
89    Edge* findEdge (Vertex* v1, Vertex* v2);    // A replacer dans HexElements
90
91    void assoCylinders ();
92    void assoSlice    (int cyl, int nx, int nzs, double* norm);
93    void assoArc (int cyl, int nx, int ny, int nz, int subid);
94    void assoArc (int cyl, int ny, Vertex* v1, Vertex* v2, int subid);
95    int  assoIntersection (int nx, int nzlice);
96
97
98    void addSlice  (int cyl, int i, int k, double h, double r, bool find=false);
99    void addCarre  (int cyl, int k, double h, double r, bool find=false);
100    void addCube   (int cyl, int k, int i=0, int k1=-1);
101    void fillSlice (int cyl, int nia, int nka, int nib, int nkb, int nic,
102                             int nkc, int nid, int nkd, bool med=false);
103
104    double getAngle (int nj)             { return  (2*((nj)%4)+1)*M_PI/4; }
105    int getKey (int cyl, int ni, int nj, int nk)
106               { return 1000*(cyl+1) + 100*ni + 10*nj + nk; }
107    int getKey (int cyl, int dd, int ni, int nj, int nk)
108               { return 10000*(cyl+1) + 1000*dd + 100*ni + 10*nj + nk; }
109 private :
110     Real3     cross_center;
111     Real3     cross_oribig,   cross_dirbig;
112     Real3     cross_orismall, cross_dirsmall;
113
114     map <int,int> map_vertex, map_edge, map_quad, map_hexa;
115     map <int,int> :: iterator it_map;
116
117     int    nbr_hexas1, nbr_quads1, nbr_edges1, nbr_vertex1;
118     double cross_rayext  [V_TWO];
119     double cross_rayint  [V_TWO];
120     double cross_hauteur [V_TWO];
121
122     bool   at_right, at_left;
123
124     NewShape* grid_geom;
125 #endif
126 };
127 END_NAMESPACE_HEXA
128 #endif