0028832: MMgt_TShared can be replaced by Standard_Transient
[occt.git] / src / TopOpeBRepBuild / TopOpeBRepBuild_HBuilder.hxx
1 // Created on: 1993-06-14
2 // Created by: Jean Yves LEBEY
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 _TopOpeBRepBuild_HBuilder_HeaderFile
18 #define _TopOpeBRepBuild_HBuilder_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <TopOpeBRepBuild_Builder1.hxx>
24 #include <TopTools_DataMapOfShapeInteger.hxx>
25 #include <TColStd_DataMapOfIntegerListOfInteger.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <TopoDS_Shape.hxx>
28 #include <TColStd_ListOfInteger.hxx>
29 #include <Standard_Transient.hxx>
30 #include <TopAbs_State.hxx>
31 #include <TopTools_ListOfShape.hxx>
32 #include <Standard_Integer.hxx>
33 class Standard_NoSuchObject;
34 class TopOpeBRepDS_BuildTool;
35 class TopOpeBRepDS_HDataStructure;
36 class TopoDS_Shape;
37 class TopOpeBRepBuild_Builder;
38
39
40 class TopOpeBRepBuild_HBuilder;
41 DEFINE_STANDARD_HANDLE(TopOpeBRepBuild_HBuilder, Standard_Transient)
42
43 //! The HBuilder  algorithm    constructs   topological
44 //! objects  from   an    existing  topology  and  new
45 //! geometries attached to the topology. It is used to
46 //! construct the result of a topological operation;
47 //! the existing  topologies are the parts involved in
48 //! the  topological  operation and the new geometries
49 //! are the intersection lines and points.
50 class TopOpeBRepBuild_HBuilder : public Standard_Transient
51 {
52
53 public:
54
55   
56   Standard_EXPORT TopOpeBRepBuild_HBuilder(const TopOpeBRepDS_BuildTool& BT);
57   
58   Standard_EXPORT const TopOpeBRepDS_BuildTool& BuildTool() const;
59   
60
61   //! Stores the data structure <HDS>,
62   //! Create shapes from the new geometries described in <HDS>.
63   Standard_EXPORT void Perform (const Handle(TopOpeBRepDS_HDataStructure)& HDS);
64   
65
66   //! Same as previous + evaluates if an operation performed on shapes S1,S2
67   //! is a particular case.
68   Standard_EXPORT void Perform (const Handle(TopOpeBRepDS_HDataStructure)& HDS, const TopoDS_Shape& S1, const TopoDS_Shape& S2);
69   
70   //! Removes all split and merge already performed.
71   //! Does NOT clear the handled DS.
72   Standard_EXPORT void Clear();
73   
74   //! returns the DS handled by this builder
75   Standard_EXPORT Handle(TopOpeBRepDS_HDataStructure) DataStructure() const;
76   
77   Standard_EXPORT TopOpeBRepDS_BuildTool& ChangeBuildTool();
78   
79   //! Merges the two shapes <S1> and <S2> keeping the
80   //! parts of states <TB1>,<TB2> in <S1>,<S2>.
81   Standard_EXPORT void MergeShapes (const TopoDS_Shape& S1, const TopAbs_State TB1, const TopoDS_Shape& S2, const TopAbs_State TB2);
82   
83   //! Merges  the two solids <S1>   and <S2> keeping the
84   //! parts in each solid of states <TB1> and <TB2>.
85   Standard_EXPORT void MergeSolids (const TopoDS_Shape& S1, const TopAbs_State TB1, const TopoDS_Shape& S2, const TopAbs_State TB2);
86   
87   //! Merges the solid <S>  keeping the
88   //! parts of state <TB>.
89   Standard_EXPORT void MergeSolid (const TopoDS_Shape& S, const TopAbs_State TB);
90   
91
92   //! Returns True if the shape <S> has been split.
93   Standard_EXPORT Standard_Boolean IsSplit (const TopoDS_Shape& S, const TopAbs_State ToBuild) const;
94   
95
96   //! Returns the split parts <ToBuild> of shape <S>.
97   Standard_EXPORT const TopTools_ListOfShape& Splits (const TopoDS_Shape& S, const TopAbs_State ToBuild) const;
98   
99
100   //! Returns True if the shape <S> has been merged.
101   Standard_EXPORT Standard_Boolean IsMerged (const TopoDS_Shape& S, const TopAbs_State ToBuild) const;
102   
103
104   //! Returns the merged parts <ToBuild> of shape <S>.
105   Standard_EXPORT const TopTools_ListOfShape& Merged (const TopoDS_Shape& S, const TopAbs_State ToBuild) const;
106   
107
108   //! Returns the vertex created on point <I>.
109   Standard_EXPORT const TopoDS_Shape& NewVertex (const Standard_Integer I) const;
110   
111
112   //! Returns the edges created on curve <I>.
113   Standard_EXPORT const TopTools_ListOfShape& NewEdges (const Standard_Integer I) const;
114   
115
116   //! Returns the edges created on curve <I>.
117   Standard_EXPORT TopTools_ListOfShape& ChangeNewEdges (const Standard_Integer I);
118   
119
120   //! Returns the faces created on surface <I>.
121   Standard_EXPORT const TopTools_ListOfShape& NewFaces (const Standard_Integer I) const;
122   
123   Standard_EXPORT const TopTools_ListOfShape& Section();
124   
125   Standard_EXPORT void InitExtendedSectionDS (const Standard_Integer k = 3);
126   
127   Standard_EXPORT void InitSection (const Standard_Integer k = 3);
128   
129   Standard_EXPORT Standard_Boolean MoreSection() const;
130   
131   Standard_EXPORT void NextSection();
132   
133   Standard_EXPORT const TopoDS_Shape& CurrentSection() const;
134   
135   Standard_EXPORT Standard_Integer GetDSEdgeFromSectEdge (const TopoDS_Shape& E, const Standard_Integer rank);
136   
137   Standard_EXPORT TColStd_ListOfInteger& GetDSFaceFromDSEdge (const Standard_Integer indexEdg, const Standard_Integer rank);
138   
139   Standard_EXPORT Standard_Integer GetDSCurveFromSectEdge (const TopoDS_Shape& SectEdge);
140   
141   Standard_EXPORT Standard_Integer GetDSFaceFromDSCurve (const Standard_Integer indexCur, const Standard_Integer rank);
142   
143   Standard_EXPORT Standard_Integer GetDSPointFromNewVertex (const TopoDS_Shape& NewVert);
144   
145   //! search for the couple of face F1,F2
146   //! (from arguments of supra Perform(S1,S2,HDS)) method which
147   //! intersection gives section edge E built on an intersection curve.
148   //! returns True if F1,F2 have been valued.
149   //! returns False if E is not a section edge built
150   //! on intersection curve IC.
151   Standard_EXPORT Standard_Boolean EdgeCurveAncestors (const TopoDS_Shape& E, TopoDS_Shape& F1, TopoDS_Shape& F2, Standard_Integer& IC);
152   
153   //! search for the couple of face F1,F2
154   //! (from arguments of supra Perform(S1,S2,HDS)) method which
155   //! intersection gives section edge E built on at least one edge .
156   //! returns True if F1,F2 have been valued.
157   //! returns False if E is not a section edge built
158   //! on at least one edge of S1 and/or S2.
159   //! LE1,LE2 are edges of S1,S2 which common part is edge E.
160   //! LE1 or LE2 may be empty() but not both.
161   Standard_EXPORT Standard_Boolean EdgeSectionAncestors (const TopoDS_Shape& E, TopTools_ListOfShape& LF1, TopTools_ListOfShape& LF2, TopTools_ListOfShape& LE1, TopTools_ListOfShape& LE2);
162   
163   //! Returns 0 is standard operation, != 0 if particular case
164   Standard_EXPORT Standard_Integer IsKPart();
165   
166   Standard_EXPORT void MergeKPart (const TopAbs_State TB1, const TopAbs_State TB2);
167   
168   Standard_EXPORT TopOpeBRepBuild_Builder& ChangeBuilder();
169
170
171
172
173   DEFINE_STANDARD_RTTIEXT(TopOpeBRepBuild_HBuilder,Standard_Transient)
174
175 protected:
176
177
178   TopOpeBRepBuild_Builder1 myBuilder;
179
180
181 private:
182
183   
184   Standard_EXPORT void MakeEdgeAncestorMap();
185   
186   Standard_EXPORT void MakeCurveAncestorMap();
187
188   TopTools_DataMapOfShapeInteger mySectEdgeDSEdges1;
189   TopTools_DataMapOfShapeInteger mySectEdgeDSEdges2;
190   TColStd_DataMapOfIntegerListOfInteger myDSEdgesDSFaces1;
191   TColStd_DataMapOfIntegerListOfInteger myDSEdgesDSFaces2;
192   Standard_Boolean myMakeEdgeAncestorIsDone;
193   TopTools_DataMapOfShapeInteger mySectEdgeDSCurve;
194   Standard_Boolean myMakeCurveAncestorIsDone;
195   TopTools_DataMapOfShapeInteger myNewVertexDSPoint;
196   Standard_Boolean myMakePointAncestorIsDone;
197   TopoDS_Shape myEmptyShape;
198   TColStd_ListOfInteger myEmptyIntegerList;
199
200
201 };
202
203
204
205
206
207
208
209 #endif // _TopOpeBRepBuild_HBuilder_HeaderFile