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 "HexDocument.hxx"
29 #include "HexOldShape.hxx"
30 #include "HexNewShape.hxx"
31 #include "HexVertexShape.hxx"
32 #include "HexKas_functions.hxx"
36 static bool db = on_debug (); // == getenv ("HEXA_DB") > 0
38 // ====================================================== Constructeur
39 Vertex::Vertex (Document* doc, double x, double y, double z)
40 : EltBase (doc, EL_VERTEX)
50 // ========================================================= getParent
51 Edge* Vertex::getParent (int nro)
53 return static_cast <Edge*> (getFather (nro));
55 // ========================================================= saveXml
56 void Vertex::saveXml (XmlWriter* xml)
58 char buffer[12], coord[80];
60 sprintf (coord, "%g %g %g", v_x, v_y, v_z);
62 xml->openMark ("Vertex");
63 xml->addAttribute ("id", getName (buffer));
64 xml->addAttribute ("coord", coord);
66 xml->addAttribute ("name", el_name);
71 sprintf (coord, "%g %g %g", gc_x, gc_y, gc_z);
72 v_shape->callXml (xml);
73 xml->addAttribute ("coord", coord);
77 // if (el_assoc!=NULL) xml->addAttribute ("shape", el_assoc->getBrep().c_str());
79 // ========================================================= translate
80 void Vertex::translate (Vector* vecteur, double fact)
82 v_x += fact*vecteur->getDx ();
83 v_y += fact*vecteur->getDy ();
84 v_z += fact*vecteur->getDz ();
86 // ========================================================= createMiddle
87 Vertex* Vertex::createMiddle (Vertex* left, Vertex* right)
89 Vertex* milieu = new Vertex (left);
91 milieu->v_x = (left->v_x + right->v_x) / 2;
92 milieu->v_y = (left->v_y + right->v_y) / 2;
93 milieu->v_z = (left->v_z + right->v_z) / 2;
97 // ========================================================= setAssociation
98 int Vertex::setAssociation (VertexShape* forme)
103 forme->addAssociation (this);
104 forme->getCoords (gc_x, gc_y, gc_z);
107 if (db) cout << " Vertex " << el_name
108 << " setAssociation-> " << forme->getName ()
109 << " = (" << gc_x << ", " << gc_y << ", " << gc_z << ") \n" ;
111 is_associated = true;
114 // ========================================================= setAssociation
115 int Vertex::setAssociation (NewShape* geom, int subid)
120 VertexShape* shape = geom->findVertex (subid);
124 int ier = setAssociation (shape);
127 // ========================================================= setAssociation
128 int Vertex::setAssociation (double* point)
130 NewShape* cloud = el_root->getCloud();
132 int subid = cloud->addPoint (point);
133 int ier = setAssociation (cloud, subid);
136 // ========================================================= setAssociation
137 int Vertex::setAssociation (double px, double py, double pz)
139 Real3 point = { px, py, pz };
140 int ier = setAssociation (point);
143 // ========================================================= clearAssociation
144 void Vertex::clearAssociation ()
147 is_associated = false;
149 // ========================================================= getAssoCoord
150 void Vertex::getAssoCoord (double &px, double &py, double &pz)
165 // ========================================================= getAssoCoord
166 void Vertex::getAssoCoord (double* point)
168 getAssoCoord (point[dir_x], point[dir_y], point[dir_z]);