summaryrefslogtreecommitdiff
path: root/inc/XSControl_Utils.hxx
blob: a577dc66d9e6f8c0fd912a21ba61f78359e5b92d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
// This file is generated by WOK (CPPExt).
// Please do not edit this file; modify original file instead.
// The copyright and license terms as defined for the original file apply to 
// this header file considered to be the "object code" form of the original source.

#ifndef _XSControl_Utils_HeaderFile
#define _XSControl_Utils_HeaderFile

#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif

#ifndef _Standard_CString_HeaderFile
#include <Standard_CString.hxx>
#endif
#ifndef _Handle_Standard_Transient_HeaderFile
#include <Handle_Standard_Transient.hxx>
#endif
#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
#endif
#ifndef _Handle_Standard_Type_HeaderFile
#include <Handle_Standard_Type.hxx>
#endif
#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
#endif
#ifndef _Handle_TColStd_HSequenceOfTransient_HeaderFile
#include <Handle_TColStd_HSequenceOfTransient.hxx>
#endif
#ifndef _Handle_TCollection_HAsciiString_HeaderFile
#include <Handle_TCollection_HAsciiString.hxx>
#endif
#ifndef _Standard_ExtString_HeaderFile
#include <Standard_ExtString.hxx>
#endif
#ifndef _Handle_TCollection_HExtendedString_HeaderFile
#include <Handle_TCollection_HExtendedString.hxx>
#endif
#ifndef _Handle_TColStd_HSequenceOfHAsciiString_HeaderFile
#include <Handle_TColStd_HSequenceOfHAsciiString.hxx>
#endif
#ifndef _Handle_TColStd_HSequenceOfHExtendedString_HeaderFile
#include <Handle_TColStd_HSequenceOfHExtendedString.hxx>
#endif
#ifndef _Handle_TopTools_HSequenceOfShape_HeaderFile
#include <Handle_TopTools_HSequenceOfShape.hxx>
#endif
#ifndef _TopAbs_ShapeEnum_HeaderFile
#include <TopAbs_ShapeEnum.hxx>
#endif
#ifndef _Handle_TColStd_HSequenceOfInteger_HeaderFile
#include <Handle_TColStd_HSequenceOfInteger.hxx>
#endif
class Standard_TypeMismatch;
class Standard_Transient;
class Standard_Type;
class TColStd_HSequenceOfTransient;
class TCollection_HAsciiString;
class TCollection_AsciiString;
class TCollection_HExtendedString;
class TCollection_ExtendedString;
class TColStd_HSequenceOfHAsciiString;
class TColStd_HSequenceOfHExtendedString;
class TopoDS_Shape;
class TopTools_HSequenceOfShape;
class TColStd_HSequenceOfInteger;


//! This class provides various useful utility routines, to <br>
//!           facilitate handling of most common data structures : <br>
//!           transients (type, type name ...), <br>
//!           strings (ascii or extended, pointed or handled or ...), <br>
//!           shapes (reading, writing, testing ...), <br>
//!           sequences & arrays (of strings, of transients, of shapes ...), <br>
//!           ... <br>
//! <br>
//!           Also it gives some helps on some data structures from XSTEP, <br>
//!           such as printing on standard trace file, recignizing most <br>
//!           currently used auxiliary types (Binder,Mapper ...) <br>
class XSControl_Utils  {
public:

  void* operator new(size_t,void* anAddress) 
  {
    return anAddress;
  }
  void* operator new(size_t size) 
  {
    return Standard::Allocate(size); 
  }
  void  operator delete(void *anAddress) 
  {
    if (anAddress) Standard::Free((Standard_Address&)anAddress); 
  }

  //! the only use of this, is to allow a frontal to get one <br>
//!           distinct "Utils" set per separate engine <br>
  Standard_EXPORT   XSControl_Utils();
  //! Just prints a line into the current Trace File. This allows to <br>
//!           better characterise the various trace outputs, as desired. <br>
  Standard_EXPORT     void TraceLine(const Standard_CString line) const;
  //! Just prints a line or a set of lines into the current Trace <br>
//!           File. <lines> can be a HAscii/ExtendedString (produces a print <br>
//!           without ending line) or a HSequence or HArray1 Of .. <br>
//!            (one new line per item) <br>
  Standard_EXPORT     void TraceLines(const Handle(Standard_Transient)& lines) const;
  
  Standard_EXPORT     Standard_Boolean IsKind(const Handle(Standard_Transient)& item,const Handle(Standard_Type)& what) const;
  //! Returns the name of the dynamic type of an object, i.e. : <br>
//!           If it is a Type, its Name <br>
//!           If it is a object not a type, the Name of its DynamicType <br>
//!           If it is Null, an empty string <br>
//!           If <nopk> is False (D), gives complete name <br>
//!           If <nopk> is True, returns class name without package <br>
  Standard_EXPORT     Standard_CString TypeName(const Handle(Standard_Transient)& item,const Standard_Boolean nopk = Standard_False) const;
  
  Standard_EXPORT     Handle_Standard_Transient TraValue(const Handle(Standard_Transient)& list,const Standard_Integer num) const;
  
  Standard_EXPORT     Handle_TColStd_HSequenceOfTransient NewSeqTra() const;
  
  Standard_EXPORT     void AppendTra(const Handle(TColStd_HSequenceOfTransient)& seqval,const Handle(Standard_Transient)& traval) const;
  
  Standard_EXPORT     Standard_CString DateString(const Standard_Integer yy,const Standard_Integer mm,const Standard_Integer dd,const Standard_Integer hh,const Standard_Integer mn,const Standard_Integer ss) const;
  
  Standard_EXPORT     void DateValues(const Standard_CString text,Standard_Integer& yy,Standard_Integer& mm,Standard_Integer& dd,Standard_Integer& hh,Standard_Integer& mn,Standard_Integer& ss) const;
  
  Standard_EXPORT     Standard_CString ToCString(const Handle(TCollection_HAsciiString)& strval) const;
  
  Standard_EXPORT     Standard_CString ToCString(const TCollection_AsciiString& strval) const;
  
  Standard_EXPORT     Handle_TCollection_HAsciiString ToHString(const Standard_CString strcon) const;
  
  Standard_EXPORT     TCollection_AsciiString ToAString(const Standard_CString strcon) const;
  
  Standard_EXPORT     Standard_ExtString ToEString(const Handle(TCollection_HExtendedString)& strval) const;
  
  Standard_EXPORT     Standard_ExtString ToEString(const TCollection_ExtendedString& strval) const;
  
  Standard_EXPORT     Handle_TCollection_HExtendedString ToHString(const Standard_ExtString strcon) const;
  
  Standard_EXPORT     TCollection_ExtendedString ToXString(const Standard_ExtString strcon) const;
  
  Standard_EXPORT     Standard_ExtString AsciiToExtended(const Standard_CString str) const;
  
  Standard_EXPORT     Standard_Boolean IsAscii(const Standard_ExtString str) const;
  
  Standard_EXPORT     Standard_CString ExtendedToAscii(const Standard_ExtString str) const;
  
  Standard_EXPORT     Standard_CString CStrValue(const Handle(Standard_Transient)& list,const Standard_Integer num) const;
  
  Standard_EXPORT     Standard_ExtString EStrValue(const Handle(Standard_Transient)& list,const Standard_Integer num) const;
  
  Standard_EXPORT     Handle_TColStd_HSequenceOfHAsciiString NewSeqCStr() const;
  
  Standard_EXPORT     void AppendCStr(const Handle(TColStd_HSequenceOfHAsciiString)& seqval,const Standard_CString strval) const;
  
  Standard_EXPORT     Handle_TColStd_HSequenceOfHExtendedString NewSeqEStr() const;
  
  Standard_EXPORT     void AppendEStr(const Handle(TColStd_HSequenceOfHExtendedString)& seqval,const Standard_ExtString strval) const;
  //! Writes a Shape under the internal BRepTools form <br>
//!           (an internal help utility) <br>
//!           Returns True if writing has succeeded, False else <br>
  Standard_EXPORT     Standard_Boolean WriteShape(const TopoDS_Shape& shape,const Standard_CString filename) const;
  //! Returns a new empty, undefined Shape, which can then be filled <br>
//!           by ReadShape <br>
  Standard_EXPORT     TopoDS_Shape NewShape() const;
  //! Reads a Shape from the internal BRepTools form and returns it <br>
//!           (an internal help utility) <br>
//!           Returns True if reading has succeeded, False else <br>
  Standard_EXPORT     Standard_Boolean ReadShape(TopoDS_Shape& shape,const Standard_CString filename) const;
  //! Returns True if a Shape is Null <br>
  Standard_EXPORT     Standard_Boolean IsNullShape(const TopoDS_Shape& shape) const;
  //! Converts a list of Shapes to a Compound (a kind of Shape) <br>
  Standard_EXPORT     TopoDS_Shape CompoundFromSeq(const Handle(TopTools_HSequenceOfShape)& seqval) const;
  //! Returns the type of a Shape : true type if <compound> is False <br>
//!           If <compound> is True and <shape> is a Compound, iterates on <br>
//!           its items. If all are of the same type, returns this type. <br>
//!           Else, returns COMPOUND. If it is empty, returns SHAPE <br>
//!           For a Null Shape, returns SHAPE <br>
  Standard_EXPORT     TopAbs_ShapeEnum ShapeType(const TopoDS_Shape& shape,const Standard_Boolean compound) const;
  //! From a Shape, builds a Compound as follows : <br>
//!           explores it level by level <br>
//!           If <explore> is False, only COMPOUND items. Else, all items <br>
//!           Adds to the result, shapes which comply to <type> <br>
//!           + if <type> is WIRE, considers free edges (and makes wires) <br>
//!           + if <type> is SHELL, considers free faces (and makes shells) <br>
//!           If <compound> is True, gathers items in compounds which <br>
//!           correspond to starting COMPOUND,SOLID or SHELL containers, or <br>
//!           items directly contained in a Compound <br>
  Standard_EXPORT     TopoDS_Shape SortedCompound(const TopoDS_Shape& shape,const TopAbs_ShapeEnum type,const Standard_Boolean explore,const Standard_Boolean compound) const;
  
  Standard_EXPORT     TopoDS_Shape ShapeValue(const Handle(TopTools_HSequenceOfShape)& seqv,const Standard_Integer num) const;
  
  Standard_EXPORT     Handle_TopTools_HSequenceOfShape NewSeqShape() const;
  
  Standard_EXPORT     void AppendShape(const Handle(TopTools_HSequenceOfShape)& seqv,const TopoDS_Shape& shape) const;
  //! Creates a Transient Object from a Shape : it is either a Binder <br>
//!           (used by functions which require a Transient but can process <br>
//!           a Shape, such as viewing functions) or a HShape (according to hs) <br>
//!           Default is a HShape <br>
  Standard_EXPORT     Handle_Standard_Transient ShapeBinder(const TopoDS_Shape& shape,const Standard_Boolean hs = Standard_True) const;
  //! From a Transient, returns a Shape. <br>
//!           In fact, recognizes ShapeBinder ShapeMapper and HShape <br>
  Standard_EXPORT     TopoDS_Shape BinderShape(const Handle(Standard_Transient)& tr) const;
  
  Standard_EXPORT     Standard_Integer SeqLength(const Handle(Standard_Transient)& list) const;
  
  Standard_EXPORT     Handle_Standard_Transient SeqToArr(const Handle(Standard_Transient)& seq,const Standard_Integer first = 1) const;
  
  Standard_EXPORT     Handle_Standard_Transient ArrToSeq(const Handle(Standard_Transient)& arr) const;
  
  Standard_EXPORT     Standard_Integer SeqIntValue(const Handle(TColStd_HSequenceOfInteger)& list,const Standard_Integer num) const;





protected:





private:





};





// other Inline functions and methods (like "C++: function call" methods)


#endif