Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:36

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 <TColStd_HSequenceOfTransient.hxx>
0028 #include <TColStd_HSequenceOfHAsciiString.hxx>
0029 #include <TColStd_HSequenceOfHExtendedString.hxx>
0030 #include <TopTools_HSequenceOfShape.hxx>
0031 #include <TopAbs_ShapeEnum.hxx>
0032 #include <TColStd_HSequenceOfInteger.hxx>
0033 class Standard_Transient;
0034 class TCollection_HAsciiString;
0035 class TCollection_AsciiString;
0036 class TCollection_HExtendedString;
0037 class TCollection_ExtendedString;
0038 class TopoDS_Shape;
0039 
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 
0056   DEFINE_STANDARD_ALLOC
0057 
0058   
0059   //! the only use of this, is to allow a frontal to get one
0060   //! distinct "Utils" set per separate engine
0061   Standard_EXPORT XSControl_Utils();
0062   
0063   //! Just prints a line into the current Trace File. This allows to
0064   //! better characterise the various trace outputs, as desired.
0065   Standard_EXPORT void TraceLine (const Standard_CString line) const;
0066   
0067   //! Just prints a line or a set of lines into the current Trace
0068   //! File. <lines> can be a HAscii/ExtendedString (produces a print
0069   //! without ending line) or a HSequence or HArray1 Of ..
0070   //! (one new line per item)
0071   Standard_EXPORT void TraceLines (const Handle(Standard_Transient)& lines) const;
0072   
0073   Standard_EXPORT Standard_Boolean IsKind (const Handle(Standard_Transient)& item, const Handle(Standard_Type)& what) const;
0074   
0075   //! Returns the name of the dynamic type of an object, i.e. :
0076   //! If it is a Type, its Name
0077   //! If it is a object not a type, the Name of its DynamicType
0078   //! If it is Null, an empty string
0079   //! If <nopk> is False (D), gives complete name
0080   //! If <nopk> is True, returns class name without package
0081   Standard_EXPORT Standard_CString TypeName (const Handle(Standard_Transient)& item, const Standard_Boolean nopk = Standard_False) const;
0082   
0083   Standard_EXPORT Handle(Standard_Transient) TraValue (const Handle(Standard_Transient)& list, const Standard_Integer num) const;
0084   
0085   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) NewSeqTra() const;
0086   
0087   Standard_EXPORT void AppendTra (const Handle(TColStd_HSequenceOfTransient)& seqval, const Handle(Standard_Transient)& traval) const;
0088   
0089   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;
0090   
0091   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;
0092   
0093   Standard_EXPORT Standard_CString ToCString (const Handle(TCollection_HAsciiString)& strval) const;
0094   
0095   Standard_EXPORT Standard_CString ToCString (const TCollection_AsciiString& strval) const;
0096   
0097   Standard_EXPORT Handle(TCollection_HAsciiString) ToHString (const Standard_CString strcon) const;
0098   
0099   Standard_EXPORT TCollection_AsciiString ToAString (const Standard_CString strcon) const;
0100   
0101   Standard_EXPORT Standard_ExtString ToEString (const Handle(TCollection_HExtendedString)& strval) const;
0102   
0103   Standard_EXPORT Standard_ExtString ToEString (const TCollection_ExtendedString& strval) const;
0104   
0105   Standard_EXPORT Handle(TCollection_HExtendedString) ToHString (const Standard_ExtString strcon) const;
0106   
0107   Standard_EXPORT TCollection_ExtendedString ToXString (const Standard_ExtString strcon) const;
0108   
0109   Standard_EXPORT Standard_ExtString AsciiToExtended (const Standard_CString str) const;
0110   
0111   Standard_EXPORT Standard_Boolean IsAscii (const Standard_ExtString str) const;
0112   
0113   Standard_EXPORT Standard_CString ExtendedToAscii (const Standard_ExtString str) const;
0114   
0115   Standard_EXPORT Standard_CString CStrValue (const Handle(Standard_Transient)& list, const Standard_Integer num) const;
0116   
0117   Standard_EXPORT Standard_ExtString EStrValue (const Handle(Standard_Transient)& list, const Standard_Integer num) const;
0118   
0119   Standard_EXPORT Handle(TColStd_HSequenceOfHAsciiString) NewSeqCStr() const;
0120   
0121   Standard_EXPORT void AppendCStr (const Handle(TColStd_HSequenceOfHAsciiString)& seqval, const Standard_CString strval) const;
0122   
0123   Standard_EXPORT Handle(TColStd_HSequenceOfHExtendedString) NewSeqEStr() const;
0124   
0125   Standard_EXPORT void AppendEStr (const Handle(TColStd_HSequenceOfHExtendedString)& seqval, const Standard_ExtString strval) const;
0126   
0127   //! Converts a list of Shapes to a Compound (a kind of Shape)
0128   Standard_EXPORT TopoDS_Shape CompoundFromSeq (const Handle(TopTools_HSequenceOfShape)& seqval) const;
0129   
0130   //! Returns the type of a Shape : true type if <compound> is False
0131   //! If <compound> is True and <shape> is a Compound, iterates on
0132   //! its items. If all are of the same type, returns this type.
0133   //! Else, returns COMPOUND. If it is empty, returns SHAPE
0134   //! For a Null Shape, returns SHAPE
0135   Standard_EXPORT TopAbs_ShapeEnum ShapeType (const TopoDS_Shape& shape, const Standard_Boolean compound) const;
0136   
0137   //! From a Shape, builds a Compound as follows :
0138   //! explores it level by level
0139   //! If <explore> is False, only COMPOUND items. Else, all items
0140   //! Adds to the result, shapes which comply to <type>
0141   //! + if <type> is WIRE, considers free edges (and makes wires)
0142   //! + if <type> is SHELL, considers free faces (and makes shells)
0143   //! If <compound> is True, gathers items in compounds which
0144   //! correspond to starting COMPOUND,SOLID or SHELL containers, or
0145   //! items directly contained in a Compound
0146   Standard_EXPORT TopoDS_Shape SortedCompound (const TopoDS_Shape& shape, const TopAbs_ShapeEnum type, const Standard_Boolean explore, const Standard_Boolean compound) const;
0147   
0148   Standard_EXPORT TopoDS_Shape ShapeValue (const Handle(TopTools_HSequenceOfShape)& seqv, const Standard_Integer num) const;
0149   
0150   Standard_EXPORT Handle(TopTools_HSequenceOfShape) NewSeqShape() const;
0151   
0152   Standard_EXPORT void AppendShape (const Handle(TopTools_HSequenceOfShape)& seqv, const TopoDS_Shape& shape) const;
0153   
0154   //! Creates a Transient Object from a Shape : it is either a Binder
0155   //! (used by functions which require a Transient but can process
0156   //! a Shape, such as viewing functions) or a HShape (according to hs)
0157   //! Default is a HShape
0158   Standard_EXPORT Handle(Standard_Transient) ShapeBinder (const TopoDS_Shape& shape, const Standard_Boolean hs = Standard_True) const;
0159   
0160   //! From a Transient, returns a Shape.
0161   //! In fact, recognizes ShapeBinder ShapeMapper and HShape
0162   Standard_EXPORT TopoDS_Shape BinderShape (const Handle(Standard_Transient)& tr) const;
0163   
0164   Standard_EXPORT Standard_Integer SeqLength (const Handle(Standard_Transient)& list) const;
0165   
0166   Standard_EXPORT Handle(Standard_Transient) SeqToArr (const Handle(Standard_Transient)& seq, const Standard_Integer first = 1) const;
0167   
0168   Standard_EXPORT Handle(Standard_Transient) ArrToSeq (const Handle(Standard_Transient)& arr) const;
0169   
0170   Standard_EXPORT Standard_Integer SeqIntValue (const Handle(TColStd_HSequenceOfInteger)& list, const Standard_Integer num) const;
0171 
0172 
0173 
0174 
0175 protected:
0176 
0177 
0178 
0179 
0180 
0181 private:
0182 
0183 
0184 
0185 
0186 
0187 };
0188 
0189 
0190 
0191 
0192 
0193 
0194 
0195 #endif // _XSControl_Utils_HeaderFile