1 // Created on: 1996-04-10
2 // Created by: Jean-Yves LEBEY
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <Draw_Appli.hxx>
19 #include <Draw_Drawable3D.hxx>
20 #include <TestTopOpeDraw_DrawableSHA.hxx>
21 #include <TestTopOpeDraw_DrawableC3D.hxx>
22 #include <TestTopOpeDraw_DrawableMesure.hxx>
23 #include <DrawTrSurf_Curve.hxx>
24 #include <BRep_Builder.hxx>
25 #include <BRep_Tool.hxx>
26 #include <BRepTools_ShapeSet.hxx>
27 #include <Geom_Curve.hxx>
28 #include <Geom_BSplineCurve.hxx>
30 #include <TopoDS_Shape.hxx>
31 #include <TopoDS_Edge.hxx>
32 #include <TColgp_HArray1OfPnt.hxx>
33 #include <TColgp_Array1OfPnt.hxx>
34 #include <TestTopOpeTools_Mesure.hxx>
36 // pour sauver un DrawableSHA
38 //=======================================================================
39 //function : stestTopOpe
41 //=======================================================================
43 static Standard_Boolean stestTopOpe(const Handle(Draw_Drawable3D)& D)
45 Standard_Boolean res = D->IsInstance(STANDARD_TYPE(TestTopOpeDraw_DrawableSHA));
50 //=======================================================================
51 //function : ssaveTopOpe
53 //=======================================================================
55 static void ssaveTopOpe (const Handle(Draw_Drawable3D)& D, ostream& OS)
57 Handle(TestTopOpeDraw_DrawableSHA) N;
58 N = Handle(TestTopOpeDraw_DrawableSHA)::DownCast(D);
61 BRepTools_ShapeSet S(B);
64 S.Write(N->Shape(),OS);
66 else cout <<"TestTopOpeDraw::ssaveTopOpe : error" << endl;
69 static Standard_Real size = 100.;
70 static Standard_Integer nbIsos = 2;
71 static Standard_Integer discret = 30;
72 //=======================================================================
73 //function : srestoreTopOpe
75 //=======================================================================
77 static Handle(Draw_Drawable3D) srestoreTopOpe (istream& IS)
80 BRepTools_ShapeSet S(B);
82 TopoDS_Shape theShape;
84 Handle(DBRep_DrawableShape) N;
85 N = new DBRep_DrawableShape(theShape,
97 //=======================================================================
98 //function : ssrTopOpe
100 //=======================================================================
102 static Draw_SaveAndRestore ssrTopOpe
103 ("TestTopOpeDraw_DrawableSHA",
104 stestTopOpe,ssaveTopOpe,srestoreTopOpe);
106 // pour sauver une DrawableC3D
108 //=======================================================================
109 //function : ctestTopOpe
111 //=======================================================================
113 static Standard_Boolean ctestTopOpe(const Handle(Draw_Drawable3D)& D)
115 Standard_Boolean res = D->IsInstance(STANDARD_TYPE(TestTopOpeDraw_DrawableC3D));
120 //=======================================================================
121 //function : csaveTopOpe
123 //=======================================================================
125 static void csaveTopOpe (const Handle(Draw_Drawable3D)& D, ostream& OS)
129 Handle(DrawTrSurf_Curve) N;
130 N = Handle(DrawTrSurf_Curve)::DownCast(D);
132 Handle(Geom_Curve) GC;
136 BB.MakeEdge(E, GC, 1.0e-7);
138 BRepTools_ShapeSet S(B);
143 else cout <<"TestTopOpeDraw::csaveTopOpe : error" << endl;
146 //=======================================================================
147 //function : crestoreTopOpe
149 //=======================================================================
151 static Handle(Draw_Drawable3D) crestoreTopOpe (istream& IS)
154 BRepTools_ShapeSet S(B);
156 TopoDS_Shape theShape;
158 TopoDS_Edge& E = TopoDS::Edge(theShape);
160 Handle(Geom_Curve) C3d = BRep_Tool::Curve(E, f, l);
161 Handle(TestTopOpeDraw_DrawableC3D) N;
162 N = new TestTopOpeDraw_DrawableC3D(C3d,Draw_blanc);
167 //=======================================================================
168 //function : csrTopOpe
170 //=======================================================================
172 static Draw_SaveAndRestore csrTopOpe
173 ("TestTopOpeDraw_DrawableC3D",
174 ctestTopOpe,csaveTopOpe,crestoreTopOpe);
177 // pour sauver une DrawableMesure
179 //=======================================================================
180 //function : mtestTopOpe
182 //=======================================================================
184 static Standard_Boolean mtestTopOpe(const Handle(Draw_Drawable3D)& D)
186 Standard_Boolean res = D->IsInstance(STANDARD_TYPE(TestTopOpeDraw_DrawableMesure));
191 //=======================================================================
192 //function : msaveTopOpe
194 //=======================================================================
196 static void msaveTopOpe (const Handle(Draw_Drawable3D)& D, ostream& OS)
198 Handle(DrawTrSurf_Curve) N;
199 N = Handle(DrawTrSurf_Curve)::DownCast(D);
201 Handle(Geom_BSplineCurve) BS;
202 BS = Handle(Geom_BSplineCurve)::DownCast(N->GetCurve());
205 BB.MakeEdge(E, BS, 1.0e-7);
207 BRepTools_ShapeSet S(B);
212 else cout <<"TestTopOpeDraw::msaveTopOpe : error" << endl;
215 //=======================================================================
216 //function : mrestoreTopOpe
218 //=======================================================================
220 static Handle(Draw_Drawable3D) mrestoreTopOpe (istream& IS)
223 BRepTools_ShapeSet S(B);
225 TopoDS_Shape theShape;
227 TopoDS_Edge& E = TopoDS::Edge(theShape);
228 Standard_Integer NbPoles;
230 Handle(Geom_Curve) C3d = BRep_Tool::Curve(E, f, l);
231 Handle(Geom_BSplineCurve) BS;
232 BS = Handle(Geom_BSplineCurve)::DownCast(C3d);
233 NbPoles = BS->NbPoles();
234 TColgp_HArray1OfPnt* Pnt = new TColgp_HArray1OfPnt(1, NbPoles);
235 BS->Poles(Pnt->ChangeArray1());
236 TestTopOpeTools_Mesure Mes(Pnt);
237 Handle(TestTopOpeDraw_DrawableMesure) N;
238 N = new TestTopOpeDraw_DrawableMesure(Mes, Draw_blanc, Draw_rose);
243 //=======================================================================
244 //function : msrTopOpe
246 //=======================================================================
248 static Draw_SaveAndRestore msrTopOpe
249 ("TestTopOpeDraw_DrawableMesure",
250 mtestTopOpe,msaveTopOpe,mrestoreTopOpe);