1 // Created on: 1993-06-23
2 // Created by: Jean Yves LEBEY
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 _TopOpeBRepDS_DataStructure_HeaderFile
18 #define _TopOpeBRepDS_DataStructure_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Standard_Integer.hxx>
25 #include <TopOpeBRepDS_MapOfSurface.hxx>
26 #include <TopOpeBRepDS_MapOfCurve.hxx>
27 #include <TopOpeBRepDS_MapOfPoint.hxx>
28 #include <TopOpeBRepDS_MapOfShapeData.hxx>
29 #include <TopTools_IndexedMapOfShape.hxx>
30 #include <TopOpeBRepDS_ListOfInterference.hxx>
31 #include <TopTools_ListOfShape.hxx>
32 #include <TopoDS_Shape.hxx>
33 #include <TopOpeBRepDS_Point.hxx>
34 #include <TopOpeBRepDS_Surface.hxx>
35 #include <TopOpeBRepDS_Curve.hxx>
36 #include <TopOpeBRepDS_ShapeSurface.hxx>
37 #include <Standard_Boolean.hxx>
38 #include <TopOpeBRepDS_IndexedDataMapOfShapeWithState.hxx>
39 #include <TopOpeBRepDS_Config.hxx>
40 #include <TopOpeBRepDS_ListIteratorOfListOfInterference.hxx>
42 class TopOpeBRepDS_SurfaceExplorer;
43 class TopOpeBRepDS_CurveExplorer;
44 class TopOpeBRepDS_PointExplorer;
45 class TopOpeBRepDS_Surface;
46 class TopOpeBRepDS_Curve;
47 class TopOpeBRepDS_Point;
50 class TopOpeBRepDS_Interference;
51 class TopOpeBRepDS_ShapeWithState;
54 //! The DataStructure stores :
56 //! New geometries : points, curves, and surfaces.
57 //! Topological shapes : vertices, edges, faces.
58 //! The new geometries and the topological shapes have interferences.
59 class TopOpeBRepDS_DataStructure
66 Standard_EXPORT TopOpeBRepDS_DataStructure();
68 //! reset the data structure
69 Standard_EXPORT void Init();
71 //! Insert a new surface. Returns the index.
72 Standard_EXPORT Standard_Integer AddSurface (const TopOpeBRepDS_Surface& S);
74 Standard_EXPORT void RemoveSurface (const Standard_Integer I);
76 Standard_EXPORT Standard_Boolean KeepSurface (const Standard_Integer I) const;
78 Standard_EXPORT Standard_Boolean KeepSurface (TopOpeBRepDS_Surface& S) const;
80 Standard_EXPORT void ChangeKeepSurface (const Standard_Integer I, const Standard_Boolean FindKeep);
82 Standard_EXPORT void ChangeKeepSurface (TopOpeBRepDS_Surface& S, const Standard_Boolean FindKeep);
84 //! Insert a new curve. Returns the index.
85 Standard_EXPORT Standard_Integer AddCurve (const TopOpeBRepDS_Curve& S);
87 Standard_EXPORT void RemoveCurve (const Standard_Integer I);
89 Standard_EXPORT Standard_Boolean KeepCurve (const Standard_Integer I) const;
91 Standard_EXPORT Standard_Boolean KeepCurve (const TopOpeBRepDS_Curve& C) const;
93 Standard_EXPORT void ChangeKeepCurve (const Standard_Integer I, const Standard_Boolean FindKeep);
95 Standard_EXPORT void ChangeKeepCurve (TopOpeBRepDS_Curve& C, const Standard_Boolean FindKeep);
97 //! Insert a new point. Returns the index.
98 Standard_EXPORT Standard_Integer AddPoint (const TopOpeBRepDS_Point& PDS);
100 //! Insert a new point. Returns the index.
101 Standard_EXPORT Standard_Integer AddPointSS (const TopOpeBRepDS_Point& PDS, const TopoDS_Shape& S1, const TopoDS_Shape& S2);
103 Standard_EXPORT void RemovePoint (const Standard_Integer I);
105 Standard_EXPORT Standard_Boolean KeepPoint (const Standard_Integer I) const;
107 Standard_EXPORT Standard_Boolean KeepPoint (const TopOpeBRepDS_Point& P) const;
109 Standard_EXPORT void ChangeKeepPoint (const Standard_Integer I, const Standard_Boolean FindKeep);
111 Standard_EXPORT void ChangeKeepPoint (TopOpeBRepDS_Point& P, const Standard_Boolean FindKeep);
113 //! Insert a shape S. Returns the index.
114 Standard_EXPORT Standard_Integer AddShape (const TopoDS_Shape& S);
116 //! Insert a shape S which ancestor is I = 1 or 2. Returns the index.
117 Standard_EXPORT Standard_Integer AddShape (const TopoDS_Shape& S, const Standard_Integer I);
119 Standard_EXPORT Standard_Boolean KeepShape (const Standard_Integer I, const Standard_Boolean FindKeep = Standard_True) const;
121 Standard_EXPORT Standard_Boolean KeepShape (const TopoDS_Shape& S, const Standard_Boolean FindKeep = Standard_True) const;
123 Standard_EXPORT void ChangeKeepShape (const Standard_Integer I, const Standard_Boolean FindKeep);
125 Standard_EXPORT void ChangeKeepShape (const TopoDS_Shape& S, const Standard_Boolean FindKeep);
127 Standard_EXPORT void InitSectionEdges();
129 Standard_EXPORT Standard_Integer AddSectionEdge (const TopoDS_Edge& E);
131 Standard_EXPORT const TopOpeBRepDS_ListOfInterference& SurfaceInterferences (const Standard_Integer I) const;
133 Standard_EXPORT TopOpeBRepDS_ListOfInterference& ChangeSurfaceInterferences (const Standard_Integer I);
135 Standard_EXPORT const TopOpeBRepDS_ListOfInterference& CurveInterferences (const Standard_Integer I) const;
137 Standard_EXPORT TopOpeBRepDS_ListOfInterference& ChangeCurveInterferences (const Standard_Integer I);
139 Standard_EXPORT const TopOpeBRepDS_ListOfInterference& PointInterferences (const Standard_Integer I) const;
141 Standard_EXPORT TopOpeBRepDS_ListOfInterference& ChangePointInterferences (const Standard_Integer I);
143 Standard_EXPORT const TopOpeBRepDS_ListOfInterference& ShapeInterferences (const TopoDS_Shape& S, const Standard_Boolean FindKeep = Standard_True) const;
145 Standard_EXPORT TopOpeBRepDS_ListOfInterference& ChangeShapeInterferences (const TopoDS_Shape& S);
147 Standard_EXPORT const TopOpeBRepDS_ListOfInterference& ShapeInterferences (const Standard_Integer I, const Standard_Boolean FindKeep = Standard_True) const;
149 Standard_EXPORT TopOpeBRepDS_ListOfInterference& ChangeShapeInterferences (const Standard_Integer I);
151 Standard_EXPORT const TopTools_ListOfShape& ShapeSameDomain (const TopoDS_Shape& S) const;
153 Standard_EXPORT TopTools_ListOfShape& ChangeShapeSameDomain (const TopoDS_Shape& S);
155 Standard_EXPORT const TopTools_ListOfShape& ShapeSameDomain (const Standard_Integer I) const;
157 Standard_EXPORT TopTools_ListOfShape& ChangeShapeSameDomain (const Standard_Integer I);
159 Standard_EXPORT TopOpeBRepDS_MapOfShapeData& ChangeShapes();
161 Standard_EXPORT void AddShapeSameDomain (const TopoDS_Shape& S, const TopoDS_Shape& SSD);
163 Standard_EXPORT void RemoveShapeSameDomain (const TopoDS_Shape& S, const TopoDS_Shape& SSD);
165 Standard_EXPORT Standard_Integer SameDomainRef (const Standard_Integer I) const;
167 Standard_EXPORT Standard_Integer SameDomainRef (const TopoDS_Shape& S) const;
169 Standard_EXPORT void SameDomainRef (const Standard_Integer I, const Standard_Integer Ref);
171 Standard_EXPORT void SameDomainRef (const TopoDS_Shape& S, const Standard_Integer Ref);
173 Standard_EXPORT TopOpeBRepDS_Config SameDomainOri (const Standard_Integer I) const;
175 Standard_EXPORT TopOpeBRepDS_Config SameDomainOri (const TopoDS_Shape& S) const;
177 Standard_EXPORT void SameDomainOri (const Standard_Integer I, const TopOpeBRepDS_Config Ori);
179 Standard_EXPORT void SameDomainOri (const TopoDS_Shape& S, const TopOpeBRepDS_Config Ori);
181 Standard_EXPORT Standard_Integer SameDomainInd (const Standard_Integer I) const;
183 Standard_EXPORT Standard_Integer SameDomainInd (const TopoDS_Shape& S) const;
185 Standard_EXPORT void SameDomainInd (const Standard_Integer I, const Standard_Integer Ind);
187 Standard_EXPORT void SameDomainInd (const TopoDS_Shape& S, const Standard_Integer Ind);
189 Standard_EXPORT Standard_Integer AncestorRank (const Standard_Integer I) const;
191 Standard_EXPORT Standard_Integer AncestorRank (const TopoDS_Shape& S) const;
193 Standard_EXPORT void AncestorRank (const Standard_Integer I, const Standard_Integer Ianc);
195 Standard_EXPORT void AncestorRank (const TopoDS_Shape& S, const Standard_Integer Ianc);
197 Standard_EXPORT void AddShapeInterference (const TopoDS_Shape& S, const Handle(TopOpeBRepDS_Interference)& I);
199 Standard_EXPORT void RemoveShapeInterference (const TopoDS_Shape& S, const Handle(TopOpeBRepDS_Interference)& I);
201 Standard_EXPORT void FillShapesSameDomain (const TopoDS_Shape& S1, const TopoDS_Shape& S2, const Standard_Boolean refFirst = Standard_True);
203 Standard_EXPORT void FillShapesSameDomain (const TopoDS_Shape& S1, const TopoDS_Shape& S2, const TopOpeBRepDS_Config c1, const TopOpeBRepDS_Config c2, const Standard_Boolean refFirst = Standard_True);
205 Standard_EXPORT void UnfillShapesSameDomain (const TopoDS_Shape& S1, const TopoDS_Shape& S2);
207 Standard_EXPORT Standard_Integer NbSurfaces() const;
209 Standard_EXPORT Standard_Integer NbCurves() const;
211 Standard_EXPORT void ChangeNbCurves (const Standard_Integer N);
213 Standard_EXPORT Standard_Integer NbPoints() const;
215 Standard_EXPORT Standard_Integer NbShapes() const;
217 Standard_EXPORT Standard_Integer NbSectionEdges() const;
219 //! Returns the surface of index <I>.
220 Standard_EXPORT const TopOpeBRepDS_Surface& Surface (const Standard_Integer I) const;
222 //! Returns the surface of index <I>.
223 Standard_EXPORT TopOpeBRepDS_Surface& ChangeSurface (const Standard_Integer I);
225 //! Returns the Curve of index <I>.
226 Standard_EXPORT const TopOpeBRepDS_Curve& Curve (const Standard_Integer I) const;
228 //! Returns the Curve of index <I>.
229 Standard_EXPORT TopOpeBRepDS_Curve& ChangeCurve (const Standard_Integer I);
231 //! Returns the point of index <I>.
232 Standard_EXPORT const TopOpeBRepDS_Point& Point (const Standard_Integer I) const;
234 //! Returns the point of index <I>.
235 Standard_EXPORT TopOpeBRepDS_Point& ChangePoint (const Standard_Integer I);
237 //! returns the shape of index I stored in
238 //! the map myShapes, accessing a list of interference.
239 Standard_EXPORT const TopoDS_Shape& Shape (const Standard_Integer I, const Standard_Boolean FindKeep = Standard_True) const;
241 //! returns the index of shape <S> stored in
242 //! the map myShapes, accessing a list of interference.
243 //! returns 0 if <S> is not in the map.
244 Standard_EXPORT Standard_Integer Shape (const TopoDS_Shape& S, const Standard_Boolean FindKeep = Standard_True) const;
246 Standard_EXPORT const TopoDS_Edge& SectionEdge (const Standard_Integer I, const Standard_Boolean FindKeep = Standard_True) const;
248 Standard_EXPORT Standard_Integer SectionEdge (const TopoDS_Edge& E, const Standard_Boolean FindKeep = Standard_True) const;
250 Standard_EXPORT Standard_Boolean IsSectionEdge (const TopoDS_Edge& E, const Standard_Boolean FindKeep = Standard_True) const;
252 //! Returns True if <S> has new geometries, i.e :
255 //! S a une liste d'interferences non vide.
256 //! S = SOLID, FACE, EDGE : true/false
257 //! S = SHELL, WIRE, VERTEX : false.
258 Standard_EXPORT Standard_Boolean HasGeometry (const TopoDS_Shape& S) const;
260 //! Returns True if <S> est dans myShapes
261 Standard_EXPORT Standard_Boolean HasShape (const TopoDS_Shape& S, const Standard_Boolean FindKeep = Standard_True) const;
263 Standard_EXPORT void SetNewSurface (const TopoDS_Shape& F, const Handle(Geom_Surface)& S);
265 Standard_EXPORT Standard_Boolean HasNewSurface (const TopoDS_Shape& F) const;
267 Standard_EXPORT const Handle(Geom_Surface)& NewSurface (const TopoDS_Shape& F) const;
269 Standard_EXPORT void Isfafa (const Standard_Boolean isfafa);
271 Standard_EXPORT Standard_Boolean Isfafa() const;
273 Standard_EXPORT TopOpeBRepDS_IndexedDataMapOfShapeWithState& ChangeMapOfShapeWithStateObj();
275 Standard_EXPORT TopOpeBRepDS_IndexedDataMapOfShapeWithState& ChangeMapOfShapeWithStateTool();
277 Standard_EXPORT TopOpeBRepDS_IndexedDataMapOfShapeWithState& ChangeMapOfShapeWithState (const TopoDS_Shape& aShape, Standard_Boolean& aFlag);
279 Standard_EXPORT const TopOpeBRepDS_ShapeWithState& GetShapeWithState (const TopoDS_Shape& aShape) const;
281 Standard_EXPORT TopTools_IndexedMapOfShape& ChangeMapOfRejectedShapesObj();
283 Standard_EXPORT TopTools_IndexedMapOfShape& ChangeMapOfRejectedShapesTool();
286 friend class TopOpeBRepDS_SurfaceExplorer;
287 friend class TopOpeBRepDS_CurveExplorer;
288 friend class TopOpeBRepDS_PointExplorer;
300 Standard_EXPORT Standard_Boolean FindInterference (TopOpeBRepDS_ListIteratorOfListOfInterference& IT, const Handle(TopOpeBRepDS_Interference)& I) const;
303 Standard_Integer myNbSurfaces;
304 TopOpeBRepDS_MapOfSurface mySurfaces;
305 Standard_Integer myNbCurves;
306 TopOpeBRepDS_MapOfCurve myCurves;
307 Standard_Integer myNbPoints;
308 TopOpeBRepDS_MapOfPoint myPoints;
309 TopOpeBRepDS_MapOfShapeData myShapes;
310 TopTools_IndexedMapOfShape mySectionEdges;
311 TopOpeBRepDS_ListOfInterference myEmptyListOfInterference;
312 TopTools_ListOfShape myEmptyListOfShape;
313 TopoDS_Shape myEmptyShape;
314 TopOpeBRepDS_Point myEmptyPoint;
315 TopOpeBRepDS_Surface myEmptySurface;
316 TopOpeBRepDS_Curve myEmptyCurve;
317 Handle(Geom_Surface) myEmptyGSurface;
318 TopOpeBRepDS_ShapeSurface myNewSurface;
319 Standard_Boolean myIsfafa;
320 Standard_Integer myI;
321 TopOpeBRepDS_IndexedDataMapOfShapeWithState myMapOfShapeWithStateObj;
322 TopOpeBRepDS_IndexedDataMapOfShapeWithState myMapOfShapeWithStateTool;
323 TopTools_IndexedMapOfShape myMapOfRejectedShapesObj;
324 TopTools_IndexedMapOfShape myMapOfRejectedShapesTool;
335 #endif // _TopOpeBRepDS_DataStructure_HeaderFile