Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-18 09:22:28

0001 // Created on: 1995-12-04
0002 // Created by: Christian CAILLET
0003 // Copyright (c) 1995-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _XSControl_Utils_HeaderFile
0018 #define _XSControl_Utils_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_CString.hxx>
0025 #include <Standard_Type.hxx>
0026 #include <Standard_Integer.hxx>
0027 #include <Standard_Transient.hxx>
0028 #include <NCollection_Sequence.hxx>
0029 #include <NCollection_HSequence.hxx>
0030 #include <TCollection_HAsciiString.hxx>
0031 #include <TCollection_HExtendedString.hxx>
0032 #include <TopoDS_Shape.hxx>
0033 #include <TopAbs_ShapeEnum.hxx>
0034 class Standard_Transient;
0035 class TCollection_HAsciiString;
0036 class TCollection_AsciiString;
0037 class TCollection_HExtendedString;
0038 class TCollection_ExtendedString;
0039 class TopoDS_Shape;
0040 
0041 //! This class provides various useful utility routines, to
0042 //! facilitate handling of most common data structures :
0043 //! transients (type, type name ...),
0044 //! strings (ascii or extended, pointed or handled or ...),
0045 //! shapes (reading, writing, testing ...),
0046 //! sequences & arrays (of strings, of transients, of shapes ...),
0047 //! ...
0048 //!
0049 //! Also it gives some helps on some data structures from XSTEP,
0050 //! such as printing on standard trace file, recignizing most
0051 //! currently used auxiliary types (Binder,Mapper ...)
0052 class XSControl_Utils
0053 {
0054 public:
0055   DEFINE_STANDARD_ALLOC
0056 
0057   //! the only use of this, is to allow a frontal to get one
0058   //! distinct "Utils" set per separate engine
0059   Standard_EXPORT XSControl_Utils();
0060 
0061   //! Just prints a line into the current Trace File. This allows to
0062   //! better characterise the various trace outputs, as desired.
0063   Standard_EXPORT void TraceLine(const char* const line) const;
0064 
0065   //! Just prints a line or a set of lines into the current Trace
0066   //! File. <lines> can be a HAscii/ExtendedString (produces a print
0067   //! without ending line) or a HSequence or HArray1 Of ..
0068   //! (one new line per item)
0069   Standard_EXPORT void TraceLines(const occ::handle<Standard_Transient>& lines) const;
0070 
0071   Standard_EXPORT bool IsKind(const occ::handle<Standard_Transient>& item,
0072                               const occ::handle<Standard_Type>&      what) const;
0073 
0074   //! Returns the name of the dynamic type of an object, i.e. :
0075   //! If it is a Type, its Name
0076   //! If it is a object not a type, the Name of its DynamicType
0077   //! If it is Null, an empty string
0078   //! If <nopk> is False (D), gives complete name
0079   //! If <nopk> is True, returns class name without package
0080   Standard_EXPORT const char* TypeName(const occ::handle<Standard_Transient>& item,
0081                                        const bool                             nopk = false) const;
0082 
0083   Standard_EXPORT occ::handle<Standard_Transient> TraValue(
0084     const occ::handle<Standard_Transient>& list,
0085     const int                              num) const;
0086 
0087   Standard_EXPORT occ::handle<NCollection_HSequence<occ::handle<Standard_Transient>>> NewSeqTra()
0088     const;
0089 
0090   Standard_EXPORT void AppendTra(
0091     const occ::handle<NCollection_HSequence<occ::handle<Standard_Transient>>>& seqval,
0092     const occ::handle<Standard_Transient>&                                     traval) const;
0093 
0094   Standard_EXPORT const char* DateString(const int yy,
0095                                          const int mm,
0096                                          const int dd,
0097                                          const int hh,
0098                                          const int mn,
0099                                          const int ss) const;
0100 
0101   Standard_EXPORT void DateValues(const char* const text,
0102                                   int&              yy,
0103                                   int&              mm,
0104                                   int&              dd,
0105                                   int&              hh,
0106                                   int&              mn,
0107                                   int&              ss) const;
0108 
0109   Standard_EXPORT const char* ToCString(const occ::handle<TCollection_HAsciiString>& strval) const;
0110 
0111   Standard_EXPORT const char* ToCString(const TCollection_AsciiString& strval) const;
0112 
0113   Standard_EXPORT occ::handle<TCollection_HAsciiString> ToHString(const char* const strcon) const;
0114 
0115   Standard_EXPORT TCollection_AsciiString ToAString(const char* const strcon) const;
0116 
0117   Standard_EXPORT const char16_t* ToEString(
0118     const occ::handle<TCollection_HExtendedString>& strval) const;
0119 
0120   Standard_EXPORT const char16_t* ToEString(const TCollection_ExtendedString& strval) const;
0121 
0122   Standard_EXPORT occ::handle<TCollection_HExtendedString> ToHString(
0123     const char16_t* const strcon) const;
0124 
0125   Standard_EXPORT TCollection_ExtendedString ToXString(const char16_t* const strcon) const;
0126 
0127   Standard_EXPORT const char16_t* AsciiToExtended(const char* const str) const;
0128 
0129   Standard_EXPORT bool IsAscii(const char16_t* const str) const;
0130 
0131   Standard_EXPORT const char* ExtendedToAscii(const char16_t* const str) const;
0132 
0133   Standard_EXPORT const char* CStrValue(const occ::handle<Standard_Transient>& list,
0134                                         const int                              num) const;
0135 
0136   Standard_EXPORT const char16_t* EStrValue(const occ::handle<Standard_Transient>& list,
0137                                             const int                              num) const;
0138 
0139   Standard_EXPORT occ::handle<NCollection_HSequence<occ::handle<TCollection_HAsciiString>>>
0140                   NewSeqCStr() const;
0141 
0142   Standard_EXPORT void AppendCStr(
0143     const occ::handle<NCollection_HSequence<occ::handle<TCollection_HAsciiString>>>& seqval,
0144     const char* const                                                                strval) const;
0145 
0146   Standard_EXPORT occ::handle<NCollection_HSequence<occ::handle<TCollection_HExtendedString>>>
0147                   NewSeqEStr() const;
0148 
0149   Standard_EXPORT void AppendEStr(
0150     const occ::handle<NCollection_HSequence<occ::handle<TCollection_HExtendedString>>>& seqval,
0151     const char16_t* const strval) const;
0152 
0153   //! Converts a list of Shapes to a Compound (a kind of Shape)
0154   Standard_EXPORT TopoDS_Shape
0155     CompoundFromSeq(const occ::handle<NCollection_HSequence<TopoDS_Shape>>& seqval) const;
0156 
0157   //! Returns the type of a Shape : true type if <compound> is False
0158   //! If <compound> is True and <shape> is a Compound, iterates on
0159   //! its items. If all are of the same type, returns this type.
0160   //! Else, returns COMPOUND. If it is empty, returns SHAPE
0161   //! For a Null Shape, returns SHAPE
0162   Standard_EXPORT TopAbs_ShapeEnum ShapeType(const TopoDS_Shape& shape, const bool compound) const;
0163 
0164   //! From a Shape, builds a Compound as follows :
0165   //! explores it level by level
0166   //! If <explore> is False, only COMPOUND items. Else, all items
0167   //! Adds to the result, shapes which comply to <type>
0168   //! + if <type> is WIRE, considers free edges (and makes wires)
0169   //! + if <type> is SHELL, considers free faces (and makes shells)
0170   //! If <compound> is True, gathers items in compounds which
0171   //! correspond to starting COMPOUND,SOLID or SHELL containers, or
0172   //! items directly contained in a Compound
0173   Standard_EXPORT TopoDS_Shape SortedCompound(const TopoDS_Shape&    shape,
0174                                               const TopAbs_ShapeEnum type,
0175                                               const bool             explore,
0176                                               const bool             compound) const;
0177 
0178   Standard_EXPORT TopoDS_Shape
0179     ShapeValue(const occ::handle<NCollection_HSequence<TopoDS_Shape>>& seqv, const int num) const;
0180 
0181   Standard_EXPORT occ::handle<NCollection_HSequence<TopoDS_Shape>> NewSeqShape() const;
0182 
0183   Standard_EXPORT void AppendShape(const occ::handle<NCollection_HSequence<TopoDS_Shape>>& seqv,
0184                                    const TopoDS_Shape& shape) const;
0185 
0186   //! Creates a Transient Object from a Shape : it is either a Binder
0187   //! (used by functions which require a Transient but can process
0188   //! a Shape, such as viewing functions) or a HShape (according to hs)
0189   //! Default is a HShape
0190   Standard_EXPORT occ::handle<Standard_Transient> ShapeBinder(const TopoDS_Shape& shape,
0191                                                               const bool          hs = true) const;
0192 
0193   //! From a Transient, returns a Shape.
0194   //! In fact, recognizes ShapeBinder ShapeMapper and HShape
0195   Standard_EXPORT TopoDS_Shape BinderShape(const occ::handle<Standard_Transient>& tr) const;
0196 
0197   Standard_EXPORT int SeqLength(const occ::handle<Standard_Transient>& list) const;
0198 
0199   Standard_EXPORT occ::handle<Standard_Transient> SeqToArr(
0200     const occ::handle<Standard_Transient>& seq,
0201     const int                              first = 1) const;
0202 
0203   Standard_EXPORT occ::handle<Standard_Transient> ArrToSeq(
0204     const occ::handle<Standard_Transient>& arr) const;
0205 
0206   Standard_EXPORT int SeqIntValue(const occ::handle<NCollection_HSequence<int>>& list,
0207                                   const int                                      num) const;
0208 };
0209 
0210 #endif // _XSControl_Utils_HeaderFile