42cf5bc1 |
1 | // Created on: 1996-01-30 |
2 | // Created by: Christian CAILLET |
3 | // Copyright (c) 1996-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 _IGESControl_Writer_HeaderFile |
18 | #define _IGESControl_Writer_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <IGESData_BasicEditor.hxx> |
25 | #include <Standard_Integer.hxx> |
26 | #include <Standard_Boolean.hxx> |
27 | #include <Standard_CString.hxx> |
28 | #include <Standard_OStream.hxx> |
29 | class Transfer_FinderProcess; |
30 | class IGESData_IGESModel; |
31 | class TopoDS_Shape; |
32 | class Standard_Transient; |
33 | class IGESData_IGESEntity; |
34 | |
35 | |
36 | //! This class creates and writes |
37 | //! IGES files from CAS.CADE models. An IGES file can be written to |
38 | //! an existing IGES file or to a new one. |
39 | //! The translation can be performed in one or several |
40 | //! operations. Each translation operation |
41 | //! outputs a distinct root entity in the IGES file. |
42 | //! To write an IGES file it is possible to use the following sequence: |
43 | //! To modify the IGES file header or to change translation |
44 | //! parameters it is necessary to use class Interface_Static (see |
45 | //! IGESParameters and GeneralParameters). |
46 | class IGESControl_Writer |
47 | { |
48 | public: |
49 | |
50 | DEFINE_STANDARD_ALLOC |
42cf5bc1 |
51 | |
52 | //! Creates a writer object with the |
53 | //! default unit (millimeters) and write mode (Face). |
54 | //! IGESControl_Writer (const Standard_CString unit, |
55 | //! const Standard_Integer modecr = 0); |
56 | Standard_EXPORT IGESControl_Writer(); |
57 | |
58 | //! Creates a writer with given |
59 | //! values for units and for write mode. |
60 | //! unit may be any unit that is accepted by the IGES standard. |
61 | //! By default, it is the millimeter. |
62 | //! modecr defines the write mode and may be: |
63 | //! - 0: Faces (default) |
64 | //! - 1: BRep. |
65 | Standard_EXPORT IGESControl_Writer(const Standard_CString unit, const Standard_Integer modecr = 0); |
66 | |
67 | //! Creates a writer object with the |
68 | //! prepared IGES model model in write mode. |
69 | //! modecr defines the write mode and may be: |
70 | //! - 0: Faces (default) |
71 | //! - 1: BRep. |
72 | Standard_EXPORT IGESControl_Writer(const Handle(IGESData_IGESModel)& model, const Standard_Integer modecr = 0); |
73 | |
74 | //! Returns the IGES model to be written in output. |
7f56eba8 |
75 | const Handle(IGESData_IGESModel) & Model() const |
76 | { return myModel; } |
77 | |
78 | const Handle(Transfer_FinderProcess) & TransferProcess() const |
79 | { return myTP; } |
80 | |
42cf5bc1 |
81 | //! Returns/Sets the TransferProcess : it contains final results |
82 | //! and if some, check messages |
7f56eba8 |
83 | void SetTransferProcess (const Handle(Transfer_FinderProcess)& TP) |
84 | { myTP = TP; } |
42cf5bc1 |
85 | |
86 | //! Translates a Shape to IGES Entities and adds them to the model |
87 | //! Returns True if done, False if Shape not suitable for IGES or null |
88 | Standard_EXPORT Standard_Boolean AddShape (const TopoDS_Shape& sh); |
89 | |
90 | //! Translates a Geometry (Surface or Curve) to IGES Entities and |
91 | //! adds them to the model |
92 | //! Returns True if done, False if geom is neither a Surface or |
93 | //! a Curve suitable for IGES or is null |
94 | Standard_EXPORT Standard_Boolean AddGeom (const Handle(Standard_Transient)& geom); |
95 | |
96 | //! Adds an IGES entity (and the ones it references) to the model |
97 | Standard_EXPORT Standard_Boolean AddEntity (const Handle(IGESData_IGESEntity)& ent); |
98 | |
99 | //! Computes the entities found in |
100 | //! the model, which is ready to be written. |
101 | //! This contrasts with the default computation of headers only. |
102 | Standard_EXPORT void ComputeModel(); |
103 | |
104 | //! Computes then writes the model to an OStream |
105 | //! Returns True when done, false in case of error |
106 | Standard_EXPORT Standard_Boolean Write (Standard_OStream& S, const Standard_Boolean fnes = Standard_False); |
107 | |
108 | //! Prepares and writes an IGES model |
109 | //! either to an OStream, S or to a file name,CString. |
110 | //! Returns True if the operation was performed correctly and |
111 | //! False if an error occurred (for instance, |
112 | //! if the processor could not create the file). |
113 | Standard_EXPORT Standard_Boolean Write (const Standard_CString file, const Standard_Boolean fnes = Standard_False); |
42cf5bc1 |
114 | |
7f56eba8 |
115 | private: |
42cf5bc1 |
116 | |
7f56eba8 |
117 | Handle(Transfer_FinderProcess) myTP; |
118 | Handle(IGESData_IGESModel) myModel; |
119 | IGESData_BasicEditor myEditor; |
120 | Standard_Integer myWriteMode; |
121 | Standard_Boolean myIsComputed; |
42cf5bc1 |
122 | }; |
123 | |
42cf5bc1 |
124 | #endif // _IGESControl_Writer_HeaderFile |