Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/hexablock.git] / src / HEXABLOCK / HexKas_functions.cxx
1 //
2 // CC++ : Fonctions Interface Cascade
3 //
4 // Copyright (C) 2009-2012  CEA/DEN, EDF R&D
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef NO_CASCADE
24
25 #include "HexKas_functions.hxx"
26
27 BEGIN_NAMESPACE_HEXA
28
29 // ====================================================== same_coords
30 bool same_coords (gp_Pnt& pa, gp_Pnt& pb, double epsilon)
31 {
32    double d2 = carre (pb.X()-pa.X()) + carre (pb.Y()-pa.Y()) 
33                                      + carre (pb.Z()-pa.Z()) ;
34    return d2 < epsilon;
35 }
36 // ====================================================== save_brep
37 void save_brep (cpchar nom, string brep, int& compteur)
38 {
39     char buff[8];
40     compteur ++;
41     sprintf (buff ,"%d", compteur);
42
43     string name (nom);
44     name += buff;
45     name += ".brep";
46     FILE*    fic = fopen (name.c_str(), "w");
47     fprintf (fic, "%s\n", brep.c_str());
48     fclose  (fic);
49 }
50 // ====================================================== geom_make_brep 
51 void geom_make_brep (TopoDS_Shape& shape, string& brep)
52 {
53    ostringstream  stream_shape;
54    BRepTools::Write (shape, stream_shape);
55    brep = stream_shape.str();
56 }
57 END_NAMESPACE_HEXA
58 #endif