2 // class : Les hexaedres
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
23 /* -----------------------------------------------------
25 // ---- Numerotation des faces (%x)
27 6=bed +----bd-----+ bdf=7
31 4=bce +----bc-----+...|...bcf=5
35 2=ade...|...+----ad-|---+ adf=3 | y
39 0=ace +----ac-----+ acf=1 +-----> x
41 * ----------------------------------------------------- */
45 #include "HexEltBase.hxx"
47 #include "HexQuad.hxx"
48 #include "HexEdge.hxx"
49 #include "HexVertex.hxx"
53 class Hexa : public EltBase
56 virtual Quad* getQuad (int nro);
57 virtual Edge* getEdge (int nro);
58 virtual Vertex* getVertex (int nro);
60 virtual int countQuad () { return HQ_MAXI; }
61 virtual int countEdge () { return HE_MAXI; }
62 virtual int countVertex () { return HV_MAXI; }
65 Hexa (Vertex* v1, Vertex* v2, Vertex* v3, Vertex* v4,
66 Vertex* v5, Vertex* v6, Vertex* v7, Vertex* v8);
67 Hexa (Quad* qa, Quad* qb, Quad* qc, Quad* qd, Quad* qe, Quad* qf);
69 Quad* Inter (Hexa* other);
70 bool definedBy (Vertex* v1, Vertex* v2);
71 bool definedBy (Quad* va, Quad* v2);
73 virtual void dumpPlus ();
74 virtual void dumpFull ();
77 int countNodes (); // Compte et numerote les noeuds
78 void printNodes (pfile vtk, int& count); // Impression format vtk
79 void colorNodes (pfile vtk); // Impression scalaires vtk
80 void moveNodes (Matrix* matrice); // transfo controlee ds un ensemble
81 void transform (Matrix* matrice); // transfo indivituelle
82 void printHexa (pfile vtk); // Impression de la cellule
83 void printHexaVtk (pfile vtk); // Impression de la cellule
84 virtual void majReferences(); // M.A.J relation "utilise par"
87 void propager (Propagation* prop, int nro);
88 void setScalar (double valeur);
89 void setColor (double valeur) { setScalar (valeur) ; }
91 virtual void saveXml (XmlWriter* xml);
93 Elements* disconnectQuad (Quad* face);
94 Elements* disconnectEdge (Edge* arete);
95 Elements* disconnectVertex (Vertex* noeud);
97 int getBase (Vertex* orig, Edge* normale);
99 void replaceQuad (Quad* old, Quad* nouveau);
100 void replaceEdge (Edge* old, Edge* nouveau);
101 void replaceVertex (Vertex* old, Vertex* nouveau);
102 void removeConnected ();
103 void markElements (int marque);
104 double* getCenter (double centre[]);
106 virtual void duplicate ();
107 Hexa* getClone () { return h_clone ; }
108 Quad* getOpposedQuad (Quad* face);
109 Vertex* getOpposedVertex (Quad* face, Vertex* vertex);
110 Edge* getPerpendicularEdge (Quad* face, Vertex* vertex);
111 Edge* getParallelEdge (Quad* face, Edge* edge);
112 Quad* findQuad (Edge* e1, Edge* e2);
113 Edge* findEdge (Vertex* v1, Vertex* v2);
115 int findQuad (Quad* element);
116 int findEdge (Edge* element);
117 int findVertex (Vertex* element);
122 void OrdonnerAretes (); // obsolete ?
123 void OrdonnerSommets (); // obsolete ?
125 void controlerFaces (); // Controle primaire des donnees utilisateur
126 void controlerSommets (); // Idem;
128 void verifierSommets (); // Controle de coherence des quads
129 void verifierAretes (); // Idem
131 void controlerArete (int arete, int face1, int face2);
132 void controlerSommet (int node, int arete1, int arete2, int arete3);
134 int findOpposedQuad (Quad* face, Edge* arete);
137 Quad* h_quad [HQ_MAXI];
138 Edge* h_edge [HE_MAXI];
139 Vertex* h_vertex [HV_MAXI];
142 // ------------------------------------------------------------ inlining
143 // ============================================================ getQuad
144 inline Quad* Hexa::getQuad (int nro)
147 if (nro >=0 && nro < HQ_MAXI && el_status == HOK && h_quad [nro]->isValid())
152 // ============================================================ getEdge
153 inline Edge* Hexa::getEdge (int nro)
156 if (nro >=0 && nro < HE_MAXI && el_status == HOK && h_edge [nro]->isValid())
161 // ============================================================ getVertex
162 inline Vertex* Hexa::getVertex (int nro)
165 if (nro >=0 && nro < HV_MAXI && el_status == HOK && h_vertex [nro]->isValid())
166 elt = h_vertex [nro];
170 // ============================================================ getCenter
171 inline double* Hexa::getCenter (double centre[])
173 centre [dir_x] = centre [dir_y] = centre [dir_z] = 0;
175 for (int nv=0 ; nv<HV_MAXI ; nv++)
177 centre [dir_x] += h_vertex[nv]->getX ();
178 centre [dir_y] += h_vertex[nv]->getY ();
179 centre [dir_z] += h_vertex[nv]->getZ ();
182 centre [dir_x] /= HV_MAXI;
183 centre [dir_y] /= HV_MAXI;
184 centre [dir_z] /= HV_MAXI;
187 // =============================================================== definedBy
188 inline bool Hexa::definedBy (Vertex* v1, Vertex* v2)
190 for (int n1=0 ; n1< HV_MAXI ; n1++)
192 // ( Diagonale ) Dessus
193 int n2 = (n1 + 2) MODULO HV_MAXI + HV_MAXI;
194 if ( (v1 == h_vertex[n1] && v2 == h_vertex[n2])
195 || (v1 == h_vertex[n2] && v2 == h_vertex[n1])) return true;
199 // =============================================================== definedBy
200 inline bool Hexa::definedBy (Quad* qa, Quad* qb)
202 for (int nc=0 ; nc< 3 ; nc++)
204 if ( (qa == h_quad[2*nc] && qb == h_quad[2*nc+1])
205 || (qa == h_quad[2*nc+1] && qb == h_quad[2*nc])) return true;
209 // =============================================================== setScalar
210 inline void Hexa::setScalar (double val)
212 for (int nc=0 ; nc< HV_MAXI ; nc++)
213 h_vertex[nc] -> setScalar (val);
215 // ============================================================== markElements
216 inline void Hexa::markElements (int marque)
218 for (int nc=0 ; nc< HQ_MAXI ; nc++) h_quad [nc] -> setMark (marque);
219 for (int nc=0 ; nc< HE_MAXI ; nc++) h_edge [nc] -> setMark (marque);
220 for (int nc=0 ; nc< HV_MAXI ; nc++) h_vertex[nc] -> setMark (marque);
222 // =============================================================== duplicate
223 inline void Hexa::duplicate ()
225 h_clone = new Hexa (GetClone (h_quad [Q_A]),
226 GetClone (h_quad [Q_B]),
227 GetClone (h_quad [Q_C]),
228 GetClone (h_quad [Q_D]),
229 GetClone (h_quad [Q_E]),
230 GetClone (h_quad [Q_F]));