2 // C++ : Gestion des soous-shapes
4 // Copyright (C) 2009-2013 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 "HexVertexShape.hxx"
24 #include "HexXmlWriter.hxx"
29 #include <TopoDS_Vertex.hxx>
30 #include <BRepTools.hxx>
31 #include <BRep_Builder.hxx>
32 #include <BRepBuilderAPI_MakeVertex.hxx>
37 // static bool db = on_debug (); // == getenv ("HEXA_DB") > 0
39 // ====================================================== Constructeur
40 VertexShape::VertexShape (NewShape* dad, int id)
41 : SubShape (dad, id, 0)
45 ss_coord[dir_x] = ss_coord[dir_y] = ss_coord[dir_z] = 0;
50 // ====================================================== Constructeur bis*
51 VertexShape::VertexShape (NewShape* dad, int id, double* point)
52 : SubShape (dad, id, 0)
57 for (int nc=dir_x ; nc<=dir_z ; ++nc)
58 ss_coord[nc] = point[nc];
60 // ====================================================== updateCoords
61 void VertexShape::updateCoords ()
69 TopoDS_Vertex gver = TopoDS::Vertex (geo_shape);
70 gp_Pnt gpoint = BRep_Tool::Pnt (gver);
72 ss_coord [dir_x] = gpoint.X();
73 ss_coord [dir_y] = gpoint.Y();
74 ss_coord [dir_z] = gpoint.Z();
76 // ====================================================== getCoords
77 void VertexShape::getCoords (double& px, double& py, double& pz)
86 // ====================================================== addAssociation
87 void VertexShape::addAssociation (Vertex* elt)
89 tab_assoc.push_back (elt);
90 is_associated = true ;
92 // ====================================================== getAssociation
93 Vertex* VertexShape::getAssociation (int nro)
95 if (nro>0 && nro<tab_assoc.size())
96 return tab_assoc[nro];
100 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
101 // ====================================================== saveXml
102 void VertexShape::saveXml (XmlWriter* xml)
105 sprintf (coord, "%g %g %g", ss_coord[dir_x], ss_coord[dir_y],
108 xml->openMark ("Vertex");
109 xml->addAttribute ("subid", sub_ident);
110 xml->addAttribute ("coord", coord);