]> SALOME platform Git repositories - modules/hexablock.git/blob - src/HEXABLOCK/HexKasPoint.cxx
Salome HOME
Merge from V6_main 01/04/2013
[modules/hexablock.git] / src / HEXABLOCK / HexKasPoint.cxx
1 //
2 // CC++ : Interface Cascade de la classe Elements
3 //
4 // Copyright (C) 2009-2013  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 #include "HexKasPoint.hxx"
24 #include "HexVertex.hxx"
25 #include "HexOldShape.hxx"
26
27 #ifndef NO_CASCADE
28
29 #include <BRepTools.hxx>
30 #include <BRep_Builder.hxx>
31 #include <BRepBuilderAPI_MakeVertex.hxx>
32
33 #include <GCPnts_AbscissaPoint.hxx>
34
35 #include <TopoDS.hxx>
36 #include <TopoDS_Shape.hxx>
37 #include <TopoDS_Vertex.hxx>
38
39 #include <gp_Pnt.hxx>
40
41 BEGIN_NAMESPACE_HEXA
42
43 static bool db = false;
44
45 // ======================================================= Constructeur
46 KasPoint::KasPoint ()
47 {
48    db = on_debug();
49    razPoint ();
50 }
51 // ======================================================= razPoint
52 void KasPoint::razPoint ()
53 {
54    is_ok = false;
55    b_rep = "";
56    for (int nc=0; nc <DIM3 ; nc++) g_coord [nc] = 0;
57 }
58 // ======================================================= definePoint (vertex)
59 int KasPoint::definePoint (Vertex* node)
60 {
61    return HERR;
62 #if 0
63    razPoint ();
64
65    if (node==NULL)
66       return HERR;
67
68    Shape* asso = node->getAssociation();
69    if (asso==NULL)
70       return HERR;
71
72    b_rep = asso->getBrep ();
73
74    TopoDS_Shape topo;
75    istringstream streamBrep(b_rep);
76    BRep_Builder aBuilder;
77    BRepTools::Read(topo, streamBrep, aBuilder);
78
79    if (topo.ShapeType() != TopAbs_VERTEX)
80       return HERR;
81
82    is_ok    = true;
83    g_vertex = TopoDS::Vertex (topo);
84    g_point  = BRep_Tool::Pnt( g_vertex );
85
86    g_coord [dir_x] = g_point.X();
87    g_coord [dir_y] = g_point.Y();
88    g_coord [dir_z] = g_point.Z();
89    return HOK;
90 #endif
91 }
92 // ======================================================= definePoint (xyz)
93 void KasPoint::definePoint (Real3 coord)
94 {
95    gp_Pnt gpoint (coord[dir_x], coord[dir_y], coord[dir_z]);
96    definePoint   (gpoint);
97 }
98 // ======================================================= definePoint (g_pnt)
99 void KasPoint::definePoint (gp_Pnt& gpoint)
100 {
101    is_ok   = true;
102    g_point = gpoint;
103
104    ostringstream   stream_shape;
105
106    BRepBuilderAPI_MakeVertex mkVertex (g_point);
107    TopoDS_Shape              aShape = mkVertex.Shape();
108    BRepTools::Write(aShape, stream_shape);
109
110    g_vertex = TopoDS::Vertex( aShape );
111    b_rep    = stream_shape.str();
112
113    g_coord [dir_x] = g_point.X();
114    g_coord [dir_y] = g_point.Y();
115    g_coord [dir_z] = g_point.Z();
116
117    if (db)
118       {
119       cout << " KasPoint::definePoint :" << endl;
120       PutCoord (g_coord);
121       }
122 }
123 // ======================================================= associate
124 void KasPoint::associate (Vertex* node)
125 {
126 /****************
127    if (db) cout << " ++ KasPoint::associate " << endl;
128    if (db) PutName (node);
129    if (node==NULL)
130       return;
131
132    Shape* vshape = new Shape (b_rep);
133    node->setAssociation (vshape);
134
135 *********************/
136 }
137 END_NAMESPACE_HEXA
138 #endif