42cf5bc1 |
1 | // Created on: 1993-07-19 |
2 | // Created by: Remi LEQUETTE |
3 | // Copyright (c) 1993-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
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. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _BRepTools_ShapeSet_HeaderFile |
18 | #define _BRepTools_ShapeSet_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <BRep_Builder.hxx> |
25 | #include <GeomTools_SurfaceSet.hxx> |
26 | #include <GeomTools_CurveSet.hxx> |
27 | #include <GeomTools_Curve2dSet.hxx> |
28 | #include <TColStd_IndexedMapOfTransient.hxx> |
29 | #include <Standard_Boolean.hxx> |
30 | #include <TopTools_ShapeSet.hxx> |
31 | #include <Standard_OStream.hxx> |
32 | #include <Standard_IStream.hxx> |
33 | #include <TopAbs_ShapeEnum.hxx> |
6d8f9f4a |
34 | |
42cf5bc1 |
35 | class BRep_Builder; |
36 | class TopoDS_Shape; |
37 | |
38 | |
39 | //! Contains a Shape and all its subshapes, locations |
40 | //! and geometries. |
41 | //! |
42 | //! The topology is inherited from TopTools. |
43 | class BRepTools_ShapeSet : public TopTools_ShapeSet |
44 | { |
45 | public: |
46 | |
47 | DEFINE_STANDARD_ALLOC |
48 | |
42cf5bc1 |
49 | //! Builds an empty ShapeSet. |
14eea829 |
50 | //! @param theWithTriangles flag to write triangulation data |
9f45d35b |
51 | Standard_EXPORT BRepTools_ShapeSet (const Standard_Boolean theWithTriangles = Standard_True, |
52 | const Standard_Boolean theWithNormals = Standard_False); |
42cf5bc1 |
53 | |
54 | //! Builds an empty ShapeSet. |
14eea829 |
55 | //! @param theWithTriangles flag to write triangulation data |
56 | Standard_EXPORT BRepTools_ShapeSet (const BRep_Builder& theBuilder, |
9f45d35b |
57 | const Standard_Boolean theWithTriangles = Standard_True, |
58 | const Standard_Boolean theWithNormals = Standard_False); |
14eea829 |
59 | |
60 | Standard_EXPORT virtual ~BRepTools_ShapeSet(); |
61 | |
62 | //! Return true if shape should be stored with triangles. |
63 | Standard_Boolean IsWithTriangles() const { return myWithTriangles; } |
9f45d35b |
64 | //! Return true if shape should be stored triangulation with normals. |
65 | Standard_Boolean IsWithNormals() const { return myWithNormals; } |
14eea829 |
66 | |
67 | //! Define if shape will be stored with triangles. |
68 | //! Ignored (always written) if face defines only triangulation (no surface). |
69 | void SetWithTriangles (const Standard_Boolean theWithTriangles) { myWithTriangles = theWithTriangles; } |
9f45d35b |
70 | //! Define if shape will be stored triangulation with normals. |
71 | //! Ignored (always written) if face defines only triangulation (no surface). |
72 | void SetWithNormals (const Standard_Boolean theWithNormals) { myWithNormals = theWithNormals; } |
14eea829 |
73 | |
42cf5bc1 |
74 | //! Clears the content of the set. |
75 | Standard_EXPORT virtual void Clear() Standard_OVERRIDE; |
76 | |
77 | //! Stores the goemetry of <S>. |
78 | Standard_EXPORT virtual void AddGeometry (const TopoDS_Shape& S) Standard_OVERRIDE; |
79 | |
80 | //! Dumps the geometry of me on the stream <OS>. |
81 | Standard_EXPORT virtual void DumpGeometry (Standard_OStream& OS) const Standard_OVERRIDE; |
82 | |
83 | //! Writes the geometry of me on the stream <OS> in a |
84 | //! format that can be read back by Read. |
7e785937 |
85 | Standard_EXPORT virtual void WriteGeometry (Standard_OStream& OS, |
86 | const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE; |
42cf5bc1 |
87 | |
88 | //! Reads the geometry of me from the stream <IS>. |
7e785937 |
89 | Standard_EXPORT virtual void ReadGeometry (Standard_IStream& IS, |
90 | const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE; |
42cf5bc1 |
91 | |
92 | //! Dumps the geometry of <S> on the stream <OS>. |
7e785937 |
93 | Standard_EXPORT virtual void DumpGeometry (const TopoDS_Shape& S, Standard_OStream& OS) const Standard_OVERRIDE; |
42cf5bc1 |
94 | |
95 | //! Writes the geometry of <S> on the stream <OS> in a |
96 | //! format that can be read back by Read. |
7e785937 |
97 | Standard_EXPORT virtual void WriteGeometry (const TopoDS_Shape& S, Standard_OStream& OS) const Standard_OVERRIDE; |
42cf5bc1 |
98 | |
99 | //! Reads the geometry of a shape of type <T> from the |
100 | //! stream <IS> and returns it in <S>. |
7e785937 |
101 | Standard_EXPORT virtual void ReadGeometry (const TopAbs_ShapeEnum T, Standard_IStream& IS, TopoDS_Shape& S) Standard_OVERRIDE; |
42cf5bc1 |
102 | |
103 | //! Inserts the shape <S2> in the shape <S1>. This |
104 | //! method must be redefined to use the correct |
105 | //! builder. |
106 | Standard_EXPORT virtual void AddShapes (TopoDS_Shape& S1, const TopoDS_Shape& S2) Standard_OVERRIDE; |
107 | |
108 | Standard_EXPORT virtual void Check (const TopAbs_ShapeEnum T, TopoDS_Shape& S) Standard_OVERRIDE; |
109 | |
110 | //! Reads the 3d polygons of me |
111 | //! from the stream <IS>. |
7e785937 |
112 | Standard_EXPORT void ReadPolygon3D (Standard_IStream& IS, |
113 | const Message_ProgressRange& theProgress = Message_ProgressRange()); |
42cf5bc1 |
114 | |
115 | //! Writes the 3d polygons |
116 | //! on the stream <OS> in a format that can |
117 | //! be read back by Read. |
7e785937 |
118 | Standard_EXPORT void WritePolygon3D (Standard_OStream& OS, |
119 | const Standard_Boolean Compact = Standard_True, |
120 | const Message_ProgressRange& theProgress = Message_ProgressRange()) const; |
42cf5bc1 |
121 | |
122 | //! Dumps the 3d polygons |
123 | //! on the stream <OS>. |
124 | Standard_EXPORT void DumpPolygon3D (Standard_OStream& OS) const; |
125 | |
126 | //! Reads the triangulation of me |
127 | //! from the stream <IS>. |
7e785937 |
128 | Standard_EXPORT void ReadTriangulation (Standard_IStream& IS, |
129 | const Message_ProgressRange& theProgress = Message_ProgressRange()); |
42cf5bc1 |
130 | |
131 | //! Writes the triangulation |
132 | //! on the stream <OS> in a format that can |
133 | //! be read back by Read. |
7e785937 |
134 | Standard_EXPORT void WriteTriangulation (Standard_OStream& OS, |
135 | const Standard_Boolean Compact = Standard_True, |
136 | const Message_ProgressRange& theProgress = Message_ProgressRange()) const; |
42cf5bc1 |
137 | |
138 | //! Dumps the triangulation |
139 | //! on the stream <OS>. |
140 | Standard_EXPORT void DumpTriangulation (Standard_OStream& OS) const; |
141 | |
142 | //! Reads the polygons on triangulation of me |
143 | //! from the stream <IS>. |
7e785937 |
144 | Standard_EXPORT void ReadPolygonOnTriangulation (Standard_IStream& IS, |
145 | const Message_ProgressRange& theProgress = Message_ProgressRange()); |
42cf5bc1 |
146 | |
147 | //! Writes the polygons on triangulation |
148 | //! on the stream <OS> in a format that can |
149 | //! be read back by Read. |
7e785937 |
150 | Standard_EXPORT void WritePolygonOnTriangulation (Standard_OStream& OS, |
151 | const Standard_Boolean Compact = Standard_True, |
152 | const Message_ProgressRange& theProgress = Message_ProgressRange()) const; |
42cf5bc1 |
153 | |
154 | //! Dumps the polygons on triangulation |
155 | //! on the stream <OS>. |
156 | Standard_EXPORT void DumpPolygonOnTriangulation (Standard_OStream& OS) const; |
157 | |
7e785937 |
158 | |
159 | |
160 | |
161 | protected: |
162 | |
163 | |
164 | |
165 | |
166 | |
42cf5bc1 |
167 | private: |
168 | |
7e785937 |
169 | |
170 | |
42cf5bc1 |
171 | BRep_Builder myBuilder; |
172 | GeomTools_SurfaceSet mySurfaces; |
173 | GeomTools_CurveSet myCurves; |
174 | GeomTools_Curve2dSet myCurves2d; |
175 | TColStd_IndexedMapOfTransient myPolygons2D; |
176 | TColStd_IndexedMapOfTransient myPolygons3D; |
9f45d35b |
177 | NCollection_IndexedDataMap<Handle(Poly_Triangulation), |
178 | Standard_Boolean> myTriangulations; //!< Contains a boolean flag with information |
179 | //! to save normals for triangulation |
42cf5bc1 |
180 | TColStd_IndexedMapOfTransient myNodes; |
181 | Standard_Boolean myWithTriangles; |
9f45d35b |
182 | Standard_Boolean myWithNormals; |
42cf5bc1 |
183 | |
42cf5bc1 |
184 | }; |
185 | |
42cf5bc1 |
186 | #endif // _BRepTools_ShapeSet_HeaderFile |