Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/TopTools_ShapeSet.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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_ShapeMapHasher.hxx>
0024 #include <NCollection_IndexedMap.hxx>
0025 #include <TopTools_LocationSet.hxx>
0026 #include <Standard_Integer.hxx>
0027 #include <Standard_OStream.hxx>
0028 #include <Standard_IStream.hxx>
0029 #include <TopAbs_ShapeEnum.hxx>
0030 #include <TopTools_FormatVersion.hxx>
0031 
0032 class TopoDS_Shape;
0033 class TCollection_AsciiString;
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   DEFINE_STANDARD_ALLOC
0044 
0045   //! Builds an empty ShapeSet.
0046   Standard_EXPORT TopTools_ShapeSet();
0047 
0048   Standard_EXPORT virtual ~TopTools_ShapeSet();
0049 
0050   //! Sets the TopTools_FormatVersion
0051   Standard_EXPORT void SetFormatNb(const int theFormatNb);
0052 
0053   //! Returns the TopTools_FormatVersion
0054   Standard_EXPORT int FormatNb() const;
0055 
0056   //! Clears the content of the set. This method can be
0057   //! redefined.
0058   Standard_EXPORT virtual void Clear();
0059 
0060   //! Stores <S> and its sub-shape. Returns the index of <S>.
0061   //! The method AddGeometry is called on each sub-shape.
0062   Standard_EXPORT int Add(const TopoDS_Shape& S);
0063 
0064   //! Returns the sub-shape of index <I>.
0065   Standard_EXPORT const TopoDS_Shape& Shape(const int I) const;
0066 
0067   //! Returns the index of <S>.
0068   Standard_EXPORT int Index(const TopoDS_Shape& S) const;
0069 
0070   Standard_EXPORT const TopTools_LocationSet& Locations() const;
0071 
0072   Standard_EXPORT TopTools_LocationSet& ChangeLocations();
0073 
0074   //! Dumps the number of objects in me on the stream <OS>.
0075   //! (Number of shapes of each type)
0076   Standard_EXPORT Standard_OStream& DumpExtent(Standard_OStream& OS) const;
0077 
0078   //! Dumps the number of objects in me in the string S
0079   //! (Number of shapes of each type)
0080   Standard_EXPORT void DumpExtent(TCollection_AsciiString& S) const;
0081 
0082   //! Dumps the content of me on the stream <OS>.
0083   //!
0084   //! Dumps the shapes from first to last.
0085   //! For each Shape
0086   //! Dump the type, the flags, the subshapes
0087   //! calls DumpGeometry(S)
0088   //!
0089   //! Dumps the geometry calling DumpGeometry.
0090   //!
0091   //! Dumps the locations.
0092   Standard_EXPORT virtual void Dump(Standard_OStream& OS) const;
0093 
0094   //! Writes the content of me on the stream <OS> in a
0095   //! format that can be read back by Read.
0096   //!
0097   //! Writes the locations.
0098   //!
0099   //! Writes the geometry calling WriteGeometry.
0100   //!
0101   //! Dumps the shapes from last to first.
0102   //! For each shape:
0103   //! Write the type.
0104   //! calls WriteGeometry(S).
0105   //! Write the flags, the subshapes.
0106   Standard_EXPORT virtual void Write(
0107     Standard_OStream&            OS,
0108     const Message_ProgressRange& theProgress = Message_ProgressRange());
0109 
0110   //! Reads the content of me from the stream <IS>. me
0111   //! is first cleared.
0112   //!
0113   //! Reads the locations.
0114   //!
0115   //! Reads the geometry calling ReadGeometry.
0116   //!
0117   //! Reads the shapes.
0118   //! For each shape
0119   //! Reads the type.
0120   //! calls ReadGeometry(T,S).
0121   //! Reads the flag, the subshapes.
0122   Standard_EXPORT virtual void Read(
0123     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(
0148     Standard_OStream&            OS,
0149     const Message_ProgressRange& theProgress = Message_ProgressRange());
0150 
0151   //! Reads the geometry of me from the stream <IS>.
0152   Standard_EXPORT virtual void ReadGeometry(
0153     Standard_IStream&            IS,
0154     const Message_ProgressRange& theProgress = Message_ProgressRange());
0155 
0156   //! Dumps the geometry of <S> on the stream <OS>.
0157   Standard_EXPORT virtual void DumpGeometry(const TopoDS_Shape& S, Standard_OStream& OS) const;
0158 
0159   //! Writes the geometry of <S> on the stream <OS> in a
0160   //! format that can be read back by Read.
0161   Standard_EXPORT virtual void WriteGeometry(const TopoDS_Shape& S, Standard_OStream& OS) const;
0162 
0163   //! Reads the geometry of a shape of type <T> from the
0164   //! stream <IS> and returns it in <S>.
0165   Standard_EXPORT virtual void ReadGeometry(const TopAbs_ShapeEnum T,
0166                                             Standard_IStream&      IS,
0167                                             TopoDS_Shape&          S);
0168 
0169   //! Inserts the shape <S2> in the shape <S1>. This
0170   //! method must be redefined to use the correct
0171   //! builder.
0172   Standard_EXPORT virtual void AddShapes(TopoDS_Shape& S1, const TopoDS_Shape& S2);
0173 
0174   //! This method is called after each new completed
0175   //! shape. <T> is the type. <S> is the shape. In this
0176   //! class it does nothing, but it gives the opportunity
0177   //! in derived classes to perform extra treatment on
0178   //! shapes.
0179   Standard_EXPORT virtual void Check(const TopAbs_ShapeEnum T, TopoDS_Shape& S);
0180 
0181   //! Returns number of shapes read from file.
0182   Standard_EXPORT int NbShapes() const;
0183 
0184 public:
0185   static const char* const THE_ASCII_VERSIONS[TopTools_FormatVersion_VERSION_3 + 1];
0186 
0187 private:
0188   //! Reads from <IS> a shape and returns it in S.
0189   //! <NbShapes> is the number of tshapes in the set.
0190   Standard_EXPORT void Read(TopoDS_Shape& S, Standard_IStream& IS, const int NbShapes) const;
0191 
0192   NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher> myShapes;
0193   TopTools_LocationSet                                          myLocations;
0194   int                                                           myFormatNb;
0195 };
0196 
0197 #endif // _TopTools_ShapeSet_HeaderFile