1 // Created on: 1993-07-01
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _TopTools_ShapeSet_HeaderFile
18 #define _TopTools_ShapeSet_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <TopTools_IndexedMapOfShape.hxx>
25 #include <TopTools_LocationSet.hxx>
26 #include <Standard_Integer.hxx>
27 #include <Standard_OStream.hxx>
28 #include <Standard_IStream.hxx>
29 #include <TopAbs_ShapeEnum.hxx>
30 class Message_ProgressIndicator;
32 class TopTools_LocationSet;
33 class TCollection_AsciiString;
36 //! A ShapeSets contains a Shape and all its
37 //! sub-shapes and locations. It can be dump, write
40 //! Methods to handle the geometry can be redefined.
41 class TopTools_ShapeSet
48 //! Builds an empty ShapeSet.
49 Standard_EXPORT TopTools_ShapeSet();
51 Standard_EXPORT virtual ~TopTools_ShapeSet();
53 Standard_EXPORT void SetFormatNb (const Standard_Integer theFormatNb);
55 //! two formats available for the moment:
56 //! First: does not write CurveOnSurface UV Points into the file
57 //! on reading calls Check() method.
58 //! Second: stores CurveOnSurface UV Points.
59 //! On reading format is recognized from Version string.
60 Standard_EXPORT Standard_Integer FormatNb() const;
62 //! Clears the content of the set. This method can be
64 Standard_EXPORT virtual void Clear();
66 //! Stores <S> and its sub-shape. Returns the index of <S>.
67 //! The method AddGeometry is called on each sub-shape.
68 Standard_EXPORT Standard_Integer Add (const TopoDS_Shape& S);
70 //! Returns the sub-shape of index <I>.
71 Standard_EXPORT const TopoDS_Shape& Shape (const Standard_Integer I) const;
73 //! Returns the index of <S>.
74 Standard_EXPORT Standard_Integer Index (const TopoDS_Shape& S) const;
76 Standard_EXPORT const TopTools_LocationSet& Locations() const;
78 Standard_EXPORT TopTools_LocationSet& ChangeLocations();
80 //! Dumps the number of objects in me on the stream <OS>.
81 //! (Number of shapes of each type)
82 Standard_EXPORT Standard_OStream& DumpExtent (Standard_OStream& OS) const;
84 //! Dumps the number of objects in me in the string S
85 //! (Number of shapes of each type)
86 Standard_EXPORT void DumpExtent (TCollection_AsciiString& S) const;
88 //! Dumps the content of me on the stream <OS>.
90 //! Dumps the shapes from first to last.
92 //! Dump the type, the flags, the subshapes
93 //! calls DumpGeometry(S)
95 //! Dumps the geometry calling DumpGeometry.
97 //! Dumps the locations.
98 Standard_EXPORT virtual void Dump (Standard_OStream& OS) const;
100 //! Writes the content of me on the stream <OS> in a
101 //! format that can be read back by Read.
103 //! Writes the locations.
105 //! Writes the geometry calling WriteGeometry.
107 //! Dumps the shapes from last to first.
110 //! calls WriteGeometry(S).
111 //! Write the flags, the subshapes.
112 Standard_EXPORT virtual void Write (Standard_OStream& OS);
114 //! Reads the content of me from the stream <IS>. me
115 //! is first cleared.
117 //! Reads the locations.
119 //! Reads the geometry calling ReadGeometry.
121 //! Reads the shapes.
124 //! calls ReadGeometry(T,S).
125 //! Reads the flag, the subshapes.
126 Standard_EXPORT virtual void Read (Standard_IStream& IS);
128 //! Dumps on <OS> the shape <S>. Dumps the
129 //! orientation, the index of the TShape and the index
131 Standard_EXPORT void Dump (const TopoDS_Shape& S, Standard_OStream& OS) const;
133 //! Writes on <OS> the shape <S>. Writes the
134 //! orientation, the index of the TShape and the index
136 Standard_EXPORT void Write (const TopoDS_Shape& S, Standard_OStream& OS) const;
138 //! Reads from <IS> a shape and returns it in S.
139 Standard_EXPORT void Read (TopoDS_Shape& S, Standard_IStream& IS) const;
141 //! Stores the geometry of <S>.
142 Standard_EXPORT virtual void AddGeometry (const TopoDS_Shape& S);
144 //! Dumps the geometry of me on the stream <OS>.
145 Standard_EXPORT virtual void DumpGeometry (Standard_OStream& OS) const;
147 //! Writes the geometry of me on the stream <OS> in a
148 //! format that can be read back by Read.
149 Standard_EXPORT virtual void WriteGeometry (Standard_OStream& OS);
151 //! Reads the geometry of me from the stream <IS>.
152 Standard_EXPORT virtual void ReadGeometry (Standard_IStream& IS);
154 //! Dumps the geometry of <S> on the stream <OS>.
155 Standard_EXPORT virtual void DumpGeometry (const TopoDS_Shape& S, Standard_OStream& OS) const;
157 //! Writes the geometry of <S> on the stream <OS> in a
158 //! format that can be read back by Read.
159 Standard_EXPORT virtual void WriteGeometry (const TopoDS_Shape& S, Standard_OStream& OS) const;
161 //! Reads the geometry of a shape of type <T> from the
162 //! stream <IS> and returns it in <S>.
163 Standard_EXPORT virtual void ReadGeometry (const TopAbs_ShapeEnum T, Standard_IStream& IS, TopoDS_Shape& S);
165 //! Inserts the shape <S2> in the shape <S1>. This
166 //! method must be redefined to use the correct
168 Standard_EXPORT virtual void AddShapes (TopoDS_Shape& S1, const TopoDS_Shape& S2);
170 //! This method is called after each new completed
171 //! shape. <T> is the type. <S> is the shape. In this
172 //! class it does nothing, but it gives the opportunity
173 //! in derived classes to perform extra treatment on
175 Standard_EXPORT virtual void Check (const TopAbs_ShapeEnum T, TopoDS_Shape& S);
177 //! Returns number of shapes read from file.
178 Standard_EXPORT Standard_Integer NbShapes() const;
180 Standard_EXPORT void SetProgress (const Handle(Message_ProgressIndicator)& PR);
182 Standard_EXPORT Handle(Message_ProgressIndicator) GetProgress() const;
196 //! Reads from <IS> a shape and returns it in S.
197 //! <NbShapes> is the number of tshapes in the set.
198 Standard_EXPORT void Read (TopoDS_Shape& S, Standard_IStream& IS, const Standard_Integer NbShapes) const;
201 TopTools_IndexedMapOfShape myShapes;
202 TopTools_LocationSet myLocations;
203 Standard_Integer myFormatNb;
204 Handle(Message_ProgressIndicator) myProgress;
215 #endif // _TopTools_ShapeSet_HeaderFile