0020716: Eliminate usage of "config.h" header file
[occt.git] / src / TestTopOpeDraw / TestTopOpeDraw_TTOT.cxx
CommitLineData
b311480e 1// Created on: 1996-09-20
2// Created by: Jean Yves LEBEY
3// Copyright (c) 1996-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
7fd59977 17#include <TestTopOpeDraw_TTOT.hxx>
18#include <GeomAdaptor_Curve.hxx>
19#include <GeomAdaptor_Surface.hxx>
20#include <BRep_Tool.hxx>
7fd59977 21
22//=======================================================================
23//function : ShapeEnumToString
24//purpose :
25//=======================================================================
26void TestTopOpeDraw_TTOT::ShapeEnumToString
27(const TopAbs_ShapeEnum T, TCollection_AsciiString& N)
28{
29 if (T == TopAbs_SHAPE) N = "s";
30 else if (T == TopAbs_COMPOUND) N = "co";
31 else if (T == TopAbs_COMPSOLID) N = "cs";
32 else if (T == TopAbs_SOLID) N = "so";
33 else if (T == TopAbs_SHELL) N = "sh";
34 else if (T == TopAbs_FACE) N = "f";
35 else if (T == TopAbs_WIRE) N = "w";
36 else if (T == TopAbs_EDGE) N = "e";
37 else if (T == TopAbs_VERTEX) N = "v";
38}
39
40//=======================================================================
41//function : OrientationToString
42//purpose :
43//=======================================================================
44
45void TestTopOpeDraw_TTOT::OrientationToString
46(const TopAbs_Orientation o, TCollection_AsciiString& N)
47{
48 switch (o) {
49 case TopAbs_FORWARD : N = "FORWARD" ; break;
50 case TopAbs_REVERSED : N = "REVERSED"; break;
51 case TopAbs_INTERNAL : N = "INTERNAL"; break;
52 case TopAbs_EXTERNAL : N = "EXTERNAL"; break;
53 }
54}
55
56//=======================================================================
57//function : StringToKind
58//purpose :
59//=======================================================================
60
61Standard_Boolean TestTopOpeDraw_TTOT::StringToKind
62(const TCollection_AsciiString& N, TopOpeBRepDS_Kind& T)
63{
64 char *s = (char*)N.ToCString();
65 Standard_Integer ok = 0;
66 if (!strcasecmp(s,"su")) { T = TopOpeBRepDS_SURFACE; ok = 1; }
67 else if (!strcasecmp(s,"c")) { T = TopOpeBRepDS_CURVE; ok = 1; }
68 else if (!strcasecmp(s,"p")) { T = TopOpeBRepDS_POINT; ok = 1; }
69 if (!strcasecmp(s,"co")) { T = TopOpeBRepDS_COMPOUND; ok = 1; }
70 if (!strcasecmp(s,"cs")) { T = TopOpeBRepDS_COMPSOLID; ok = 1; }
71 else if (!strcasecmp(s,"so")) { T = TopOpeBRepDS_SOLID; ok = 1; }
72 else if (!strcasecmp(s,"sh")) { T = TopOpeBRepDS_SHELL; ok = 1; }
73 else if (!strcasecmp(s,"f")) { T = TopOpeBRepDS_FACE; ok = 1; }
74 else if (!strcasecmp(s,"w")) { T = TopOpeBRepDS_WIRE; ok = 1; }
75 else if (!strcasecmp(s,"e")) { T = TopOpeBRepDS_EDGE; ok = 1; }
76 else if (!strcasecmp(s,"v")) { T = TopOpeBRepDS_VERTEX; ok = 1; }
77 return ok != 0;
78}
79
80//=======================================================================
81//function : KindToString
82//purpose :
83//=======================================================================
84
85void TestTopOpeDraw_TTOT::KindToString
86(const TopOpeBRepDS_Kind T, TCollection_AsciiString& N)
87{
88 if (T == TopOpeBRepDS_SURFACE) N = "su";
89 else if (T == TopOpeBRepDS_CURVE) N = "c";
90 else if (T == TopOpeBRepDS_POINT) N = "p";
91 else if (T == TopOpeBRepDS_COMPOUND) N = "co";
92 else if (T == TopOpeBRepDS_COMPSOLID) N = "cs";
93 else if (T == TopOpeBRepDS_SOLID) N = "so";
94 else if (T == TopOpeBRepDS_SHELL) N = "sh";
95 else if (T == TopOpeBRepDS_FACE) N = "f";
96 else if (T == TopOpeBRepDS_WIRE) N = "w";
97 else if (T == TopOpeBRepDS_EDGE) N = "e";
98 else if (T == TopOpeBRepDS_VERTEX) N = "v";
99}
100
101
102//=======================================================================
103//function : StringToShapeEnum
104//purpose :
105//=======================================================================
106
107Standard_Boolean TestTopOpeDraw_TTOT::StringToShapeEnum
108(const TCollection_AsciiString& N, TopAbs_ShapeEnum& T)
109{
110 char *s = (char*)N.ToCString();
111 Standard_Integer ok = 0;
112 if (!strcasecmp(s,"s")) { T = TopAbs_SHAPE; ok = 1; }
113 else if (!strcasecmp(s,"co")) { T = TopAbs_COMPOUND; ok = 1; }
114 else if (!strcasecmp(s,"cs")) { T = TopAbs_COMPSOLID; ok = 1; }
115 else if (!strcasecmp(s,"so")) { T = TopAbs_SOLID; ok = 1; }
116 else if (!strcasecmp(s,"sh")) { T = TopAbs_SHELL; ok = 1; }
117 else if (!strcasecmp(s,"f")) { T = TopAbs_FACE; ok = 1; }
118 else if (!strcasecmp(s,"w")) { T = TopAbs_WIRE; ok = 1; }
119 else if (!strcasecmp(s,"e")) { T = TopAbs_EDGE; ok = 1; }
120 else if (!strcasecmp(s,"v")) { T = TopAbs_VERTEX; ok = 1; }
121 return ok != 0;
122}
123
124
125//=======================================================================
126//function : ShapeColor
127//purpose :
128//=======================================================================
129
130Draw_ColorKind TestTopOpeDraw_TTOT::ShapeColor
131(const TopoDS_Shape& S)
132{
133 Draw_ColorKind col = Draw_orange;
134 switch ( S.ShapeType() ) {
135 case TopAbs_COMPOUND : col = Draw_saumon; break;
136 case TopAbs_COMPSOLID : col = Draw_blanc; break;
137 case TopAbs_SOLID : col = Draw_violet; break;
138 case TopAbs_SHELL : col = Draw_corail; break;
139 case TopAbs_FACE : col = Draw_vert; break; // col = Draw_jaune; break;
140 case TopAbs_WIRE : col = Draw_cyan; break;
141 case TopAbs_EDGE : col = Draw_magenta; break;
142 case TopAbs_VERTEX : col = Draw_orange; break;
143 default : col = Draw_marron;
144 }
145 return col;
146}
147
148Draw_ColorKind TestTopOpeDraw_TTOT::KindColor
149(const TopOpeBRepDS_Kind K)
150{
151 Draw_ColorKind col = Draw_orange;
152 if (K == TopOpeBRepDS_SURFACE) col = Draw_jaune;
153 else if (K == TopOpeBRepDS_CURVE) col = Draw_vert;
154 else if (K == TopOpeBRepDS_POINT) col = Draw_blanc;
155 else if (K == TopOpeBRepDS_FACE) col = Draw_cyan;
156 return col;
157}
158
159//=======================================================================
160//function : GeometryColor
161//purpose :
162//=======================================================================
163
164Draw_ColorKind TestTopOpeDraw_TTOT::GeometryColor
165(const TopOpeBRepDS_Kind K)
166{
167 Draw_ColorKind col = Draw_orange;
168 col = KindColor(K);
169 return col;
170}
171
172//=======================================================================
173//function : CurveToString
174//purpose :
175//=======================================================================
176
177void TestTopOpeDraw_TTOT::CurveToString
178(const GeomAbs_CurveType t, TCollection_AsciiString& N)
179{
180 switch(t) {
181 case GeomAbs_Line : N = "LINE"; break;
182 case GeomAbs_Circle : N = "CIRCLE"; break;
183 case GeomAbs_Ellipse : N = "ELLIPSE"; break;
184 case GeomAbs_Hyperbola : N = "HYPERBOLA"; break;
185 case GeomAbs_Parabola : N = "PARABOLA"; break;
186 case GeomAbs_BezierCurve : N = "BEZIER"; break;
187 case GeomAbs_BSplineCurve : N = "BSPLINE"; break;
188 case GeomAbs_OtherCurve : N = "OTHER"; break;
189 default : N = "UNKNOWN"; break;
190 }
191}
192
193//=======================================================================
194//function : SurfaceToString
195//purpose :
196//=======================================================================
197
198void TestTopOpeDraw_TTOT::SurfaceToString
199(const GeomAbs_SurfaceType t, TCollection_AsciiString& N)
200{
201 switch(t) {
202 case GeomAbs_Plane : N = "PLANE"; break;
203 case GeomAbs_Cylinder : N = "CYLINDER"; break;
204 case GeomAbs_Cone : N = "CONE"; break;
205 case GeomAbs_Sphere : N = "SPHERE"; break;
206 case GeomAbs_Torus : N = "TORUS"; break;
207 case GeomAbs_BezierSurface : N = "BEZIER"; break;
208 case GeomAbs_BSplineSurface : N = "BSPLINE"; break;
209 case GeomAbs_SurfaceOfRevolution : N = "REVOLUTION"; break;
210 case GeomAbs_SurfaceOfExtrusion : N = "EXTRUSION"; break;
211 case GeomAbs_OffsetSurface : N = "OFFSET"; break;
212 case GeomAbs_OtherSurface : N = "OTHER"; break;
213 default : N = "UNKNOWN"; break;
214 }
215}
216
217//=======================================================================
218//function : GeometryName
219//purpose :
220//=======================================================================
221
222void TestTopOpeDraw_TTOT::GeometryName
223(const Standard_Integer I, const TopOpeBRepDS_Kind K, TCollection_AsciiString& N)
224{
225 TCollection_AsciiString name; KindToString(K,name);
226 name = name + "_" + TCollection_AsciiString(I);
227 N = name;
228}
229
230//=======================================================================
231//function : CatCurveName
232//purpose :
233//=======================================================================
234
235void TestTopOpeDraw_TTOT::CatCurveName
236(const Standard_Integer I, TCollection_AsciiString& N)
237{
238 TCollection_AsciiString n; GeometryName(I,TopOpeBRepDS_CURVE,n);
239 N = N + n;
240}
241
242//=======================================================================
243//function : CatOrientation
244//purpose :
245//=======================================================================
246
247void TestTopOpeDraw_TTOT::CatOrientation
248(const TopAbs_Orientation o,TCollection_AsciiString& N)
249{
250 TCollection_AsciiString s; OrientationToString(o,s);
251 s.Trunc(1);
252 N = N + "["; N = N + s; N = N + "]";
253}
254
255//=======================================================================
256//function : CatOrientation
257//purpose :
258//=======================================================================
259
260void TestTopOpeDraw_TTOT::CatOrientation
261(const TopoDS_Shape& S,TCollection_AsciiString& N)
262{
263 CatOrientation(S.Orientation(),N);
264}
265
266//=======================================================================
267//function : CatCurve
268//purpose :
269//=======================================================================
270
271void TestTopOpeDraw_TTOT::CatCurve
272(const Handle(Geom_Curve) GC, TCollection_AsciiString& N)
273{
274 if ( GC.IsNull() ) return;
275 GeomAdaptor_Curve GAC(GC); GeomAbs_CurveType t = GAC.GetType();
276 TCollection_AsciiString s; CurveToString(t,s);
277 s.Trunc(2);
278 N = N + "("; N = N + s; N = N + ")";
279}
280
281//=======================================================================
282//function : CatSurface
283//purpose :
284//=======================================================================
285
286void TestTopOpeDraw_TTOT::CatSurface
287(const Handle(Geom_Surface) GS, TCollection_AsciiString& N)
288{
289 if ( GS.IsNull() ) return;
290 GeomAdaptor_Surface GAS(GS); GeomAbs_SurfaceType t = GAS.GetType();
291 TCollection_AsciiString s; SurfaceToString(t,s);
292 s.Trunc(2);
293 N = N + "("; N = N + s; N = N + ")";
294}
295
296//=======================================================================
297//function : CatGeometry
298//purpose :
299//=======================================================================
300
301void TestTopOpeDraw_TTOT::CatGeometry
302(const TopoDS_Shape& S, TCollection_AsciiString& N)
303{
304 if ( S.IsNull() ) return;
305 const TopAbs_ShapeEnum t = S.ShapeType();
306 if (t == TopAbs_FACE) {
307 const TopoDS_Face& F = TopoDS::Face(S);
308 TopLoc_Location loc;
309 Handle(Geom_Surface) GS = BRep_Tool::Surface(F,loc);
310 CatSurface(GS,N);
311 }
312 else if (t == TopAbs_EDGE) {
313 const TopoDS_Edge& E = TopoDS::Edge(S);
314 TopLoc_Location loc; Standard_Real f,l;
315 Handle(Geom_Curve) GC = BRep_Tool::Curve(E,loc,f,l);
316 CatCurve(GC,N);
317 }
318}
319
320//=======================================================================
321//function : CatCurveDisplayName
322//purpose :
323//=======================================================================
324
325void TestTopOpeDraw_TTOT::CatCurveDisplayName
326(const Standard_Integer I, const Handle(Geom_Curve) GC, TCollection_AsciiString& N)
327{
328 if ( GC.IsNull() ) return;
329 CatCurveName(I,N);
330 CatCurve(GC,N);
331}
332
333//=======================================================================
334//function : CurveDisplayName
335//purpose :
336//=======================================================================
337
338void TestTopOpeDraw_TTOT::CurveDisplayName
339(const Standard_Integer I, const Handle(Geom_Curve) GC, TCollection_AsciiString& N)
340{
341 N = " ";
342 CatCurveDisplayName(I,GC,N);
343}
344
345//=======================================================================
346//function : ShapeKind
347//purpose :
348//=======================================================================
349
350Standard_Boolean TestTopOpeDraw_TTOT::ShapeKind(const TopoDS_Shape& S,const TopAbs_ShapeEnum TS)
351{
352 if ( TS == TopAbs_SHAPE ) return Standard_True;
353 else return ( S.ShapeType() == TS );
354}