2 // CC++ : Fonctions Interface Cascade
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 "HexKas_functions.hxx"
25 // #include "HexEdge.hxx"
28 #include <TopoDS_Shape.hxx>
29 #include <TopoDS_Vertex.hxx>
31 #include <BRep_Builder.hxx>
32 #include <BRepTools.hxx>
40 // ====================================================== same_coords
41 bool same_coords (gp_Pnt& pa, gp_Pnt& pb, double epsilon)
43 double d2 = carre (pb.X()-pa.X()) + carre (pb.Y()-pa.Y())
44 + carre (pb.Z()-pa.Z()) ;
47 // ====================================================== save_brep
48 void save_brep (cpchar nom, string brep, int& compteur)
52 sprintf (buff ,"%d", compteur);
57 FILE* fic = fopen (name.c_str(), "w");
58 fprintf (fic, "%s\n", brep.c_str());
61 // ====================================================== geom_make_brep
62 void geom_make_brep (TopoDS_Shape& shape, string& brep)
64 ostringstream stream_shape;
65 BRepTools::Write (shape, stream_shape);
66 brep = stream_shape.str();
68 // ====================================================== geom_brep2shape (F)
69 TopoDS_Shape geom_brep2shape (rcstring brep)
72 istringstream streamBrep(brep);
73 BRep_Builder aBuilder;
74 BRepTools::Read (topo, streamBrep, aBuilder);
77 // ====================================================== geom_brep2shape
78 int geom_brep2shape (rcstring brep, TopoDS_Shape& shape)
80 istringstream streamBrep(brep);
81 BRep_Builder aBuilder;
82 BRepTools::Read (shape, streamBrep, aBuilder);
85 // ====================================================== geom_brep2point
86 int geom_brep2point (rcstring brep, double& px, double& py, double& pz)
89 geom_brep2shape (brep, topo);
91 if (topo.ShapeType() != TopAbs_VERTEX)
94 TopoDS_Vertex g_vertex = TopoDS::Vertex (topo);
95 gp_Pnt g_point = BRep_Tool::Pnt( g_vertex );
102 // ====================================================== clear_associations
103 // void clear_associations (Edge* edge)
105 // edge->clearAssociation();
106 // edge->getVertex(V_AMONT)->clearAssociation();
107 // edge->getVertex(V_AVAL )->clearAssociation();
109 // ====================================================== clean_brep
110 void clean_brep (string& brep)
113 BRep_Builder builder;
114 istringstream stream_brep (brep);
116 BRepTools::Read (shape, stream_brep, builder);
117 BRepTools::Clean (shape);
119 ostringstream stream_shape;
120 BRepTools::Write (shape, stream_shape);
121 brep = stream_shape.str();