Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-01 08:32:04

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 virtual ~BinTools_ShapeWriter();
0041 
0042   //! Clears the content of the set.
0043   Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
0044 
0045   //! Writes the shape to stream using previously stored shapes and objects to refer them.
0046   Standard_EXPORT virtual void Write(const TopoDS_Shape& theShape,
0047                                      Standard_OStream&   theStream) Standard_OVERRIDE;
0048 
0049   //! Writes location to the stream (all the needed sub-information or reference if it is already
0050   //! used).
0051   Standard_EXPORT virtual void WriteLocation(BinTools_OStream&      theStream,
0052                                              const TopLoc_Location& theLocation);
0053 
0054 private:
0055   //! Writes shape to the stream (all the needed sub-information or reference if it is already
0056   //! used).
0057   virtual void WriteShape(BinTools_OStream& theStream, const TopoDS_Shape& theShape);
0058   //! Writes curve to the stream (all the needed sub-information or reference if it is already
0059   //! used).
0060   void WriteCurve(BinTools_OStream& theStream, const Handle(Geom_Curve)& theCurve);
0061   //! Writes curve2d to the stream (all the needed sub-information or reference if it is already
0062   //! used).
0063   void WriteCurve(BinTools_OStream& theStream, const Handle(Geom2d_Curve)& theCurve);
0064   //! Writes surface to the stream.
0065   void WriteSurface(BinTools_OStream& theStream, const Handle(Geom_Surface)& theSurface);
0066   //! Writes ploygon3d to the stream.
0067   void WritePolygon(BinTools_OStream& theStream, const Handle(Poly_Polygon3D)& thePolygon);
0068   //! Writes polygon on triangulation to the stream.
0069   void WritePolygon(BinTools_OStream&                          theStream,
0070                     const Handle(Poly_PolygonOnTriangulation)& thePolygon);
0071   //! Writes triangulation to the stream.
0072   void WriteTriangulation(BinTools_OStream&                 theStream,
0073                           const Handle(Poly_Triangulation)& theTriangulation,
0074                           const Standard_Boolean            theNeedToWriteNormals);
0075 
0076   /// position of the shape previously stored
0077   NCollection_DataMap<TopoDS_Shape, uint64_t, TopTools_ShapeMapHasher> myShapePos;
0078   NCollection_DataMap<TopLoc_Location, uint64_t>                       myLocationPos;
0079   NCollection_DataMap<Handle(Geom_Curve), uint64_t>                    myCurvePos;
0080   NCollection_DataMap<Handle(Geom2d_Curve), uint64_t>                  myCurve2dPos;
0081   NCollection_DataMap<Handle(Geom_Surface), uint64_t>                  mySurfacePos;
0082   NCollection_DataMap<Handle(Poly_Polygon3D), uint64_t>                myPolygon3dPos;
0083   NCollection_DataMap<Handle(Poly_PolygonOnTriangulation), uint64_t>   myPolygonPos;
0084   NCollection_DataMap<Handle(Poly_Triangulation), uint64_t>            myTriangulationPos;
0085 };
0086 
0087 #endif // _BinTools_ShapeWriter_HeaderFile