0031035: Coding - uninitialized class fields reported by Visual Studio Code Analysis
[occt.git] / src / BRepLib / BRepLib_MakeWire.hxx
1 // Created on: 1993-07-08
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 _BRepLib_MakeWire_HeaderFile
18 #define _BRepLib_MakeWire_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <BRepLib_WireError.hxx>
25 #include <TopoDS_Edge.hxx>
26 #include <TopoDS_Vertex.hxx>
27 #include <TopTools_DataMapOfShapeShape.hxx>
28 #include <TopTools_IndexedMapOfShape.hxx>
29 #include <BRepLib_MakeShape.hxx>
30 #include <TopTools_ListOfShape.hxx>
31 #include <Bnd_Box.hxx>
32 #include <NCollection_UBTree.hxx>
33
34 class StdFail_NotDone;
35 class TopoDS_Edge;
36 class TopoDS_Wire;
37 class TopoDS_Vertex;
38
39 //! Provides methods to build wires.
40 //!
41 //! A wire may be built :
42 //!
43 //! * From a single edge.
44 //!
45 //! * From a wire and an edge.
46 //!
47 //! - A new wire  is created with the edges  of  the
48 //! wire + the edge.
49 //!
50 //! - If the edge is not connnected  to the wire the
51 //! flag NotDone   is set and  the  method Wire will
52 //! raise an error.
53 //!
54 //! - The connection may be :
55 //!
56 //! . Through an existing vertex. The edge is shared.
57 //!
58 //! . Through a geometric coincidence of vertices.
59 //! The edge is  copied  and the vertices from the
60 //! edge are  replaced  by  the vertices from  the
61 //! wire.
62 //!
63 //! . The new edge and the connection vertices are
64 //! kept by the algorithm.
65 //!
66 //! * From 2, 3, 4 edges.
67 //!
68 //! - A wire is  created from  the first edge, the
69 //! following edges are added.
70 //!
71 //! * From many edges.
72 //!
73 //! - The following syntax may be used :
74 //!
75 //! BRepLib_MakeWire MW;
76 //!
77 //! // for all the edges ...
78 //! MW.Add(anEdge);
79 //!
80 //! TopoDS_Wire W = MW;
81
82 class BRepLib_MakeWire  : public BRepLib_MakeShape
83 {
84 public:
85
86   DEFINE_STANDARD_ALLOC
87
88   
89   //! NotDone MakeWire.
90   Standard_EXPORT BRepLib_MakeWire();
91   
92   //! Make a Wire from an edge.
93   Standard_EXPORT BRepLib_MakeWire(const TopoDS_Edge& E);
94   
95   //! Make a Wire from two edges.
96   Standard_EXPORT BRepLib_MakeWire(const TopoDS_Edge& E1, const TopoDS_Edge& E2);
97   
98   //! Make a Wire from three edges.
99   Standard_EXPORT BRepLib_MakeWire(const TopoDS_Edge& E1, const TopoDS_Edge& E2, const TopoDS_Edge& E3);
100   
101   //! Make a Wire from four edges.
102   Standard_EXPORT BRepLib_MakeWire(const TopoDS_Edge& E1, const TopoDS_Edge& E2, const TopoDS_Edge& E3, const TopoDS_Edge& E4);
103   
104   //! Make a Wire from a Wire. Usefull for adding later.
105   Standard_EXPORT BRepLib_MakeWire(const TopoDS_Wire& W);
106   
107   //! Add an edge to a wire.
108   Standard_EXPORT BRepLib_MakeWire(const TopoDS_Wire& W, const TopoDS_Edge& E);
109   
110   //! Add the edge <E> to the current wire.
111   Standard_EXPORT void Add (const TopoDS_Edge& E);
112   
113   //! Add the edges of <W> to the current wire.
114   Standard_EXPORT void Add (const TopoDS_Wire& W);
115   
116   //! Add the edges of <L> to the current wire.
117   //! The edges are not to be consecutive.  But they are
118   //! to be all connected geometrically or topologically.
119   Standard_EXPORT void Add (const TopTools_ListOfShape& L);
120   
121   Standard_EXPORT BRepLib_WireError Error() const;
122   
123   //! Returns the new wire.
124   Standard_EXPORT const TopoDS_Wire& Wire();
125   Standard_EXPORT operator TopoDS_Wire();
126   
127   //! Returns the last edge added to the wire.
128   Standard_EXPORT const TopoDS_Edge& Edge() const;
129   
130   //! Returns the last connecting vertex.
131   Standard_EXPORT const TopoDS_Vertex& Vertex() const;
132
133 private:
134   class BRepLib_BndBoxVertexSelector : public NCollection_UBTree <Standard_Integer,Bnd_Box>::Selector
135   {
136   public:
137     BRepLib_BndBoxVertexSelector(const TopTools_IndexedMapOfShape& theMapOfShape)
138     : BRepLib_BndBoxVertexSelector::Selector(),
139       myMapOfShape (theMapOfShape),
140       myTolP(0.0),
141       myVInd(0)
142     {
143     }
144
145     Standard_Boolean Reject (const Bnd_Box& theBox) const
146     {
147       return theBox.IsOut(myVBox);
148     }
149
150     Standard_Boolean Accept (const Standard_Integer& theObj);
151
152     void SetCurrentVertex (const gp_Pnt& theP, Standard_Real theTol, 
153                            Standard_Integer theVInd);
154
155     const NCollection_List<Standard_Integer>& GetResultInds () const
156     { 
157       return myResultInd;
158     }
159
160     void ClearResInds()
161     { 
162       myResultInd.Clear();
163     }
164
165   private:
166
167     BRepLib_BndBoxVertexSelector(const BRepLib_BndBoxVertexSelector& );
168     BRepLib_BndBoxVertexSelector& operator=(const BRepLib_BndBoxVertexSelector& );
169
170     const TopTools_IndexedMapOfShape& myMapOfShape; //vertices
171     gp_Pnt myP;
172     Standard_Real myTolP;
173     Standard_Integer myVInd;
174     Bnd_Box myVBox;
175     NCollection_List<Standard_Integer> myResultInd; 
176   };
177
178   void CollectCoincidentVertices(const TopTools_ListOfShape& theL,
179                                  NCollection_List<NCollection_List<TopoDS_Vertex>>& theGrVL);
180
181   void CreateNewVertices(const NCollection_List<NCollection_List<TopoDS_Vertex>>& theGrVL, 
182                          TopTools_DataMapOfShapeShape& theO2NV);
183
184   void CreateNewListOfEdges(const TopTools_ListOfShape& theL,
185                             const TopTools_DataMapOfShapeShape& theO2NV,
186                             TopTools_ListOfShape& theNewEList);
187
188   void Add(const TopoDS_Edge& E, Standard_Boolean IsCheckGeometryProximity);
189
190
191
192 protected:
193
194
195
196 private:
197
198   BRepLib_WireError myError;
199   TopoDS_Edge myEdge;
200   TopoDS_Vertex myVertex;
201   TopTools_IndexedMapOfShape myVertices;
202   TopoDS_Vertex FirstVertex;
203   TopoDS_Vertex VF;
204   TopoDS_Vertex VL;
205
206 };
207
208
209
210
211
212
213
214 #endif // _BRepLib_MakeWire_HeaderFile