0029705: Foundation Classes - ShapeAnalysis_FreeBounds intention documentation is...
[occt.git] / src / ShapeAnalysis / ShapeAnalysis_FreeBounds.hxx
1 // Created on: 1998-06-03
2 // Created by: Daniel RISSER
3 // Copyright (c) 1998-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 _ShapeAnalysis_FreeBounds_HeaderFile
18 #define _ShapeAnalysis_FreeBounds_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <TopoDS_Compound.hxx>
25 #include <Standard_Real.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <TopTools_HSequenceOfShape.hxx>
28 #include <TopTools_DataMapOfShapeShape.hxx>
29 class TopoDS_Shape;
30 class TopoDS_Compound;
31
32
33 //! This class is intended to output free bounds of the shape.
34 //!
35 //! Free bounds are the wires consisting of edges referenced by the faces of the shape
36 //! only once; these are the edges composing the outer boundary of the face or shell
37 //! (as opposed to internal edges between the faces in the shell or seam edges on closed faces).
38 //!
39 //! This class works on two distinct types of shapes when analyzing
40 //! their free bounds:
41 //! 1. compound of faces.
42 //! Analyzer of sewing algorithm (BRepAlgo_Sewing) is used for
43 //! for forecasting free bounds that would be obtained after
44 //! performing sewing
45 //! 2. compound of shells.
46 //! Actual free bounds (edges shared by the only face in the shell)
47 //! are output in this case. ShapeAnalysis_Shell is used for that.
48 //!
49 //! When connecting edges into the wires algorithm tries to build
50 //! wires of maximum length. Two options are provided for a user
51 //! to extract closed sub-contours out of closed and/or open contours.
52 //!
53 //! Free bounds are returned as two compounds, one for closed and one
54 //! for open wires.
55 //!
56 //! This class also provides some static methods for advanced use:
57 //! connecting edges/wires to wires, extracting closed sub-wires out
58 //! of wires, dispatching wires into compounds for closed and open
59 //! wires.
60 //! NOTE. Ends of the edge or wire mean hereafter their end vertices.
61 class ShapeAnalysis_FreeBounds 
62 {
63 public:
64
65   DEFINE_STANDARD_ALLOC
66
67   
68   //! Empty constructor
69   Standard_EXPORT ShapeAnalysis_FreeBounds();
70   
71   //! Builds forecasting free bounds of the <shape>.
72   //! <shape> should be a compound of faces.
73   //! This constructor is to be used for forecasting free edges
74   //! with help of sewing analyzer BRepAlgo_Sewing which is called
75   //! with tolerance <toler>.
76   //! Free edges are connected into wires only when their ends are
77   //! at distance less than <toler>.
78   //! If <splitclosed> is True extracts closed sub-wires out of
79   //! built closed wires.
80   //! If <splitopen> is True extracts closed sub-wires out of
81   //! built open wires.
82   Standard_EXPORT ShapeAnalysis_FreeBounds(const TopoDS_Shape& shape, const Standard_Real toler, const Standard_Boolean splitclosed = Standard_False, const Standard_Boolean splitopen = Standard_True);
83   
84   //! Builds actual free bounds of the <shape>.
85   //! <shape> should be a compound of shells.
86   //! This constructor is to be used for getting free edges (ones
87   //! referenced by the only face) with help of analyzer
88   //! ShapeAnalysis_Shell.
89   //! Free edges are connected into wires only when they share the
90   //! same vertex.
91   //! If <splitclosed> is True extracts closed sub-wires out of
92   //! built closed wires.
93   //! If <splitopen> is True extracts closed sub-wires out of
94   //! built open wires.
95   Standard_EXPORT ShapeAnalysis_FreeBounds(const TopoDS_Shape& shape, const Standard_Boolean splitclosed = Standard_False, const Standard_Boolean splitopen = Standard_True, const Standard_Boolean checkinternaledges = Standard_False);
96   
97   //! Returns compound of closed wires out of free edges.
98     const TopoDS_Compound& GetClosedWires() const;
99   
100   //! Returns compound of open wires out of free edges.
101     const TopoDS_Compound& GetOpenWires() const;
102   
103   //! Builds sequnce of <wires> out of sequence of not sorted
104   //! <edges>.
105   //! Tries to build wires of maximum length. Building a wire is
106   //! stopped when no edges can be connected to it at its head or
107   //! at its tail.
108   //!
109   //! Orientation of the edge can change when connecting.
110   //! If <shared> is True connection is performed only when
111   //! adjacent edges share the same vertex.
112   //! If <shared> is False connection is performed only when
113   //! ends of adjacent edges are at distance less than <toler>.
114   Standard_EXPORT static void ConnectEdgesToWires (Handle(TopTools_HSequenceOfShape)& edges, const Standard_Real toler, const Standard_Boolean shared, Handle(TopTools_HSequenceOfShape)& wires);
115   
116   Standard_EXPORT static void ConnectWiresToWires (Handle(TopTools_HSequenceOfShape)& iwires, const Standard_Real toler, const Standard_Boolean shared, Handle(TopTools_HSequenceOfShape)& owires);
117   
118   //! Builds sequnce of <owires> out of sequence of not sorted
119   //! <iwires>.
120   //! Tries to build wires of maximum length. Building a wire is
121   //! stopped when no wires can be connected to it at its head or
122   //! at its tail.
123   //!
124   //! Orientation of the wire can change when connecting.
125   //! If <shared> is True connection is performed only when
126   //! adjacent wires share the same vertex.
127   //! If <shared> is False connection is performed only when
128   //! ends of adjacent wires are at distance less than <toler>.
129   //! Map <vertices> stores the correspondence between original
130   //! end vertices of the wires and new connecting vertices.
131   Standard_EXPORT static void ConnectWiresToWires (Handle(TopTools_HSequenceOfShape)& iwires, const Standard_Real toler, const Standard_Boolean shared, Handle(TopTools_HSequenceOfShape)& owires, TopTools_DataMapOfShapeShape& vertices);
132   
133   //! Extracts closed sub-wires out of <wires> and adds them
134   //! to <closed>, open wires remained after extraction are put
135   //! into <open>.
136   //! If <shared> is True extraction is performed only when
137   //! edges share the same vertex.
138   //! If <shared> is False connection is performed only when
139   //! ends of the edges are at distance less than <toler>.
140   Standard_EXPORT static void SplitWires (const Handle(TopTools_HSequenceOfShape)& wires, const Standard_Real toler, const Standard_Boolean shared, Handle(TopTools_HSequenceOfShape)& closed, Handle(TopTools_HSequenceOfShape)& open);
141   
142   //! Dispatches sequence of <wires> into two compounds
143   //! <closed> for closed wires and <open> for open wires.
144   //! If a compound is not empty wires are added into it.
145   Standard_EXPORT static void DispatchWires (const Handle(TopTools_HSequenceOfShape)& wires, TopoDS_Compound& closed, TopoDS_Compound& open);
146
147
148
149
150 protected:
151
152
153
154
155
156 private:
157
158   
159   Standard_EXPORT void SplitWires();
160
161
162   TopoDS_Compound myWires;
163   TopoDS_Compound myEdges;
164   Standard_Real myTolerance;
165   Standard_Boolean myShared;
166   Standard_Boolean mySplitClosed;
167   Standard_Boolean mySplitOpen;
168
169
170 };
171
172
173 #include <ShapeAnalysis_FreeBounds.lxx>
174
175
176
177
178
179 #endif // _ShapeAnalysis_FreeBounds_HeaderFile