Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-04 08:31:41

0001 // Created on: 2004-05-11
0002 // Created by: Sergey ZARITCHNY <szy@opencascade.com>
0003 // Copyright (c) 2004-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _BinTools_ShapeSet_HeaderFile
0017 #define _BinTools_ShapeSet_HeaderFile
0018 
0019 #include <BinTools_ShapeSetBase.hxx>
0020 
0021 #include <TopTools_IndexedMapOfShape.hxx>
0022 #include <BinTools_LocationSet.hxx>
0023 #include <BRep_Builder.hxx>
0024 #include <BinTools_SurfaceSet.hxx>
0025 #include <BinTools_CurveSet.hxx>
0026 #include <BinTools_Curve2dSet.hxx>
0027 #include <TColStd_IndexedMapOfTransient.hxx>
0028 #include <Standard_OStream.hxx>
0029 #include <Standard_IStream.hxx>
0030 
0031 //! Writes topology in OStream in binary format
0032 class BinTools_ShapeSet : public BinTools_ShapeSetBase
0033 {
0034 public:
0035   DEFINE_STANDARD_ALLOC
0036 
0037   //! Builds an empty ShapeSet.
0038   //! @param[in] theWithTriangles  flag to write triangulation data
0039   Standard_EXPORT BinTools_ShapeSet();
0040 
0041   Standard_EXPORT virtual ~BinTools_ShapeSet();
0042 
0043   //! Clears the content of the set.
0044   Standard_EXPORT virtual void Clear();
0045 
0046   //! Stores <S> and its sub-shape. Returns the index of <S>.
0047   //! The method AddGeometry is called on each sub-shape.
0048   Standard_EXPORT Standard_Integer Add(const TopoDS_Shape& S);
0049 
0050   //! Returns the sub-shape of index <I>.
0051   Standard_EXPORT const TopoDS_Shape& Shape(const Standard_Integer I);
0052 
0053   //! Returns the index of <S>.
0054   Standard_EXPORT Standard_Integer Index(const TopoDS_Shape& S) const;
0055 
0056   Standard_EXPORT const BinTools_LocationSet& Locations() const;
0057 
0058   Standard_EXPORT BinTools_LocationSet& ChangeLocations();
0059 
0060   //! Returns number of shapes read from file.
0061   Standard_EXPORT Standard_Integer NbShapes() const;
0062 
0063   //! Writes the content of  me  on the stream <OS> in binary
0064   //! format that can be read back by Read.
0065   //!
0066   //! Writes the locations.
0067   //!
0068   //! Writes the geometry calling WriteGeometry.
0069   //!
0070   //! Dumps the shapes from last to first.
0071   //! For each shape  :
0072   //! Write the type.
0073   //! calls WriteGeometry(S).
0074   //! Write the flags, the subshapes.
0075   Standard_EXPORT virtual void Write(
0076     Standard_OStream&            OS,
0077     const Message_ProgressRange& theRange = Message_ProgressRange());
0078 
0079   //! Reads the content of me from the binary stream  <IS>. me
0080   //! is first cleared.
0081   //!
0082   //! Reads the locations.
0083   //!
0084   //! Reads the geometry calling ReadGeometry.
0085   //!
0086   //! Reads the shapes.
0087   //! For each shape
0088   //! Reads the type.
0089   //! calls ReadGeometry(T,S).
0090   //! Reads the flag, the subshapes.
0091   Standard_EXPORT virtual void Read(
0092     Standard_IStream&            IS,
0093     const Message_ProgressRange& theRange = Message_ProgressRange());
0094 
0095   //! Writes   on  <OS>   the shape   <S>.    Writes the
0096   //! orientation, the index of the TShape and the index
0097   //! of the Location.
0098   Standard_EXPORT virtual void Write(const TopoDS_Shape& S, Standard_OStream& OS);
0099 
0100   //! Writes the geometry of  me  on the stream <OS> in a
0101   //! binary format that can be read back by Read.
0102   Standard_EXPORT virtual void WriteGeometry(
0103     Standard_OStream&            OS,
0104     const Message_ProgressRange& theRange = Message_ProgressRange()) const;
0105 
0106   //! Reads the geometry of me from the  stream  <IS>.
0107   Standard_EXPORT virtual void ReadGeometry(
0108     Standard_IStream&            IS,
0109     const Message_ProgressRange& theRange = Message_ProgressRange());
0110 
0111   //! Reads from <IS> a shape flags and sub-shapes and modifies S.
0112   Standard_EXPORT virtual void ReadFlagsAndSubs(TopoDS_Shape&          S,
0113                                                 const TopAbs_ShapeEnum T,
0114                                                 Standard_IStream&      IS,
0115                                                 const Standard_Integer NbShapes);
0116 
0117   //! Reads from <IS> a shape and returns it in S.
0118   //! <NbShapes> is the number of tshapes in the set.
0119   Standard_EXPORT virtual void ReadSubs(TopoDS_Shape&          S,
0120                                         Standard_IStream&      IS,
0121                                         const Standard_Integer NbShapes);
0122 
0123   //! An empty virtual method for redefinition in shape-reader.
0124   Standard_EXPORT virtual void Read(Standard_IStream& /*theStream*/, TopoDS_Shape& /*theShape*/) {};
0125 
0126   //! Writes the shape <S> on the stream <OS> in a
0127   //! binary format that can be read back by Read.
0128   Standard_EXPORT virtual void WriteShape(const TopoDS_Shape& S, Standard_OStream& OS) const;
0129 
0130   //! Reads  a shape of type <T> from the stream <IS> and returns it in <S>.
0131   Standard_EXPORT virtual void ReadShape(const TopAbs_ShapeEnum T,
0132                                          Standard_IStream&      IS,
0133                                          TopoDS_Shape&          S);
0134 
0135   //! Stores the shape <S>.
0136   Standard_EXPORT virtual void AddShape(const TopoDS_Shape& S);
0137 
0138   //! Inserts  the shape <S2> in the shape <S1>.
0139   Standard_EXPORT virtual void AddShapes(TopoDS_Shape& S1, const TopoDS_Shape& S2);
0140 
0141   //! Reads the 3d polygons  of me
0142   //! from the  stream  <IS>.
0143   Standard_EXPORT void ReadPolygon3D(
0144     Standard_IStream&            IS,
0145     const Message_ProgressRange& theRange = Message_ProgressRange());
0146 
0147   //! Writes the 3d polygons
0148   //! on the stream <OS> in a format that can
0149   //! be read back by Read.
0150   Standard_EXPORT void WritePolygon3D(
0151     Standard_OStream&            OS,
0152     const Message_ProgressRange& theRange = Message_ProgressRange()) const;
0153 
0154   //! Reads the triangulation of me
0155   //! from the  stream  <IS>.
0156   Standard_EXPORT void ReadTriangulation(
0157     Standard_IStream&            IS,
0158     const Message_ProgressRange& theRange = Message_ProgressRange());
0159 
0160   //! Writes the triangulation
0161   //! on the stream <OS> in a format that can
0162   //! be read back by Read.
0163   Standard_EXPORT void WriteTriangulation(
0164     Standard_OStream&            OS,
0165     const Message_ProgressRange& theRange = Message_ProgressRange()) const;
0166 
0167   //! Reads the polygons on triangulation of me
0168   //! from the  stream  <IS>.
0169   Standard_EXPORT void ReadPolygonOnTriangulation(
0170     Standard_IStream&            IS,
0171     const Message_ProgressRange& theRange = Message_ProgressRange());
0172 
0173   //! Writes the polygons on triangulation
0174   //! on the stream <OS> in a format that can
0175   //! be read back by Read.
0176   Standard_EXPORT void WritePolygonOnTriangulation(
0177     Standard_OStream&            OS,
0178     const Message_ProgressRange& theRange = Message_ProgressRange()) const;
0179 
0180 private:
0181   TopTools_IndexedMapOfShape                     myShapes; ///< index and its shape (started from 1)
0182   BinTools_LocationSet                           myLocations;
0183   BRep_Builder                                   myBuilder;
0184   BinTools_SurfaceSet                            mySurfaces;
0185   BinTools_CurveSet                              myCurves;
0186   BinTools_Curve2dSet                            myCurves2d;
0187   NCollection_IndexedMap<Handle(Poly_Polygon2D)> myPolygons2D;
0188   NCollection_IndexedMap<Handle(Poly_Polygon3D)> myPolygons3D;
0189   NCollection_IndexedDataMap<Handle(Poly_Triangulation),
0190                              // clang-format off
0191                              Standard_Boolean> myTriangulations; //!< Contains a boolean flag with information
0192                                                                  //!  to save normals for triangulation
0193   // clang-format on
0194   NCollection_IndexedMap<Handle(Poly_PolygonOnTriangulation)> myNodes;
0195 };
0196 
0197 #endif // _BinTools_ShapeSet_HeaderFile