Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-28 10:19:15

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_ShapeWriter_HeaderFile
0015 #define _BinTools_ShapeWriter_HeaderFile
0016 
0017 #include <BinTools_ShapeSetBase.hxx>
0018 #include <BinTools_OStream.hxx>
0019 #include <NCollection_DataMap.hxx>
0020 #include <TopTools_ShapeMapHasher.hxx>
0021 
0022 class Geom_Curve;
0023 class Geom2d_Curve;
0024 class Geom_Surface;
0025 class Poly_Polygon3D;
0026 class Poly_PolygonOnTriangulation;
0027 class Poly_Triangulation;
0028 
0029 //! Writes topology in OStream in binary format without grouping of objects by types
0030 //! and using relative positions in a file as references.
0031 class BinTools_ShapeWriter : public BinTools_ShapeSetBase
0032 {
0033 public:
0034   DEFINE_STANDARD_ALLOC
0035 
0036   //! Builds an empty ShapeSet.
0037   //! Parameter <theWithTriangles> is added for XML Persistence
0038   Standard_EXPORT BinTools_ShapeWriter();
0039 
0040   Standard_EXPORT ~BinTools_ShapeWriter() override;
0041 
0042   //! Clears the content of the set.
0043   Standard_EXPORT void Clear() override;
0044 
0045   //! Writes the shape to stream using previously stored shapes and objects to refer them.
0046   Standard_EXPORT void Write(const TopoDS_Shape& theShape, Standard_OStream& theStream) override;
0047 
0048   //! Writes location to the stream (all the needed sub-information or reference if it is already
0049   //! used).
0050   Standard_EXPORT virtual void WriteLocation(BinTools_OStream&      theStream,
0051                                              const TopLoc_Location& theLocation);
0052 
0053 private:
0054   //! Writes shape to the stream (all the needed sub-information or reference if it is already
0055   //! used).
0056   virtual void WriteShape(BinTools_OStream& theStream, const TopoDS_Shape& theShape);
0057   //! Writes curve to the stream (all the needed sub-information or reference if it is already
0058   //! used).
0059   void WriteCurve(BinTools_OStream& theStream, const occ::handle<Geom_Curve>& theCurve);
0060   //! Writes curve2d to the stream (all the needed sub-information or reference if it is already
0061   //! used).
0062   void WriteCurve(BinTools_OStream& theStream, const occ::handle<Geom2d_Curve>& theCurve);
0063   //! Writes surface to the stream.
0064   void WriteSurface(BinTools_OStream& theStream, const occ::handle<Geom_Surface>& theSurface);
0065   //! Writes ploygon3d to the stream.
0066   void WritePolygon(BinTools_OStream& theStream, const occ::handle<Poly_Polygon3D>& thePolygon);
0067   //! Writes polygon on triangulation to the stream.
0068   void WritePolygon(BinTools_OStream&                               theStream,
0069                     const occ::handle<Poly_PolygonOnTriangulation>& thePolygon);
0070   //! Writes triangulation to the stream.
0071   void WriteTriangulation(BinTools_OStream&                      theStream,
0072                           const occ::handle<Poly_Triangulation>& theTriangulation,
0073                           const bool                             theNeedToWriteNormals);
0074 
0075   /// position of the shape previously stored
0076   NCollection_DataMap<TopoDS_Shape, uint64_t, TopTools_ShapeMapHasher>    myShapePos;
0077   NCollection_DataMap<TopLoc_Location, uint64_t>                          myLocationPos;
0078   NCollection_DataMap<occ::handle<Geom_Curve>, uint64_t>                  myCurvePos;
0079   NCollection_DataMap<occ::handle<Geom2d_Curve>, uint64_t>                myCurve2dPos;
0080   NCollection_DataMap<occ::handle<Geom_Surface>, uint64_t>                mySurfacePos;
0081   NCollection_DataMap<occ::handle<Poly_Polygon3D>, uint64_t>              myPolygon3dPos;
0082   NCollection_DataMap<occ::handle<Poly_PolygonOnTriangulation>, uint64_t> myPolygonPos;
0083   NCollection_DataMap<occ::handle<Poly_Triangulation>, uint64_t>          myTriangulationPos;
0084 };
0085 
0086 #endif // _BinTools_ShapeWriter_HeaderFile