2 // C++ : La clase principale de Hexa
4 // Copyright (C) 2009-2012 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 "HexCylinder.hxx"
35 #include "HexPipe.hxx"
36 #include "HexMatrix.hxx"
37 #include "HexCloner.hxx"
38 #include "HexPropagation.hxx"
41 #include "HexXmlWriter.hxx"
42 #include "HexXmlTree.hxx"
43 #include "HexGlobale.hxx"
46 // ========================================================= performTranslation
47 int Document::performTranslation (Elements* elts, Vector* trans)
50 matrice.defTranslation (trans);
52 int ier = elts->transform (&matrice);
55 // ==================================================== performScale
56 int Document::performScale (Elements* elts, Vertex* ver, double k)
59 matrice.defScale (ver, k);
61 int ier = elts->transform (&matrice);
64 // ==================================================== performRotation
65 int Document::performRotation (Elements* elts, Vertex* ver, Vector* vec, double angle)
68 matrice.defRotation (ver, vec, angle);
70 int ier = elts->transform (&matrice);
73 // ==================================================== performSymmetryPoint
74 int Document::performSymmetryPoint (Elements* elts, Vertex* ver)
77 matrice.defSymmetryPoint (ver);
79 int ier = elts->transform (&matrice);
82 // ==================================================== performSymmetryPlane
83 int Document::performSymmetryPlane (Elements* elts, Vertex* ver, Vector* vec)
86 matrice.defSymmetryPlane (ver, vec);
88 int ier = elts->transform (&matrice);
91 // ==================================================== performSymmetryLine
92 int Document::performSymmetryLine (Elements* elts, Vertex* ver, Vector* vec)
95 matrice.defSymmetryLine (ver, vec);
97 int ier = elts->transform (&matrice);
100 // --------------------------------------------------------
101 // --------------------------------------------------------
102 // --------------------------------------------------------
103 // ========================================================= clonerElements
104 Elements* Document::clonerElements (Elements* table, Matrix* matrice)
106 Cloner copieur (matrice);
107 Elements* grille = copieur.clonerElements (table);
110 // --------------------------------------------------------
111 // --------------------------------------------------------
112 // --------------------------------------------------------
113 // ========================================================= makeTranslation
114 Elements* Document::makeTranslation (Elements* table, Vector* trans)
117 matrice.defTranslation (trans);
119 Elements* grille = clonerElements (table, &matrice);
122 // ========================================================= makeScale
123 Elements* Document::makeScale (Elements* table, Vertex* ver, double k)
126 matrice.defScale (ver, k);
128 Elements* grille = clonerElements (table, &matrice);
131 // ========================================================= makeRotation
132 Elements* Document::makeRotation (Elements* table, Vertex* ver, Vector* vec,
136 matrice.defRotation (ver, vec, angle);
138 Elements* grille = clonerElements (table, &matrice);
141 // ========================================================= makeSymmetryPoint
142 Elements* Document::makeSymmetryPoint (Elements* table, Vertex* ver)
145 matrice.defSymmetryPoint (ver);
147 Elements* grille = clonerElements (table, &matrice);
150 // ========================================================= makeSymmetryLine
151 Elements* Document::makeSymmetryLine (Elements* table, Vertex* ver, Vector* vec)
154 matrice.defSymmetryLine (ver, vec);
156 Elements* grille = clonerElements (table, &matrice);
159 // ========================================================= makeSymmetryPlane
160 Elements* Document::makeSymmetryPlane (Elements* table, Vertex* ver, Vector* vec)
163 matrice.defSymmetryPlane (ver, vec);
165 Elements* grille = clonerElements (table, &matrice);
168 // ----------------------------------------------------------------------
169 // ------------ Destroy
170 // ----------------------------------------------------------------------
171 // ========================================================= removeHexa
172 int Document::removeHexa (Hexa* cell)
180 // ========================================================= removeQuad
181 int Document::removeQuad (Quad* cell)
189 // ========================================================= removeElements
190 int Document::removeElements (Elements* bloc)
198 // ====================================================== removeConnectedHexa
199 int Document::removeConnectedHexa (Hexa* cell)
205 cell->removeConnected ();
208 // ========================================================= dumpPropagation
209 void Document::dumpPropagation ()
211 int nb = countPropagation ();
213 for (int nro=0 ; nro<nb ; nro++)
215 Propagation* prop = getPropagation (nro);
216 const Edges& table = prop->getEdges ();
217 printf (" ____________________________________ Prop nro %d\n", nro);
218 for (int ned=0 ; ned<(int)table.size() ; ned++)
220 bool way = table [ned]->getWay ();
222 table [ned]->printName (" = ");
226 table [ned]->getVertex (0)->printName (", ");
227 table [ned]->getVertex (1)->printName (")\n");
232 table [ned]->getVertex (1)->printName (", ");
233 table [ned]->getVertex (0)->printName (")\n");
238 // ----------------------------------------------------------------------
239 // ------------ reorderFaces
240 // ----------------------------------------------------------------------
241 // ========================================================= reorderFaces
242 // ==== Ordonner les faces externes
243 void Document::reorderFaces ()
246 Real3 cg, orig, pi, pj, vi, vj, vk;
248 for (EltBase* elt = doc_first_elt[EL_QUAD]->next (); elt!=NULL;
251 Quad* quad = static_cast <Quad*> (elt);
252 if (quad!=NULL && quad->isHere())
253 quad->setOrientation ();