2 // class : Gestion des aretes
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 "HexVertex.hxx"
29 class Edge : public EltBase
32 virtual int countVertex () { return V_TWO; }
33 virtual Vertex* getVertex (int nro);
34 bool getWay () { return e_way ; }
37 virtual void saveXml (XmlWriter* xml);
38 virtual void replaceVertex (Vertex* old, Vertex* nouveau);
39 virtual void clearAssociation ();
41 Edge (Vertex* va, Vertex* vb);
43 int anaMerge (Vertex* orig, Vertex* couple[]);
44 bool definedBy (Vertex* v1, Vertex* v2);
46 void propager (Propagation* prop, int nro, int sens=1);
48 void setPropag (int nro, bool sens) { e_propag = nro; e_way=sens; }
49 int getPropag () { return e_propag ; }
51 Quad* getParent (int nro);
56 virtual void majReferences();
58 int inter (Edge* other, int& nother);
59 int inter (Edge* other);
60 int index (Vertex* node);
61 Vertex* commonVertex (Edge* other);
62 Vertex* opposedVertex (Vertex* sommet);
63 double* commonPoint (Edge* other, double point[]);
65 Vertex* getAmont () { return e_vertex [NOT e_way] ; }
66 Vertex* getAval () { return e_vertex [e_way] ; }
68 Law* getLaw () { return e_law ; }
69 void setLaw (Law* law) { e_law = law ; }
71 void setScalar (double valeur);
72 void setColor (double valeur) { setScalar (valeur) ; }
74 const Shapes & getAssociations () { return tab_shapes ; }
76 virtual void duplicate ();
77 Edge* getClone () { return e_clone ; }
78 double* getVector (double vecteur[]);
79 string makeDefinition ();
81 virtual int addAssociation (Shape* forme) {return HOK;} // Perime Hexa5
82 virtual void setAssociation (Shape* forme) {} // Perime Hexa5
84 int addAssociation (NewShape* geom, int subid, double deb, double fin);
85 int addAssociation (EdgeShape* gline, double deb, double fin);
86 int checkAssociation ();
87 int countAssociation () { return tab_assoc.size () ; }
88 AssoEdge* getAssociation (int nro);
92 Vertex* e_vertex [V_TWO];
95 bool e_way; // Sens de propagation
96 Law* e_law; // Le soleil brille, brille, brille
102 // ----------------------------------------------- Inlining
103 // =============================================================== getVertex
104 inline Vertex* Edge::getVertex(int nro)
107 if (nro >=0 && nro < V_TWO && el_status == HOK
108 && e_vertex [nro]->isValid())
109 elt = e_vertex [nro];
113 // =============================================================== index
114 inline int Edge::index (Vertex* node)
116 return node == NULL ? NOTHING
117 : node == e_vertex[V_AMONT] ? V_AMONT
118 : node == e_vertex[V_AVAL ] ? V_AVAL : NOTHING;
120 // ============================================================= opposedVertex
121 inline Vertex* Edge::opposedVertex (Vertex* sommet)
123 int nro = index (sommet);
124 return nro<0 ? NULL : e_vertex[1-nro];
126 // ============================================================= commonVertex
127 inline Vertex* Edge::commonVertex (Edge* other)
129 int nro = inter (other);
130 return nro<0 ? NULL : e_vertex[nro];
132 // ============================================================= commonPoint
133 inline double* Edge::commonPoint (Edge* other, double point[])
135 Vertex* commun = commonVertex (other);
138 point[dir_x] = point[dir_y] = point[dir_z] = 0;
142 commun->getPoint (point);
145 // =============================================================== inter
146 inline int Edge::inter (Edge* other)
149 return inter (other, nro);
151 // =============================================================== inter
152 inline int Edge::inter (Edge* other, int& nother)
154 for (int ni=0 ; ni<V_TWO ; ni++)
155 for (int nj=0 ; nj<V_TWO ; nj++)
156 if (e_vertex[ni] == other->e_vertex[nj])
165 // =============================================================== definedBy
166 inline bool Edge::definedBy (Vertex* v1, Vertex* v2)
168 bool rep = (v1 == e_vertex[V_AMONT] && v2 == e_vertex[V_AVAL ])
169 || (v1 == e_vertex[V_AVAL ] && v2 == e_vertex[V_AMONT]);
172 // =============================================================== setScalar
173 inline void Edge::setScalar (double val)
175 e_vertex [V_AMONT]->setScalar (val);
176 e_vertex [V_AVAL ]->setScalar (val);
178 // =============================================================== duplicate
179 inline void Edge::duplicate ()
181 e_clone = new Edge (GetClone (e_vertex [V_AMONT]),
182 GetClone (e_vertex [V_AVAL ]));
184 e_clone->tab_shapes = tab_shapes;
185 e_clone->tab_assoc = tab_assoc;
187 // =============================================================== getVector
188 inline double* Edge::getVector (double vecteur[])
191 if (e_vertex[V_AMONT]==NULL || e_vertex[V_AVAL]==NULL)
193 vecteur [dir_x] = vecteur [dir_y] = vecteur [dir_z] = 0;
197 vecteur[dir_x] = e_vertex[V_AVAL]->getX() - e_vertex[V_AMONT]->getX();
198 vecteur[dir_y] = e_vertex[V_AVAL]->getY() - e_vertex[V_AMONT]->getY();
199 vecteur[dir_z] = e_vertex[V_AVAL]->getZ() - e_vertex[V_AMONT]->getZ();