Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:00

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 
0030 //! Tool to keep shapes in binary format
0031 class BinTools 
0032 {
0033 public:
0034 
0035   DEFINE_STANDARD_ALLOC
0036 
0037   Standard_EXPORT static Standard_OStream& PutReal (Standard_OStream& OS, const Standard_Real& theValue);
0038 
0039   Standard_EXPORT static Standard_OStream& PutShortReal (Standard_OStream& OS, const Standard_ShortReal& theValue);
0040 
0041   Standard_EXPORT static Standard_OStream& PutInteger (Standard_OStream& OS, const Standard_Integer theValue);
0042   
0043   Standard_EXPORT static Standard_OStream& PutBool (Standard_OStream& OS, const Standard_Boolean theValue);
0044   
0045   Standard_EXPORT static Standard_OStream& PutExtChar (Standard_OStream& OS, const Standard_ExtCharacter theValue);
0046 
0047   Standard_EXPORT static Standard_IStream& GetReal (Standard_IStream& IS, Standard_Real& theValue);
0048 
0049   Standard_EXPORT static Standard_IStream& GetShortReal (Standard_IStream& IS, Standard_ShortReal& theValue);
0050 
0051   Standard_EXPORT static Standard_IStream& GetInteger (Standard_IStream& IS, Standard_Integer& theValue);
0052   
0053   Standard_EXPORT static Standard_IStream& GetBool (Standard_IStream& IS, Standard_Boolean& theValue);
0054   
0055   Standard_EXPORT static Standard_IStream& GetExtChar (Standard_IStream& IS, Standard_ExtCharacter& theValue);
0056 
0057   //! Writes the shape to the stream in binary format BinTools_FormatVersion_CURRENT.
0058   //! This alias writes shape with triangulation data.
0059   //! @param theShape [in]       the shape to write
0060   //! @param theStream [in][out] the stream to output shape into
0061   //! @param theRange            the range of progress indicator to fill in
0062   static void Write (const TopoDS_Shape& theShape,
0063                      Standard_OStream& theStream,
0064                      const Message_ProgressRange& theRange = Message_ProgressRange())
0065   {
0066     Write (theShape, theStream, Standard_True, Standard_False,
0067            BinTools_FormatVersion_CURRENT, theRange);
0068   }
0069 
0070   //! Writes the shape to the stream in binary format of specified version.
0071   //! @param theShape [in]         the shape to write
0072   //! @param theStream [in][out]   the stream to output shape into
0073   //! @param theWithTriangles [in] flag which specifies whether to save shape with (TRUE) or without (FALSE) triangles;
0074   //!                              has no effect on triangulation-only geometry
0075   //! @param theWithNormals [in]   flag which specifies whether to save triangulation with (TRUE) or without (FALSE) normals;
0076   //!                              has no effect on triangulation-only geometry
0077   //! @param theVersion [in]       the BinTools format version
0078   //! @param theRange              the range of progress indicator to fill in
0079   Standard_EXPORT static void Write(const TopoDS_Shape& theShape, Standard_OStream& theStream,
0080                                     const Standard_Boolean theWithTriangles,
0081                                     const Standard_Boolean theWithNormals,
0082                                     const BinTools_FormatVersion theVersion,
0083                                     const Message_ProgressRange& theRange = Message_ProgressRange());
0084 
0085   //! Reads a shape from <theStream> and returns it in <theShape>.
0086   Standard_EXPORT static void Read (TopoDS_Shape& theShape, Standard_IStream& theStream,
0087                                     const Message_ProgressRange& theRange = Message_ProgressRange());
0088 
0089   //! Writes the shape to the file in binary format BinTools_FormatVersion_CURRENT.
0090   //! @param theShape [in] the shape to write
0091   //! @param theFile [in]  the path to file to output shape into
0092   //! @param theRange      the range of progress indicator to fill in
0093   static Standard_Boolean Write (const TopoDS_Shape& theShape,
0094                                  const Standard_CString theFile,
0095                                  const Message_ProgressRange& theRange = Message_ProgressRange())
0096   {
0097     return Write (theShape, theFile, Standard_True, Standard_False,
0098                   BinTools_FormatVersion_CURRENT, theRange);
0099   }
0100 
0101   //! Writes the shape to the file in binary format of specified version.
0102   //! @param theShape [in]         the shape to write
0103   //! @param theFile [in]          the path to file to output shape into
0104   //! @param theWithTriangles [in] flag which specifies whether to save shape with (TRUE) or without (FALSE) triangles;
0105   //!                              has no effect on triangulation-only geometry
0106   //! @param theWithNormals [in]   flag which specifies whether to save triangulation with (TRUE) or without (FALSE) normals;
0107   //!                              has no effect on triangulation-only geometry
0108   //! @param theVersion [in]       the BinTools format version
0109   //! @param theRange              the range of progress indicator to fill in
0110   Standard_EXPORT static Standard_Boolean Write (const TopoDS_Shape& theShape,
0111                                                  const Standard_CString theFile,
0112                                                  const Standard_Boolean theWithTriangles,
0113                                                  const Standard_Boolean theWithNormals,
0114                                                  const BinTools_FormatVersion theVersion,
0115                                                  const Message_ProgressRange& theRange = Message_ProgressRange());
0116 
0117   //! Reads a shape from <theFile> and returns it in <theShape>.
0118   Standard_EXPORT static Standard_Boolean Read
0119     (TopoDS_Shape& theShape, const Standard_CString theFile,
0120      const Message_ProgressRange& theRange = Message_ProgressRange());
0121 
0122 };
0123 
0124 #endif // _BinTools_HeaderFile