Salome HOME
Merge from V5_1_4_BR 07/05/2010
[modules/geom.git] / src / GEOMImpl / GEOMImpl_Fillet1d.hxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 //  File   : GEOMImpl_Fillet1d.hxx
21 //  Module : GEOMImpl
22 //
23 #ifndef _GEOMImpl_Fillet1d_HeaderFile
24 #define _GEOMImpl_Fillet1d_HeaderFile
25
26 #include <gp_Pnt.hxx>
27 #include <Geom_Plane.hxx>
28 #include <Geom2d_Curve.hxx>
29
30 #include <TopoDS_Edge.hxx>
31 #include <TColStd_ListOfReal.hxx>
32 #include <TColStd_SequenceOfReal.hxx>
33 #include <TColStd_SequenceOfInteger.hxx>
34
35 class GEOMImpl_Fillet1dPoint;
36
37 /**
38 * GEOMImpl_Fillet1d is 1D fillet algorithm on two planar edges with given radius
39 */
40
41 class GEOMImpl_Fillet1d 
42 {
43 public:
44   //! Constructor
45   //! The fillet 1D algorithm initialise by two edges and plane
46   Standard_EXPORT GEOMImpl_Fillet1d(const TopoDS_Edge& theEdge1,
47                                     const TopoDS_Edge& theEdge2,
48                                     const gp_Pln&      thePlane);
49   //! Makes fillet with given radius
50   //! @returns Standard_True, if at least one result computed
51   Standard_EXPORT Standard_Boolean Perform(const Standard_Real theRadius);
52   //! Returns result fillet edge and modified edges as out parameters
53   Standard_EXPORT TopoDS_Edge Result(const gp_Pnt& thePoint, TopoDS_Edge& theEdge1, TopoDS_Edge& theEdge2);
54
55 private:
56   //! private methods
57   void fillPoint(GEOMImpl_Fillet1dPoint*);
58   void fillDiff(GEOMImpl_Fillet1dPoint*, Standard_Real, Standard_Boolean);
59   void performNewton(GEOMImpl_Fillet1dPoint*, GEOMImpl_Fillet1dPoint*);
60   Standard_Boolean processPoint(GEOMImpl_Fillet1dPoint*, GEOMImpl_Fillet1dPoint*, Standard_Real);
61
62
63 private:
64   //! private fields
65   TopoDS_Edge myEdge1, myEdge2;
66   Handle(Geom_Plane) myPlane;
67   Handle(Geom2d_Curve) myCurve1, myCurve2;
68   Standard_Real myStart1, myEnd1, myStart2, myEnd2, myRadius;
69   TColStd_ListOfReal myResultParams;
70   TColStd_SequenceOfInteger myResultOrientation;
71   Standard_Boolean myStartSide, myEdgesExchnged;
72 };
73
74
75 /**
76 * GEOMImpl_Fillet1dPoint is an internal class for 1D fillet algorithm
77 *   to store and compare computed solutions on edges
78 */
79
80 class GEOMImpl_Fillet1dPoint
81 {
82 public:
83   //! Puiblic methods
84
85   //! Constructor
86   Standard_EXPORT GEOMImpl_Fillet1dPoint(Standard_Real theParam)
87   {myParam = theParam;}
88   
89   //! Make copy of point
90   //!WARNING: Copies only field values: myParam, myV, myD, myValid
91   Standard_EXPORT GEOMImpl_Fillet1dPoint* Copy(); // warning: this is not the full copy! 
92
93   //! Set/Get parameter
94   Standard_EXPORT inline void SetParam(Standard_Real theParam)
95     {myParam = theParam;}
96   Standard_EXPORT inline Standard_Real GetParam() const
97     {return myParam;}
98   Standard_EXPORT inline void SetParam2(const Standard_Real theParam2)
99     {myParam2 = theParam2;}
100   Standard_EXPORT inline Standard_Real GetParam2()
101     { return myParam2 ; }
102
103   //! Returns validity  
104   Standard_EXPORT inline Standard_Boolean IsValid(int theIndex)
105     {return (Standard_Boolean)myValid.Value(theIndex);}
106
107   //! Get values
108   Standard_EXPORT inline Standard_Integer GetNBValues() {return myV.Length();}
109   Standard_EXPORT inline Standard_Real GetValue(Standard_Integer theIndex)
110     {return myV.Value(theIndex);}
111   Standard_EXPORT inline Standard_Real GetDiff(Standard_Integer theIndex)
112     {return myD.Value(theIndex);}
113   Standard_EXPORT inline Standard_Integer GetNear(Standard_Integer theIndex)
114     {return myNear.Value(theIndex);}
115
116   //! Set/Get center point
117   Standard_EXPORT inline void SetCenter(const gp_Pnt2d thePoint)
118     {myCenter = thePoint;}
119   Standard_EXPORT inline const gp_Pnt2d GetCenter()
120     {return myCenter;}
121
122   Standard_EXPORT void AddValue(Standard_Real theValue, Standard_Boolean theIsValid);
123
124   //! compute difference between this and given point
125   Standard_EXPORT Standard_Boolean ComputeDifference(GEOMImpl_Fillet1dPoint*);
126   Standard_EXPORT void FilterPoints(GEOMImpl_Fillet1dPoint*);
127   
128   //! Check is point contains solution and  returns the index of them if any
129   Standard_EXPORT Standard_Integer HasSolution(Standard_Real theRadius); 
130   //! Remove solution by index
131   void RemoveSolution(Standard_Integer theIndex);
132
133 private:
134   //! Private fields
135   gp_Pnt2d myCenter;
136   Standard_Real myParam, myParam2;
137   TColStd_SequenceOfReal myV, myD;
138   TColStd_SequenceOfInteger myValid, myNear;
139 };
140
141 #endif