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/
21 // or email : webmaster.salome@opencascade.com
24 #include "HexVertexShape.hxx"
25 #include "HexNewShape.hxx"
26 #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 // ====================================================== getShape
87 const TopoDS_Shape& VertexShape::getShape()
89 if (geo_shape.IsNull() && ss_parent != NULL &&
90 ss_parent->getOrigin() == SH_CLOUD)
95 geo_shape = BRepBuilderAPI_MakeVertex(pnt);
98 return SubShape::getShape ();
100 // ====================================================== addAssociation
101 void VertexShape::addAssociation (Vertex* elt)
103 tab_assoc.push_back (elt);
104 is_associated = true ;
106 // ====================================================== getAssociation
107 Vertex* VertexShape::getAssociation (int nro)
109 if (nro>0 && nro < (int)tab_assoc.size())
110 return tab_assoc[nro];
114 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
115 // ====================================================== saveXml
116 void VertexShape::saveXml (XmlWriter* xml)
119 sprintf (coord, "%g %g %g", ss_coord[dir_x], ss_coord[dir_y],
122 xml->openMark ("Vertex");
123 xml->addAttribute ("subid", sub_ident);
124 xml->addAttribute ("coord", coord);