1 -- Created on: 1994-10-03
2 -- Created by: Christian CAILLET
3 -- Copyright (c) 1994-1999 Matra Datavision
4 -- Copyright (c) 1999-2012 OPEN CASCADE SAS
6 -- The content of this file is subject to the Open CASCADE Technology Public
7 -- License Version 6.5 (the "License"). You may not use the content of this file
8 -- except in compliance with the License. Please obtain a copy of the License
9 -- at http://www.opencascade.org and read it completely before using this file.
11 -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 -- The Original Code and all software distributed under the License is
15 -- distributed on an "AS IS" basis, without warranty of any kind, and the
16 -- Initial Developer hereby disclaims all such warranties, including without
17 -- limitation, any warranties of merchantability, fitness for a particular
18 -- purpose or non-infringement. Please see the License for the specific terms
19 -- and conditions governing the rights and limitations under the License.
23 class Reader from TransferBRep
25 ---Purpose : This class offers a simple, easy to call, way of transferring
26 -- data from interface files to Shapes from CasCade
27 -- It must be specialized according to each norm/protocol, by :
28 -- - defining how to read a file (specific method with protocol)
29 -- - definig transfer, by providing an Actor
31 uses CString, Transient, HSequenceOfTransient from TColStd,
32 Shape from TopoDS, HSequenceOfShape from TopTools,
33 InterfaceModel, Protocol from Interface, CheckIterator,
34 TransientProcess from Transfer, ActorOfTransientProcess from Transfer
40 Create returns Reader;
41 ---Purpose : Initializes a non-specialised Reader. Typically, for each norm
42 -- or protocol, is will be required to define a specific Create
43 -- to load a file and transfer it
45 SetProtocol (me : in out; protocol : Protocol from Interface);
46 ---Purpose : Records the protocol to be used for read and transfer roots
48 Protocol (me) returns Protocol from Interface is virtual;
49 ---Purpose : Returns the recorded Protocol
51 SetActor (me : in out; actor : ActorOfTransientProcess from Transfer);
52 ---Purpose : Records the actor to be used for transfers
54 Actor (me) returns ActorOfTransientProcess is virtual;
55 ---Purpose : Returns the recorded Actor
58 SetFileStatus (me : in out; status : Integer);
59 ---Purpose : Sets File Status to be interpreted as follows :
62 -- > 0 read error, no Model could be created
64 FileStatus (me) returns Integer;
65 ---Purpose : Returns the File Status
67 FileNotFound (me) returns Boolean;
68 ---Purpose : Returns True if FileStatus is for FileNotFound
70 SyntaxError (me) returns Boolean;
71 ---Purpose : Returns True if FileStatus is for Error during read
72 -- (major error; for local error, see CheckModel)
74 SetModel (me : in out; model : InterfaceModel);
75 ---Purpose : Specifies a Model to work on
76 -- Also clears the result and Done status
78 Model (me) returns InterfaceModel;
79 ---Purpose : Returns the Model to be worked on
82 ---Purpose : clears the result and Done status. But not the Model.
84 CheckStatusModel (me; withprint : Boolean) returns Boolean;
85 ---Purpose : Checks the Model. Returns True if there is NO FAIL at all
86 -- (regardless Warnings)
87 -- If <withprint> is True, also sends Checks on standard output
89 CheckListModel (me) returns CheckIterator;
90 ---Purpose : Checks the Model (complete : syntax + semantic) and returns
91 -- the produced Check List
93 ModeNewTransfer (me : in out) returns Boolean;
94 ---Purpose : Returns (by Reference, hence can be changed) the Mode for new
95 -- Transfer : True (D) means that each new Transfer produces a
96 -- new TransferProcess. Else keeps the original one but each
97 -- Transfer clears its (former results are not kept)
100 BeginTransfer (me : in out) returns Boolean;
101 ---Purpose : Initializes the Reader for a Transfer (one,roots, or list)
102 -- Also calls PrepareTransfer
103 -- Returns True when done, False if could not be done
105 EndTransfer (me : in out);
106 ---Purpose : Ebds a Transfer (one, roots or list) by recording its result
108 PrepareTransfer (me : in out) is virtual;
109 ---Purpose : Prepares the Transfer. Also can act on the Actor or change the
110 -- TransientProcess if required.
111 -- Should not set the Actor into the TransientProcess, it is done
112 -- by caller. The provided default does nothing.
114 TransferRoots (me : in out) is virtual;
115 ---Purpose : Transfers all Root Entities which are recognized as Geom-Topol
116 -- The result will be a list of Shapes.
117 -- This method calls user redefinable PrepareTransfer
118 -- Remark : former result is cleared
120 Transfer (me : in out; num : Integer) returns Boolean is virtual;
121 ---Purpose : Transfers an Entity given its rank in the Model (Root or not)
122 -- Returns True if it is recognized as Geom-Topol.
123 -- (But it can have failed : see IsDone)
125 TransferList (me : in out; list : HSequenceOfTransient) is virtual;
126 ---Purpose : Transfers a list of Entities (only the ones also in the Model)
127 -- Remark : former result is cleared
129 IsDone (me) returns Boolean;
130 ---Purpose : Returns True if the LAST Transfer/TransferRoots was a success
132 NbShapes (me) returns Integer;
133 ---Purpose : Returns the count of produced Shapes (roots)
135 Shapes (me) returns HSequenceOfShape;
136 ---Purpose : Returns the complete list of produced Shapes
138 Shape (me; num : Integer = 1) returns Shape from TopoDS
139 ---Purpose : Returns a Shape given its rank, by default the first one
141 -- Error if num < 1 or num > NbShapes
142 ---C++ : return const &
144 ShapeResult (me; ent : Transient) returns Shape from TopoDS;
145 ---Purpose : Returns a Shape produced from a given entity (if it was
146 -- individually transferred or if an intermediate result is
147 -- known). If no Shape is bound with <ent>, returns a Null Shape
148 -- Warning : Runs on the last call to Transfer,TransferRoots,TransferList
150 OneShape (me) returns Shape from TopoDS;
151 ---Purpose : Returns a unique Shape for the result :
152 -- - a void Shape (type = SHAPE) if result is empty
153 -- - a simple Shape if result has only one : returns this one
154 -- - a Compound if result has more than one Shape
156 NbTransients (me) returns Integer;
157 ---Purpose : Returns the count of produced Transient Results (roots)
159 Transients (me) returns HSequenceOfTransient;
160 ---Purpose : Returns the complete list of produced Transient Results
162 Transient (me; num : Integer = 1) returns any Transient
163 ---Purpose : Returns a Transient Root Result, given its rank (by default
166 -- Error if num < 1 or num > NbShapes
169 CheckStatusResult (me; withprints : Boolean) returns Boolean;
170 ---Purpose : Checks the Result of last Transfer (individual or roots, no
171 -- cumulation on several transfers). Returns True if NO fail
172 -- occured during Transfer (queries the TransientProcess)
174 CheckListResult (me) returns CheckIterator;
175 ---Purpose : Checks the Result of last Transfer (individual or roots, no
176 -- cumulation on several transfers) and returns the produced list
178 TransientProcess (me) returns TransientProcess;
179 ---Purpose : Returns the TransientProcess. It records informations about
180 -- the very last transfer done. Null if no transfer yet done.
181 -- Can be used for queries more accurate than the default ones.
183 Destroy (me: in out) is virtual;
184 ---C++ : alias "Standard_EXPORT virtual ~TransferBRep_Reader() { Destroy(); }"
189 theProto : Protocol from Interface;
190 theActor : ActorOfTransientProcess from Transfer;
191 theModel : InterfaceModel;
193 theDone : Boolean is protected;
195 theProc : TransientProcess is protected;
196 theShapes : HSequenceOfShape;
197 theTransi : HSequenceOfTransient;