0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / ChFi2d / ChFi2d_Builder.hxx
1 // Created on: 1995-06-12
2 // Created by: Joelle CHAUVET
3 // Copyright (c) 1995-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 _ChFi2d_Builder_HeaderFile
18 #define _ChFi2d_Builder_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <ChFi2d_ConstructionError.hxx>
25 #include <TopoDS_Face.hxx>
26 #include <TopTools_SequenceOfShape.hxx>
27 #include <TopTools_DataMapOfShapeShape.hxx>
28 #include <Standard_Real.hxx>
29 #include <Standard_Boolean.hxx>
30 #include <Standard_Integer.hxx>
31 class TopoDS_Face;
32 class TopoDS_Edge;
33 class TopoDS_Vertex;
34
35
36 //! This  class contains  the algorithm  used to build
37 //! fillet on planar wire.
38 class ChFi2d_Builder 
39 {
40 public:
41
42   DEFINE_STANDARD_ALLOC
43
44   
45   Standard_EXPORT ChFi2d_Builder();
46   
47   //! The face  <F> can be build  on a closed or an open
48   //! wire.
49   Standard_EXPORT ChFi2d_Builder(const TopoDS_Face& F);
50   
51   Standard_EXPORT void Init (const TopoDS_Face& F);
52   
53   Standard_EXPORT void Init (const TopoDS_Face& RefFace, const TopoDS_Face& ModFace);
54   
55   //! Add  a fillet  of   radius  <Radius> on  the  wire
56   //! between the two edges connected to the vertex <V>.
57   //! <AddFillet> returns the  fillet edge. The returned
58   //! edge has  sense only   if the status   <status> is
59   //! <IsDone>
60   Standard_EXPORT TopoDS_Edge AddFillet (const TopoDS_Vertex& V, const Standard_Real Radius);
61   
62   //! modify the fillet radius and return the new fillet
63   //! edge. this    edge has sense  only if   the status
64   //! <status> is <IsDone>.
65   Standard_EXPORT TopoDS_Edge ModifyFillet (const TopoDS_Edge& Fillet, const Standard_Real Radius);
66   
67   //! removes the fillet <Fillet> and returns the vertex
68   //! connecting the two adjacent edges to  this fillet.
69   Standard_EXPORT TopoDS_Vertex RemoveFillet (const TopoDS_Edge& Fillet);
70   
71   //! Add a chamfer on  the  wire between the two  edges
72   //! connected <E1> and  <E2>. <AddChamfer> returns the
73   //! chamfer  edge. This  edge  has  sense only if  the
74   //! status <status> is <IsDone>.
75   Standard_EXPORT TopoDS_Edge AddChamfer (const TopoDS_Edge& E1, const TopoDS_Edge& E2, const Standard_Real D1, const Standard_Real D2);
76   
77   //! Add  a chamfer on the   wire between the two edges
78   //! connected to the vertex <V>. The chamfer will make
79   //! an  angle <Ang> with the edge  <E>, and one of its
80   //! extremities  will be on  <E>  at distance <D>. The
81   //! returned   edge has sense   only   if the   status
82   //! <status> is <IsDone>.
83   //! Warning: The value of <Ang> must be expressed in Radian.
84   Standard_EXPORT TopoDS_Edge AddChamfer (const TopoDS_Edge& E, const TopoDS_Vertex& V, const Standard_Real D, const Standard_Real Ang);
85   
86   //! modify the chamfer <Chamfer>  and returns  the new
87   //! chamfer edge.
88   //! This edge as sense only  if the status <status> is
89   //! <IsDone>.
90   Standard_EXPORT TopoDS_Edge ModifyChamfer (const TopoDS_Edge& Chamfer, const TopoDS_Edge& E1, const TopoDS_Edge& E2, const Standard_Real D1, const Standard_Real D2);
91   
92   //! modify the  chamfer <Chamfer>  and returns the new
93   //! chamfer edge. This    edge as sense  only   if the
94   //! status <status>   is  <IsDone>.
95   //! Warning: The value of <Ang> must be expressed in Radian.
96   Standard_EXPORT TopoDS_Edge ModifyChamfer (const TopoDS_Edge& Chamfer, const TopoDS_Edge& E, const Standard_Real D, const Standard_Real Ang);
97   
98   //! removes   the chamfer  <Chamfer>   and returns the
99   //! vertex connecting  the two adjacent  edges to this
100   //! chamfer.
101   Standard_EXPORT TopoDS_Vertex RemoveChamfer (const TopoDS_Edge& Chamfer);
102   
103   //! returns the modified face
104     TopoDS_Face Result() const;
105   
106     Standard_Boolean IsModified (const TopoDS_Edge& E) const;
107   
108   //! returns the list of new edges
109     const TopTools_SequenceOfShape& FilletEdges() const;
110   
111     Standard_Integer NbFillet() const;
112   
113   //! returns the list of new edges
114     const TopTools_SequenceOfShape& ChamferEdges() const;
115   
116     Standard_Integer NbChamfer() const;
117   
118     Standard_Boolean HasDescendant (const TopoDS_Edge& E) const;
119   
120   //! returns the modified edge if <E> has descendant or
121   //! <E> in the other case.
122     const TopoDS_Edge& DescendantEdge (const TopoDS_Edge& E) const;
123   
124   //! Returns the parent edge of  <E>
125   //! Warning: If <E>is a basis edge,  the returned edge would be
126   //! equal to <E>
127   Standard_EXPORT const TopoDS_Edge& BasisEdge (const TopoDS_Edge& E) const;
128   
129     ChFi2d_ConstructionError Status() const;
130
131
132
133
134 protected:
135
136
137
138
139
140 private:
141
142   
143   //! Is internaly used by <AddFillet>.
144   //! Warning: <TrimE1>, <TrimE2>, <Fillet> has sense only if the
145   //! status <status> is equal to <IsDone>
146   Standard_EXPORT void ComputeFillet (const TopoDS_Vertex& V, const TopoDS_Edge& E1, const TopoDS_Edge& E2, const Standard_Real Radius, TopoDS_Edge& TrimE1, TopoDS_Edge& TrimE2, TopoDS_Edge& Fillet);
147   
148   //! Is internaly used by  <AddChamfer>. The chamfer is
149   //! computed  from  a  vertex,   two  edges   and  two
150   //! distances
151   //! Warning: <TrimE1>, <TrimE2> and <Chamfer> has sense only if
152   //! if the status <status> is equal to <IsDone>
153   Standard_EXPORT void ComputeChamfer (const TopoDS_Vertex& V, const TopoDS_Edge& E1, const TopoDS_Edge& E2, const Standard_Real D1, const Standard_Real D2, TopoDS_Edge& TrimE1, TopoDS_Edge& TrimE2, TopoDS_Edge& Chamfer);
154   
155   //! Is internaly used by <AddChamfer>.  The chamfer is
156   //! computed from   an  edge,  a  vertex,   a distance
157   //! and an angle
158   //! Warning: <TrimE1>,  <TrimE2>, and <Chamfer> has
159   //! sense only   if  the status <status> is   equal to
160   //! <IsDone>
161   Standard_EXPORT void ComputeChamfer (const TopoDS_Vertex& V, const TopoDS_Edge& E1, const Standard_Real D, const Standard_Real Ang, const TopoDS_Edge& E2, TopoDS_Edge& TrimE1, TopoDS_Edge& TrimE2, TopoDS_Edge& Chamfer);
162   
163   //! Is   internaly  used     by  <ComputeFillet>.
164   //! <NewExtr1> and  <NewExtr2>  will  contains the new
165   //! extremities of <AdjEdge1> and <AdjEdge2>
166   //! Warning: The  returned  edge has sense   only if the status
167   //! <status> is equal to <IsDone>
168   //! or to one of those specific cases :
169   //! <FirstEdgeDegenerated>
170   //! <LastEdgeDegenerated>
171   //! <BothEdgesDegenerated>
172   Standard_EXPORT TopoDS_Edge BuildFilletEdge (const TopoDS_Vertex& V, const TopoDS_Edge& AdjEdge1, const TopoDS_Edge& AdjEdge2, const Standard_Real Radius, TopoDS_Vertex& NewExtr1, TopoDS_Vertex& NewExtr2);
173   
174   //! Is   internaly  used     by  <ComputeFillet>.
175   //! <NewExtr1> and  <NewExtr2>  will  contains the new
176   //! extremities of <AdjEdge1> and <AdjEdge2>
177   //! Warning: The  returned  edge has sense   only if the status
178   //! <status> is equal to <IsDone>
179   Standard_EXPORT TopoDS_Edge BuildChamferEdge (const TopoDS_Vertex& V, const TopoDS_Edge& AdjEdge1, const TopoDS_Edge& AdjEdge2, const Standard_Real D1, const Standard_Real D2, TopoDS_Vertex& NewExtr1, TopoDS_Vertex& NewExtr2);
180   
181   //! Is   internaly  used     by  <ComputeFillet>.
182   //! <NewExtr1> and  <NewExtr2>  will  contains the new
183   //! extremities of <AdjEdge1> and <AdjEdge2>
184   //! Warning: The  returned  edge has sense   only if the status
185   //! <status> is equal to <IsDone>
186   Standard_EXPORT TopoDS_Edge BuildChamferEdge (const TopoDS_Vertex& V, const TopoDS_Edge& AdjEdge2, const Standard_Real D, const Standard_Real Ang, const TopoDS_Edge& AdjEdge1, TopoDS_Vertex& NewExtr1, TopoDS_Vertex& NewExtr2);
187   
188   //! replaces in  the  new face  <newFace> <OldE1>  and
189   //! <OldE2>  by <E1>, <Fillet> and <E2>
190   //! or by <Fillet> and <E2> if <E1> is degenerated
191   //! or by <E1> and <Fillet> if <E2> is degenerated
192   //! or by <Fillet> if <E1> and <E2> are degenerated .
193   Standard_EXPORT void BuildNewWire (const TopoDS_Edge& OldE1, const TopoDS_Edge& OldE2, const TopoDS_Edge& E1, const TopoDS_Edge& Fillet, const TopoDS_Edge& E2);
194   
195   //! Changes <OldExtr> of <E1> by <NewExtr>
196   Standard_EXPORT TopoDS_Edge BuildNewEdge (const TopoDS_Edge& E1, const TopoDS_Vertex& OldExtr, const TopoDS_Vertex& NewExtr) const;
197   
198   //! Changes <OldExtr> of <E1> by <NewExtr>
199   //! returns E1 and IsDegenerated = Standard_True
200   //! if the new edge is degenerated
201   Standard_EXPORT TopoDS_Edge BuildNewEdge (const TopoDS_Edge& E1, const TopoDS_Vertex& OldExtr, const TopoDS_Vertex& NewExtr, Standard_Boolean& IsDegenerated) const;
202   
203   //! Writes <NewEdge> in  <fillets> if <Id> is equal to
204   //! 1, or in <chamfers> if <Id> is Equal to 2.
205   //! Writes  the  modifications  in  <history> :
206   //! <TrimE1> is given by <E1>, <TrimE2> by <E2>
207   //! if <TrimE1> and <TrimE2> are not degenerated.
208   Standard_EXPORT void UpDateHistory (const TopoDS_Edge& E1, const TopoDS_Edge& E2, const TopoDS_Edge& TrimE1, const TopoDS_Edge& TrimE2, const TopoDS_Edge& NewEdge, const Standard_Integer Id);
209   
210   //! Writes the  modifications in  <history> . <TrimE1>
211   //! is given by <E1>, <TrimE2> by <E2>.
212   Standard_EXPORT void UpDateHistory (const TopoDS_Edge& E1, const TopoDS_Edge& E2, const TopoDS_Edge& TrimE1, const TopoDS_Edge& TrimE2);
213   
214   Standard_EXPORT Standard_Boolean IsAFillet (const TopoDS_Edge& E) const;
215   
216   Standard_EXPORT Standard_Boolean IsAChamfer (const TopoDS_Edge& E) const;
217
218
219   ChFi2d_ConstructionError status;
220   TopoDS_Face refFace;
221   TopoDS_Face newFace;
222   TopTools_SequenceOfShape fillets;
223   TopTools_SequenceOfShape chamfers;
224   TopTools_DataMapOfShapeShape history;
225
226
227 };
228
229
230 #include <ChFi2d_Builder.lxx>
231
232
233
234
235
236 #endif // _ChFi2d_Builder_HeaderFile