Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Copyright (c) 2021 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _BinTools_OStream_HeaderFile
0015 #define _BinTools_OStream_HeaderFile
0016 
0017 #include <BinTools.hxx>
0018 #include <BinTools_ObjectType.hxx>
0019 #include <TopAbs_ShapeEnum.hxx>
0020 #include <TopAbs_Orientation.hxx>
0021 #include <gp_Pnt.hxx>
0022 #include <Poly_Triangle.hxx>
0023 #include <gp_Vec3f.hxx>
0024 
0025 //! Substitution of OStream for shape writer for fast management of position in the file
0026 //! and operation on all writing types.
0027 class BinTools_OStream
0028 {
0029 public:
0030 
0031   //! Creates OStream using the current stream OStream.
0032   Standard_EXPORT BinTools_OStream (Standard_OStream& theStream);
0033 
0034   //! Returns the current position of the stream
0035   Standard_EXPORT const uint64_t& Position() { return myPosition; }
0036   //! Writes the reference to the given position (an offset between the current and the given one).
0037   Standard_EXPORT void WriteReference (const uint64_t& thePosition);
0038   //! Writes an identifier of shape type and orientation into the stream.
0039   Standard_EXPORT void WriteShape (const TopAbs_ShapeEnum& theType, const TopAbs_Orientation& theOrientation);
0040 
0041 
0042   //! Writes an object type to the stream.
0043   Standard_EXPORT BinTools_OStream& operator << (const BinTools_ObjectType& theType);
0044   //! Writes a byte to the stream.
0045   Standard_EXPORT BinTools_OStream& operator << (const Standard_Byte& theValue);
0046   //! Writes a real to the stream.
0047   Standard_EXPORT BinTools_OStream& operator << (const Standard_Real& theValue);
0048   //! Writes a boolean to the stream.
0049   Standard_EXPORT BinTools_OStream& operator << (const Standard_Boolean& theValue);
0050   //! Writes a integer to the stream.
0051   Standard_EXPORT BinTools_OStream& operator << (const Standard_Integer& theValue);
0052   //! Writes a extended character to the stream.
0053   Standard_EXPORT BinTools_OStream& operator << (const Standard_ExtCharacter& theValue);
0054   //! Writes a 3D point to the stream.
0055   Standard_EXPORT BinTools_OStream& operator << (const gp_Pnt& theValue);
0056   //! Writes a 3D direction to the stream.
0057   Standard_EXPORT BinTools_OStream& operator << (const gp_Dir& theValue);
0058   //! Writes a 2D point to the stream.
0059   Standard_EXPORT BinTools_OStream& operator << (const gp_Pnt2d& theValue);
0060   //! Writes a 2D direction to the stream.
0061   Standard_EXPORT BinTools_OStream& operator << (const gp_Dir2d& theValue);
0062   //! Writes a transformation matrix to the stream.
0063   Standard_EXPORT BinTools_OStream& operator << (const gp_Trsf& theValue);
0064   //! Writes triangle nodes indices to the stream.
0065   Standard_EXPORT BinTools_OStream& operator << (const Poly_Triangle& theValue);
0066   //! Writes a vector to the stream.
0067   Standard_EXPORT BinTools_OStream& operator << (const gp_Vec3f& theValue);
0068 
0069   //! Writes 3 booleans as one byte to the stream.
0070   Standard_EXPORT void PutBools (
0071     const Standard_Boolean theValue1, const Standard_Boolean theValue2, const Standard_Boolean theValue3);
0072 
0073   //! Writes 7 booleans as one byte to the stream.
0074   Standard_EXPORT void PutBools (
0075     const Standard_Boolean theValue1, const Standard_Boolean theValue2, const Standard_Boolean theValue3,
0076     const Standard_Boolean theValue4, const Standard_Boolean theValue5, const Standard_Boolean theValue6,
0077     const Standard_Boolean theValue7);
0078 
0079 private:
0080   Standard_OStream* myStream; ///< pointer to the stream
0081   uint64_t myPosition; ///< the current position relatively to the OStream position at the moment of creation of this class instance
0082   Standard_Real myRealBuf[12]; ///< buffer for 12 reals storage
0083   Standard_Integer myIntBuf[3]; ///< buffer for 3 integers storage
0084   float myFloatBuf[3]; ///< buffer for 3 floats storage
0085 };
0086 
0087 #endif // _BinTools_OStream_HeaderFile