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
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 _BRepLib_MakeWire_HeaderFile
18 #define _BRepLib_MakeWire_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
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>
34 class StdFail_NotDone;
39 //! Provides methods to build wires.
41 //! A wire may be built :
43 //! * From a single edge.
45 //! * From a wire and an edge.
47 //! - A new wire is created with the edges of the
50 //! - If the edge is not connnected to the wire the
51 //! flag NotDone is set and the method Wire will
54 //! - The connection may be :
56 //! . Through an existing vertex. The edge is shared.
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
63 //! . The new edge and the connection vertices are
64 //! kept by the algorithm.
66 //! * From 2, 3, 4 edges.
68 //! - A wire is created from the first edge, the
69 //! following edges are added.
71 //! * From many edges.
73 //! - The following syntax may be used :
75 //! BRepLib_MakeWire MW;
77 //! // for all the edges ...
80 //! TopoDS_Wire W = MW;
82 class BRepLib_MakeWire : public BRepLib_MakeShape
90 Standard_EXPORT BRepLib_MakeWire();
92 //! Make a Wire from an edge.
93 Standard_EXPORT BRepLib_MakeWire(const TopoDS_Edge& E);
95 //! Make a Wire from two edges.
96 Standard_EXPORT BRepLib_MakeWire(const TopoDS_Edge& E1, const TopoDS_Edge& E2);
98 //! Make a Wire from three edges.
99 Standard_EXPORT BRepLib_MakeWire(const TopoDS_Edge& E1, const TopoDS_Edge& E2, const TopoDS_Edge& E3);
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);
104 //! Make a Wire from a Wire. Usefull for adding later.
105 Standard_EXPORT BRepLib_MakeWire(const TopoDS_Wire& W);
107 //! Add an edge to a wire.
108 Standard_EXPORT BRepLib_MakeWire(const TopoDS_Wire& W, const TopoDS_Edge& E);
110 //! Add the edge <E> to the current wire.
111 Standard_EXPORT void Add (const TopoDS_Edge& E);
113 //! Add the edges of <W> to the current wire.
114 Standard_EXPORT void Add (const TopoDS_Wire& W);
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);
121 Standard_EXPORT BRepLib_WireError Error() const;
123 //! Returns the new wire.
124 Standard_EXPORT const TopoDS_Wire& Wire();
125 Standard_EXPORT operator TopoDS_Wire();
127 //! Returns the last edge added to the wire.
128 Standard_EXPORT const TopoDS_Edge& Edge() const;
130 //! Returns the last connecting vertex.
131 Standard_EXPORT const TopoDS_Vertex& Vertex() const;
134 class BRepLib_BndBoxVertexSelector : public NCollection_UBTree <Standard_Integer,Bnd_Box>::Selector
137 BRepLib_BndBoxVertexSelector(const TopTools_IndexedMapOfShape& theMapOfShape)
138 : BRepLib_BndBoxVertexSelector::Selector(), myMapOfShape (theMapOfShape)
141 Standard_Boolean Reject (const Bnd_Box& theBox) const
143 return theBox.IsOut(myVBox);
146 Standard_Boolean Accept (const Standard_Integer& theObj);
148 void SetCurrentVertex (const gp_Pnt& theP, Standard_Real theTol,
149 Standard_Integer theVInd);
151 const NCollection_List<Standard_Integer>& GetResultInds () const
163 BRepLib_BndBoxVertexSelector(const BRepLib_BndBoxVertexSelector& );
164 BRepLib_BndBoxVertexSelector& operator=(const BRepLib_BndBoxVertexSelector& );
166 const TopTools_IndexedMapOfShape& myMapOfShape; //vertices
168 Standard_Real mySTol;
169 Standard_Integer myVInd;
171 NCollection_List<Standard_Integer> myResultInd;
174 void CollectCoincidentVertices(const TopTools_ListOfShape& theL,
175 NCollection_List<NCollection_List<TopoDS_Vertex>>& theGrVL);
177 void CreateNewVertices(const NCollection_List<NCollection_List<TopoDS_Vertex>>& theGrVL,
178 TopTools_DataMapOfShapeShape& theO2NV);
180 void CreateNewListOfEdges(const TopTools_ListOfShape& theL,
181 const TopTools_DataMapOfShapeShape& theO2NV,
182 TopTools_ListOfShape& theNewEList);
184 void Add(const TopoDS_Edge& E, Standard_Boolean IsCheckGeometryProximity);
194 BRepLib_WireError myError;
196 TopoDS_Vertex myVertex;
197 TopTools_IndexedMapOfShape myVertices;
198 TopoDS_Vertex FirstVertex;
210 #endif // _BRepLib_MakeWire_HeaderFile