Salome HOME
Merge from V6_main 01/04/2013
[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 #include "HexCrossElements.hxx"
32
33 #include "HexVector.hxx"
34 #include "HexCylinder.hxx"
35 #include "HexPipe.hxx"
36 #include "HexMatrix.hxx"
37 #include "HexCloner.hxx"
38 #include "HexPropagation.hxx"
39 #include "HexLaw.hxx"
40
41 #include "HexXmlWriter.hxx"
42 #include "HexXmlTree.hxx"
43 #include "HexGlobale.hxx"
44
45 BEGIN_NAMESPACE_HEXA
46 // ========================================================= performTranslation
47 int Document::performTranslation (Elements* elts, Vector* trans)
48
49    Matrix matrice;
50    matrice.defTranslation (trans);
51
52    int    ier = elts->transform (&matrice);
53    return ier;
54 }
55 // ==================================================== performScale
56 int Document::performScale (Elements* elts, Vertex* ver, double k)
57
58    Matrix matrice;
59    matrice.defScale (ver, k);
60
61    int    ier = elts->transform (&matrice);
62    return ier;
63 }
64 // ==================================================== performRotation
65 int Document::performRotation (Elements* elts, Vertex* ver, Vector* vec, double angle)
66
67    Matrix matrice;
68    matrice.defRotation (ver, vec, angle);
69
70    int    ier = elts->transform (&matrice);
71    return ier;
72 }
73 // ==================================================== performSymmetryPoint
74 int Document::performSymmetryPoint (Elements* elts, Vertex* ver)
75
76    Matrix matrice;
77    matrice.defSymmetryPoint (ver);
78
79    int    ier = elts->transform (&matrice);
80    return ier;
81 }
82 // ==================================================== performSymmetryPlane
83 int Document::performSymmetryPlane (Elements* elts, Vertex* ver, Vector* vec)    
84
85    Matrix matrice;
86    matrice.defSymmetryPlane (ver, vec);
87
88    int    ier = elts->transform (&matrice);
89    return ier;
90 }
91
92 // ==================================================== performSymmetryLine
93 int Document::performSymmetryLine (Elements* elts, Vertex* ver, Vector* vec)
94
95    Matrix matrice;
96    matrice.defSymmetryLine (ver, vec);
97
98    int    ier = elts->transform (&matrice);
99    return ier;
100 }
101 // -------------------------------------------------------- 
102 // -------------------------------------------------------- 
103 // -------------------------------------------------------- 
104 // ========================================================= clonerElements
105 Elements* Document::clonerElements (Elements* table, Matrix* matrice)
106 {
107    Cloner    copieur (matrice);
108    Elements* grille = copieur.clonerElements (table);
109    return    grille;
110 }
111 // -------------------------------------------------------- 
112 // -------------------------------------------------------- 
113 // -------------------------------------------------------- 
114 // ========================================================= makeTranslation
115 Elements* Document::makeTranslation (Elements* table, Vector* trans)
116 {
117    Matrix  matrice;
118    matrice.defTranslation (trans);
119
120    Elements* grille = clonerElements (table, &matrice);
121    return    grille;
122 }
123 // ========================================================= makeScale
124 Elements* Document::makeScale (Elements* table, Vertex* ver, double k)
125 {
126    Matrix  matrice;
127    matrice.defScale (ver, k);
128
129    Elements* grille = clonerElements (table, &matrice);
130    return    grille;
131 }
132 // ========================================================= makeRotation
133 Elements* Document::makeRotation (Elements* table, Vertex* ver, Vector* vec, 
134                                 double angle)
135 {
136    Matrix  matrice;
137    matrice.defRotation (ver, vec, angle);
138
139    Elements* grille = clonerElements (table, &matrice);
140    return    grille;
141 }
142 // ========================================================= makeSymmetryPoint
143 Elements* Document::makeSymmetryPoint (Elements* table, Vertex* ver)
144 {
145    Matrix  matrice;
146    matrice.defSymmetryPoint (ver);
147
148    Elements* grille = clonerElements (table, &matrice);
149    return    grille;
150 }
151 // ========================================================= makeSymmetryLine
152 Elements* Document::makeSymmetryLine (Elements* table, Vertex* ver, Vector* vec)
153 {
154    Matrix  matrice;
155    matrice.defSymmetryLine (ver, vec);
156
157    Elements* grille = clonerElements (table, &matrice);
158    return    grille;
159 }
160 // ========================================================= makeSymmetryPlane
161 Elements* Document::makeSymmetryPlane (Elements* table, Vertex* ver, Vector* vec)
162 {
163    Matrix  matrice;
164    matrice.defSymmetryPlane (ver, vec);
165
166    Elements* grille = clonerElements (table, &matrice);
167    return    grille;
168 }
169 // ----------------------------------------------------------------------
170 // ------------ Destroy
171 // ----------------------------------------------------------------------
172 // ========================================================= removeHexa
173 int Document::removeHexa (Hexa* cell)
174 {
175    if (cell==NULL)
176       return HERR;
177
178    cell->remove ();
179    return  HOK;
180 }
181 // ========================================================= removeQuad
182 int Document::removeQuad (Quad* cell)
183 {
184    if (cell==NULL)
185       return HERR;
186
187    cell->remove ();
188    return  HOK;
189 }
190 // ========================================================= removeElements
191 int Document::removeElements (Elements* bloc)
192 {
193    if (bloc==NULL)
194       return HERR;
195
196    bloc->remove ();
197    return  HOK;
198 }
199 // ====================================================== removeConnectedHexa
200 int Document::removeConnectedHexa (Hexa* cell)
201 {
202    if (cell==NULL)
203       return HERR;
204
205    update ();
206    cell->removeConnected ();
207    return  HOK;
208 }
209 // ========================================================= dumpPropagation
210 void Document::dumpPropagation ()
211 {
212    int nb = countPropagation ();
213
214    for (int nro=0 ; nro<nb ; nro++)
215        {
216        Propagation*  prop  = getPropagation (nro);
217        const Edges&  table = prop->getEdges ();
218        printf (" ____________________________________ Prop nro %d\n", nro);
219        for (int ned=0 ; ned<(int)table.size() ; ned++)
220            {
221            bool way = table [ned]->getWay ();
222
223            table [ned]->printName (" = ");
224            if (way)
225               {
226               printf (" +(");
227               table [ned]->getVertex (0)->printName (", ");
228               table [ned]->getVertex (1)->printName (")\n");
229               }
230           else
231               {
232               printf (" -(");
233               table [ned]->getVertex (1)->printName (", ");
234               table [ned]->getVertex (0)->printName (")\n");
235               }
236            }
237        }
238 }
239 // ----------------------------------------------------------------------
240 // ------------ reorderFaces
241 // ----------------------------------------------------------------------
242 // ========================================================= reorderFaces
243 // ==== Ordonner les faces externes
244 void Document::reorderFaces ()
245 {
246    majReferences ();
247    for (EltBase* elt = doc_first_elt[EL_QUAD]->next (); elt!=NULL;
248                  elt = elt->next())
249        {
250        Quad* quad = static_cast <Quad*> (elt);
251        if (quad!=NULL && quad->isHere())
252            quad->setOrientation ();
253        }
254
255 }
256 END_NAMESPACE_HEXA