|
|
|||
File indexing completed on 2026-10-05 09:22:04
0001 // Created on: 1992-03-23 0002 // Created by: Herve LEGRAND 0003 // Copyright (c) 1992-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _GCPnts_UniformDeflection_HeaderFile 0018 #define _GCPnts_UniformDeflection_HeaderFile 0019 0020 #include <StdFail_NotDone.hxx> 0021 #include <NCollection_Sequence.hxx> 0022 #include <gp_Pnt.hxx> 0023 0024 class Adaptor3d_Curve; 0025 class Adaptor2d_Curve2d; 0026 class gp_Pnt; 0027 0028 //! Provides an algorithm to compute a distribution of 0029 //! points on a 'C2' continuous curve. 0030 //! The algorithm respects a criterion of maximum deflection between 0031 //! the curve and the polygon that results from the computed points. 0032 //! Note: This algorithm is relatively time consuming. 0033 //! A GCPnts_QuasiUniformDeflection algorithm is quicker; 0034 //! it can also work with non-'C2' continuous curves, 0035 //! but it generates more points in the distribution. 0036 class GCPnts_UniformDeflection 0037 { 0038 public: 0039 DEFINE_STANDARD_ALLOC 0040 0041 //! Constructs an empty algorithm. 0042 //! To define the problem to be solved, use the function Initialize. 0043 Standard_EXPORT GCPnts_UniformDeflection(); 0044 0045 //! Computes a uniform Deflection distribution of points on the curve. 0046 //! @param[in] theC input 3D curve 0047 //! @param[in] theDeflection target deflection 0048 //! @param[in] theWithControl when TRUE, the algorithm controls the estimate deflection 0049 Standard_EXPORT GCPnts_UniformDeflection(const Adaptor3d_Curve& theC, 0050 const double theDeflection, 0051 const bool theWithControl = true); 0052 0053 //! Computes a uniform Deflection distribution of points on the curve. 0054 //! @param[in] theC input 2D curve 0055 //! @param[in] theDeflection target deflection 0056 //! @param[in] theWithControl when TRUE, the algorithm controls the estimate deflection 0057 Standard_EXPORT GCPnts_UniformDeflection(const Adaptor2d_Curve2d& theC, 0058 const double theDeflection, 0059 const bool theWithControl = true); 0060 0061 //! Computes a Uniform Deflection distribution of points on a part of the curve. 0062 //! @param[in] theC input 3D curve 0063 //! @param[in] theDeflection target deflection 0064 //! @param[in] theU1 first parameter on curve 0065 //! @param[in] theU2 last parameter on curve 0066 //! @param[in] theWithControl when TRUE, the algorithm controls the estimate deflection 0067 Standard_EXPORT GCPnts_UniformDeflection(const Adaptor3d_Curve& theC, 0068 const double theDeflection, 0069 const double theU1, 0070 const double theU2, 0071 const bool theWithControl = true); 0072 0073 //! Computes a Uniform Deflection distribution of points on a part of the curve. 0074 //! @param[in] theC input 2D curve 0075 //! @param[in] theDeflection target deflection 0076 //! @param[in] theU1 first parameter on curve 0077 //! @param[in] theU2 last parameter on curve 0078 //! @param[in] theWithControl when TRUE, the algorithm controls the estimate deflection 0079 Standard_EXPORT GCPnts_UniformDeflection(const Adaptor2d_Curve2d& theC, 0080 const double theDeflection, 0081 const double theU1, 0082 const double theU2, 0083 const bool theWithControl = true); 0084 0085 //! Initialize the algorithms with 3D curve and deflection. 0086 Standard_EXPORT void Initialize(const Adaptor3d_Curve& theC, 0087 const double theDeflection, 0088 const bool theWithControl = true); 0089 0090 //! Initialize the algorithms with 2D curve and deflection. 0091 Standard_EXPORT void Initialize(const Adaptor2d_Curve2d& theC, 0092 const double theDeflection, 0093 const bool theWithControl = true); 0094 0095 //! Initialize the algorithms with 3D curve, deflection, parameter range. 0096 Standard_EXPORT void Initialize(const Adaptor3d_Curve& theC, 0097 const double theDeflection, 0098 const double theU1, 0099 const double theU2, 0100 const bool theWithControl = true); 0101 0102 //! Initialize the algorithms with curve, deflection, parameter range. 0103 //! This and the above methods initialize (or reinitialize) this algorithm and 0104 //! compute a distribution of points: 0105 //! - on the curve theC, or 0106 //! - on the part of curve theC limited by the two parameter values theU1 and theU2, 0107 //! where the maximum distance between theC and the 0108 //! polygon that results from the points of the 0109 //! distribution is not greater than theDeflection. 0110 //! The first point of the distribution is either the origin 0111 //! of curve theC or the point of parameter theU1. 0112 //! The last point of the distribution is either the end point of 0113 //! curve theC or the point of parameter theU2. 0114 //! Intermediate points of the distribution are built using 0115 //! interpolations of segments of the curve limited at the 2nd degree. 0116 //! The construction ensures, in a first step, 0117 //! that the chordal deviation for this 0118 //! interpolation of the curve is less than or equal to theDeflection. 0119 //! However, it does not ensure that the chordal deviation 0120 //! for the curve itself is less than or equal to theDeflection. 0121 //! To do this a check is necessary, 0122 //! which may generate (second step) additional intermediate points. 0123 //! This check is time consuming, and can be avoided by setting theWithControl to false. 0124 //! Note that by default theWithControl is true and check is performed. 0125 //! Use the function IsDone to verify that the computation was successful, 0126 //! the function NbPoints() to obtain the number of points of the computed distribution, 0127 //! and the function Parameter to read the parameter of each point. 0128 //! 0129 //! Warning 0130 //! - theC is necessary, 'C2' continuous. 0131 //! This property is not checked at construction time. 0132 //! - The roles of theU1 and theU2 are inverted if theU1 > theU2. 0133 //! 0134 //! Warning 0135 //! theC is an adapted curve, i.e. an object which is an interface between: 0136 //! - the services provided by either a 2D curve from 0137 //! the package Geom2d (in the case of an Adaptor2d_Curve2d curve) 0138 //! or a 3D curve from the package Geom (in the case of an Adaptor3d_Curve curve), 0139 //! - and those required on the curve by the computation algorithm. 0140 Standard_EXPORT void Initialize(const Adaptor2d_Curve2d& theC, 0141 const double theDeflection, 0142 const double theU1, 0143 const double theU2, 0144 const bool theWithControl = true); 0145 0146 //! Returns true if the computation was successful. 0147 //! IsDone is a protection against: 0148 //! - non-convergence of the algorithm 0149 //! - querying the results before computation. 0150 bool IsDone() const { return myDone; } 0151 0152 //! Returns the number of points of the distribution 0153 //! computed by this algorithm. 0154 //! Exceptions 0155 //! StdFail_NotDone if this algorithm has not been 0156 //! initialized, or if the computation was not successful. 0157 int NbPoints() const 0158 { 0159 StdFail_NotDone_Raise_if(!myDone, "GCPnts_UniformDeflection::NbPoints()"); 0160 return myParams.Length(); 0161 } 0162 0163 //! Returns the parameter of the point of index Index in 0164 //! the distribution computed by this algorithm. 0165 //! Warning 0166 //! Index must be greater than or equal to 1, and less 0167 //! than or equal to the number of points of the 0168 //! distribution. However, pay particular attention as this 0169 //! condition is not checked by this function. 0170 //! Exceptions 0171 //! StdFail_NotDone if this algorithm has not been 0172 //! initialized, or if the computation was not successful. 0173 double Parameter(const int Index) const 0174 { 0175 StdFail_NotDone_Raise_if(!myDone, "GCPnts_UniformDeflection::Parameter()"); 0176 return myParams(Index); 0177 } 0178 0179 //! Returns the point of index Index in the distribution 0180 //! computed by this algorithm. 0181 //! Warning 0182 //! Index must be greater than or equal to 1, and less 0183 //! than or equal to the number of points of the 0184 //! distribution. However, pay particular attention as this 0185 //! condition is not checked by this function. 0186 //! Exceptions 0187 //! StdFAil_NotDone if this algorithm has not been 0188 //! initialized, or if the computation was not successful. 0189 Standard_EXPORT gp_Pnt Value(const int Index) const; 0190 0191 //! Returns the deflection between the curve and the 0192 //! polygon resulting from the points of the distribution 0193 //! computed by this algorithm. 0194 //! This value is the one given to the algorithm at the 0195 //! time of construction (or initialization). 0196 //! Exceptions 0197 //! StdFail_NotDone if this algorithm has not been 0198 //! initialized, or if the computation was not successful. 0199 double Deflection() const 0200 { 0201 StdFail_NotDone_Raise_if(!myDone, "GCPnts_UniformDeflection::Deflection()"); 0202 return myDeflection; 0203 } 0204 0205 private: 0206 //! Initialize the algorithm. 0207 template <class TheCurve> 0208 void initialize(const TheCurve& theC, 0209 const double theDeflection, 0210 const double theU1, 0211 const double theU2, 0212 const bool theWithControl); 0213 0214 private: 0215 bool myDone; 0216 double myDeflection; 0217 NCollection_Sequence<double> myParams; 0218 NCollection_Sequence<gp_Pnt> myPoints; 0219 }; 0220 0221 #endif // _GCPnts_UniformDeflection_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|