Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-25 09:19:26

0001 // Created on: 2013-05-20
0002 // Created by: Vlad ROMASHKO
0003 // Copyright (c) 2003-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef ChFi2d_AnaFilletAlgo_HeaderFile
0017 #define ChFi2d_AnaFilletAlgo_HeaderFile
0018 
0019 #include <TopoDS_Wire.hxx>
0020 #include <TopoDS_Edge.hxx>
0021 #include <gp_Pln.hxx>
0022 
0023 //! An analytical algorithm for calculation of the fillets.
0024 //! It is implemented for segments and arcs of circle only.
0025 class ChFi2d_AnaFilletAlgo
0026 {
0027 public:
0028   //! An empty constructor.
0029   //! Use the method Init() to initialize the class.
0030   Standard_EXPORT ChFi2d_AnaFilletAlgo();
0031 
0032   //! A constructor.
0033   //! It expects a wire consisting of two edges of type (any combination of):
0034   //! - segment
0035   //! - arc of circle.
0036   Standard_EXPORT ChFi2d_AnaFilletAlgo(const TopoDS_Wire& theWire, const gp_Pln& thePlane);
0037 
0038   //! A constructor.
0039   //! It expects two edges having a common point of type:
0040   //! - segment
0041   //! - arc of circle.
0042   Standard_EXPORT ChFi2d_AnaFilletAlgo(const TopoDS_Edge& theEdge1,
0043                                        const TopoDS_Edge& theEdge2,
0044                                        const gp_Pln&      thePlane);
0045 
0046   //! Initializes the class by a wire consisting of two edges.
0047   Standard_EXPORT void Init(const TopoDS_Wire& theWire, const gp_Pln& thePlane);
0048 
0049   //! Initializes the class by two edges.
0050   Standard_EXPORT void Init(const TopoDS_Edge& theEdge1,
0051                             const TopoDS_Edge& theEdge2,
0052                             const gp_Pln&      thePlane);
0053 
0054   //! Calculates a fillet.
0055   Standard_EXPORT bool Perform(const double radius);
0056 
0057   //! Retrieves a result (fillet and shrinked neighbours).
0058   Standard_EXPORT const TopoDS_Edge& Result(TopoDS_Edge& e1, TopoDS_Edge& e2);
0059 
0060 private:
0061   // WW5 method to compute fillet.
0062   // It returns a constructed fillet definition:
0063   //     center point (xc, yc)
0064   //     point on the 1st segment (xstart, ystart)
0065   //     point on the 2nd segment (xend, yend)
0066   //     is the arc of fillet clockwise (cw = true) or counterclockwise (cw = false).
0067   bool SegmentFilletSegment(const double radius,
0068                             double&      xc,
0069                             double&      yc,
0070                             bool&        cw,
0071                             double&      start,
0072                             double&      end);
0073 
0074   // A function constructs a fillet between a segment and an arc.
0075   bool SegmentFilletArc(const double radius,
0076                         double&      xc,
0077                         double&      yc,
0078                         bool&        cw,
0079                         double&      start,
0080                         double&      end,
0081                         double&      xend,
0082                         double&      yend);
0083 
0084   // A function constructs a fillet between an arc and a segment.
0085   bool ArcFilletSegment(const double radius,
0086                         double&      xc,
0087                         double&      yc,
0088                         bool&        cw,
0089                         double&      start,
0090                         double&      end,
0091                         double&      xstart,
0092                         double&      ystart);
0093 
0094   // WW5 method to compute fillet: arc - arc.
0095   // It returns a constructed fillet definition:
0096   //     center point (xc, yc)
0097   //     shrinking parameter of the 1st circle (start)
0098   //     shrinking parameter of the 2nd circle (end)
0099   //     if the arc of fillet clockwise (cw = true) or counterclockwise (cw = false).
0100   bool ArcFilletArc(const double radius,
0101                     double&      xc,
0102                     double&      yc,
0103                     bool&        cw,
0104                     double&      start,
0105                     double&      end);
0106 
0107   // Cuts intersecting edges of a contour.
0108   bool Cut(const gp_Pln& plane, TopoDS_Edge& e1, TopoDS_Edge& e2);
0109 
0110   // Plane.
0111   gp_Pln plane;
0112 
0113   // Left neighbour.
0114   TopoDS_Edge e1;
0115   bool        segment1;
0116   double      x11;
0117   double      y11;
0118   double      x12;
0119   double      y12;
0120   double      xc1;
0121   double      yc1;
0122   double      radius1;
0123   bool        cw1;
0124 
0125   // Right neighbour.
0126   TopoDS_Edge e2;
0127   bool        segment2;
0128   double      x21;
0129   double      y21;
0130   double      x22;
0131   double      y22;
0132   double      xc2;
0133   double      yc2;
0134   double      radius2;
0135   bool        cw2;
0136 
0137   // Fillet (result).
0138   TopoDS_Edge fillet;
0139   TopoDS_Edge shrinke1;
0140   TopoDS_Edge shrinke2;
0141 };
0142 
0143 #endif // _ANAFILLETALGO_H_