Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-28 09:20:23

0001 // Copyright (c) 2025 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _HelixBRep_BuilderHelix_HeaderFile
0015 #define _HelixBRep_BuilderHelix_HeaderFile
0016 
0017 #include <Standard.hxx>
0018 #include <Standard_DefineAlloc.hxx>
0019 #include <Standard_Handle.hxx>
0020 
0021 #include <gp_Ax3.hxx>
0022 #include <Standard_Integer.hxx>
0023 #include <Standard_Real.hxx>
0024 #include <GeomAbs_Shape.hxx>
0025 #include <TopoDS_Shape.hxx>
0026 #include <Standard_Boolean.hxx>
0027 #include <NCollection_Array1.hxx>
0028 #include <NCollection_List.hxx>
0029 
0030 #include <NCollection_HArray1.hxx>
0031 class gp_Ax1;
0032 class gp_Pnt;
0033 class TopoDS_Wire;
0034 class TopoDS_Edge;
0035 
0036 //! Implementation of building helix wire
0037 //! Values of Error Status returned by algo:
0038 //! 0 - OK
0039 //! 1 - object is just initialized, it means that no input parameters were set
0040 //! 2 - approximation fails
0041 //!
0042 //! 10 - R < tolerance - starting point is too close to axis
0043 //! 11 - step (Pitch) < tolerance
0044 //! 12 - Height < tolerance
0045 //! 13 - TaperAngle < 0 or TaperAngle > Pi/2 - TolAng
0046 //! Warning Status:
0047 //! 0 - OK
0048 //! 1 - tolerance reached by approximation > requested tolerance.
0049 class HelixBRep_BuilderHelix
0050 {
0051 public:
0052   DEFINE_STANDARD_ALLOC
0053 
0054   //! Empty constructor
0055   Standard_EXPORT HelixBRep_BuilderHelix();
0056   Standard_EXPORT virtual ~HelixBRep_BuilderHelix();
0057 
0058   //! Sets parameters of general composite helix
0059   Standard_EXPORT void SetParameters(const gp_Ax3&                     theAxis,
0060                                      const NCollection_Array1<double>& theDiams,
0061                                      const NCollection_Array1<double>& theHeights,
0062                                      const NCollection_Array1<double>& thePitches,
0063                                      const NCollection_Array1<bool>&   theIsPitches);
0064 
0065   //! Sets parameters of pure helix
0066   Standard_EXPORT void SetParameters(const gp_Ax3&                     theAxis,
0067                                      const double                      theDiam,
0068                                      const NCollection_Array1<double>& theHeights,
0069                                      const NCollection_Array1<double>& thePitches,
0070                                      const NCollection_Array1<bool>&   theIsPitches);
0071 
0072   //! Sets parameters of pure spiral
0073   Standard_EXPORT void SetParameters(const gp_Ax3&                     theAxis,
0074                                      const double                      theDiam1,
0075                                      const double                      theDiam2,
0076                                      const NCollection_Array1<double>& theHeights,
0077                                      const NCollection_Array1<double>& thePitches,
0078                                      const NCollection_Array1<bool>&   theIsPitches);
0079 
0080   //! Sets parameters of general composite helix
0081   Standard_EXPORT void SetParameters(const gp_Ax3&                     theAxis,
0082                                      const NCollection_Array1<double>& theDiams,
0083                                      const NCollection_Array1<double>& thePitches,
0084                                      const NCollection_Array1<double>& theNbTurns);
0085 
0086   //! Sets parameters of pure helix
0087   Standard_EXPORT void SetParameters(const gp_Ax3&                     theAxis,
0088                                      const double                      theDiam,
0089                                      const NCollection_Array1<double>& thePitches,
0090                                      const NCollection_Array1<double>& theNbTurns);
0091 
0092   //! Sets parameters of pure spiral
0093   Standard_EXPORT void SetParameters(const gp_Ax3&                     theAxis,
0094                                      const double                      theDiam1,
0095                                      const double                      theDiam2,
0096                                      const NCollection_Array1<double>& thePitches,
0097                                      const NCollection_Array1<double>& theNbTurns);
0098 
0099   //! Sets parameters for approximation
0100   Standard_EXPORT void SetApproxParameters(const double        theTolerance,
0101                                            const int           theMaxDegree,
0102                                            const GeomAbs_Shape theContinuity);
0103 
0104   //! Performs calculations
0105   Standard_EXPORT void Perform();
0106 
0107   //! Gets tolerance reached by approximation
0108   Standard_EXPORT double ToleranceReached() const;
0109 
0110   //! Returns error status of algorithm
0111   Standard_EXPORT int ErrorStatus() const;
0112 
0113   //! Returns warning status of algorithm
0114   Standard_EXPORT int WarningStatus() const;
0115 
0116   //! Gets result of algorithm
0117   Standard_EXPORT const TopoDS_Shape& Shape() const;
0118 
0119 protected:
0120   gp_Ax3                                   myAxis3;
0121   occ::handle<NCollection_HArray1<double>> myDiams;
0122   occ::handle<NCollection_HArray1<double>> myHeights;
0123   occ::handle<NCollection_HArray1<double>> myPitches;
0124   occ::handle<NCollection_HArray1<bool>>   myIsPitches;
0125   double                                   myTolerance;
0126   double                                   myTolReached;
0127   GeomAbs_Shape                            myContinuity;
0128   int                                      myMaxDegree;
0129   int                                      myMaxSegments;
0130   int                                      myErrorStatus;
0131   int                                      myWarningStatus;
0132   TopoDS_Shape                             myShape;
0133 
0134 private:
0135   Standard_EXPORT void BuildPart(const gp_Ax1& theAxis,
0136                                  const gp_Pnt& thePStart,
0137                                  const double  theHeight,
0138                                  const double  thePitch,
0139                                  const double  theTaperAngle,
0140                                  const bool    theIsClockwise,
0141                                  TopoDS_Wire&  thePart);
0142 
0143   Standard_EXPORT void Smoothing(NCollection_List<TopoDS_Shape>& theParts);
0144 
0145   Standard_EXPORT void SmoothingEdges(TopoDS_Edge& thePrev, TopoDS_Edge& theNext);
0146 
0147   int myNParts;
0148 };
0149 
0150 #endif // _HelixBRep_BuilderHelix_HeaderFile