2 // C++ : La clase principale de Hexa
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/ or email : webmaster.salome@opencascade.com
22 #include "HexDocument.hxx"
24 #include "HexEltBase.hxx"
25 #include "HexVertex.hxx"
26 #include "HexEdge.hxx"
27 #include "HexQuad.hxx"
28 #include "HexHexa.hxx"
30 #include "HexElements.hxx"
31 #include "HexCrossElements.hxx"
33 #include "HexVector.hxx"
34 #include "HexMatrix.hxx"
35 #include "HexCloner.hxx"
36 #include "HexPropagation.hxx"
39 #include "HexXmlWriter.hxx"
40 #include "HexXmlTree.hxx"
41 #include "HexGlobale.hxx"
44 // ========================================================= performTranslation
45 int Document::performTranslation (Elements* elts, Vector* trans)
47 DumpStart ("performTranslation", elts << trans);
50 matrice.defTranslation (trans);
52 int ier = elts->transform (&matrice);
57 // ==================================================== performScale
58 int Document::performScale (Elements* elts, Vertex* ver, double k)
60 DumpStart ("performScale", elts << ver << k);
63 matrice.defScale (ver, k);
65 int ier = elts->transform (&matrice);
70 // ==================================================== performRotation
71 int Document::performRotation (Elements* elts, Vertex* ver, Vector* vec, double angle)
73 DumpStart ("performRotation", elts << ver << vec << angle);
76 matrice.defRotation (ver, vec, angle);
78 int ier = elts->transform (&matrice);
83 // ==================================================== performSymmetryPoint
84 int Document::performSymmetryPoint (Elements* elts, Vertex* ver)
86 DumpStart ("performSymmetryPoint", elts << ver);
89 matrice.defSymmetryPoint (ver);
91 int ier = elts->transform (&matrice);
96 // ==================================================== performSymmetryPlane
97 int Document::performSymmetryPlane (Elements* elts, Vertex* ver, Vector* vec)
99 DumpStart ("performSymmetryPlane", elts << ver << vec);
102 matrice.defSymmetryPlane (ver, vec);
104 int ier = elts->transform (&matrice);
110 // ==================================================== performSymmetryLine
111 int Document::performSymmetryLine (Elements* elts, Vertex* ver, Vector* vec)
113 DumpStart ("performSymmetryLine", elts << ver << vec);
116 matrice.defSymmetryLine (ver, vec);
118 int ier = elts->transform (&matrice);
123 // --------------------------------------------------------
124 // --------------------------------------------------------
125 // --------------------------------------------------------
126 // ========================================================= clonerElements
127 Elements* Document::clonerElements (Elements* table, Matrix* matrice)
129 Cloner copieur (matrice);
130 Elements* grille = copieur.clonerElements (table);
133 // --------------------------------------------------------
134 // --------------------------------------------------------
135 // --------------------------------------------------------
136 // ========================================================= makeTranslation
137 Elements* Document::makeTranslation (Elements* table, Vector* trans)
139 DumpStart ("makeTranslation", table << trans);
142 matrice.defTranslation (trans);
144 Elements* grille = clonerElements (table, &matrice);
149 // ========================================================= makeScale
150 Elements* Document::makeScale (Elements* table, Vertex* ver, double k)
152 DumpStart ("makeScale", table << ver << k);
155 matrice.defScale (ver, k);
157 Elements* grille = clonerElements (table, &matrice);
162 // ========================================================= makeRotation
163 Elements* Document::makeRotation (Elements* table, Vertex* ver, Vector* vec,
166 DumpStart ("makeRotation", table << ver << vec << angle);
169 matrice.defRotation (ver, vec, angle);
171 Elements* grille = clonerElements (table, &matrice);
176 // ========================================================= makeSymmetryPoint
177 Elements* Document::makeSymmetryPoint (Elements* table, Vertex* ver)
179 DumpStart ("makeSymmetryPoint", table << ver);
182 matrice.defSymmetryPoint (ver);
184 Elements* grille = clonerElements (table, &matrice);
189 // ========================================================= makeSymmetryLine
190 Elements* Document::makeSymmetryLine (Elements* table, Vertex* ver, Vector* vec)
192 DumpStart ("makeSymmetryLine", table << ver << vec);
195 matrice.defSymmetryLine (ver, vec);
197 Elements* grille = clonerElements (table, &matrice);
202 // ========================================================= makeSymmetryPlane
203 Elements* Document::makeSymmetryPlane (Elements* table, Vertex* ver, Vector* vec)
205 DumpStart ("makeSymmetryPlane", table << ver << vec);
208 matrice.defSymmetryPlane (ver, vec);
210 Elements* grille = clonerElements (table, &matrice);
215 // ----------------------------------------------------------------------
216 // ------------ Destroy
217 // ----------------------------------------------------------------------
218 // ========================================================= removeHexa
219 int Document::removeHexa (Hexa* cell)
221 DumpStart ("removeHexa", cell);
232 // ========================================================= removeQuad
233 int Document::removeQuad (Quad* cell)
235 DumpStart ("removeQuad", cell);
246 // ========================================================= removeElements
247 int Document::removeElements (Elements* bloc)
249 DumpStart ("removeElements", bloc);
261 // ====================================================== removeConnectedHexa
262 int Document::removeConnectedHexa (Hexa* cell)
264 DumpStart ("removeConnectedHexa", cell);
273 cell->removeConnected ();
279 // ========================================================= dumpPropagation
280 void Document::dumpPropagation ()
282 int nb = countPropagation ();
284 for (int nro=0 ; nro<nb ; nro++)
286 Propagation* prop = getPropagation (nro);
287 const Edges& table = prop->getEdges ();
288 printf (" ____________________________________ Prop nro %d\n", nro);
289 for (int ned=0 ; ned<(int)table.size() ; ned++)
291 bool way = table [ned]->getWay ();
293 table [ned]->printName (" = ");
297 table [ned]->getVertex (0)->printName (", ");
298 table [ned]->getVertex (1)->printName (")\n");
303 table [ned]->getVertex (1)->printName (", ");
304 table [ned]->getVertex (0)->printName (")\n");
309 // ----------------------------------------------------------------------
310 // ------------ reorderFaces
311 // ----------------------------------------------------------------------
312 // ========================================================= reorderFaces
313 // ==== Ordonner les faces externes
314 void Document::reorderFaces ()
317 for (EltBase* elt = doc_first_elt[EL_QUAD]->next (); elt!=NULL;
320 Quad* quad = static_cast <Quad*> (elt);
321 if (quad!=NULL && quad->isHere())
322 quad->setOrientation ();