Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-21 09:17:27

0001 // Created on: 1992-04-07
0002 // Created by: Christian CAILLET
0003 // Copyright (c) 1992-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 _IGESData_IGESWriter_HeaderFile
0018 #define _IGESData_IGESWriter_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <TCollection_HAsciiString.hxx>
0025 #include <NCollection_Sequence.hxx>
0026 #include <NCollection_HSequence.hxx>
0027 #include <IGESData_DirPart.hxx>
0028 #include <NCollection_Array1.hxx>
0029 #include <Standard_Integer.hxx>
0030 #include <IGESData_ReadStage.hxx>
0031 #include <Interface_LineBuffer.hxx>
0032 #include <Interface_FloatWriter.hxx>
0033 #include <Standard_CString.hxx>
0034 #include <Standard_OStream.hxx>
0035 
0036 class IGESData_IGESModel;
0037 class IGESData_Protocol;
0038 class IGESData_GlobalSection;
0039 class IGESData_IGESEntity;
0040 class TCollection_HAsciiString;
0041 class gp_XY;
0042 class gp_XYZ;
0043 
0044 //! manages atomic file writing, under control of IGESModel :
0045 //! prepare text to be sent then sends it
0046 //! takes into account distinction between successive Sections
0047 class IGESData_IGESWriter
0048 {
0049 public:
0050   DEFINE_STANDARD_ALLOC
0051 
0052   //! Creates an IGESWriter, empty ready to work
0053   //! (see the methods SendModel and Print)
0054   Standard_EXPORT IGESData_IGESWriter(const occ::handle<IGESData_IGESModel>& amodel);
0055 
0056   //! Default constructor (not used) to satisfy the compiler
0057   Standard_EXPORT IGESData_IGESWriter();
0058 
0059   //! Constructor by copy (not used) to satisfy the compiler
0060   Standard_EXPORT IGESData_IGESWriter(const IGESData_IGESWriter& other);
0061 
0062   //! Returns the embedded FloatWriter, which controls sending Reals
0063   //! Use this method to access FloatWriter in order to consult or
0064   //! change its options (MainFormat, FormatForRange,ZeroSuppress),
0065   //! because it is returned as the address of its field
0066   Standard_EXPORT Interface_FloatWriter& FloatWriter();
0067 
0068   //! Returns the write mode, in order to be read and/or changed
0069   //! Write Mode controls the way final print works
0070   //! 0 (D) : Normal IGES, 10 : FNES
0071   Standard_EXPORT int& WriteMode();
0072 
0073   //! Sends an additional Starting Line : this is the way used to
0074   //! send comments in an IGES File (at beginning of the file).
0075   //! If the line is more than 72 chars long, it is split into
0076   //! as many lines as required to send it completely
0077   Standard_EXPORT void SendStartLine(const char* const startline);
0078 
0079   //! Sends the complete IGESModel (Global Section, Entities as
0080   //! Directory Entries & Parameter Lists, etc...)
0081   //! i.e. fills a list of texts. Once filled, it can be sent by
0082   //! method Print
0083   Standard_EXPORT void SendModel(const occ::handle<IGESData_Protocol>& protocol);
0084 
0085   //! declares sending of S section (only a declaration)
0086   //! error if state is not initial
0087   Standard_EXPORT void SectionS();
0088 
0089   //! prepares sending of header, from a GlobalSection (stores it)
0090   //! error if SectionS was not called just before
0091   //! takes in account special characters (Separator, EndMark)
0092   Standard_EXPORT void SectionG(const IGESData_GlobalSection& header);
0093 
0094   //! prepares sending of list of entities, as Sections D (directory
0095   //! list) and P (Parameters lists, one per entity)
0096   //! Entities will be then processed, one after the other
0097   //! error if SectionG has not be called just before
0098   Standard_EXPORT void SectionsDP();
0099 
0100   //! declares sending of T section (only a declaration)
0101   //! error if does not follow Entities sending
0102   Standard_EXPORT void SectionT();
0103 
0104   //! translates directory part of an Entity into a literal DirPart
0105   //! Some infos are computed after sending parameters
0106   //! Error if not in sections DP or Stage not "Dir"
0107   Standard_EXPORT void DirPart(const occ::handle<IGESData_IGESEntity>& anent);
0108 
0109   //! sends own parameters of the entity, by sending firstly its
0110   //! type, then calling specific method WriteOwnParams
0111   //! Error if not in sections DP or Stage not "Own"
0112   Standard_EXPORT void OwnParams(const occ::handle<IGESData_IGESEntity>& anent);
0113 
0114   //! sends associativity list, as complement of parameters list
0115   //! error if not in sections DP or Stage not "Associativity"
0116   Standard_EXPORT void Associativities(const occ::handle<IGESData_IGESEntity>& anent);
0117 
0118   //! sends property list, as complement of parameters list
0119   //! error if not in sections DP or Stage not "Property"
0120   Standard_EXPORT void Properties(const occ::handle<IGESData_IGESEntity>& anent);
0121 
0122   //! declares end of sending an entity (ends param list by ';')
0123   Standard_EXPORT void EndEntity();
0124 
0125   //! sends a void parameter, that is null text
0126   Standard_EXPORT void SendVoid();
0127 
0128   //! sends an Integer parameter
0129   Standard_EXPORT void Send(const int val);
0130 
0131   //! sends a Boolean parameter as an Integer value 0(False)/1(True)
0132   Standard_EXPORT void SendBoolean(const bool val);
0133 
0134   //! sends a Real parameter. Works with FloatWriter
0135   Standard_EXPORT void Send(const double val);
0136 
0137   //! sends a Text parameter under Hollerith form
0138   Standard_EXPORT void Send(const occ::handle<TCollection_HAsciiString>& val);
0139 
0140   //! sends a Reference to an Entity (if its Number is N, its
0141   //! pointer is 2*N-1)
0142   //! If <val> is Null, "0" will be sent
0143   //! If <negative> is True, "Pointer" is sent as negative
0144   Standard_EXPORT void Send(const occ::handle<IGESData_IGESEntity>& val,
0145                             const bool                              negative = false);
0146 
0147   //! Helper method to avoid ambiguity of calls to above methods Send() for
0148   //! classes derived from IGESData_IGESEntity, for VC++ 10 and 11 compilers
0149   template <class T>
0150   void Send(const occ::handle<T>& val,
0151             bool                  negative = false,
0152             typename opencascade::std::enable_if<
0153               opencascade::std::is_base_of<IGESData_IGESEntity, T>::value>::type* = nullptr)
0154   {
0155     Send((const occ::handle<IGESData_IGESEntity>&)val, negative);
0156   }
0157 
0158   //! sends a parameter under its exact form given as a string
0159   Standard_EXPORT void SendString(const occ::handle<TCollection_HAsciiString>& val);
0160 
0161   //! Sends a XY, interpreted as a couple of 2 Reals (X & Y)
0162   Standard_EXPORT void Send(const gp_XY& val);
0163 
0164   //! Sends a XYZ, interpreted as a couple of 2 Reals (X , Y & Z)
0165   Standard_EXPORT void Send(const gp_XYZ& val);
0166 
0167   //! Returns the list of strings for a section given its rank
0168   //! 1 : Start (if not empty)  2 : Global  3 or 4 : Parameters
0169   //! RQ: no string list for Directory section
0170   //! An empty section gives a null handle
0171   Standard_EXPORT occ::handle<NCollection_HSequence<occ::handle<TCollection_HAsciiString>>>
0172                   SectionStrings(const int numsec) const;
0173 
0174   //! Writes result on an output defined as an OStream
0175   //! resolves stored infos at this time; in particular, numbers of
0176   //! lines used to address P-section from D-section and final totals
0177   //! Takes WriteMode into account
0178   Standard_EXPORT bool Print(Standard_OStream& S) const;
0179 
0180 private:
0181   //! Basic action of adding a string to current parameter list as a
0182   //! line; manages size limit (64 or 72 according Sestion G or P)
0183   //! <more>, if precised, requires that <more> characters will
0184   //! remain free on the current line once this AddString done
0185   Standard_EXPORT void AddString(const occ::handle<TCollection_HAsciiString>& val,
0186                                  const int                                    more = 0);
0187 
0188   //! Basic action of adding a string to current parameter list as a
0189   //! line. Manages size limit (64 or 72 according Sestion G or P)
0190   //! <val> is the string and <lnval> its length. If <lnval> is not
0191   //! given, it is computed by strlen(val).
0192   //! <more>, if precised, requires that <more> characters will
0193   //! remain free on the current line once this AddString done
0194   Standard_EXPORT void AddString(const char* const val, const int lnval = 0, const int more = 0);
0195 
0196   //! Adds a string defined as a single character (for instance, the
0197   //! parameter separator). Manages size limit
0198   //! <more>, if precised, requires that <more> characters will
0199   //! remain free on the current line once this AddString done
0200   Standard_EXPORT void AddChar(const char val, const int more = 0);
0201 
0202 private:
0203   occ::handle<IGESData_IGESModel>                                           themodel;
0204   occ::handle<NCollection_HSequence<occ::handle<TCollection_HAsciiString>>> thestar;
0205   occ::handle<NCollection_HSequence<occ::handle<TCollection_HAsciiString>>> thehead;
0206   char                                                                      thesep;
0207   char                                                                      theendm;
0208   NCollection_Array1<IGESData_DirPart>                                      thedirs;
0209   NCollection_Array1<int>                                                   thepnum;
0210   occ::handle<NCollection_HSequence<occ::handle<TCollection_HAsciiString>>> thepars;
0211   int                                                                       thesect;
0212   IGESData_ReadStage                                                        thestep;
0213   Interface_LineBuffer                                                      thecurr;
0214   int                                                                       themodew;
0215   Interface_FloatWriter                                                     thefloatw;
0216 };
0217 
0218 #endif // _IGESData_IGESWriter_HeaderFile