0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / BinTools / BinTools_ShapeSet.hxx
CommitLineData
42cf5bc1 1// Created on: 2004-05-11
2// Created by: Sergey ZARITCHNY <szy@opencascade.com>
3// Copyright (c) 2004-2014 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef _BinTools_ShapeSet_HeaderFile
17#define _BinTools_ShapeSet_HeaderFile
18
19#include <Standard.hxx>
20#include <Standard_DefineAlloc.hxx>
21#include <Standard_Handle.hxx>
22
23#include <TopTools_IndexedMapOfShape.hxx>
24#include <BinTools_LocationSet.hxx>
25#include <Standard_Integer.hxx>
26#include <BRep_Builder.hxx>
27#include <BinTools_SurfaceSet.hxx>
28#include <BinTools_CurveSet.hxx>
29#include <BinTools_Curve2dSet.hxx>
30#include <TColStd_IndexedMapOfTransient.hxx>
31#include <Standard_Boolean.hxx>
32#include <Standard_OStream.hxx>
33#include <Standard_IStream.hxx>
34#include <TopAbs_ShapeEnum.hxx>
6d8f9f4a 35
42cf5bc1 36class TopoDS_Shape;
37class BinTools_LocationSet;
38
39
40//! Writes topology in OStream in binary format
41class BinTools_ShapeSet
42{
43public:
44
45 DEFINE_STANDARD_ALLOC
46
47
48 //! Builds an empty ShapeSet.
49 //! Parameter <isWithTriangles> is added for XML Persistence
50 Standard_EXPORT BinTools_ShapeSet(const Standard_Boolean isWithTriangles = Standard_False);
51
e6f550da 52 Standard_EXPORT virtual ~BinTools_ShapeSet();
f1fb0901 53
54 //! Return true if shape should be stored with triangles.
55 Standard_Boolean IsWithTriangles() const { return myWithTriangles; }
56
57 //! Define if shape will be stored with triangles.
58 //! Ignored (always written) if face defines only triangulation (no surface).
59 void SetWithTriangles (const Standard_Boolean isWithTriangles) { myWithTriangles = isWithTriangles; }
60
42cf5bc1 61 Standard_EXPORT void SetFormatNb (const Standard_Integer theFormatNb);
62
63 //! two formats available for the moment:
64 //! First: does not write CurveOnSurface UV Points into the file
65 //! on reading calls Check() method.
66 //! Second: stores CurveOnSurface UV Points.
67 //! On reading format is recognized from Version string.
68 Standard_EXPORT Standard_Integer FormatNb() const;
69
70 //! Clears the content of the set.
71 Standard_EXPORT virtual void Clear();
72
73 //! Stores <S> and its sub-shape. Returns the index of <S>.
74 //! The method AddGeometry is called on each sub-shape.
75 Standard_EXPORT Standard_Integer Add (const TopoDS_Shape& S);
76
77 //! Returns the sub-shape of index <I>.
78 Standard_EXPORT const TopoDS_Shape& Shape (const Standard_Integer I) const;
79
80 //! Returns the index of <S>.
81 Standard_EXPORT Standard_Integer Index (const TopoDS_Shape& S) const;
82
83 Standard_EXPORT const BinTools_LocationSet& Locations() const;
84
85 Standard_EXPORT BinTools_LocationSet& ChangeLocations();
86
87 //! Returns number of shapes read from file.
88 Standard_EXPORT Standard_Integer NbShapes() const;
89
90 //! Writes the content of me on the stream <OS> in binary
91 //! format that can be read back by Read.
92 //!
93 //! Writes the locations.
94 //!
95 //! Writes the geometry calling WriteGeometry.
96 //!
97 //! Dumps the shapes from last to first.
98 //! For each shape :
99 //! Write the type.
100 //! calls WriteGeometry(S).
101 //! Write the flags, the subshapes.
6d8f9f4a 102 Standard_EXPORT virtual void Write
103 (Standard_OStream& OS,
104 const Handle(Message_ProgressIndicator)& theProgress = NULL) const;
42cf5bc1 105
106 //! Reads the content of me from the binary stream <IS>. me
107 //! is first cleared.
108 //!
109 //! Reads the locations.
110 //!
111 //! Reads the geometry calling ReadGeometry.
112 //!
113 //! Reads the shapes.
114 //! For each shape
115 //! Reads the type.
116 //! calls ReadGeometry(T,S).
117 //! Reads the flag, the subshapes.
6d8f9f4a 118 Standard_EXPORT virtual void Read
119 (Standard_IStream& IS,
120 const Handle(Message_ProgressIndicator)& theProgress = NULL);
42cf5bc1 121
122 //! Writes on <OS> the shape <S>. Writes the
123 //! orientation, the index of the TShape and the index
124 //! of the Location.
125 Standard_EXPORT virtual void Write (const TopoDS_Shape& S, Standard_OStream& OS) const;
126
127 //! Writes the geometry of me on the stream <OS> in a
128 //! binary format that can be read back by Read.
6d8f9f4a 129 Standard_EXPORT virtual void WriteGeometry
130 (Standard_OStream& OS,
131 const Handle(Message_ProgressIndicator)& theProgress = NULL) const;
42cf5bc1 132
133 //! Reads the geometry of me from the stream <IS>.
6d8f9f4a 134 Standard_EXPORT virtual void ReadGeometry
135 (Standard_IStream& IS,
136 const Handle(Message_ProgressIndicator)& theProgress = NULL);
42cf5bc1 137
138 //! Reads from <IS> a shape and returns it in S.
139 //! <NbShapes> is the number of tshapes in the set.
6d8f9f4a 140 Standard_EXPORT virtual void Read
141 (TopoDS_Shape& S,
142 Standard_IStream& IS, const Standard_Integer NbShapes) const;
42cf5bc1 143
144 //! Writes the geometry of <S> on the stream <OS> in a
145 //! binary format that can be read back by Read.
146 Standard_EXPORT virtual void WriteGeometry (const TopoDS_Shape& S, Standard_OStream& OS) const;
147
148 //! Reads the geometry of a shape of type <T> from the
149 //! stream <IS> and returns it in <S>.
150 Standard_EXPORT virtual void ReadGeometry (const TopAbs_ShapeEnum T, Standard_IStream& IS, TopoDS_Shape& S);
151
152 //! Stores the goemetry of <S>.
153 Standard_EXPORT virtual void AddGeometry (const TopoDS_Shape& S);
154
155 //! Inserts the shape <S2> in the shape <S1>.
156 Standard_EXPORT virtual void AddShapes (TopoDS_Shape& S1, const TopoDS_Shape& S2);
157
158 //! Reads the 3d polygons of me
159 //! from the stream <IS>.
6d8f9f4a 160 Standard_EXPORT void ReadPolygon3D
161 (Standard_IStream& IS,
162 const Handle(Message_ProgressIndicator)& theProgress = NULL);
42cf5bc1 163
164 //! Writes the 3d polygons
165 //! on the stream <OS> in a format that can
166 //! be read back by Read.
6d8f9f4a 167 Standard_EXPORT void WritePolygon3D
168 (Standard_OStream& OS,
169 const Handle(Message_ProgressIndicator)& theProgress = NULL) const;
42cf5bc1 170
171 //! Reads the triangulation of me
172 //! from the stream <IS>.
6d8f9f4a 173 Standard_EXPORT void ReadTriangulation
174 (Standard_IStream& IS,
175 const Handle(Message_ProgressIndicator)& theProgress = NULL);
42cf5bc1 176
177 //! Writes the triangulation
178 //! on the stream <OS> in a format that can
179 //! be read back by Read.
6d8f9f4a 180 Standard_EXPORT void WriteTriangulation
181 (Standard_OStream& OS,
182 const Handle(Message_ProgressIndicator)& theProgress = NULL) const;
42cf5bc1 183
184 //! Reads the polygons on triangulation of me
185 //! from the stream <IS>.
6d8f9f4a 186 Standard_EXPORT void ReadPolygonOnTriangulation
187 (Standard_IStream& IS,
188 const Handle(Message_ProgressIndicator)& theProgress = NULL);
42cf5bc1 189
190 //! Writes the polygons on triangulation
191 //! on the stream <OS> in a format that can
192 //! be read back by Read.
6d8f9f4a 193 Standard_EXPORT void WritePolygonOnTriangulation
194 (Standard_OStream& OS,
195 const Handle(Message_ProgressIndicator)& theProgress = NULL) const;
42cf5bc1 196
42cf5bc1 197private:
198
42cf5bc1 199 TopTools_IndexedMapOfShape myShapes;
200 BinTools_LocationSet myLocations;
201 Standard_Integer myFormatNb;
202 BRep_Builder myBuilder;
203 BinTools_SurfaceSet mySurfaces;
204 BinTools_CurveSet myCurves;
205 BinTools_Curve2dSet myCurves2d;
6b467e52 206 NCollection_IndexedMap<Handle(Poly_Polygon2D), TColStd_MapTransientHasher> myPolygons2D;
207 NCollection_IndexedMap<Handle(Poly_Polygon3D), TColStd_MapTransientHasher> myPolygons3D;
208 NCollection_IndexedMap<Handle(Poly_Triangulation), TColStd_MapTransientHasher> myTriangulations;
209 NCollection_IndexedMap<Handle(Poly_PolygonOnTriangulation), TColStd_MapTransientHasher> myNodes;
42cf5bc1 210 Standard_Boolean myWithTriangles;
211
42cf5bc1 212};
213
42cf5bc1 214#endif // _BinTools_ShapeSet_HeaderFile