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
23 #include "HexVertex.hxx"
24 #include "HexEdge.hxx"
25 #include "HexVector.hxx"
27 #include "HexXmlWriter.hxx"
28 #include "HexShape.hxx"
32 // ====================================================== Constructeur
33 Vertex::Vertex (Document* doc, double x, double y, double z)
34 : EltBase (doc, EL_VERTEX)
43 // ========================================================= getParent
44 Edge* Vertex::getParent (int nro)
46 return static_cast <Edge*> (getFather (nro));
48 // ========================================================= saveXml
49 void Vertex::saveXml (XmlWriter* xml)
51 char buffer[12], coord[80];
53 sprintf (coord, "%g %g %g", v_x,v_y,v_z);
55 xml->openMark ("Vertex");
56 xml->addAttribute ("id", getName (buffer));
57 xml->addAttribute ("coord", coord);
59 xml->addAttribute ("name", el_name);
61 xml->addAttribute ("shape", el_assoc->getBrep().c_str());
64 // ========================================================= translate
65 void Vertex::translate (Vector* vecteur, double fact)
67 v_x += fact*vecteur->getDx ();
68 v_y += fact*vecteur->getDy ();
69 v_z += fact*vecteur->getDz ();
71 // ========================================================= createMiddle
72 Vertex* Vertex::createMiddle (Vertex* left, Vertex* right)
74 Vertex* milieu = new Vertex (left);
76 milieu->v_x = (left->v_x + right->v_x) / 2;
77 milieu->v_y = (left->v_y + right->v_y) / 2;
78 milieu->v_z = (left->v_z + right->v_z) / 2;