1 // Created on: 2004-05-11
2 // Created by: Sergey ZARITCHNY <szy@opencascade.com>
3 // Copyright (c) 2004-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _BinTools_HeaderFile
17 #define _BinTools_HeaderFile
19 #include <BinTools_FormatVersion.hxx>
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Standard_Real.hxx>
25 #include <Standard_Integer.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <Standard_ExtCharacter.hxx>
28 #include <Standard_OStream.hxx>
29 #include <Standard_IStream.hxx>
30 #include <Message_ProgressRange.hxx>
33 class BinTools_ShapeSet;
34 class BinTools_Curve2dSet;
35 class BinTools_CurveSet;
36 class BinTools_SurfaceSet;
37 class BinTools_LocationSet;
40 //! Tool to keep shapes in binary format
47 Standard_EXPORT static Standard_OStream& PutReal (Standard_OStream& OS, const Standard_Real& theValue);
49 Standard_EXPORT static Standard_OStream& PutShortReal (Standard_OStream& OS, const Standard_ShortReal& theValue);
51 Standard_EXPORT static Standard_OStream& PutInteger (Standard_OStream& OS, const Standard_Integer theValue);
53 Standard_EXPORT static Standard_OStream& PutBool (Standard_OStream& OS, const Standard_Boolean theValue);
55 Standard_EXPORT static Standard_OStream& PutExtChar (Standard_OStream& OS, const Standard_ExtCharacter theValue);
57 Standard_EXPORT static Standard_IStream& GetReal (Standard_IStream& IS, Standard_Real& theValue);
59 Standard_EXPORT static Standard_IStream& GetShortReal (Standard_IStream& IS, Standard_ShortReal& theValue);
61 Standard_EXPORT static Standard_IStream& GetInteger (Standard_IStream& IS, Standard_Integer& theValue);
63 Standard_EXPORT static Standard_IStream& GetBool (Standard_IStream& IS, Standard_Boolean& theValue);
65 Standard_EXPORT static Standard_IStream& GetExtChar (Standard_IStream& IS, Standard_ExtCharacter& theValue);
67 //! Writes the shape to the stream in binary format BinTools_FormatVersion_CURRENT.
68 //! This alias writes shape with triangulation data.
69 //! @param theShape [in] the shape to write
70 //! @param theStream [in][out] the stream to output shape into
71 //! @param theRange the range of progress indicator to fill in
72 static void Write (const TopoDS_Shape& theShape,
73 Standard_OStream& theStream,
74 const Message_ProgressRange& theRange = Message_ProgressRange())
76 Write (theShape, theStream, Standard_True, Standard_False,
77 BinTools_FormatVersion_CURRENT, theRange);
80 //! Writes the shape to the stream in binary format of specified version.
81 //! @param theShape [in] the shape to write
82 //! @param theStream [in][out] the stream to output shape into
83 //! @param theWithTriangles [in] flag which specifies whether to save shape with (TRUE) or without (FALSE) triangles;
84 //! has no effect on triangulation-only geometry
85 //! @param theWithNormals [in] flag which specifies whether to save triangulation with (TRUE) or without (FALSE) normals;
86 //! has no effect on triangulation-only geometry
87 //! @param theVersion [in] the BinTools format version
88 //! @param theRange the range of progress indicator to fill in
89 Standard_EXPORT static void Write(const TopoDS_Shape& theShape, Standard_OStream& theStream,
90 const Standard_Boolean theWithTriangles,
91 const Standard_Boolean theWithNormals,
92 const BinTools_FormatVersion theVersion,
93 const Message_ProgressRange& theRange = Message_ProgressRange());
95 //! Reads a shape from <theStream> and returns it in <theShape>.
96 Standard_EXPORT static void Read (TopoDS_Shape& theShape, Standard_IStream& theStream,
97 const Message_ProgressRange& theRange = Message_ProgressRange());
99 //! Writes the shape to the file in binary format BinTools_FormatVersion_CURRENT.
100 //! @param theShape [in] the shape to write
101 //! @param theFile [in] the path to file to output shape into
102 //! @param theRange the range of progress indicator to fill in
103 static Standard_Boolean Write (const TopoDS_Shape& theShape,
104 const Standard_CString theFile,
105 const Message_ProgressRange& theRange = Message_ProgressRange())
107 return Write (theShape, theFile, Standard_True, Standard_False,
108 BinTools_FormatVersion_CURRENT, theRange);
111 //! Writes the shape to the file in binary format of specified version.
112 //! @param theShape [in] the shape to write
113 //! @param theFile [in] the path to file to output shape into
114 //! @param theWithTriangles [in] flag which specifies whether to save shape with (TRUE) or without (FALSE) triangles;
115 //! has no effect on triangulation-only geometry
116 //! @param theWithNormals [in] flag which specifies whether to save triangulation with (TRUE) or without (FALSE) normals;
117 //! has no effect on triangulation-only geometry
118 //! @param theVersion [in] the BinTools format version
119 //! @param theRange the range of progress indicator to fill in
120 Standard_EXPORT static Standard_Boolean Write (const TopoDS_Shape& theShape,
121 const Standard_CString theFile,
122 const Standard_Boolean theWithTriangles,
123 const Standard_Boolean theWithNormals,
124 const BinTools_FormatVersion theVersion,
125 const Message_ProgressRange& theRange = Message_ProgressRange());
127 //! Reads a shape from <theFile> and returns it in <theShape>.
128 Standard_EXPORT static Standard_Boolean Read
129 (TopoDS_Shape& theShape, const Standard_CString theFile,
130 const Message_ProgressRange& theRange = Message_ProgressRange());
143 friend class BinTools_ShapeSet;
144 friend class BinTools_Curve2dSet;
145 friend class BinTools_CurveSet;
146 friend class BinTools_SurfaceSet;
147 friend class BinTools_LocationSet;
157 #endif // _BinTools_HeaderFile