Back to home page

EIC code displayed by LXR

 
 

    


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

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 
0032 //! Writes topology in OStream in binary format
0033 class BinTools_ShapeSet : public BinTools_ShapeSetBase
0034 {
0035 public:
0036 
0037   DEFINE_STANDARD_ALLOC
0038 
0039   //! Builds an empty ShapeSet.
0040   //! @param theWithTriangles [in] flag to write triangulation data
0041   Standard_EXPORT BinTools_ShapeSet ();
0042 
0043   Standard_EXPORT virtual ~BinTools_ShapeSet();
0044 
0045   //! Clears the content of the set.
0046   Standard_EXPORT virtual void Clear();
0047   
0048   //! Stores <S> and its sub-shape. Returns the index of <S>.
0049   //! The method AddGeometry is called on each sub-shape.
0050   Standard_EXPORT Standard_Integer Add (const TopoDS_Shape& S);
0051   
0052   //! Returns the sub-shape of index <I>.
0053   Standard_EXPORT const TopoDS_Shape& Shape (const Standard_Integer I);
0054   
0055   //! Returns the index of <S>.
0056   Standard_EXPORT Standard_Integer Index (const TopoDS_Shape& S) const;
0057   
0058   Standard_EXPORT const BinTools_LocationSet& Locations() const;
0059   
0060   Standard_EXPORT BinTools_LocationSet& ChangeLocations();
0061   
0062   //! Returns number of shapes read from file.
0063   Standard_EXPORT Standard_Integer NbShapes() const;
0064   
0065   //! Writes the content of  me  on the stream <OS> in binary
0066   //! format that can be read back by Read.
0067   //!
0068   //! Writes the locations.
0069   //!
0070   //! Writes the geometry calling WriteGeometry.
0071   //!
0072   //! Dumps the shapes from last to first.
0073   //! For each shape  :
0074   //! Write the type.
0075   //! calls WriteGeometry(S).
0076   //! Write the flags, the subshapes.
0077   Standard_EXPORT virtual void Write
0078     (Standard_OStream& OS,
0079      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,
0095      const Message_ProgressRange& theRange = Message_ProgressRange());
0096   
0097   //! Writes   on  <OS>   the shape   <S>.    Writes the
0098   //! orientation, the index of the TShape and the index
0099   //! of the Location.
0100   Standard_EXPORT virtual void Write (const TopoDS_Shape& S, Standard_OStream& OS);
0101   
0102   //! Writes the geometry of  me  on the stream <OS> in a
0103   //! binary format that can be read back by Read.
0104   Standard_EXPORT virtual void WriteGeometry
0105     (Standard_OStream& OS,
0106      const Message_ProgressRange& theRange = Message_ProgressRange()) const;
0107   
0108   //! Reads the geometry of me from the  stream  <IS>.
0109   Standard_EXPORT virtual void ReadGeometry
0110     (Standard_IStream& IS,
0111      const Message_ProgressRange& theRange = Message_ProgressRange());
0112   
0113   //! Reads from <IS> a shape flags and sub-shapes and modifies S.
0114   Standard_EXPORT virtual void ReadFlagsAndSubs
0115     (TopoDS_Shape& S, const TopAbs_ShapeEnum T,
0116      Standard_IStream& IS, const Standard_Integer NbShapes);
0117 
0118   //! Reads from <IS> a shape and returns it in S.
0119   //! <NbShapes> is the number of tshapes in the set.
0120   Standard_EXPORT virtual void ReadSubs
0121   (TopoDS_Shape& S, Standard_IStream& IS, 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, Standard_IStream& IS, TopoDS_Shape& S);
0132 
0133   //! Stores the shape <S>.
0134   Standard_EXPORT virtual void AddShape (const TopoDS_Shape& S);
0135   
0136   //! Inserts  the shape <S2> in the shape <S1>.
0137   Standard_EXPORT virtual void AddShapes (TopoDS_Shape& S1, const TopoDS_Shape& S2);
0138   
0139   //! Reads the 3d polygons  of me
0140   //! from the  stream  <IS>.
0141   Standard_EXPORT void ReadPolygon3D
0142     (Standard_IStream& IS,
0143         const Message_ProgressRange& theRange = Message_ProgressRange());
0144   
0145   //! Writes the 3d polygons
0146   //! on the stream <OS> in a format that can
0147   //! be read back by Read.
0148   Standard_EXPORT void WritePolygon3D
0149     (Standard_OStream& OS,
0150         const Message_ProgressRange& theRange = Message_ProgressRange()) const;
0151   
0152   //! Reads the triangulation of me
0153   //! from the  stream  <IS>.
0154   Standard_EXPORT void ReadTriangulation
0155     (Standard_IStream& IS,
0156         const Message_ProgressRange& theRange = Message_ProgressRange());
0157   
0158   //! Writes the triangulation
0159   //! on the stream <OS> in a format that can
0160   //! be read back by Read.
0161   Standard_EXPORT void WriteTriangulation
0162     (Standard_OStream& OS,
0163         const Message_ProgressRange& theRange = Message_ProgressRange()) const;
0164   
0165   //! Reads the polygons on triangulation of me
0166   //! from the  stream  <IS>.
0167   Standard_EXPORT void ReadPolygonOnTriangulation
0168     (Standard_IStream& IS,
0169         const Message_ProgressRange& theRange = Message_ProgressRange());
0170   
0171   //! Writes the polygons on triangulation
0172   //! on the stream <OS> in a format that can
0173   //! be read back by Read.
0174   Standard_EXPORT void WritePolygonOnTriangulation
0175     (Standard_OStream& OS,
0176         const Message_ProgressRange& theRange = Message_ProgressRange()) const;
0177 
0178 private:
0179 
0180   TopTools_IndexedMapOfShape myShapes; ///< index and its shape (started from 1)
0181   BinTools_LocationSet myLocations;
0182   BRep_Builder myBuilder;
0183   BinTools_SurfaceSet mySurfaces;
0184   BinTools_CurveSet myCurves;
0185   BinTools_Curve2dSet myCurves2d;
0186   NCollection_IndexedMap<Handle(Poly_Polygon2D)> myPolygons2D;
0187   NCollection_IndexedMap<Handle(Poly_Polygon3D)> myPolygons3D;
0188   NCollection_IndexedDataMap<Handle(Poly_Triangulation),
0189                              Standard_Boolean> myTriangulations; //!< Contains a boolean flag with information
0190                                                                  //!  to save normals for triangulation
0191   NCollection_IndexedMap<Handle(Poly_PolygonOnTriangulation)> myNodes;
0192 };
0193 
0194 #endif // _BinTools_ShapeSet_HeaderFile