2 // class : Les Quadrangles
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
25 #include "HexEdge.hxx"
31 Vertex* v11; // 1er sommet 1er quad
33 Vertex* v21; // 1er sommet 2eme quad
35 int dir; // direction element suivant
37 StrOrient ( Vertex* n11, Vertex* n12, Vertex* n21, Vertex* n22, int d=0)
38 : v11 (n11), v12 (n12), v21 (n21), v22 (n22), dir (d) {}
40 StrOrient ( StrOrient* s)
41 : v11 (s->v11), v12(s->v12), v21(s->v21), v22(s->v22), dir(s->dir){}
45 class Quad : public EltBase
48 virtual Edge* getEdge (int nro);
49 virtual Vertex* getVertex (int nro);
51 virtual int countEdge () { return QUAD4; }
52 virtual int countVertex () { return QUAD4; }
55 Quad (Vertex* va, Vertex* vb, Vertex* vc, Vertex* vd);
56 Quad (Edge* ea, Edge* eb, Edge* ec, Edge* ed);
59 Hexa* getParent (int nro);
61 Edge* findEdge (Vertex* v1, Vertex*v2);
62 Edge* commonEdge (Quad* other);
63 int anaMerge (Vertex* v1, Vertex* v2, Vertex* tv[], Edge* te[]);
65 int ordoVertex (Vertex* v1, Vertex* v2, Vertex* tv[]);
66 int prepaMerge (Vertex* tv1[], Vertex* tv2[], Edge* te1[]);
68 int inter (Quad* other, int& nro);
69 bool definedBy (Vertex* v1, Vertex* v2);
70 bool definedBy (Edge* e1, Edge* e2);
72 int indexVertex (Vertex* elt);
73 int indexEdge (Edge* elt);
75 int accoupler (Quad* other, StrOrient* orient);
76 int coupler (Quad* other, StrOrient* orient, Elements* table);
78 Edge* getOpposEdge (Edge* arete, int &sens);
79 Vertex* getOpposVertex (Vertex* sommet);
81 virtual void majReferences(); // M.A.J relation "utilise par"
83 virtual void dumpPlus ();
84 virtual void saveXml (XmlWriter* xml);
85 void setScalar (double valeur);
86 void setColor (double valeur) { setScalar (valeur) ; }
88 void replace (Quad* old);
89 virtual void replaceEdge (Edge* old, Edge* nouveau);
90 virtual void replaceVertex (Vertex* old, Vertex* nouveau);
92 virtual void setAssociation (Shape* forme) {} // PERIME
93 virtual int addAssociation (Shape* forme) {return HOK ; } // PERIME
95 virtual void clearAssociation ();
97 // const Shapes& getAssociations () { return tab_shapes ; }
100 virtual void duplicate ();
101 Quad* getClone () { return q_clone ; }
103 Edge* getOpposEdge (Edge* arete); // Version simplifiee
104 Edge* getPerpendicular (Edge* arete, Vertex* node);
105 int getOrientation () { return q_orientation; }
106 int setOrientation ();
107 void setOrientation (int ori);
109 int addAssociation (NewShape* forme, int subid);
110 int addAssociation (FaceShape* forme);
111 int countAssociation () { return tab_assoc.size () ; }
112 FaceShape* getAssociation (int nro);
116 Quad* getBrother (StrOrient* orient);
119 Edge* q_edge [QUAD4];
120 Vertex* q_vertex [QUAD4];
124 FaceShapes tab_assoc;
126 // ----------------------------------------------- Inlining
127 // ======================================================== commonEdge
128 inline Edge* Quad::commonEdge (Quad* other)
130 for (int ne1=0 ; ne1<QUAD4 ; ne1++)
131 for (int ne2=0 ; ne2<QUAD4 ; ne2++)
132 if (q_edge [ne1] == other->q_edge [ne2])
138 // ======================================================== Inter
139 inline int Quad::inter (Quad* other, int& nother)
141 for (int ne1=0 ; ne1<QUAD4 ; ne1++)
142 for (int ne2=0 ; ne2<QUAD4 ; ne2++)
143 if (q_edge [ne1] == other->q_edge [ne2])
152 // ============================================================ definedBy (v)
153 inline bool Quad::definedBy (Vertex* v1, Vertex* v2)
155 for (int n1=0 ; n1< QUAD4 ; n1++)
156 if (v1 == q_vertex[n1] && v2 == q_vertex[(n1+2) MODULO QUAD4])
161 // ============================================================ definedBy (e)
162 inline bool Quad::definedBy (Edge* e1, Edge* e2)
164 for (int n1=0 ; n1< QUAD4 ; n1++)
165 if (e1 == q_edge[n1] && e2 == q_edge[(n1+2) MODULO QUAD4])
170 // =============================================================== findEdge
171 inline Edge* Quad::findEdge (Vertex* v1, Vertex* v2)
173 for (int nro=0 ; nro< QUAD4 ; nro++)
175 Vertex* va = q_edge[nro]->getVertex(V_AMONT) ;
176 Vertex* vb = q_edge[nro]->getVertex(V_AVAL) ;
177 if ((v1==va && v2==vb) || (v1==vb && v2==va))
183 // =============================================================== indexVertex
184 inline int Quad::indexVertex (Vertex* elt)
186 for (int n1=0 ; n1< QUAD4 ; n1++)
187 if (elt == q_vertex[n1])
192 // =============================================================== indexEdge
193 inline int Quad::indexEdge (Edge* elt)
195 for (int n1=0 ; n1< QUAD4 ; n1++)
196 if (elt == q_edge[n1])
201 // =============================================================== setScalar
202 inline void Quad::setScalar (double val)
204 for (int n1=0 ; n1< QUAD4 ; n1++)
205 q_vertex[n1] -> setScalar (val);
207 // =============================================================== duplicate
208 inline void Quad::duplicate ()
210 q_orientation = Q_UNDEFINED;
211 q_clone = new Quad (GetClone (q_edge [E_A]),
212 GetClone (q_edge [E_B]),
213 GetClone (q_edge [E_C]),
214 GetClone (q_edge [E_D]));
215 q_clone->tab_assoc = tab_assoc;