Back to home page

EIC code displayed by LXR

 
 

    


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

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