42cf5bc1 |
1 | // Created on: 1994-10-03 |
2 | // Created by: Christian CAILLET |
3 | // Copyright (c) 1994-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
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. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _TransferBRep_Reader_HeaderFile |
18 | #define _TransferBRep_Reader_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <Standard_Integer.hxx> |
25 | #include <Standard_Boolean.hxx> |
26 | #include <TopTools_HSequenceOfShape.hxx> |
27 | #include <TColStd_HSequenceOfTransient.hxx> |
28 | class Interface_Protocol; |
29 | class Transfer_ActorOfTransientProcess; |
30 | class Interface_InterfaceModel; |
31 | class Transfer_TransientProcess; |
32 | class Standard_OutOfRange; |
33 | class Interface_CheckIterator; |
34 | class TopoDS_Shape; |
35 | class Standard_Transient; |
36 | |
37 | |
38 | //! This class offers a simple, easy to call, way of transferring |
39 | //! data from interface files to Shapes from CasCade |
40 | //! It must be specialized according to each norm/protocol, by : |
41 | //! - defining how to read a file (specific method with protocol) |
42 | //! - definig transfer, by providing an Actor |
43 | class TransferBRep_Reader |
44 | { |
45 | public: |
46 | |
47 | DEFINE_STANDARD_ALLOC |
48 | |
49 | |
50 | //! Initializes a non-specialised Reader. Typically, for each norm |
51 | //! or protocol, is will be required to define a specific Create |
52 | //! to load a file and transfer it |
53 | Standard_EXPORT TransferBRep_Reader(); |
54 | |
55 | //! Records the protocol to be used for read and transfer roots |
56 | Standard_EXPORT void SetProtocol (const Handle(Interface_Protocol)& protocol); |
57 | |
58 | //! Returns the recorded Protocol |
59 | Standard_EXPORT virtual Handle(Interface_Protocol) Protocol() const; |
60 | |
61 | //! Records the actor to be used for transfers |
62 | Standard_EXPORT void SetActor (const Handle(Transfer_ActorOfTransientProcess)& actor); |
63 | |
64 | //! Returns the recorded Actor |
65 | Standard_EXPORT virtual Handle(Transfer_ActorOfTransientProcess) Actor() const; |
66 | |
67 | //! Sets File Status to be interpreted as follows : |
68 | //! = 0 OK |
69 | //! < 0 file not found |
70 | //! > 0 read error, no Model could be created |
71 | Standard_EXPORT void SetFileStatus (const Standard_Integer status); |
72 | |
73 | //! Returns the File Status |
74 | Standard_EXPORT Standard_Integer FileStatus() const; |
75 | |
76 | //! Returns True if FileStatus is for FileNotFound |
77 | Standard_EXPORT Standard_Boolean FileNotFound() const; |
78 | |
79 | //! Returns True if FileStatus is for Error during read |
80 | //! (major error; for local error, see CheckModel) |
81 | Standard_EXPORT Standard_Boolean SyntaxError() const; |
82 | |
83 | //! Specifies a Model to work on |
84 | //! Also clears the result and Done status |
85 | Standard_EXPORT void SetModel (const Handle(Interface_InterfaceModel)& model); |
86 | |
87 | //! Returns the Model to be worked on |
88 | Standard_EXPORT Handle(Interface_InterfaceModel) Model() const; |
89 | |
90 | //! clears the result and Done status. But not the Model. |
91 | Standard_EXPORT void Clear(); |
92 | |
93 | //! Checks the Model. Returns True if there is NO FAIL at all |
94 | //! (regardless Warnings) |
95 | //! If <withprint> is True, also sends Checks on standard output |
96 | Standard_EXPORT Standard_Boolean CheckStatusModel (const Standard_Boolean withprint) const; |
97 | |
98 | //! Checks the Model (complete : syntax + semantic) and returns |
99 | //! the produced Check List |
100 | Standard_EXPORT Interface_CheckIterator CheckListModel() const; |
101 | |
102 | //! Returns (by Reference, hence can be changed) the Mode for new |
103 | //! Transfer : True (D) means that each new Transfer produces a |
104 | //! new TransferProcess. Else keeps the original one but each |
105 | //! Transfer clears its (former results are not kept) |
106 | Standard_EXPORT Standard_Boolean& ModeNewTransfer(); |
107 | |
108 | //! Initializes the Reader for a Transfer (one,roots, or list) |
109 | //! Also calls PrepareTransfer |
110 | //! Returns True when done, False if could not be done |
111 | Standard_EXPORT Standard_Boolean BeginTransfer(); |
112 | |
113 | //! Ebds a Transfer (one, roots or list) by recording its result |
114 | Standard_EXPORT void EndTransfer(); |
115 | |
116 | //! Prepares the Transfer. Also can act on the Actor or change the |
117 | //! TransientProcess if required. |
118 | //! Should not set the Actor into the TransientProcess, it is done |
119 | //! by caller. The provided default does nothing. |
120 | Standard_EXPORT virtual void PrepareTransfer(); |
121 | |
122 | //! Transfers all Root Entities which are recognized as Geom-Topol |
123 | //! The result will be a list of Shapes. |
124 | //! This method calls user redefinable PrepareTransfer |
125 | //! Remark : former result is cleared |
126 | Standard_EXPORT virtual void TransferRoots(); |
127 | |
128 | //! Transfers an Entity given its rank in the Model (Root or not) |
129 | //! Returns True if it is recognized as Geom-Topol. |
130 | //! (But it can have failed : see IsDone) |
131 | Standard_EXPORT virtual Standard_Boolean Transfer (const Standard_Integer num); |
132 | |
133 | //! Transfers a list of Entities (only the ones also in the Model) |
134 | //! Remark : former result is cleared |
135 | Standard_EXPORT virtual void TransferList (const Handle(TColStd_HSequenceOfTransient)& list); |
136 | |
137 | //! Returns True if the LAST Transfer/TransferRoots was a success |
138 | Standard_EXPORT Standard_Boolean IsDone() const; |
139 | |
140 | //! Returns the count of produced Shapes (roots) |
141 | Standard_EXPORT Standard_Integer NbShapes() const; |
142 | |
143 | //! Returns the complete list of produced Shapes |
144 | Standard_EXPORT Handle(TopTools_HSequenceOfShape) Shapes() const; |
145 | |
146 | //! Returns a Shape given its rank, by default the first one |
147 | Standard_EXPORT const TopoDS_Shape& Shape (const Standard_Integer num = 1) const; |
148 | |
149 | //! Returns a Shape produced from a given entity (if it was |
150 | //! individually transferred or if an intermediate result is |
151 | //! known). If no Shape is bound with <ent>, returns a Null Shape |
152 | //! Warning : Runs on the last call to Transfer,TransferRoots,TransferList |
153 | Standard_EXPORT TopoDS_Shape ShapeResult (const Handle(Standard_Transient)& ent) const; |
154 | |
155 | //! Returns a unique Shape for the result : |
156 | //! - a void Shape (type = SHAPE) if result is empty |
157 | //! - a simple Shape if result has only one : returns this one |
158 | //! - a Compound if result has more than one Shape |
159 | Standard_EXPORT TopoDS_Shape OneShape() const; |
160 | |
161 | //! Returns the count of produced Transient Results (roots) |
162 | Standard_EXPORT Standard_Integer NbTransients() const; |
163 | |
164 | //! Returns the complete list of produced Transient Results |
165 | Standard_EXPORT Handle(TColStd_HSequenceOfTransient) Transients() const; |
166 | |
167 | //! Returns a Transient Root Result, given its rank (by default |
168 | //! the first one) |
169 | Standard_EXPORT Handle(Standard_Transient) Transient (const Standard_Integer num = 1) const; |
170 | |
171 | //! Checks the Result of last Transfer (individual or roots, no |
172 | //! cumulation on several transfers). Returns True if NO fail |
173 | //! occured during Transfer (queries the TransientProcess) |
174 | Standard_EXPORT Standard_Boolean CheckStatusResult (const Standard_Boolean withprints) const; |
175 | |
176 | //! Checks the Result of last Transfer (individual or roots, no |
177 | //! cumulation on several transfers) and returns the produced list |
178 | Standard_EXPORT Interface_CheckIterator CheckListResult() const; |
179 | |
180 | //! Returns the TransientProcess. It records informations about |
181 | //! the very last transfer done. Null if no transfer yet done. |
182 | //! Can be used for queries more accurate than the default ones. |
183 | Standard_EXPORT Handle(Transfer_TransientProcess) TransientProcess() const; |
184 | |
185 | Standard_EXPORT virtual void Destroy(); |
186 | Standard_EXPORT virtual ~TransferBRep_Reader() { Destroy(); } |
187 | |
188 | |
189 | |
190 | |
191 | protected: |
192 | |
193 | |
194 | |
195 | Standard_Boolean theDone; |
196 | Handle(Transfer_TransientProcess) theProc; |
197 | |
198 | |
199 | private: |
200 | |
201 | |
202 | |
203 | Handle(Interface_Protocol) theProto; |
204 | Handle(Transfer_ActorOfTransientProcess) theActor; |
205 | Handle(Interface_InterfaceModel) theModel; |
206 | Standard_Integer theFilest; |
207 | Standard_Boolean theNewpr; |
208 | Handle(TopTools_HSequenceOfShape) theShapes; |
209 | Handle(TColStd_HSequenceOfTransient) theTransi; |
210 | |
211 | |
212 | }; |
213 | |
214 | |
215 | |
216 | |
217 | |
218 | |
219 | |
220 | #endif // _TransferBRep_Reader_HeaderFile |