2 // CC++ : Fonctions Interface Cascade
4 // Copyright (C) 2009-2019 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, or (at your option) any later version.
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"
24 // #include "HexEdge.hxx"
27 #include <TopoDS_Shape.hxx>
28 #include <TopoDS_Vertex.hxx>
30 #include <BRep_Builder.hxx>
31 #include <BRepTools.hxx>
39 // ====================================================== same_coords
40 bool same_coords (gp_Pnt& pa, gp_Pnt& pb, double epsilon)
42 double d2 = carre (pb.X()-pa.X()) + carre (pb.Y()-pa.Y())
43 + carre (pb.Z()-pa.Z()) ;
46 // ====================================================== save_brep
47 void save_brep (cpchar nom, std::string brep, int& compteur)
51 sprintf (buff ,"%d", compteur);
53 std::string name (nom);
56 FILE* fic = fopen (name.c_str(), "w");
57 fprintf (fic, "%s\n", brep.c_str());
60 // ====================================================== geom_make_brep
61 void geom_make_brep (TopoDS_Shape& shape, std::string& brep)
63 std::ostringstream stream_shape;
64 BRepTools::Write (shape, stream_shape);
65 brep = stream_shape.str();
67 // ====================================================== geom_brep2shape (F)
68 TopoDS_Shape geom_brep2shape (rcstring brep)
71 std::istringstream streamBrep(brep);
72 BRep_Builder aBuilder;
73 BRepTools::Read (topo, streamBrep, aBuilder);
76 // ====================================================== geom_brep2shape
77 int geom_brep2shape (rcstring brep, TopoDS_Shape& shape)
79 std::istringstream streamBrep(brep);
80 BRep_Builder aBuilder;
81 BRepTools::Read (shape, streamBrep, aBuilder);
84 // ====================================================== geom_brep2point
85 int geom_brep2point (rcstring brep, double& px, double& py, double& pz)
88 geom_brep2shape (brep, topo);
90 if (topo.ShapeType() != TopAbs_VERTEX)
93 TopoDS_Vertex g_vertex = TopoDS::Vertex (topo);
94 gp_Pnt g_point = BRep_Tool::Pnt( g_vertex );
101 // ====================================================== clear_associations
102 // void clear_associations (Edge* edge)
104 // edge->clearAssociation();
105 // edge->getVertex(V_AMONT)->clearAssociation();
106 // edge->getVertex(V_AVAL )->clearAssociation();
108 // ====================================================== clean_brep
109 void clean_brep (std::string& brep)
112 BRep_Builder builder;
113 std::istringstream stream_brep (brep);
115 BRepTools::Read (shape, stream_brep, builder);
116 BRepTools::Clean (shape);
118 std::ostringstream stream_shape;
119 BRepTools::Write (shape, stream_shape);
120 brep = stream_shape.str();