0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / ChFi2d / ChFi2d_AnaFilletAlgo.hxx
1 // Created on: 2013-05-20
2 // Created by: Vlad ROMASHKO
3 // Copyright (c) 2003-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _ANAFILLETALGO_H_
17 #define _ANAFILLETALGO_H_
18
19 #include <TopoDS_Wire.hxx>
20 #include <TopoDS_Edge.hxx>
21 #include <gp_Pln.hxx>
22
23 //! An analytical algorithm for calculation of the fillets.
24 //! It is implemented for segments and arcs of circle only.
25 class ChFi2d_AnaFilletAlgo
26 {
27 public:
28
29   //! An empty constructor.
30   //! Use the method Init() to initialize the class.
31   Standard_EXPORT ChFi2d_AnaFilletAlgo();
32
33   //! A constructor.
34   //! It expects a wire consisting of two edges of type (any combination of):
35   //! - segment
36   //! - arc of circle.
37   Standard_EXPORT ChFi2d_AnaFilletAlgo(const TopoDS_Wire& theWire, 
38                                        const gp_Pln& thePlane);
39
40   //! A constructor.
41   //! It expects two edges having a common point of type:
42   //! - segment
43   //! - arc of circle.
44   Standard_EXPORT ChFi2d_AnaFilletAlgo(const TopoDS_Edge& theEdge1, 
45                                        const TopoDS_Edge& theEdge2,
46                                        const gp_Pln& thePlane);
47
48   //! Initializes the class by a wire consisting of two edges.
49   Standard_EXPORT void Init(const TopoDS_Wire& theWire, const gp_Pln& thePlane);
50
51   //! Initializes the class by two edges.
52   Standard_EXPORT void Init(const TopoDS_Edge& theEdge1, const TopoDS_Edge& theEdge2, 
53                             const gp_Pln& thePlane);
54
55   //! Calculates a fillet.
56   Standard_EXPORT Standard_Boolean Perform(const Standard_Real radius);
57
58   //! Retrieves a result (fillet and shrinked neighbours).
59   Standard_EXPORT const TopoDS_Edge& Result(TopoDS_Edge& e1, TopoDS_Edge& e2);
60
61 private:
62
63   // WW5 method to compute fillet.
64   // It returns a constructed fillet definition:
65   //     center point (xc, yc)
66   //     point on the 1st segment (xstart, ystart)
67   //     point on the 2nd segment (xend, yend)
68   //     is the arc of fillet clockwise (cw = true) or counterclockwise (cw = false).
69   Standard_Boolean SegmentFilletSegment(const Standard_Real radius, 
70                                         Standard_Real& xc, Standard_Real& yc, 
71                                         Standard_Boolean& cw,
72                                         Standard_Real& start, Standard_Real& end);
73
74   // A function constructs a fillet between a segment and an arc.
75   Standard_Boolean SegmentFilletArc(const Standard_Real radius, 
76                                     Standard_Real& xc, Standard_Real& yc, 
77                                     Standard_Boolean& cw,
78                                     Standard_Real& start, Standard_Real& end, 
79                                     Standard_Real& xend, Standard_Real& yend);
80
81   // A function constructs a fillet between an arc and a segment.
82   Standard_Boolean ArcFilletSegment(const Standard_Real radius, 
83                                     Standard_Real& xc, Standard_Real& yc, 
84                                     Standard_Boolean& cw,
85                                     Standard_Real& start, Standard_Real& end, 
86                                     Standard_Real& xstart, Standard_Real& ystart);
87
88   // WW5 method to compute fillet: arc - arc.
89   // It returns a constructed fillet definition:
90   //     center point (xc, yc)
91   //     shrinking parameter of the 1st circle (start)
92   //     shrinking parameter of the 2nd circle (end)
93   //     if the arc of fillet clockwise (cw = true) or counterclockwise (cw = false).
94   Standard_Boolean ArcFilletArc(const Standard_Real radius, 
95                                 Standard_Real& xc, Standard_Real& yc, 
96                                 Standard_Boolean& cw,
97                                 Standard_Real& start, Standard_Real& end);
98
99   // Cuts intersecting edges of a contour.
100   Standard_Boolean Cut(const gp_Pln& plane, TopoDS_Edge& e1, TopoDS_Edge& e2);
101
102   // Plane.
103   gp_Pln           plane;
104
105   // Left neighbour.
106   TopoDS_Edge      e1;
107   Standard_Boolean segment1;
108   Standard_Real    x11;
109   Standard_Real    y11;
110   Standard_Real    x12;
111   Standard_Real    y12;
112   Standard_Real    xc1;
113   Standard_Real    yc1;
114   Standard_Real    radius1;
115   Standard_Boolean cw1;
116
117   // Right neighbour.
118   TopoDS_Edge      e2;
119   Standard_Boolean segment2;
120   Standard_Real    x21;
121   Standard_Real    y21;
122   Standard_Real    x22;
123   Standard_Real    y22;
124   Standard_Real    xc2;
125   Standard_Real    yc2;
126   Standard_Real    radius2;
127   Standard_Boolean cw2;
128
129   // Fillet (result).
130   TopoDS_Edge fillet;
131   TopoDS_Edge shrinke1;
132   TopoDS_Edge shrinke2;
133 };
134
135 #endif // _ANAFILLETALGO_H_