Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:28

0001 // Created on: 1993-07-01
0002 // Created by: Remi LEQUETTE
0003 // Copyright (c) 1993-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _TopTools_ShapeSet_HeaderFile
0018 #define _TopTools_ShapeSet_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 #include <TopTools_IndexedMapOfShape.hxx>
0024 #include <TopTools_LocationSet.hxx>
0025 #include <Standard_Integer.hxx>
0026 #include <Standard_OStream.hxx>
0027 #include <Standard_IStream.hxx>
0028 #include <TopAbs_ShapeEnum.hxx>
0029 #include <TopTools_FormatVersion.hxx>
0030 
0031 class TopoDS_Shape;
0032 class TCollection_AsciiString;
0033 
0034 
0035 //! A ShapeSets    contains  a  Shape    and all   its
0036 //! sub-shapes and locations.  It  can be dump,  write
0037 //! and read.
0038 //!
0039 //! Methods to handle the geometry can be redefined.
0040 class TopTools_ShapeSet 
0041 {
0042 public:
0043 
0044   DEFINE_STANDARD_ALLOC
0045 
0046   
0047   //! Builds an empty ShapeSet.
0048   Standard_EXPORT TopTools_ShapeSet();
0049   
0050   Standard_EXPORT virtual ~TopTools_ShapeSet();
0051   
0052   //! Sets the TopTools_FormatVersion
0053   Standard_EXPORT void SetFormatNb (const Standard_Integer theFormatNb);
0054   
0055   //! Returns the TopTools_FormatVersion
0056   Standard_EXPORT Standard_Integer FormatNb() const;
0057   
0058   //! Clears the content of the set.  This method can be
0059   //! redefined.
0060   Standard_EXPORT virtual void Clear();
0061   
0062   //! Stores <S> and its sub-shape. Returns the index of <S>.
0063   //! The method AddGeometry is called on each sub-shape.
0064   Standard_EXPORT Standard_Integer Add (const TopoDS_Shape& S);
0065   
0066   //! Returns the sub-shape of index <I>.
0067   Standard_EXPORT const TopoDS_Shape& Shape (const Standard_Integer I) const;
0068   
0069   //! Returns the index of <S>.
0070   Standard_EXPORT Standard_Integer Index (const TopoDS_Shape& S) const;
0071   
0072   Standard_EXPORT const TopTools_LocationSet& Locations() const;
0073   
0074   Standard_EXPORT TopTools_LocationSet& ChangeLocations();
0075   
0076   //! Dumps the number of objects in me on the stream <OS>.
0077   //! (Number of shapes of each type)
0078   Standard_EXPORT Standard_OStream& DumpExtent (Standard_OStream& OS) const;
0079   
0080   //! Dumps the number of objects in me in the string S
0081   //! (Number of shapes of each type)
0082   Standard_EXPORT void DumpExtent (TCollection_AsciiString& S) const;
0083   
0084   //! Dumps the content of me on the stream <OS>.
0085   //!
0086   //! Dumps the shapes from first to last.
0087   //! For each Shape
0088   //! Dump the type, the flags, the subshapes
0089   //! calls DumpGeometry(S)
0090   //!
0091   //! Dumps the geometry calling DumpGeometry.
0092   //!
0093   //! Dumps the locations.
0094   Standard_EXPORT virtual void Dump (Standard_OStream& OS) const;
0095   
0096   //! Writes the content of  me  on the stream <OS> in a
0097   //! format that can be read back by Read.
0098   //!
0099   //! Writes the locations.
0100   //!
0101   //! Writes the geometry calling WriteGeometry.
0102   //!
0103   //! Dumps the shapes from last to first.
0104   //! For each shape  :
0105   //! Write the type.
0106   //! calls WriteGeometry(S).
0107   //! Write the flags, the subshapes.
0108   Standard_EXPORT virtual void Write (Standard_OStream& OS,
0109                                       const Message_ProgressRange& theProgress = Message_ProgressRange());
0110   
0111   //! Reads the content of me from the  stream  <IS>. me
0112   //! is first cleared.
0113   //!
0114   //! Reads the locations.
0115   //!
0116   //! Reads the geometry calling ReadGeometry.
0117   //!
0118   //! Reads the shapes.
0119   //! For each shape
0120   //! Reads the type.
0121   //! calls ReadGeometry(T,S).
0122   //! Reads the flag, the subshapes.
0123   Standard_EXPORT virtual void Read (Standard_IStream& IS,
0124                                      const Message_ProgressRange& theProgress = Message_ProgressRange());
0125   
0126   //! Dumps   on  <OS>    the  shape  <S>.   Dumps   the
0127   //! orientation, the index of the TShape and the index
0128   //! of the Location.
0129   Standard_EXPORT void Dump (const TopoDS_Shape& S, Standard_OStream& OS) const;
0130   
0131   //! Writes   on  <OS>   the shape   <S>.    Writes the
0132   //! orientation, the index of the TShape and the index
0133   //! of the Location.
0134   Standard_EXPORT void Write (const TopoDS_Shape& S, Standard_OStream& OS) const;
0135   
0136   //! Reads from <IS> a shape and returns it in S.
0137   Standard_EXPORT void Read (TopoDS_Shape& S, Standard_IStream& IS) const;
0138   
0139   //! Stores the geometry of <S>.
0140   Standard_EXPORT virtual void AddGeometry (const TopoDS_Shape& S);
0141   
0142   //! Dumps the geometry of me on the stream <OS>.
0143   Standard_EXPORT virtual void DumpGeometry (Standard_OStream& OS) const;
0144   
0145   //! Writes the geometry of  me  on the stream <OS> in a
0146   //! format that can be read back by Read.
0147   Standard_EXPORT virtual void WriteGeometry (Standard_OStream& OS,
0148                                               const Message_ProgressRange& theProgress = Message_ProgressRange());
0149   
0150   //! Reads the geometry of me from the  stream  <IS>.
0151   Standard_EXPORT virtual void ReadGeometry (Standard_IStream& IS,
0152                                              const Message_ProgressRange& theProgress = Message_ProgressRange());
0153   
0154   //! Dumps the geometry of <S> on the stream <OS>.
0155   Standard_EXPORT virtual void DumpGeometry (const TopoDS_Shape& S, Standard_OStream& OS) const;
0156   
0157   //! Writes the geometry of <S>  on the stream <OS> in a
0158   //! format that can be read back by Read.
0159   Standard_EXPORT virtual void WriteGeometry (const TopoDS_Shape& S, Standard_OStream& OS) const;
0160   
0161   //! Reads the geometry of a shape of type <T> from the
0162   //! stream <IS> and returns it in <S>.
0163   Standard_EXPORT virtual void ReadGeometry (const TopAbs_ShapeEnum T, Standard_IStream& IS, TopoDS_Shape& S);
0164   
0165   //! Inserts  the shape <S2> in  the  shape <S1>.  This
0166   //! method must be   redefined  to  use   the  correct
0167   //! builder.
0168   Standard_EXPORT virtual void AddShapes (TopoDS_Shape& S1, const TopoDS_Shape& S2);
0169   
0170   //! This method is   called after  each  new  completed
0171   //! shape. <T> is the  type. <S> is  the shape. In this
0172   //! class it does nothing, but it gives the opportunity
0173   //! in derived  classes to perform  extra  treatment on
0174   //! shapes.
0175   Standard_EXPORT virtual void Check (const TopAbs_ShapeEnum T, TopoDS_Shape& S);
0176   
0177   //! Returns number of shapes read from file.
0178   Standard_EXPORT Standard_Integer NbShapes() const;
0179 
0180 public:
0181 
0182   static const Standard_CString THE_ASCII_VERSIONS[TopTools_FormatVersion_VERSION_3 + 1];
0183 
0184 private:
0185 
0186   //! Reads  from <IS>  a shape  and  returns  it in  S.
0187   //! <NbShapes> is the number of tshapes in the set.
0188   Standard_EXPORT void Read (TopoDS_Shape& S, Standard_IStream& IS, const Standard_Integer NbShapes) const;
0189 
0190 
0191   TopTools_IndexedMapOfShape myShapes;
0192   TopTools_LocationSet myLocations;
0193   Standard_Integer myFormatNb;
0194 
0195 };
0196 
0197 #endif // _TopTools_ShapeSet_HeaderFile