2 // Class : Gestion des sommets
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
26 #include "HexEltBase.hxx"
30 class Vertex : public EltBase
33 double getX() { return v_x; }
34 double getY() { return v_y; }
35 double getZ() { return v_z; }
36 double getCoord (int dir);
38 virtual int countVertex () { return 1; }
39 virtual Vertex* getVertex (int nro) { return this; }
42 void setX (double v) { v_x = v ; }
43 void setY (double v) { v_y = v ; }
44 void setZ (double v) { v_z = v ; }
46 virtual void setAssociation (Shape* forme) {} // PERIME
48 int setAssociation (NewShape* geom, int subid);
49 int setAssociation (VertexShape* forme);
50 int setAssociation (double* point);
51 int setAssociation (double px, double py, double pz);
52 void clearAssociation ();
54 VertexShape* getAssoVertex () { return v_shape ;}
55 VertexShape* getAssociation () { return v_shape ;}
57 void getAssoCoord (double &x, double &y, double &z);
58 void getAssoCoord (double* point);
60 double getAssoX () { return is_associated ? gc_x : v_x ; }
61 double getAssoY () { return is_associated ? gc_y : v_y ; }
62 double getAssoZ () { return is_associated ? gc_z : v_z ; }
65 Vertex (Document* prev, double x=0.0, double y=0.0, double z=0.0);
66 Vertex (Document* cible, Vertex* other);
67 Vertex (Vertex* other);
69 virtual void dump () ;
70 virtual void saveXml (XmlWriter* xml);
72 void setScalar (double val) { v_scalar = val ; }
73 double getScalar () { return v_scalar ; }
74 void setColor (double valeur) { setScalar (valeur) ; }
75 double* getPoint (double point[]);
77 void setCoord (double x, double y, double z);
78 void setCoord (double point[]) { setCoord (point[0], point[1], point[2]); }
80 bool isin (double xmin, double xmax, double ymin, double ymax,
81 double zmin, double zmax);
82 Edge* getParent (int nro);
83 Vertex* makeSymetric (Vertex* other);
84 void translate (Vector* vecteur, double fact=1.0);
85 void replace (Vertex* old);
87 Vertex* getClone () { return v_clone ; }
88 void duplicate (Document* doc);
90 static Vertex* createMiddle (Vertex* left, Vertex* right);
91 bool definedBy (double px, double py, double pz, double eps2=1e-4);
100 double gc_x, gc_y, gc_z;
101 VertexShape* v_shape;
103 // ========================================================= Constructeur bis
104 inline Vertex::Vertex (Vertex* other)
105 : EltBase (other->dad(), EL_VERTEX)
112 v_scalar = other->v_scalar;
120 gc_x = gc_y = gc_z = 0;
124 // ===================================================== getCoord
125 inline double Vertex::getCoord (int dir)
130 case dir_x : val = v_x;
132 case dir_y : val = v_y;
134 case dir_z : val = v_z;
139 // ========================================================= dump
140 inline void Vertex::dump ()
145 printf ("(*** deleted ***)\n");
149 printf ("(%g, %g, %g)", v_x,v_y,v_z);
152 // ========================================================= setCoord
153 inline void Vertex::setCoord (double x, double y, double z)
159 // ========================================================= isin
160 inline bool Vertex::isin (double xmin, double xmax, double ymin, double ymax,
161 double zmin, double zmax)
163 bool rep = v_x >= xmin && v_x <= xmax
164 && v_y >= ymin && v_y <= ymax
165 && v_z >= zmin && v_z <= zmax;
168 // ========================================================= getPoint
169 inline double* Vertex::getPoint (double point[])
176 // ========================================================= duplicate
177 inline void Vertex::duplicate (Document* cible)
179 v_clone = new Vertex (cible, v_x, v_y, v_z);
180 v_clone->v_scalar = v_scalar;
182 // ========================================================= duplicate
183 inline bool Vertex::definedBy (double px, double py, double pz, double eps2)
185 double dist2 = carre (v_x-px) + carre (v_y-py) + carre (v_z-pz);