]> SALOME platform Git repositories - modules/hexablock.git/blob - src/HEXABLOCK/test_hexa5.cxx
Salome HOME
Bug moteur + ajout cas test
[modules/hexablock.git] / src / HEXABLOCK / test_hexa5.cxx
1
2 // C++ : Tests unitaires sur les creations h'hexaedres
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 #include "Hex.hxx"
24
25 #include <unistd.h>
26
27 #include "HexDocument.hxx"
28 #include "HexElements.hxx"
29
30 #include "HexHexa.hxx"
31 #include "HexQuad.hxx"
32 #include "HexEdge.hxx"
33 #include "HexVertex.hxx"
34
35 #include "HexCramer.hxx"
36
37 // ======================================================== test_hexa_quads_5
38 int test_replace5 (int nbargs, cpchar tabargs[])
39 {
40    const int size_x = 4;
41    const int size_y = 4;
42    const int size_z = 2;
43
44    double lgcell = 3;
45    double decal  = lgcell/sqrt (2.0);
46
47    int nvtk = 0;
48    cpchar son_nom = "replace5";
49
50    Hex::Hex mon_ex;
51    Hex::Document* doc = mon_ex.addDocument (son_nom);
52
53    Hex::Vector* vx   = doc->addVector (3,0,0);
54    Hex::Vector* vz   = doc->addVector (0,0,1);
55
56    Hex::Elements* grid1 = doc->makeCartesianTop (size_x,size_y,size_z);
57    doc->saveVtk (son_nom, nvtk);
58
59    for (int nz=0 ; nz<=size_z ; ++nz)
60        {
61        grid1->getVertexIJK (1, 1, nz)->setX (-decal);
62        grid1->getVertexIJK (1, 1, nz)->setY (-decal);
63
64        grid1->getVertexIJK (1, 3, nz)->setX (-decal);
65        grid1->getVertexIJK (1, 3, nz)->setY ( decal);
66
67        grid1->getVertexIJK (3, 1, nz)->setX ( decal);
68        grid1->getVertexIJK (3, 1, nz)->setY (-decal);
69
70        grid1->getVertexIJK (3, 3, nz)->setX ( decal);
71        grid1->getVertexIJK (3, 3, nz)->setY ( decal);
72        }
73
74    doc->saveVtk (son_nom, nvtk);
75
76    Hex::Vertex* ori0 = doc->addVertex (0,-10,0);
77    Hex::Vertex* ori2 = doc->addVertex (0,0,0);
78    const double da = 360;
79    const double dl = 1;
80    const int    nr = 2;
81    const int    na = 8;
82    const int    nl = 3;
83
84
85    Hex::Elements* grid0 = doc->makePipeUni (ori0, vx, vz, 
86                                             1.0,5.0, da, dl, nr, na, nl);
87
88    doc->saveVtk (son_nom, nvtk);
89
90    // Hex::Elements* grid2 = 
91    doc->makePipeUni (ori2, vx, vz, 1.0,5.0, da, dl, nr, na, nl);
92
93    doc->saveVtk (son_nom, nvtk);
94    grid0->remove ();
95    doc->saveVtk (son_nom, nvtk);
96    return HOK;
97 }
98 // ======================================================== test_get
99 int test_get (int nbargs, cpchar tabargs[])
100 {
101    const int size_x = 2;
102    const int size_y = 2;
103    const int size_z = 2;
104
105    int nvtk = 0;
106    cpchar son_nom = "test_get";
107
108    Hex::Hex mon_ex;
109    Hex::Document* doc = mon_ex.addDocument (son_nom);
110
111    Hex::Elements* grid = doc->makeCartesianTop (size_x,size_y,size_z);
112    doc->saveVtk (son_nom, nvtk);
113    grid->getVertexIJK (2, 1, 1)->setColor (4);
114    doc->saveVtk (son_nom, nvtk);
115
116    grid->getVertexIJK (2, 1, 1)->setColor (0);
117    grid->getEdgeK     (1, 0, 1)->setColor (4);
118    doc->saveVtk (son_nom, nvtk);
119
120    grid->getEdgeK     (1, 0, 1)->setColor (0);
121    grid->getQuadIJ    (1, 0, 2)->setColor (4);
122    doc->saveVtk (son_nom, nvtk);
123
124    grid->getHexaIJK   (1, 0, 1)->setColor (4);
125    doc->saveVtk (son_nom, nvtk);
126    doc->saveVtk (son_nom, nvtk);
127    doc->saveVtk (son_nom, nvtk);
128    doc->saveVtk (son_nom, nvtk);
129    doc->saveVtk (son_nom, nvtk);
130    doc->saveVtk (son_nom, nvtk);
131    doc->saveVtk (son_nom, nvtk);
132    doc->saveVtk (son_nom, nvtk);
133    return HOK;
134 }
135 // ======================================================== test_dump
136 int test_dump (int nbargs, cpchar tabargs[])
137 {
138    const int size_x = 4;
139    const int size_y = 4;
140    const int size_z = 2;
141
142    int nvtk = 0;
143    cpchar son_nom = "test_dump";
144
145    Hex::Hex mon_ex;
146    Hex::Document* doc = mon_ex.addDocument (son_nom);
147
148    doc->makeCartesianTop (size_x,size_y,size_z);
149    doc->saveVtk (son_nom, nvtk);
150    return HOK;
151 }