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/ or email : webmaster.salome@opencascade.com
23 #include "HexKas_functions.hxx"
28 #include <TopoDS_Shape.hxx>
29 #include <TopoDS_Vertex.hxx>
31 #include <BRep_Builder.hxx>
32 #include <BRepTools.hxx>
38 // ====================================================== same_coords
39 bool same_coords (gp_Pnt& pa, gp_Pnt& pb, double epsilon)
41 double d2 = carre (pb.X()-pa.X()) + carre (pb.Y()-pa.Y())
42 + carre (pb.Z()-pa.Z()) ;
45 // ====================================================== save_brep
46 void save_brep (cpchar nom, string brep, int& compteur)
50 sprintf (buff ,"%d", compteur);
55 FILE* fic = fopen (name.c_str(), "w");
56 fprintf (fic, "%s\n", brep.c_str());
59 // ====================================================== geom_make_brep
60 void geom_make_brep (TopoDS_Shape& shape, string& brep)
62 ostringstream stream_shape;
63 BRepTools::Write (shape, stream_shape);
64 brep = stream_shape.str();
66 // ====================================================== geom_brep2shape (F)
67 TopoDS_Shape geom_brep2shape (rcstring brep)
70 istringstream streamBrep(brep);
71 BRep_Builder aBuilder;
72 BRepTools::Read (topo, streamBrep, aBuilder);
75 // ====================================================== geom_brep2shape
76 int geom_brep2shape (rcstring brep, TopoDS_Shape& shape)
78 istringstream streamBrep(brep);
79 BRep_Builder aBuilder;
80 BRepTools::Read (shape, streamBrep, aBuilder);
83 // ====================================================== geom_brep2point
84 int geom_brep2point (rcstring brep, double& px, double& py, double& pz)
87 geom_brep2shape (brep, topo);
89 if (topo.ShapeType() != TopAbs_VERTEX)
92 TopoDS_Vertex g_vertex = TopoDS::Vertex (topo);
93 gp_Pnt g_point = BRep_Tool::Pnt( g_vertex );
102 #else // *************************************************** NO_CASCADE
105 int geom_brep2point (rcstring b, double& x, double& y, double& z) {return HOK;}
106 int geom_brep2shape (rcstring brep, TopoDS_Shape& shape) {return HOK ; }
107 TopoDS_Shape geom_brep2shape (rcstring brep) {return O ; }