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_ShapeSetBase_HeaderFile
0015 #define _BinTools_ShapeSetBase_HeaderFile
0016 
0017 #include <Standard.hxx>
0018 #include <Standard_DefineAlloc.hxx>
0019 #include <Standard_Handle.hxx>
0020 
0021 #include <Standard_OStream.hxx>
0022 #include <Standard_IStream.hxx>
0023 #include <Message_ProgressRange.hxx>
0024 #include <BinTools_FormatVersion.hxx>
0025 
0026 class TopoDS_Shape;
0027 class gp_Pnt;
0028 
0029 //! Writes to the stream a gp_Pnt data
0030 Standard_OStream& operator << (Standard_OStream& OS, const gp_Pnt& P);
0031 
0032 //! A base class for all readers/writers of TopoDS_Shape into/from stream.
0033 class BinTools_ShapeSetBase
0034 {
0035 public:
0036 
0037   DEFINE_STANDARD_ALLOC
0038 
0039   
0040   //! A default constructor.
0041   Standard_EXPORT BinTools_ShapeSetBase();
0042   
0043   Standard_EXPORT virtual ~BinTools_ShapeSetBase();
0044 
0045   //! Return true if shape should be stored with triangles.
0046   Standard_Boolean IsWithTriangles() const { return myWithTriangles; }
0047   //! Return true if shape should be stored triangulation with normals.
0048   Standard_Boolean IsWithNormals() const { return myWithNormals; }
0049 
0050   //! Define if shape will be stored with triangles.
0051   //! Ignored (always written) if face defines only triangulation (no surface).
0052   void SetWithTriangles (const Standard_Boolean theWithTriangles) { myWithTriangles = theWithTriangles; }
0053   //! Define if shape will be stored triangulation with normals.
0054   //! Ignored (always written) if face defines only triangulation (no surface).
0055   void SetWithNormals(const Standard_Boolean theWithNormals) { myWithNormals = theWithNormals; }
0056 
0057   //! Sets the BinTools_FormatVersion.
0058   Standard_EXPORT void SetFormatNb (const Standard_Integer theFormatNb);
0059 
0060   //! Returns the BinTools_FormatVersion.
0061   Standard_EXPORT Standard_Integer FormatNb() const { return myFormatNb; }
0062   
0063   //! Clears the content of the set.
0064   Standard_EXPORT virtual void Clear() {}
0065   
0066   //! Writes the content of  me  on the stream <OS> in binary
0067   //! format that can be read back by Read.
0068   //!
0069   //! Writes the locations.
0070   //!
0071   //! Writes the geometry calling WriteGeometry.
0072   //!
0073   //! Dumps the shapes from last to first.
0074   //! For each shape  :
0075   //! Write the type.
0076   //! calls WriteGeometry(S).
0077   //! Write the flags, the subshapes.
0078   Standard_EXPORT virtual void Write
0079     (Standard_OStream& /*OS*/, const Message_ProgressRange& /*theRange*/ = Message_ProgressRange()) {}
0080   
0081   //! Reads the content of me from the binary stream  <IS>. me
0082   //! is first cleared.
0083   //!
0084   //! Reads the locations.
0085   //!
0086   //! Reads the geometry calling ReadGeometry.
0087   //!
0088   //! Reads the shapes.
0089   //! For each shape
0090   //! Reads the type.
0091   //! calls ReadGeometry(T,S).
0092   //! Reads the flag, the subshapes.
0093   Standard_EXPORT virtual void Read
0094     (Standard_IStream& /*IS*/, const Message_ProgressRange& /*theRange*/ = Message_ProgressRange()) {}
0095   
0096   //! Writes   on  <OS>   the shape   <S>.    Writes the
0097   //! orientation, the index of the TShape and the index
0098   //! of the Location.
0099   Standard_EXPORT virtual void Write (const TopoDS_Shape& /*theShape*/, Standard_OStream& /*theStream*/) {}
0100   
0101   //! An empty virtual method for redefinition in shape-reader.
0102   Standard_EXPORT virtual void Read (Standard_IStream& /*theStream*/, TopoDS_Shape& /*theShape*/) {}
0103                                                                                     
0104   static const Standard_CString THE_ASCII_VERSIONS[BinTools_FormatVersion_UPPER + 1];
0105 private:
0106 
0107   Standard_Integer myFormatNb;
0108   Standard_Boolean myWithTriangles;
0109   Standard_Boolean myWithNormals;
0110 };
0111 
0112 #endif // _BinTools_ShapeSet_HeaderFile