Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-24 09:15:47

0001 // Created on: 2004-05-11
0002 // Created by: Sergey ZARITCHNY <szy@opencascade.com>
0003 // Copyright (c) 2004-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _BinTools_HeaderFile
0017 #define _BinTools_HeaderFile
0018 
0019 #include <BinTools_FormatVersion.hxx>
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_Real.hxx>
0025 #include <Message_ProgressRange.hxx>
0026 
0027 class TopoDS_Shape;
0028 
0029 //! Tool to keep shapes in binary format
0030 class BinTools
0031 {
0032 public:
0033   DEFINE_STANDARD_ALLOC
0034 
0035   Standard_EXPORT static Standard_OStream& PutReal(Standard_OStream&    OS,
0036                                                    const Standard_Real& theValue);
0037 
0038   Standard_EXPORT static Standard_OStream& PutShortReal(Standard_OStream&         OS,
0039                                                         const Standard_ShortReal& theValue);
0040 
0041   Standard_EXPORT static Standard_OStream& PutInteger(Standard_OStream&      OS,
0042                                                       const Standard_Integer theValue);
0043 
0044   Standard_EXPORT static Standard_OStream& PutBool(Standard_OStream&      OS,
0045                                                    const Standard_Boolean theValue);
0046 
0047   Standard_EXPORT static Standard_OStream& PutExtChar(Standard_OStream&           OS,
0048                                                       const Standard_ExtCharacter theValue);
0049 
0050   Standard_EXPORT static Standard_IStream& GetReal(Standard_IStream& IS, Standard_Real& theValue);
0051 
0052   Standard_EXPORT static Standard_IStream& GetShortReal(Standard_IStream&   IS,
0053                                                         Standard_ShortReal& theValue);
0054 
0055   Standard_EXPORT static Standard_IStream& GetInteger(Standard_IStream& IS,
0056                                                       Standard_Integer& theValue);
0057 
0058   Standard_EXPORT static Standard_IStream& GetBool(Standard_IStream& IS,
0059                                                    Standard_Boolean& theValue);
0060 
0061   Standard_EXPORT static Standard_IStream& GetExtChar(Standard_IStream&      IS,
0062                                                       Standard_ExtCharacter& theValue);
0063 
0064   //! Writes the shape to the stream in binary format BinTools_FormatVersion_CURRENT.
0065   //! This alias writes shape with triangulation data.
0066   //! @param[in] theShape        the shape to write
0067   //! @param[in][out] theStream  the stream to output shape into
0068   //! @param theRange            the range of progress indicator to fill in
0069   static void Write(const TopoDS_Shape&          theShape,
0070                     Standard_OStream&            theStream,
0071                     const Message_ProgressRange& theRange = Message_ProgressRange())
0072   {
0073     Write(theShape,
0074           theStream,
0075           Standard_True,
0076           Standard_False,
0077           BinTools_FormatVersion_CURRENT,
0078           theRange);
0079   }
0080 
0081   //! Writes the shape to the stream in binary format of specified version.
0082   //! @param[in] theShape          the shape to write
0083   //! @param[in][out] theStream    the stream to output shape into
0084   //! @param[in] theWithTriangles  flag which specifies whether to save shape with (TRUE) or without
0085   //! (FALSE) triangles;
0086   //!                              has no effect on triangulation-only geometry
0087   //! @param[in] theWithNormals    flag which specifies whether to save triangulation with (TRUE) or
0088   //! without (FALSE) normals;
0089   //!                              has no effect on triangulation-only geometry
0090   //! @param[in] theVersion        the BinTools format version
0091   //! @param theRange              the range of progress indicator to fill in
0092   Standard_EXPORT static void Write(
0093     const TopoDS_Shape&          theShape,
0094     Standard_OStream&            theStream,
0095     const Standard_Boolean       theWithTriangles,
0096     const Standard_Boolean       theWithNormals,
0097     const BinTools_FormatVersion theVersion,
0098     const Message_ProgressRange& theRange = Message_ProgressRange());
0099 
0100   //! Reads a shape from <theStream> and returns it in <theShape>.
0101   Standard_EXPORT static void Read(TopoDS_Shape&                theShape,
0102                                    Standard_IStream&            theStream,
0103                                    const Message_ProgressRange& theRange = Message_ProgressRange());
0104 
0105   //! Writes the shape to the file in binary format BinTools_FormatVersion_CURRENT.
0106   //! @param[in] theShape  the shape to write
0107   //! @param[in] theFile   the path to file to output shape into
0108   //! @param theRange      the range of progress indicator to fill in
0109   static Standard_Boolean Write(const TopoDS_Shape&          theShape,
0110                                 const Standard_CString       theFile,
0111                                 const Message_ProgressRange& theRange = Message_ProgressRange())
0112   {
0113     return Write(theShape,
0114                  theFile,
0115                  Standard_True,
0116                  Standard_False,
0117                  BinTools_FormatVersion_CURRENT,
0118                  theRange);
0119   }
0120 
0121   //! Writes the shape to the file in binary format of specified version.
0122   //! @param[in] theShape          the shape to write
0123   //! @param[in] theFile           the path to file to output shape into
0124   //! @param[in] theWithTriangles  flag which specifies whether to save shape with (TRUE) or without
0125   //! (FALSE) triangles;
0126   //!                              has no effect on triangulation-only geometry
0127   //! @param[in] theWithNormals    flag which specifies whether to save triangulation with (TRUE) or
0128   //! without (FALSE) normals;
0129   //!                              has no effect on triangulation-only geometry
0130   //! @param[in] theVersion        the BinTools format version
0131   //! @param theRange              the range of progress indicator to fill in
0132   Standard_EXPORT static Standard_Boolean Write(
0133     const TopoDS_Shape&          theShape,
0134     const Standard_CString       theFile,
0135     const Standard_Boolean       theWithTriangles,
0136     const Standard_Boolean       theWithNormals,
0137     const BinTools_FormatVersion theVersion,
0138     const Message_ProgressRange& theRange = Message_ProgressRange());
0139 
0140   //! Reads a shape from <theFile> and returns it in <theShape>.
0141   Standard_EXPORT static Standard_Boolean Read(
0142     TopoDS_Shape&                theShape,
0143     const Standard_CString       theFile,
0144     const Message_ProgressRange& theRange = Message_ProgressRange());
0145 };
0146 
0147 #endif // _BinTools_HeaderFile