Salome HOME
Move Hex_defines.hxx to the list of the headers.
[modules/hexablock.git] / src / HEXABLOCK / HexDocument_del.cxx
1
2 // C++ : Fonctions perimees de HexDocument
3
4 //  Copyright (C) 2009-2013  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 #include "HexDocument.hxx"
24
25 #include "HexEltBase.hxx"
26 #include "HexVertex.hxx"
27 #include "HexEdge.hxx"
28 #include "HexQuad.hxx"
29 #include "HexHexa.hxx"
30
31 #include "HexElements.hxx"
32 #include "HexCrossElements.hxx"
33
34 #include "HexVector.hxx"
35 #include "HexCylinder.hxx"
36 #include "HexPipe.hxx"
37 #include "HexMatrix.hxx"
38 #include "HexCloner.hxx"
39 #include "HexPropagation.hxx"
40 #include "HexLaw.hxx"
41
42 #include "HexXmlWriter.hxx"
43 #include "HexXmlTree.hxx"
44 #include "HexGlobale.hxx"
45 #include "HexGroup.hxx"
46 #include "Hex.hxx"
47 #include "HexNewShape.hxx"
48
49 BEGIN_NAMESPACE_HEXA
50
51
52 // ======================================================== makeCartesian
53 Elements* Document::makeCartesian (Vertex* v, Vector* dir,
54                             int px, int py, int pz, int mx, int my, int mz)
55 {
56    DumpStart ("makeCartesianDiag", v << dir << px << py << pz << mx << my << mz);
57
58    Vector* v1 = new Vector (this, dir->getDx(), 0, 0);
59    Vector* v2 = new Vector (this, 0, dir->getDy(), 0);
60    Vector* v3 = new Vector (this, 0,0,  dir->getDz());
61    Elements*  grille = new Elements (this);
62    grille->makeCartesianGrid (v, v1, v2, v3, px, py, pz, mx, my, mz);
63
64    DumpReturn (grille);
65    return grille;
66 }
67 // ======================================================== makeCartesian
68 Elements* Document::makeCartesian (Vertex* v, Vector* v1, Vector* v2,
69                                    Vector* v3, int px, int py, int pz)
70 {
71    DumpStart ("makeCartesian", v << v1 << v2 << v3 << px << py << pz);
72
73    Elements* grille = new Elements (this);
74    grille->makeCartesianGrid (v, v1, v2, v3, px, py, pz);
75
76    DumpReturn (grille);
77    return grille;
78 }
79 // ======================================================== makeCartesian1
80 Elements* Document::makeCartesian1 (Vertex* v, Vector* v1, Vector* v2,
81                     Vector* v3, int px, int py, int pz, int mx, int my, int mz)
82 {
83    DumpStart ("makeCartesian1", v << v1 << v2 << v3 << px << py << pz
84                               << mx << my << mz);
85
86    Elements* grille = new Elements (this);
87    grille->makeCartesianGrid (v, v1, v2, v3, px, py, pz, mx, my, mz);
88
89    DumpReturn (grille);
90    return grille;
91 }
92 // ======================================================== makeSpherical
93 Elements* Document::makeSpherical (Vertex* c, double rayon, int nb, double k)
94 {
95    DumpStart ("makeSpherical", c << rayon << nb << k );
96
97    Elements* grille = new Elements (this);
98    grille->makeSphericalGrid (c, rayon, nb, k);
99
100    DumpReturn (grille);
101    return grille;
102 }
103 // ======================================================== makeCylindrical
104 Elements* Document::makeCylindrical (Vertex* c, Vector* b, Vector* h,
105         double dr, double da, double dl, int nr, int na, int nl, bool fill)
106 {
107    DumpStart ("makeCylindrical", c << b << h << dr << da << dl << nr << na
108                                    << nl << fill);
109
110    Elements* grille = new Elements (this);
111    grille->makeCylindricalGrid (c, b, h, dr, da, dl, nr, na, nl, fill);
112
113    DumpReturn (grille);
114    return grille;
115 }
116 // ======================================================== makeSphere
117 Elements* Document::makeSphere (Vertex* center, Vector* vx, Vector* vz,
118                                 double radius, double radhole, Vertex* plorig,
119                                 int nrad, int nang, int nhaut)
120 {
121    DumpStart ("makeSphere", center << vx << vz << radius << radhole << plorig
122                   << nrad << nang << nhaut);
123
124    Elements* grille = new Elements (this);
125    double radint = (radhole + radius)*DEMI;
126    grille->makeRind (GR_HEMISPHERIC, center, vx, vz, radius, radint, radhole,
127                      plorig, 360.0, nrad, nang, nhaut);
128
129    DumpReturn (grille);
130    return grille;
131 }
132 // ======================================================== makePartSphere
133 Elements* Document::makePartSphere (Vertex* center, Vector* vx, Vector* vz,
134                                  double  radius, double radhole,
135                                  Vertex* plorig, double angle,
136                                  int nrad, int nang, int nhaut)
137 {
138    DumpStart ("makePartSphere", center << vx << vz
139                   << radius << radhole
140                   << plorig << angle
141                   << nrad   << nang << nhaut);
142
143    Elements* grille = new Elements (this);
144    double radint = (radhole + radius)*DEMI;
145    grille->makeRind (GR_PART_SPHERIC, center, vx, vz, radius, radint, radhole,
146                      plorig, angle, nrad, nang, nhaut);
147
148    DumpReturn (grille);
149    return grille;
150 }
151 // ======================================================== makeRind
152 Elements* Document::makeRind (Vertex* center, Vector* vx, Vector* vz,
153                               double  radext, double radint, double radhole,
154                               Vertex* plorig, int nrad, int nang, int nhaut)
155 {
156    DumpStart ("makeRind", center << vx << vz
157                   << radext << radint << radhole
158                   << plorig << nrad   << nang << nhaut);
159
160    Elements* grille = new Elements (this);
161    grille->makeRind (GR_RIND, center, vx, vz, radext, radint, radhole,
162                      plorig, 360.0, nrad, nang, nhaut);
163
164    DumpReturn (grille);
165    return grille;
166 }
167 // ======================================================== makePartRind
168 Elements* Document::makePartRind (Vertex* center, Vector* vx, Vector* vz,
169                            double  radext, double radint, double radhole,
170                            Vertex* plorig, double angle,
171                                int nrad, int nang, int nhaut)
172 {
173    DumpStart ("makePartRind", center << vx << vz
174                   << radext << radint << radhole
175                   << plorig << angle  << nrad  << nang << nhaut);
176
177    Elements* grille = new Elements (this);
178    grille->makeRind (GR_PART_RIND, center, vx, vz, radext, radint, radhole,
179                      plorig, angle, nrad, nang, nhaut);
180
181    DumpReturn (grille);
182    return grille;
183 }
184 // ======================================================== prismQuad
185 Elements* Document::prismQuad  (Quad* qstart, Vector* dir, int nb)
186 {
187    DumpStart ("prismQuad", qstart << dir << nb);
188
189    Quads  tstart;
190    tstart.push_back (qstart);
191
192    update ();
193    Elements* prisme = prismQuads (tstart, dir, nb);
194
195    DumpReturn (prisme);
196    return      prisme;
197 }
198 // ======================================================== prismQuads
199 Elements* Document::prismQuads (Quads tstart, Vector* dir, int nb)
200 {
201    DumpStart ("prismQuads", tstart << dir << nb);
202
203    Elements*  prisme = new Elements (this);
204
205    prisme->prismQuads (tstart, dir, nb);
206
207    DumpReturn (prisme);
208    return prisme;
209 }
210 // ======================================================== prismQuadsVec
211 Elements* Document::prismQuadsVec (Quads tstart, Vector* dir, RealVector tlen,
212                                    int crit)
213 {
214    DumpStart ("prismQuadVec", tstart << dir << tlen << crit);
215    Elements*  prisme = new Elements (this);
216    if (tlen.size()<=0) return prisme;
217
218    prisme->prismQuadsVec (tstart, dir, tlen, crit);
219
220    DumpReturn (prisme);
221    return prisme;
222 }
223 // ======================================================== joinQuads
224 Elements* Document::joinQuads (Quads tstart, Quad* dest, Vertex* v1,
225                                Vertex* v2, Vertex* v3, Vertex* v4, int nb)
226 {
227    DumpStart ("joinQuads", tstart << dest << v1 << v2 << v3 << v4 << nb);
228    update ();
229    Elements*  joint = new Elements (this);
230    if (nb<=0)      return joint;
231
232    int ier = joint->joinQuads (tstart, nb, v1, v2, v3, v4, dest);
233    if (ier !=HOK)
234       printf ("\n ****\n **** Error in joinQuad(s)\n ****\n");
235
236    DumpReturn (joint);
237    return joint;
238 }
239 // ======================================================== joinQuad
240 Elements* Document::joinQuad (Quad* qstart, Quad* dest, Vertex* v1,
241                               Vertex* v2,  Vertex* v3, Vertex* v4, int nb)
242 {
243    DumpStart ("joinQuad", qstart << dest << v1 << v2 << v3 << v4 << nb);
244
245    Quads  tstart;
246    tstart.push_back (qstart);
247
248    Elements* joint = joinQuads (tstart, dest, v1, v2, v3, v4, nb);
249
250    DumpReturn (joint);
251    return    joint;
252 }
253 // ======================================================== cut
254 Elements* Document::cut (Edge* edge, int nbcuts)
255 {
256    Elements* t_hexas = new Elements (this);
257
258    if (edge==NULL || nbcuts<=0)
259       return t_hexas;
260
261    Propagation* prop    = findPropagation (edge);
262    const Edges& t_edges = prop->getEdges ();
263
264    t_hexas->cutHexas (t_edges, nbcuts);
265
266    majPropagation ();
267    return t_hexas;
268 }
269 // ======================================================== makeCylinder
270 Elements* Document::makeCylinder (Cylinder* cyl, Vector* base, int nr, int na,
271                                                                        int nl)
272 {
273    DumpStart ("makeCylinder", cyl << base << nr << na << nl);
274
275    Elements* grille = new Elements (this);
276    grille->makeCylinder (cyl, base, nr, na, nl);
277
278    DumpReturn (grille);
279    return grille;
280 }
281 // ======================================================== makeCylinders
282 CrossElements* Document::makeCylinders (Cylinder* cyl1, Cylinder* cyl2)
283 {
284    DumpStart ("makeCylinders", cyl1 << cyl2 );
285
286    CrossElements* grille = new CrossElements (this, GR_BICYL);
287    grille->crossCylinders (cyl1, cyl2, true);
288
289    DumpReturn (grille);
290    return grille;
291 }
292
293 // ======================================================== makePipe
294 Elements* Document::makePipe (Pipe* pipe, Vector* bx, int nr, int na, int nl)
295 {
296    DumpStart ("makePipe",
297         pipe << bx << nr << na << nl);
298
299    Elements* grille = new Elements (this);
300    grille->makePipe (pipe, bx, nr, na, nr);
301
302    DumpReturn (grille);
303    return grille;
304 }
305 // ======================================================== makePipes
306 CrossElements* Document::makePipes (Pipe* pipe1, Pipe* pipe2)
307 {
308    DumpStart ("makePipes",
309         pipe1 << pipe2);
310
311    CrossElements* grille = new CrossElements (this, GR_BIPIPE);
312    grille->crossCylinders (pipe1, pipe2, false);
313
314    DumpReturn (grille);
315    return grille;
316 }
317 // ======================================================== getCylinder
318 Cylinder* Document::getCylinder (int nro)
319 {
320    int size = doc_cylinder.size();
321    if (nro>=0 && nro<size)
322       return doc_cylinder [nro];
323    else
324       return NULL;
325 }
326 // ======================================================== getPipe
327 Pipe* Document::getPipe (int nro)
328 {
329    int size = doc_pipe.size();
330    if (nro>=0 && nro<size)
331       return doc_pipe [nro];
332    else
333       return NULL;
334 }
335 // ======================================================== addCylinder
336 Cylinder* Document::addCylinder (Vertex* b, Vector* d, double r,  double h)
337 {
338    DumpStart ("addCylinder", b << d << r << h);
339
340    Cylinder* cyl = new  Cylinder (b, d, r, h);
341    doc_cylinder.push_back (cyl);
342
343    DumpReturn (cyl);
344    return    cyl;
345 }
346 // ======================================================== addPipe
347 Pipe* Document::addPipe (Vertex* b, Vector* d, double ri, double re, double h)
348 {
349    DumpStart ("addPipe", b << d << ri << re << h);
350
351    Pipe*  tuyau = new  Pipe (b, d, ri, re, h);
352    doc_pipe.push_back (tuyau);
353
354    DumpReturn (tuyau);
355    return tuyau;
356 }
357 // ======================================================== revolutionQuads
358 Elements* Document::revolutionQuadsVec (Quads start, Vertex* orig, Vector* axis,
359                                         RealVector angles)
360 {
361    if (orig==NULL)       return NULL;
362    if (axis==NULL)       return NULL;
363    if (angles.size()==0) return NULL;
364    if (start .size()==0) return NULL;
365
366    Elements*  prisme = new Elements (this);
367    prisme->revolutionQuads (start, orig, axis, angles);
368    return prisme;
369 }
370 // ======================================================== makeCylindricals
371 Elements* Document::makeCylindricals (Vertex* c, Vector* b, Vector* h, 
372                  RealVector tdr, RealVector tda, RealVector tdl, bool fill)
373 {
374    Elements* grille = new Elements (this);
375    grille->makeCylindricalGrid (c, b, h, tdr, tda, tdl, fill);
376    return grille;
377 }
378 END_NAMESPACE_HEXA