1 -- Created on: 1992-04-07
2 -- Created by: Christian CAILLET
3 -- Copyright (c) 1992-1999 Matra Datavision
4 -- Copyright (c) 1999-2014 OPEN CASCADE SAS
6 -- This file is part of Open CASCADE Technology software library.
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
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.
14 -- Alternatively, this file may be used under the terms of Open CASCADE
15 -- commercial license or contractual agreement.
17 class IGESWriter from IGESData
19 ---Purpose : manages atomic file writing, under control of IGESModel :
20 -- prepare text to be sent then sends it
21 -- takes into account distinction between successive Sections
23 uses Integer, Real, Character,
24 HAsciiString from TCollection, HSequenceOfHAsciiString from TColStd,
25 Array1OfInteger from TColStd,
26 IGESModel, GlobalSection, IGESEntity, Array1OfDirPart, ReadStage,
27 Protocol from IGESData, WriterLib, LineBuffer, FloatWriter,
30 raises InterfaceMismatch
34 Create (amodel : IGESModel) returns IGESWriter;
35 ---Purpose : Creates an IGESWriter, empty ready to work
36 -- (see the methods SendModel and Print)
38 Create returns IGESWriter;
39 ---Purpose : Default constructor (not used) to satisfy the compiler
41 Create (other : IGESWriter) returns IGESWriter;
42 ---Purpose : Constructor by copy (not used) to satisfy the compiler
44 -- Options for Sending Forms --
46 FloatWriter (me : in out) returns FloatWriter;
47 ---Purpose : Returns the embedded FloatWriter, which controls sending Reals
48 -- Use this method to access FloatWriter in order to consult or
49 -- change its options (MainFormat, FormatForRange,ZeroSuppress),
50 -- because it is returned as the address of its field
53 WriteMode (me : in out) returns Integer;
54 ---Purpose : Returns the write mode, in order to be read and/or changed
55 -- Write Mode controls the way final print works
56 -- 0 (D) : Normal IGES, 10 : FNES
59 -- -- Management of building file -- --
61 SendStartLine (me : in out; startline : CString);
62 ---Purpose : Sends an additionnal Starting Line : this is the way used to
63 -- send comments in an IGES File (at beginning of the file).
64 -- If the line is more than 72 char.s long, it is splited into
65 -- as many lines as required to send it completely
67 SendModel (me : in out; protocol : Protocol from IGESData);
68 ---Purpose : Sends the complete IGESModel (Global Section, Entities as
69 -- Directory Entries & Parameter Lists, etc...)
70 -- i.e. fills a list of texts. Once filled, it can be sent by
73 SectionS (me : in out) raises InterfaceMismatch;
74 ---Purpose : declares sending of S section (only a declaration)
75 -- error if state is not initial
77 SectionG (me : in out; header : GlobalSection) raises InterfaceMismatch;
78 ---Purpose : prepares sending of header, from a GlobalSection (stores it)
79 -- error if SectionS was not called just before
80 -- takes in account special characters (Separator, EndMark)
82 SectionsDP (me : in out) raises InterfaceMismatch;
83 ---Purpose : prepares sending of list of entities, as Sections D (directory
84 -- list) and P (Parameters lists, one per entity)
85 -- Entities will be then processed, one after the other
86 -- error if SectionG has not be called just before
88 SectionT (me : in out) raises InterfaceMismatch;
89 ---Purpose : declares sending of T section (only a declaration)
90 -- error if does not follow Entities sending
92 DirPart (me : in out; anent : IGESEntity) raises InterfaceMismatch;
93 ---Purpose : translates directory part of an Entity into a litteral DirPart
94 -- Some infos are computed after sending parameters
95 -- Error if not in sections DP or Stage not "Dir"
97 OwnParams (me : in out; anent : IGESEntity) raises InterfaceMismatch;
98 ---Purpose : sends own parameters of the entity, by sending firstly its
99 -- type, then calling specific method WriteOwnParams
100 -- Error if not in sections DP or Stage not "Own"
102 Associativities (me : in out; anent : IGESEntity) raises InterfaceMismatch;
103 ---Purpose : sends associativity list, as complement of parameters list
104 -- error if not in sections DP or Stage not "Associativity"
106 Properties (me : in out; anent : IGESEntity) raises InterfaceMismatch;
107 ---Purpose : sends property list, as complement of parameters list
108 -- error if not in sections DP or Stage not "Property"
110 EndEntity (me : in out) raises InterfaceMismatch;
111 ---Purpose : declares end of sending an entity (ends param list by ';')
113 -- -- Sending parameters (to be used by WriteOwnParams) -- --
115 AddString (me : in out; val : HAsciiString from TCollection;
116 more : Integer = 0) is private;
117 ---Purpose : Basic action of adding a string to current parameter list as a
118 -- line; manages size limit (64 or 72 according Sestion G or P)
119 -- <more>, if precised, requires that <more> characters will
120 -- remain free on the current line once this AddString done
122 AddString (me : in out; val : CString; lnval : Integer = 0;
123 more : Integer = 0) is private;
124 ---Purpose : Basic action of adding a string to current parameter list as a
125 -- line. Manages size limit (64 or 72 according Sestion G or P)
126 -- <val> is the string and <lnval> its length. If <lnval> is not
127 -- given, it is computed by strlen(val).
128 -- <more>, if precised, requires that <more> characters will
129 -- remain free on the current line once this AddString done
131 AddChar (me : in out; val : Character; more : Integer = 0) is private;
132 ---Purpose : Adds a string defined as a single character (for instance, the
133 -- parameter separator). Manages size limit
134 -- <more>, if precised, requires that <more> characters will
135 -- remain free on the current line once this AddString done
138 SendVoid (me : in out);
139 ---Purpose : sends a void parameter, that is null text
141 Send (me : in out; val : Integer);
142 ---Purpose : sends an Integer parameter
144 SendBoolean (me : in out; val : Boolean);
145 ---Purpose : sends a Boolean parameter as an Integer value 0(False)/1(True)
147 Send (me : in out; val : Real);
148 ---Purpose : sends a Real parameter. Works with FloatWriter
150 Send (me : in out; val : HAsciiString from TCollection);
151 ---Purpose : sends a Text parameter under Hollerith form
153 Send (me : in out; val : IGESEntity; negative : Boolean = Standard_False);
154 ---Purpose : sends a Reference to an Entity (if its Number is N, its
156 -- If <val> is Null, "0" will be sent
157 -- If <negative> is True, "Pointer" is sent as negative
158 ---C++: alias "template <class T> void Send (const Handle(T)& val, Standard_Boolean negative = Standard_False, typename std::enable_if<std::is_base_of<IGESData_IGESEntity, T>::value>::type * = 0) { Send ((const Handle(IGESData_IGESEntity)&)val, negative); }"
160 SendString (me : in out; val : HAsciiString from TCollection);
161 ---Purpose : sends a parameter under its exact form given as a string
163 Send (me : in out; val : XY);
164 ---Purpose : Sends a XY, interpreted as a couple of 2 Reals (X & Y)
166 Send (me : in out; val : XYZ);
167 ---Purpose : Sends a XYZ, interpreted as a couple of 2 Reals (X , Y & Z)
169 -- -- Conclusion : printing on an output -- --
171 SectionStrings (me; numsec : Integer)
172 returns HSequenceOfHAsciiString from TColStd;
173 ---Purpose : Returns the list of strings for a section given its rank
174 -- 1 : Start (if not empty) 2 : Global 3 or 4 : Parameters
175 -- RQ: no string list for Directory section
176 -- An empty section gives a null handle
178 Print (me; S : in out OStream) returns Boolean
179 ---Purpose : Writes result on an output defined as an OStream
180 -- resolves stored infos at this time; in particular, numbers of
181 -- lines used to adress P-section from D-section and final totals
182 -- Takes WriteMode into account
183 raises InterfaceMismatch;
184 -- Error if not at Section "T"
188 themodel : IGESModel;
189 thestar : HSequenceOfHAsciiString from TColStd; -- starting lines
190 thehead : HSequenceOfHAsciiString from TColStd; -- parameters for header
192 thesep : Character; -- separator (gotten from GlobalSection)
193 theendm : Character; -- end mark ( id )
194 thedirs : Array1OfDirPart;
195 thepnum : Array1OfInteger from TColStd; -- rank in P-section for each entity
196 thepars : HSequenceOfHAsciiString from TColStd; -- parameters for file
197 thesect : Integer; -- section number (initial:0-S-G-DP-T)
198 thestep : ReadStage; -- step for each entity
199 thecurr : LineBuffer; -- current line (for sections G then P)
201 themodew : Integer; -- control of writing mode
202 thefloatw : FloatWriter; -- control of sending Reals