2 // C++ : Fonctions perimees de HexDocument
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
23 #include "HexDocument.hxx"
25 #include "HexEltBase.hxx"
26 #include "HexVertex.hxx"
27 #include "HexEdge.hxx"
28 #include "HexQuad.hxx"
29 #include "HexHexa.hxx"
31 #include "HexElements.hxx"
32 #include "HexCrossElements.hxx"
34 #include "HexVector.hxx"
35 #include "HexCylinder.hxx"
36 #include "HexPipe.hxx"
37 #include "HexMatrix.hxx"
38 #include "HexCloner.hxx"
39 #include "HexPropagation.hxx"
42 #include "HexXmlWriter.hxx"
43 #include "HexXmlTree.hxx"
44 #include "HexGlobale.hxx"
45 #include "HexGroup.hxx"
47 #include "HexNewShape.hxx"
52 // ======================================================== makeCartesian
53 Elements* Document::makeCartesian (Vertex* v, Vector* dir,
54 int px, int py, int pz, int mx, int my, int mz)
56 DumpStart ("makeCartesianDiag", v << dir << px << py << pz << mx << my << mz);
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);
67 // ======================================================== makeCartesian
68 Elements* Document::makeCartesian (Vertex* v, Vector* v1, Vector* v2,
69 Vector* v3, int px, int py, int pz)
71 DumpStart ("makeCartesian", v << v1 << v2 << v3 << px << py << pz);
73 Elements* grille = new Elements (this);
74 grille->makeCartesianGrid (v, v1, v2, v3, px, py, pz);
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)
83 DumpStart ("makeCartesian1", v << v1 << v2 << v3 << px << py << pz
86 Elements* grille = new Elements (this);
87 grille->makeCartesianGrid (v, v1, v2, v3, px, py, pz, mx, my, mz);
92 // ======================================================== makeSpherical
93 Elements* Document::makeSpherical (Vertex* c, double rayon, int nb, double k)
95 DumpStart ("makeSpherical", c << rayon << nb << k );
97 Elements* grille = new Elements (this);
98 grille->makeSphericalGrid (c, rayon, nb, k);
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)
107 DumpStart ("makeCylindrical", c << b << h << dr << da << dl << nr << na
110 Elements* grille = new Elements (this);
111 grille->makeCylindricalGrid (c, b, h, dr, da, dl, nr, na, nl, fill);
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)
121 DumpStart ("makeSphere", center << vx << vz << radius << radhole << plorig
122 << nrad << nang << nhaut);
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);
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)
138 DumpStart ("makePartSphere", center << vx << vz
141 << nrad << nang << nhaut);
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);
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)
156 DumpStart ("makeRind", center << vx << vz
157 << radext << radint << radhole
158 << plorig << nrad << nang << nhaut);
160 Elements* grille = new Elements (this);
161 grille->makeRind (GR_RIND, center, vx, vz, radext, radint, radhole,
162 plorig, 360.0, nrad, nang, nhaut);
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)
173 DumpStart ("makePartRind", center << vx << vz
174 << radext << radint << radhole
175 << plorig << angle << nrad << nang << nhaut);
177 Elements* grille = new Elements (this);
178 grille->makeRind (GR_PART_RIND, center, vx, vz, radext, radint, radhole,
179 plorig, angle, nrad, nang, nhaut);
184 // ======================================================== prismQuad
185 Elements* Document::prismQuad (Quad* qstart, Vector* dir, int nb)
187 DumpStart ("prismQuad", qstart << dir << nb);
190 tstart.push_back (qstart);
193 Elements* prisme = prismQuads (tstart, dir, nb);
198 // ======================================================== prismQuads
199 Elements* Document::prismQuads (Quads tstart, Vector* dir, int nb)
201 DumpStart ("prismQuads", tstart << dir << nb);
203 Elements* prisme = new Elements (this);
205 prisme->prismQuads (tstart, dir, nb);
210 // ======================================================== prismQuadsVec
211 Elements* Document::prismQuadsVec (Quads tstart, Vector* dir, RealVector tlen,
214 DumpStart ("prismQuadVec", tstart << dir << tlen << crit);
215 Elements* prisme = new Elements (this);
216 if (tlen.size()<=0) return prisme;
218 prisme->prismQuadsVec (tstart, dir, tlen, crit);
223 // ======================================================== joinQuads
224 Elements* Document::joinQuads (Quads tstart, Quad* dest, Vertex* v1,
225 Vertex* v2, Vertex* v3, Vertex* v4, int nb)
227 DumpStart ("joinQuads", tstart << dest << v1 << v2 << v3 << v4 << nb);
229 Elements* joint = new Elements (this);
230 if (nb<=0) return joint;
232 int ier = joint->joinQuads (tstart, nb, v1, v2, v3, v4, dest);
234 printf ("\n ****\n **** Error in joinQuad(s)\n ****\n");
239 // ======================================================== joinQuad
240 Elements* Document::joinQuad (Quad* qstart, Quad* dest, Vertex* v1,
241 Vertex* v2, Vertex* v3, Vertex* v4, int nb)
243 DumpStart ("joinQuad", qstart << dest << v1 << v2 << v3 << v4 << nb);
246 tstart.push_back (qstart);
248 Elements* joint = joinQuads (tstart, dest, v1, v2, v3, v4, nb);
253 // ======================================================== cut
254 Elements* Document::cut (Edge* edge, int nbcuts)
256 Elements* t_hexas = new Elements (this);
258 if (edge==NULL || nbcuts<=0)
261 Propagation* prop = findPropagation (edge);
262 const Edges& t_edges = prop->getEdges ();
264 t_hexas->cutHexas (t_edges, nbcuts);
269 // ======================================================== makeCylinder
270 Elements* Document::makeCylinder (Cylinder* cyl, Vector* base, int nr, int na,
273 DumpStart ("makeCylinder", cyl << base << nr << na << nl);
275 Elements* grille = new Elements (this);
276 grille->makeCylinder (cyl, base, nr, na, nl);
281 // ======================================================== makeCylinders
282 CrossElements* Document::makeCylinders (Cylinder* cyl1, Cylinder* cyl2)
284 DumpStart ("makeCylinders", cyl1 << cyl2 );
286 CrossElements* grille = new CrossElements (this, GR_BICYL);
287 grille->crossCylinders (cyl1, cyl2, true);
293 // ======================================================== makePipe
294 Elements* Document::makePipe (Pipe* pipe, Vector* bx, int nr, int na, int nl)
296 DumpStart ("makePipe",
297 pipe << bx << nr << na << nl);
299 Elements* grille = new Elements (this);
300 grille->makePipe (pipe, bx, nr, na, nr);
305 // ======================================================== makePipes
306 CrossElements* Document::makePipes (Pipe* pipe1, Pipe* pipe2)
308 DumpStart ("makePipes",
311 CrossElements* grille = new CrossElements (this, GR_BIPIPE);
312 grille->crossCylinders (pipe1, pipe2, false);
317 // ======================================================== getCylinder
318 Cylinder* Document::getCylinder (int nro)
320 int size = doc_cylinder.size();
321 if (nro>=0 && nro<size)
322 return doc_cylinder [nro];
326 // ======================================================== getPipe
327 Pipe* Document::getPipe (int nro)
329 int size = doc_pipe.size();
330 if (nro>=0 && nro<size)
331 return doc_pipe [nro];
335 // ======================================================== addCylinder
336 Cylinder* Document::addCylinder (Vertex* b, Vector* d, double r, double h)
338 DumpStart ("addCylinder", b << d << r << h);
340 Cylinder* cyl = new Cylinder (b, d, r, h);
341 doc_cylinder.push_back (cyl);
346 // ======================================================== addPipe
347 Pipe* Document::addPipe (Vertex* b, Vector* d, double ri, double re, double h)
349 DumpStart ("addPipe", b << d << ri << re << h);
351 Pipe* tuyau = new Pipe (b, d, ri, re, h);
352 doc_pipe.push_back (tuyau);
357 // ======================================================== revolutionQuads
358 Elements* Document::revolutionQuadsVec (Quads start, Vertex* orig, Vector* axis,
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;
366 Elements* prisme = new Elements (this);
367 prisme->revolutionQuads (start, orig, axis, angles);
370 // ======================================================== makeCylindricals
371 Elements* Document::makeCylindricals (Vertex* c, Vector* b, Vector* h,
372 RealVector tdr, RealVector tda, RealVector tdl, bool fill)
374 Elements* grille = new Elements (this);
375 grille->makeCylindricalGrid (c, b, h, tdr, tda, tdl, fill);