]> SALOME platform Git repositories - modules/hexablock.git/blob - src/HEXABLOCK/HexDocument_trans.cxx
Salome HOME
ParaView 4.1 / VTK 6.1 porting
[modules/hexablock.git] / src / HEXABLOCK / HexDocument_trans.cxx
1
2 // C++ : La clase principale de Hexa
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/ or email : webmaster.salome@opencascade.com
21 //
22 #include "HexDocument.hxx"
23
24 #include "HexEltBase.hxx"
25 #include "HexVertex.hxx"
26 #include "HexEdge.hxx"
27 #include "HexQuad.hxx"
28 #include "HexHexa.hxx"
29
30 #include "HexElements.hxx"
31
32 #include "HexVector.hxx"
33 #include "HexMatrix.hxx"
34 #include "HexCloner.hxx"
35 #include "HexPropagation.hxx"
36 #include "HexLaw.hxx"
37
38 #include "HexXmlWriter.hxx"
39 #include "HexXmlTree.hxx"
40 #include "HexGlobale.hxx"
41
42 BEGIN_NAMESPACE_HEXA
43 // ========================================================= performTranslation
44 int Document::performTranslation (Elements* elts, Vector* trans)
45
46    DumpStart ("performTranslation", elts << trans);
47
48    Matrix matrice;
49    matrice.defTranslation (trans);
50
51    int    ier = elts->transform (&matrice);
52
53    DumpReturn (ier);
54    return ier;
55 }
56 // ==================================================== performScale
57 int Document::performScale (Elements* elts, Vertex* ver, double k)
58
59    DumpStart ("performScale", elts << ver << k);
60
61    Matrix matrice;
62    matrice.defScale (ver, k);
63
64    int    ier = elts->transform (&matrice);
65
66    DumpReturn (ier);
67    return ier;
68 }
69 // ==================================================== performRotation
70 int Document::performRotation (Elements* elts, Vertex* ver, Vector* vec, double angle)
71
72    DumpStart ("performRotation", elts << ver << vec << angle);
73
74    Matrix matrice;
75    matrice.defRotation (ver, vec, angle);
76
77    int    ier = elts->transform (&matrice);
78
79    DumpReturn (ier);
80    return ier;
81 }
82 // ==================================================== performSymmetryPoint
83 int Document::performSymmetryPoint (Elements* elts, Vertex* ver)
84
85    DumpStart ("performSymmetryPoint", elts << ver);
86
87    Matrix matrice;
88    matrice.defSymmetryPoint (ver);
89
90    int    ier = elts->transform (&matrice);
91
92    DumpReturn (ier);
93    return ier;
94 }
95 // ==================================================== performSymmetryPlane
96 int Document::performSymmetryPlane (Elements* elts, Vertex* ver, Vector* vec)    
97
98    DumpStart ("performSymmetryPlane", elts << ver << vec);
99
100    Matrix matrice;
101    matrice.defSymmetryPlane (ver, vec);
102
103    int    ier = elts->transform (&matrice);
104
105    DumpReturn (ier);
106    return ier;
107 }
108
109 // ==================================================== performSymmetryLine
110 int Document::performSymmetryLine (Elements* elts, Vertex* ver, Vector* vec)
111
112    DumpStart ("performSymmetryLine", elts << ver << vec);
113
114    Matrix matrice;
115    matrice.defSymmetryLine (ver, vec);
116
117    int    ier = elts->transform (&matrice);
118
119    DumpReturn (ier);
120    return ier;
121 }
122 // -------------------------------------------------------- 
123 // -------------------------------------------------------- 
124 // -------------------------------------------------------- 
125 // ========================================================= clonerElements
126 Elements* Document::clonerElements (Elements* table, Matrix* matrice)
127 {
128    Cloner    copieur (matrice);
129    Elements* grille = copieur.clonerElements (table);
130    return    grille;
131 }
132 // -------------------------------------------------------- 
133 // -------------------------------------------------------- 
134 // -------------------------------------------------------- 
135 // ========================================================= makeTranslation
136 Elements* Document::makeTranslation (Elements* table, Vector* trans)
137 {
138    DumpStart ("makeTranslation", table  << trans);
139
140    Matrix  matrice;
141    matrice.defTranslation (trans);
142
143    Elements* grille = clonerElements (table, &matrice);
144
145    DumpReturn (grille);
146    return  grille;
147 }
148 // ========================================================= makeScale
149 Elements* Document::makeScale (Elements* table, Vertex* ver, double k)
150 {
151    DumpStart ("makeScale", table  << ver << k);
152
153    Matrix  matrice;
154    matrice.defScale (ver, k);
155
156    Elements* grille = clonerElements (table, &matrice);
157
158    DumpReturn (grille);
159    return    grille;
160 }
161 // ========================================================= makeRotation
162 Elements* Document::makeRotation (Elements* table, Vertex* ver, Vector* vec, 
163                                   double angle)
164 {
165    DumpStart ("makeRotation", table  << ver << vec << angle);
166
167    Matrix  matrice;
168    matrice.defRotation (ver, vec, angle);
169
170    Elements* grille = clonerElements (table, &matrice);
171
172    DumpReturn (grille);
173    return    grille;
174 }
175 // ========================================================= makeSymmetryPoint
176 Elements* Document::makeSymmetryPoint (Elements* table, Vertex* ver)
177 {
178    DumpStart ("makeSymmetryPoint", table  << ver);
179
180    Matrix  matrice;
181    matrice.defSymmetryPoint (ver);
182
183    Elements* grille = clonerElements (table, &matrice);
184
185    DumpReturn (grille);
186    return    grille;
187 }
188 // ========================================================= makeSymmetryLine
189 Elements* Document::makeSymmetryLine (Elements* table, Vertex* ver, Vector* vec)
190 {
191    DumpStart ("makeSymmetryLine", table  << ver << vec);
192
193    Matrix  matrice;
194    matrice.defSymmetryLine (ver, vec);
195
196    Elements* grille = clonerElements (table, &matrice);
197
198    DumpReturn (grille);
199    return    grille;
200 }
201 // ========================================================= makeSymmetryPlane
202 Elements* Document::makeSymmetryPlane (Elements* table, Vertex* ver, Vector* vec)
203 {
204    DumpStart ("makeSymmetryPlane", table  << ver << vec);
205
206    Matrix  matrice;
207    matrice.defSymmetryPlane (ver, vec);
208
209    Elements* grille = clonerElements (table, &matrice);
210
211    DumpReturn (grille);
212    return    grille;
213 }
214 // ----------------------------------------------------------------------
215 // ------------ Destroy
216 // ----------------------------------------------------------------------
217 // ========================================================= removeHexa
218 int Document::removeHexa (Hexa* cell)
219 {
220    DumpStart ("removeHexa", cell);
221
222    int ier = HOK;
223    if (cell==NULL)
224       ier = HERR;
225    else
226       cell->remove ();
227
228    DumpReturn (ier);
229    return ier;
230 }
231 // ========================================================= removeQuad
232 int Document::removeQuad (Quad* cell)
233 {
234    DumpStart ("removeQuad", cell);
235
236    int ier = HOK;
237    if (cell==NULL)
238       ier = HERR;
239    else
240       cell->remove ();
241
242    DumpReturn (ier);
243    return ier;
244 }
245 // ========================================================= removeElements
246 int Document::removeElements (Elements* bloc)
247 {
248    DumpStart ("removeElements", bloc);
249
250    int ier = HOK;
251
252    if (bloc==NULL)
253       ier = HERR;
254    else
255       bloc->remove ();
256
257    DumpReturn (ier);
258    return ier;
259 }
260 // ====================================================== removeConnectedHexa
261 int Document::removeConnectedHexa (Hexa* cell)
262 {
263    DumpStart ("removeConnectedHexa", cell);
264
265    int ier = HOK;
266
267    if (cell==NULL)
268       ier = HERR;
269    else
270       {
271       update ();
272       cell->removeConnected ();
273       }
274
275    DumpReturn (ier);
276    return ier;
277 }
278 // ========================================================= dumpPropagation
279 void Document::dumpPropagation ()
280 {
281    int nb = countPropagation ();
282
283    for (int nro=0 ; nro<nb ; nro++)
284        {
285        Propagation*  prop  = getPropagation (nro);
286        const Edges&  table = prop->getEdges ();
287        printf (" ____________________________________ Prop nro %d\n", nro);
288        for (int ned=0 ; ned<(int)table.size() ; ned++)
289            {
290            bool way = table [ned]->getWay ();
291
292            table [ned]->printName (" = ");
293            if (way)
294               {
295               printf (" +(");
296               table [ned]->getVertex (0)->printName (", ");
297               table [ned]->getVertex (1)->printName (")\n");
298               }
299           else
300               {
301               printf (" -(");
302               table [ned]->getVertex (1)->printName (", ");
303               table [ned]->getVertex (0)->printName (")\n");
304               }
305            }
306        }
307 }
308 // ----------------------------------------------------------------------
309 // ------------ reorderFaces
310 // ----------------------------------------------------------------------
311 // ========================================================= reorderFaces
312 // ==== Ordonner les faces externes
313 void Document::reorderFaces ()
314 {
315    majReferences ();
316    for (EltBase* elt = doc_first_elt[EL_QUAD]->next (); elt!=NULL;
317                  elt = elt->next())
318        {
319        Quad* quad = static_cast <Quad*> (elt);
320        if (quad!=NULL && quad->isHere())
321            quad->setOrientation ();
322        }
323
324 }
325 END_NAMESPACE_HEXA